|
@@ -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);
|
|
|
|
|
|
// 将原来所有父节点下数据关联到新的父节点下
|