| | |
| | | import com.sinata.system.domain.MwApplication; |
| | | import com.sinata.system.domain.SysDepartment; |
| | | import com.sinata.system.domain.SysDepartmentInfo; |
| | | import com.sinata.system.domain.SysUserDepartment; |
| | | import com.sinata.system.domain.dto.DisposalUnitDTO; |
| | | import com.sinata.system.domain.dto.MedicalInstitutionDTO; |
| | | import com.sinata.system.domain.dto.RegulatoryUnitDTO; |
| | |
| | | import com.sinata.system.domain.vo.SysDepartmentVO; |
| | | import com.sinata.system.enums.DepartmentEnum; |
| | | import com.sinata.system.mapper.SysDepartmentMapper; |
| | | import com.sinata.system.service.ISysUserService; |
| | | import com.sinata.system.service.SysDepartmentInfoService; |
| | | import com.sinata.system.service.SysDepartmentService; |
| | | import com.sinata.system.service.SysUserDepartmentService; |
| | |
| | | private final SysUserDepartmentService sysUserDepartmentService; |
| | | private final RedisTemplate<Object, Object> redisTemplate; |
| | | private final SysDepartmentInfoService sysDepartmentInfoService; |
| | | private final ISysUserService sysUserService; |
| | | /** |
| | | * 获取区域树 |
| | | * @return |
| | |
| | | break; |
| | | case 4: |
| | | childrenMap = getChildrenDepartmentByOrgType(myDepartment, Arrays.asList(DepartmentEnum.REGION.getCode(), DepartmentEnum.REGULATORY_UNIT.getCode())); |
| | | break; |
| | | case 5: |
| | | childrenMap = getChildrenDepartmentByOrgType(myDepartment, Arrays.asList(DepartmentEnum.REGION.getCode(), DepartmentEnum.MEDICAL_INSTITUTION.getCode(), DepartmentEnum.DISPOSAL_UNIT.getCode())); |
| | | break; |
| | | default: |
| | | childrenMap = getChildrenDepartmentByOrgType(myDepartment, null); |
| | |
| | | @NotNull |
| | | private Map<Long, List<SysDepartment>> getChildrenDepartmentByOrgType(SysDepartment myDepartment, List<Integer> orgTypes) { |
| | | List<SysDepartment> sysDepartmentList = this.lambdaQuery() |
| | | .in(CollUtils.isNotEmpty(orgTypes), SysDepartment::getOrgType, orgTypes) |
| | | .likeRight(SysDepartment::getTreeCode, myDepartment.getTreeCode()) |
| | | .orderByDesc(SysDepartment::getCreateTime) |
| | | .list(); |
| | |
| | | .collect(Collectors.groupingBy(SysDepartment::getParentId)); |
| | | } |
| | | |
| | | @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(); |
| | | return sysDepartmentList.stream() |
| | | .collect(Collectors.groupingBy(SysDepartment::getParentId)); |
| | | } |
| | | @Override |
| | | public SysDepartment getDepartmentByParentId(Long parentId) { |
| | | return this.lambdaQuery().eq(SysDepartment::getId, parentId).one(); |
| | |
| | | // if (!currentDepartment.getOrgType().equals(DepartmentEnum.REGION.getCode())) { |
| | | // return root; |
| | | // } |
| | | Map<Long, List<SysDepartment>> childrenMap = getChildrenDepartmentByOrgType(currentDepartment, Collections.singletonList(DepartmentEnum.REGION.getCode())); |
| | | 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(); |
| | |
| | | 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); |
| | | |
| | | |
| | |
| | | BeanUtils.copyProperties(sysDepartment2,sysDepartmentVO2); |
| | | List<SysDepartmentVO> root2 = new ArrayList<>(); |
| | | root2.add(sysDepartmentVO1); |
| | | sysDepartmentVO2.setChildren(root2); |
| | | sysDepartmentVO2.setChildren(root2); |
| | | sysDepartmentVO = sysDepartmentVO2; |
| | | } |
| | | root.add(sysDepartmentVO); |
| | |
| | | .orderByDesc(SysDepartment::getCreateTime) |
| | | .list(); |
| | | List<Long> departmentIds = sysDepartmentList.stream().map(SysDepartment::getId).collect(Collectors.toList()); |
| | | Long count = sysUserDepartmentService.lambdaQuery().in(SysUserDepartment::getDepartmentId, departmentIds).count(); |
| | | Long count = sysUserService.lambdaQuery().in(SysUser::getDepartmentId, departmentIds).count(); |
| | | if (count > 0) { |
| | | throw new ServiceException("该区域已存在用户,无法删除"); |
| | | throw new ServiceException("该区域已关联用户,无法删除"); |
| | | } |
| | | removeById(id); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public void deleteMedical(Long id) { |
| | | Long count = sysUserDepartmentService.lambdaQuery().eq(SysUserDepartment::getDepartmentId, id).count(); |
| | | Long count = sysUserService.lambdaQuery().eq(SysUser::getDepartmentId, id).count(); |
| | | if (count > 0) { |
| | | throw new ServiceException("该医疗机构已存在用户,无法删除"); |
| | | throw new ServiceException("该医疗机构已关联用户,无法删除"); |
| | | } |
| | | removeById(id); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void deleteDisposalUnit(Long id) { |
| | | Long count = sysUserDepartmentService.lambdaQuery().eq(SysUserDepartment::getDepartmentId, id).count(); |
| | | Long count = sysUserService.lambdaQuery().eq(SysUser::getDepartmentId, id).count(); |
| | | if (count > 0) { |
| | | throw new ServiceException("该处置单位构已存在用户,无法删除"); |
| | | throw new ServiceException("该处置单位构已关联用户,无法删除"); |
| | | } |
| | | removeById(id); |
| | | } |
| | |
| | | .like(StringUtils.isNotBlank(query.getContactPerson()), SysDepartment::getContactPerson, query.getContactPerson()) |
| | | .like(StringUtils.isNotBlank(query.getContactPhone()), SysDepartment::getContactPhone, query.getContactPhone()) |
| | | .eq(SysDepartment::getOrgType, DepartmentEnum.REGULATORY_UNIT.getCode()) |
| | | .orderByDesc(SysDepartment::getCreateTime) |
| | | .page(new Page<>(query.getPageCurr(), query.getPageSize())); |
| | | return PageDTO.of(page, RegulatoryUnitVO.class); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public void deleteRegulatoryUnit(Long id) { |
| | | Long count = sysUserDepartmentService.lambdaQuery().eq(SysUserDepartment::getDepartmentId, id).count(); |
| | | Long count = sysUserService.lambdaQuery().eq(SysUser::getDepartmentId, id).count(); |
| | | if (count > 0) { |
| | | throw new ServiceException("该监管单位构已存在用户,无法删除"); |
| | | throw new ServiceException("该监管单位构已关联用户,无法删除"); |
| | | } |
| | | removeById(id); |
| | | } |