Kaynağa Gözat

Merge branch 'refs/heads/cnbg-master-77' into cnbg-master

shc 11 ay önce
ebeveyn
işleme
064de53c34

+ 53 - 29
hnqz-auth/src/main/java/com/qunzhixinxi/hnqz/auth/handler/HnqzAuthenticationFailureEventHandler.java

@@ -1,4 +1,3 @@
-
 package com.qunzhixinxi.hnqz.auth.handler;
 
 import com.qunzhixinxi.hnqz.admin.api.entity.SysLog;
@@ -11,6 +10,7 @@ import com.qunzhixinxi.hnqz.common.security.handler.AuthenticationFailureHandler
 import lombok.AllArgsConstructor;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.http.HttpHeaders;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.security.core.Authentication;
@@ -19,6 +19,7 @@ import org.springframework.stereotype.Component;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.util.concurrent.TimeUnit;
 
 /**
  * @author hnqz
@@ -29,33 +30,56 @@ import javax.servlet.http.HttpServletResponse;
 @AllArgsConstructor
 public class HnqzAuthenticationFailureEventHandler implements AuthenticationFailureHandler {
 
-	private final RemoteLogService logService;
-
-	/**
-	 * 异步处理,登录失败方法
-	 * <p>
-	 * @param authenticationException 登录的authentication 对象
-	 * @param authentication 登录的authenticationException 对象
-	 * @param request 请求
-	 * @param response 响应
-	 */
-	@Async
-	@Override
-	@SneakyThrows
-	public void handle(AuthenticationException authenticationException, Authentication authentication,
-			HttpServletRequest request, HttpServletResponse response) {
-		String username = authentication.getName();
-		SysLog sysLog = SysLogUtils.getSysLog(request, username);
-		sysLog.setTitle(username + "用户登录");
-		sysLog.setType(CommonConstants.STATUS_LOCK);
-		sysLog.setParams(username);
-		sysLog.setException(authenticationException.getLocalizedMessage());
-		String header = request.getHeader(HttpHeaders.AUTHORIZATION);
-		sysLog.setServiceId(WebUtils.extractClientId(header).orElse("N/A"));
-
-		logService.saveLog(sysLog, SecurityConstants.FROM_IN);
-
-		log.info("用户:{} 登录失败,异常:{}", username, authenticationException.getLocalizedMessage());
-	}
+    private final RemoteLogService logService;
+    private final RedisTemplate<String, Object> redisTemplate;
+
+    /**
+     * 异步处理,登录失败方法
+     * <p>
+     *
+     * @param authenticationException 登录的authentication 对象
+     * @param authentication          登录的authenticationException 对象
+     * @param request                 请求
+     * @param response                响应
+     */
+    @Async
+    @Override
+    @SneakyThrows
+    public void handle(AuthenticationException authenticationException, Authentication authentication,
+                       HttpServletRequest request, HttpServletResponse response) {
+        String username = authentication.getName();
+        SysLog sysLog = SysLogUtils.getSysLog(request, username);
+        sysLog.setTitle(username + "用户登录");
+        sysLog.setType(CommonConstants.STATUS_LOCK);
+        sysLog.setParams(username);
+        sysLog.setException(authenticationException.getLocalizedMessage());
+        String header = request.getHeader(HttpHeaders.AUTHORIZATION);
+        sysLog.setServiceId(WebUtils.extractClientId(header).orElse("N/A"));
+
+        logService.saveLog(sysLog, SecurityConstants.FROM_IN);
+
+        log.info("用户:{} 登录失败,异常:{}", username, authenticationException.getLocalizedMessage());
+
+        // 连续失败5次锁定10分钟
+
+        final String errorKey = "login:error:lock:" + username;
+        final String lockKey = "login:error:limit:times:" + username;
+
+        if (Boolean.TRUE.equals(redisTemplate.hasKey(lockKey))) {
+            Object o = redisTemplate.opsForValue().get(lockKey);
+            int limit = Integer.parseInt(o.toString());
+
+            if (limit >= 5) {
+                redisTemplate.opsForValue().set(errorKey, username, 10, TimeUnit.MINUTES);
+            } else {
+                redisTemplate.opsForValue().set(lockKey, limit + 1);
+            }
+
+
+        } else {
+            redisTemplate.opsForValue().set(lockKey, 1);
+        }
+
+    }
 
 }

+ 8 - 5
hnqz-auth/src/main/java/com/qunzhixinxi/hnqz/auth/handler/HnqzAuthenticationSuccessEventHandler.java

@@ -1,4 +1,3 @@
-
 package com.qunzhixinxi.hnqz.auth.handler;
 
 import com.qunzhixinxi.hnqz.admin.api.entity.SysLog;
@@ -9,6 +8,7 @@ import com.qunzhixinxi.hnqz.common.log.util.SysLogUtils;
 import com.qunzhixinxi.hnqz.common.security.handler.AuthenticationSuccessHandler;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.http.HttpHeaders;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.security.core.Authentication;
@@ -17,16 +17,13 @@ import org.springframework.stereotype.Component;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-/**
- * @author hnqz
- * @date 2018/10/8
- */
 @Slf4j
 @Component
 @AllArgsConstructor
 public class HnqzAuthenticationSuccessEventHandler implements AuthenticationSuccessHandler {
 
 	private final RemoteLogService logService;
+	private final RedisTemplate<String, Object> redisTemplate;
 
 	/**
 	 * 处理登录成功方法
@@ -48,6 +45,12 @@ public class HnqzAuthenticationSuccessEventHandler implements AuthenticationSucc
 
 		logService.saveLog(sysLog, SecurityConstants.FROM_IN);
 		log.info("用户:{} 登录成功", username);
+
+		// 登陆成功后删除错误次数
+		final String lockKey = "login:error:limit:times:" + username;
+
+		redisTemplate.delete(lockKey);
+
 	}
 
 }

+ 14 - 6
hnqz-auth/src/main/java/com/qunzhixinxi/hnqz/auth/service/HnqzUserDetailsServiceImpl.java

@@ -16,12 +16,14 @@ import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.cache.Cache;
 import org.springframework.cache.CacheManager;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.authority.AuthorityUtils;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UsernameNotFoundException;
 import org.springframework.stereotype.Service;
 
+import javax.security.auth.login.AccountLockedException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
@@ -41,6 +43,7 @@ public class HnqzUserDetailsServiceImpl implements HnqzUserDetailsService {
 
     private final CacheManager cacheManager;
 
+
     /**
      * 用户密码登录
      *
@@ -64,14 +67,15 @@ public class HnqzUserDetailsServiceImpl implements HnqzUserDetailsService {
         }
 
 
-        Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS);
-        if (cache != null && cache.get(rawUsername) != null) {
-            return (HnqzUser) cache.get(rawUsername).get();
-        }
+
+        // Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS);
+        // if (cache != null && cache.get(rawUsername) != null) {
+        //     return (HnqzUser) cache.get(rawUsername).get();
+        // }
 
         R<UserInfo> result = remoteUserService.info1(rawUsername, isApp, SecurityConstants.FROM_IN);
         UserDetails userDetails = getUserDetails(result);
-        cache.put(username, userDetails);
+        // cache.put(username, userDetails);
         return userDetails;
     }
 
@@ -114,6 +118,10 @@ public class HnqzUserDetailsServiceImpl implements HnqzUserDetailsService {
         boolean enabled = StrUtil.equals(user.getLockFlag(), CommonConstants.STATUS_NORMAL);
         // 构造security用户
 
+        if (!CommonConstants.STATUS_NORMAL.equals(user.getLockFlag())){
+            throw new RuntimeException("当前账号已经锁定了");
+        }
+
         return new HnqzUser(user.getUserId(),
                 user.getDeptId(),
                 user.getPhone(),
@@ -124,7 +132,7 @@ public class HnqzUserDetailsServiceImpl implements HnqzUserDetailsService {
                 enabled,
                 true,
                 true,
-                !CommonConstants.STATUS_LOCK.equals(user.getLockFlag()),
+                CommonConstants.STATUS_NORMAL.equals(user.getLockFlag()),
                 authorities,
                 user.getPlatId(),
                 user.getDrugEntId(),

+ 71 - 71
hnqz-common/hnqz-common-core/src/main/java/com/qunzhixinxi/hnqz/common/core/constant/CacheConstants.java

@@ -8,76 +8,76 @@ package com.qunzhixinxi.hnqz.common.core.constant;
  */
 public interface CacheConstants {
 
-	/**
-	 * 全局缓存,在缓存名称上加上该前缀表示该缓存不区分租户,比如:
-	 * <p/>
-	 * {@code @Cacheable(value = CacheConstants.GLOBALLY+CacheConstants.MENU_DETAILS, key = "#roleId  + '_menu'", unless = "#result == null")}
-	 */
-	String GLOBALLY = "gl:";
-
-	/**
-	 * 验证码前缀
-	 */
-	String DEFAULT_CODE_KEY = "DEFAULT_CODE_KEY:";
-
-	/**
-	 * 菜单信息缓存
-	 */
-	String MENU_DETAILS = "menu_details";
-
-	/**
-	 * 用户信息缓存
-	 */
-	String USER_DETAILS = "user_details";
-
-	/**
-	 * 字典信息缓存
-	 */
-	String DICT_DETAILS = "dict_details";
-
-	/**
-	 * oauth 客户端信息
-	 */
-	String CLIENT_DETAILS_KEY = "hnqz_oauth:client:details";
-
-	/**
-	 * spring boot admin 事件key
-	 */
-	String EVENT_KEY = "event_key";
-
-	/**
-	 * 路由存放
-	 */
-	String ROUTE_KEY = "gateway_route_key";
-
-	/**
-	 * redis reload 事件
-	 */
-	String ROUTE_REDIS_RELOAD_TOPIC = "gateway_redis_route_reload_topic";
-
-	/**
-	 * 内存reload 时间
-	 */
-	String ROUTE_JVM_RELOAD_TOPIC = "gateway_jvm_route_reload_topic";
-
-	/**
-	 * 公众号 reload
-	 */
-	String MP_REDIS_RELOAD_TOPIC = "mp_redis_reload_topic";
-
-	/**
-	 * 支付 reload 事件
-	 */
-	String PAY_REDIS_RELOAD_TOPIC = "pay_redis_reload_topic";
-
-	/**
-	 * 参数缓存
-	 */
-	String PARAMS_DETAILS = "params_details";
-
-	/**
-	 * 租户缓存 (不区分租户)
-	 */
-	String TENANT_DETAILS = GLOBALLY + "tenant_details";
+    /**
+     * 全局缓存,在缓存名称上加上该前缀表示该缓存不区分租户,比如:
+     * <p/>
+     * {@code @Cacheable(value = CacheConstants.GLOBALLY+CacheConstants.MENU_DETAILS, key = "#roleId  + '_menu'", unless = "#result == null")}
+     */
+    String GLOBALLY = "gl:";
+
+    /**
+     * 验证码前缀
+     */
+    String DEFAULT_CODE_KEY = "DEFAULT_CODE_KEY:";
+
+    /**
+     * 菜单信息缓存
+     */
+    String MENU_DETAILS = "menu_details";
+
+    /**
+     * 用户信息缓存
+     */
+    String USER_DETAILS = "user_details";
+
+    /**
+     * 字典信息缓存
+     */
+    String DICT_DETAILS = "dict_details";
+
+    /**
+     * oauth 客户端信息
+     */
+    String CLIENT_DETAILS_KEY = "hnqz_oauth:client:details";
+
+    /**
+     * spring boot admin 事件key
+     */
+    String EVENT_KEY = "event_key";
+
+    /**
+     * 路由存放
+     */
+    String ROUTE_KEY = "gateway_route_key";
+
+    /**
+     * redis reload 事件
+     */
+    String ROUTE_REDIS_RELOAD_TOPIC = "gateway_redis_route_reload_topic";
+
+    /**
+     * 内存reload 时间
+     */
+    String ROUTE_JVM_RELOAD_TOPIC = "gateway_jvm_route_reload_topic";
+
+    /**
+     * 公众号 reload
+     */
+    String MP_REDIS_RELOAD_TOPIC = "mp_redis_reload_topic";
+
+    /**
+     * 支付 reload 事件
+     */
+    String PAY_REDIS_RELOAD_TOPIC = "pay_redis_reload_topic";
+
+    /**
+     * 参数缓存
+     */
+    String PARAMS_DETAILS = "params_details";
+
+    /**
+     * 租户缓存 (不区分租户)
+     */
+    String TENANT_DETAILS = GLOBALLY + "tenant_details";
 
 }

+ 10 - 4
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/dto/CommonUserDTO.java

@@ -51,14 +51,20 @@ public class CommonUserDTO implements Serializable {
 	 */
 	private String lockFlag;
 
+
 	/**
-	 * 省份编码
+	 * 企业名称
 	 */
+	private String entName;
 
-	private String provinceCode;
+	/**
+	 * 身份证号
+	 */
+	private String idCard;
 
 	/**
-	 * 城市编码
+	 * 
 	 */
-	private String cityCode;
+	private String district;
+
 }

+ 48 - 44
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/model/excel/CommonUserExcelModel.java

@@ -14,61 +14,65 @@ import java.io.Serializable;
  */
 @Data
 public class CommonUserExcelModel implements Serializable {
-	private static final long serialVersionUID = -8680773572039025644L;
+    private static final long serialVersionUID = -8680773572039025644L;
 
-	/**
-	 * id
-	 */
-	@ExcelProperty(index = 0)
-	private String id;
+    /**
+     * id
+     */
+    @ExcelProperty(index = 0)
+    private String id;
 
-	/**
-	 * 用户真实姓名
-	 */
-	@ExcelProperty(index = 1)
-	private String realName;
+    /**
+     * 用户真实姓名
+     */
+    @ExcelProperty(index = 1)
+    private String realName;
 
-	/**
-	 * 用户名
-	 */
-	@ExcelProperty(index = 2)
-	private String username;
+    /**
+     * 企业名称
+     */
+    @ExcelProperty(index = 2)
+    private String entName;
 
-	/**
-	 * 省
-	 */
-	@ExcelProperty(index = 3)
-	private String province;
-
-	/**
-	 * 市
-	 */
-	@ExcelProperty(index = 4)
-	private String city;
+    /**
+     * 身份证号
+     */
+    @ExcelProperty(index = 3)
+    private String idCard;
 
+    /**
+     * 用户名/用户名
+     */
+    @ExcelProperty(index = 4)
+    private String username;
 
-	/**
-	 * 角色名称
-	 */
-	@ExcelProperty(index = 5)
-	private String roleName;
+    /**
+     * 省
+     */
+    @ExcelProperty(index = 5)
+    private String province;
 
-	/**
-	 * 锁定状态
-	 */
-	@ExcelProperty(index = 6)
-	private String lockFlag;
+    /**
+     * 市
+     */
+    @ExcelProperty(index = 6)
+    private String city;
 
 	/**
-	 * 省份编码
+	 * 
 	 */
 	@ExcelProperty(index = 7)
-	private String provinceCode;
+	private String district;
 
-	/**
-	 * 城市编码
-	 */
-	@ExcelProperty(index = 8)
-	private String cityCode;
+    /**
+     * 角色名称
+     */
+    @ExcelProperty(index = 8)
+    private String roleName;
 
+    /**
+     * 锁定状态
+     */
+    @ExcelProperty(index = 9)
+    private String lockFlag;
 }

+ 5 - 0
hnqz-upms/hnqz-upms-biz/pom.xml

@@ -167,6 +167,11 @@
 			<version>4.1.2</version>
 		</dependency>
 
+		<dependency>
+			<groupId>commons-io</groupId>
+			<artifactId>commons-io</artifactId>
+			<version>2.16.1</version>
+		</dependency>
 
 		<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
 		<dependency>

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

@@ -257,21 +257,26 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 
         String errorInfo = null;
 
-        if (StringUtils.isEmpty(roleName)) {
+        if (StringUtils.isEmpty(roleName) || dept == null) {
             errorInfo = "角色名称为空";
         } else {
+
+
+            List<String> roleNames = roleName.contains(StrUtil.SLASH) ? StrUtil.split(roleName, StrUtil.SLASH) : Collections.singletonList(roleName);
+
             // 根据角色名称获取角色
-            SysRole sysRole = sysRoleService.getOne(Wrappers.<SysRole>lambdaQuery()
-                    .eq(SysRole::getRoleName, roleName)
-                    .eq(SysRole::getDelFlag, DelEnum.NOT_DEL.getVal()));
-            if (sysRole == null) {
+            List<Integer> sysRole = sysRoleService.list(Wrappers.<SysRole>lambdaQuery()
+                    .in(SysRole::getRoleName, roleNames)
+                    .eq(SysRole::getDelFlag, DelEnum.NOT_DEL.getVal())).stream().mapToInt(SysRole::getRoleId).boxed().distinct().collect(Collectors.toList());
+
+            if (CollUtil.isEmpty(sysRole)) {
                 errorInfo = "角色不存在或者未启用";
             } else {
-                userDTO.setRole(Collections.singletonList(sysRole.getRoleId()));
+                userDTO.setRole(sysRole);
                 if (userDTO.getRole().contains(2)) {
                     UserDTO tmp = new UserDTO();
                     tmp.setUsername(userDTO.getUsername());
-                    tmp.setDelFlag("0");
+                    userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
                     List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
                     if (CollUtil.isNotEmpty(userVoList)) {
                         for (UserVO userVO : userVoList) {
@@ -296,6 +301,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                                     if (r.getRoleId() == 7) {
                                         errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为财务管理员!";
                                     }
+                                    if (r.getRoleId() == 31) {
+                                        errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为招商经理";
+                                    }
                                 }
                             }
                         }
@@ -304,7 +312,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 } else if (userDTO.getRole().contains(3)) {
                     UserDTO tmp = new UserDTO();
                     tmp.setUsername(userDTO.getUsername());
-                    tmp.setDelFlag("0");
+                    userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
                     List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
                     if (CollUtil.isNotEmpty(userVoList)) {
                         for (UserVO userVO : userVoList) {
@@ -328,16 +336,16 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                         }
                     }
 
-                } else if (userDTO.getRole().contains(4)) {
+                } else if (userDTO.getRole().contains(4) || userDTO.getRole().contains(37)) {
                     UserDTO tmp = new UserDTO();
                     tmp.setUsername(userDTO.getUsername());
-                    tmp.setDelFlag("0");
+                    userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
                     List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
                     if (CollUtil.isNotEmpty(userVoList)) {
                         for (UserVO userVO : userVoList) {
                             if (null != userVO.getRoleList()) {
                                 for (SysRole r : userVO.getRoleList()) {
-                                    if (sysRole.getRoleId() == 2) {
+                                    if (r.getRoleId() == 2) {
                                         errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为!";
                                         continue;
                                     }
@@ -357,6 +365,17 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                                             }
                                         }
                                     }
+                                    if (r.getRoleId() == 31) {
+                                        SysUserRole sysUserRole = new SysUserRole();
+                                        sysUserRole.setUserId(userVO.getUserId());
+                                        List<SysUserRole> sysUserRoleList = sysUserRoleMapper.selectById(sysUserRole);
+                                        for (SysUserRole userRole : sysUserRoleList) {
+                                            SysUser sysUser = getById(userRole.getUserId());
+                                            if (!sysUser.getDeptId().equals(userDTO.getDeptId())) {
+                                                errorInfo = errorInfo + "用户已存在招商经理角色,不能为其他机构CSO管理员";
+                                            }
+                                        }
+                                    }
                                 }
                             }
                         }
@@ -453,7 +472,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                         for (UserVO userVO : userVoList) {
                             if (null != userVO.getRoleList()) {
                                 for (SysRole r : userVO.getRoleList()) {
-                                    if (sysRole.getRoleId() == 2) {
+                                    if (r.getRoleId() == 2) {
                                         errorInfo = errorInfo + "用户已存在平台管理员,不能同时为CRO管理员!";
                                         continue;
                                     }
@@ -485,8 +504,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
      * @param errorMap          错误信息记录map
      * @param currentList       正确结果收集信息
      */
-    private void checkoutCommonUserDTOInfo(List<CommonUserDTO> commonUserDTOList, HnqzUser
-            creator, Map<String, String> errorMap, List<UserDTO> currentList) {
+    private void checkoutCommonUserDTOInfo(List<CommonUserDTO> commonUserDTOList, HnqzUser creator, Map<String, String> errorMap, List<UserDTO> currentList) {
 
         // 行编号
         log.info("开始校验数据:{}", commonUserDTOList);
@@ -510,6 +528,37 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
             userDTO.setRealname(realName);
         }
 
+        // 校验用户所属企业
+        List<SysDept> list = sysDeptService.list(Wrappers.<SysDept>lambdaQuery().like(SysDept::getName, StrUtil.cleanBlank(commonUserDTO.getEntName())));
+        SysDept dept = null;
+        if (CollUtil.isEmpty(list)) {
+            log.error("所属企业不存在");
+            errorMap(errorMap, "所属企业不存在", commonUserDTO.getId());
+        } else {
+            dept = list.get(0);
+            userDTO.setDeptId(dept.getDeptId());
+        }
+
+        // 校验身份证号
+        String idCard = StrUtil.cleanBlank(commonUserDTO.getIdCard());
+        if (StrUtil.isBlank(idCard)) {
+            log.error("身份证号不存在");
+            errorMap(errorMap, "身份证号不存在", commonUserDTO.getId());
+        } else {
+            if (!Validator.isCitizenId(idCard)) {
+                log.error("身份证号格式不正确");
+                errorMap(errorMap, "身份证号格式不正确", commonUserDTO.getId());
+            }
+
+            int count = this.count(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getIdCardNumber, commonUserDTO.getId()));
+            if (count != 0) {
+                log.error("身份证号格式已经被占用");
+                errorMap(errorMap, "身份证号格式已经被占用", commonUserDTO.getId());
+            }
+
+            userDTO.setIdCardNumber(idCard);
+        }
+
         // 校验手机号
         String username = StrUtil.cleanBlank(commonUserDTO.getUsername());
         if (StringUtils.isEmpty(username)) {
@@ -524,9 +573,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
             }
 
             // 校验部门下是否有启用的用户
-            int count = count(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, username)
-                    .eq(SysUser::getDeptId, creator.getDeptId())
-                    .eq(SysUser::getLockFlag, LockEnum.UN_LOCK.getVal()).eq(SysUser::getDelFlag, DelEnum.NOT_DEL.getVal()));
+            int count = count(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, username));
+                    // .eq(dept != null, SysUser::getDeptId, dept.getDeptId()));
             if (count != 0) {
                 log.info("手机号被占用");
                 errorMap(errorMap, "手机号被占用", commonUserDTO.getId());
@@ -538,7 +586,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         }
 
         // 校验用户角色
-        SysDept dept = sysDeptService.getById(creator.getDeptId());
         String roleName = StrUtil.cleanBlank(commonUserDTO.getRoleName());
         String errInfo = checkoutCommonUserRole(roleName, userDTO, dept);
         if (StringUtils.isNotEmpty(errInfo)) {
@@ -553,9 +600,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
             errorMap(errorMap, "用户状态为空", commonUserDTO.getId());
         } else {
             if (StringUtils.equals(lockFlag, "活跃")) {
-                userDTO.setLockFlag("0");
+                userDTO.setLockFlag(CommonConstants.STATUS_NORMAL);
             } else if (StringUtils.equals(lockFlag, "休眠")) {
-                userDTO.setLockFlag("9");
+                userDTO.setLockFlag(CommonConstants.STATUS_LOCK);
             } else {
                 log.error("用户状态为值不是\"活跃\"或者\"休眠\"");
                 errorMap(errorMap, "用户状态为值不是\"活跃\"或者\"休眠\"", commonUserDTO.getId());
@@ -564,7 +611,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 
         // 记录正确的结果
         userDTO.setCreateTime(LocalDateTime.now());
-        userDTO.setDeptId(dept.getDeptId());
+        userDTO.setUpdateTime(LocalDateTime.now());
         currentList.add(userDTO);
 
     }
@@ -630,6 +677,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
      */
     @Override
     public UserInfo findUserInfo(SysUser sysUser) {
+
+        final String errorKey = "login:error:lock:" + sysUser.getUsername();
+        if (Boolean.TRUE.equals(redisTemplate.hasKey(errorKey))) {
+            sysUser.setLockFlag(CommonConstants.STATUS_LOCK);
+        }
+
         UserInfo userInfo = new UserInfo();
         userInfo.setSysUser(sysUser);
         // 设置角色列表 (ID)

BIN
hnqz-upms/hnqz-upms-biz/src/main/resources/excel/batch_create_user_template.xlsx


+ 16 - 0
pom.xml

@@ -331,5 +331,21 @@
 				<profiles.report.port>3001</profiles.report.port>
 			</properties>
 		</profile>
+		<profile>
+			<id>remote</id>
+			<properties>
+				<!-- 环境标识,需要与配置文件的名称相对应 -->
+				<profiles.active>remote</profiles.active>
+				<nacos.username>nacos</nacos.username>
+				<nacos.password>nacos1</nacos.password>
+				<nacos.server-addr>nacos.freerr.cn:57260</nacos.server-addr>
+				<profiles.namespace>51f03f27-1bcc-4720-bfab-83cffa17807c</profiles.namespace>
+				<profiles.auth.port>3000</profiles.auth.port>
+				<profiles.gateway.port>9999</profiles.gateway.port>
+				<profiles.upms.biz.port>4000</profiles.upms.biz.port>
+				<profiles.quartz.port>5007</profiles.quartz.port>
+				<profiles.report.port>3001</profiles.report.port>
+			</properties>
+		</profile>
 	</profiles>
 </project>