Browse Source

无法修改合并计算的责任中心的分摊参数对应配置的问题修复

JammeyJiang 6 months ago
parent
commit
9f856b4f82

+ 25 - 4
src/main/java/com/kcim/service/impl/CostAccountShareServiceImpl.java

@@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.ObjectUtils;
 import org.springframework.util.StringUtils;
 import org.springframework.util.StringUtils;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
@@ -151,7 +152,7 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
     public void addCostAccountShare(CostAccountShareSaveDto costAccountShareSaveDto) {
     public void addCostAccountShare(CostAccountShareSaveDto costAccountShareSaveDto) {
         Long hospId = UserContext.getCurrentLoginHospId();
         Long hospId = UserContext.getCurrentLoginHospId();
         // 检验输入的数据的合理性
         // 检验输入的数据的合理性
-        checkAccountShare(costAccountShareSaveDto, hospId);
+        checkAccountShare(costAccountShareSaveDto, hospId,null);
         CostAccountShare costAccountShareRequest = BeanUtil.convertObj(costAccountShareSaveDto, CostAccountShare.class);
         CostAccountShare costAccountShareRequest = BeanUtil.convertObj(costAccountShareSaveDto, CostAccountShare.class);
         costAccountShareRequest.setHospId(hospId);
         costAccountShareRequest.setHospId(hospId);
         costAccountShareRequest.setCreateTime(System.currentTimeMillis());
         costAccountShareRequest.setCreateTime(System.currentTimeMillis());
@@ -164,7 +165,7 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
      * @param costAccountShareSaveDto
      * @param costAccountShareSaveDto
      * @param hospId
      * @param hospId
      */
      */
-    private void checkAccountShare(CostAccountShareSaveDto costAccountShareSaveDto, Long hospId) {
+    private void checkAccountShare(CostAccountShareSaveDto costAccountShareSaveDto, Long hospId,CostAccountShare oldCostAccountShare) {
         Long responsibilityId = costAccountShareSaveDto.getResponsibilityId();
         Long responsibilityId = costAccountShareSaveDto.getResponsibilityId();
         Responsibility responsibility = responsibilityService.getOne(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId).eq(Responsibility::getId, responsibilityId));
         Responsibility responsibility = responsibilityService.getOne(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId).eq(Responsibility::getId, responsibilityId));
         if (Objects.isNull(responsibility)) {
         if (Objects.isNull(responsibility)) {
@@ -174,7 +175,8 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
         costAccountShareSaveDto.setResponsibilityCode(responsibility.getResponsibilityCode());
         costAccountShareSaveDto.setResponsibilityCode(responsibility.getResponsibilityCode());
         costAccountShareSaveDto.setResponsibilityName(responsibility.getResponsibilityName());
         costAccountShareSaveDto.setResponsibilityName(responsibility.getResponsibilityName());
         costAccountShareSaveDto.setShareLevel(responsibility.getShareLevel());
         costAccountShareSaveDto.setShareLevel(responsibility.getShareLevel());
-        List<CostAccountShare> costAccountShareList = baseMapper.selectList(new QueryWrapper<CostAccountShare>().lambda().eq(CostAccountShare::getHospId, hospId).eq(CostAccountShare::getResponsibilityId, costAccountShareSaveDto.getResponsibilityId()));
+        //获取责任中心的其他设置记录
+        List<CostAccountShare> costAccountShareList = getResponsibilityOtherRecords(costAccountShareSaveDto,hospId,oldCostAccountShare);
         if (!StringUtils.isEmpty(costAccountShareSaveDto.getAccountingIds())) {
         if (!StringUtils.isEmpty(costAccountShareSaveDto.getAccountingIds())) {
             // 这个责任中心允许输入会计科目
             // 这个责任中心允许输入会计科目
             List<Long> accountIdList = Arrays.stream(costAccountShareSaveDto.getAccountingIds().split(StrUtil.COMMA)).map(Long::valueOf).collect(Collectors.toList());
             List<Long> accountIdList = Arrays.stream(costAccountShareSaveDto.getAccountingIds().split(StrUtil.COMMA)).map(Long::valueOf).collect(Collectors.toList());
@@ -235,6 +237,24 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
         }
         }
     }
     }
 
 
+    /**
+     * 获取责任中心的其他设置记录
+     * @param costAccountShareSaveDto
+     * @param hospId
+     * @param oldCostAccountShare
+     * @return
+     */
+    public List<CostAccountShare> getResponsibilityOtherRecords(CostAccountShareSaveDto costAccountShareSaveDto, Long hospId,CostAccountShare oldCostAccountShare){
+        LambdaQueryWrapper<CostAccountShare> costAccountShareQuery = new QueryWrapper<CostAccountShare>().lambda().eq(CostAccountShare::getHospId, hospId).eq(CostAccountShare::getResponsibilityId, costAccountShareSaveDto.getResponsibilityId());
+        //修改时需排除掉自己
+        if(!ObjectUtils.isEmpty(oldCostAccountShare)){
+            costAccountShareQuery=costAccountShareQuery.ne(CostAccountShare::getId,oldCostAccountShare.getId());
+        }
+        List<CostAccountShare> costAccountShareList = baseMapper.selectList(costAccountShareQuery);
+        return costAccountShareList;
+    }
+
+
     /**
     /**
      * 修改成本分摊参数对应表
      * 修改成本分摊参数对应表
      *
      *
@@ -253,9 +273,10 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
         // 新增责任中心成本对照数据
         // 新增责任中心成本对照数据
         CostAccountShareSaveDto costAccountShareSaveDto = BeanUtil.convertObj(costAccountShareEditDto, CostAccountShareSaveDto.class);
         CostAccountShareSaveDto costAccountShareSaveDto = BeanUtil.convertObj(costAccountShareEditDto, CostAccountShareSaveDto.class);
         // 检验输入的数据是否符合规则
         // 检验输入的数据是否符合规则
-        checkAccountShare(costAccountShareSaveDto, hospId);
+        checkAccountShare(costAccountShareSaveDto, hospId,costAccountShare);
         CostAccountShareEditDto accountShareEditDto = BeanUtil.convertObj(costAccountShareSaveDto, CostAccountShareEditDto.class);
         CostAccountShareEditDto accountShareEditDto = BeanUtil.convertObj(costAccountShareSaveDto, CostAccountShareEditDto.class);
         BeanUtil.convertObj(accountShareEditDto, costAccountShare);
         BeanUtil.convertObj(accountShareEditDto, costAccountShare);
+        costAccountShare.setId(costAccountShareEditDto.getId());
         baseMapper.updateById(costAccountShare);
         baseMapper.updateById(costAccountShare);
     }
     }
 
 

+ 5 - 0
src/main/java/com/kcim/service/impl/ResponsibilityDepartmentServiceImpl.java

@@ -123,6 +123,11 @@ public class ResponsibilityDepartmentServiceImpl
         });
         });
         //只取有对应科室数据的记录
         //只取有对应科室数据的记录
         List<ResponsibilityDepartIdVO> activeResponsibilityDeparts = responsibilityDepartIdVOS.stream().filter(responsibilityDepartIdVO -> !Objects.isNull(responsibilityDepartIdVO.getDepartmentCode())).collect(Collectors.toList());
         List<ResponsibilityDepartIdVO> activeResponsibilityDeparts = responsibilityDepartIdVOS.stream().filter(responsibilityDepartIdVO -> !Objects.isNull(responsibilityDepartIdVO.getDepartmentCode())).collect(Collectors.toList());
+        if(CollectionUtils.isEmpty(activeResponsibilityDeparts))
+        {
+            activeResponsibilityDeparts=new ArrayList<>();
+            return  activeResponsibilityDeparts;
+        }
         return  activeResponsibilityDeparts;
         return  activeResponsibilityDeparts;
     }
     }