|
|
@@ -584,6 +584,39 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
|
|
return baseMapper.selectVoList(lqw);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询本部门及所有下级部门的用户列表(按 userId 去重)
|
|
|
+ * <p>
|
|
|
+ * 复用 deptMapper.selectDeptAndChildById(parentId) 拿到本部门 + 所有子孙部门 ID 列表,
|
|
|
+ * 再按部门逐个查用户,合并去重后返回。
|
|
|
+ * <p>
|
|
|
+ * 典型场景:巡检任务/隐患处理等业务模块的"责任人/审核人"选择器,
|
|
|
+ * 限定可选范围 = 当前登录用户所在部门 + 所有下级部门
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<SysUserVo> selectUserListByDeptChain(Long deptId) {
|
|
|
+ if (deptId == null) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ List<Long> deptIds = deptMapper.selectDeptAndChildById(deptId);
|
|
|
+ if (CollUtil.isEmpty(deptIds)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ // 按 userId 去重合并
|
|
|
+ Map<Long, SysUserVo> resultMap = new LinkedHashMap<>(deptIds.size() * 4);
|
|
|
+ for (Long did : deptIds) {
|
|
|
+ List<SysUserVo> users = selectUserListByDept(did);
|
|
|
+ if (CollUtil.isNotEmpty(users)) {
|
|
|
+ for (SysUserVo u : users) {
|
|
|
+ if (u != null && u.getUserId() != null) {
|
|
|
+ resultMap.putIfAbsent(u.getUserId(), u);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ArrayList<>(resultMap.values());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 通过用户ID查询用户账户
|
|
|
*
|