fix:试验结果建文件夹
This commit is contained in:
@@ -14,4 +14,13 @@ public class CommonConstants {
|
||||
|
||||
public static final String GENERAL_N = "N";
|
||||
|
||||
/**
|
||||
* 交付物文件夹名
|
||||
*/
|
||||
public static final String DELIVERABLE_DIR_NAME = "交付物文件";
|
||||
/**
|
||||
* 试验结果文件夹名
|
||||
*/
|
||||
public static final String EXPERIMENT_DIR_NAME = "试验结果";
|
||||
|
||||
}
|
||||
|
||||
@@ -64,11 +64,11 @@ public class DataClientFeignClientImpl implements IDataFeignClient {
|
||||
SdmResponse<PageDataResp<List<FileMetadataInfoResp>>> response;
|
||||
try {
|
||||
response = dataClient.queryDir(req);
|
||||
log.info("创建文响应件夹:"+ response);
|
||||
log.info("查询文件夹响应:"+ response);
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
log.error("创建文件夹失败", e);
|
||||
return SdmResponse.failed("创建文件夹失败");
|
||||
log.error("查询文件夹失败", e);
|
||||
return SdmResponse.failed("查询文件夹失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.entity.constants.CommonConstants;
|
||||
import com.sdm.common.entity.constants.NumberConstants;
|
||||
import com.sdm.common.entity.enums.*;
|
||||
import com.sdm.common.entity.flowable.dto.FlowElementDTO;
|
||||
@@ -757,6 +758,19 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
return response;
|
||||
}
|
||||
|
||||
private SdmResponse createDir(String uuid, Long parentDirId, String dirName, Integer dirType, String uuidOwnType) {
|
||||
CreateDirReq createDirReq = new CreateDirReq();
|
||||
createDirReq.setUuId(uuid);
|
||||
createDirReq.setParDirId(parentDirId);
|
||||
createDirReq.setUuIdOwnType(uuidOwnType);
|
||||
createDirReq.setDirName(dirName);
|
||||
createDirReq.setDirType(dirType);
|
||||
log.info("上传试验结果时,调用创建文件夹的参数为:{}", createDirReq);
|
||||
SdmResponse response = dataFeignClient.createDir(createDirReq);
|
||||
log.info("上传试验结果时,调用创建文件夹的返回值为:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SdmResponse deleteTaskRun(SpdmTaskRunReq req) {
|
||||
@@ -2093,9 +2107,12 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
req.getFileInfoList().add(req.getImageFileInfo());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(req.getFileInfoList())) {
|
||||
// 试验结果文件不直接放在task下面,要放在task的交付物文件夹的试验结果文件夹下面
|
||||
Long parentId = getParentDirId(req.getTaskId());
|
||||
|
||||
UploadFilesReq filesReq = new UploadFilesReq();
|
||||
BeanUtils.copyProperties(req, filesReq);
|
||||
filesReq.setUuid(req.getTaskId());
|
||||
filesReq.setDirId(parentId);
|
||||
filesReq.setSourceFiles(req.getFileInfoList().stream().map(i -> new UploadFilesReq(i.getFileName(), i.getFileSize(), i.getFileType())).toList());
|
||||
// 批量存储文件信息,返回数据供第二步分片上传使用
|
||||
SdmResponse<List<BatchAddFileInfoResp>> sdmResponse = dataFeignClient.batchAddFileInfo(filesReq);
|
||||
@@ -2116,6 +2133,43 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
return SdmResponse.success(experimentResult.getUuid());
|
||||
}
|
||||
|
||||
private Long getParentDirId(String taskId) {
|
||||
Long parentId = null;
|
||||
QueryDirReq queryDirReq = new QueryDirReq();
|
||||
queryDirReq.setUuid(taskId);
|
||||
queryDirReq.setQueryTarget(DataTypeEnum.DIRECTORY.getValue());
|
||||
queryDirReq.setFileName(CommonConstants.DELIVERABLE_DIR_NAME);
|
||||
queryDirReq.setCurrent(1);
|
||||
queryDirReq.setSize(10);
|
||||
SdmResponse<PageDataResp<List<FileMetadataInfoResp>>> response = dataFeignClient.queryDir(queryDirReq);
|
||||
// 建过交付物文件夹直接取id
|
||||
if (response.getData() != null && response.getData().getData() != null) {
|
||||
FileMetadataInfoResp dirFileMetadataInfo = response.getData().getData().get(0);
|
||||
Long parentDirId = dirFileMetadataInfo.getId();
|
||||
// 再查是否建过试验结果文件夹,没有则新建
|
||||
queryDirReq.setUuid(null);
|
||||
queryDirReq.setFileId(parentDirId);
|
||||
queryDirReq.setFileName(CommonConstants.EXPERIMENT_DIR_NAME);
|
||||
SdmResponse<PageDataResp<List<FileMetadataInfoResp>>> expResponse = dataFeignClient.queryDir(queryDirReq);
|
||||
if (expResponse.getData() != null && expResponse.getData().getData() != null) {
|
||||
FileMetadataInfoResp expFileMetadataInfo = expResponse.getData().getData().get(0);
|
||||
parentId = expFileMetadataInfo.getId();
|
||||
} else {
|
||||
// 再建试验结果文件夹
|
||||
SdmResponse expResultResponse = createDir(null, parentDirId, CommonConstants.EXPERIMENT_DIR_NAME, DirTypeEnum.PROJECT_NODE_DIR.getValue(), null);
|
||||
parentId = Long.parseLong(expResultResponse.getData().toString());
|
||||
}
|
||||
} else {
|
||||
// 没建过交付物文件夹则新建
|
||||
SdmResponse deliverableDirResponse = createDir(null, taskId, CommonConstants.DELIVERABLE_DIR_NAME, DirTypeEnum.PROJECT_NODE_DIR.getValue(), null);
|
||||
Long parentDirId = Long.parseLong(deliverableDirResponse.getData().toString());
|
||||
// 再建试验结果文件夹
|
||||
SdmResponse expResultResponse = createDir(null, parentDirId, CommonConstants.EXPERIMENT_DIR_NAME, DirTypeEnum.PROJECT_NODE_DIR.getValue(), null);
|
||||
parentId = Long.parseLong(expResultResponse.getData().toString());
|
||||
}
|
||||
return parentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<PageDataResp<List<SimulationExperimentResult>>> listExperimentResult(ExperimentResultReq req) {
|
||||
PageHelper.startPage(req.getCurrent(), req.getSize());
|
||||
@@ -2207,9 +2261,11 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
|
||||
// 再处理新增的文件
|
||||
if (CollectionUtils.size(req.getAddFileInfoList()) > 0) {
|
||||
Long parentId = getParentDirId(req.getTaskId());
|
||||
|
||||
UploadFilesReq filesReq = new UploadFilesReq();
|
||||
BeanUtils.copyProperties(req, filesReq);
|
||||
filesReq.setUuid(req.getTaskId());
|
||||
filesReq.setDirId(parentId);
|
||||
filesReq.setSourceFiles(req.getAddFileInfoList().stream().map(i -> new UploadFilesReq(i.getFileName(), i.getFileSize(), i.getFileType())).toList());
|
||||
// 批量存储文件信息,返回数据供第二步分片上传使用
|
||||
batchAddResponse = dataFeignClient.batchAddFileInfo(filesReq);
|
||||
|
||||
Reference in New Issue
Block a user