fix:任务执行bug
This commit is contained in:
@@ -28,4 +28,9 @@ public class SpdmReportReq {
|
||||
*/
|
||||
private String outPutDirPath;
|
||||
|
||||
/**
|
||||
* 生成的报告要上传到流程节点的路径
|
||||
*/
|
||||
private String flowPath;
|
||||
|
||||
}
|
||||
@@ -576,7 +576,8 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
// 创建算例文件夹
|
||||
SdmResponse runDirResponse = createDir(simulationRun.getUuid(), simulationTask.getUuid(), req.getRunName(), DirTypeEnum.PROJECT_NODE_DIR.getValue(), NodeTypeEnum.RUN.getValue());
|
||||
if (!runDirResponse.isSuccess()) {
|
||||
return SdmResponse.failed("创建算例文件夹失败:{}" + runDirResponse.getMessage());
|
||||
log.error("创建算例文件夹失败:{}", runDirResponse.getMessage());
|
||||
throw new RuntimeException("创建算例文件夹失败:" + runDirResponse.getMessage());
|
||||
}
|
||||
|
||||
// 解析流程模板中的节点结构,初始化流程节点表
|
||||
@@ -602,7 +603,8 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
// 每个流程节点建立节点文件夹
|
||||
SdmResponse nodeDirResponse = createDir(flowNodeDto.getUuid(), simulationRun.getUuid(), flowNodeDto.getNodeName(), DirTypeEnum.PROJECT_NODE_DIR.getValue(), NodeTypeEnum.FLOW_NODE.getValue());
|
||||
if (!nodeDirResponse.isSuccess()) {
|
||||
return SdmResponse.failed("创建节点文件夹失败:{}" + nodeDirResponse.getMessage());
|
||||
log.error("创建节点文件夹失败:{}", nodeDirResponse.getMessage());
|
||||
throw new RuntimeException("创建节点文件夹失败:" + nodeDirResponse.getMessage());
|
||||
}
|
||||
// 每个流程节点初始化输入输出两个文件夹
|
||||
SdmResponse inputDir = createDir(null, flowNodeDto.getUuid(), "数据输入", DirTypeEnum.PROJECT_NODE_DIR.getValue(), null);
|
||||
@@ -613,7 +615,8 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
FlowNodeDto addReq = new FlowNodeDto();
|
||||
addReq.setFlowNodeDtoList(flowNodeDtoList);
|
||||
if (!flowFeignClient.batchAddSimulationFlowNode(addReq).isSuccess()) {
|
||||
return SdmResponse.failed("新增流程节点失败:{}");
|
||||
log.error("新增流程节点失败");
|
||||
throw new RuntimeException("新增流程节点失败");
|
||||
}
|
||||
// 子算例继承父算例的用户输入参数
|
||||
if (StringUtils.isNotBlank(simulationRun.getParentId())) {
|
||||
@@ -662,9 +665,11 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
// 删除算例目录
|
||||
DelDirReq delDirReq = new DelDirReq();
|
||||
delDirReq.setDelUuid(simulationRun.getUuid());
|
||||
log.info("删除算例调用删除文件夹的参数为:{}", req);
|
||||
SdmResponse response = dataFeignClient.delDir(delDirReq);
|
||||
log.info("删除算例调用删除文件夹的返回值为:{}", response);
|
||||
if (!response.isSuccess()) {
|
||||
log.error("删除算例文件夹失败:{}", response.getMessage());
|
||||
throw new RuntimeException("删除算例文件夹失败:" + response.getMessage());
|
||||
}
|
||||
return SdmResponse.success(response);
|
||||
}
|
||||
|
||||
@@ -1210,28 +1215,43 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
} else {
|
||||
log.info(commands + "执行脚本完成!");
|
||||
}
|
||||
try {
|
||||
// 获取临时路径中脚本生成的报告
|
||||
FileInputStream fileInputStream = new FileInputStream(TEMP_REPORT_PATH + randomId + File.separator + "report" + File.separator + "report.docx");
|
||||
byte[] fileData = fileInputStream.readAllBytes();
|
||||
// 设置响应头
|
||||
response.reset();
|
||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
response.addHeader("Content-Length", String.valueOf(fileData.length));
|
||||
byte[] fileData = null;
|
||||
if (response != null) {
|
||||
try {
|
||||
// 获取临时路径中脚本生成的报告
|
||||
FileInputStream fileInputStream = new FileInputStream(TEMP_REPORT_PATH + randomId + File.separator + "report" + File.separator + "report.docx");
|
||||
fileData = fileInputStream.readAllBytes();
|
||||
// 设置响应头
|
||||
response.reset();
|
||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
response.addHeader("Content-Length", String.valueOf(fileData.length));
|
||||
// 写入响应流
|
||||
OutputStream outputStream = response.getOutputStream();
|
||||
outputStream.write(fileData);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
fileInputStream.close();
|
||||
} catch (Exception ex) {
|
||||
log.error("生成自动化报告失败:{}", ex.getMessage());
|
||||
throw new RuntimeException("生成自动化报告失败");
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(req.getFlowPath()) && fileData != null) {
|
||||
// 将生成的报告上传到flowPath路径下
|
||||
// 写入响应流
|
||||
OutputStream outputStream = response.getOutputStream();
|
||||
outputStream.write(fileData);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
fileInputStream.close();
|
||||
} catch (Exception ex) {
|
||||
log.error("生成自动化报告失败:{}", ex.getMessage());
|
||||
throw new RuntimeException("生成自动化报告失败");
|
||||
FileOutputStream outputStream = null;
|
||||
try {
|
||||
outputStream = new FileOutputStream(req.getFlowPath());
|
||||
outputStream.write(fileData);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
// 删除临时路径
|
||||
log.info("删除临时路径:{},中。。。。。。", randomId);
|
||||
deleteFolder(new File(TEMP_REPORT_PATH + randomId));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user