|
@@ -29,7 +29,6 @@ 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.api.constant.enums.SubjectLocation;
|
|
|
-import com.qunzhixinxi.hnqz.admin.api.constant.enums.SubjectTypeEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.mapper.SysCsmUserRelationMapper;
|
|
|
import com.qunzhixinxi.hnqz.admin.mapper.SysUserMapper;
|
|
|
import com.qunzhixinxi.hnqz.admin.mapper.SysUserRoleMapper;
|
|
@@ -45,7 +44,6 @@ import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
@@ -81,1282 +79,1121 @@ import java.util.stream.Stream;
|
|
|
@RequestMapping("/user")
|
|
|
public class SysUserController {
|
|
|
|
|
|
- private final SysUserService userService;
|
|
|
- private final SysUserMapper sysUserMapper;
|
|
|
- private final SysDeptService sysDeptService;
|
|
|
- private final RedisTemplate<String, Object> redisTemplate;
|
|
|
- private final SysUserRoleMapper sysUserRoleMapper;
|
|
|
- private final WmPlatformQuizTestResultService platformQuizTestResultService;
|
|
|
- private final SysCsmUserRelationMapper sysCsmUserRelationMapper;
|
|
|
-
|
|
|
-
|
|
|
- private boolean isZbOrDbUsers(Integer[] roles) {
|
|
|
- if (null == roles) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 1-管理员,2-平台管理员,3-药企管理员,4-CSO管理员,7-财务管理员,9-CRO管理员,11-患教管理员,19-CMS,27-平台财务管理员,33-行政人员,
|
|
|
- // 34-财务复核, 35-BC总负责人
|
|
|
- return Arrays.asList(roles).contains(1)
|
|
|
- || Arrays.asList(roles).contains(2)
|
|
|
- || Arrays.asList(roles).contains(3)
|
|
|
- || Arrays.asList(roles).contains(4)
|
|
|
- || Arrays.asList(roles).contains(7)
|
|
|
- || Arrays.asList(roles).contains(9)
|
|
|
- || Arrays.asList(roles).contains(11)
|
|
|
- || Arrays.asList(roles).contains(19)
|
|
|
- || Arrays.asList(roles).contains(27)
|
|
|
- || Arrays.asList(roles).contains(33)
|
|
|
- || Arrays.asList(roles).contains(34)
|
|
|
- || Arrays.asList(roles).contains(35);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 用户管理-认证
|
|
|
- *
|
|
|
- * @param input
|
|
|
- * @return R
|
|
|
- */
|
|
|
- @SysLog("用户管理-认证")
|
|
|
- @GetMapping("/getAuthInfo")
|
|
|
- public R getAuthInfo(UserCertificationInput input) {
|
|
|
- //参数校验
|
|
|
- return userService.getAuthInfo(input);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 用户管理-认证-确定
|
|
|
- *
|
|
|
- * @param input
|
|
|
- * @return R
|
|
|
- */
|
|
|
- @SysLog("用户管理-认证-确定")
|
|
|
- @PostMapping("/batchChannelCert")
|
|
|
- public R batchChannelCert(@RequestBody UserCertificationInput input) {
|
|
|
- //参数校验
|
|
|
- return userService.batchChannelCert(input);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取指定用户全部信息
|
|
|
- *
|
|
|
- * @return 用户信息
|
|
|
- */
|
|
|
- @Inner
|
|
|
- @GetMapping("/info/{username}")
|
|
|
- public R info(@PathVariable String username) {
|
|
|
-
|
|
|
- boolean b = username.endsWith("@mp");
|
|
|
- if (b){
|
|
|
- username = username.split("@")[0];
|
|
|
- }
|
|
|
-
|
|
|
- // 根据用户名查询用户时,过滤掉已删除和已禁用的用户
|
|
|
- List<SysUser> user = userService.list(Wrappers.<SysUser>query().lambda().eq(SysUser::getUsername, username)
|
|
|
- .eq(SysUser::getDelFlag, 0).eq(SysUser::getLockFlag, 0));
|
|
|
-
|
|
|
- if (user == null) {
|
|
|
- return R.failed(null, String.format("用户信息为空 %s", username));
|
|
|
- }
|
|
|
-
|
|
|
- if (user.size() == 1) {
|
|
|
- UserInfo userInfo = userService.findUserInfo(user.get(0));
|
|
|
-
|
|
|
- boolean zbOrDbUsers = isZbOrDbUsers(userInfo.getRoles());
|
|
|
- // 校验用户角色是否包含众包用户和医药代表用户
|
|
|
- if ((b && !zbOrDbUsers)||(!b && zbOrDbUsers)){
|
|
|
- // 角色是小程序角色,则直接返回
|
|
|
- return R.ok(userInfo);
|
|
|
- } else {
|
|
|
- return R.failed(null, String.format("用户信息错误 %s", username));
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 小程序多账号情况
|
|
|
- if (b) {
|
|
|
- for (SysUser u : user) {
|
|
|
- UserInfo userInfo = userService.findUserInfo(u);
|
|
|
- if (!isZbOrDbUsers(userInfo.getRoles())) {
|
|
|
- // 角色是小程序角色,则直接返回
|
|
|
- return R.ok(userInfo);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- String password = redisTemplate.opsForValue().get(username) + "";
|
|
|
- if (null != password) {
|
|
|
- for (int i = 0; i < user.size(); i++) {
|
|
|
- UserInfo userInfo = userService.findUserInfo(user.get(i));
|
|
|
- if (Md5Utils.getMD5(password.getBytes()).equals(user.get(i).getW1())) {
|
|
|
- if (isZbOrDbUsers(userInfo.getRoles())) {
|
|
|
- redisTemplate.delete(username);
|
|
|
- return R.ok(userInfo);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return R.failed(null, String.format("用户信息为空 %s", username));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过ID查询用户信息
|
|
|
- *
|
|
|
- * @param id ID
|
|
|
- * @return 用户信息
|
|
|
- */
|
|
|
- @GetMapping("/{id}")
|
|
|
- public R user(@PathVariable Integer id) {
|
|
|
- return R.ok(userService.selectUserVoById(id));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据用户名查询用户信息
|
|
|
- *
|
|
|
- * @param username 用户名
|
|
|
- * @return
|
|
|
- */
|
|
|
- @GetMapping("/details/{username}")
|
|
|
- public R user(@PathVariable String username) {
|
|
|
- SysUser condition = new SysUser();
|
|
|
- condition.setUsername(username);
|
|
|
- return R.ok(userService.getOne(new QueryWrapper<>(condition)));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据用户名查询用户信息
|
|
|
- *
|
|
|
- * @param username 用户名
|
|
|
- * @return
|
|
|
- */
|
|
|
- @GetMapping("/getDetails")
|
|
|
- public R getuser(String deptId, String username) {
|
|
|
- SysUser condition = new SysUser();
|
|
|
- condition.setUsername(username);
|
|
|
- SysDept sysDept1 = sysDeptService.getById(Integer.parseInt(deptId));
|
|
|
- if (null != sysDept1) {
|
|
|
- condition.setDeptId(sysDept1.getDeptId());
|
|
|
- }
|
|
|
- return R.ok(userService.getOne(new QueryWrapper<>(condition)));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除用户信息
|
|
|
- *
|
|
|
- * @param id ID
|
|
|
- * @return R
|
|
|
- */
|
|
|
- @SysLog("删除用户信息")
|
|
|
- @DeleteMapping("/{id}")
|
|
|
- @PreAuthorize("@pms.hasPermission('sys_user_del')")
|
|
|
- public R userDel(@PathVariable Integer id) {
|
|
|
- SysUser sysUser = userService.getById(id);
|
|
|
- return R.ok(userService.deleteUserById(sysUser));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 添加用户
|
|
|
- *
|
|
|
- * @param userPwd 用户信息
|
|
|
- * @return success/false
|
|
|
- */
|
|
|
- @Inner(value = false)
|
|
|
- @SysLog("修改密码")
|
|
|
- @PostMapping("/upd")
|
|
|
- public R updatePwd(@RequestBody @Valid UserPwd userPwd) {
|
|
|
-
|
|
|
- return userService.updatePwd(userPwd);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 添加用户
|
|
|
- *
|
|
|
- * @param userDto 用户信息
|
|
|
- * @return success/false
|
|
|
- */
|
|
|
- @SysLog("添加用户")
|
|
|
- @PostMapping
|
|
|
- @PreAuthorize("@pms.hasPermission('sys_user_add')")
|
|
|
- public R user(@RequestBody UserDTO userDto) {
|
|
|
-
|
|
|
- // 姓名去除空格(包括字符之间的所有空格都会去除)
|
|
|
- userDto.setRealname(StrUtil.cleanBlank(userDto.getRealname()));
|
|
|
-
|
|
|
- SysDept sysDept = sysDeptService.getById(userDto.getDeptId());
|
|
|
-
|
|
|
- List<SysUser> queryUserByPhoneList =
|
|
|
- userService.list(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, userDto.getUsername()));
|
|
|
- if (CollUtil.isNotEmpty(queryUserByPhoneList)) {
|
|
|
- SysUser queryUserByPhone = queryUserByPhoneList.get(0);
|
|
|
- if (!StrUtil.equals(queryUserByPhone.getRealname(), userDto.getRealname())) {
|
|
|
- return R.failed(String.format("创建失败,已存在该手机号,姓名为%s,请核对信息", queryUserByPhone.getRealname()));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //// TODO qcc调用企查查查询是否为主要人员
|
|
|
- ///**
|
|
|
- // * @Modify: start qcc调用企查查查询是否为主要人员
|
|
|
- // * @Version: v2021.4.16
|
|
|
- // * @Author: ryz
|
|
|
- // * @Date: 2021/5/6
|
|
|
- // */
|
|
|
- //if (userDto.getRole().contains(6) || userDto.getRole().contains(10)) {
|
|
|
- // Map<String, String> params = new HashMap<>();
|
|
|
- // params.put("searchKey", sysDept.getName());
|
|
|
- // params.put("pageIndex", "1");
|
|
|
- // params.put("pageSize", "10");
|
|
|
- // EmployeeGetListResponse qccRes = qccService.getList(params);
|
|
|
- // if (qccRes.isSuccess()) {
|
|
|
- // for (EmployeeGetListDataItem item : qccRes.getResult()) {
|
|
|
- // if (userDto.getRealname().equals(item.getName())) {
|
|
|
- // if (userDto.getRole().contains(10)) {
|
|
|
- // return R.failed(String.format("%s为该公司%s,不能为兼职CRC", item.getName(), item.getJob()));
|
|
|
- // } else {
|
|
|
- // return R.failed(String.format("%s为该公司%s,不能为兼职学术推广员", item.getName(), item.getJob()));
|
|
|
- // }
|
|
|
- //
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (null != qccRes.getPaging()) {
|
|
|
- // PageInfo qccPage = qccRes.getPaging();
|
|
|
- // // 需要分页查询
|
|
|
- // if (qccPage.getTotalRecords() > qccPage.getPageIndex() * qccPage.getPageSize()) {
|
|
|
- // int totalPage = qccPage.getTotalRecords() / qccPage.getPageSize();
|
|
|
- //
|
|
|
- // for (int i = 2; i < totalPage + 2; i++) {
|
|
|
- // params.put("pageIndex", i + "");
|
|
|
- // qccRes = qccService.getList(params);
|
|
|
- // if (qccRes.isSuccess()) {
|
|
|
- // for (EmployeeGetListDataItem item : qccRes.getResult()) {
|
|
|
- // if (userDto.getRealname().equals(item.getName())) {
|
|
|
- // if (userDto.getRole().contains(10)) {
|
|
|
- // return R.failed(String.format("%s为该公司%s,不能为兼职CRC", item.getName(), item.getJob()));
|
|
|
- // } else {
|
|
|
- // return R.failed(String.format("%s为该公司%s,不能为兼职学术推广员", item.getName(), item.getJob()));
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- //
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- if (ArrayUtils.contains(sysDept.getSubjectType(), SubjectTypeEnum.TYPE_SHUIBANGYUN.getCode())) {
|
|
|
- //userDto.setCertStatus(TaxHelperCertStatus.UN_CERT.getCode());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (userDto.getRole().contains(2)) {
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- userDTO.setUsername(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
- List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
- for (UserVO userVO : userDTOList) {
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
- for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
- if (sysRole.getRoleId() == 3) {
|
|
|
- return R.failed("用户已存在平台管理员角色,不能同时为药企管理员");
|
|
|
- }
|
|
|
- if (sysRole.getRoleId() == 4) {
|
|
|
- return R.failed("用户已存在平台管理员角色,不能同时为CSO管理员");
|
|
|
- }
|
|
|
- if (sysRole.getRoleId() == 5) {
|
|
|
- return R.failed("用户已存在平台管理员角色,不能同时为全职学术推广员");
|
|
|
- }
|
|
|
- if (sysRole.getRoleId() == 6) {
|
|
|
- return R.failed("用户已存在平台管理员角色,不能同时为兼职学术推广员");
|
|
|
- }
|
|
|
- if (sysRole.getRoleId() == 7) {
|
|
|
- return R.failed("用户已存在平台管理员角色,不能同时为财务管理员");
|
|
|
- }
|
|
|
- if (sysRole.getRoleId() == 31) {
|
|
|
- return R.failed("用户已存在平台管理员角色,不能同时为招商经理");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else if (userDto.getRole().contains(3)) {
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- userDTO.setUsername(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
- List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
- 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 (sysRole.getRoleId() == 4) {
|
|
|
- return R.failed("用户已存在药企管理员角色,不能同时为CSO管理员");
|
|
|
- }
|
|
|
+ private final SysUserService userService;
|
|
|
+ private final SysUserMapper sysUserMapper;
|
|
|
+ private final SysDeptService sysDeptService;
|
|
|
+ private final RedisTemplate<String, Object> redisTemplate;
|
|
|
+ private final SysUserRoleMapper sysUserRoleMapper;
|
|
|
+ private final WmPlatformQuizTestResultService platformQuizTestResultService;
|
|
|
+ private final SysCsmUserRelationMapper sysCsmUserRelationMapper;
|
|
|
+
|
|
|
+
|
|
|
+ private boolean isZbOrDbUsers(Integer[] roles) {
|
|
|
+ if (null == roles) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1-管理员,2-平台管理员,3-药企管理员,4-CSO管理员,7-财务管理员,9-CRO管理员,11-患教管理员,19-CMS,27-平台财务管理员,33-行政人员,
|
|
|
+ // 34-财务复核, 35-BC总负责人
|
|
|
+ return Arrays.asList(roles).contains(1)
|
|
|
+ || Arrays.asList(roles).contains(2)
|
|
|
+ || Arrays.asList(roles).contains(3)
|
|
|
+ || Arrays.asList(roles).contains(4)
|
|
|
+ || Arrays.asList(roles).contains(7)
|
|
|
+ || Arrays.asList(roles).contains(9)
|
|
|
+ || Arrays.asList(roles).contains(11)
|
|
|
+ || Arrays.asList(roles).contains(19)
|
|
|
+ || Arrays.asList(roles).contains(27)
|
|
|
+ || Arrays.asList(roles).contains(33)
|
|
|
+ || Arrays.asList(roles).contains(34)
|
|
|
+ || Arrays.asList(roles).contains(35);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户管理-认证
|
|
|
+ *
|
|
|
+ * @param input
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("用户管理-认证")
|
|
|
+ @GetMapping("/getAuthInfo")
|
|
|
+ public R getAuthInfo(UserCertificationInput input) {
|
|
|
+ //参数校验
|
|
|
+ return userService.getAuthInfo(input);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户管理-认证-确定
|
|
|
+ *
|
|
|
+ * @param input
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("用户管理-认证-确定")
|
|
|
+ @PostMapping("/batchChannelCert")
|
|
|
+ public R batchChannelCert(@RequestBody UserCertificationInput input) {
|
|
|
+ //参数校验
|
|
|
+ return userService.batchChannelCert(input);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取指定用户全部信息
|
|
|
+ *
|
|
|
+ * @return 用户信息
|
|
|
+ */
|
|
|
+ @Inner
|
|
|
+ @GetMapping("/info/{username}")
|
|
|
+ public R info(@PathVariable String username) {
|
|
|
+
|
|
|
+ boolean b = username.endsWith("@mp");
|
|
|
+ if (b) {
|
|
|
+ username = username.split("@")[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据用户名查询用户时,过滤掉已删除和已禁用的用户
|
|
|
+ List<SysUser> user = userService.list(Wrappers.<SysUser>query().lambda().eq(SysUser::getUsername, username)
|
|
|
+ .eq(SysUser::getDelFlag, 0).eq(SysUser::getLockFlag, 0));
|
|
|
+
|
|
|
+ if (user == null) {
|
|
|
+ return R.failed(null, String.format("用户信息为空 %s", username));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (user.size() == 1) {
|
|
|
+ UserInfo userInfo = userService.findUserInfo(user.get(0));
|
|
|
+
|
|
|
+ boolean zbOrDbUsers = isZbOrDbUsers(userInfo.getRoles());
|
|
|
+ // 校验用户角色是否包含众包用户和医药代表用户
|
|
|
+ if ((b && !zbOrDbUsers) || (!b && zbOrDbUsers)) {
|
|
|
+ // 角色是小程序角色,则直接返回
|
|
|
+ return R.ok(userInfo);
|
|
|
+ } else {
|
|
|
+ return R.failed(null, String.format("用户信息错误 %s", username));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 小程序多账号情况
|
|
|
+ if (b) {
|
|
|
+ for (SysUser u : user) {
|
|
|
+ UserInfo userInfo = userService.findUserInfo(u);
|
|
|
+ if (!isZbOrDbUsers(userInfo.getRoles())) {
|
|
|
+ // 角色是小程序角色,则直接返回
|
|
|
+ return R.ok(userInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String password = redisTemplate.opsForValue().get(username) + "";
|
|
|
+ if (null != password) {
|
|
|
+ for (int i = 0; i < user.size(); i++) {
|
|
|
+ UserInfo userInfo = userService.findUserInfo(user.get(i));
|
|
|
+ if (Md5Utils.getMD5(password.getBytes()).equals(user.get(i).getW1())) {
|
|
|
+ if (isZbOrDbUsers(userInfo.getRoles())) {
|
|
|
+ redisTemplate.delete(username);
|
|
|
+ return R.ok(userInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.failed(null, String.format("用户信息为空 %s", username));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过ID查询用户信息
|
|
|
+ *
|
|
|
+ * @param id ID
|
|
|
+ * @return 用户信息
|
|
|
+ */
|
|
|
+ @GetMapping("/{id}")
|
|
|
+ public R user(@PathVariable Integer id) {
|
|
|
+ return R.ok(userService.selectUserVoById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据用户名查询用户信息
|
|
|
+ *
|
|
|
+ * @param username 用户名
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/details/{username}")
|
|
|
+ public R user(@PathVariable String username) {
|
|
|
+ SysUser condition = new SysUser();
|
|
|
+ condition.setUsername(username);
|
|
|
+ return R.ok(userService.getOne(new QueryWrapper<>(condition)));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据用户名查询用户信息
|
|
|
+ *
|
|
|
+ * @param username 用户名
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/getDetails")
|
|
|
+ public R getuser(String deptId, String username) {
|
|
|
+ SysUser condition = new SysUser();
|
|
|
+ condition.setUsername(username);
|
|
|
+ SysDept sysDept1 = sysDeptService.getById(Integer.parseInt(deptId));
|
|
|
+ if (null != sysDept1) {
|
|
|
+ condition.setDeptId(sysDept1.getDeptId());
|
|
|
+ }
|
|
|
+ return R.ok(userService.getOne(new QueryWrapper<>(condition)));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除用户信息
|
|
|
+ *
|
|
|
+ * @param id ID
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("删除用户信息")
|
|
|
+ @DeleteMapping("/{id}")
|
|
|
+ @PreAuthorize("@pms.hasPermission('sys_user_del')")
|
|
|
+ public R userDel(@PathVariable Integer id) {
|
|
|
+ SysUser sysUser = userService.getById(id);
|
|
|
+ return R.ok(userService.deleteUserById(sysUser));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加用户
|
|
|
+ *
|
|
|
+ * @param userPwd 用户信息
|
|
|
+ * @return success/false
|
|
|
+ */
|
|
|
+ @Inner(value = false)
|
|
|
+ @SysLog("修改密码")
|
|
|
+ @PostMapping("/upd")
|
|
|
+ public R updatePwd(@RequestBody @Valid UserPwd userPwd) {
|
|
|
+
|
|
|
+ return userService.updatePwd(userPwd);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加用户
|
|
|
+ *
|
|
|
+ * @param userDto 用户信息
|
|
|
+ * @return success/false
|
|
|
+ */
|
|
|
+ @SysLog("添加用户")
|
|
|
+ @PostMapping
|
|
|
+ @PreAuthorize("@pms.hasPermission('sys_user_add')")
|
|
|
+ public R user(@RequestBody UserDTO userDto) {
|
|
|
+
|
|
|
+ // 姓名去除空格(包括字符之间的所有空格都会去除)
|
|
|
+ userDto.setRealname(StrUtil.cleanBlank(userDto.getRealname()));
|
|
|
+
|
|
|
+ SysDept sysDept = sysDeptService.getById(userDto.getDeptId());
|
|
|
+
|
|
|
+ List<SysUser> queryUserByPhoneList =
|
|
|
+ userService.list(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, userDto.getUsername()));
|
|
|
+ if (CollUtil.isNotEmpty(queryUserByPhoneList)) {
|
|
|
+ SysUser queryUserByPhone = queryUserByPhoneList.get(0);
|
|
|
+ if (!StrUtil.equals(queryUserByPhone.getRealname(), userDto.getRealname())) {
|
|
|
+ return R.failed(String.format("创建失败,已存在该手机号,姓名为%s,请核对信息", queryUserByPhone.getRealname()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (userDto.getRole().contains(2)) {
|
|
|
+ UserDTO userDTO = new UserDTO();
|
|
|
+ userDTO.setUsername(userDto.getUsername());
|
|
|
+ userDTO.setDelFlag("0");
|
|
|
+ List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
+ if (userDTOList.size() > 0) {
|
|
|
+ for (UserVO userVO : userDTOList) {
|
|
|
+ if (null != userVO.getRoleList()) {
|
|
|
+ for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
+ if (sysRole.getRoleId() == 3) {
|
|
|
+ return R.failed("用户已存在平台管理员角色,不能同时为药企管理员");
|
|
|
+ }
|
|
|
+ if (sysRole.getRoleId() == 4) {
|
|
|
+ return R.failed("用户已存在平台管理员角色,不能同时为CSO管理员");
|
|
|
+ }
|
|
|
+ if (sysRole.getRoleId() == 5) {
|
|
|
+ return R.failed("用户已存在平台管理员角色,不能同时为全职学术推广员");
|
|
|
+ }
|
|
|
+ if (sysRole.getRoleId() == 6) {
|
|
|
+ return R.failed("用户已存在平台管理员角色,不能同时为兼职学术推广员");
|
|
|
+ }
|
|
|
+ if (sysRole.getRoleId() == 7) {
|
|
|
+ return R.failed("用户已存在平台管理员角色,不能同时为财务管理员");
|
|
|
+ }
|
|
|
+ if (sysRole.getRoleId() == 31) {
|
|
|
+ return R.failed("用户已存在平台管理员角色,不能同时为招商经理");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (userDto.getRole().contains(3)) {
|
|
|
+ UserDTO userDTO = new UserDTO();
|
|
|
+ userDTO.setUsername(userDto.getUsername());
|
|
|
+ userDTO.setDelFlag("0");
|
|
|
+ List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
+ if (userDTOList.size() > 0) {
|
|
|
+ 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 (sysRole.getRoleId() == 4) {
|
|
|
+ return R.failed("用户已存在药企管理员角色,不能同时为CSO管理员");
|
|
|
+ }
|
|
|
// SysDept sysDept = sysDeptService.getById(userVO.getDeptId());
|
|
|
- if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
- if (sysRole.getRoleId() == 5) {
|
|
|
- return R.failed("用户已存在CSO关系角色,不能同时为药企管理员");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else if (userDto.getRole().contains(4)) {
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- userDTO.setUsername(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
- List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
- for (UserVO userVO : userDTOList) {
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
- for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
- if (sysRole.getRoleId() == 2) {
|
|
|
- return R.failed("用户已存在平台管理员角色,不能同时为CSO管理员");
|
|
|
- }
|
|
|
- if (sysRole.getRoleId() == 4) {
|
|
|
- return R.failed("用户已存在CSO管理员角色,不能为其他机构CSO管理员");
|
|
|
- }
|
|
|
- if (sysRole.getRoleId() == 9) {
|
|
|
- return R.failed("用户已存在CRO管理员,不能同时为CSO管理员");
|
|
|
- }
|
|
|
-
|
|
|
- if (sysRole.getRoleId() == 3) {
|
|
|
- return R.failed("用户已存在药企管理员角色,不能同时为CSO管理员");
|
|
|
- }
|
|
|
- if (sysRole.getRoleId() == 5) {
|
|
|
- SysUserRole sysUserRole = new SysUserRole();
|
|
|
- sysUserRole.setUserId(userVO.getUserId());
|
|
|
- List<SysUserRole> sysUserRoleList = sysUserRoleMapper.selectById(sysUserRole);
|
|
|
- for (int i = 0; i < sysUserRoleList.size(); i++) {
|
|
|
- SysUser sysUser = userService.getById(sysUserRoleList.get(i).getUserId());
|
|
|
- if (!sysUser.getDeptId().equals(userDto.getDeptId())) {
|
|
|
- return R.failed("用户已存在全职学术推广员角色,不能为其他机构CSO管理员");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (sysRole.getRoleId() == 31) {
|
|
|
- SysUserRole sysUserRole = new SysUserRole();
|
|
|
- sysUserRole.setUserId(userVO.getUserId());
|
|
|
- List<SysUserRole> sysUserRoleList = sysUserRoleMapper.selectById(sysUserRole);
|
|
|
- for (int i = 0; i < sysUserRoleList.size(); i++) {
|
|
|
- SysUser sysUser = userService.getById(sysUserRoleList.get(i).getUserId());
|
|
|
- if (!sysUser.getDeptId().equals(userDto.getDeptId())) {
|
|
|
- return R.failed("用户已存在招商经理角色,不能为其他机构CSO管理员");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else if (userDto.getRole().contains(7)) {
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- userDTO.setUsername(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
- List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
- for (UserVO userVO : userDTOList) {
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
- for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
- if (sysRole.getRoleId() == 2) {
|
|
|
- return R.failed("用户已存在平台管理员,不能同时为财务管理员");
|
|
|
- }
|
|
|
- if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
- if (sysRole.getRoleId() == 3) {
|
|
|
- return R.failed("用户已存在药企管理员,不能同时为CSO机构财务管理员");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else if (userDto.getRole().contains(5)) {
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- userDTO.setUsername(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
- List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
- for (UserVO userVO : userDTOList) {
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
- for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
- if (sysRole.getRoleId() == 2) {
|
|
|
- return R.failed("用户已存在平台管理员,不能同时为全职学术推广员");
|
|
|
- }
|
|
|
- if (sysRole.getRoleId() == 3) {
|
|
|
- if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
- return R.failed("用户已存在药企管理员,不能为CSO的全职学术推广员");
|
|
|
- }
|
|
|
- }
|
|
|
- if (sysRole.getRoleId() == 4) {
|
|
|
- if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
- return R.failed("用户已存在CSO管理员,不能为其他CSO的全职学术推广员");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else if (userDto.getRole().contains(6)) {
|
|
|
-
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- userDTO.setUsername(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
- List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
- for (UserVO userVO : userDTOList) {
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
- for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
- if (sysRole.getRoleId() == 2) {
|
|
|
- return R.failed("用户已存在平台管理员,不能同时为兼职学术推广员");
|
|
|
- }
|
|
|
- SysUserRole sysUserRole = new SysUserRole();
|
|
|
- sysUserRole.setUserId(userVO.getUserId());
|
|
|
- List<SysUserRole> sysUserRoleList = sysUserRoleMapper.selectById(sysUserRole);
|
|
|
- for (int i = 0; i < sysUserRoleList.size(); i++) {
|
|
|
- if (sysUserRoleList.get(i).getRoleId().equals(7)) {
|
|
|
- SysUser sysUser = userService.getById(sysUserRoleList.get(i).getUserId());
|
|
|
- if (sysUser.getDeptId().equals(userDto.getDeptId())) {
|
|
|
- return R.failed("用户已存在财务管理员角色,不能同时为兼职学术推广员");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else if (userDto.getRole().contains(9)) {
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- userDTO.setUsername(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
- List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
- 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 (sysRole.getRoleId() == 4) {
|
|
|
- return R.failed("用户已存在CSO管理员角色,不能同时为CRO管理员");
|
|
|
- }
|
|
|
- if (sysRole.getRoleId() == 9) {
|
|
|
- return R.failed("用户已存在CRO管理员角色");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else if (userDto.getRole().contains(31)) {
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- userDTO.setUsername(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
- List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
- if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
- for (UserVO userVO : userDTOList) {
|
|
|
- for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
- if (sysRole.getRoleId() == 2) {
|
|
|
- return R.failed("用户已存在平台管理员,不能同时为招商经理");
|
|
|
- }
|
|
|
- if (sysRole.getRoleId() == 3) {
|
|
|
- if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
- return R.failed("用户已存在药企管理员,不能为CSO的招商经理");
|
|
|
- }
|
|
|
- }
|
|
|
- if (sysRole.getRoleId() == 4) {
|
|
|
- if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
- return R.failed("用户已存在CSO管理员,不能为其他CSO的招商经理");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (userDto.getRole().contains(3)) {
|
|
|
- if (sysDept.getLevel() != 2) {
|
|
|
- return R.failed("角色选为药企管理员时,组织架构必须为药企");
|
|
|
- }
|
|
|
- }
|
|
|
- // }
|
|
|
- if (!userDto.getDeptId().equals(SecurityUtils.getUser().getDeptId())) {
|
|
|
- if (userDto.getRole().contains(5) || userDto.getRole().contains(6)) {
|
|
|
- return R.failed("不能跨机构维护学术推广员");
|
|
|
- }
|
|
|
- if (userDto.getRole().contains(31)) {
|
|
|
- return R.failed("不能跨机构维护招商经理");
|
|
|
- }
|
|
|
- }
|
|
|
- SysUser query = new SysUser();
|
|
|
- query.setUsername(userDto.getUsername());
|
|
|
- query.setDeptId(userDto.getDeptId());
|
|
|
- Integer count = sysUserMapper.selectCount(Wrappers.query(query));
|
|
|
- // TODO 用户是否存在
|
|
|
- if (count != 0) {
|
|
|
- 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.saveUser(userDto));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量导入用户
|
|
|
- *
|
|
|
- * @param commonUserExcelModelList 用户信息列表
|
|
|
- * @return success/false
|
|
|
- */
|
|
|
- @SysLog("批量导入用户")
|
|
|
- @PostMapping(value = "/batch")
|
|
|
- @PreAuthorize("@pms.hasPermission('sys_user_add')")
|
|
|
- public R batchUser(@RequestExcel List<CommonUserExcelModel> commonUserExcelModelList) {
|
|
|
-
|
|
|
- // 参数校验
|
|
|
- if (CollectionUtils.isEmpty(commonUserExcelModelList)) {
|
|
|
- log.error("空报表,不能上传");
|
|
|
- return R.failed("空报表,不能上传");
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, List<CommonUserDTO>> collect = commonUserExcelModelList.stream().map(commonUserExcelModel ->
|
|
|
- BeanUtil.copyProperties(commonUserExcelModel, CommonUserDTO.class)
|
|
|
- ).collect(Collectors.groupingBy(CommonUserDTO::getUsername));
|
|
|
-
|
|
|
-
|
|
|
- // 实际的处理业务
|
|
|
- Map<String, String> errorMap = userService.batchByExcel(collect);
|
|
|
-
|
|
|
- // 返回上传结果
|
|
|
- Map<String, Object> result = new HashMap<>(3);
|
|
|
- if (CollectionUtil.isEmpty(errorMap)) {
|
|
|
- result.put("code", "SUCCESS");
|
|
|
- result.put("message", "上传成功");
|
|
|
- result.put("data", null);
|
|
|
- return R.ok(result);
|
|
|
- } else {
|
|
|
- log.error("上传数据错误,{}", JSONUtil.toJsonStr(errorMap));
|
|
|
- result.put("code", "FAILURE");
|
|
|
- result.put("message", "上传数据错误");
|
|
|
- result.put("data", errorMap);
|
|
|
- return R.failed(result);
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新用户信息
|
|
|
- *
|
|
|
- * @param userDto 用户信息
|
|
|
- * @return R
|
|
|
- */
|
|
|
- @SysLog("更新用户信息")
|
|
|
- @PutMapping
|
|
|
- @PreAuthorize("@pms.hasPermission('sys_user_edit')")
|
|
|
- public R updateUser(@Valid @RequestBody UserDTO userDto) {
|
|
|
-
|
|
|
- // qcc调用企查查查询是否为主要人员
|
|
|
- SysDept sysDept = sysDeptService.getById(userDto.getDeptId());
|
|
|
-
|
|
|
- if (null != userDto.getUserId()) {
|
|
|
- // 姓名去除空格(包括字符之间的所有空格都会去除)
|
|
|
- userDto.setRealname(StrUtil.cleanBlank(userDto.getRealname()));
|
|
|
-
|
|
|
- SysUser oldData = userService.getById(userDto.getUserId());
|
|
|
- //if (!userDto.getRealname().equals(oldData.getRealname())) {
|
|
|
- // if (userDto.getRole().contains(6) || userDto.getRole().contains(10)) {
|
|
|
- // Map<String, String> params = new HashMap<>();
|
|
|
- // params.put("searchKey", sysDept.getName());
|
|
|
- // params.put("pageIndex", "1");
|
|
|
- // params.put("pageSize", "10");
|
|
|
- // EmployeeGetListResponse qccRes = qccService.getList(params);
|
|
|
- // if (qccRes.isSuccess()) {
|
|
|
- // for (EmployeeGetListDataItem item : qccRes.getResult()) {
|
|
|
- // if (userDto.getRealname().equals(item.getName())) {
|
|
|
- // if (userDto.getRole().contains(10)) {
|
|
|
- // return R.failed(String.format("%s为该公司%s,不能为兼职CRC", item.getName(), item.getJob()));
|
|
|
- // } else {
|
|
|
- // return R.failed(String.format("%s为该公司%s,不能为兼职学术推广员", item.getName(), item.getJob()));
|
|
|
- // }
|
|
|
- //
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (null != qccRes.getPaging()) {
|
|
|
- // PageInfo qccPage = qccRes.getPaging();
|
|
|
- // // 需要分页查询
|
|
|
- // if (qccPage.getTotalRecords() > qccPage.getPageIndex() * qccPage.getPageSize()) {
|
|
|
- // int totalPage = qccPage.getTotalRecords() / qccPage.getPageSize();
|
|
|
- //
|
|
|
- // for (int i = 2; i < totalPage + 2; i++) {
|
|
|
- // params.put("pageIndex", i + "");
|
|
|
- // qccRes = qccService.getList(params);
|
|
|
- // if (qccRes.isSuccess()) {
|
|
|
- // for (EmployeeGetListDataItem item : qccRes.getResult()) {
|
|
|
- // if (userDto.getRole().contains(10)) {
|
|
|
- // return R.failed(String.format("%s为该公司%s,不能为兼职CRC", item.getName(), item.getJob()));
|
|
|
- // } else {
|
|
|
- // return R.failed(String.format("%s为该公司%s,不能为兼职学术推广员", item.getName(), item.getJob()));
|
|
|
- // }
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- //
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
-
|
|
|
- List<Integer> cetList = new ArrayList<>();
|
|
|
- cetList.add(1);
|
|
|
- cetList.add(3);
|
|
|
- cetList.add(11);
|
|
|
- cetList.add(12);
|
|
|
- cetList.add(13);
|
|
|
- cetList.add(14);
|
|
|
- cetList.add(15);
|
|
|
- cetList.add(16);
|
|
|
-
|
|
|
- /**
|
|
|
- * @Modify: start
|
|
|
- * @Version: v2021.4.16
|
|
|
- * @Author: ryz
|
|
|
- * @Date: 2021/4/29
|
|
|
- * 去掉修改用户信息时候的认证
|
|
|
- */
|
|
|
- boolean updateFlag = true;
|
|
|
- if (null != oldData.getCertStatus()) {
|
|
|
- if (oldData.getCertStatus() != 10) {
|
|
|
- updateFlag = false;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- if (null != oldData.getRljCertStatus()) {
|
|
|
- if (oldData.getRljCertStatus() == 1 || oldData.getRljCertStatus() == 3) {
|
|
|
- updateFlag = false;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!updateFlag) {
|
|
|
- if (!userDto.getRealname().equals(oldData.getRealname())) {
|
|
|
- return R.failed("用户认证通过或正在认证,暂不能修改姓名");
|
|
|
- }
|
|
|
- if (!userDto.getIdCardNumber().equals(oldData.getIdCardNumber())) {
|
|
|
- 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("0");
|
|
|
- List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
- 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("0");
|
|
|
- List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
- 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 userDTO = new UserDTO();
|
|
|
- userDTO.setPlatId(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
- List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
- 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("0");
|
|
|
- List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
- 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("0");
|
|
|
- List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
- 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.val()));
|
|
|
- if (count > 0) {
|
|
|
- if (userDto.getRole().contains(6) && userDto.getRole().contains(4)) {
|
|
|
- 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));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 分页查询用户
|
|
|
- *
|
|
|
- * @param page 参数集
|
|
|
- * @param userDTO 查询参数列表
|
|
|
- * @return 用户集合
|
|
|
- */
|
|
|
- @GetMapping("/page")
|
|
|
- public R getUserPage(Page page, UserDTO userDTO) {
|
|
|
-
|
|
|
- return R.ok(userService.getUsersWithRolePageNoLock(page, userDTO));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 分页查询用户
|
|
|
- *
|
|
|
- * @param page 参数集
|
|
|
- * @param userDTO 查询参数列表
|
|
|
- * @return 用户集合
|
|
|
- */
|
|
|
- @GetMapping("/selectUserList")
|
|
|
- public R<?> selectUserList(Page page, UserDTO userDTO) {
|
|
|
-
|
|
|
- userDTO.setSubType(null);
|
|
|
- if (StrUtil.isNotBlank(userDTO.getSubjectLocation())) {
|
|
|
- String[] locationArr = Stream.of(SubjectLocation.values())
|
|
|
- .map(SubjectLocation::getType)
|
|
|
- .toArray(String[]::new);
|
|
|
- if (!ArrayUtil.containsAny(userDTO.getSubjectLocation().split(StrUtil.COMMA), locationArr)) {
|
|
|
- // 只接收已有的税源地类型值
|
|
|
- userDTO.setSubjectLocation(null);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- IPage<UserVO> userVosPage = userService.selectUserList(page, userDTO);
|
|
|
-
|
|
|
- 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);
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //// 封装结算通道
|
|
|
- //Set<Integer> deptIds = userVosPage.getRecords().stream().map(UserVO::getDeptId).collect(Collectors.toSet());
|
|
|
- //
|
|
|
- //if (CollUtil.isNotEmpty(deptIds)) {
|
|
|
- // // 税源地
|
|
|
- // Map<Integer, Map<String, Integer>> coll = sysDeptSubService.list(Wrappers.<SysDeptSub>lambdaQuery()
|
|
|
- // .eq(SysDeptSub::getEnableFlag, SubjectTypeEnum.ENABLE_FLAG_TRUE.getCode())
|
|
|
- // .in(SysDeptSub::getDeptId, deptIds))
|
|
|
- // .stream()
|
|
|
- // .collect(Collectors.groupingBy(SysDeptSub::getDeptId,
|
|
|
- // Collectors.toMap(sysDeptSub -> sysDeptSub.getSubjectLocation().name(), SysDeptSub::getSubjectChannel)));
|
|
|
- //
|
|
|
- // userVosPage.getRecords().forEach(item -> {
|
|
|
- // if ("0".equals(userDTO.getSubType())) {
|
|
|
- // item.setCertStatus(null);
|
|
|
- // } else if ("1".equals(userDTO.getSubType())) {
|
|
|
- // item.setRljCertStatus(null);
|
|
|
- // }
|
|
|
- //
|
|
|
- // item.setSubjectTypeAndChannel(coll.get(item.getDeptId()));
|
|
|
- //
|
|
|
- // });
|
|
|
- //}
|
|
|
- //
|
|
|
- //// 登录人所属企业的结算配置信息
|
|
|
- //List<SubjectLocation> locations;
|
|
|
- //Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
- //// 非平台用户,获取各自的配置项
|
|
|
- //if (1 != deptId) {
|
|
|
- // List<SysDeptSub> l = sysDeptSubService.list(Wrappers.<SysDeptSub>lambdaQuery().eq(SysDeptSub::getDeptId, deptId).eq(SysDeptSub::getEnableFlag, "1"));
|
|
|
- // if (CollUtil.isNotEmpty(l)) {
|
|
|
- // locations = l.stream().filter(sub -> sub.getSubjectLocation() != null)
|
|
|
- // .map(sub -> Enum.valueOf(SubjectLocation.class, sub.getSubjectLocation().getType()))
|
|
|
- // .collect(Collectors.toList());
|
|
|
- // } else {
|
|
|
- // locations = Collections.emptyList();
|
|
|
- // }
|
|
|
- //
|
|
|
- //}
|
|
|
- //// 平台管理员和admin获取全部
|
|
|
- //else {
|
|
|
- // List<SysDictItem> list = sysDictItemService.list(Wrappers.<SysDictItem>query().lambda().eq(SysDictItem::getType, "subject_location"));
|
|
|
- // locations = list.stream().map(item -> Enum.valueOf(SubjectLocation.class, item.getValue())).collect(Collectors.toList());
|
|
|
- //}
|
|
|
-
|
|
|
- Map<Integer, List<SysCsmUserRelation>> csmParentUserMap = new HashMap<>();
|
|
|
- if (CollUtil.isNotEmpty(userIds)) {
|
|
|
- // 上级csm
|
|
|
- List<SysCsmUserRelation> csmUserRelations = sysCsmUserRelationMapper.selectList(Wrappers.<SysCsmUserRelation>lambdaQuery()
|
|
|
- .in(SysCsmUserRelation::getUserId, userIds));
|
|
|
- if (CollUtil.isNotEmpty(csmUserRelations)) {
|
|
|
- csmParentUserMap.putAll(csmUserRelations.stream().collect(Collectors.groupingBy(SysCsmUserRelation::getUserId)));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- userVosPage.getRecords().forEach(userVO -> {
|
|
|
- //// 查询所属企业渠道
|
|
|
- //SysDeptSub sysDeptSub = new SysDeptSub();
|
|
|
- //sysDeptSub.setDeptId(userVO.getDeptId());
|
|
|
- //sysDeptSub.setEnableFlag(SubjectTypeEnum.ENABLE_FLAG_TRUE.getCode());
|
|
|
- //List<SysDeptSub> subList = sysDeptSubService.list(Wrappers.query(sysDeptSub));
|
|
|
- //
|
|
|
- //if (CollUtil.isNotEmpty(subList)) {
|
|
|
- // // 查询当前用户认证渠道
|
|
|
- // List<SysUserSub> userSubList = sysUserSubService.list(Wrappers.<SysUserSub>lambdaQuery()
|
|
|
- // .eq(SysUserSub::getDeptId, userVO.getDeptId())
|
|
|
- // .eq(SysUserSub::getUserId, userVO.getUserId()));
|
|
|
- //
|
|
|
- // if (CollUtil.isNotEmpty(userSubList) && CollUtil.isNotEmpty(locations)) {
|
|
|
- //
|
|
|
- // // 不同渠道认证名称,封装成中文名称数组格式
|
|
|
- // Map<SubjectLocation, SysUserSub> certStatusMap = userSubList.stream()
|
|
|
- // .collect(Collectors.toMap(SysUserSub::getSubjectLocation,
|
|
|
- // sysUserSub -> sysUserSub));
|
|
|
- //
|
|
|
- // // 以企业配置并启用的税源地为基准,进行回显
|
|
|
- // List<SysUserSubVO> subVOS = locations.stream().map(loc -> {
|
|
|
- // SysUserSub sysUserSub = certStatusMap.get(loc);
|
|
|
- // if (sysUserSub != null) {
|
|
|
- // // 如果userSub存在该税源地对应的认证数据,则处理后返回
|
|
|
- // SysUserSubVO userSubVO = BeanUtil.copyProperties(sysUserSub, SysUserSubVO.class, "certStatus");
|
|
|
- // userSubVO.setCertStatus(GigTypeEnum.getCertStatusByCode(sysUserSub.getGigType(), sysUserSub.getCertStatus()));
|
|
|
- // userSubVO.setCertStatusDisplay(String.format("%s:%s", sysUserSub.getSubjectLocation().getDescription(),
|
|
|
- // GigTypeEnum.getCertStatusNameByCode(sysUserSub.getGigType(), sysUserSub.getCertStatus())));
|
|
|
- // return userSubVO;
|
|
|
- // } else {
|
|
|
- // // 如果userSub不存在该税源地对应的认证数据,则默认返回一条
|
|
|
- // SysUserSubVO userSubVO = new SysUserSubVO();
|
|
|
- // userSubVO.setUserId(userVO.getUserId());
|
|
|
- // userSubVO.setGigType(loc.getGigType());
|
|
|
- // userSubVO.setSubjectLocation(loc);
|
|
|
- // userSubVO.setCertStatus(GigTypeEnum.getCertStatusByCode(userSubVO.getGigType(), 0));
|
|
|
- // userSubVO.setCertStatusDisplay(String.format("%s:%s", userSubVO.getSubjectLocation().getDescription(),
|
|
|
- // GigTypeEnum.getCertStatusNameByCode(userSubVO.getGigType(), 0)));
|
|
|
- // return userSubVO;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // ).collect(Collectors.toList());
|
|
|
- // userVO.setCertList(subVOS);
|
|
|
- //
|
|
|
- // // 该企业配置的所有税源地
|
|
|
- // List<SubjectLocation> subjectLocationList = subList.stream().map(SysDeptSub::getSubjectLocation).collect(Collectors.toList());
|
|
|
- //
|
|
|
- // List<String> certStatusNameList = new ArrayList<>();
|
|
|
- // subjectLocationList.stream()
|
|
|
- // .sorted(Comparator.comparing(SubjectLocation::getSort))
|
|
|
- // .forEach(subjectLocation -> {
|
|
|
- // SysUserSub sysUserSub = certStatusMap.get(subjectLocation);
|
|
|
- // int certStatus = sysUserSub != null ? sysUserSub.getCertStatus() : 0;
|
|
|
- // certStatusNameList.add(GigTypeEnum.getCertStatusNameByCode(subjectLocation.getGigType(), certStatus));
|
|
|
- // });
|
|
|
- //
|
|
|
- // userVO.setCertStatusArr(certStatusNameList.toArray(new String[0]));
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- // 上级csm
|
|
|
- List<SysCsmUserRelation> csmUserRelations = csmParentUserMap.get(userVO.getUserId());
|
|
|
- if (CollUtil.isNotEmpty(csmUserRelations)) {
|
|
|
- userVO.setParentIdList(csmUserRelations.stream().map(SysCsmUserRelation::getParentId).collect(Collectors.toList()));
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- return R.ok(userVosPage);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改个人信息
|
|
|
- *
|
|
|
- * @param userDto userDto
|
|
|
- * @return success/false
|
|
|
- */
|
|
|
- @SysLog("修改个人信息")
|
|
|
- @PutMapping("/edit")
|
|
|
- public R updateUserInfo(@Valid @RequestBody UserDTO userDto) {
|
|
|
- userDto.setUserId(SecurityUtils.getUser().getId());
|
|
|
- return userService.updateUserInfo(userDto);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param username 用户名称
|
|
|
- * @return 上级部门用户列表
|
|
|
- */
|
|
|
- @GetMapping("/ancestor/{username}")
|
|
|
- public R listAncestorUsers(@PathVariable String username) {
|
|
|
- return R.ok(userService.listAncestorUsers(username));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改个人信息
|
|
|
- *
|
|
|
- * @param userDTO userDTO
|
|
|
- * @return success/false
|
|
|
- */
|
|
|
- @GetMapping("/list")
|
|
|
- public R listScope(Page page, UserDTO userDTO) {
|
|
|
- if (null != userDTO.getRole() && userDTO.getRole().size() > 0) {
|
|
|
- userDTO.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
- page.setSize(10000);
|
|
|
- List<UserVO> sysUserList = userService.getUsersWithRolePage(page, userDTO).getRecords();
|
|
|
- List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
- if (sysUserList.size() > 0) {
|
|
|
- for (UserVO sysUser : sysUserList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- map.put("id", sysUser.getUserId() + "");
|
|
|
- map.put("realname", sysUser.getRealname() + "");
|
|
|
- answerList.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- return R.ok(answerList);
|
|
|
- } else {
|
|
|
- page.setSize(10000);
|
|
|
- List<Integer> list = new ArrayList<>();
|
|
|
- list.add(5);
|
|
|
- list.add(6);
|
|
|
- userDTO.setRole(list);
|
|
|
-
|
|
|
- List<UserVO> sysUserList = userService.getUsersWithRolePage(page, userDTO).getRecords();
|
|
|
- List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
- if (sysUserList.size() > 0) {
|
|
|
- for (UserVO sysUser : sysUserList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- map.put("id", sysUser.getUserId() + "");
|
|
|
- map.put("realname", sysUser.getRealname() + "");
|
|
|
- answerList.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- return R.ok(answerList);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询全可用的用户
|
|
|
- *
|
|
|
- * @param userDTO userDTO
|
|
|
- * @return success/false
|
|
|
- */
|
|
|
- @SysLog("查询全可用的用户")
|
|
|
- @GetMapping("/list/available")
|
|
|
- public R listScope1(Page page, UserDTO userDTO) {
|
|
|
- userDTO.setLockFlag(CommonConstants.STATUS_NORMAL);
|
|
|
- if (CollUtil.isNotEmpty(userDTO.getRole())) {
|
|
|
- userDTO.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
- page.setSize(10000);
|
|
|
- List<UserVO> sysUserList = userService.getUsersWithRolePage(page, userDTO).getRecords();
|
|
|
- List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
- if (sysUserList.size() > 0) {
|
|
|
- for (UserVO sysUser : sysUserList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- map.put("id", sysUser.getUserId() + "");
|
|
|
- map.put("username", sysUser.getUsername() + "");
|
|
|
- map.put("realname", sysUser.getRealname() + "");
|
|
|
- answerList.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- return R.ok(answerList);
|
|
|
- } else {
|
|
|
- page.setSize(10000);
|
|
|
- List<Integer> list = new ArrayList<>();
|
|
|
- list.add(5);
|
|
|
- list.add(6);
|
|
|
- userDTO.setRole(list);
|
|
|
-
|
|
|
- List<UserVO> sysUserList = userService.getUsersWithRolePage(page, userDTO).getRecords();
|
|
|
- List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
- if (sysUserList.size() > 0) {
|
|
|
- for (UserVO sysUser : sysUserList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- map.put("id", sysUser.getUserId() + "");
|
|
|
- map.put("username", sysUser.getUsername() + "");
|
|
|
- map.put("realname", sysUser.getRealname() + "");
|
|
|
- answerList.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- return R.ok(answerList);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询用户列表
|
|
|
- *
|
|
|
- * @param userDTO
|
|
|
- * @return
|
|
|
- */
|
|
|
- @GetMapping("/listNoScope")
|
|
|
- public R listNoScope(UserDTO userDTO) {
|
|
|
-
|
|
|
- SysUser sysUserSel = new SysUser();
|
|
|
-
|
|
|
- if (SecurityUtils.getRoles().contains(2) || SecurityUtils.getRoles().contains(1)) {
|
|
|
-
|
|
|
- } else {
|
|
|
- sysUserSel.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
- }
|
|
|
- QueryWrapper<SysUser> query = Wrappers.query(sysUserSel);
|
|
|
- if (StringUtils.isNotEmpty(userDTO.getRealname())) {
|
|
|
- query.lambda().like(SysUser::getRealname, userDTO.getRealname());
|
|
|
- }
|
|
|
- List<SysUser> sysUserList = userService.list(query);
|
|
|
- List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
- if (sysUserList.size() > 0) {
|
|
|
- for (SysUser sysUser : sysUserList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- map.put("id", sysUser.getUserId() + "");
|
|
|
- map.put("realname", sysUser.getRealname() + "");
|
|
|
- map.put("name", sysUser.getUsername() + "");
|
|
|
-
|
|
|
- answerList.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- return R.ok(answerList);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改个人信息
|
|
|
- *
|
|
|
- * @param userDTO userDTO
|
|
|
- * @return success/false
|
|
|
- */
|
|
|
- @GetMapping("/listNoScopeAll")
|
|
|
- public R listNoScopeAll(Page page, UserDTO userDTO) {
|
|
|
- page.setSize(10000);
|
|
|
- QueryWrapper<SysUser> queryWrapper = null;
|
|
|
- if (userDTO.getDeptId() != null) {
|
|
|
- SysUser sysUser = new SysUser();
|
|
|
- sysUser.setDeptId(userDTO.getDeptId());
|
|
|
- queryWrapper = Wrappers.query(sysUser);
|
|
|
- } else {
|
|
|
- queryWrapper = Wrappers.query();
|
|
|
- }
|
|
|
-
|
|
|
- List<SysUser> sysUserList = userService.list(queryWrapper);
|
|
|
- List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
- if (sysUserList.size() > 0) {
|
|
|
- for (SysUser sysUser : sysUserList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- map.put("id", sysUser.getUserId() + "");
|
|
|
- map.put("realname", sysUser.getRealname() + "");
|
|
|
- map.put("name", sysUser.getUsername() + "");
|
|
|
-
|
|
|
- answerList.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- return R.ok(answerList);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询CSM列表
|
|
|
- *
|
|
|
- * @return {@link R}<{@link ?}>
|
|
|
- */
|
|
|
- @GetMapping("/list-csm")
|
|
|
- public R<?> listCsm() {
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- userDTO.setRole(Stream.of(19).collect(Collectors.toList()));
|
|
|
- List<UserVO> users = sysUserMapper.listUserByRole(userDTO);
|
|
|
-
|
|
|
- List<Map<String, Object>> result = users.stream().map(user -> {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("userId", user.getUserId());
|
|
|
- map.put("realname", user.getRealname());
|
|
|
- return map;
|
|
|
- }).collect(Collectors.toList());
|
|
|
-
|
|
|
- return R.ok(result);
|
|
|
- }
|
|
|
+ if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
+ if (sysRole.getRoleId() == 5) {
|
|
|
+ return R.failed("用户已存在CSO关系角色,不能同时为药企管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (userDto.getRole().contains(4)) {
|
|
|
+ UserDTO userDTO = new UserDTO();
|
|
|
+ userDTO.setUsername(userDto.getUsername());
|
|
|
+ userDTO.setDelFlag("0");
|
|
|
+ List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
+ if (userDTOList.size() > 0) {
|
|
|
+ for (UserVO userVO : userDTOList) {
|
|
|
+ if (null != userVO.getRoleList()) {
|
|
|
+ for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
+ if (sysRole.getRoleId() == 2) {
|
|
|
+ return R.failed("用户已存在平台管理员角色,不能同时为CSO管理员");
|
|
|
+ }
|
|
|
+ if (sysRole.getRoleId() == 4) {
|
|
|
+ return R.failed("用户已存在CSO管理员角色,不能为其他机构CSO管理员");
|
|
|
+ }
|
|
|
+ if (sysRole.getRoleId() == 9) {
|
|
|
+ return R.failed("用户已存在CRO管理员,不能同时为CSO管理员");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sysRole.getRoleId() == 3) {
|
|
|
+ return R.failed("用户已存在药企管理员角色,不能同时为CSO管理员");
|
|
|
+ }
|
|
|
+ if (sysRole.getRoleId() == 5) {
|
|
|
+ SysUserRole sysUserRole = new SysUserRole();
|
|
|
+ sysUserRole.setUserId(userVO.getUserId());
|
|
|
+ List<SysUserRole> sysUserRoleList = sysUserRoleMapper.selectById(sysUserRole);
|
|
|
+ for (int i = 0; i < sysUserRoleList.size(); i++) {
|
|
|
+ SysUser sysUser = userService.getById(sysUserRoleList.get(i).getUserId());
|
|
|
+ if (!sysUser.getDeptId().equals(userDto.getDeptId())) {
|
|
|
+ return R.failed("用户已存在全职学术推广员角色,不能为其他机构CSO管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sysRole.getRoleId() == 31) {
|
|
|
+ SysUserRole sysUserRole = new SysUserRole();
|
|
|
+ sysUserRole.setUserId(userVO.getUserId());
|
|
|
+ List<SysUserRole> sysUserRoleList = sysUserRoleMapper.selectById(sysUserRole);
|
|
|
+ for (int i = 0; i < sysUserRoleList.size(); i++) {
|
|
|
+ SysUser sysUser = userService.getById(sysUserRoleList.get(i).getUserId());
|
|
|
+ if (!sysUser.getDeptId().equals(userDto.getDeptId())) {
|
|
|
+ return R.failed("用户已存在招商经理角色,不能为其他机构CSO管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (userDto.getRole().contains(7)) {
|
|
|
+ UserDTO userDTO = new UserDTO();
|
|
|
+ userDTO.setUsername(userDto.getUsername());
|
|
|
+ userDTO.setDelFlag("0");
|
|
|
+ List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
+ if (userDTOList.size() > 0) {
|
|
|
+ for (UserVO userVO : userDTOList) {
|
|
|
+ if (null != userVO.getRoleList()) {
|
|
|
+ for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
+ if (sysRole.getRoleId() == 2) {
|
|
|
+ return R.failed("用户已存在平台管理员,不能同时为财务管理员");
|
|
|
+ }
|
|
|
+ if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
+ if (sysRole.getRoleId() == 3) {
|
|
|
+ return R.failed("用户已存在药企管理员,不能同时为CSO机构财务管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (userDto.getRole().contains(5)) {
|
|
|
+ UserDTO userDTO = new UserDTO();
|
|
|
+ userDTO.setUsername(userDto.getUsername());
|
|
|
+ userDTO.setDelFlag("0");
|
|
|
+ List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
+ if (userDTOList.size() > 0) {
|
|
|
+ for (UserVO userVO : userDTOList) {
|
|
|
+ if (null != userVO.getRoleList()) {
|
|
|
+ for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
+ if (sysRole.getRoleId() == 2) {
|
|
|
+ return R.failed("用户已存在平台管理员,不能同时为全职学术推广员");
|
|
|
+ }
|
|
|
+ if (sysRole.getRoleId() == 3) {
|
|
|
+ if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
+ return R.failed("用户已存在药企管理员,不能为CSO的全职学术推广员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sysRole.getRoleId() == 4) {
|
|
|
+ if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
+ return R.failed("用户已存在CSO管理员,不能为其他CSO的全职学术推广员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (userDto.getRole().contains(6)) {
|
|
|
+
|
|
|
+ UserDTO userDTO = new UserDTO();
|
|
|
+ userDTO.setUsername(userDto.getUsername());
|
|
|
+ userDTO.setDelFlag("0");
|
|
|
+ List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
+ if (userDTOList.size() > 0) {
|
|
|
+ for (UserVO userVO : userDTOList) {
|
|
|
+ if (null != userVO.getRoleList()) {
|
|
|
+ for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
+ if (sysRole.getRoleId() == 2) {
|
|
|
+ return R.failed("用户已存在平台管理员,不能同时为兼职学术推广员");
|
|
|
+ }
|
|
|
+ SysUserRole sysUserRole = new SysUserRole();
|
|
|
+ sysUserRole.setUserId(userVO.getUserId());
|
|
|
+ List<SysUserRole> sysUserRoleList = sysUserRoleMapper.selectById(sysUserRole);
|
|
|
+ for (int i = 0; i < sysUserRoleList.size(); i++) {
|
|
|
+ if (sysUserRoleList.get(i).getRoleId().equals(7)) {
|
|
|
+ SysUser sysUser = userService.getById(sysUserRoleList.get(i).getUserId());
|
|
|
+ if (sysUser.getDeptId().equals(userDto.getDeptId())) {
|
|
|
+ return R.failed("用户已存在财务管理员角色,不能同时为兼职学术推广员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (userDto.getRole().contains(9)) {
|
|
|
+ UserDTO userDTO = new UserDTO();
|
|
|
+ userDTO.setUsername(userDto.getUsername());
|
|
|
+ userDTO.setDelFlag("0");
|
|
|
+ List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
+ if (userDTOList.size() > 0) {
|
|
|
+ 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 (sysRole.getRoleId() == 4) {
|
|
|
+ return R.failed("用户已存在CSO管理员角色,不能同时为CRO管理员");
|
|
|
+ }
|
|
|
+ if (sysRole.getRoleId() == 9) {
|
|
|
+ return R.failed("用户已存在CRO管理员角色");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (userDto.getRole().contains(31)) {
|
|
|
+ UserDTO userDTO = new UserDTO();
|
|
|
+ userDTO.setUsername(userDto.getUsername());
|
|
|
+ userDTO.setDelFlag("0");
|
|
|
+ List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
+ if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
+ for (UserVO userVO : userDTOList) {
|
|
|
+ for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
+ if (sysRole.getRoleId() == 2) {
|
|
|
+ return R.failed("用户已存在平台管理员,不能同时为招商经理");
|
|
|
+ }
|
|
|
+ if (sysRole.getRoleId() == 3) {
|
|
|
+ if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
+ return R.failed("用户已存在药企管理员,不能为CSO的招商经理");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sysRole.getRoleId() == 4) {
|
|
|
+ if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
+ return R.failed("用户已存在CSO管理员,不能为其他CSO的招商经理");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (userDto.getRole().contains(3)) {
|
|
|
+ if (sysDept.getLevel() != 2) {
|
|
|
+ return R.failed("角色选为药企管理员时,组织架构必须为药企");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // }
|
|
|
+ if (!userDto.getDeptId().equals(SecurityUtils.getUser().getDeptId())) {
|
|
|
+ if (userDto.getRole().contains(5) || userDto.getRole().contains(6)) {
|
|
|
+ return R.failed("不能跨机构维护学术推广员");
|
|
|
+ }
|
|
|
+ if (userDto.getRole().contains(31)) {
|
|
|
+ return R.failed("不能跨机构维护招商经理");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SysUser query = new SysUser();
|
|
|
+ query.setUsername(userDto.getUsername());
|
|
|
+ query.setDeptId(userDto.getDeptId());
|
|
|
+ Integer count = sysUserMapper.selectCount(Wrappers.query(query));
|
|
|
+ // TODO 用户是否存在
|
|
|
+ if (count != 0) {
|
|
|
+ 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.saveUser(userDto));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量导入用户
|
|
|
+ *
|
|
|
+ * @param commonUserExcelModelList 用户信息列表
|
|
|
+ * @return success/false
|
|
|
+ */
|
|
|
+ @SysLog("批量导入用户")
|
|
|
+ @PostMapping(value = "/batch")
|
|
|
+ @PreAuthorize("@pms.hasPermission('sys_user_add')")
|
|
|
+ public R batchUser(@RequestExcel List<CommonUserExcelModel> commonUserExcelModelList) {
|
|
|
+
|
|
|
+ // 参数校验
|
|
|
+ if (CollectionUtils.isEmpty(commonUserExcelModelList)) {
|
|
|
+ log.error("空报表,不能上传");
|
|
|
+ return R.failed("空报表,不能上传");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, List<CommonUserDTO>> collect = commonUserExcelModelList.stream().map(commonUserExcelModel ->
|
|
|
+ BeanUtil.copyProperties(commonUserExcelModel, CommonUserDTO.class)
|
|
|
+ ).collect(Collectors.groupingBy(CommonUserDTO::getUsername));
|
|
|
+
|
|
|
+
|
|
|
+ // 实际的处理业务
|
|
|
+ Map<String, String> errorMap = userService.batchByExcel(collect);
|
|
|
+
|
|
|
+ // 返回上传结果
|
|
|
+ Map<String, Object> result = new HashMap<>(3);
|
|
|
+ if (CollectionUtil.isEmpty(errorMap)) {
|
|
|
+ result.put("code", "SUCCESS");
|
|
|
+ result.put("message", "上传成功");
|
|
|
+ result.put("data", null);
|
|
|
+ return R.ok(result);
|
|
|
+ } else {
|
|
|
+ log.error("上传数据错误,{}", JSONUtil.toJsonStr(errorMap));
|
|
|
+ result.put("code", "FAILURE");
|
|
|
+ result.put("message", "上传数据错误");
|
|
|
+ result.put("data", errorMap);
|
|
|
+ return R.failed(result);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新用户信息
|
|
|
+ *
|
|
|
+ * @param userDto 用户信息
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("更新用户信息")
|
|
|
+ @PutMapping
|
|
|
+ @PreAuthorize("@pms.hasPermission('sys_user_edit')")
|
|
|
+ public R updateUser(@Valid @RequestBody UserDTO userDto) {
|
|
|
+
|
|
|
+ // qcc调用企查查查询是否为主要人员
|
|
|
+ SysDept sysDept = sysDeptService.getById(userDto.getDeptId());
|
|
|
+
|
|
|
+ if (null != userDto.getUserId()) {
|
|
|
+ // 姓名去除空格(包括字符之间的所有空格都会去除)
|
|
|
+ userDto.setRealname(StrUtil.cleanBlank(userDto.getRealname()));
|
|
|
+
|
|
|
+ SysUser oldData = userService.getById(userDto.getUserId());
|
|
|
+ //if (!userDto.getRealname().equals(oldData.getRealname())) {
|
|
|
+ // if (userDto.getRole().contains(6) || userDto.getRole().contains(10)) {
|
|
|
+ // Map<String, String> params = new HashMap<>();
|
|
|
+ // params.put("searchKey", sysDept.getName());
|
|
|
+ // params.put("pageIndex", "1");
|
|
|
+ // params.put("pageSize", "10");
|
|
|
+ // EmployeeGetListResponse qccRes = qccService.getList(params);
|
|
|
+ // if (qccRes.isSuccess()) {
|
|
|
+ // for (EmployeeGetListDataItem item : qccRes.getResult()) {
|
|
|
+ // if (userDto.getRealname().equals(item.getName())) {
|
|
|
+ // if (userDto.getRole().contains(10)) {
|
|
|
+ // return R.failed(String.format("%s为该公司%s,不能为兼职CRC", item.getName(), item.getJob()));
|
|
|
+ // } else {
|
|
|
+ // return R.failed(String.format("%s为该公司%s,不能为兼职学术推广员", item.getName(), item.getJob()));
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (null != qccRes.getPaging()) {
|
|
|
+ // PageInfo qccPage = qccRes.getPaging();
|
|
|
+ // // 需要分页查询
|
|
|
+ // if (qccPage.getTotalRecords() > qccPage.getPageIndex() * qccPage.getPageSize()) {
|
|
|
+ // int totalPage = qccPage.getTotalRecords() / qccPage.getPageSize();
|
|
|
+ //
|
|
|
+ // for (int i = 2; i < totalPage + 2; i++) {
|
|
|
+ // params.put("pageIndex", i + "");
|
|
|
+ // qccRes = qccService.getList(params);
|
|
|
+ // if (qccRes.isSuccess()) {
|
|
|
+ // for (EmployeeGetListDataItem item : qccRes.getResult()) {
|
|
|
+ // if (userDto.getRole().contains(10)) {
|
|
|
+ // return R.failed(String.format("%s为该公司%s,不能为兼职CRC", item.getName(), item.getJob()));
|
|
|
+ // } else {
|
|
|
+ // return R.failed(String.format("%s为该公司%s,不能为兼职学术推广员", item.getName(), item.getJob()));
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+ List<Integer> cetList = new ArrayList<>();
|
|
|
+ cetList.add(1);
|
|
|
+ cetList.add(3);
|
|
|
+ cetList.add(11);
|
|
|
+ cetList.add(12);
|
|
|
+ cetList.add(13);
|
|
|
+ cetList.add(14);
|
|
|
+ cetList.add(15);
|
|
|
+ cetList.add(16);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Modify: start
|
|
|
+ * @Version: v2021.4.16
|
|
|
+ * @Author: ryz
|
|
|
+ * @Date: 2021/4/29
|
|
|
+ * 去掉修改用户信息时候的认证
|
|
|
+ */
|
|
|
+ boolean updateFlag = true;
|
|
|
+ if (null != oldData.getCertStatus()) {
|
|
|
+ if (oldData.getCertStatus() != 10) {
|
|
|
+ updateFlag = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (null != oldData.getRljCertStatus()) {
|
|
|
+ if (oldData.getRljCertStatus() == 1 || oldData.getRljCertStatus() == 3) {
|
|
|
+ updateFlag = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!updateFlag) {
|
|
|
+ if (!userDto.getRealname().equals(oldData.getRealname())) {
|
|
|
+ return R.failed("用户认证通过或正在认证,暂不能修改姓名");
|
|
|
+ }
|
|
|
+ if (!userDto.getIdCardNumber().equals(oldData.getIdCardNumber())) {
|
|
|
+ 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("0");
|
|
|
+ List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
+ if (userDTOList.size() > 0) {
|
|
|
+ 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("0");
|
|
|
+ List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
+ if (userDTOList.size() > 0) {
|
|
|
+ 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 userDTO = new UserDTO();
|
|
|
+ userDTO.setPlatId(userDto.getUsername());
|
|
|
+ userDTO.setDelFlag("0");
|
|
|
+ List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
+ if (userDTOList.size() > 0) {
|
|
|
+ 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("0");
|
|
|
+ List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
+ if (userDTOList.size() > 0) {
|
|
|
+ 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("0");
|
|
|
+ List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
+ if (userDTOList.size() > 0) {
|
|
|
+ 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.val()));
|
|
|
+ if (count > 0) {
|
|
|
+ if (userDto.getRole().contains(6) && userDto.getRole().contains(4)) {
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询用户
|
|
|
+ *
|
|
|
+ * @param page 参数集
|
|
|
+ * @param userDTO 查询参数列表
|
|
|
+ * @return 用户集合
|
|
|
+ */
|
|
|
+ @GetMapping("/page")
|
|
|
+ public R getUserPage(Page page, UserDTO userDTO) {
|
|
|
+
|
|
|
+ return R.ok(userService.getUsersWithRolePageNoLock(page, userDTO));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询用户
|
|
|
+ *
|
|
|
+ * @param page 参数集
|
|
|
+ * @param userDTO 查询参数列表
|
|
|
+ * @return 用户集合
|
|
|
+ */
|
|
|
+ @GetMapping("/selectUserList")
|
|
|
+ public R<?> selectUserList(Page page, UserDTO userDTO) {
|
|
|
+
|
|
|
+ userDTO.setSubType(null);
|
|
|
+ if (StrUtil.isNotBlank(userDTO.getSubjectLocation())) {
|
|
|
+ String[] locationArr = Stream.of(SubjectLocation.values())
|
|
|
+ .map(SubjectLocation::getType)
|
|
|
+ .toArray(String[]::new);
|
|
|
+ if (!ArrayUtil.containsAny(userDTO.getSubjectLocation().split(StrUtil.COMMA), locationArr)) {
|
|
|
+ // 只接收已有的税源地类型值
|
|
|
+ userDTO.setSubjectLocation(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ IPage<UserVO> userVosPage = userService.selectUserList(page, userDTO);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Map<Integer, List<SysCsmUserRelation>> csmParentUserMap = new HashMap<>();
|
|
|
+ if (CollUtil.isNotEmpty(userIds)) {
|
|
|
+ // 上级csm
|
|
|
+ List<SysCsmUserRelation> csmUserRelations = sysCsmUserRelationMapper.selectList(Wrappers.<SysCsmUserRelation>lambdaQuery()
|
|
|
+ .in(SysCsmUserRelation::getUserId, userIds));
|
|
|
+ if (CollUtil.isNotEmpty(csmUserRelations)) {
|
|
|
+ csmParentUserMap.putAll(csmUserRelations.stream().collect(Collectors.groupingBy(SysCsmUserRelation::getUserId)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ userVosPage.getRecords().forEach(userVO -> {
|
|
|
+
|
|
|
+ // 上级csm
|
|
|
+ List<SysCsmUserRelation> csmUserRelations = csmParentUserMap.get(userVO.getUserId());
|
|
|
+ if (CollUtil.isNotEmpty(csmUserRelations)) {
|
|
|
+ userVO.setParentIdList(csmUserRelations.stream().map(SysCsmUserRelation::getParentId).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return R.ok(userVosPage);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改个人信息
|
|
|
+ *
|
|
|
+ * @param userDto userDto
|
|
|
+ * @return success/false
|
|
|
+ */
|
|
|
+ @SysLog("修改个人信息")
|
|
|
+ @PutMapping("/edit")
|
|
|
+ public R updateUserInfo(@Valid @RequestBody UserDTO userDto) {
|
|
|
+ userDto.setUserId(SecurityUtils.getUser().getId());
|
|
|
+ return userService.updateUserInfo(userDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param username 用户名称
|
|
|
+ * @return 上级部门用户列表
|
|
|
+ */
|
|
|
+ @GetMapping("/ancestor/{username}")
|
|
|
+ public R listAncestorUsers(@PathVariable String username) {
|
|
|
+ return R.ok(userService.listAncestorUsers(username));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改个人信息
|
|
|
+ *
|
|
|
+ * @param userDTO userDTO
|
|
|
+ * @return success/false
|
|
|
+ */
|
|
|
+ @GetMapping("/list")
|
|
|
+ public R listScope(Page page, UserDTO userDTO) {
|
|
|
+ if (null != userDTO.getRole() && userDTO.getRole().size() > 0) {
|
|
|
+ userDTO.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
+ page.setSize(10000);
|
|
|
+ List<UserVO> sysUserList = userService.getUsersWithRolePage(page, userDTO).getRecords();
|
|
|
+ List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
+ if (sysUserList.size() > 0) {
|
|
|
+ for (UserVO sysUser : sysUserList) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("id", sysUser.getUserId() + "");
|
|
|
+ map.put("realname", sysUser.getRealname() + "");
|
|
|
+ answerList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return R.ok(answerList);
|
|
|
+ } else {
|
|
|
+ page.setSize(10000);
|
|
|
+ List<Integer> list = new ArrayList<>();
|
|
|
+ list.add(5);
|
|
|
+ list.add(6);
|
|
|
+ userDTO.setRole(list);
|
|
|
+
|
|
|
+ List<UserVO> sysUserList = userService.getUsersWithRolePage(page, userDTO).getRecords();
|
|
|
+ List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
+ if (sysUserList.size() > 0) {
|
|
|
+ for (UserVO sysUser : sysUserList) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("id", sysUser.getUserId() + "");
|
|
|
+ map.put("realname", sysUser.getRealname() + "");
|
|
|
+ answerList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return R.ok(answerList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询全可用的用户
|
|
|
+ *
|
|
|
+ * @param userDTO userDTO
|
|
|
+ * @return success/false
|
|
|
+ */
|
|
|
+ @SysLog("查询全可用的用户")
|
|
|
+ @GetMapping("/list/available")
|
|
|
+ public R listScope1(Page page, UserDTO userDTO) {
|
|
|
+ userDTO.setLockFlag(CommonConstants.STATUS_NORMAL);
|
|
|
+ if (CollUtil.isNotEmpty(userDTO.getRole())) {
|
|
|
+ userDTO.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
+ page.setSize(10000);
|
|
|
+ List<UserVO> sysUserList = userService.getUsersWithRolePage(page, userDTO).getRecords();
|
|
|
+ List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
+ if (sysUserList.size() > 0) {
|
|
|
+ for (UserVO sysUser : sysUserList) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("id", sysUser.getUserId() + "");
|
|
|
+ map.put("username", sysUser.getUsername() + "");
|
|
|
+ map.put("realname", sysUser.getRealname() + "");
|
|
|
+ answerList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return R.ok(answerList);
|
|
|
+ } else {
|
|
|
+ page.setSize(10000);
|
|
|
+ List<Integer> list = new ArrayList<>();
|
|
|
+ list.add(5);
|
|
|
+ list.add(6);
|
|
|
+ userDTO.setRole(list);
|
|
|
+
|
|
|
+ List<UserVO> sysUserList = userService.getUsersWithRolePage(page, userDTO).getRecords();
|
|
|
+ List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
+ if (sysUserList.size() > 0) {
|
|
|
+ for (UserVO sysUser : sysUserList) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("id", sysUser.getUserId() + "");
|
|
|
+ map.put("username", sysUser.getUsername() + "");
|
|
|
+ map.put("realname", sysUser.getRealname() + "");
|
|
|
+ answerList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return R.ok(answerList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询用户列表
|
|
|
+ *
|
|
|
+ * @param userDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/listNoScope")
|
|
|
+ public R listNoScope(UserDTO userDTO) {
|
|
|
+
|
|
|
+ SysUser sysUserSel = new SysUser();
|
|
|
+
|
|
|
+ if (SecurityUtils.getRoles().contains(2) || SecurityUtils.getRoles().contains(1)) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ sysUserSel.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
+ }
|
|
|
+ QueryWrapper<SysUser> query = Wrappers.query(sysUserSel);
|
|
|
+ if (StringUtils.isNotEmpty(userDTO.getRealname())) {
|
|
|
+ query.lambda().like(SysUser::getRealname, userDTO.getRealname());
|
|
|
+ }
|
|
|
+ List<SysUser> sysUserList = userService.list(query);
|
|
|
+ List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
+ if (sysUserList.size() > 0) {
|
|
|
+ for (SysUser sysUser : sysUserList) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("id", sysUser.getUserId() + "");
|
|
|
+ map.put("realname", sysUser.getRealname() + "");
|
|
|
+ map.put("name", sysUser.getUsername() + "");
|
|
|
+
|
|
|
+ answerList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return R.ok(answerList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改个人信息
|
|
|
+ *
|
|
|
+ * @param userDTO userDTO
|
|
|
+ * @return success/false
|
|
|
+ */
|
|
|
+ @GetMapping("/listNoScopeAll")
|
|
|
+ public R listNoScopeAll(Page page, UserDTO userDTO) {
|
|
|
+ page.setSize(10000);
|
|
|
+ QueryWrapper<SysUser> queryWrapper = null;
|
|
|
+ if (userDTO.getDeptId() != null) {
|
|
|
+ SysUser sysUser = new SysUser();
|
|
|
+ sysUser.setDeptId(userDTO.getDeptId());
|
|
|
+ queryWrapper = Wrappers.query(sysUser);
|
|
|
+ } else {
|
|
|
+ queryWrapper = Wrappers.query();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SysUser> sysUserList = userService.list(queryWrapper);
|
|
|
+ List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
+ if (sysUserList.size() > 0) {
|
|
|
+ for (SysUser sysUser : sysUserList) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("id", sysUser.getUserId() + "");
|
|
|
+ map.put("realname", sysUser.getRealname() + "");
|
|
|
+ map.put("name", sysUser.getUsername() + "");
|
|
|
+
|
|
|
+ answerList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return R.ok(answerList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询CSM列表
|
|
|
+ *
|
|
|
+ * @return {@link R}<{@link ?}>
|
|
|
+ */
|
|
|
+ @GetMapping("/list-csm")
|
|
|
+ public R<?> listCsm() {
|
|
|
+ UserDTO userDTO = new UserDTO();
|
|
|
+ userDTO.setRole(Stream.of(19).collect(Collectors.toList()));
|
|
|
+ List<UserVO> users = sysUserMapper.listUserByRole(userDTO);
|
|
|
+
|
|
|
+ List<Map<String, Object>> result = users.stream().map(user -> {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("userId", user.getUserId());
|
|
|
+ map.put("realname", user.getRealname());
|
|
|
+ return map;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ return R.ok(result);
|
|
|
+ }
|
|
|
|
|
|
}
|