From 2f3d3fb97bd4ebdc00c40a2774465c8b3487b6d1 Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期三, 02 四月 2025 17:14:27 +0800 Subject: [PATCH] bug修改 --- medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysDepartmentServiceImpl.java | 73 +++++++++++++++++++++++++++++++++++- 1 files changed, 70 insertions(+), 3 deletions(-) diff --git a/medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysDepartmentServiceImpl.java b/medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysDepartmentServiceImpl.java index cbe63bf..6fc2758 100644 --- a/medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysDepartmentServiceImpl.java +++ b/medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysDepartmentServiceImpl.java @@ -1,5 +1,6 @@ package com.sinata.system.service.impl; +import com.alibaba.fastjson2.JSONArray; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -12,6 +13,14 @@ import com.sinata.common.utils.SecurityUtils; import com.sinata.common.utils.StringUtils; import com.sinata.system.domain.MwApplication; +import com.sinata.system.domain.MwContract; +import com.sinata.system.domain.MwMicroEquipment; +import com.sinata.system.domain.MwProtectionEquipment; +import com.sinata.system.domain.MwProtectionRegulation; +import com.sinata.system.domain.MwProtectionTask; +import com.sinata.system.domain.MwStagingRoom; +import com.sinata.system.domain.MwTransitCar; +import com.sinata.system.domain.MwTransitRoute; import com.sinata.system.domain.SysDepartment; import com.sinata.system.domain.SysDepartmentInfo; import com.sinata.system.domain.dto.DisposalUnitDTO; @@ -26,6 +35,15 @@ import com.sinata.system.enums.DepartmentEnum; import com.sinata.system.mapper.SysDepartmentMapper; import com.sinata.system.service.ISysUserService; +import com.sinata.system.service.MwApplicationService; +import com.sinata.system.service.MwContractService; +import com.sinata.system.service.MwMicroEquipmentService; +import com.sinata.system.service.MwProtectionEquipmentService; +import com.sinata.system.service.MwProtectionRegulationService; +import com.sinata.system.service.MwProtectionTaskService; +import com.sinata.system.service.MwStagingRoomService; +import com.sinata.system.service.MwTransitCarService; +import com.sinata.system.service.MwTransitRouteService; import com.sinata.system.service.SysDepartmentInfoService; import com.sinata.system.service.SysDepartmentService; import com.sinata.system.service.SysUserDepartmentService; @@ -61,6 +79,16 @@ private final RedisTemplate<Object, Object> redisTemplate; private final SysDepartmentInfoService sysDepartmentInfoService; private final ISysUserService sysUserService; + + private final MwApplicationService mwApplicationService; + private final MwContractService mwContractService; + private final MwMicroEquipmentService mwMicroEquipmentService; + private final MwProtectionEquipmentService mwProtectionEquipmentService; + private final MwProtectionTaskService mwProtectionTaskService; + private final MwProtectionRegulationService mwProtectionRegulationService; + private final MwStagingRoomService mwStagingRoomService; + private final MwTransitCarService mwTransitCarService; + private final MwTransitRouteService mwTransitRouteService; /** * 获取区域树 * @return @@ -91,6 +119,12 @@ break; case 5: childrenMap = getChildrenDepartmentByOrgType(myDepartment, Arrays.asList(DepartmentEnum.REGION.getCode(), DepartmentEnum.MEDICAL_INSTITUTION.getCode(), DepartmentEnum.DISPOSAL_UNIT.getCode())); + break; + case 6: + childrenMap = getChildrenDepartmentByOrgType(myDepartment, Arrays.asList(DepartmentEnum.REGION.getCode(), DepartmentEnum.MEDICAL_INSTITUTION.getCode(), DepartmentEnum.REGULATORY_UNIT.getCode())); + break; + case 7: + childrenMap = getChildrenDepartmentByOrgType(myDepartment, Arrays.asList(DepartmentEnum.REGION.getCode(), DepartmentEnum.DISPOSAL_UNIT.getCode(), DepartmentEnum.REGULATORY_UNIT.getCode())); break; default: childrenMap = getChildrenDepartmentByOrgType(myDepartment, null); @@ -150,6 +184,9 @@ @NotNull private Map<Long, List<SysDepartment>> getChildrenDepartmentMap(SysDepartment myDepartment) { List<SysDepartment> sysDepartmentList = this.lambdaQuery() + .ne(SysDepartment::getOrgType , 4) + .ne(SysDepartment::getOrgType , 3) + .ne(SysDepartment::getOrgType , 2) .likeRight(SysDepartment::getTreeCode, myDepartment.getTreeCode()) .orderByDesc(SysDepartment::getCreateTime) .list(); @@ -219,6 +256,13 @@ // } Map<Long, List<SysDepartment>> childrenMap = getChildrenDepartmentMap(currentDepartment); SysDepartmentVO sysDepartmentVO = fillChildrenTreeModel(currentDepartment, childrenMap); + Integer orgType = sysDepartmentVO.getOrgType(); + if (sysDepartmentVO.getOrgType()==4){ + SysDepartment byId = this.getById(sysDepartmentVO.getParentId()); + childrenMap = getChildrenDepartmentMap(byId); + sysDepartmentVO = fillChildrenTreeModel(byId, childrenMap); +// sysDepartmentVO.setChildren(new ArrayList<>()); + } if (sysDepartmentVO.getTreeCode().length()==10){ SysDepartment sysDepartment = this.baseMapper.selectById(sysDepartmentVO.getParentId()); SysDepartmentVO sysDepartmentVO1 = new SysDepartmentVO(); @@ -228,12 +272,12 @@ sysDepartmentVO1.setChildren(root1); sysDepartmentVO = sysDepartmentVO1; } - if (sysDepartmentVO.getTreeCode().length()==14){ + if (sysDepartmentVO.getTreeCode().length()>=14){ SysDepartment sysDepartment = this.baseMapper.selectById(sysDepartmentVO.getParentId()); SysDepartmentVO sysDepartmentVO1 = new SysDepartmentVO(); BeanUtils.copyProperties(sysDepartment,sysDepartmentVO1); List<SysDepartmentVO> root1 = new ArrayList<>(); - root1.add(sysDepartmentVO); + root1.add(sysDepartmentVO); sysDepartmentVO1.setChildren(root1); @@ -242,7 +286,7 @@ BeanUtils.copyProperties(sysDepartment2,sysDepartmentVO2); List<SysDepartmentVO> root2 = new ArrayList<>(); root2.add(sysDepartmentVO1); - sysDepartmentVO2.setChildren(root2); + sysDepartmentVO2.setChildren(root2); sysDepartmentVO = sysDepartmentVO2; } root.add(sysDepartmentVO); @@ -613,6 +657,8 @@ sysDepartmentInfo.setDepartmentId(department.getId()); sysDepartmentInfo.setId(null); sysDepartmentInfoService.save(sysDepartmentInfo); + //处理层级关系 + handleRelation(sysDepartment, parent, dto.getRelation()); } /** @@ -743,6 +789,26 @@ sysDepartmentInfo.setId(null); sysDepartmentInfo.setDepartmentId(department.getId()); sysDepartmentInfoService.save(sysDepartmentInfo); + //如果修改了所属区域 + handleRelation(sysDepartment, parent, dto.getRelation()); + } + + private void handleRelation(SysDepartment sysDepartment, SysDepartment parent, String relation) { + if (!sysDepartment.getParentId().equals(parent.getId())) { + List<Long> relationList = Arrays.stream(relation.split(",")).map(Long::valueOf).collect(Collectors.toList()); + relationList.add(sysDepartment.getId()); + relation = JSONArray.toJSONString(relationList); + //同步该单位所属器具的层级 + mwApplicationService.lambdaUpdate().set(MwApplication::getRelation, relation).eq(MwApplication::getDepartmentId, sysDepartment.getId()).update(); + mwContractService.lambdaUpdate().set(MwContract::getRelation, relation).eq(MwContract::getDepartmentId, sysDepartment.getId()).update(); + mwMicroEquipmentService.lambdaUpdate().set(MwMicroEquipment::getRelation, relation).eq(MwMicroEquipment::getDepartmentId, sysDepartment.getId()).update(); + mwProtectionEquipmentService.lambdaUpdate().set(MwProtectionEquipment::getRelation, relation).eq(MwProtectionEquipment::getDepartmentId, sysDepartment.getId()).update(); + mwProtectionTaskService.lambdaUpdate().set(MwProtectionTask::getRelation, relation).eq(MwProtectionTask::getDepartmentId, sysDepartment.getId()).update(); + mwProtectionRegulationService.lambdaUpdate().set(MwProtectionRegulation::getRelation, relation).eq(MwProtectionRegulation::getDepartmentId, sysDepartment.getId()).update(); + mwStagingRoomService.lambdaUpdate().set(MwStagingRoom::getRelation, relation).eq(MwStagingRoom::getDepartmentId, sysDepartment.getId()).update(); + mwTransitCarService.lambdaUpdate().set(MwTransitCar::getRelation, relation).eq(MwTransitCar::getDepartmentId, sysDepartment.getId()).update(); + mwTransitRouteService.lambdaUpdate().set(MwTransitRoute::getRelation, relation).eq(MwTransitRoute::getDepartmentId, sysDepartment.getId()).update(); + } } /** @@ -863,6 +929,7 @@ department.setRegion(region); } updateById(department); + handleRelation(sysDepartment, parent, dto.getRelation()); } /** -- Gitblit v1.7.1