update
This commit is contained in:
@@ -127,8 +127,8 @@ public class ExperimentReportController extends JeecgController<ExperimentReport
|
|||||||
fileName = sampleName + "-" + modelBatch;
|
fileName = sampleName + "-" + modelBatch;
|
||||||
}
|
}
|
||||||
experimentReport.setReportName("试验报告-" + fileName);
|
experimentReport.setReportName("试验报告-" + fileName);
|
||||||
experimentReportService.save(experimentReport);
|
boolean save = experimentReportService.save(experimentReport);
|
||||||
experimentDocService.generate(experimentId, ExperimentDocType.sybg.getType());
|
experimentDocService.generateExperimentReport( experimentReport.getId());
|
||||||
return Result.OK("添加成功!");
|
return Result.OK("添加成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,8 +156,8 @@ public class ExperimentReportController extends JeecgController<ExperimentReport
|
|||||||
// experimentReport.setStatus(experimentReport.getLastStatus());
|
// experimentReport.setStatus(experimentReport.getLastStatus());
|
||||||
//}
|
//}
|
||||||
experimentReportService.updateById(experimentReport);
|
experimentReportService.updateById(experimentReport);
|
||||||
experimentDocService.generate(report.getExperimentId(), ExperimentDocType.sybg.getType());
|
String generate = experimentDocService.generateExperimentReport(experimentReport.getId());
|
||||||
return Result.OK("编辑成功!");
|
return Result.OK(generate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ public interface IExperimentDocService extends IService<ExperimentDoc> {
|
|||||||
|
|
||||||
ExperimentDoc generate(String experimentId, String type);
|
ExperimentDoc generate(String experimentId, String type);
|
||||||
|
|
||||||
|
String generateExperimentReport(String experimentReportId);
|
||||||
|
|
||||||
List<ExperimentDoc> getHistoryByExperimentId(String experimentId, String type);
|
List<ExperimentDoc> getHistoryByExperimentId(String experimentId, String type);
|
||||||
|
|
||||||
ExperimentDoc getByExperimentId(String experimentId, String type);
|
ExperimentDoc getByExperimentId(String experimentId, String type);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.apache.poi.xwpf.usermodel.*;
|
import org.apache.poi.xwpf.usermodel.*;
|
||||||
import org.jeecg.common.util.DateUtils;
|
import org.jeecg.common.util.DateUtils;
|
||||||
import org.jeecg.common.util.MinioUtil;
|
import org.jeecg.common.util.MinioUtil;
|
||||||
|
import org.jeecg.modules.database.constant.ExperimentDocType;
|
||||||
import org.jeecg.modules.database.dto.RadiationDetailDTO;
|
import org.jeecg.modules.database.dto.RadiationDetailDTO;
|
||||||
import org.jeecg.modules.database.dto.RadiationMapDTO;
|
import org.jeecg.modules.database.dto.RadiationMapDTO;
|
||||||
import org.jeecg.modules.database.entity.*;
|
import org.jeecg.modules.database.entity.*;
|
||||||
@@ -232,9 +233,6 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
|
|||||||
FileUtil.mkdir(outputDir);
|
FileUtil.mkdir(outputDir);
|
||||||
}
|
}
|
||||||
for (ExperimentReport experimentReport : reportList) {
|
for (ExperimentReport experimentReport : reportList) {
|
||||||
if (StringUtils.isNotBlank(experimentReport.getFileUrl())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Map<String, Object> params = assembleSybg(experimentId, experimentReport);
|
Map<String, Object> params = assembleSybg(experimentId, experimentReport);
|
||||||
XWPFTemplate render = XWPFTemplate.compile(absolutePath).render(params);
|
XWPFTemplate render = XWPFTemplate.compile(absolutePath).render(params);
|
||||||
String filePath = outputDir + File.separator + experimentReport.getReportName() + ".docx";
|
String filePath = outputDir + File.separator + experimentReport.getReportName() + ".docx";
|
||||||
@@ -245,6 +243,7 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
|
|||||||
experimentReport.setFileUrl(reportPath);
|
experimentReport.setFileUrl(reportPath);
|
||||||
experimentReportService.updateById(experimentReport);
|
experimentReportService.updateById(experimentReport);
|
||||||
}
|
}
|
||||||
|
|
||||||
File zip = ZipUtil.zip(outputDir);
|
File zip = ZipUtil.zip(outputDir);
|
||||||
String zipPath = MinioUtil.upload(FileUtil.getInputStream(zip),
|
String zipPath = MinioUtil.upload(FileUtil.getInputStream(zip),
|
||||||
"experiment_doc/" + experimentId + "/" + version + "/" + type + "-" + experiment.getName() + ".zip");
|
"experiment_doc/" + experimentId + "/" + version + "/" + type + "-" + experiment.getName() + ".zip");
|
||||||
@@ -745,6 +744,50 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String generateExperimentReport(String experimentReportId) {
|
||||||
|
String version = DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN);
|
||||||
|
ExperimentReport experimentReport = experimentReportService.getById(experimentReportId);
|
||||||
|
if (Objects.isNull(experimentReport)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String experimentId = experimentReport.getExperimentId();
|
||||||
|
String absolutePath = templatePath + File.separator + docTempalteMap.get(ExperimentDocType.sybg.getType());
|
||||||
|
log.info("doc template path: " + absolutePath);
|
||||||
|
if (!FileUtil.exist(absolutePath)) {
|
||||||
|
throw new RuntimeException("模板文件不存在!");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Experiment experiment = experimentService.getById(experimentId);
|
||||||
|
if (Objects.isNull(experiment)) {
|
||||||
|
throw new RuntimeException("实验数据不存在!");
|
||||||
|
}
|
||||||
|
String tmpDirPath = FileUtil.getTmpDirPath();
|
||||||
|
|
||||||
|
List<String> pathList = new ArrayList<>();
|
||||||
|
|
||||||
|
String outputDir = tmpDirPath + ExperimentDocType.sybg.getType() + File.separator + experimentId + File.separator + version;
|
||||||
|
if (FileUtil.exist(outputDir)) {
|
||||||
|
FileUtil.del(outputDir);
|
||||||
|
}
|
||||||
|
if (!FileUtil.exist(outputDir)) {
|
||||||
|
FileUtil.mkdir(outputDir);
|
||||||
|
}
|
||||||
|
Map<String, Object> params = assembleSybg(experimentId, experimentReport);
|
||||||
|
XWPFTemplate render = XWPFTemplate.compile(absolutePath).render(params);
|
||||||
|
String filePath = outputDir + File.separator + experimentReport.getReportName() + ".docx";
|
||||||
|
render.writeToFile(filePath);
|
||||||
|
String reportPath = MinioUtil.upload(FileUtil.getInputStream(filePath),
|
||||||
|
"experiment_doc/" + experimentId + "/" + version + "/" + experimentReport.getReportName() + ".docx");
|
||||||
|
experimentReport.setFileUrl(reportPath);
|
||||||
|
experimentReportService.updateById(experimentReport);
|
||||||
|
return reportPath;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExperimentDoc generate(String experimentId, String type) {
|
public ExperimentDoc generate(String experimentId, String type) {
|
||||||
String version = DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN);
|
String version = DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN);
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user