Merge remote-tracking branch 'origin/main'

This commit is contained in:
2025-12-03 18:12:47 +08:00
7 changed files with 150 additions and 11 deletions

View File

@@ -447,7 +447,7 @@ public class DataFileController implements IDataFeignClient {
*
* @param fileId
*/
@PostMapping("/downloadFileForEdit")
@GetMapping("/downloadFileForEdit")
@Operation(summary = "根据fileId下载文件到指定目录并返回该文件的系统路径", description = "根据fileId下载文件到指定目录并返回该文件的系统路径")
public SdmResponse downloadFileForEdit(@RequestParam(value = "fileId") @Validated Long fileId) {
return IDataFileService.downloadFileForEdit(fileId);

View File

@@ -152,9 +152,9 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
// return type;
// }
private static final String TEMP_FILE_PATH = "D:\\nginx-1.28.0\\html\\static\\";
private static final String TEMP_FILE_PATH = "/usr/local/nginx/html/storage/";
private static final String TEMP_NG_URL = "http://192.168.65.199:10031/static/";
private static final String TEMP_NG_URL = "http://192.168.65.161:10031/storage/";
@Override
@Transactional(rollbackFor = Exception.class)
@@ -2418,6 +2418,8 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
@Override
public ResponseEntity<Object> onlyOfficeCallback(CallbackData callbackData) {
log.info("调用回调接口,url{}",callbackData.getUrl());
log.info("调用回调接口key{}",callbackData.getKey());
log.info("调用回调接口status{}",callbackData.getStatus());
//状态监听
//参见https://api.onlyoffice.com/editors/callback
Integer status = callbackData.getStatus();
@@ -2451,13 +2453,13 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
}
case 6: {
//document is being edited, but the current document state is saved,编辑保存
String prefixUrl = "D:\\software\\docker_file\\onlyoffice-de\\lib\\documentserver\\App_Data\\cache\\files\\data";
String prefixUrl = "/home/onlyoffice/lib/documentserver/App_Data/cache/files/data";
String url = callbackData.getUrl();
url = url.substring(url.indexOf("data") + 5,url.indexOf("output.docx") - 1);
log.info("动态路径为:{}",url);
url = prefixUrl + File.separator + url + File.separator + "output.docx";
log.info("最终路径为:{}",url);
String fileId = callbackData.getKey();
String fileId = callbackData.getKey().split("_")[0];
try {
Path path = Paths.get(url);
uploadNewFile(fileId,path);
@@ -2529,6 +2531,8 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
outputStream.close();
JSONObject jsonObject = new JSONObject();
jsonObject.put("url",TEMP_NG_URL + randomId + "/" + fileMetadataInfo.getOriginalName());
jsonObject.put("fileName",fileMetadataInfo.getOriginalName());
jsonObject.put("fileType",fileMetadataInfo.getOriginalName().substring(fileMetadataInfo.getOriginalName().lastIndexOf(".") + 1));
return SdmResponse.success(jsonObject);
} catch (Exception e) {
log.error("onlyoffice编辑文件失败", e);

View File

@@ -0,0 +1,25 @@
package com.sdm.project.model.req;
import lombok.Data;
import java.io.Serializable;
@Data
public class PerformanceInfoReq implements Serializable {
private static final long serialVersionUID = 1L;
private String value;
private String englishName;
private String highValue;
private String performanceName;
private String method;
private String unit;
}

View File

@@ -0,0 +1,47 @@
package com.sdm.project.model.req;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.io.Serializable;
@Data
public class ProjecInfoReq implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 部门
*/
private String department;
private String applicants;
private String date;
private String projectNum;
private String workspaceNum;
private String workspace;
private String taskType;
private String reportVer;
private String fileNum;
private String formulateTime;
private String checkTime;
private String approveTime;
private Boolean isBatch = false;
private String loadcaseName;
private String reportCommand;
}

View File

@@ -25,8 +25,8 @@ public class SpdmReportReq {
private List<SimulationPerformance> performanceList;
/**
* 算例父节点信息集合
* 算例父节点信息
*/
private List<TaskNode> parentNodeInfoList;
private ProjecInfoReq projecInfoReq;
}

View File

@@ -14,6 +14,7 @@ import com.sdm.common.entity.constants.TagConstant;
import com.sdm.common.entity.enums.DirTypeEnum;
import com.sdm.common.entity.enums.NodeTypeEnum;
import com.sdm.common.entity.req.data.CreateDirReq;
import com.sdm.common.entity.req.data.DelDirReq;
import com.sdm.common.entity.req.data.RenameDirReq;
import com.sdm.common.entity.req.data.UploadFilesReq;
import com.sdm.common.entity.req.project.*;
@@ -199,10 +200,26 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return SdmResponse.failed("操作节点失败,原因:删除节点时失败!");
}
deleteDirNew(deleteNodeIdList);
}
return SdmResponse.success();
}
// 删除文件夹
public boolean deleteDirNew(List<String> uuidList) {
for (String uuid : uuidList) {
DelDirReq req = new DelDirReq();
req.setDelUuid(uuid);
log.info("调用删除文件夹的参数为:{}", req);
SdmResponse response = dataClientFeignClient.delDir(req);
log.info("调用删除文件夹的返回值为:{}", response);
if (response.getCode() != ResultCode.SUCCESS.getCode()) {
return false;
}
}
return true;
}
private boolean deleteNode(List<String> deleteNodeIdList) {
List<ProjectNodePo> projectNodePoList = nodeMapper.allList(deleteNodeIdList);
@@ -235,7 +252,11 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
List<Long> performanceIdList = performanceNodePoList.stream().map(PerformanceNodePo::getId).toList();
nodeMapper.deletePerformanceBatch(performanceIdList);
nodeMapper.deletePerformanceExtraBatch(performanceIdList);
return true;
List<SpdmNodeVo> childrenNodeList = nodeMapper.getNodeListByNodeIdList(deleteNodeIdList);
if (CollectionUtils.isEmpty(childrenNodeList)) {
return true;
}
return deleteNode(childrenNodeList.stream().map(SpdmNodeVo::getUuid).toList());
}
@Override

View File

@@ -79,6 +79,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
@@ -1099,6 +1100,48 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
for (Long fileId : imageFileIdList) {
dataFeignClient.downloadFileToLocal(fileId, TEMP_REPORT_PATH + randomId);
}
// 生成projectInfo.json
// 父节点信息
ProjecInfoReq projecInfoReq = req.getProjecInfoReq();
if (ObjectUtils.isNotEmpty(projecInfoReq)) {
projecInfoReq.setReportCommand("python /opt/script/exportWord.py /opt/script/project/dynamics1 /opt/script/template dynamics");
String jsonString = JSON.toJSONString(projecInfoReq);
FileOutputStream projectInfoOutputStream = null;
try {
projectInfoOutputStream = new FileOutputStream(TEMP_REPORT_PATH + randomId + File.separator + "projectInfo.json");
projectInfoOutputStream.write(jsonString.getBytes(StandardCharsets.UTF_8));
projectInfoOutputStream.flush();
projectInfoOutputStream.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
// 生成performance.json
List<SimulationPerformance> performanceList = req.getPerformanceList();
List<PerformanceInfoReq> exportPerformanceList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(performanceList)) {
PerformanceInfoReq performanceInfoReq = new PerformanceInfoReq();
for (SimulationPerformance performance : performanceList) {
performanceInfoReq.setValue(StringUtils.isNotBlank(performance.getTargetValue()) ? performance.getTargetValue() : "");
performanceInfoReq.setEnglishName(StringUtils.isNotBlank(performance.getEnglishName()) ? performance.getEnglishName() : "");
performanceInfoReq.setHighValue(StringUtils.isNotBlank(performance.getHighValue()) ? performance.getHighValue() : "");
performanceInfoReq.setPerformanceName(StringUtils.isNotBlank(performance.getPerformanceName()) ? performance.getPerformanceName() : "");
performanceInfoReq.setMethod(StringUtils.isNotBlank(performance.getMethod()) ? performance.getMethod() : "");
performanceInfoReq.setUnit(StringUtils.isNotBlank(performance.getUnit()) ? performance.getUnit() : "");
exportPerformanceList.add(performanceInfoReq);
}
String jsonString = JSON.toJSONString(exportPerformanceList);
FileOutputStream performanceOutputStream = null;
try {
performanceOutputStream = new FileOutputStream(TEMP_REPORT_PATH + randomId + File.separator + "performance.json");
performanceOutputStream.write(jsonString.getBytes(StandardCharsets.UTF_8));
performanceOutputStream.flush();
performanceOutputStream.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
// 调用脚本
log.info("调用脚本中。。。。。。");
String commands = "python /opt/script/exportWord.py " + TEMP_REPORT_PATH + randomId + File.separator;
@@ -1131,7 +1174,7 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
}
try {
// 获取临时路径中脚本生成的报告
FileInputStream fileInputStream = new FileInputStream(TEMP_REPORT_PATH + randomId + File.separator + "report.docx");
FileInputStream fileInputStream = new FileInputStream(TEMP_REPORT_PATH + randomId + File.separator + "report" + File.separator + "report.docx");
byte[] fileData = fileInputStream.readAllBytes();
// 设置响应头
response.reset();
@@ -1153,8 +1196,7 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
}
// 性能指标集合
List<SimulationPerformance> performanceList = req.getPerformanceList();
// 父节点集合
List<TaskNode> parentNodeInfoList = req.getParentNodeInfoList();
}