Parcourir la source

07 30 8 fix some bugs

hr il y a 4 ans
Parent
commit
ada2c73b4a

+ 1 - 0
src/main/java/com/imed/costaccount/service/impl/AccountingServiceImpl.java

@@ -104,6 +104,7 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
             if (Objects.isNull(byId)) {
                 throw new CostException(500, "上层级别会计科目已被移除");
             }
+            // 如果父子节点的会计科目类型不一致,退出
             if (!byId.getAccountingType().equals(accountingSaveDTO.getAccountingType())) {
                 throw new CostException(500, "会计科目类型要与上层一致");
             }

+ 21 - 1
src/main/java/com/imed/costaccount/service/impl/ResponsibilityServiceImpl.java

@@ -138,6 +138,8 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
         if (Objects.isNull(center)) {
             throw new CostException(ErrorCodeEnum.DATA_NOT_EXIST);
         }
+
+
         // 如果修改父节点节点(只有两层的情况)
         if (center.getResponsibilityLevel() == 1) {
             this.updateParent(responsibilityEditDTO, center, user.getHospId());
@@ -170,7 +172,25 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
         this.checkCode(dto.getResponsibilityCode(), hospId);
         // 新增父节点数据
         Responsibility newResponsibility = BeanUtil.convertObj(dto, Responsibility.class);
-        newResponsibility.setId(null).setHospId(responsibility.getHospId()).setCreateTime(new Date().getTime()).setResponsibilityLevel(1);
+        newResponsibility.setId(null).setHospId(responsibility.getHospId()).setCreateTime(new Date().getTime()).setResponsibilityLevel(2);
+        // 相关校验
+        if (dto.getParentId() == 0) {
+            newResponsibility.setResponsibilityLevel(1);
+        }
+
+        // 如果是汇总中心,那么不存在分摊级别
+        Integer isGatherCenter = newResponsibility.getIsGatherCenter();
+        if (isGatherCenter == 1) {
+            newResponsibility.setShareId(null);
+            newResponsibility.setShareLevel(0);
+            newResponsibility.setShareName("");
+        }
+        // 父节点不允许为非汇总中心
+        Responsibility byId = this.getById(id);
+        if (Objects.nonNull(byId) && (byId.getIsGatherCenter() == 2)) {
+            throw new CostException(500, "非汇总中心不允许添加");
+        }
+
         this.save(newResponsibility);
 
         // 将原来所有父节点下数据关联到新的父节点下