Ver código fonte

成本分摊参数对应ID传递

ljx 4 anos atrás
pai
commit
e8ad8843ab

+ 19 - 11
src/main/java/com/imed/costaccount/service/impl/CostAccountShareServiceImpl.java

@@ -83,6 +83,7 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
         Integer hospId = user.getHospId();
         // 检验输入的数据的合理性
         checkAccountShare(costAccountShareSaveDto, hospId);
+
         CostAccountShare costAccountShareRequest = BeanUtil.convertObj(costAccountShareSaveDto, CostAccountShare.class);
         costAccountShareRequest.setHospId(hospId);
         costAccountShareRequest.setCreateTime(System.currentTimeMillis());
@@ -100,21 +101,29 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
         if (Objects.isNull(responsibility)){
             throw new CostException(500,"输入的责任不存在");
         }
+        costAccountShareSaveDto.setResponsibilityId(responsibilityId);
+        costAccountShareSaveDto.setResponsibilityCode(responsibility.getResponsibilityCode());
+        costAccountShareSaveDto.setResponsibilityName(responsibility.getResponsibilityName());
+        costAccountShareSaveDto.setShareLevel(responsibility.getShareLevel());
         if (costAccountShareSaveDto.getAccountingId() > 0){
             // 如果输入成本科目的情况下
             Accounting accounting = accountingService.getOne(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId).eq(Accounting::getId, costAccountShareSaveDto.getAccountingId()));
             if (Objects.isNull(accounting)){
                 throw new CostException(500,"输入的成本科目不存在");
+            }else {
+                costAccountShareSaveDto.setAccountingId(accounting.getId());
+                costAccountShareSaveDto.setAccountingName(accounting.getAccountingName());
+                costAccountShareSaveDto.setAccountingCode(accounting.getAccountingCode());
             }
-        }
-        // 检验输入的责任中心与匹配的成本科目是否存在
-        List<CostAccountShare> costAccountShareList = baseMapper.selectList(new QueryWrapper<CostAccountShare>().lambda().eq(CostAccountShare::getHospId,hospId));
-        Map<String, List<CostAccountShare>> costAccountMap = costAccountShareList.stream().collect(Collectors.groupingBy(CostAccountShare::getResponsibilityCode));
-        List<CostAccountShare> list = costAccountMap.get(costAccountShareSaveDto.getResponsibilityCode());
-        if (!CollectionUtils.isEmpty(list)){
-            String accountingCode = list.get(0).getAccountingCode();
-            if (accountingCode.equals(costAccountShareSaveDto.getAccountingCode())){
-                throw new CostException(500,"输入的责任中心对应的成本科目已存在");
+            // 检验输入的责任中心与匹配的成本科目是否存在
+            List<CostAccountShare> costAccountShareList = baseMapper.selectList(new QueryWrapper<CostAccountShare>().lambda().eq(CostAccountShare::getHospId,hospId));
+            Map<String, List<CostAccountShare>> costAccountMap = costAccountShareList.stream().collect(Collectors.groupingBy(CostAccountShare::getResponsibilityCode));
+            List<CostAccountShare> list = costAccountMap.get(costAccountShareSaveDto.getResponsibilityCode());
+            if (!CollectionUtils.isEmpty(list)){
+                String accountingCode = list.get(0).getAccountingCode();
+                if (accountingCode.equals(costAccountShareSaveDto.getAccountingCode())){
+                    throw new CostException(500,"输入的责任中心对应的成本科目已存在");
+                }
             }
         }
         // 检验输入的这个责任中心是否允许输入成本科目
@@ -126,12 +135,11 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
                 throw new CostException(500,"合并计算不允许选择成本科目");
             }
             if (costAccountShareSaveDto.getAccountingId()<= 0 && NumberConstant.ONE.equals(costShareLevel.getCalcType())){
-                throw new CostException(500,"分开计算需要选择成本科目");
+                throw new CostException(500,"分开计算的责任中心需要选择成本科目");
             }
         }else {
             throw new CostException(500,"对不起该责任中心没有对应分摊层级");
         }
-
     }
 
     /**