ludc
2024-06-25 6f994bf94166b3b900eb43edcba07611017a6474
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java
@@ -27,6 +27,7 @@
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -103,6 +104,7 @@
      }
      return departmentVO;
   }
   /**
     * 批量获取部门的信息 (根据部门主键)
     * @param deptOidCollections 部门主键的集合,可以超过1000个
@@ -127,6 +129,7 @@
      });
      return    deptDO2VOs(depts);
   }
   /**
     * 获取部门的列表,默认会以部门名称升序排列,部门的编辑页面列表不要使用这个接口
     * @param queryMap 查询条件
@@ -150,6 +153,7 @@
      }
      return dataGrid;
   }
    /**
     * 根据部门主键获取部门的姓名
     * @param deptOid 部门主键
@@ -200,7 +204,8 @@
      }
      return deptDO2VOs(roles);
   }
    /**
   /**
     * 根据用户主键获取关联的部门
     * @param userOid 用户主键
     * @param queryMap 查询条件,如果需要使用用户的属性来查询可以使用pkUser.xxxx
@@ -215,6 +220,7 @@
      }
      return departmentVOS.get(0);
   }
   /**
     * 获取未关联某个用户的部门
     * @param userOid 用户主键
@@ -290,16 +296,19 @@
            List<BusinessObject> cbos = boService.queryBySql(sql, null);
            if(!CollectionUtils.isEmpty(cbos)){
               cbos.stream().forEach(cbo->{
                  String userOid = ObjectTool.getBOAttributeValue(cbo,"pluseruid");
                  String userOid = ObjectTool.getNewBOAttributeValue(cbo,"pluseruid");
                  List<String> deptOids = userDeptOidMap.getOrDefault(userOid,new ArrayList<>());
                  deptOids.add(ObjectTool.getBOAttributeValue(cbo,"pldeptuid"));
                  deptOids.add(ObjectTool.getNewBOAttributeValue(cbo,"pldeptuid"));
                  userDeptOidMap.put(userOid,deptOids);
               });
            }
         }
      });
      if(!CollectionUtils.isEmpty(deptVOList)){
         Map<String, OrgDepartmentVO> deptVOMap = deptVOList.stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
         //这儿应该对deptVOList做一次去重处理,因为肯定会有重复的部门被查出来
         Map<String, OrgDepartmentVO> deptVOMap = deptVOList.stream()
               .collect(Collectors.toMap(OrgDepartmentVO::getOid, Function.identity(), (existing, replacement) -> existing));
         //Map<String, OrgDepartmentVO> deptVOMap = deptVOList.stream().distinct().collect(Collectors.toMap(s -> s.getOid(), t -> t));
         Map<String, List<OrgDepartmentVO>> userDeptVOMap = new HashMap<>();
         userDeptOidMap.forEach((userOid,deptOids)->{
            List<OrgDepartmentVO> deptVOS = new ArrayList<>();
@@ -314,6 +323,7 @@
      }
      return new HashMap<>();
   }
    /**
     * 获取某个部门的直属下级部门
     * @param pkFatherDepartmment 部门的主键
@@ -332,6 +342,7 @@
      List<OrgDeptForPlatform1> depts = boService.selectByQueryWrapper(queryWrapperForDO, OrgDeptForPlatform1.class);
      return deptDO2VOs(depts);
   }
    /**
     * 获取某个部门的所有层级的下级部门
     * @param pkFatherDepartmment 部门的主键
@@ -345,6 +356,7 @@
      queryWrapperForDO.in("pluid","select pluid from pldept start with " + (StringUtils.isBlank(pkFatherDepartmment)?" (plparentuid is null or plparentuid = '') ":"plparentuid = '" + pkFatherDepartmment.trim() + "'") +  "connect by PRIOR pluid=plparentuid");
      return deptDO2VOs(boService.selectByQueryWrapper(queryWrapperForDO, OrgDeptForPlatform1.class));
   }
   /**
     * 参照树形数据的部门信息
     * @param treeQueryObject 树形查询的条件
@@ -371,6 +383,7 @@
         return dept.getId() + " " + dept.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equals(dept.getLcStatus())?"【停用】":"");
      });
   }
     /**
     * 参照树形表格的部门信息,上级部门的是表格中的树形列
     * @param treeQueryObject 树形查询的条件