Selaa lähdekoodia

财务结算-settlement account status keep same

yangzian 3 vuotta sitten
vanhempi
commit
a5e4919630

+ 72 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementInfoServiceImpl.java

@@ -3,6 +3,12 @@ package org.jeecg.ctop.finance.settlement.service.serviceImpl;
 import cn.afterturn.easypoi.excel.ExcelImportUtil;
 import cn.afterturn.easypoi.excel.entity.ImportParams;
 import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
+import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
+import cn.com.ctop.alarm.modules.service.impl.RuleAccountTemplateServiceImpl;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.service.impl.UserAllocationServiceImpl;
+import cn.com.ctop.common.module.utils.Check;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -13,11 +19,20 @@ import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementInfo;
 import org.jeecg.ctop.finance.settlement.entity.vo.AccountImportVo;
 import org.jeecg.ctop.finance.settlement.mapper.SettlementInfoMapper;
 import org.jeecg.ctop.finance.settlement.service.ISettlementInfoService;
+import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.client.RestTemplate;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -49,6 +64,9 @@ public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper,
         return Result.successMsg("财务结算-账户列表查询成功。", pageInfo);
     }
 
+
+    @Autowired
+    private UserAllocationServiceImpl userAllocationService;
     /**
      * @description: 财务结算-修改账户状态
      * @param id
@@ -58,10 +76,64 @@ public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper,
      */
     @Override
     public Result updSettlementStatusById(Long id, Integer status) {
+        // 修改状态
         settlementInfoMapper.updSettlementStatusById(id,status);
+
+        //同步 状态
+       CtopCwjsSettlementInfo settlementInfo =  settlementInfoMapper.selectById(id);
+        UserAllocation userAllocation = userAllocationService.getByAccountId(new Long(settlementInfo.getAccountId()));
+        userAllocation.setAccountStatus(status);
+        userAllocationService.editUserAlloCation(userAllocation);
+
         return Result.successMsg("财务结算-修改账户状态成功。", null);
     }
 
+
+/*
+    public Result<UserAllocation> edit(UserAllocation userAllocation) {
+        Result<UserAllocation> result = new Result<>();
+        UserAllocation userAllocationEntity = userAllocationService.getById(userAllocation.getId());
+        if (userAllocationEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = userAllocationService.updateById(userAllocation);
+            Integer accountStatus = userAllocation.getAccountStatus();
+            if (!Check.isNull(accountStatus)) {
+                if (accountStatus == 1) {
+                    QueryWrapper<RuleAccountTemplate> ruleAccountTemplateQueryWrapper = new QueryWrapper<>();
+                    ruleAccountTemplateQueryWrapper.eq("account_id", userAllocationEntity.getAccountId());
+                    RuleAccountTemplate updateRuleAccountTemplate = new RuleAccountTemplate();
+                    updateRuleAccountTemplate.setTemplateStatus(1);
+                    ruleAccountTemplateService.update(updateRuleAccountTemplate, ruleAccountTemplateQueryWrapper);
+                }
+            }
+
+            UserAllocation update = userAllocationService.getById(userAllocation.getId());
+            QueryWrapper<ProjectMember> memberQueryWrapper = new QueryWrapper<>();
+            memberQueryWrapper.eq("user_id", update.getUserId());
+            memberQueryWrapper.eq("project_id", update.getProjectId());
+            memberQueryWrapper.last("limit 1");
+            ProjectMember member = memberMapper.selectOne(memberQueryWrapper);
+            if (Check.isNull(member)) {
+                ProjectMember addMember = new ProjectMember();
+                addMember.setProjectId(userAllocationEntity.getProjectId());
+                addMember.setUserId(userAllocationEntity.getUserId());
+                addMember.setUserName(userAllocationEntity.getUserName());
+                String roleCode = sysRoleService.getRoleCodeByUserId(userAllocationEntity.getUserId());
+                if (!Check.isNull(roleCode)) {
+                    addMember.setRoleCode(roleCode);
+                }
+                projectMemberService.save(addMember);
+            }
+
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+        return result;
+    }
+    */
+
     /**
      *
      * @description: 删除

+ 5 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.common.api.vo.Result;
 
 import java.util.List;
 import java.util.Map;
@@ -68,4 +69,8 @@ public interface IUserAllocationService extends IService<UserAllocation> {
 
     List<Long> queryAutomaticAccounts(Long projectId);
 
+
+
+    Result<UserAllocation> editUserAlloCation(UserAllocation userAllocation);
+
 }

+ 64 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -1,8 +1,12 @@
 package cn.com.ctop.common.module.service.impl;
 
+import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
+import cn.com.ctop.alarm.modules.mapper.RuleAccountTemplateMapper;
 import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.SysRoleMapper;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
@@ -10,6 +14,9 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.ctop.entity.ProjectMember;
+import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -217,4 +224,61 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     public List<Long> queryAutomaticAccounts(Long projectId) {
         return userAllocationMapper.queryAutomaticAccounts(projectId);
     }
+
+    @Autowired
+    RuleAccountTemplateMapper ruleAccountTemplateMapper;
+
+    @Autowired
+    SysRoleMapper sysRoleMapper;
+
+    @Autowired
+    ProjectMemberMapper projectMemberMapper;
+
+    @Autowired
+    ProjectMemberMapper memberMapper;
+    @Override
+    public Result<UserAllocation> editUserAlloCation(UserAllocation userAllocation) {
+        Result<UserAllocation> result = new Result<>();
+        UserAllocation userAllocationEntity = userAllocationMapper.selectById(userAllocation.getId());
+        if (userAllocationEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            int ok = userAllocationMapper.updateById(userAllocation);
+            Integer accountStatus = userAllocation.getAccountStatus();
+            if (!Check.isNull(accountStatus)) {
+                if (accountStatus == 1) {
+                    QueryWrapper<RuleAccountTemplate> ruleAccountTemplateQueryWrapper = new QueryWrapper<>();
+                    ruleAccountTemplateQueryWrapper.eq("account_id", userAllocationEntity.getAccountId());
+                    RuleAccountTemplate updateRuleAccountTemplate = new RuleAccountTemplate();
+                    updateRuleAccountTemplate.setTemplateStatus(1);
+                    ruleAccountTemplateMapper.update(updateRuleAccountTemplate, ruleAccountTemplateQueryWrapper);
+                }
+            }
+
+            UserAllocation update = userAllocationMapper.selectById(userAllocation.getId());
+            QueryWrapper<ProjectMember> memberQueryWrapper = new QueryWrapper<>();
+            memberQueryWrapper.eq("user_id", update.getUserId());
+            memberQueryWrapper.eq("project_id", update.getProjectId());
+            memberQueryWrapper.last("limit 1");
+            ProjectMember member = memberMapper.selectOne(memberQueryWrapper);
+            if (Check.isNull(member)) {
+                ProjectMember addMember = new ProjectMember();
+                addMember.setProjectId(userAllocationEntity.getProjectId());
+                addMember.setUserId(userAllocationEntity.getUserId());
+                addMember.setUserName(userAllocationEntity.getUserName());
+                String roleCode = sysRoleMapper.getRoleCodeByUserId(userAllocationEntity.getUserId());
+                if (!Check.isNull(roleCode)) {
+                    addMember.setRoleCode(roleCode);
+                }
+                projectMemberMapper.insert(addMember);
+            }
+
+            if (ok == 1) {
+                result.success("修改成功!");
+            }
+        }
+        return result;
+    }
+
+
 }

+ 1 - 40
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java

@@ -535,46 +535,7 @@ public class UserAllocationController {
     @ApiOperation(value = "用户分配-编辑", notes = "用户分配-编辑")
     @PutMapping(value = "/edit")
     public Result<UserAllocation> edit(@RequestBody UserAllocation userAllocation) {
-        Result<UserAllocation> result = new Result<>();
-        UserAllocation userAllocationEntity = userAllocationService.getById(userAllocation.getId());
-        if (userAllocationEntity == null) {
-            result.error500("未找到对应实体");
-        } else {
-            boolean ok = userAllocationService.updateById(userAllocation);
-            Integer accountStatus = userAllocation.getAccountStatus();
-            if (!Check.isNull(accountStatus)) {
-                if (accountStatus == 1) {
-                    QueryWrapper<RuleAccountTemplate> ruleAccountTemplateQueryWrapper = new QueryWrapper<>();
-                    ruleAccountTemplateQueryWrapper.eq("account_id", userAllocationEntity.getAccountId());
-                    RuleAccountTemplate updateRuleAccountTemplate = new RuleAccountTemplate();
-                    updateRuleAccountTemplate.setTemplateStatus(1);
-                    ruleAccountTemplateService.update(updateRuleAccountTemplate, ruleAccountTemplateQueryWrapper);
-                }
-            }
-
-            UserAllocation update = userAllocationService.getById(userAllocation.getId());
-            QueryWrapper<ProjectMember> memberQueryWrapper = new QueryWrapper<>();
-            memberQueryWrapper.eq("user_id", update.getUserId());
-            memberQueryWrapper.eq("project_id", update.getProjectId());
-            memberQueryWrapper.last("limit 1");
-            ProjectMember member = memberMapper.selectOne(memberQueryWrapper);
-            if (Check.isNull(member)) {
-                ProjectMember addMember = new ProjectMember();
-                addMember.setProjectId(userAllocationEntity.getProjectId());
-                addMember.setUserId(userAllocationEntity.getUserId());
-                addMember.setUserName(userAllocationEntity.getUserName());
-                String roleCode = sysRoleService.getRoleCodeByUserId(userAllocationEntity.getUserId());
-                if (!Check.isNull(roleCode)) {
-                    addMember.setRoleCode(roleCode);
-                }
-                projectMemberService.save(addMember);
-            }
-
-            if (ok) {
-                result.success("修改成功!");
-            }
-        }
-        return result;
+        return userAllocationService.editUserAlloCation(userAllocation);
     }
 
     /**