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();
|
||||
|
||||
@@ -377,6 +377,10 @@ export default {
|
||||
personName: [
|
||||
{ required: true, message: '请输入用户姓名', trigger: 'blur' },
|
||||
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: '请输入用户密码', trigger: 'blur' },
|
||||
{ pattern: /^(?=.*\d)(?=.*[A-z])[\da-zA-Z]{6,12}$/, message: '长度6位以上,数字+密码', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
syncDrawer: false,
|
||||
@@ -463,7 +467,7 @@ export default {
|
||||
},
|
||||
// 新增前将多选的值设置为空
|
||||
[CRUD.HOOK.beforeToAdd]() {
|
||||
this.form.password = '123456'
|
||||
// this.form.password = '123456'
|
||||
this.roleDatas = []
|
||||
},
|
||||
// 初始化编辑时候的角色与岗位
|
||||
@@ -626,10 +630,10 @@ export default {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
row.password = '123456'
|
||||
row.password = 'HL123456'
|
||||
crudUser.edit(row).then(res => {
|
||||
this.crud.toQuery()
|
||||
this.crud.notify('密码重置成功,密码:123456', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.crud.notify('密码重置成功,密码:HL123456', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user