feat: ossFile表和minio数据有效性检测接口

This commit is contained in:
2024-03-15 10:46:38 +08:00
parent 6bb0b1d056
commit 9677266fad
5 changed files with 57 additions and 9 deletions
@@ -113,8 +113,8 @@ public class LoginServiceImpl implements ILoginService {
//redisUtil.del(realKey);
try {
//解密获取密码和用户名
// password = CommonUtils.decryptBtRsaPriKey(password, rsaPrivateKey);
username = "admin";
password = CommonUtils.decryptBtRsaPriKey(password, rsaPrivateKey);
username = CommonUtils.decryptBtRsaPriKey(username, rsaPrivateKey);
} catch (Exception e) {
e.printStackTrace();
}
@@ -141,13 +141,13 @@ public class LoginServiceImpl implements ILoginService {
//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);
// }
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)) {
@@ -192,4 +192,12 @@ public class OldSystemController {
return Result.OK(oldSystemDeptRelationService.esAuthDeptDataFix());
}
@GetMapping("/dataFileFix")
@AutoLog(value = "老法规系统-上线后检测ossFile表中的数据和minio中的数据是否一致/找到minio中不存在的数据")
@ApiOperation(value="老法规系统-上线后检测ossFile表中的数据和minio中的数据是否一致/找到minio中不存在的数据", notes="老法规系统-上线后检测ossFile表中的数据和minio中的数据是否一致/找到minio中不存在的数据")
@ApiOperationSupport(order = 15)
public void dataFileFix(HttpServletResponse response) {
oldSystemService.dataFileFix(response);
}
}
@@ -176,6 +176,10 @@ public class OldSystemImportDTO {
@TableField(exist = false)
private String errorInfo;
@Excel(name = "OssFileID", width = 15, orderNum = "53")
@TableField(exist = false)
private String ossFileId;
/**
* 判断是否是空行
* @return 如果所有字段都为null或空字符串,返回true,否则返回false
@@ -113,4 +113,10 @@ public interface OldSystemService {
* @param response
*/
void importOldSystemFileFixDocPath(MultipartFile file, String type, HttpServletResponse response);
/**
* 上线后检测ossFile表中的数据和minio中的数据是否一致/找到minio中不存在的数据
* @param response
*/
void dataFileFix(HttpServletResponse response);
}
@@ -419,6 +419,36 @@ public class OldSystemServiceImpl implements OldSystemService {
}
}
@Override
public void dataFileFix(HttpServletResponse response) {
List<OldSystemImportDTO> errImportList = new ArrayList<>();
List<OSSFile> ossFileList = ossFileService.list();
for (OSSFile ossFile : ossFileList) {
String url = ossFile.getUrl();
if (StrUtil.isBlank(url)) {
OldSystemImportDTO dto = new OldSystemImportDTO();
dto.setBzh(ossFile.getStandardNo());
log.error("文件路径为空");
dto.setErrorInfo("文件路径为空");
dto.setOssFileId(ossFile.getId());
errImportList.add(dto);
continue;
}
if (!MinioUtil.doesObjectExist(url)) {
OldSystemImportDTO dto = new OldSystemImportDTO();
dto.setBzh(ossFile.getStandardNo());
log.error("文件不存在,路径是:" + url);
dto.setErrorInfo("文件不存在,路径是:" + url);
dto.setOssFileId(ossFile.getId());
errImportList.add(dto);
}
}
if (!errImportList.isEmpty()) {
this.exportWithExcel(response, errImportList, "OldSystemStandardErrorData.xls");
}
}
private void oldSysFBDataFileDocPath(List<OldSystemImportDTO> allDatalist, List<OldSystemImportDTO> errImportList) {
List<OldSystemImportDTO> fbDatalist = allDatalist.stream().filter(o -> o.getBzfl().contains("ISO") ||
o.getBzfl().contains("引进") ||