fix:编辑报告名称去掉时间戳/重名覆盖&提供校验文件重名方法
This commit is contained in:
@@ -425,6 +425,12 @@ public class DataFileController implements IDataFeignClient {
|
||||
return IDataFileService.uploadFiles(req);
|
||||
}
|
||||
|
||||
@PostMapping("/checkDuplicateFileName")
|
||||
@Operation(summary = "检查上传文件在同目录下是否已有重名", description = "检查上传文件在同目录下是否已有重名")
|
||||
public SdmResponse checkDuplicateFileName(@RequestBody UploadFilesReq req) {
|
||||
return IDataFileService.checkDuplicateFileName(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录用户下载历史
|
||||
*
|
||||
|
||||
@@ -111,6 +111,8 @@ public interface IDataFileService {
|
||||
*/
|
||||
SdmResponse uploadFiles(UploadFilesReq req);
|
||||
|
||||
SdmResponse checkDuplicateFileName(UploadFilesReq req);
|
||||
|
||||
|
||||
/**
|
||||
* 更新文件信息
|
||||
|
||||
@@ -2358,6 +2358,41 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse checkDuplicateFileName(UploadFilesReq req) {
|
||||
SdmResponse<FileMetadataInfo> dirResponse = resolveUploadDirectory(req);
|
||||
if (!dirResponse.isSuccess()) {
|
||||
return SdmResponse.failed(dirResponse.getMessage());
|
||||
}
|
||||
FileMetadataInfo dirMetadataInfo = dirResponse.getData();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(req.getSourceFiles())) {
|
||||
for (UploadFilesReq sourceFileReq : req.getSourceFiles()) {
|
||||
SdmResponse<?> existsResponse = checkFileObjectKey(sourceFileReq, dirMetadataInfo);
|
||||
if (!existsResponse.isSuccess()) {
|
||||
return SdmResponse.success(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SdmResponse<?> existsResponse = checkFileObjectKey(req, dirMetadataInfo);
|
||||
if (!existsResponse.isSuccess()) {
|
||||
return SdmResponse.success(true);
|
||||
}
|
||||
}
|
||||
return SdmResponse.success(false);
|
||||
}
|
||||
|
||||
private SdmResponse checkFileObjectKey(UploadFilesReq req, FileMetadataInfo dirMetadataInfo) {
|
||||
String originalName = resolveOriginalName(req);
|
||||
SdmResponse<String> versionedNameResponse = buildVersionedFileName(originalName);
|
||||
if (!versionedNameResponse.isSuccess()) {
|
||||
return versionedNameResponse;
|
||||
}
|
||||
String modifiedFileName = versionedNameResponse.getData();
|
||||
String fileMinioObjectKey = buildFileObjectKey(dirMetadataInfo, modifiedFileName);
|
||||
return ensureFileNotExists(fileMinioObjectKey);
|
||||
}
|
||||
|
||||
private SdmResponse<BatchAddFileInfoResp> handleBatchFileInfo(UploadFilesReq req, UploadFilesReq fileReq, FileMetadataInfo dirMetadataInfo) {
|
||||
String uploadFileId = fileReq.getUploadFileId();
|
||||
String originalName = fileReq.getFileName();
|
||||
|
||||
@@ -1500,6 +1500,11 @@ public class SystemFileIDataFileServiceImpl implements IDataFileService {
|
||||
return SdmResponse.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse checkDuplicateFileName(UploadFilesReq req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse downloadRecord(AddDownloadRecordReq req) {
|
||||
String jobNumber = ThreadLocalContext.getJobNumber();
|
||||
|
||||
@@ -2056,7 +2056,7 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
*/
|
||||
private String generateReportName(String taskName) {
|
||||
String prefix = StringUtils.isNotEmpty(taskName) ? taskName.replaceAll("\\s+", "") : "report";
|
||||
return prefix + "_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) + ".docx";
|
||||
return prefix + ".docx";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2196,6 +2196,7 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
filesReq.setIsConverSameNameFile(true);
|
||||
SdmResponse sdmResponse = uploadKeyResultFiles(filesReq);
|
||||
if (!sdmResponse.isSuccess()) {
|
||||
log.error("生成自动化报告上传任务报告结果目录失败:{}", JSON.toJSONString(sdmResponse));
|
||||
throw new RuntimeException("生成自动化报告上传任务报告结果目录失败");
|
||||
}
|
||||
} else {
|
||||
@@ -2211,6 +2212,7 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
resultReq.setIsConverSameNameFile(true);
|
||||
SdmResponse sdmResponse = addSimulationKeyResult(resultReq);
|
||||
if (!sdmResponse.isSuccess()) {
|
||||
log.error("生成自动化报告上传算例报告结果目录失败:{}", JSON.toJSONString(sdmResponse));
|
||||
throw new RuntimeException("生成自动化报告上传算例报告结果目录失败");
|
||||
}
|
||||
}
|
||||
@@ -2718,14 +2720,23 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
} else {
|
||||
// 再建试验结果文件夹
|
||||
SdmResponse expResultResponse = createDir(null, parentDirId, dirName, DirTypeEnum.PROJECT_NODE_DIR.getValue(), null);
|
||||
if (!expResultResponse.isSuccess()) {
|
||||
throw new RuntimeException(expResultResponse.getMessage());
|
||||
}
|
||||
parentId = Long.parseLong(expResultResponse.getData().toString());
|
||||
}
|
||||
} else {
|
||||
// 没建过交付物文件夹则新建
|
||||
SdmResponse deliverableDirResponse = createDir(null, taskId, CommonConstants.DELIVERABLE_DIR_NAME, DirTypeEnum.PROJECT_NODE_DIR.getValue(), null);
|
||||
if (!deliverableDirResponse.isSuccess()) {
|
||||
throw new RuntimeException(deliverableDirResponse.getMessage());
|
||||
}
|
||||
Long parentDirId = Long.parseLong(deliverableDirResponse.getData().toString());
|
||||
// 再建试验结果文件夹
|
||||
SdmResponse expResultResponse = createDir(null, parentDirId, dirName, DirTypeEnum.PROJECT_NODE_DIR.getValue(), null);
|
||||
if (!expResultResponse.isSuccess()) {
|
||||
throw new RuntimeException(expResultResponse.getMessage());
|
||||
}
|
||||
parentId = Long.parseLong(expResultResponse.getData().toString());
|
||||
}
|
||||
return parentId;
|
||||
|
||||
Reference in New Issue
Block a user