|
@@ -0,0 +1,465 @@
|
|
|
+package com.kcim.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.kcim.constants.NumberConstant;
|
|
|
+import com.kcim.controller.request.QualificationManageAdjustRequest;
|
|
|
+import com.kcim.controller.request.QualificationReAuthorizeRequest;
|
|
|
+import com.kcim.controller.response.QualificationManage;
|
|
|
+import com.kcim.controller.response.QualificationManageForDoctor;
|
|
|
+import com.kcim.dao.mapper.QualificationApplyMapper;
|
|
|
+import com.kcim.dao.model.*;
|
|
|
+import com.kcim.dao.repository.*;
|
|
|
+import com.kcim.service.CenterService;
|
|
|
+import com.kcim.service.QualificationApplyService;
|
|
|
+import com.kcim.service.QualificationManageService;
|
|
|
+import com.kcim.service.QualificationService;
|
|
|
+import com.kcim.util.BaseUtil;
|
|
|
+import com.kcim.util.PageUtils;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import lombok.val;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service("QualificationManageService")
|
|
|
+@AllArgsConstructor
|
|
|
+@Slf4j
|
|
|
+public class QualificationManageServiceImpl extends ServiceImpl<QualificationApplyMapper, QualificationApply> implements QualificationManageService {
|
|
|
+
|
|
|
+ QualificationRepository qualificationRepository;
|
|
|
+ QualificationTypeRepository qualificationTypeRepository;
|
|
|
+ QualificationApplyRepository qualificationApplyRepository;
|
|
|
+ QualificationApplyAdjustRepository qualificationApplyAdjustRepository;
|
|
|
+ UserInfoRepository userInfoRepository;
|
|
|
+ DepartmentRepository departmentRepository;
|
|
|
+ DoctorAttachmentRepository doctorAttachmentRepository;
|
|
|
+
|
|
|
+ QualificationService qualificationService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object listByQualification(String name, String qualificationTypeCode, String operationLevelCode, Integer techFlag, Integer operationFlag, Integer current, Integer pageSize) {
|
|
|
+
|
|
|
+ //返回的集合
|
|
|
+ List<QualificationManage> listReturn = new ArrayList<>();
|
|
|
+
|
|
|
+ //资质集合
|
|
|
+ List<Qualification> qualificationList = qualificationRepository.list();
|
|
|
+
|
|
|
+ //资质分类集合
|
|
|
+ List<QualificationType> qualificationTypeList = qualificationTypeRepository.list();
|
|
|
+
|
|
|
+ //人员列表
|
|
|
+ List<UserInfo> empList = userInfoRepository.list();
|
|
|
+ Map<Long,UserInfo> empMap = empList.stream().collect(Collectors.toMap(UserInfo::getId, vo -> vo, (a, b) -> b));
|
|
|
+
|
|
|
+ //有效的资质授权
|
|
|
+ List<QualificationApply> list = qualificationApplyRepository.listByQualification();
|
|
|
+
|
|
|
+ for(QualificationApply qualificationApply : list){
|
|
|
+
|
|
|
+ //医生信息
|
|
|
+ qualificationApply.setUserInfo(empMap.get(qualificationApply.getUserId()));
|
|
|
+
|
|
|
+ //调整历史-调整人姓名
|
|
|
+ for(QualificationApplyAdjust adjust : qualificationApply.getApplyAdjust()){
|
|
|
+ adjust.setAdjustUserName(empMap.get(adjust.getUserId()).getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ //资质字典
|
|
|
+ Qualification qualification = qualificationList.stream().filter(q -> q.getCode().equals(qualificationApply.getQualificationCode())).findFirst().get();
|
|
|
+ //资质名称
|
|
|
+ String qualificationName = qualification.getName();
|
|
|
+ //资质分类
|
|
|
+ QualificationType qualificationType = qualificationTypeList.stream().filter(t -> t.getCode().equals(qualification.getQualificationTypeCode())).findFirst().get();
|
|
|
+ //资质分类编码
|
|
|
+ String typeCode = qualificationType.getCode();
|
|
|
+ //资质分类名称
|
|
|
+ String typeName = qualificationType.getName();
|
|
|
+ qualification.setQualificationTypeName(typeName);
|
|
|
+
|
|
|
+ //名称过滤
|
|
|
+ if(!StringUtils.isEmpty(name) && !qualificationName.contains(name)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //分类过滤
|
|
|
+ if(!qualificationTypeCode.equals("0")){
|
|
|
+ //List<String> typeCodeList = qualificationServiceImpl.getQualificationTypeCodeRecursion(qualificationTypeList,qualificationTypeCode);
|
|
|
+ List<String> typeCodeList = qualificationService.getQualificationTypeCodeRecursion(qualificationTypeList,qualificationTypeCode);
|
|
|
+ if(!typeCodeList.contains(typeCode)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //手术标志过滤
|
|
|
+ if(operationFlag != null && operationFlag.equals(NumberConstant.ONE) && qualification.getOperationFlag().equals(NumberConstant.ZERO)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //医疗技术标志过滤
|
|
|
+ if(techFlag != null && techFlag.equals(NumberConstant.ONE) && qualification.getTechFlag().equals(NumberConstant.ZERO)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //手术级别过滤
|
|
|
+ if(!StringUtils.isEmpty(operationLevelCode) && !qualification.getOperationLevelCode().equals(operationLevelCode)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ Optional<QualificationManage> returnItem = listReturn.stream().filter(q -> q.getQualification().getCode().equals(qualificationApply.getQualificationCode())).findFirst();
|
|
|
+ //添加1项
|
|
|
+ if(!returnItem.isPresent()) {
|
|
|
+ QualificationManage newItem = new QualificationManage();
|
|
|
+ //资质字典
|
|
|
+ newItem.setQualification(qualification);
|
|
|
+ //医生列表
|
|
|
+ if(qualificationApply.getCurrentStatus().equals("授权中")){
|
|
|
+ newItem.setDoctorList(qualificationApply.getUserInfo().getName());
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ newItem.setDoctorList(""); //新建时如果不是授权中状态,则给一个空字符串,避免出现null文本
|
|
|
+ }
|
|
|
+ //申请列表
|
|
|
+ List<QualificationApply> applyList = new ArrayList<>();
|
|
|
+ applyList.add(qualificationApply);
|
|
|
+ newItem.setApplyList(applyList);
|
|
|
+
|
|
|
+ listReturn.add(newItem);
|
|
|
+ }
|
|
|
+ //更新项
|
|
|
+ else{
|
|
|
+ //医生列表
|
|
|
+ if(qualificationApply.getCurrentStatus().equals("授权中")){
|
|
|
+ String newDoctorList = returnItem.get().getDoctorList() + "," + qualificationApply.getUserInfo().getName();
|
|
|
+ newDoctorList = StringUtils.trimLeadingCharacter(newDoctorList,','); //去掉最左边的逗号
|
|
|
+ returnItem.get().setDoctorList(newDoctorList);
|
|
|
+ }
|
|
|
+ //申请列表
|
|
|
+ returnItem.get().getApplyList().add(qualificationApply);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置「允许重新授权状态」,已过期的授权,如果没有对应的授权中的人时,才可以重新授权
|
|
|
+ for(QualificationManage item : listReturn ){
|
|
|
+ for(QualificationApply apply : item.getApplyList()){
|
|
|
+ if(apply.getCurrentStatus().equals("已过期")) {
|
|
|
+ if(item.getApplyList().stream().filter(a -> a.getCurrentStatus().equals("授权中"))
|
|
|
+ .noneMatch(a -> a.getUserId().equals(apply.getUserId()))) {
|
|
|
+ apply.setAllowReAuthorize(NumberConstant.ONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return new PageUtils(listReturn, Math.toIntExact(listReturn.size()),pageSize,current);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object listByDoctor(String deptCode, String userName, Integer current, Integer pageSize) {
|
|
|
+
|
|
|
+ //返回的集合
|
|
|
+ List<QualificationManageForDoctor> listReturn = new ArrayList<>();
|
|
|
+
|
|
|
+ //资质集合
|
|
|
+ List<Qualification> qualificationList = qualificationRepository.list();
|
|
|
+
|
|
|
+ //有效的资质授权
|
|
|
+ List<QualificationApply> list = qualificationApplyRepository.listByQualification();
|
|
|
+
|
|
|
+ //过滤的科室代码和其下级代码组成的列表
|
|
|
+ List<String> listDept = getDepartmentCodeRecursion(departmentRepository.list(),deptCode);
|
|
|
+
|
|
|
+ //人员列表
|
|
|
+ List<UserInfo> empList = userInfoRepository.list();
|
|
|
+ Map<Long,UserInfo> empMap = empList.stream().collect(Collectors.toMap(UserInfo::getId, vo -> vo, (a, b) -> b));
|
|
|
+
|
|
|
+ for(QualificationApply qualificationApply : list){
|
|
|
+
|
|
|
+ //资质字典
|
|
|
+ Qualification qualification = qualificationList.stream().filter(q -> q.getCode().equals(qualificationApply.getQualificationCode())).findFirst().get();
|
|
|
+ //资质名称
|
|
|
+ String qualificationName = qualification.getName();
|
|
|
+
|
|
|
+ //科室过滤
|
|
|
+ if(!StringUtils.isEmpty(deptCode) && !listDept.contains(qualificationApply.getUserInfo().getDeptCode())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //姓名过滤
|
|
|
+ if(!StringUtils.isEmpty(userName) && !qualificationApply.getUserInfo().getName().contains(userName)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //调整历史-调整人姓名
|
|
|
+ for(QualificationApplyAdjust adjust : qualificationApply.getApplyAdjust()){
|
|
|
+ adjust.setAdjustUserName(empMap.get(adjust.getUserId()).getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ Optional<QualificationManageForDoctor> returnItem = listReturn.stream().filter(q -> q.getUserInfo().getId().equals(qualificationApply.getUserId())).findFirst();
|
|
|
+ //添加1项
|
|
|
+ if(!returnItem.isPresent()) {
|
|
|
+ QualificationManageForDoctor newItem = new QualificationManageForDoctor();
|
|
|
+ //医生信息
|
|
|
+ newItem.setUserInfo(userInfoRepository.getUserInfoById(qualificationApply.getUserId()));
|
|
|
+ //资质名称列表
|
|
|
+ if(qualificationApply.getCurrentStatus().equals("授权中")){
|
|
|
+ newItem.setQualificationList(qualificationName);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ newItem.setQualificationList(""); //新建时如果不是授权中状态,则给一个空字符串,避免出现null文本
|
|
|
+ }
|
|
|
+ //申请列表
|
|
|
+ List<QualificationApply> applyList = new ArrayList<>();
|
|
|
+ applyList.add(qualificationApply);
|
|
|
+ newItem.setApplyList(applyList);
|
|
|
+
|
|
|
+ listReturn.add(newItem);
|
|
|
+ }
|
|
|
+ //更新项
|
|
|
+ else{
|
|
|
+ //资质名称列表
|
|
|
+ if(qualificationApply.getCurrentStatus().equals("授权中")){
|
|
|
+ String newQualificationList = returnItem.get().getQualificationList() + "," + qualificationName;
|
|
|
+ newQualificationList = StringUtils.trimLeadingCharacter(newQualificationList,','); //去掉最左边的逗号
|
|
|
+ returnItem.get().setQualificationList(newQualificationList);
|
|
|
+ }
|
|
|
+ //申请列表
|
|
|
+ returnItem.get().getApplyList().add(qualificationApply);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置「允许重新授权状态」,已过期的授权,如果没有对应的授权中的授权时,才可以重新授权
|
|
|
+ for(QualificationManageForDoctor item : listReturn ){
|
|
|
+ for(QualificationApply apply : item.getApplyList()){
|
|
|
+ if(apply.getCurrentStatus().equals("已过期")) {
|
|
|
+ if(item.getApplyList().stream().filter(a -> a.getCurrentStatus().equals("授权中"))
|
|
|
+ .noneMatch(a -> a.getQualificationInfo().getCode().equals(apply.getQualificationInfo().getCode()))) {
|
|
|
+ apply.setAllowReAuthorize(NumberConstant.ONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return new PageUtils(listReturn, Math.toIntExact(listReturn.size()),pageSize,current);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 递归获取的科室编码的下级编码列表
|
|
|
+ */
|
|
|
+ public List<String> getDepartmentCodeRecursion(List<Department> deptList,String deptCode){
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+
|
|
|
+ //父节点为传入节点的节点数
|
|
|
+ long count = deptList.stream().filter(t -> t.getParentCode().equals(deptCode)).count();
|
|
|
+
|
|
|
+ //传入的是根节点
|
|
|
+ if(count == 0){
|
|
|
+ list.add(deptCode);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ //传入的不是根节点
|
|
|
+ for(Department dept : deptList){
|
|
|
+ //传入节点的直接下级
|
|
|
+ if(dept.getParentCode().equals(deptCode)){
|
|
|
+ long childCount = deptList.stream().filter(t -> t.getParentCode().equals(dept.getCode())).count();
|
|
|
+ //是末级节点
|
|
|
+ if(childCount == 0 && !list.contains(dept.getCode())){
|
|
|
+ list.add(dept.getCode());
|
|
|
+ }
|
|
|
+ //递归
|
|
|
+ else{
|
|
|
+ list.addAll(getDepartmentCodeRecursion(deptList,dept.getCode()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void adjust(QualificationManageAdjustRequest request) {
|
|
|
+ QualificationApply apply = qualificationApplyRepository.getById(request.getQualificationApplyId());
|
|
|
+
|
|
|
+ //更新调整记录
|
|
|
+ QualificationApplyAdjust adjust = new QualificationApplyAdjust();
|
|
|
+ adjust.setQualificationApplyId(request.getQualificationApplyId());
|
|
|
+ adjust.setUserId(BaseUtil.getCurrentUser().getId());
|
|
|
+ adjust.setQualificationPeriodBefore(apply.getQualificationPeriod());
|
|
|
+ adjust.setQualificationPeriodAfter(request.getQualificationPeriod());
|
|
|
+ adjust.setBeginDateBefore(apply.getBeginDate());
|
|
|
+ adjust.setBeginDateAfter(request.getBeginDate());
|
|
|
+ adjust.setEndDateBefore(apply.getEndDate());
|
|
|
+ adjust.setEndDateAfter(request.getEndDate());
|
|
|
+ adjust.setMemo(request.getMemo());
|
|
|
+
|
|
|
+ adjust.setCreateUser(String.valueOf(BaseUtil.getCurrentUser().getId()));
|
|
|
+ adjust.setCreateTime(new Date());
|
|
|
+ adjust.setHospId(BaseUtil.getCurrentLoginHospId());
|
|
|
+
|
|
|
+ qualificationApplyAdjustRepository.save(adjust);
|
|
|
+
|
|
|
+ //更新资质申请
|
|
|
+ apply.setQualificationPeriod(request.getQualificationPeriod());
|
|
|
+ apply.setBeginDate(request.getBeginDate());
|
|
|
+ apply.setEndDate(request.getEndDate());
|
|
|
+
|
|
|
+ apply.setUpdateUser(String.valueOf(BaseUtil.getCurrentUser().getId()));
|
|
|
+ apply.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ qualificationApplyRepository.updateById(apply);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void adjustBatch(List<QualificationManageAdjustRequest> request) {
|
|
|
+ for(QualificationManageAdjustRequest r : request) {
|
|
|
+ adjust(r);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void reAuthorize(QualificationReAuthorizeRequest request) {
|
|
|
+
|
|
|
+ //取原来的申请
|
|
|
+ QualificationApply apply = qualificationApplyRepository.getById(request.getQualificationApplyId());
|
|
|
+
|
|
|
+ //拷贝原来的属性
|
|
|
+ QualificationApply newApply = new QualificationApply();
|
|
|
+ newApply.setQualificationCode(apply.getQualificationCode());
|
|
|
+ newApply.setUserId(apply.getUserId());
|
|
|
+ //新授权属性
|
|
|
+ newApply.setQualificationPeriod(request.getQualificationPeriod());
|
|
|
+ newApply.setBeginDate(request.getBeginDate());
|
|
|
+ newApply.setEndDate(request.getEndDate());
|
|
|
+ newApply.setManagerOpinion(request.getMemo());
|
|
|
+
|
|
|
+ newApply.setApplyDate(new Date());
|
|
|
+ newApply.setApplyStatus(NumberConstant.FIVE);
|
|
|
+ newApply.setCreateUser(String.valueOf(BaseUtil.getCurrentUser().getId()));
|
|
|
+ newApply.setCreateTime(new Date());
|
|
|
+ newApply.setHospId(BaseUtil.getCurrentLoginHospId());
|
|
|
+
|
|
|
+ qualificationApplyRepository.save(newApply);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object listAllDoctor(String queryCondition) {
|
|
|
+ return userInfoRepository.listAllDoctor(queryCondition);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object listAvailableQualification(String queryCondition, Date expireDate, Integer current, Integer pageSize) {
|
|
|
+ return qualificationApplyRepository.listAvailableQualification(queryCondition,expireDate, current, pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getMyInfo() {
|
|
|
+ UserInfo myInfo = userInfoRepository.getCurrentUserInfo();
|
|
|
+ myInfo.setAttachments(doctorAttachmentRepository.listByUserId(BaseUtil.getCurrentUser().getId()));
|
|
|
+ return myInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object listAllDepartment(String queryCondition) {
|
|
|
+ //返回的集合
|
|
|
+ List<Department> listReturn = new ArrayList<>();
|
|
|
+
|
|
|
+ //先把所有科室都查询出来
|
|
|
+ List<Department> listAll = departmentRepository.list();
|
|
|
+
|
|
|
+ //需要检索
|
|
|
+ if(!StringUtils.isEmpty(queryCondition)) {
|
|
|
+ //生成检索字段的值
|
|
|
+ for(Department department : listAll) {
|
|
|
+ department.setFilter(getChildDepartmentFilter(department.getCode(),department.getName(),listAll));
|
|
|
+ }
|
|
|
+
|
|
|
+ //过滤得到子集
|
|
|
+ List<Department> list = listAll.stream().filter(d -> d.getFilter().contains(queryCondition)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //查无结果
|
|
|
+ if((long) list.size() == 0){
|
|
|
+ return listReturn;
|
|
|
+ }
|
|
|
+
|
|
|
+ //把子集填到返回放列表里
|
|
|
+ //先添加根节点,因为根节点是必须有的
|
|
|
+ Optional<Department> rootNode = list.stream().filter(d -> d.getCode().equals("0")).findFirst();
|
|
|
+ if(rootNode.isPresent()){
|
|
|
+ rootNode.get().setChildren(getChildrenDepartment("0",list));
|
|
|
+ listReturn.add(rootNode.get());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //不需要检索
|
|
|
+ else{
|
|
|
+ //先添加根节点,因为根节点是必须有的
|
|
|
+ Optional<Department> rooNode = listAll.stream().filter(d -> d.getCode().equals("0")).findFirst();
|
|
|
+ if(rooNode.isPresent()){
|
|
|
+ rooNode.get().setChildren((getChildrenDepartment("0",listAll)));
|
|
|
+ listReturn.add(rooNode.get());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return listReturn;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object listMyAvailableQualification(String qualificationName, String operationLevelCode, Integer techFlag, Integer operationFlag, Integer current, Integer pageSize) {
|
|
|
+ return qualificationApplyRepository.listMyAvailableQualification(qualificationName, operationLevelCode, techFlag, operationFlag, current, pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object saveDoctorAttachment(DoctorAttachment doctorAttachments) {
|
|
|
+ doctorAttachments.setHospId(BaseUtil.getCurrentLoginHospId());
|
|
|
+ doctorAttachments.setCreateTime(new Date());
|
|
|
+ doctorAttachments.setCreateUser(String.valueOf(BaseUtil.getCurrentUser().getId()));
|
|
|
+ return doctorAttachmentRepository.save(doctorAttachments);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object editDoctorAttachment(DoctorAttachment doctorAttachments) {
|
|
|
+ doctorAttachments.setUpdateTime(new Date());
|
|
|
+ doctorAttachments.setUpdateUser(String.valueOf(BaseUtil.getCurrentUser().getId()));
|
|
|
+ return doctorAttachmentRepository.updateById(doctorAttachments);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object deleteDoctorAttachment(Integer id){
|
|
|
+ return doctorAttachmentRepository.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getChildDepartmentFilter(String code,String name,List<Department> list) {
|
|
|
+
|
|
|
+ val filter = new StringBuilder();
|
|
|
+ //先把自己的内容加上
|
|
|
+ filter.append(code).append(",").append(name).append(",");
|
|
|
+ //遍历所有项
|
|
|
+ for(Department department : list) {
|
|
|
+ //是传入code的直接子节点
|
|
|
+ if(department.getParentCode().equals(code)) {
|
|
|
+ //把当前节点的code和name拼到过滤串中
|
|
|
+ filter.append(department.getCode()).append(",").append(department.getName()).append(",");
|
|
|
+ //当前节点的子节点数量
|
|
|
+ long childCount = list.stream().filter(d -> d.getParentCode().equals(department.getCode())).count();
|
|
|
+ //不是末级节点,则递归
|
|
|
+ if(childCount > 0){
|
|
|
+ filter.append(getChildDepartmentFilter(department.getCode(),department.getName(),list)).append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return filter.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Department> getChildrenDepartment(String code,List<Department> list){
|
|
|
+ List<Department> listReturn = new ArrayList<>();
|
|
|
+ for (Department department : list) {
|
|
|
+ //如果传入的code是直接下级节点
|
|
|
+ if(department.getParentCode().equals(code)) {
|
|
|
+ //当前节点的子节点数量
|
|
|
+ long childCount = list.stream().filter(d -> d.getParentCode().equals(department.getCode())).count();
|
|
|
+ //不是末级节点,则递归
|
|
|
+ if(childCount > 0) {
|
|
|
+ department.setChildren(getChildrenDepartment(department.getCode(),list));
|
|
|
+ }
|
|
|
+ listReturn.add(department);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return listReturn;
|
|
|
+ }
|
|
|
+}
|