fix: 89026 法规符合性排查流程(法规工程师发起) --车型项目上传数据错误,提示语不明确

This commit is contained in:
2024-08-20 09:50:01 +08:00
parent 20bceefa06
commit 66ea671702
3 changed files with 69 additions and 26 deletions
@@ -1,6 +1,7 @@
package com.jero.modules.system.service.impl;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.asymmetric.RSA;
import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.exceptions.ClientException;
@@ -94,22 +95,22 @@ public class LoginServiceImpl implements ILoginService {
String rsaPublicKey = sysLoginModel.getRsaPublicKey();
String rsaPrivateKey = redisUtil.get(rsaPublicKey) != null ? String.valueOf(redisUtil.get(rsaPublicKey)) : null;
// if(StrUtil.isEmpty(rsaPrivateKey)){
// return Result.error(CommonConstant.SC_RSA_TIMEOUT_600, "页面过期,将刷新页面");
// }
//
// String captcha = sysLoginModel.getCaptcha();
// if(StringUtils.isBlank(captcha)){
// return Result.error("验证码无效");
// }
// String lowerCaseCaptcha = captcha.toLowerCase();
// String realKey = MD5Util.MD5Encode(lowerCaseCaptcha + sysLoginModel.getCheckKey(), UTF_8);
// Object checkCode = redisUtil.get(realKey);
// // 验证码前后端比较
// if(checkCode == null || !checkCode.toString().equals(lowerCaseCaptcha)) {
// return Result.error("验证码错误");
// }
// redisUtil.del(realKey);
if(StrUtil.isEmpty(rsaPrivateKey)){
return Result.error(CommonConstant.SC_RSA_TIMEOUT_600, "页面过期,将刷新页面");
}
String captcha = sysLoginModel.getCaptcha();
if(StringUtils.isBlank(captcha)){
return Result.error("验证码无效");
}
String lowerCaseCaptcha = captcha.toLowerCase();
String realKey = MD5Util.MD5Encode(lowerCaseCaptcha + sysLoginModel.getCheckKey(), UTF_8);
Object checkCode = redisUtil.get(realKey);
// 验证码前后端比较
if(checkCode == null || !checkCode.toString().equals(lowerCaseCaptcha)) {
return Result.error("验证码错误");
}
redisUtil.del(realKey);
try {
//解密获取密码和用户名
password = CommonUtils.decryptBtRsaPriKey(password, rsaPrivateKey);
@@ -138,15 +139,15 @@ public class LoginServiceImpl implements ILoginService {
return Result.error("密码错误次数过多,请15分钟后重试");
}
//2. 校验用户名或密码是否正确
// String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
// String syspassword = sysUser.getPassword();
// if (!syspassword.equals(userpassword)) {
// // 重试登录次数加一
// retryCount++;
// this.setRetryInfoToRedis(username, retryCount);
// String msg = retryCount == RETRY_LOGIN_MAX_COUNT ? "密码错误次数过多,请稍后重试":"用户名或密码错误,剩余可登录次数:"+(RETRY_LOGIN_MAX_COUNT - retryCount);
// return Result.error(msg);
// }
String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
String syspassword = sysUser.getPassword();
if (!syspassword.equals(userpassword)) {
// 重试登录次数加一
retryCount++;
this.setRetryInfoToRedis(username, retryCount);
String msg = retryCount == RETRY_LOGIN_MAX_COUNT ? "密码错误次数过多,请稍后重试":"用户名或密码错误,剩余可登录次数:"+(RETRY_LOGIN_MAX_COUNT - retryCount);
return Result.error(msg);
}
//登录成功,清除错误登录次数
redisUtil.del(RETRY_LOGIN_PREFIX + username);
if (checkSysPermission(username)) {
@@ -789,8 +789,11 @@ public class ProcessStandardComplianceCheckServiceImpl extends ServiceImpl<Proce
private List<String> validationModelList(List<ModelExcelVO> list, List<SysDictItemCore> listDict) {
List<String> errorMsgs = new ArrayList<>();
Set<String> modelSet = new HashSet<>();
Map<String, List<Integer>> duplicateModels = new HashMap<>();
int i = 2;
Iterator<ModelExcelVO> iterator = list.iterator();
while (iterator.hasNext()) {
ModelExcelVO data = iterator.next();
if (ExcelUtils.isEmptyRow(data)) {
@@ -800,6 +803,7 @@ public class ProcessStandardComplianceCheckServiceImpl extends ServiceImpl<Proce
}
continue;
}
String model = data.getModel();
String modelState = data.getModelState();
StringBuilder errMsgHeader = new StringBuilder();
@@ -807,13 +811,40 @@ public class ProcessStandardComplianceCheckServiceImpl extends ServiceImpl<Proce
data.setSort(String.valueOf(i++));
errMsgHeader.append("").append(data.getSort()).append("");
// 检查重复的model
if (!modelSet.add(model)) {
duplicateModels.putIfAbsent(model, new ArrayList<>());
duplicateModels.get(model).add(Integer.parseInt(data.getSort()));
} else {
duplicateModels.putIfAbsent(model, new ArrayList<>());
duplicateModels.get(model).add(Integer.parseInt(data.getSort()));
}
// 检查所有数据字典校验的字段
errMsg.append(excelUtils.validModel(model));
errMsg.append(excelUtils.validModelState(modelState, listDict));
// 如果数据有问题,则将提示信息添加到 errorMsgs 中
if (errMsg.length() > 0) {
errorMsgs.add(errMsgHeader.append(errMsg).toString());
}
}
// 添加重复model的错误信息
for (Map.Entry<String, List<Integer>> entry : duplicateModels.entrySet()) {
if (entry.getValue().size() > 1) {
StringBuilder duplicateErrMsg = new StringBuilder("车型 '")
.append(entry.getKey())
.append("' 在以下行中重复: ");
for (int index : entry.getValue()) {
duplicateErrMsg.append(index).append("行, ");
}
// 移除最后一个多余的逗号和空格
duplicateErrMsg.setLength(duplicateErrMsg.length() - 2);
errorMsgs.add(duplicateErrMsg.toString());
}
}
return errorMsgs;
}
@@ -615,7 +615,7 @@ public class ExcelUtils {
public String validModelState(String value, List<SysDictItemCore> listDict) {
if (StrUtil.isBlank(value)) {
return "";
return "'车型状态'为空。";
}
// 检查排查结果
if (!excelUtils.validDict("model_status", value, null, null, true, listDict)) {
@@ -623,4 +623,15 @@ public class ExcelUtils {
}
return "";
}
public String validModel(String value) {
if (StrUtil.isBlank(value)) {
return "'车型'为空。";
}
// 判断是否超长
if (value.length() > 50) {
return "'车型'超过50字";
}
return "";
}
}