Explorar el Código

pref: selectUserList

shc hace 9 meses
padre
commit
b6dc9c7d14

+ 26 - 0
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/dto/SysUserDTO.java

@@ -11,6 +11,7 @@ import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 import java.util.List;
+import java.util.Set;
 
 @NoArgsConstructor(access = AccessLevel.NONE)
 public final class SysUserDTO {
@@ -96,4 +97,29 @@ public final class SysUserDTO {
         private Integer userId;
 
     }
+
+    @Data
+    public static class OnPage{
+
+        private String username;
+
+        private String realName;
+
+        private Integer roleId;
+
+        private Set<Integer> finalQueryRoleIds;
+
+        private Integer deptId;
+
+        private List<Long> areaCodes;
+
+        private String lockFlag;
+
+        @NotNull(message = "size必填")
+        private Integer size;
+
+        @NotNull(message = "页码必填")
+        private Integer current;
+
+    }
 }

+ 5 - 0
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/entity/SysRole.java

@@ -1,6 +1,7 @@
 package com.qunzhixinxi.hnqz.admin.api.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
@@ -60,4 +61,8 @@ public class SysRole extends Model<SysRole> {
 	@TableLogic
 	private String delFlag;
 
+	//  该角色可以看见的角色
+	@TableField(value = "vis")
+	private String visible;
+
 }

+ 298 - 183
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/SysUserController.java

@@ -30,17 +30,18 @@ import com.qunzhixinxi.hnqz.admin.api.vo.UserVO;
 import com.qunzhixinxi.hnqz.admin.api.dto.CommonUserDTO;
 import com.qunzhixinxi.hnqz.admin.api.model.input.UserCertificationInput;
 import com.qunzhixinxi.hnqz.admin.api.model.excel.CommonUserExcelModel;
-import com.qunzhixinxi.hnqz.admin.api.constant.enums.DelEnum;
 import com.qunzhixinxi.hnqz.admin.manager.SysUserManager;
 import com.qunzhixinxi.hnqz.admin.mapper.SysUserMapper;
 import com.qunzhixinxi.hnqz.admin.mapper.SysUserRoleMapper;
 import com.qunzhixinxi.hnqz.admin.service.SysAreaEntityService;
 import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
+import com.qunzhixinxi.hnqz.admin.service.SysRoleService;
 import com.qunzhixinxi.hnqz.admin.service.SysUserAreaService;
 import com.qunzhixinxi.hnqz.admin.service.SysUserService;
 import com.qunzhixinxi.hnqz.admin.service.WmPlatformQuizTestResultService;
 import com.qunzhixinxi.hnqz.common.core.constant.CommonConstants;
 import com.qunzhixinxi.hnqz.common.core.entity.BaseEntity;
+import com.qunzhixinxi.hnqz.common.core.exception.BizException;
 import com.qunzhixinxi.hnqz.common.core.util.R;
 import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
 import com.qunzhixinxi.hnqz.common.security.annotation.Inner;
@@ -69,10 +70,12 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -99,10 +102,12 @@ public class SysUserController {
     private final WmPlatformQuizTestResultService platformQuizTestResultService;
     private final SysAreaEntityService areaEntityService;
     private final SysUserManager userManager;
+    private final SysRoleService roleService;
 
     private static final List<Integer> SALESMAN_ROLE_ID = ListUtil.of(5, 6);
     private static final List<Integer> ADMIN_ROLE_ID = ListUtil.of(1, 2, 7, 19, 27, 34, 35, 44, 45, 46, 47, 48, 49);
 
+
     /**
      * 判断可以登陆的角色
      * 只有单纯是5 和 6的角色才不能登陆
@@ -807,19 +812,19 @@ public class SysUserController {
     public R<?> updateUser(@Valid @RequestBody UserDTO userDto) {
 
 
-        if (CollUtil.containsAny(userDto.getRole(), SALESMAN_ROLE_ID)) {
-            return R.failed("当前业务规定不支持修改(全职/兼职)业务员信息");
-        }
+        // if (CollUtil.containsAny(userDto.getRole(), SALESMAN_ROLE_ID)) {
+        //     return R.failed("当前业务规定不支持修改(全职/兼职)业务员信息");
+        // }
 
-        SysDept sysDept = sysDeptService.getById(userDto.getDeptId());
+        // SysDept sysDept = sysDeptService.getById(userDto.getDeptId());
 
         if (null != userDto.getUserId()) {
 
             SysUser oldData = userService.getById(userDto.getUserId());
 
-            if (StrUtil.isNotBlank(oldData.getRealname()) && StrUtil.isNotBlank(userDto.getRealname()) && !StrUtil.equals(oldData.getRealname(), userDto.getRealname())) {
-                return R.failed("用户不能修改姓名");
-            }
+            // if (StrUtil.isNotBlank(oldData.getRealname()) && StrUtil.isNotBlank(userDto.getRealname()) && !StrUtil.equals(oldData.getRealname(), userDto.getRealname())) {
+            //     return R.failed("用户不能修改姓名");
+            // }
             if (StrUtil.isNotBlank(oldData.getIdCardNumber()) && StrUtil.isNotBlank(userDto.getIdCardNumber()) && !StrUtil.equals(oldData.getIdCardNumber(), userDto.getIdCardNumber())) {
                 return R.failed("用户不能修改身份证号");
             }
@@ -827,180 +832,180 @@ public class SysUserController {
         }
 
 
-        if (SecurityUtils.getRoles().contains(2) || SecurityUtils.getRoles().contains(1)) {
-            if (userDto.getRole().contains(2)) {
-                UserDTO userDTO = new UserDTO();
-                userDTO.setPlatId(userDto.getUsername());
-                userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
-                List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
-                if (CollUtil.isNotEmpty(userDTOList)) {
-                    for (UserVO userVO : userDTOList) {
-                        if (null != userVO.getRoleList()) {
-                            for (SysRole sysRole : userVO.getRoleList()) {
-                                if (sysRole.getRoleId() == 3) {
-                                    return R.failed("用户不能同时为平台管理员和药企管理员");
-                                }
-                            }
-                        }
-                    }
-                }
-
-            } else if (userDto.getRole().contains(3)) {
-                UserDTO userDTO = new UserDTO();
-                userDTO.setPlatId(userDto.getUsername());
-                userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
-                List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
-                if (CollUtil.isNotEmpty(userDTOList)) {
-                    for (UserVO userVO : userDTOList) {
-                        if (null != userVO.getRoleList()) {
-                            for (SysRole sysRole : userVO.getRoleList()) {
-                                if (sysRole.getRoleId() == 2) {
-                                    return R.failed("用户不能同时为平台管理员和药企管理员");
-                                }
-
-                                if (userDto.getDeptId().equals(userVO.getDeptId())) {
-                                    if (sysRole.getRoleId() == 6) {
-                                        return R.failed("用户已存在本机构药企管理员,不能同时为兼职学术推广员");
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-                SysUser query = new SysUser();
-                query.setUsername(userDto.getUsername());
-                query.setDeptId(userDto.getDeptId());
-                SysUser sysUser = sysUserMapper.selectUserByName(query);
-                if (sysUser != null) {
-                    if (sysDept.getLevel() != 2) {
-                        return R.failed("角色选为药企管理员时,组织架构必须为药企");
-                    }
-                }
-
-            } else if (userDto.getRole().contains(4) || userDto.getRole().contains(37)) {
-                UserDTO userDTO = new UserDTO();
-                userDTO.setPlatId(userDto.getUsername());
-                userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
-                List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
-                if (CollUtil.isNotEmpty(userDTOList)) {
-                    for (UserVO userVO : userDTOList) {
-                        if (null != userVO.getRoleList()) {
-                            for (SysRole sysRole : userVO.getRoleList()) {
-                                if (sysRole.getRoleId() == 2) {
-                                    return R.failed("用户不能同时为平台管理员和经销商管理员");
-                                }
-
-                                if (sysRole.getRoleId() == 3) {
-                                    return R.failed("用户不能同时为药企管理员和经销商管理员");
-                                }
-                                if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 4) {
-                                    return R.failed("用户已存在CSO管理员角色,不能维护为其他经销商组织的CSO管理员角色");
-                                }
-                                if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 9) {
-                                    return R.failed("用户已存在CRO管理员角色,不能维护为其他经销商组织的CSO管理员角色");
-                                }
-                            }
-                        }
-                    }
-                }
-
-            } else if (userDto.getRole().contains(9)) {
-                UserDTO userDTO = new UserDTO();
-                userDTO.setPlatId(userDto.getUsername());
-                userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
-                List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
-                if (CollUtil.isNotEmpty(userDTOList)) {
-                    for (UserVO userVO : userDTOList) {
-                        if (null != userVO.getRoleList()) {
-                            for (SysRole sysRole : userVO.getRoleList()) {
-                                if (sysRole.getRoleId() == 2) {
-                                    return R.failed("用户不能同时为平台管理员和CRO管理员");
-                                }
-
-                                if (sysRole.getRoleId() == 3) {
-                                    return R.failed("用户不能同时为药企管理员和CRO管理员");
-                                }
-                                if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 4) {
-                                    return R.failed("用户已存在CSO管理员角色,不能维护为其他经销商组织的CRO管理员角色");
-                                }
-                                if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 9) {
-                                    return R.failed("用户已存在CRO管理员角色,不能维护为其他经销商组织的CRO管理员角色");
-                                }
-                            }
-                        }
-                    }
-                }
-
-            } else if (userDto.getRole().contains(6)) {
-                UserDTO userDTO = new UserDTO();
-                userDTO.setPlatId(userDto.getUsername());
-                userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
-                List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
-                if (CollUtil.isNotEmpty(userDTOList)) {
-                    for (UserVO userVO : userDTOList) {
-                        if (null != userVO.getRoleList()) {
-                            for (SysRole sysRole : userVO.getRoleList()) {
-                                if (sysRole.getRoleId() == 2) {
-                                    return R.failed("用户不能同时为平台管理员和兼职学术推广员");
-                                }
-                                if (userDto.getDeptId().equals(userVO.getDeptId())) {
-                                    if (sysRole.getRoleId() == 3) {
-                                        return R.failed("用户已存在本药企药企管理员,不能同时为兼职学术推广员");
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-
-            } else {
-                if (!userDto.getDeptId().equals(SecurityUtils.getUser().getDeptId())) {
-                    if (userDto.getRole().contains(5) || userDto.getRole().contains(6)) {
-                        return R.failed("不能跨机构维护学术推广员");
-                    }
-                }
-            }
-
-        } else {
-            if (!userDto.getDeptId().equals(SecurityUtils.getUser().getDeptId())) {
-                if (userDto.getRole().contains(5) || userDto.getRole().contains(6)) {
-                    return R.failed("不能跨机构维护学术推广员");
-                }
-            }
-
-            Integer count = sysUserMapper.selectCount(Wrappers.<SysUser>lambdaQuery()
-                    .eq(SysUser::getUsername, userDto.getUsername())
-                    .eq(SysUser::getDeptId, userDto.getDeptId())
-                    .eq(SysUser::getDelFlag, DelEnum.NOT_DEL.getVal()));
-            if (count > 0) {
-                if (userDto.getRole().contains(6) && userDto.getRole().contains(4) || userDto.getRole().contains(37)) {
-                    return R.failed("用户不能同时为经销商管理员角色和兼职学术推广员角色");
-                }
-                if (userDto.getRole().contains(7) && userDto.getRole().contains(6)) {
-                    return R.failed("用户不能同时为财务管理员角色和兼职学术推广员角色");
-                }
-                if (userDto.getRole().contains(3)) {
-                    if (sysDept.getLevel() != 2) {
-                        return R.failed("角色选为药企管理员时,组织架构必须为药企");
-                    }
-                }
-            }
-        }
-
-        // 校验身份证上的年龄
-        if (StringUtils.isNotEmpty(userDto.getIdCardNumber())) {
-            // 获取更新操作的用户角色
-            List<Integer> roles = userDto.getRole();
-            // 如果角色中包含全职和兼职就需要校验身份证年龄
-            if (roles.contains(5) || roles.contains(6)) {
-                int ageByIdCard = IdcardUtil.getAgeByIdCard(userDto.getIdCardNumber());
-                if (ageByIdCard < 18) {
-                    return R.failed("年龄未满十八");
-                } else if (ageByIdCard > 65) {
-                    return R.failed("年龄已超过六十五");
-                }
-            }
-        }
+        // if (SecurityUtils.getRoles().contains(2) || SecurityUtils.getRoles().contains(1)) {
+        //     if (userDto.getRole().contains(2)) {
+        //         UserDTO userDTO = new UserDTO();
+        //         userDTO.setPlatId(userDto.getUsername());
+        //         userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
+        //         List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
+        //         if (CollUtil.isNotEmpty(userDTOList)) {
+        //             for (UserVO userVO : userDTOList) {
+        //                 if (null != userVO.getRoleList()) {
+        //                     for (SysRole sysRole : userVO.getRoleList()) {
+        //                         if (sysRole.getRoleId() == 3) {
+        //                             return R.failed("用户不能同时为平台管理员和药企管理员");
+        //                         }
+        //                     }
+        //                 }
+        //             }
+        //         }
+        //
+        //     } else if (userDto.getRole().contains(3)) {
+        //         UserDTO userDTO = new UserDTO();
+        //         userDTO.setPlatId(userDto.getUsername());
+        //         userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
+        //         List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
+        //         if (CollUtil.isNotEmpty(userDTOList)) {
+        //             for (UserVO userVO : userDTOList) {
+        //                 if (null != userVO.getRoleList()) {
+        //                     for (SysRole sysRole : userVO.getRoleList()) {
+        //                         if (sysRole.getRoleId() == 2) {
+        //                             return R.failed("用户不能同时为平台管理员和药企管理员");
+        //                         }
+        //
+        //                         if (userDto.getDeptId().equals(userVO.getDeptId())) {
+        //                             if (sysRole.getRoleId() == 6) {
+        //                                 return R.failed("用户已存在本机构药企管理员,不能同时为兼职学术推广员");
+        //                             }
+        //                         }
+        //                     }
+        //                 }
+        //             }
+        //         }
+        //         SysUser query = new SysUser();
+        //         query.setUsername(userDto.getUsername());
+        //         query.setDeptId(userDto.getDeptId());
+        //         SysUser sysUser = sysUserMapper.selectUserByName(query);
+        //         if (sysUser != null) {
+        //             if (sysDept.getLevel() != 2) {
+        //                 return R.failed("角色选为药企管理员时,组织架构必须为药企");
+        //             }
+        //         }
+        //
+        //     } else if (userDto.getRole().contains(4) || userDto.getRole().contains(37)) {
+        //         UserDTO userDTO = new UserDTO();
+        //         userDTO.setPlatId(userDto.getUsername());
+        //         userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
+        //         List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
+        //         if (CollUtil.isNotEmpty(userDTOList)) {
+        //             for (UserVO userVO : userDTOList) {
+        //                 if (null != userVO.getRoleList()) {
+        //                     for (SysRole sysRole : userVO.getRoleList()) {
+        //                         if (sysRole.getRoleId() == 2) {
+        //                             return R.failed("用户不能同时为平台管理员和经销商管理员");
+        //                         }
+        //
+        //                         if (sysRole.getRoleId() == 3) {
+        //                             return R.failed("用户不能同时为药企管理员和经销商管理员");
+        //                         }
+        //                         if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 4) {
+        //                             return R.failed("用户已存在CSO管理员角色,不能维护为其他经销商组织的CSO管理员角色");
+        //                         }
+        //                         if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 9) {
+        //                             return R.failed("用户已存在CRO管理员角色,不能维护为其他经销商组织的CSO管理员角色");
+        //                         }
+        //                     }
+        //                 }
+        //             }
+        //         }
+        //
+        //     } else if (userDto.getRole().contains(9)) {
+        //         UserDTO userDTO = new UserDTO();
+        //         userDTO.setPlatId(userDto.getUsername());
+        //         userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
+        //         List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
+        //         if (CollUtil.isNotEmpty(userDTOList)) {
+        //             for (UserVO userVO : userDTOList) {
+        //                 if (null != userVO.getRoleList()) {
+        //                     for (SysRole sysRole : userVO.getRoleList()) {
+        //                         if (sysRole.getRoleId() == 2) {
+        //                             return R.failed("用户不能同时为平台管理员和CRO管理员");
+        //                         }
+        //
+        //                         if (sysRole.getRoleId() == 3) {
+        //                             return R.failed("用户不能同时为药企管理员和CRO管理员");
+        //                         }
+        //                         if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 4) {
+        //                             return R.failed("用户已存在CSO管理员角色,不能维护为其他经销商组织的CRO管理员角色");
+        //                         }
+        //                         if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 9) {
+        //                             return R.failed("用户已存在CRO管理员角色,不能维护为其他经销商组织的CRO管理员角色");
+        //                         }
+        //                     }
+        //                 }
+        //             }
+        //         }
+        //
+        //     } else if (userDto.getRole().contains(6)) {
+        //         UserDTO userDTO = new UserDTO();
+        //         userDTO.setPlatId(userDto.getUsername());
+        //         userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
+        //         List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
+        //         if (CollUtil.isNotEmpty(userDTOList)) {
+        //             for (UserVO userVO : userDTOList) {
+        //                 if (null != userVO.getRoleList()) {
+        //                     for (SysRole sysRole : userVO.getRoleList()) {
+        //                         if (sysRole.getRoleId() == 2) {
+        //                             return R.failed("用户不能同时为平台管理员和兼职学术推广员");
+        //                         }
+        //                         if (userDto.getDeptId().equals(userVO.getDeptId())) {
+        //                             if (sysRole.getRoleId() == 3) {
+        //                                 return R.failed("用户已存在本药企药企管理员,不能同时为兼职学术推广员");
+        //                             }
+        //                         }
+        //                     }
+        //                 }
+        //             }
+        //         }
+        //
+        //     } else {
+        //         if (!userDto.getDeptId().equals(SecurityUtils.getUser().getDeptId())) {
+        //             if (userDto.getRole().contains(5) || userDto.getRole().contains(6)) {
+        //                 return R.failed("不能跨机构维护学术推广员");
+        //             }
+        //         }
+        //     }
+        //
+        // } else {
+        //     if (!userDto.getDeptId().equals(SecurityUtils.getUser().getDeptId())) {
+        //         if (userDto.getRole().contains(5) || userDto.getRole().contains(6)) {
+        //             return R.failed("不能跨机构维护学术推广员");
+        //         }
+        //     }
+        //
+        //     Integer count = sysUserMapper.selectCount(Wrappers.<SysUser>lambdaQuery()
+        //             .eq(SysUser::getUsername, userDto.getUsername())
+        //             .eq(SysUser::getDeptId, userDto.getDeptId())
+        //             .eq(SysUser::getDelFlag, DelEnum.NOT_DEL.getVal()));
+        //     if (count > 0) {
+        //         if (CollUtil.containsAll(userDto.getRole(), ListUtil.of(6, 37))) {
+        //             return R.failed("用户不能同时为经销商管理员角色和兼职学术推广员角色");
+        //         }
+        //         if (userDto.getRole().contains(7) && userDto.getRole().contains(6)) {
+        //             return R.failed("用户不能同时为财务管理员角色和兼职学术推广员角色");
+        //         }
+        //         if (userDto.getRole().contains(3)) {
+        //             if (sysDept.getLevel() != 2) {
+        //                 return R.failed("角色选为药企管理员时,组织架构必须为药企");
+        //             }
+        //         }
+        //     }
+        // }
+        //
+        // // 校验身份证上的年龄
+        // if (StringUtils.isNotEmpty(userDto.getIdCardNumber())) {
+        //     // 获取更新操作的用户角色
+        //     List<Integer> roles = userDto.getRole();
+        //     // 如果角色中包含全职和兼职就需要校验身份证年龄
+        //     if (roles.contains(5) || roles.contains(6)) {
+        //         int ageByIdCard = IdcardUtil.getAgeByIdCard(userDto.getIdCardNumber());
+        //         if (ageByIdCard < 18) {
+        //             return R.failed("年龄未满十八");
+        //         } else if (ageByIdCard > 65) {
+        //             return R.failed("年龄已超过六十五");
+        //         }
+        //     }
+        // }
 
         return R.ok(userService.updateUser(userDto));
     }
@@ -1024,7 +1029,7 @@ public class SysUserController {
      * @param userDTO 查询参数列表
      * @return 用户集合
      */
-    @PostMapping(value = "/selectUserList")
+    // @PostMapping(value = "/selectUserList")
     public R<?> selectUserList(@RequestBody UserDTO userDTO) {
 
         HnqzUser user = SecurityUtils.getUser();
@@ -1083,6 +1088,116 @@ public class SysUserController {
         return R.ok(userVosPage);
     }
 
+    /**
+     * 分页查询用户
+     *
+     * @param query 查询参数列表
+     * @return 用户集合
+     */
+    @PostMapping(value = "/selectUserList")
+    public R<?> pageUsers(@Validated @RequestBody SysUserDTO.OnPage query) {
+
+
+        //  获取全部的可用角色
+        Map<Integer, SysRole> roleId2RoleMap = roleService.list().stream().collect(Collectors.toMap(SysRole::getRoleId, Function.identity()));
+
+
+        // 操作人
+        HnqzUser user = SecurityUtils.getUser();
+
+        // 获取操作人的角色
+        Set<Integer> operatorRoleIds = new HashSet<>(SecurityUtils.getRoles());
+
+
+        Set<Integer> targetRoleIds = new HashSet<>();
+
+
+        SysRole role = null;
+
+        // 系统管理员
+        if (operatorRoleIds.contains(1)) {
+            role = roleId2RoleMap.get(1);
+        }
+        // 中生平台管理员
+        else if (operatorRoleIds.contains(2)) {
+            role = roleId2RoleMap.get(2);
+        }
+        // 事业部系统管理员
+        else if (operatorRoleIds.contains(50)) {
+            role = roleId2RoleMap.get(50);
+        }
+        // 运营管理员
+        else if (operatorRoleIds.contains(3)) {
+            role = roleId2RoleMap.get(3);
+        }
+        // 区域管理员
+        else if (operatorRoleIds.contains(4)) {
+            role = roleId2RoleMap.get(4);
+        }
+        // 服务商管理员
+        else if (operatorRoleIds.contains(37)) {
+            role = roleId2RoleMap.get(37);
+        }
+
+        if (role == null){
+            throw new BizException("当前用户角色不可用");
+        } else {
+            String visible = role.getVisible();
+            if (StrUtil.isBlank(visible)) {
+                throw new BizException("当前角色未配置查询角色");
+            }
+
+            Set<Integer> visibles = Arrays.stream(visible.split(StrUtil.COMMA)).mapToInt(Integer::valueOf).boxed().collect(Collectors.toSet());
+
+            Integer targetRoleId = query.getRoleId();
+
+            if (targetRoleId == null){
+                targetRoleIds.addAll(visibles);
+            } else if (visibles.contains(targetRoleId)) {
+                targetRoleIds.add(targetRoleId);
+            } else {
+                throw new BizException("当前角色禁止查看其他角色");
+            }
+        }
+
+        query.setFinalQueryRoleIds(targetRoleIds);
+
+        Page<SysUser> userVosPage = userService.pageUser(query, SecurityUtils.getUser());
+
+
+        // Set<Integer> userIds = userVosPage.getRecords().stream().map(UserVO::getUserId).collect(Collectors.toSet());
+        //
+        // if (CollUtil.isNotEmpty(userIds)) {
+        //
+        //     List<WmPlatformQuizTestResult> quizTestResults = platformQuizTestResultService.listPltQuizResults(userIds);
+        //
+        //     LocalDate today = LocalDate.now();
+        //     Map<Integer, List<WmPlatformQuizTestResult>> quizTestResult = quizTestResults.stream().filter(res -> res.getExpiry().isAfter(today)).collect(Collectors.groupingBy(WmPlatformQuizTestResult::getUserId));
+        //
+        //     userVosPage.getRecords().forEach(vo -> {
+        //         List<WmPlatformQuizTestResult> testResults = quizTestResult.get(vo.getUserId());
+        //         List<WmQuizResultModel> pure = null;
+        //         if (CollUtil.isNotEmpty(testResults)) {
+        //             Map<Integer, List<WmPlatformQuizTestResult>> collect = testResults.stream().collect(Collectors.groupingBy(WmPlatformQuizTestResult::getQuizId));
+        //             pure = new ArrayList<>(collect.size());
+        //
+        //             for (Map.Entry<Integer, List<WmPlatformQuizTestResult>> entry : collect.entrySet()) {
+        //                 pure.add(entry.getValue().get(0).getQuizResult());
+        //             }
+        //         }
+        //
+        //         vo.setQuizResult(CollUtil.isEmpty(pure) ? Collections.emptyList() : pure);
+        //
+        //         // 所属区域
+        //         List<Long> areaCodes = userAreaService.listUserAreas(Long.valueOf(vo.getUserId()));
+        //         vo.setAreaCodes(areaCodes);
+        //
+        //     });
+        // }
+
+        return R.ok(userVosPage);
+    }
+
     /**
      * 修改个人信息
      *

+ 11 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/SysUserService.java

@@ -3,6 +3,7 @@ package com.qunzhixinxi.hnqz.admin.service;
 import cn.hutool.core.lang.tree.Tree;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qunzhixinxi.hnqz.admin.api.dto.SysUserDTO;
 import com.qunzhixinxi.hnqz.admin.api.dto.UserDTO;
 import com.qunzhixinxi.hnqz.admin.api.dto.UserInfo;
 import com.qunzhixinxi.hnqz.admin.api.dto.UserPwd;
@@ -46,6 +47,7 @@ public interface SysUserService extends IService<SysUser> {
     Page<UserVO> selectUserList(Page<UserVO> page, UserDTO userDTO, HnqzUser user);
 
     Page<UserVO> selectUserList1(Page<UserVO> page, UserDTO userDTO, HnqzUser user);
+
     Page<UserVO> selectUserList2(Page<UserVO> page, UserDTO userDTO, HnqzUser user);
 
     /**
@@ -148,4 +150,13 @@ public interface SysUserService extends IService<SysUser> {
      * @return 延期结果
      */
     Boolean exceedingPwdChangeTime(HnqzUser user);
+
+    /**
+     * 查询用户分页
+     *
+     * @param query    查询条件
+     * @param operator 操作人
+     * @return 用户分页
+     */
+    Page<SysUser> pageUser(SysUserDTO.OnPage query, HnqzUser operator);
 }

+ 40 - 10
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/SysUserServiceImpl.java

@@ -10,10 +10,12 @@ import cn.hutool.core.util.IdcardUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.nacos.common.utils.Md5Utils;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
+import com.qunzhixinxi.hnqz.admin.api.dto.SysUserDTO;
 import com.qunzhixinxi.hnqz.admin.api.dto.UserDTO;
 import com.qunzhixinxi.hnqz.admin.api.dto.UserInfo;
 import com.qunzhixinxi.hnqz.admin.api.dto.UserPwd;
@@ -45,6 +47,7 @@ import com.qunzhixinxi.hnqz.admin.service.SysUserRoleService;
 import com.qunzhixinxi.hnqz.admin.service.SysUserService;
 import com.qunzhixinxi.hnqz.common.core.constant.CacheConstants;
 import com.qunzhixinxi.hnqz.common.core.constant.CommonConstants;
+import com.qunzhixinxi.hnqz.common.core.exception.BizException;
 import com.qunzhixinxi.hnqz.common.core.util.R;
 import com.qunzhixinxi.hnqz.common.data.datascope.DataScope;
 import com.qunzhixinxi.hnqz.common.security.encoder.SM4PasswordEncoder;
@@ -64,6 +67,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.Collections;
@@ -231,6 +235,34 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         return this.update(Wrappers.<SysUser>lambdaUpdate().eq(SysUser::getUserId, user.getId()).set(SysUser::getLatestChangePwdTime, LocalDateTime.now()));
     }
 
+    /**
+     * 查询用户分页
+     *
+     * @param query    查询条件
+     * @param operator 操作人
+     * @return 用户分页
+     */
+    @Override
+    public Page<SysUser> pageUser(SysUserDTO.OnPage query, HnqzUser operator) {
+
+        LambdaQueryWrapper<SysUser> queryWrapper = Wrappers.lambdaQuery();
+
+
+        Set<Integer> userIdByRoleIdSet = sysUserRoleService.list(Wrappers.<SysUserRole>lambdaQuery().in(SysUserRole::getRoleId, query.getFinalQueryRoleIds())).stream().mapToInt(SysUserRole::getUserId).boxed().collect(Collectors.toSet());
+
+
+        queryWrapper
+                .like(StrUtil.isNotBlank(query.getUsername()), SysUser::getUsername, query.getUsername())
+                .like(StrUtil.isNotBlank(query.getRealName()), SysUser::getRealname, query.getRealName())
+                .eq(StrUtil.isNotBlank(query.getLockFlag()), SysUser::getLockFlag, query.getLockFlag())
+                .eq(query.getDeptId() != null, SysUser::getDeptId, query.getDeptId())
+                .in(SysUser::getUserId, userIdByRoleIdSet);
+
+        Page<SysUser> page = this.page(new Page<>(query.getCurrent(), query.getSize()), queryWrapper);
+
+        return page;
+    }
+
     /**
      * 封装错误信息
      *
@@ -545,7 +577,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         if (StrUtil.isNotBlank(idCard)) {
             // log.error("身份证号不存在");
             // errorMap(errorMap, "身份证号不存在", commonUserDTO.getId());
-        // } else {
+            // } else {
             if (!Validator.isCitizenId(idCard)) {
                 log.error("身份证号格式不正确");
                 errorMap(errorMap, "身份证号格式不正确", commonUserDTO.getId());
@@ -575,7 +607,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 
             // 校验部门下是否有启用的用户
             int count = count(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, username));
-                    // .eq(dept != null, SysUser::getDeptId, dept.getDeptId()));
+            // .eq(dept != null, SysUser::getDeptId, dept.getDeptId()));
             if (count != 0) {
                 log.info("手机号被占用");
                 errorMap(errorMap, "手机号被占用", commonUserDTO.getId());
@@ -753,7 +785,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
             return baseMapper.getUserVosPage(page, userDTO, new DataScope());
         }
         // 系统管理员
-        else if (SecurityUtils.getRoles().contains(50)){
+        else if (SecurityUtils.getRoles().contains(50)) {
 
             // 3营管理员
             // 4域管理员
@@ -774,12 +806,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 
             List<Integer> role = userDTO.getRole();
             if (CollUtil.isEmpty(role)) {
-                userDTO.setRole(ListUtil.of( 3, 4, 5, 37, 38, 39, 40, 41, 42, 43, 44, 45, 47, 48, 49, 50));
+                userDTO.setRole(ListUtil.of(3, 4, 5, 37, 38, 39, 40, 41, 42, 43, 44, 45, 47, 48, 49, 50));
             }
 
             return baseMapper.getUserVosPage(page, userDTO, new DataScope());
-        }
-        else if (SecurityUtils.getRoles().contains(2) /*|| SecurityUtils.getRoles().contains(35)*/) {
+        } else if (SecurityUtils.getRoles().contains(2) /*|| SecurityUtils.getRoles().contains(35)*/) {
             // 人数据权限
             List<Integer> bcRoles = Stream.of(2, 3, 4, 5, 6, 7, 9, 10, 11, 13, 19, 31, 35, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50).collect(Collectors.toList());
             if (CollUtil.isNotEmpty(userDTO.getRole())) {
@@ -904,7 +935,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
             return baseMapper.getUserVosPage(page, userDTO, new DataScope());
         }
         // 系统管理员
-        else if (SecurityUtils.getRoles().contains(50)){
+        else if (SecurityUtils.getRoles().contains(50)) {
 
             // 3营管理员
             // 4域管理员
@@ -925,12 +956,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 
             List<Integer> role = userDTO.getRole();
             if (CollUtil.isEmpty(role)) {
-                userDTO.setRole(ListUtil.of( 3, 4, 5, 37, 38, 39, 40, 41, 42, 43, 44, 45, 47, 48, 49, 50));
+                userDTO.setRole(ListUtil.of(3, 4, 5, 37, 38, 39, 40, 41, 42, 43, 44, 45, 47, 48, 49, 50));
             }
 
             return baseMapper.getUserVosPage(page, userDTO, new DataScope());
-        }
-        else if (SecurityUtils.getRoles().contains(2) /*|| SecurityUtils.getRoles().contains(35)*/) {
+        } else if (SecurityUtils.getRoles().contains(2) /*|| SecurityUtils.getRoles().contains(35)*/) {
             // 人数据权限
             List<Integer> bcRoles = Stream.of(2, 3, 4, 5, 6, 7, 9, 10, 11, 13, 19, 31, 35, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50).collect(Collectors.toList());
             if (CollUtil.isNotEmpty(userDTO.getRole())) {

+ 2 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/WmDaAgentServiceImpl.java

@@ -252,6 +252,8 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
             page.getRecords().forEach(agent -> {
                 List<Long> areas = enterpriseAreaService.listEntAreas(Collections.singletonList(Long.valueOf(agent.getDeptId())));
                 agent.setAreaCodes(areas);
+                SysDept sysDept = sysDeptMapper.selectById(agent.getDeptId());
+                agent.setAbbr(sysDept != null ? sysDept.getAbbr() : "");
             });
         }