Commit df2e2f6b by levphon

修复选中组织节点获取可见用户bug

1 parent 58f89e56
......@@ -98,14 +98,12 @@ public interface UserPathMapper extends CommonBaseMapper<UserPath> {
* @param superiorId
* @param userIds
* @param orgIds
* @param supOrgIds
* @param subOrgIds
* @return
*/
List<DepartmentUserCount> selectSubordinateDepartmentList(@Param("superiorId") Long superiorId,
@Param("userIds") Collection<Long> userIds,
@Param("orgIds") Collection<Long> orgIds,
@Param("supOrgIds") Collection<Long> supOrgIds,
@Param("subOrgIds") Collection<Long> subOrgIds);
}
\ No newline at end of file
......@@ -136,7 +136,7 @@ public class SubOrdinateStrategy extends PermissionStrategy {
}
//存在用户的下级部门
List<DepartmentUserCount> departmentUserCountList = userPathMapper.selectSubordinateDepartmentList(userId, null, null, null, null);
List<DepartmentUserCount> departmentUserCountList = userPathMapper.selectSubordinateDepartmentList(userId, null, null, null);
Set<Long> hasUserDeptIdList = departmentUserCountList.stream().map(DepartmentUserCount::getDepartmentId).filter(Objects::nonNull).collect(Collectors.toSet());
......@@ -165,9 +165,12 @@ public class SubOrdinateStrategy extends PermissionStrategy {
Long userId = ShieldContextHolder.getUserId();
//如果是搜索search.getUserIds()
List<DepartmentUserCount> departmentUserCountList = userPathMapper.selectSubordinateDepartmentList(userId, search.getUserIds(),
search.getOrgIds(), search.getSupOrgIds(), search.getSubOrgIds());
List<DepartmentUserCount> departmentUserCountList = userPathMapper.selectSubordinateDepartmentList(userId,
search.getUserIds(),
search.getOrgIds(),
search.getSubOrgIds());
//下级部门id
Set<Long> subDepartmentIdList = departmentUserCountList.stream().map(DepartmentUserCount::getDepartmentId).filter(Objects::nonNull).collect(Collectors.toSet());
......@@ -203,7 +206,7 @@ public class SubOrdinateStrategy extends PermissionStrategy {
//过滤一级层次组织
Map<Long, Organization> organizationMap = organizationList.stream().filter(m -> m.getDepth() == 1).collect(Collectors.toMap(Organization::getSubId, treeModel -> treeModel));
Map<Long, Long> subordinateDepartmentUserCountMap = departmentUserCountList.parallelStream().collect(Collectors.groupingBy(DepartmentUserCount::getSuperiorId, Collectors.counting()));
Map<Long, Long> subordinateUserCountMap = departmentUserCountList.parallelStream().collect(Collectors.groupingBy(DepartmentUserCount::getSuperiorId, Collectors.counting()));
List<OrgModel> modelList = allDepartmentList.stream().map(dep -> {
OrgModel orgModel = new OrgModel();
......@@ -212,7 +215,7 @@ public class SubOrdinateStrategy extends PermissionStrategy {
orgModel.setOrgId(dep.getId());
orgModel.setOrgName(dep.getDepartmentName());
orgModel.setTenantId(dep.getTenantId());
Long userNumber = subordinateDepartmentUserCountMap.get(dep.getId());
Long userNumber = subordinateUserCountMap.get(dep.getId());
orgModel.setUserNumber(userNumber != null ? Math.toIntExact(userNumber) : 0);
orgModel.setOrderNum(dep.getOrderNum());
orgModel.setIsRoot(dep.getIsRoot());
......@@ -231,10 +234,10 @@ public class SubOrdinateStrategy extends PermissionStrategy {
for (int i = 0; i < treeSize; i++) {
OrgTreeModel otm = orgTreeModelList.get(i);
Long orgId = Long.valueOf(otm.getId());
Long userNumber = subordinateDepartmentUserCountMap.get(orgId);
Long userNumber = subordinateUserCountMap.get(orgId);
otm.setUserNumber(userNumber == null ? 0 : Math.toIntExact(userNumber));
//2021/8/19 设置下级用户子树
if (search.getHasUserLeaf() && otm.getUserNumber() > 0) {
if (search.getHasUserLeaf()) {
List<OrgModel> userList = groupByOrgIdUserMap.get(orgId);
if (CollectionUtils.isNotEmpty(userList)) {
List<OrgTreeModel> userTreeList = userList.stream().map(OrgTreeModel::new).collect(Collectors.toList());
......
......@@ -110,14 +110,8 @@
#{item}
</foreach>
</if>
<if test="supOrgIds != null and supOrgIds.size() > 0">
and to2.superior_id in
<foreach collection="supOrgIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="subOrgIds != null and subOrgIds.size() > 0">
and to2.sub_id in
and to2.superior_id in
<foreach collection="subOrgIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!