rev:新增登录次数限制,密码正则表达式校验,发货区AGV任务生成添加开关
This commit is contained in:
@@ -37,6 +37,7 @@ import org.nl.system.service.user.dto.UserDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -44,6 +45,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
@@ -58,6 +60,8 @@ public class OnlineUserService {
|
||||
@Autowired
|
||||
private ISysRoleService roleService;
|
||||
private final RedisUtils redisUtils;
|
||||
@Autowired
|
||||
private RedisTemplate<Object, Object> redisTemplate;
|
||||
@Value("${sa-token.cookie.domain}")
|
||||
private String domain;
|
||||
|
||||
@@ -237,11 +241,53 @@ public class OnlineUserService {
|
||||
// if (StrUtil.isEmpty(authUser.getCode()) || !authUser.getCode().equalsIgnoreCase(code)) {
|
||||
// throw new BadRequestException("验证码错误");
|
||||
// }
|
||||
// 校验数据库
|
||||
// 根据用户名查询,在比对密码
|
||||
SysUser userInfo = sysUserService.getOne(new QueryWrapper<SysUser>().eq("username", authUser.getUsername()));
|
||||
if (userInfo == null || !userInfo.getPassword().equals(SaSecureUtil.md5BySalt(password, "salt"))) { // 这里需要密码加密
|
||||
throw new BadRequestException("账号或密码错误");
|
||||
|
||||
// 这里需要密码加密
|
||||
if (userInfo == null) {
|
||||
throw new BadRequestException("当前用户不存在!");
|
||||
}
|
||||
String userName = userInfo.getUsername();
|
||||
if (!userInfo.getPassword().equals(SaSecureUtil.md5BySalt(password, "salt"))) {
|
||||
Boolean aBoolean = redisTemplate.hasKey("LoginName:" + userName);
|
||||
if (aBoolean) {
|
||||
String errorLoginCount = redisTemplate.opsForValue().get("LoginName:" + userName).toString();
|
||||
Integer newerrorLoginCount = Integer.parseInt(errorLoginCount);
|
||||
//key为 LoginName: userName value是对应的错误登陆次数
|
||||
if (newerrorLoginCount.intValue() == 3) {
|
||||
Long expire = redisTemplate.opsForValue().getOperations().getExpire("LoginName:" + userName);
|
||||
if (expire.intValue() > 0) {
|
||||
throw new BadRequestException("当前用户锁定中,请" + expire / 60 + "分钟后重试");
|
||||
}
|
||||
} else {
|
||||
redisTemplate.opsForValue().set("LoginName:" + userName, newerrorLoginCount + 1);
|
||||
if (3 - newerrorLoginCount - 1 == 0) {
|
||||
redisTemplate.opsForValue().getOperations().expire("LoginName:" + userName, 300, TimeUnit.SECONDS);
|
||||
throw new BadRequestException("当前用户已锁定,请5分钟后重试");
|
||||
}
|
||||
throw new BadRequestException("密码错误,还有" + (3 - newerrorLoginCount - 1) + "次机会");
|
||||
}
|
||||
} else {
|
||||
redisTemplate.opsForValue().set("LoginName:" + userName, "1");
|
||||
throw new BadRequestException("密码错误,还有" + 2 + "次机会");
|
||||
}
|
||||
}
|
||||
{
|
||||
//密码正确,判断redis里面是否有值,有值就代表锁定中
|
||||
Boolean aBoolean = redisTemplate.hasKey("LoginName:" + userName);
|
||||
if (aBoolean) {
|
||||
String errorLoginCount = redisTemplate.opsForValue().get("LoginName:" + userName).toString();
|
||||
Integer newerrorLoginCount = Integer.parseInt(errorLoginCount);
|
||||
if (newerrorLoginCount.intValue() == 3) {
|
||||
Long expire = redisTemplate.opsForValue().getOperations().getExpire("LoginName:" + userName);
|
||||
if (expire.intValue() > 0) {
|
||||
throw new BadRequestException("当前用户锁定中,请" + expire / 60 + "分钟后重试");
|
||||
}
|
||||
} else {
|
||||
//直接删除key
|
||||
redisTemplate.delete("LoginName:" + userName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取权限列表 - 登录查找权限
|
||||
|
||||
@@ -468,6 +468,23 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
throw new BadRequestException("未查询到该木箱对应的包装关系!");
|
||||
}
|
||||
|
||||
//判断是否开启了系统参数生成AGV搬运任务
|
||||
String agv_transport = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("agv_transport").getValue();
|
||||
//如果未开启AGV搬运则不创建从1016到发货区的任务
|
||||
if (agv_transport.equals("0")){
|
||||
log.info("未开启AGV搬运系统参数,不生成AGV搬运["+vehicle_code+"]任务!");
|
||||
JSONArray sub_rows2 = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '" + vehicle_code + "'").getResultJSONArray(0);
|
||||
for (int i = 0; i < sub_rows2.size(); i++) {
|
||||
JSONObject sub_row = sub_rows2.getJSONObject(i);
|
||||
if (StrUtil.isNotEmpty(sub_row.getString("need_delete")) && "1".equals(sub_row.getString("need_delete"))) {
|
||||
WQLObject.getWQLObject("pdm_bi_subpackagerelation").delete(sub_row);
|
||||
}
|
||||
}
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "下发成功!");
|
||||
return result;
|
||||
}
|
||||
|
||||
// 校验木箱长度类型
|
||||
double box_length = sub_jo.getDoubleValue("box_length");
|
||||
String length_down_1 = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("box_length_down_1").getValue();
|
||||
|
||||
Reference in New Issue
Block a user