feat:任务下归档报告
This commit is contained in:
2
1-sql/2026-02-10/simulation_task.sql
Normal file
2
1-sql/2026-02-10/simulation_task.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE spdm_baseline.simulation_task ADD reportTemplate varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '报告模板uuid';
|
||||
ALTER TABLE spdm_baseline.simulation_task ADD reportContent mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '报告模板填充内容';
|
||||
@@ -1,18 +1,25 @@
|
||||
package com.sdm.common.entity.req.project;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class EditReportReq {
|
||||
|
||||
@Schema(description= "算例uuid")
|
||||
private String runId;
|
||||
|
||||
@Schema(description= "报告模板uuid")
|
||||
private String reportTemplate;
|
||||
|
||||
@Schema(description= "报告模板内容")
|
||||
private String reportContent;
|
||||
|
||||
@Schema(description= "任务uuid")
|
||||
private String taskId;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.sdm.common.entity.pojo.BaseEntity;
|
||||
import com.sdm.common.entity.resp.system.CIDUserResp;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@@ -224,4 +225,10 @@ public class SpdmTaskVo extends BaseEntity {
|
||||
*/
|
||||
private String eUserId;
|
||||
|
||||
@Schema(description= "报告模板内容")
|
||||
private String reportContent;
|
||||
|
||||
@Schema(description= "任务uuid")
|
||||
private String taskId;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -210,5 +211,13 @@ public class SimulationTask implements Serializable {
|
||||
@TableField("discipline")
|
||||
private String discipline;
|
||||
|
||||
@Schema(description= "报告模板uuid")
|
||||
@TableField("reportTemplate")
|
||||
private String reportTemplate;
|
||||
|
||||
@Schema(description= "报告模板填充内容")
|
||||
@TableField("reportContent")
|
||||
private String reportContent;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -915,6 +915,7 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
if (StringUtils.isEmpty(req.getFileTypeDictValue())) {
|
||||
req.setFileTypeDictClass(FileDictTagEnum.FILE_TYPE.getDictClass());
|
||||
req.setFileTypeDictValue(String.valueOf(req.getFileType()));
|
||||
req.setDictTags(Arrays.asList(FileDictTagEnum.FILE_TYPE.getDictClassFieldName(), FileDictTagEnum.FILE_TYPE.getDictValueFieldName()));
|
||||
}
|
||||
SdmResponse response = uploadKeyResultFiles(filesReq);
|
||||
if (response.isSuccess() && response.getData() != null) {
|
||||
@@ -1626,13 +1627,24 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
@Override
|
||||
public SdmResponse editReport(EditReportReq req) {
|
||||
log.info("编辑报告参数为:{}", req);
|
||||
String reportContent = req.getReportContent();
|
||||
if (StringUtils.isNotEmpty(req.getTaskId())) {
|
||||
SimulationTask simulationTask = simulationTaskService.lambdaQuery().eq(SimulationTask::getUuid, req.getTaskId()).one();
|
||||
if (simulationTask != null) {
|
||||
// 任务绑定报告模板
|
||||
simulationTask.setReportTemplate(req.getReportTemplate());
|
||||
simulationTask.setReportContent(reportContent);
|
||||
simulationTaskService.updateById(simulationTask);
|
||||
}
|
||||
} else {
|
||||
SimulationRun simulationRun = this.lambdaQuery().eq(SimulationRun::getUuid, req.getRunId()).one();
|
||||
if (simulationRun != null) {
|
||||
String reportContent = req.getReportContent();
|
||||
// 算例绑定报告模板
|
||||
simulationRun.setReportTemplate(req.getReportTemplate());
|
||||
simulationRun.setReportContent(reportContent);
|
||||
this.updateById(simulationRun);
|
||||
}
|
||||
}
|
||||
|
||||
String randomId = RandomUtil.generateString(16);
|
||||
// 创建临时文件夹
|
||||
@@ -1711,24 +1723,41 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
FileInputStream fileInputStream = new FileInputStream(TEMP_REPORT_PATH + randomId + File.separator + reportName);
|
||||
fileData = fileInputStream.readAllBytes();
|
||||
|
||||
// 上传到算例下的报告文件夹下
|
||||
KeyResultReq resultReq = new KeyResultReq();
|
||||
resultReq.setKeyResultType(KeyResultTypeEnum.DOCUMENT.getKeyResultType());
|
||||
resultReq.setRunId(req.getRunId());
|
||||
resultReq.setName(reportName);
|
||||
// 创建临时MultipartFile
|
||||
MockMultipartFile multipartFile = new MockMultipartFile(
|
||||
reportName,
|
||||
reportName,
|
||||
"application/json",
|
||||
fileData);
|
||||
if (StringUtils.isNotEmpty(req.getTaskId())) {
|
||||
// 上传到任务下的交付物文件夹的报告文件夹下
|
||||
Long parentId = getParentDirId(req.getTaskId(), FileBizTypeEnum.REPORT_FILE.getDirName());
|
||||
UploadFilesReq filesReq = new UploadFilesReq();
|
||||
filesReq.setFile(multipartFile);
|
||||
filesReq.setFileName(reportName);
|
||||
filesReq.setFileType(FileBizTypeEnum.REPORT_FILE.getValue());
|
||||
filesReq.setUuid(null);
|
||||
filesReq.setDirId(parentId);
|
||||
SdmResponse sdmResponse = uploadKeyResultFiles(filesReq);
|
||||
if (!sdmResponse.isSuccess()) {
|
||||
throw new RuntimeException("生成自动化报告上传任务报告结果目录失败");
|
||||
}
|
||||
} else {
|
||||
// 上传到算例下的报告文件夹下
|
||||
KeyResultReq resultReq = new KeyResultReq();
|
||||
resultReq.setKeyResultType(KeyResultTypeEnum.DOCUMENT.getKeyResultType());
|
||||
resultReq.setRunId(req.getRunId());
|
||||
resultReq.setName(reportName);
|
||||
|
||||
resultReq.setFile(multipartFile);
|
||||
resultReq.setFileName(reportName);
|
||||
resultReq.setFileType(FileBizTypeEnum.REPORT_FILE.getValue());
|
||||
SdmResponse sdmResponse = addSimulationKeyResult(resultReq);
|
||||
if (!sdmResponse.isSuccess()) {
|
||||
throw new RuntimeException("生成自动化报告上传报告结果目录失败");
|
||||
throw new RuntimeException("生成自动化报告上传算例报告结果目录失败");
|
||||
}
|
||||
}
|
||||
|
||||
fileInputStream.close();
|
||||
// 删除临时路径
|
||||
log.info("删除临时路径:{},中。。。。。。", randomId);
|
||||
@@ -1739,20 +1768,30 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
throw new RuntimeException("生成自动化报告失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
return SdmResponse.failed("算例不存在");
|
||||
return SdmResponse.failed("生成自动化报告失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editReportAndDownload(EditReportReq req, HttpServletResponse response) {
|
||||
log.info("编辑报告参数为:{}", req);
|
||||
String reportContent = req.getReportContent();
|
||||
if (StringUtils.isNotEmpty(req.getTaskId())) {
|
||||
SimulationTask simulationTask = simulationTaskService.lambdaQuery().eq(SimulationTask::getUuid, req.getTaskId()).one();
|
||||
if (simulationTask != null) {
|
||||
// 任务绑定报告模板
|
||||
simulationTask.setReportTemplate(req.getReportTemplate());
|
||||
simulationTask.setReportContent(reportContent);
|
||||
simulationTaskService.updateById(simulationTask);
|
||||
}
|
||||
} else {
|
||||
SimulationRun simulationRun = this.lambdaQuery().eq(SimulationRun::getUuid, req.getRunId()).one();
|
||||
if (simulationRun != null) {
|
||||
String reportContent = req.getReportContent();
|
||||
// 算例绑定报告模板
|
||||
simulationRun.setReportTemplate(req.getReportTemplate());
|
||||
simulationRun.setReportContent(reportContent);
|
||||
this.updateById(simulationRun);
|
||||
}
|
||||
}
|
||||
|
||||
String randomId = RandomUtil.generateString(16);
|
||||
// 创建临时文件夹
|
||||
@@ -1832,23 +1871,39 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
FileInputStream fileInputStream = new FileInputStream(TEMP_REPORT_PATH + randomId + File.separator + reportName);
|
||||
fileData = fileInputStream.readAllBytes();
|
||||
|
||||
// 上传到算例下的报告文件夹下
|
||||
KeyResultReq resultReq = new KeyResultReq();
|
||||
resultReq.setKeyResultType(KeyResultTypeEnum.DOCUMENT.getKeyResultType());
|
||||
resultReq.setRunId(req.getRunId());
|
||||
resultReq.setName(reportName);
|
||||
// 创建临时MultipartFile
|
||||
MockMultipartFile multipartFile = new MockMultipartFile(
|
||||
reportName,
|
||||
reportName,
|
||||
"application/json",
|
||||
fileData);
|
||||
if (StringUtils.isNotEmpty(req.getTaskId())) {
|
||||
// 上传到任务下的交付物文件夹的报告文件夹下
|
||||
Long parentId = getParentDirId(req.getTaskId(), FileBizTypeEnum.REPORT_FILE.getDirName());
|
||||
UploadFilesReq filesReq = new UploadFilesReq();
|
||||
filesReq.setFile(multipartFile);
|
||||
filesReq.setFileName(reportName);
|
||||
filesReq.setFileType(FileBizTypeEnum.REPORT_FILE.getValue());
|
||||
filesReq.setUuid(null);
|
||||
filesReq.setDirId(parentId);
|
||||
SdmResponse sdmResponse = uploadKeyResultFiles(filesReq);
|
||||
if (!sdmResponse.isSuccess()) {
|
||||
throw new RuntimeException("生成自动化报告上传任务报告结果目录失败");
|
||||
}
|
||||
} else {
|
||||
// 上传到算例下的报告文件夹下
|
||||
KeyResultReq resultReq = new KeyResultReq();
|
||||
resultReq.setKeyResultType(KeyResultTypeEnum.DOCUMENT.getKeyResultType());
|
||||
resultReq.setRunId(req.getRunId());
|
||||
resultReq.setName(reportName);
|
||||
|
||||
resultReq.setFile(multipartFile);
|
||||
resultReq.setFileName(reportName);
|
||||
resultReq.setFileType(FileBizTypeEnum.REPORT_FILE.getValue());
|
||||
SdmResponse sdmResponse = addSimulationKeyResult(resultReq);
|
||||
if (!sdmResponse.isSuccess()) {
|
||||
throw new RuntimeException("生成自动化报告上传报告结果目录失败");
|
||||
throw new RuntimeException("生成自动化报告上传算例报告结果目录失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 下载到本地
|
||||
@@ -1872,7 +1927,6 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
deleteFolder(new File(TEMP_REPORT_PATH + randomId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<Void> generateReportInternal(SpdmReportReq req) {
|
||||
|
||||
Reference in New Issue
Block a user