|
@@ -20,12 +20,16 @@
|
|
package com.qunzhixinxi.hnqz.admin.controller;
|
|
package com.qunzhixinxi.hnqz.admin.controller;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
import com.alibaba.csp.sentinel.util.StringUtil;
|
|
import com.alibaba.csp.sentinel.util.StringUtil;
|
|
import com.alibaba.nacos.common.utils.Md5Utils;
|
|
import com.alibaba.nacos.common.utils.Md5Utils;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.pig4cloud.plugin.excel.annotation.RequestExcel;
|
|
import com.qunzhixinxi.hnqz.admin.api.dto.UserDTO;
|
|
import com.qunzhixinxi.hnqz.admin.api.dto.UserDTO;
|
|
import com.qunzhixinxi.hnqz.admin.api.dto.UserInfo;
|
|
import com.qunzhixinxi.hnqz.admin.api.dto.UserInfo;
|
|
import com.qunzhixinxi.hnqz.admin.api.dto.UserPwd;
|
|
import com.qunzhixinxi.hnqz.admin.api.dto.UserPwd;
|
|
@@ -36,7 +40,9 @@ import com.qunzhixinxi.hnqz.admin.api.entity.SysUserRole;
|
|
import com.qunzhixinxi.hnqz.admin.api.vo.ErrorInfoVo;
|
|
import com.qunzhixinxi.hnqz.admin.api.vo.ErrorInfoVo;
|
|
import com.qunzhixinxi.hnqz.admin.api.vo.UserVO;
|
|
import com.qunzhixinxi.hnqz.admin.api.vo.UserVO;
|
|
import com.qunzhixinxi.hnqz.admin.config.UpmsConfig;
|
|
import com.qunzhixinxi.hnqz.admin.config.UpmsConfig;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.entity.dto.CommonUserDTO;
|
|
import com.qunzhixinxi.hnqz.admin.entity.input.UserCertificationInput;
|
|
import com.qunzhixinxi.hnqz.admin.entity.input.UserCertificationInput;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.entity.model.excel.CommonUserExcelModel;
|
|
import com.qunzhixinxi.hnqz.admin.enums.SubjectTypeEnum;
|
|
import com.qunzhixinxi.hnqz.admin.enums.SubjectTypeEnum;
|
|
import com.qunzhixinxi.hnqz.admin.mapper.*;
|
|
import com.qunzhixinxi.hnqz.admin.mapper.*;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
|
|
@@ -79,6 +85,7 @@ import javax.validation.Valid;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author hnqz
|
|
* @author hnqz
|
|
@@ -873,486 +880,528 @@ public class SysUserController {
|
|
/**
|
|
/**
|
|
* 批量导入用户
|
|
* 批量导入用户
|
|
*
|
|
*
|
|
- * @param file 用户信息文件
|
|
|
|
|
|
+ * @param commonUserExcelModelList 用户信息列表
|
|
* @return success/false
|
|
* @return success/false
|
|
*/
|
|
*/
|
|
@SysLog("批量导入用户")
|
|
@SysLog("批量导入用户")
|
|
@PostMapping(value = "/batch")
|
|
@PostMapping(value = "/batch")
|
|
@PreAuthorize("@pms.hasPermission('sys_user_add')")
|
|
@PreAuthorize("@pms.hasPermission('sys_user_add')")
|
|
- public R batchUser(@RequestPart("file") MultipartFile file) {
|
|
|
|
-
|
|
|
|
- // 获取操作员和操作员所在的结算主体
|
|
|
|
- HnqzUser operator = SecurityUtils.getUser();
|
|
|
|
- SysDept sysDept = sysDeptService.getById(operator.getDeptId());
|
|
|
|
-
|
|
|
|
- // 读取excel
|
|
|
|
- try {
|
|
|
|
- String fileName = file.getOriginalFilename().toLowerCase();
|
|
|
|
- InputStream inputStream = file.getInputStream();
|
|
|
|
-
|
|
|
|
- // 校验文件信息
|
|
|
|
- Workbook wbs = null;
|
|
|
|
- if (fileName.endsWith("xls")) {
|
|
|
|
- //2003
|
|
|
|
- wbs = new HSSFWorkbook(inputStream);
|
|
|
|
- } else if (fileName.endsWith("xlsx")) {
|
|
|
|
- //2007
|
|
|
|
- wbs = new XSSFWorkbook(inputStream);
|
|
|
|
- } else {
|
|
|
|
- return R.failed("上传文件格式错误!");
|
|
|
|
- }
|
|
|
|
- if (wbs.isSheetHidden(0)) {
|
|
|
|
- return R.failed("导入表中有隐藏列");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 校验页(数据页)
|
|
|
|
- Sheet sheet = wbs.getSheetAt(1);
|
|
|
|
-
|
|
|
|
- // 校验模板
|
|
|
|
- Row row0 = sheet.getRow(0);
|
|
|
|
- if (row0 == null) {
|
|
|
|
- return R.failed("导入模版错误!");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 校验记录数
|
|
|
|
- int rowNum = sheet.getLastRowNum();
|
|
|
|
- if (rowNum < 1) {
|
|
|
|
- return R.failed("导入表中缺少数据!");
|
|
|
|
- } else if (rowNum > 1000) {
|
|
|
|
- return R.failed("单次批量导入最大支持1000行数据!");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 校验列信息
|
|
|
|
- String name = row0.getCell(0).getStringCellValue();
|
|
|
|
- if (!"姓名".equals(name)) {
|
|
|
|
- return R.failed("导入模版第一列错误!");
|
|
|
|
- }
|
|
|
|
- String phone = row0.getCell(1).getStringCellValue();
|
|
|
|
- if (!"手机号".equals(phone)) {
|
|
|
|
- return R.failed("导入模版第二列错误!");
|
|
|
|
- }
|
|
|
|
- String prov = row0.getCell(2).getStringCellValue();
|
|
|
|
- if (!"省".equals(prov)) {
|
|
|
|
- return R.failed("导入模版第三列错误!");
|
|
|
|
- }
|
|
|
|
- String city = row0.getCell(3).getStringCellValue();
|
|
|
|
- if (!"市".equals(city)) {
|
|
|
|
- return R.failed("导入模版第四列错误!");
|
|
|
|
- }
|
|
|
|
- String role = row0.getCell(4).getStringCellValue();
|
|
|
|
- if (!"角色".equals(role)) {
|
|
|
|
- return R.failed("导入模版第五列错误!");
|
|
|
|
- }
|
|
|
|
- String userStatus = row0.getCell(5).getStringCellValue();
|
|
|
|
- if (!"状态".equals(userStatus)) {
|
|
|
|
- return R.failed("导入模版第六列错误!");
|
|
|
|
- }
|
|
|
|
- String provinceCode = row0.getCell(6).getStringCellValue();
|
|
|
|
- if (!"省份编码".equals(provinceCode)) {
|
|
|
|
- return R.failed("导入模版第七列错误!");
|
|
|
|
- }
|
|
|
|
- String cityCode = row0.getCell(7).getStringCellValue();
|
|
|
|
- if (!"城市编码".equals(cityCode)) {
|
|
|
|
- return R.failed("导入模版第八列错误!");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //数据
|
|
|
|
- List<UserDTO> userDTOList = new ArrayList<>();
|
|
|
|
- List<ErrorInfoVo> errorList = new ArrayList<>();
|
|
|
|
- log.info(">>> 通过excel批量创建用户开始 <<<");
|
|
|
|
- // 行数据
|
|
|
|
- for (int i = 1; i <= rowNum; i++) {
|
|
|
|
-
|
|
|
|
- // 行编号
|
|
|
|
- int rNum = i;
|
|
|
|
- Row row = sheet.getRow(i);
|
|
|
|
- log.info(">>>当前导入第{}行<<<", i);
|
|
|
|
-
|
|
|
|
- if (row == null) {
|
|
|
|
- ErrorInfoVo errorInfoVo = new ErrorInfoVo();
|
|
|
|
- errorInfoVo.setRowNum(rNum);
|
|
|
|
- errorInfoVo.setColumnName(null);
|
|
|
|
- errorInfoVo.setContent(null);
|
|
|
|
- errorInfoVo.setReason("当前行没有数据信息");
|
|
|
|
- errorList.add(errorInfoVo);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- int colNum = row.getLastCellNum();
|
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
|
-
|
|
|
|
- userDTO.setDeptId(sysDept.getDeptId());
|
|
|
|
- if(ArrayUtils.contains(sysDept.getSubjectType(),SubjectTypeEnum.TYPE_SHUIBANGYUN.getCode())){
|
|
|
|
- userDTO.setCertStatus(TaxHelperCertStatus.UN_CERT.getCode());
|
|
|
|
- }
|
|
|
|
-// if(ArrayUtils.contains(sysDept.getSubjectType(),SubjectTypeEnum.TYPE_RENLIJIA.getCode())){
|
|
|
|
-// userDTO.setRljCertStatus(DingEnum.CER_STATUS_4.getType());
|
|
|
|
-// }
|
|
|
|
-// if ("1".equals(sysDept.getSubjectType())) {
|
|
|
|
-// userDTO.setCertStatus(TaxHelperCertStatus.UN_CERT.getCode());
|
|
|
|
-// userDTO.setUserType("1");
|
|
|
|
-// } else {
|
|
|
|
-// userDTO.setUserType("0");
|
|
|
|
-// }
|
|
|
|
- userDTO.setCreateTime(LocalDateTime.now());
|
|
|
|
-
|
|
|
|
- for (int j = 0; j < colNum; j++) {//列数据
|
|
|
|
-
|
|
|
|
- // 获取列名称
|
|
|
|
- String columnName = row0.getCell(j).getStringCellValue();
|
|
|
|
- int columnNum = j + 1;
|
|
|
|
-
|
|
|
|
- if (null == row.getCell(j)) {
|
|
|
|
- ErrorInfoVo errorInfoVo = new ErrorInfoVo();
|
|
|
|
- errorInfoVo.setRowNum(rNum);
|
|
|
|
- errorInfoVo.setColumnNum(columnNum);
|
|
|
|
- errorInfoVo.setColumnName(columnName);
|
|
|
|
- errorInfoVo.setContent(null);
|
|
|
|
- errorInfoVo.setReason("列数据为空");
|
|
|
|
- errorList.add(errorInfoVo);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 格式化字符串
|
|
|
|
- row.getCell(j).setCellType(CellType.STRING);
|
|
|
|
- String value = row.getCell(j).getStringCellValue()
|
|
|
|
- .replaceAll(" ", "")
|
|
|
|
- .replaceAll(",", "")
|
|
|
|
- .replaceAll("\\u00A0", "")
|
|
|
|
- .replaceAll((char) 12288 + "", "")
|
|
|
|
- .replace("+", "·");
|
|
|
|
-
|
|
|
|
- // 校验value
|
|
|
|
- if (StringUtil.isEmpty(value)) {
|
|
|
|
- ErrorInfoVo errorInfoVo = new ErrorInfoVo();
|
|
|
|
- errorInfoVo.setRowNum(rNum);
|
|
|
|
- errorInfoVo.setColumnNum(columnNum);
|
|
|
|
- errorInfoVo.setColumnName(columnName);
|
|
|
|
- errorInfoVo.setContent(value);
|
|
|
|
- errorInfoVo.setReason("数据为空");
|
|
|
|
- errorList.add(errorInfoVo);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (j == 0) {
|
|
|
|
- userDTO.setRealname(value);
|
|
|
|
- } else if (j == 1) {
|
|
|
|
- // 记录错误说明
|
|
|
|
- String errorInfo = null;
|
|
|
|
- // 正则校验手机号
|
|
|
|
- if (ValidateUtils.validPhoneNum("0", value)) {
|
|
|
|
- // 判断同一个dept下用户是否重复
|
|
|
|
- SysUser query = new SysUser();
|
|
|
|
- query.setUsername(value);
|
|
|
|
- query.setDeptId(userDTO.getDeptId());
|
|
|
|
- SysUser sysUser = sysUserMapper.selectUserByName(query);
|
|
|
|
- if (sysUser != null) {
|
|
|
|
- errorInfo = "手机号已被占用";
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- errorInfo = "不是手机号";
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 封装错误信息
|
|
|
|
- if (StringUtils.isNotEmpty(errorInfo)) {
|
|
|
|
- ErrorInfoVo errorInfoVo = new ErrorInfoVo();
|
|
|
|
- errorInfoVo.setRowNum(rNum);
|
|
|
|
- errorInfoVo.setColumnNum(columnNum);
|
|
|
|
- errorInfoVo.setColumnName(columnName);
|
|
|
|
- errorInfoVo.setContent(value);
|
|
|
|
- errorInfoVo.setReason(errorInfo);
|
|
|
|
- errorList.add(errorInfoVo);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- userDTO.setPlatId(value);
|
|
|
|
- userDTO.setPhone(value);
|
|
|
|
- userDTO.setUsername(value);
|
|
|
|
- } else if (j == 2) {
|
|
|
|
- if ("全国".equals(value)) {
|
|
|
|
- userDTO.setProvince("");
|
|
|
|
- } else {
|
|
|
|
- userDTO.setProvince(value);
|
|
|
|
- }
|
|
|
|
- } else if (j == 3) {
|
|
|
|
- if (StringUtils.isEmpty(userDTO.getProvince())) {
|
|
|
|
- userDTO.setCity("");
|
|
|
|
- } else {
|
|
|
|
- userDTO.setCity(value);
|
|
|
|
- }
|
|
|
|
- } else if (j == 4) {
|
|
|
|
- // 声明错误信息记录
|
|
|
|
- String errorInfo = "";
|
|
|
|
-
|
|
|
|
- // 根据角色名称获取角色
|
|
|
|
- SysRole sysRole = sysRoleMapper.selectOne(Wrappers.<SysRole>query().eq("role_name", value));
|
|
|
|
- if (sysRole != null) {
|
|
|
|
- userDTO.setRole(Arrays.asList(sysRole.getRoleId()));
|
|
|
|
- if (userDTO.getRole().contains(2)) {
|
|
|
|
- UserDTO tmp = new UserDTO();
|
|
|
|
- tmp.setUsername(userDTO.getUsername());
|
|
|
|
- tmp.setDelFlag("0");
|
|
|
|
- List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
|
|
- if (userVoList.size() > 0) {
|
|
|
|
- for (UserVO userVO : userVoList) {
|
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
|
- for (SysRole r : userVO.getRoleList()) {
|
|
|
|
- if (r.getRoleId() == 3) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为药企管理员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (r.getRoleId() == 4) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为CSO管理员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (r.getRoleId() == 5) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为全职学术推广员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (r.getRoleId() == 6) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为兼职学术推广员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (r.getRoleId() == 7) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为财务管理员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else if (userDTO.getRole().contains(3)) {
|
|
|
|
- UserDTO tmp = new UserDTO();
|
|
|
|
- tmp.setUsername(userDTO.getUsername());
|
|
|
|
- tmp.setDelFlag("0");
|
|
|
|
- List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
|
|
- if (userVoList.size() > 0) {
|
|
|
|
- for (UserVO userVO : userVoList) {
|
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
|
- for (SysRole r : userVO.getRoleList()) {
|
|
|
|
- if (r.getRoleId() == 2) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在药企管理员角色,不能同时为平台管理员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (r.getRoleId() == 4) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在药企管理员角色,不能同时为CSO管理员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
|
- if (r.getRoleId() == 5) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在CSO关系角色,不能同时为药企管理员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else if (userDTO.getRole().contains(4)) {
|
|
|
|
- UserDTO tmp = new UserDTO();
|
|
|
|
- tmp.setUsername(userDTO.getUsername());
|
|
|
|
- tmp.setDelFlag("0");
|
|
|
|
- List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
|
|
- if (userVoList.size() > 0) {
|
|
|
|
- for (UserVO userVO : userVoList) {
|
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
|
- for (SysRole r : userVO.getRoleList()) {
|
|
|
|
- if (sysRole.getRoleId() == 2) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (r.getRoleId() == 3) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在药企管理员角色,不能同时为CSO管理员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (r.getRoleId() == 5) {
|
|
|
|
- SysUserRole sysUserRole = new SysUserRole();
|
|
|
|
- sysUserRole.setUserId(userVO.getUserId());
|
|
|
|
- List<SysUserRole> sysUserRoleList = sysUserRoleMapper.selectById(sysUserRole);
|
|
|
|
- for (int k = 0; k < sysUserRoleList.size(); k++) {
|
|
|
|
- SysUser sysUser = userService.getById(sysUserRoleList.get(k).getUserId());
|
|
|
|
- if (!sysUser.getDeptId().equals(userDTO.getDeptId())) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在全职学术推广员角色,不能为其他机构CSO管理员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else if (userDTO.getRole().contains(7)) {
|
|
|
|
- UserDTO tmp = new UserDTO();
|
|
|
|
- tmp.setUsername(userDTO.getUsername());
|
|
|
|
- tmp.setDelFlag("0");
|
|
|
|
- List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
|
|
- if (userVoList.size() > 0) {
|
|
|
|
- for (UserVO userVO : userVoList) {
|
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
|
- for (SysRole r : userVO.getRoleList()) {
|
|
|
|
- if (r.getRoleId() == 2) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在平台管理员,不能同时为财务管理员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
|
- if (r.getRoleId() == 3) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在药企管理员,不能同时为CSO机构财务管理员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else if (userDTO.getRole().contains(5)) {
|
|
|
|
- UserDTO tmp = new UserDTO();
|
|
|
|
- tmp.setUsername(userDTO.getUsername());
|
|
|
|
- tmp.setDelFlag("0");
|
|
|
|
- List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
|
|
- if (userVoList.size() > 0) {
|
|
|
|
- for (UserVO userVO : userVoList) {
|
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
|
- for (SysRole r : userVO.getRoleList()) {
|
|
|
|
- if (r.getRoleId() == 2) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在平台管理员,不能同时为全职学术推广员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (r.getRoleId() == 3) {
|
|
|
|
- if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在药企管理员,不能为CSO的全职学术推广员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (r.getRoleId() == 4) {
|
|
|
|
- if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在CSO管理员,不能为其他CSO的全职学术推广员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ public R batchUser(@RequestExcel List<CommonUserExcelModel> commonUserExcelModelList){
|
|
|
|
|
|
- } else if (userDTO.getRole().contains(6)) {
|
|
|
|
- UserDTO tmp = new UserDTO();
|
|
|
|
- tmp.setUsername(userDTO.getUsername());
|
|
|
|
- tmp.setDelFlag("0");
|
|
|
|
- List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
|
|
- if (userVoList.size() > 0) {
|
|
|
|
- for (UserVO userVO : userVoList) {
|
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
|
- for (SysRole r : userVO.getRoleList()) {
|
|
|
|
- if (r.getRoleId() == 2) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在平台管理员,不能同时为兼职学术推广员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- SysUserRole sysUserRole = new SysUserRole();
|
|
|
|
- sysUserRole.setUserId(userVO.getUserId());
|
|
|
|
- List<SysUserRole> sysUserRoleList = sysUserRoleMapper.selectById(sysUserRole);
|
|
|
|
- for (int k = 0; k < sysUserRoleList.size(); k++) {
|
|
|
|
- if (sysUserRoleList.get(k).getRoleId().equals(7)) {
|
|
|
|
- SysUser sysUser = userService.getById(sysUserRoleList.get(k).getUserId());
|
|
|
|
- if (sysUser.getDeptId().equals(userDTO.getDeptId())) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在财务管理员角色,不能同时为兼职学术推广员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // 参数校验
|
|
|
|
+ if (CollectionUtils.isEmpty(commonUserExcelModelList)) {
|
|
|
|
+ log.error("空报表,不能上传");
|
|
|
|
+ return R.failed("空报表,不能上传");
|
|
|
|
+ }
|
|
|
|
|
|
- } else if (userDTO.getRole().contains(9)) {
|
|
|
|
- UserDTO tmp = new UserDTO();
|
|
|
|
- tmp.setUsername(userDTO.getUsername());
|
|
|
|
- tmp.setDelFlag("0");
|
|
|
|
- List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
|
|
- if (userVoList.size() > 0) {
|
|
|
|
- for (UserVO userVO : userVoList) {
|
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
|
- for (SysRole r : userVO.getRoleList()) {
|
|
|
|
- if (sysRole.getRoleId() == 2) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在平台管理员,不能同时为CRO管理员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (r.getRoleId() == 3) {
|
|
|
|
- errorInfo = errorInfo + "用户已存在药企管理员,不能同时为CRO管理员!";
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (userDTO.getRole().contains(3)) {
|
|
|
|
- if (sysDept.getLevel() != 2) {
|
|
|
|
- errorInfo = errorInfo + "角色选为药企管理员时,组织架构必须为药企!";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (!userDTO.getDeptId().equals(SecurityUtils.getUser().getDeptId())) {
|
|
|
|
- if (userDTO.getRole().contains(5) || userDTO.getRole().contains(6)) {
|
|
|
|
- errorInfo = errorInfo + "不能跨机构维护学术推广员!";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ Map<String, List<CommonUserDTO>> collect = commonUserExcelModelList.stream().map(commonUserExcelModel ->
|
|
|
|
+ BeanUtil.copyProperties(commonUserExcelModel, CommonUserDTO.class)
|
|
|
|
+ ).collect(Collectors.groupingBy(CommonUserDTO::getUsername));
|
|
|
|
|
|
- // 存在错误
|
|
|
|
- if (StringUtils.isNotEmpty(errorInfo) || sysRole == null) {
|
|
|
|
- ErrorInfoVo errorInfoVo = new ErrorInfoVo();
|
|
|
|
- errorInfoVo.setRowNum(rNum);
|
|
|
|
- errorInfoVo.setColumnNum(columnNum);
|
|
|
|
- errorInfoVo.setColumnName(columnName);
|
|
|
|
- errorInfoVo.setContent(errorInfo);
|
|
|
|
- errorInfoVo.setReason("角色信息有误");
|
|
|
|
- errorList.add(errorInfoVo);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- } else if (j == 5) {
|
|
|
|
- if (!"活跃".equals(value) && !"休眠".equals(value)) {
|
|
|
|
- ErrorInfoVo errorInfoVo = new ErrorInfoVo();
|
|
|
|
- errorInfoVo.setRowNum(rNum);
|
|
|
|
- errorInfoVo.setColumnNum(columnNum);
|
|
|
|
- errorInfoVo.setColumnName(columnName);
|
|
|
|
- errorInfoVo.setContent(value);
|
|
|
|
- errorInfoVo.setReason("角色状态有误");
|
|
|
|
- errorList.add(errorInfoVo);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- userDTO.setLockFlag("活跃".equals(value) ? "0" : "9");
|
|
|
|
- } else if (j == 6) {
|
|
|
|
- userDTO.setProvinceCode(value);
|
|
|
|
- } else if (j == 7) {
|
|
|
|
- userDTO.setCityCode(value);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
- // 记录争取额的信息
|
|
|
|
- userDTOList.add(userDTO);
|
|
|
|
- }
|
|
|
|
|
|
+ // 实际的处理业务
|
|
|
|
+ Map<String, String> errorMap = userService.batchByExcel(collect);
|
|
|
|
|
|
- // 判断是否有错误的数据行,如果没有,执行入库操作
|
|
|
|
- if (CollectionUtils.isEmpty(errorList)) {
|
|
|
|
- userDTOList.forEach(userDTO -> {
|
|
|
|
- userService.saveUser(userDTO);
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- return R.ok(errorList);
|
|
|
|
|
|
+ // 返回上传结果
|
|
|
|
+ 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);
|
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("批量创建用户失败:{}",e.getMessage());
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return R.failed("批量创建用户失败");
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// /**
|
|
|
|
+// * 批量导入用户
|
|
|
|
+// *
|
|
|
|
+// * @param file 用户信息文件
|
|
|
|
+// * @return success/false
|
|
|
|
+// */
|
|
|
|
+// @SysLog("批量导入用户")
|
|
|
|
+// @PostMapping(value = "/batch")
|
|
|
|
+// @PreAuthorize("@pms.hasPermission('sys_user_add')")
|
|
|
|
+// public R batchUser(@RequestPart("file") MultipartFile file) {
|
|
|
|
+//
|
|
|
|
+// // 获取操作员和操作员所在的结算主体
|
|
|
|
+// HnqzUser operator = SecurityUtils.getUser();
|
|
|
|
+// SysDept sysDept = sysDeptService.getById(operator.getDeptId());
|
|
|
|
+//
|
|
|
|
+// // 读取excel
|
|
|
|
+// try {
|
|
|
|
+// String fileName = file.getOriginalFilename().toLowerCase();
|
|
|
|
+// InputStream inputStream = file.getInputStream();
|
|
|
|
+//
|
|
|
|
+// // 校验文件信息
|
|
|
|
+// Workbook wbs = null;
|
|
|
|
+// if (fileName.endsWith("xls")) {
|
|
|
|
+// //2003
|
|
|
|
+// wbs = new HSSFWorkbook(inputStream);
|
|
|
|
+// } else if (fileName.endsWith("xlsx")) {
|
|
|
|
+// //2007
|
|
|
|
+// wbs = new XSSFWorkbook(inputStream);
|
|
|
|
+// } else {
|
|
|
|
+// return R.failed("上传文件格式错误!");
|
|
|
|
+// }
|
|
|
|
+// if (wbs.isSheetHidden(0)) {
|
|
|
|
+// return R.failed("导入表中有隐藏列");
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// // 校验页(数据页)
|
|
|
|
+// Sheet sheet = wbs.getSheetAt(1);
|
|
|
|
+//
|
|
|
|
+// // 校验模板
|
|
|
|
+// Row row0 = sheet.getRow(0);
|
|
|
|
+// if (row0 == null) {
|
|
|
|
+// return R.failed("导入模版错误!");
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// // 校验记录数
|
|
|
|
+// int rowNum = sheet.getLastRowNum();
|
|
|
|
+// if (rowNum < 1) {
|
|
|
|
+// return R.failed("导入表中缺少数据!");
|
|
|
|
+// } else if (rowNum > 1000) {
|
|
|
|
+// return R.failed("单次批量导入最大支持1000行数据!");
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// // 校验列信息
|
|
|
|
+// String name = row0.getCell(0).getStringCellValue();
|
|
|
|
+// if (!"姓名".equals(name)) {
|
|
|
|
+// return R.failed("导入模版第一列错误!");
|
|
|
|
+// }
|
|
|
|
+// String phone = row0.getCell(1).getStringCellValue();
|
|
|
|
+// if (!"手机号".equals(phone)) {
|
|
|
|
+// return R.failed("导入模版第二列错误!");
|
|
|
|
+// }
|
|
|
|
+// String prov = row0.getCell(2).getStringCellValue();
|
|
|
|
+// if (!"省".equals(prov)) {
|
|
|
|
+// return R.failed("导入模版第三列错误!");
|
|
|
|
+// }
|
|
|
|
+// String city = row0.getCell(3).getStringCellValue();
|
|
|
|
+// if (!"市".equals(city)) {
|
|
|
|
+// return R.failed("导入模版第四列错误!");
|
|
|
|
+// }
|
|
|
|
+// String role = row0.getCell(4).getStringCellValue();
|
|
|
|
+// if (!"角色".equals(role)) {
|
|
|
|
+// return R.failed("导入模版第五列错误!");
|
|
|
|
+// }
|
|
|
|
+// String userStatus = row0.getCell(5).getStringCellValue();
|
|
|
|
+// if (!"状态".equals(userStatus)) {
|
|
|
|
+// return R.failed("导入模版第六列错误!");
|
|
|
|
+// }
|
|
|
|
+// String provinceCode = row0.getCell(6).getStringCellValue();
|
|
|
|
+// if (!"省份编码".equals(provinceCode)) {
|
|
|
|
+// return R.failed("导入模版第七列错误!");
|
|
|
|
+// }
|
|
|
|
+// String cityCode = row0.getCell(7).getStringCellValue();
|
|
|
|
+// if (!"城市编码".equals(cityCode)) {
|
|
|
|
+// return R.failed("导入模版第八列错误!");
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //数据
|
|
|
|
+// List<UserDTO> userDTOList = new ArrayList<>();
|
|
|
|
+// List<ErrorInfoVo> errorList = new ArrayList<>();
|
|
|
|
+// log.info(">>> 通过excel批量创建用户开始 <<<");
|
|
|
|
+// // 行数据
|
|
|
|
+// for (int i = 1; i <= rowNum; i++) {
|
|
|
|
+//
|
|
|
|
+// // 行编号
|
|
|
|
+// int rNum = i;
|
|
|
|
+// Row row = sheet.getRow(i);
|
|
|
|
+// log.info(">>>当前导入第{}行<<<", i);
|
|
|
|
+//
|
|
|
|
+// if (row == null) {
|
|
|
|
+// ErrorInfoVo errorInfoVo = new ErrorInfoVo();
|
|
|
|
+// errorInfoVo.setRowNum(rNum);
|
|
|
|
+// errorInfoVo.setColumnName(null);
|
|
|
|
+// errorInfoVo.setContent(null);
|
|
|
|
+// errorInfoVo.setReason("当前行没有数据信息");
|
|
|
|
+// errorList.add(errorInfoVo);
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// int colNum = row.getLastCellNum();
|
|
|
|
+// UserDTO userDTO = new UserDTO();
|
|
|
|
+//
|
|
|
|
+// userDTO.setDeptId(sysDept.getDeptId());
|
|
|
|
+// if(ArrayUtils.contains(sysDept.getSubjectType(),SubjectTypeEnum.TYPE_SHUIBANGYUN.getCode())){
|
|
|
|
+// userDTO.setCertStatus(TaxHelperCertStatus.UN_CERT.getCode());
|
|
|
|
+// }
|
|
|
|
+// // if(ArrayUtils.contains(sysDept.getSubjectType(),SubjectTypeEnum.TYPE_RENLIJIA.getCode())){
|
|
|
|
+// // userDTO.setRljCertStatus(DingEnum.CER_STATUS_4.getType());
|
|
|
|
+// // }
|
|
|
|
+// // if ("1".equals(sysDept.getSubjectType())) {
|
|
|
|
+// // userDTO.setCertStatus(TaxHelperCertStatus.UN_CERT.getCode());
|
|
|
|
+// // userDTO.setUserType("1");
|
|
|
|
+// // } else {
|
|
|
|
+// // userDTO.setUserType("0");
|
|
|
|
+// // }
|
|
|
|
+// userDTO.setCreateTime(LocalDateTime.now());
|
|
|
|
+//
|
|
|
|
+// for (int j = 0; j < colNum; j++) {//列数据
|
|
|
|
+//
|
|
|
|
+// // 获取列名称
|
|
|
|
+// String columnName = row0.getCell(j).getStringCellValue();
|
|
|
|
+// int columnNum = j + 1;
|
|
|
|
+//
|
|
|
|
+// if (null == row.getCell(j)) {
|
|
|
|
+// ErrorInfoVo errorInfoVo = new ErrorInfoVo();
|
|
|
|
+// errorInfoVo.setRowNum(rNum);
|
|
|
|
+// errorInfoVo.setColumnNum(columnNum);
|
|
|
|
+// errorInfoVo.setColumnName(columnName);
|
|
|
|
+// errorInfoVo.setContent(null);
|
|
|
|
+// errorInfoVo.setReason("列数据为空");
|
|
|
|
+// errorList.add(errorInfoVo);
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// // 格式化字符串
|
|
|
|
+// row.getCell(j).setCellType(CellType.STRING);
|
|
|
|
+// String value = row.getCell(j).getStringCellValue()
|
|
|
|
+// .replaceAll(" ", "")
|
|
|
|
+// .replaceAll(",", "")
|
|
|
|
+// .replaceAll("\\u00A0", "")
|
|
|
|
+// .replaceAll((char) 12288 + "", "")
|
|
|
|
+// .replace("+", "·");
|
|
|
|
+//
|
|
|
|
+// // 校验value
|
|
|
|
+// if (StringUtil.isEmpty(value)) {
|
|
|
|
+// ErrorInfoVo errorInfoVo = new ErrorInfoVo();
|
|
|
|
+// errorInfoVo.setRowNum(rNum);
|
|
|
|
+// errorInfoVo.setColumnNum(columnNum);
|
|
|
|
+// errorInfoVo.setColumnName(columnName);
|
|
|
|
+// errorInfoVo.setContent(value);
|
|
|
|
+// errorInfoVo.setReason("数据为空");
|
|
|
|
+// errorList.add(errorInfoVo);
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if (j == 0) {
|
|
|
|
+// userDTO.setRealname(value);
|
|
|
|
+// } else if (j == 1) {
|
|
|
|
+// // 记录错误说明
|
|
|
|
+// String errorInfo = null;
|
|
|
|
+// // 正则校验手机号
|
|
|
|
+// if (ValidateUtils.validPhoneNum("0", value)) {
|
|
|
|
+// // 判断同一个dept下用户是否重复
|
|
|
|
+// SysUser query = new SysUser();
|
|
|
|
+// query.setUsername(value);
|
|
|
|
+// query.setDeptId(userDTO.getDeptId());
|
|
|
|
+// SysUser sysUser = sysUserMapper.selectUserByName(query);
|
|
|
|
+// if (sysUser != null) {
|
|
|
|
+// errorInfo = "手机号已被占用";
|
|
|
|
+// }
|
|
|
|
+// } else {
|
|
|
|
+// errorInfo = "不是手机号";
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// // 封装错误信息
|
|
|
|
+// if (StringUtils.isNotEmpty(errorInfo)) {
|
|
|
|
+// ErrorInfoVo errorInfoVo = new ErrorInfoVo();
|
|
|
|
+// errorInfoVo.setRowNum(rNum);
|
|
|
|
+// errorInfoVo.setColumnNum(columnNum);
|
|
|
|
+// errorInfoVo.setColumnName(columnName);
|
|
|
|
+// errorInfoVo.setContent(value);
|
|
|
|
+// errorInfoVo.setReason(errorInfo);
|
|
|
|
+// errorList.add(errorInfoVo);
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// userDTO.setPlatId(value);
|
|
|
|
+// userDTO.setPhone(value);
|
|
|
|
+// userDTO.setUsername(value);
|
|
|
|
+// } else if (j == 2) {
|
|
|
|
+// if ("全国".equals(value)) {
|
|
|
|
+// userDTO.setProvince("");
|
|
|
|
+// } else {
|
|
|
|
+// userDTO.setProvince(value);
|
|
|
|
+// }
|
|
|
|
+// } else if (j == 3) {
|
|
|
|
+// if (StringUtils.isEmpty(userDTO.getProvince())) {
|
|
|
|
+// userDTO.setCity("");
|
|
|
|
+// } else {
|
|
|
|
+// userDTO.setCity(value);
|
|
|
|
+// }
|
|
|
|
+// } else if (j == 4) {
|
|
|
|
+// // 声明错误信息记录
|
|
|
|
+// String errorInfo = "";
|
|
|
|
+//
|
|
|
|
+// // 根据角色名称获取角色
|
|
|
|
+// SysRole sysRole = sysRoleMapper.selectOne(Wrappers.<SysRole>query().eq("role_name", value));
|
|
|
|
+// if (sysRole != null) {
|
|
|
|
+// userDTO.setRole(Arrays.asList(sysRole.getRoleId()));
|
|
|
|
+// if (userDTO.getRole().contains(2)) {
|
|
|
|
+// UserDTO tmp = new UserDTO();
|
|
|
|
+// tmp.setUsername(userDTO.getUsername());
|
|
|
|
+// tmp.setDelFlag("0");
|
|
|
|
+// List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
|
|
+// if (userVoList.size() > 0) {
|
|
|
|
+// for (UserVO userVO : userVoList) {
|
|
|
|
+// if (null != userVO.getRoleList()) {
|
|
|
|
+// for (SysRole r : userVO.getRoleList()) {
|
|
|
|
+// if (r.getRoleId() == 3) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为药企管理员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (r.getRoleId() == 4) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为CSO管理员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (r.getRoleId() == 5) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为全职学术推广员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (r.getRoleId() == 6) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为兼职学术推广员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (r.getRoleId() == 7) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为财务管理员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// } else if (userDTO.getRole().contains(3)) {
|
|
|
|
+// UserDTO tmp = new UserDTO();
|
|
|
|
+// tmp.setUsername(userDTO.getUsername());
|
|
|
|
+// tmp.setDelFlag("0");
|
|
|
|
+// List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
|
|
+// if (userVoList.size() > 0) {
|
|
|
|
+// for (UserVO userVO : userVoList) {
|
|
|
|
+// if (null != userVO.getRoleList()) {
|
|
|
|
+// for (SysRole r : userVO.getRoleList()) {
|
|
|
|
+// if (r.getRoleId() == 2) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在药企管理员角色,不能同时为平台管理员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (r.getRoleId() == 4) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在药企管理员角色,不能同时为CSO管理员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
|
+// if (r.getRoleId() == 5) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在CSO关系角色,不能同时为药企管理员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// } else if (userDTO.getRole().contains(4)) {
|
|
|
|
+// UserDTO tmp = new UserDTO();
|
|
|
|
+// tmp.setUsername(userDTO.getUsername());
|
|
|
|
+// tmp.setDelFlag("0");
|
|
|
|
+// List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
|
|
+// if (userVoList.size() > 0) {
|
|
|
|
+// for (UserVO userVO : userVoList) {
|
|
|
|
+// if (null != userVO.getRoleList()) {
|
|
|
|
+// for (SysRole r : userVO.getRoleList()) {
|
|
|
|
+// if (sysRole.getRoleId() == 2) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if (r.getRoleId() == 3) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在药企管理员角色,不能同时为CSO管理员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (r.getRoleId() == 5) {
|
|
|
|
+// SysUserRole sysUserRole = new SysUserRole();
|
|
|
|
+// sysUserRole.setUserId(userVO.getUserId());
|
|
|
|
+// List<SysUserRole> sysUserRoleList = sysUserRoleMapper.selectById(sysUserRole);
|
|
|
|
+// for (int k = 0; k < sysUserRoleList.size(); k++) {
|
|
|
|
+// SysUser sysUser = userService.getById(sysUserRoleList.get(k).getUserId());
|
|
|
|
+// if (!sysUser.getDeptId().equals(userDTO.getDeptId())) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在全职学术推广员角色,不能为其他机构CSO管理员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// } else if (userDTO.getRole().contains(7)) {
|
|
|
|
+// UserDTO tmp = new UserDTO();
|
|
|
|
+// tmp.setUsername(userDTO.getUsername());
|
|
|
|
+// tmp.setDelFlag("0");
|
|
|
|
+// List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
|
|
+// if (userVoList.size() > 0) {
|
|
|
|
+// for (UserVO userVO : userVoList) {
|
|
|
|
+// if (null != userVO.getRoleList()) {
|
|
|
|
+// for (SysRole r : userVO.getRoleList()) {
|
|
|
|
+// if (r.getRoleId() == 2) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在平台管理员,不能同时为财务管理员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
|
+// if (r.getRoleId() == 3) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在药企管理员,不能同时为CSO机构财务管理员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// } else if (userDTO.getRole().contains(5)) {
|
|
|
|
+// UserDTO tmp = new UserDTO();
|
|
|
|
+// tmp.setUsername(userDTO.getUsername());
|
|
|
|
+// tmp.setDelFlag("0");
|
|
|
|
+// List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
|
|
+// if (userVoList.size() > 0) {
|
|
|
|
+// for (UserVO userVO : userVoList) {
|
|
|
|
+// if (null != userVO.getRoleList()) {
|
|
|
|
+// for (SysRole r : userVO.getRoleList()) {
|
|
|
|
+// if (r.getRoleId() == 2) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在平台管理员,不能同时为全职学术推广员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (r.getRoleId() == 3) {
|
|
|
|
+// if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在药企管理员,不能为CSO的全职学术推广员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// if (r.getRoleId() == 4) {
|
|
|
|
+// if (sysDept.getLevel() == 3 || sysDept.getLevel() == 4) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在CSO管理员,不能为其他CSO的全职学术推广员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// } else if (userDTO.getRole().contains(6)) {
|
|
|
|
+// UserDTO tmp = new UserDTO();
|
|
|
|
+// tmp.setUsername(userDTO.getUsername());
|
|
|
|
+// tmp.setDelFlag("0");
|
|
|
|
+// List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
|
|
+// if (userVoList.size() > 0) {
|
|
|
|
+// for (UserVO userVO : userVoList) {
|
|
|
|
+// if (null != userVO.getRoleList()) {
|
|
|
|
+// for (SysRole r : userVO.getRoleList()) {
|
|
|
|
+// if (r.getRoleId() == 2) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在平台管理员,不能同时为兼职学术推广员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// SysUserRole sysUserRole = new SysUserRole();
|
|
|
|
+// sysUserRole.setUserId(userVO.getUserId());
|
|
|
|
+// List<SysUserRole> sysUserRoleList = sysUserRoleMapper.selectById(sysUserRole);
|
|
|
|
+// for (int k = 0; k < sysUserRoleList.size(); k++) {
|
|
|
|
+// if (sysUserRoleList.get(k).getRoleId().equals(7)) {
|
|
|
|
+// SysUser sysUser = userService.getById(sysUserRoleList.get(k).getUserId());
|
|
|
|
+// if (sysUser.getDeptId().equals(userDTO.getDeptId())) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在财务管理员角色,不能同时为兼职学术推广员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// } else if (userDTO.getRole().contains(9)) {
|
|
|
|
+// UserDTO tmp = new UserDTO();
|
|
|
|
+// tmp.setUsername(userDTO.getUsername());
|
|
|
|
+// tmp.setDelFlag("0");
|
|
|
|
+// List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
|
|
+// if (userVoList.size() > 0) {
|
|
|
|
+// for (UserVO userVO : userVoList) {
|
|
|
|
+// if (null != userVO.getRoleList()) {
|
|
|
|
+// for (SysRole r : userVO.getRoleList()) {
|
|
|
|
+// if (sysRole.getRoleId() == 2) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在平台管理员,不能同时为CRO管理员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (r.getRoleId() == 3) {
|
|
|
|
+// errorInfo = errorInfo + "用户已存在药企管理员,不能同时为CRO管理员!";
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// if (userDTO.getRole().contains(3)) {
|
|
|
|
+// if (sysDept.getLevel() != 2) {
|
|
|
|
+// errorInfo = errorInfo + "角色选为药企管理员时,组织架构必须为药企!";
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// if (!userDTO.getDeptId().equals(SecurityUtils.getUser().getDeptId())) {
|
|
|
|
+// if (userDTO.getRole().contains(5) || userDTO.getRole().contains(6)) {
|
|
|
|
+// errorInfo = errorInfo + "不能跨机构维护学术推广员!";
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// // 存在错误
|
|
|
|
+// if (StringUtils.isNotEmpty(errorInfo) || sysRole == null) {
|
|
|
|
+// ErrorInfoVo errorInfoVo = new ErrorInfoVo();
|
|
|
|
+// errorInfoVo.setRowNum(rNum);
|
|
|
|
+// errorInfoVo.setColumnNum(columnNum);
|
|
|
|
+// errorInfoVo.setColumnName(columnName);
|
|
|
|
+// errorInfoVo.setContent(errorInfo);
|
|
|
|
+// errorInfoVo.setReason("角色信息有误");
|
|
|
|
+// errorList.add(errorInfoVo);
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// } else if (j == 5) {
|
|
|
|
+// if (!"活跃".equals(value) && !"休眠".equals(value)) {
|
|
|
|
+// ErrorInfoVo errorInfoVo = new ErrorInfoVo();
|
|
|
|
+// errorInfoVo.setRowNum(rNum);
|
|
|
|
+// errorInfoVo.setColumnNum(columnNum);
|
|
|
|
+// errorInfoVo.setColumnName(columnName);
|
|
|
|
+// errorInfoVo.setContent(value);
|
|
|
|
+// errorInfoVo.setReason("角色状态有误");
|
|
|
|
+// errorList.add(errorInfoVo);
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// userDTO.setLockFlag("活跃".equals(value) ? "0" : "9");
|
|
|
|
+// } else if (j == 6) {
|
|
|
|
+// userDTO.setProvinceCode(value);
|
|
|
|
+// } else if (j == 7) {
|
|
|
|
+// userDTO.setCityCode(value);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// // 记录争取额的信息
|
|
|
|
+// userDTOList.add(userDTO);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// // 判断是否有错误的数据行,如果没有,执行入库操作
|
|
|
|
+// if (CollectionUtils.isEmpty(errorList)) {
|
|
|
|
+// userDTOList.forEach(userDTO -> {
|
|
|
|
+// userService.saveUser(userDTO);
|
|
|
|
+// });
|
|
|
|
+// }
|
|
|
|
+// return R.ok(errorList);
|
|
|
|
+//
|
|
|
|
+// } catch (Exception e) {
|
|
|
|
+// log.error("批量创建用户失败:{}",e.getMessage());
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// return R.failed("批量创建用户失败");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 更新用户信息
|
|
* 更新用户信息
|
|
*
|
|
*
|