1、生成报告时,判断临时文件夹是否已存在

This commit is contained in:
2025-12-04 18:01:26 +08:00
parent 02a167e347
commit bcee415cbd

View File

@@ -1096,6 +1096,14 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
dataFeignClient.downloadFileToLocal(fileId, TEMP_REPORT_PATH + randomId);
}
}
Path folder = Paths.get(TEMP_REPORT_PATH + randomId);
if (!Files.exists(folder) || Files.isDirectory(folder)) {
boolean mkdirResult = new File(TEMP_REPORT_PATH + randomId).mkdir();
if (mkdirResult) {
log.error("创建临时文件夹:{}失败",TEMP_REPORT_PATH + randomId);
throw new RuntimeException("生成报告失败,原因为:创建临时文件夹失败");
}
}
log.info("临时路径为:{}", randomId);
String commands = "python /opt/script/exportWord.py " + TEMP_REPORT_PATH + randomId + File.separator + TEMPLATE_PATH + projecInfoReq.getLoadcaseName() + "Analyse";
// 生成projectInfo.json