|
@@ -138,19 +138,90 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
|
|
|
if (Objects.isNull(center)) {
|
|
|
throw new CostException(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
|
}
|
|
|
- // 不管是哪个绑定到父级目录下
|
|
|
-// if (responsibilityEditDTO.getParentId() == 0) {
|
|
|
-//
|
|
|
+
|
|
|
+ // 判断是否有子节点
|
|
|
+ List<Responsibility> list = this.list(
|
|
|
+ new LambdaQueryWrapper<Responsibility>()
|
|
|
+ .eq(Responsibility::getHospId, user.getHospId())
|
|
|
+ .eq(Responsibility::getParentId, id)
|
|
|
+ );
|
|
|
+ // 如果不存在子节点 ,修改它本身
|
|
|
+ if (list.isEmpty()) {
|
|
|
+ this.updateCurResp(center, responsibilityEditDTO, user);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.updateParent(responsibilityEditDTO, center, user.getHospId());
|
|
|
+// // 不管是哪个绑定到父级目录下
|
|
|
+//// if (responsibilityEditDTO.getParentId() == 0) {
|
|
|
+////
|
|
|
+//// }
|
|
|
+////
|
|
|
+////
|
|
|
+//// // 如果修改父节点节点(只有两层的情况)
|
|
|
+// if (center.getResponsibilityLevel() == 1) {
|
|
|
+// this.updateParent(responsibilityEditDTO, center, user.getHospId());
|
|
|
+// return;
|
|
|
// }
|
|
|
-//
|
|
|
-//
|
|
|
-// // 如果修改父节点节点(只有两层的情况)
|
|
|
- if (center.getResponsibilityLevel() == 1) {
|
|
|
- this.updateParent(responsibilityEditDTO, center, user.getHospId());
|
|
|
- return;
|
|
|
+
|
|
|
+// this.updateCurrent(responsibilityEditDTO, center, user.getHospId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
|
|
|
+ public void updateAllResp(Responsibility center, ResponsibilityEditDTO dto, User user, List<Responsibility> list) {
|
|
|
+ // 删除原有的父节点数据
|
|
|
+ Integer id = dto.getId();
|
|
|
+ this.removeById(id);
|
|
|
+ this.checkCode(dto.getResponsibilityCode(), user.getHospId());
|
|
|
+ // 新增父节点数据
|
|
|
+ Responsibility newResponsibility = BeanUtil.convertObj(dto, Responsibility.class);
|
|
|
+ newResponsibility.setId(null).setHospId(user.getHospId()).setCreateTime(new Date().getTime()).setResponsibilityLevel(2);
|
|
|
+ // 相关校验
|
|
|
+ if (dto.getParentId() == 0) {
|
|
|
+ newResponsibility.setResponsibilityLevel(1);
|
|
|
}
|
|
|
|
|
|
- this.updateCurrent(responsibilityEditDTO, center, user.getHospId());
|
|
|
+ // 如果是汇总中心,那么不存在分摊级别
|
|
|
+ Integer isGatherCenter = newResponsibility.getIsGatherCenter();
|
|
|
+ if (isGatherCenter == 1) {
|
|
|
+ newResponsibility.setShareId(null);
|
|
|
+ newResponsibility.setShareLevel(0);
|
|
|
+ newResponsibility.setShareName("");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Objects.nonNull(center) && (center.getIsGatherCenter() == 2)) {
|
|
|
+ throw new CostException(500, "非汇总中心不允许添加");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
|
|
|
+ public void updateCurResp(Responsibility center, ResponsibilityEditDTO dto, User user) {
|
|
|
+ // 删除
|
|
|
+ Integer id = dto.getId();
|
|
|
+ this.removeById(id);
|
|
|
+ // 校验code
|
|
|
+ this.checkCode(dto.getResponsibilityCode(), user.getHospId());
|
|
|
+
|
|
|
+ Responsibility newResponsibility = BeanUtil.convertObj(dto, Responsibility.class);
|
|
|
+ newResponsibility.setId(null)
|
|
|
+ .setHospId(user.getHospId())
|
|
|
+ .setCreateTime(System.currentTimeMillis())
|
|
|
+ .setParentId(dto.getParentId())
|
|
|
+ .setResponsibilityLevel(2);
|
|
|
+ // 如果变成了汇总中心,那么变成第一层
|
|
|
+ if (dto.getIsGatherCenter() == 1) {
|
|
|
+ newResponsibility.setShareId(null)
|
|
|
+ .setShareLevel(0)
|
|
|
+ .setShareName(null)
|
|
|
+ .setParentId(0)
|
|
|
+ .setResponsibilityLevel(1);
|
|
|
+ }
|
|
|
+ if (dto.getParentId() == 0) {
|
|
|
+ newResponsibility.setResponsibilityLevel(1);
|
|
|
+ }
|
|
|
+ this.save(newResponsibility);
|
|
|
}
|
|
|
|
|
|
/**
|