Commit 58f89e56 by levphon

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

1 parent 45706e4a
......@@ -97,8 +97,15 @@ 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);
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);
List<DepartmentUserCount> departmentUserCountList = userPathMapper.selectSubordinateDepartmentList(userId, null, null, null, null);
Set<Long> hasUserDeptIdList = departmentUserCountList.stream().map(DepartmentUserCount::getDepartmentId).filter(Objects::nonNull).collect(Collectors.toSet());
......@@ -166,7 +166,8 @@ public class SubOrdinateStrategy extends PermissionStrategy {
Long userId = ShieldContextHolder.getUserId();
//如果是搜索search.getUserIds()
List<DepartmentUserCount> departmentUserCountList = userPathMapper.selectSubordinateDepartmentList(userId, search.getUserIds());
List<DepartmentUserCount> departmentUserCountList = userPathMapper.selectSubordinateDepartmentList(userId, search.getUserIds(),
search.getOrgIds(), search.getSupOrgIds(), search.getSubOrgIds());
//下级部门id
Set<Long> subDepartmentIdList = departmentUserCountList.stream().map(DepartmentUserCount::getDepartmentId).filter(Objects::nonNull).collect(Collectors.toSet());
......@@ -221,7 +222,7 @@ public class SubOrdinateStrategy extends PermissionStrategy {
List<OrgTreeModel> orgTreeModelList = modelList.stream().map(OrgTreeModel::new).sorted(Comparator.comparing(OrgTreeModel::getOrder)).collect(Collectors.toList());
//获取用户及下级用户
List<OrgModel> userPathsOrgModelList = getUserOrgModel(search.getUserIds());
List<OrgModel> userPathsOrgModelList = getUserOrgModel(departmentUserCountList);
Map<Long, List<OrgModel>> groupByOrgIdUserMap = userPathsOrgModelList.stream().collect(Collectors.groupingBy(OrgModel::getParentId));
......@@ -254,9 +255,16 @@ public class SubOrdinateStrategy extends PermissionStrategy {
return null;
}
public List<OrgModel> getUserOrgModel(Collection<Long> userIds) {
public List<OrgModel> getUserOrgModel(List<DepartmentUserCount> deptUserList) {
List<OrgModel> list = Lists.newArrayList();
List<User> userList = this.permissionUsers();
if (CollectionUtils.isEmpty(deptUserList)) {
return list;
}
Set<Long> userSet = deptUserList.stream().map(DepartmentUserCount::getUserId).collect(Collectors.toSet());
List<User> userList = userMapper.selectByIds(userSet);
userList.forEach(user -> {
OrgModel userModel = new OrgModel();
userModel.setParentId(user.getDepartmentId());
......
......@@ -104,5 +104,23 @@
#{item}
</foreach>
</if>
<if test="orgIds != null and orgIds.size() > 0">
and tu.department_id in
<foreach collection="orgIds" item="item" open="(" close=")" separator=",">
#{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
<foreach collection="subOrgIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!