实验报告批量 zip 下载
This commit is contained in:
@@ -72,4 +72,7 @@ ADD COLUMN `sample_model` varchar(2048) NULL COMMENT '样品型号' ;
|
||||
```sql
|
||||
ALTER TABLE `physical-boot`.`experiment_report`
|
||||
ADD COLUMN `last_status` varchar(32) NULL COMMENT '上一个状态' AFTER `confirmer`;
|
||||
|
||||
ALTER TABLE `physical-boot`.`experiment_report`
|
||||
ADD COLUMN `file_url` text NULL COMMENT '生成的文件路径' AFTER `sample_info`;
|
||||
```
|
||||
@@ -243,7 +243,7 @@ jeecg:
|
||||
minio_url: http://47.102.126.67:29000
|
||||
minio_public_url: http://47.102.126.67/oss/
|
||||
minio_name: root
|
||||
minio_pass: 12345678
|
||||
minio_pass: FeF4qA6uQBHeRd
|
||||
bucketName: physical
|
||||
#分布式锁配置
|
||||
redisson:
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.jeecg.modules.database.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -30,6 +31,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 试验报告
|
||||
@@ -81,10 +83,10 @@ public class ExperimentReportController extends JeecgController<ExperimentReport
|
||||
}
|
||||
Page<ExperimentReport> page = new Page<>(pageNo, pageSize);
|
||||
IPage<ExperimentReport> pageList = experimentReportService.join(page, experimentReport, queryWrapper);
|
||||
pageList.getRecords().forEach(v -> {
|
||||
ExperimentDoc experimentDoc = experimentDocService.getByExperimentId(v.getExperimentId(), ExperimentDocType.sybg.getType());
|
||||
v.setFileUrl(Optional.ofNullable(experimentDoc).map(ExperimentDoc::getFilePath).orElse(null));
|
||||
});
|
||||
//pageList.getRecords().forEach(v -> {
|
||||
// ExperimentDoc experimentDoc = experimentDocService.getByExperimentId(v.getExperimentId(), ExperimentDocType.sybg.getType());
|
||||
// v.setFileUrl(Optional.ofNullable(experimentDoc).map(ExperimentDoc::getFilePath).orElse(null));
|
||||
//});
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@@ -114,7 +116,17 @@ public class ExperimentReportController extends JeecgController<ExperimentReport
|
||||
//if (ObjUtil.isNotNull(report)) {
|
||||
// return Result.error("试验报告已存在!");
|
||||
//}
|
||||
experimentReport.setReportName(experiment.getName() + "-试验报告");
|
||||
String sampleInfo = experimentReport.getSampleInfo();
|
||||
String fileName = experiment.getName();
|
||||
if (StringUtils.isNotBlank(sampleInfo)) {
|
||||
List<Map> sampleList = JSON.parseArray(sampleInfo, Map.class);
|
||||
String modelBatch = sampleList.stream().map(v -> String.valueOf(v.getOrDefault("modelBatch", ""))).collect(
|
||||
Collectors.joining("-"));
|
||||
String sampleName = sampleList.stream().map(v -> String.valueOf(v.getOrDefault("sampleName", ""))).collect(
|
||||
Collectors.joining("-"));
|
||||
fileName = sampleName + "-" + modelBatch;
|
||||
}
|
||||
experimentReport.setReportName("试验报告-" + fileName);
|
||||
experimentReportService.save(experimentReport);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
@@ -192,9 +204,9 @@ public class ExperimentReportController extends JeecgController<ExperimentReport
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
|
||||
ExperimentDoc experimentDoc = experimentDocService.getByExperimentId(experimentReport.getExperimentId(),
|
||||
ExperimentDocType.sybg.getType());
|
||||
experimentReport.setFileUrl(Optional.ofNullable(experimentDoc).map(ExperimentDoc::getFilePath).orElse(null));
|
||||
//ExperimentDoc experimentDoc = experimentDocService.getByExperimentId(experimentReport.getExperimentId(),
|
||||
// ExperimentDocType.sybg.getType());
|
||||
//experimentReport.setFileUrl(Optional.ofNullable(experimentDoc).map(ExperimentDoc::getFilePath).orElse(null));
|
||||
return Result.OK(experimentReport);
|
||||
}
|
||||
|
||||
@@ -213,10 +225,10 @@ public class ExperimentReportController extends JeecgController<ExperimentReport
|
||||
if (CollUtil.isEmpty(experimentReport)) {
|
||||
return Result.ok();
|
||||
}
|
||||
experimentReport.forEach(v -> {
|
||||
ExperimentDoc experimentDoc = experimentDocService.getByExperimentId(experimentId, ExperimentDocType.sybg.getType());
|
||||
v.setFileUrl(Optional.ofNullable(experimentDoc).map(ExperimentDoc::getFilePath).orElse(null));
|
||||
});
|
||||
//experimentReport.forEach(v -> {
|
||||
// ExperimentDoc experimentDoc = experimentDocService.getByExperimentId(experimentId, ExperimentDocType.sybg.getType());
|
||||
// v.setFileUrl(Optional.ofNullable(experimentDoc).map(ExperimentDoc::getFilePath).orElse(null));
|
||||
//});
|
||||
|
||||
return Result.OK(experimentReport);
|
||||
}
|
||||
@@ -309,10 +321,12 @@ public class ExperimentReportController extends JeecgController<ExperimentReport
|
||||
} else {
|
||||
return Result.error("实验报告状态异常!");
|
||||
}
|
||||
experimentReportService.updateById(report);
|
||||
if (StringUtils.equals(report.getStatus(), ExperimentReportStatus.PASSED)) {
|
||||
experimentDocService.generate(report.getExperimentId(), ExperimentDocType.sybg.getType());
|
||||
ExperimentDoc generate = experimentDocService.generate(report.getExperimentId(), ExperimentDocType.sybg.getType());
|
||||
String filePath = generate.getFilePath();
|
||||
report.setFileUrl(filePath);
|
||||
}
|
||||
experimentReportService.updateById(report);
|
||||
|
||||
return Result.OK("审核成功!");
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package org.jeecg.modules.database.dto;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -39,4 +41,24 @@ public class RadiationMapDTO implements Serializable {
|
||||
*/
|
||||
private List<RadiationDetailDTO> proton;
|
||||
|
||||
public List<RadiationDetailDTO> assembleDetails() {
|
||||
List<RadiationDetailDTO> allList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(getXgy())) {
|
||||
allList.addAll(getXgy());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(getDgy())) {
|
||||
allList.addAll(getDgy());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(getX())) {
|
||||
allList.addAll(getX());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(getElectronics())) {
|
||||
allList.addAll(getElectronics());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(getProton())) {
|
||||
allList.addAll(getProton());
|
||||
}
|
||||
return allList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package org.jeecg.modules.database.entity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -12,6 +10,9 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 试验报告 @Author: jeecg-boot @Date: 2024-10-23 @Version: V1.0
|
||||
*/
|
||||
@@ -23,76 +24,106 @@ import org.springframework.format.annotation.DateTimeFormat;
|
||||
public class ExperimentReport implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
|
||||
/** 创建人 */
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Schema(description = "创建人")
|
||||
private String createBy;
|
||||
|
||||
/** 创建日期 */
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "创建日期")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新人 */
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@Schema(description = "更新人")
|
||||
private String updateBy;
|
||||
|
||||
/** 更新日期 */
|
||||
/**
|
||||
* 更新日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
|
||||
@Schema(description = "更新日期")
|
||||
private Date updateTime;
|
||||
|
||||
/** 所属部门 */
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
@Schema(description = "所属部门")
|
||||
private String sysOrgCode;
|
||||
|
||||
/** 试验ID */
|
||||
/**
|
||||
* 试验ID
|
||||
*/
|
||||
@Excel(name = "试验ID", width = 15)
|
||||
@Schema(description = "试验ID")
|
||||
private String experimentId;
|
||||
|
||||
/** 样品信息 */
|
||||
/**
|
||||
* 样品信息
|
||||
*/
|
||||
@Excel(name = "样品信息", width = 15)
|
||||
@Schema(description = "样品信息")
|
||||
private String sampleInfo;
|
||||
|
||||
/** 偏置原理图 */
|
||||
/**
|
||||
* 偏置原理图
|
||||
*/
|
||||
@Excel(name = "偏置原理图", width = 15)
|
||||
@Schema(description = "偏置原理图")
|
||||
private String imgUrls;
|
||||
|
||||
/** 偏置原理说明 */
|
||||
/**
|
||||
* 偏置原理说明
|
||||
*/
|
||||
@Excel(name = "偏置原理说明", width = 15)
|
||||
@Schema(description = "偏置原理说明")
|
||||
private String description;
|
||||
|
||||
/** 审核员 */
|
||||
/**
|
||||
* 审核员
|
||||
*/
|
||||
@Excel(name = "审核员", width = 15)
|
||||
@Schema(description = "审核员")
|
||||
private String auditor;
|
||||
|
||||
/** 校对员 */
|
||||
/**
|
||||
* 校对员
|
||||
*/
|
||||
@Excel(name = "校对员", width = 15)
|
||||
@Schema(description = "校对员")
|
||||
private String proofreader;
|
||||
|
||||
/** 确认员 */
|
||||
/**
|
||||
* 确认员
|
||||
*/
|
||||
@Excel(name = "确认员", width = 15)
|
||||
@Schema(description = "确认员")
|
||||
private String confirmer;
|
||||
|
||||
/** 报告名称 */
|
||||
/**
|
||||
* 报告名称
|
||||
*/
|
||||
@Excel(name = "报告名称", width = 15)
|
||||
@Schema(description = "报告名称")
|
||||
private String reportName;
|
||||
|
||||
/** 状态 */
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@Excel(name = "状态", width = 15)
|
||||
@Schema(
|
||||
description =
|
||||
@@ -103,7 +134,6 @@ public class ExperimentReport implements Serializable {
|
||||
@Schema(description = "上一个状态")
|
||||
private String lastStatus;
|
||||
|
||||
|
||||
@Excel(name = "审批意见", width = 15)
|
||||
@Schema(description = "审批意见")
|
||||
private String auditorMemo;
|
||||
@@ -128,7 +158,7 @@ public class ExperimentReport implements Serializable {
|
||||
@Schema(description = "批准时间")
|
||||
private String confirmerTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "生成的文件路径")
|
||||
private String fileUrl;
|
||||
|
||||
@TableField(exist = false)
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface IExperimentReportService extends IService<ExperimentReport> {
|
||||
List<ExperimentReport> getByExperimentId(String experimentId);
|
||||
List<ExperimentReport> getPassedByExperimentId(String experimentId);
|
||||
|
||||
ExperimentReport getLatestReport(String experimentId);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.file.PathUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.alibaba.fastjson.*;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -110,10 +111,10 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
|
||||
|
||||
// 插入当前页码字段
|
||||
run = paragraph.createRun();
|
||||
run.getCTR().addNewFldChar().setFldCharType(org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType.BEGIN);
|
||||
run.getCTR().addNewFldChar().setFldCharType(STFldCharType.BEGIN);
|
||||
run.getCTR().addNewInstrText().setStringValue("PAGE");
|
||||
run.getCTR().addNewFldChar().setFldCharType(org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType.SEPARATE);
|
||||
run.getCTR().addNewFldChar().setFldCharType(org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType.END);
|
||||
run.getCTR().addNewFldChar().setFldCharType(STFldCharType.SEPARATE);
|
||||
run.getCTR().addNewFldChar().setFldCharType(STFldCharType.END);
|
||||
|
||||
// 添加文本“页,共”
|
||||
run = paragraph.createRun();
|
||||
@@ -121,10 +122,10 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
|
||||
|
||||
// 插入总页数字段
|
||||
run = paragraph.createRun();
|
||||
run.getCTR().addNewFldChar().setFldCharType(org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType.BEGIN);
|
||||
run.getCTR().addNewFldChar().setFldCharType(STFldCharType.BEGIN);
|
||||
run.getCTR().addNewInstrText().setStringValue("NUMPAGES");
|
||||
run.getCTR().addNewFldChar().setFldCharType(org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType.SEPARATE);
|
||||
run.getCTR().addNewFldChar().setFldCharType(org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType.END);
|
||||
run.getCTR().addNewFldChar().setFldCharType(STFldCharType.SEPARATE);
|
||||
run.getCTR().addNewFldChar().setFldCharType(STFldCharType.END);
|
||||
|
||||
// 添加文本“页(含封面)”
|
||||
run = paragraph.createRun();
|
||||
@@ -164,33 +165,8 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
|
||||
throw new RuntimeException("实验数据不存在!");
|
||||
}
|
||||
String tmpDirPath = FileUtil.getTmpDirPath();
|
||||
String outputFile = tmpDirPath + File.separator + fileName + "-" + experimentId + "-" + version + ".docx";
|
||||
if (FileUtil.exist(outputFile)) {
|
||||
FileUtil.del(outputFile);
|
||||
}
|
||||
log.info("output file path: " + outputFile);
|
||||
assembleParams(experimentId, fileName, outputFile);
|
||||
//XWPFTemplate render = XWPFTemplate.compile(absolutePath).render(params);
|
||||
//render.writeToFile(outputFile);
|
||||
/* NiceXWPFDocument document = render.getXWPFDocument();
|
||||
//render
|
||||
//.writeToFile(outputFile);
|
||||
//XWPFDocument document = WordExportUtil.exportWord07(absolutePath, params);
|
||||
|
||||
List<XWPFHeader> headers = document.getHeaderList();
|
||||
|
||||
// 遍历所有节,确保每个节的页眉都添加了页码
|
||||
for (XWPFHeader h : headers) {
|
||||
// 添加页码到每个节的页眉
|
||||
//addPageNumberToHeader("报告编号:" + experiment.getExperimentNo(), h);
|
||||
}
|
||||
|
||||
try (FileOutputStream out = new FileOutputStream(outputFile)) {
|
||||
document.write(out);
|
||||
}
|
||||
document.close();*/
|
||||
String path = MinioUtil.upload(FileUtil.getInputStream(outputFile),
|
||||
"experiment_doc/" + experimentId + "/" + version + "/" + experiment.getName() + "-" + fileName + ".docx");
|
||||
String path = generateUpload(experimentId, fileName, version, tmpDirPath);
|
||||
return path;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
@@ -199,40 +175,81 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> assembleParams(String experimentId, String type, String outputFile) throws IOException {
|
||||
private String generateUpload(String experimentId, String type, String version, String tmpDirPath) throws Exception {
|
||||
String absolutePath = templatePath + File.separator + docTempalteMap.get(type);
|
||||
Experiment experiment = experimentService.getById(experimentId);
|
||||
switch (type) {
|
||||
case "辐照试验计划表":
|
||||
Map<String, Object> jhparams = assembleFzsyjhb(experimentId);
|
||||
XWPFTemplate jhrender = XWPFTemplate.compile(absolutePath).render(jhparams);
|
||||
jhrender.writeToFile(outputFile);
|
||||
break;
|
||||
String outputFile1 = tmpDirPath + File.separator + type + "-" + experimentId + "-" + version + ".docx";
|
||||
if (FileUtil.exist(outputFile1)) {
|
||||
FileUtil.del(outputFile1);
|
||||
}
|
||||
jhrender.writeToFile(outputFile1);
|
||||
return MinioUtil.upload(FileUtil.getInputStream(outputFile1),
|
||||
"experiment_doc/" + experimentId + "/" + version + "/" + experiment.getName() + "-" + type + ".docx");
|
||||
case "试验报告评审表":
|
||||
Map<String, Object> psparams = assembleSybgpsb(experimentId);
|
||||
XWPFTemplate psrender = XWPFTemplate.compile(absolutePath).render(psparams);
|
||||
psrender.writeToFile(outputFile);
|
||||
break;
|
||||
String outputFile2 = tmpDirPath + File.separator + type + "-" + experimentId + "-" + version + ".docx";
|
||||
if (FileUtil.exist(outputFile2)) {
|
||||
FileUtil.del(outputFile2);
|
||||
}
|
||||
psrender.writeToFile(outputFile2);
|
||||
return MinioUtil.upload(FileUtil.getInputStream(outputFile2),
|
||||
"experiment_doc/" + experimentId + "/" + version + "/" + experiment.getName() + "-" + type + ".docx");
|
||||
case "设备使用记录表":
|
||||
Map<String, Object> sbParams = assembleSbsyjlb(experimentId);
|
||||
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||
Configure config = Configure.builder().bind("equipment", policy).build();
|
||||
XWPFTemplate template = XWPFTemplate.compile(absolutePath, config).render(sbParams);
|
||||
template.writeToFile(outputFile);
|
||||
break;
|
||||
String outputFile3 = tmpDirPath + File.separator + type + "-" + experimentId + "-" + version + ".docx";
|
||||
if (FileUtil.exist(outputFile3)) {
|
||||
FileUtil.del(outputFile3);
|
||||
}
|
||||
template.writeToFile(outputFile3);
|
||||
return MinioUtil.upload(FileUtil.getInputStream(outputFile3),
|
||||
"experiment_doc/" + experimentId + "/" + version + "/" + experiment.getName() + "-" + type + ".docx");
|
||||
case "试验报告":
|
||||
Map<String, Object> params = assembleSybg(experimentId);
|
||||
List<ExperimentReport> reportList = experimentReportService.getPassedByExperimentId(experimentId);
|
||||
List<String> pathList = new ArrayList<>();
|
||||
|
||||
String outputDir = tmpDirPath + type + File.separator + experimentId + File.separator + version;
|
||||
if (FileUtil.exist(outputDir)) {
|
||||
FileUtil.del(outputDir);
|
||||
}
|
||||
if (!FileUtil.exist(outputDir)) {
|
||||
FileUtil.mkdir(outputDir);
|
||||
}
|
||||
for (ExperimentReport experimentReport : reportList) {
|
||||
Map<String, Object> params = assembleSybg(experimentId, experimentReport);
|
||||
XWPFTemplate render = XWPFTemplate.compile(absolutePath).render(params);
|
||||
render.writeToFile(outputFile);
|
||||
break;
|
||||
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");
|
||||
pathList.add(reportPath);
|
||||
}
|
||||
File zip = ZipUtil.zip(outputDir);
|
||||
String zipPath = MinioUtil.upload(FileUtil.getInputStream(zip),
|
||||
"experiment_doc/" + experimentId + "/" + version + "/" + type + "-" + experiment.getName() + ".zip");
|
||||
|
||||
return zipPath;
|
||||
case "辐照试验总结单":
|
||||
Map<String, Object> zjdParams = assembleFzsyzjd(experimentId);
|
||||
LoopRowTableRenderPolicy zjdpolicy = new LoopRowTableRenderPolicy();
|
||||
Configure zjdconfig = Configure.builder().bind("sample", zjdpolicy).build();
|
||||
XWPFTemplate zjdtemplate = XWPFTemplate.compile(absolutePath, zjdconfig).render(zjdParams);
|
||||
zjdtemplate.writeToFile(outputFile);
|
||||
break;
|
||||
String outputFile5 = tmpDirPath + File.separator + type + "-" + experimentId + "-" + version + ".docx";
|
||||
if (FileUtil.exist(outputFile5)) {
|
||||
FileUtil.del(outputFile5);
|
||||
}
|
||||
return new HashMap<>();
|
||||
zjdtemplate.writeToFile(outputFile5);
|
||||
return MinioUtil.upload(FileUtil.getInputStream(outputFile5),
|
||||
"experiment_doc/" + experimentId + "/" + version + "/" + experiment.getName() + "-" + type + ".docx");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Map<String, Object> assembleFzsyzjd(String experimentId) {
|
||||
@@ -259,7 +276,26 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
|
||||
root.put("编制人员姓名", Optional.ofNullable(sysUserService.getUserByName(experiment.getCreateBy())).map(SysUser::getRealname)
|
||||
.orElse(""));
|
||||
List<Map<String, Object>> sampleList = new ArrayList<>();
|
||||
List<ExperimentSampleInfo> sampleInfoList = experiment.getSampleInfoList();
|
||||
|
||||
for (ExperimentRadiationProcess radiationProcess : radiationProcessList) {
|
||||
List<ExperimentSampleInfo> sampleInfoList = radiationProcess.getSampleInfoList();
|
||||
String radiationDetailJson = radiationProcess.getRadiationDetail();
|
||||
OptionalDouble maxPoint = OptionalDouble.empty();
|
||||
OptionalDouble maxRate = OptionalDouble.empty();
|
||||
if (StringUtils.isNotBlank(radiationDetailJson)) {
|
||||
RadiationMapDTO radiationMap = JSON.parseObject(radiationDetailJson, RadiationMapDTO.class);
|
||||
List<RadiationDetailDTO> detailDTOList = radiationMap.assembleDetails();
|
||||
maxPoint = detailDTOList.stream().map(obj -> obj.getPoint()) // 获取point字段
|
||||
.filter(point -> StringUtils.isNotBlank(point))
|
||||
.filter(str -> str.matches("-?\\d+(\\.\\d+)?")) // 只保留数字格式的字符串
|
||||
.mapToDouble(Double::parseDouble) // 转换为double
|
||||
.max();
|
||||
maxRate = detailDTOList.stream().map(obj -> obj.getActualMeasurementRate()) // 获取point字段
|
||||
.filter(point -> StringUtils.isNotBlank(point))
|
||||
.filter(str -> str.matches("-?\\d+(\\.\\d+)?")) // 只保留数字格式的字符串
|
||||
.mapToDouble(Double::parseDouble) // 转换为double
|
||||
.max();
|
||||
}
|
||||
for (int i = 0; i < sampleInfoList.size(); i++) {
|
||||
ExperimentSampleInfo sampleInfo = sampleInfoList.get(i);
|
||||
Map<String, Object> sample = new HashMap<>();
|
||||
@@ -269,34 +305,36 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
|
||||
sample.put("样品类型", sampleInfo.getSampleType());
|
||||
sample.put("样品批次", sampleInfo.getSampleBatch());
|
||||
sample.put("样品编号", sampleInfo.getModelBatch());
|
||||
sample.put("注量率", "");
|
||||
sample.put("总剂量", "");
|
||||
sample.put("注量率", maxRate.orElse(0));
|
||||
sample.put("总剂量", maxPoint.orElse(0));
|
||||
sampleList.add(sample);
|
||||
}
|
||||
}
|
||||
root.put("sample", sampleList);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private Map<String, Object> assembleSybg(String experimentId) {
|
||||
private Map<String, Object> assembleSybg(String experimentId, ExperimentReport experimentReport) {
|
||||
Experiment experiment = experimentService.getById(experimentId);
|
||||
experimentService.fetchExperimentDetail(experiment);
|
||||
if (Objects.isNull(experiment)) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
ExperimentReport latestReport = experimentReportService.getLatestReport(experimentId);
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
if (Objects.nonNull(latestReport)) {
|
||||
params.put("审核人员姓名", Optional.ofNullable(sysUserService.getById(latestReport.getAuditor())).map(SysUser::getRealname)
|
||||
if (Objects.nonNull(experimentReport)) {
|
||||
params.put("审核人员姓名", Optional.ofNullable(sysUserService.getById(experimentReport.getAuditor())).map(SysUser::getRealname)
|
||||
.orElse(""));
|
||||
params.put("校对人员姓名", Optional.ofNullable(sysUserService.getById(latestReport.getProofreader())).map(SysUser::getRealname)
|
||||
params.put("校对人员姓名", Optional.ofNullable(sysUserService.getById(experimentReport.getProofreader()))
|
||||
.map(SysUser::getRealname)
|
||||
.orElse(""));
|
||||
params.put("批准人员姓名", Optional.ofNullable(sysUserService.getById(latestReport.getConfirmer())).map(SysUser::getRealname)
|
||||
params.put("批准人员姓名", Optional.ofNullable(sysUserService.getById(experimentReport.getConfirmer()))
|
||||
.map(SysUser::getRealname)
|
||||
.orElse(""));
|
||||
params.put("报告生成日期", formatDate(latestReport.getCreateTime()));
|
||||
params.put("批准日期", latestReport.getConfirmerTime());
|
||||
params.put("校对日期", latestReport.getProofreaderTime());
|
||||
params.put("审核日期", latestReport.getAuditorTime());
|
||||
params.put("报告生成日期", formatDate(experimentReport.getCreateTime()));
|
||||
params.put("批准日期", experimentReport.getConfirmerTime());
|
||||
params.put("校对日期", experimentReport.getProofreaderTime());
|
||||
params.put("审核日期", experimentReport.getAuditorTime());
|
||||
|
||||
}
|
||||
params.put("试验报告名称", experiment.getName());
|
||||
@@ -325,8 +363,8 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
|
||||
params.put("测试环境温度", experimentTestProcess.getEnvironmentalTemperature());
|
||||
params.put("测试环境湿度", experimentTestProcess.getEnvironmentalHumidity());
|
||||
}
|
||||
if (Objects.nonNull(latestReport)) {
|
||||
String sampleInfo = latestReport.getSampleInfo();
|
||||
if (Objects.nonNull(experimentReport)) {
|
||||
String sampleInfo = experimentReport.getSampleInfo();
|
||||
if (StringUtils.isNotBlank(sampleInfo)) {
|
||||
List<JSONObject> sampleInfoList = JSON.parseArray(sampleInfo, JSONObject.class);
|
||||
if (CollUtil.isNotEmpty(sampleInfoList)) {
|
||||
@@ -391,8 +429,8 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
|
||||
params.put("辐照总注量", experiment.getExperimentNo());
|
||||
params.put("实际能量", experiment.getExperimentNo());
|
||||
|
||||
if (Objects.nonNull(latestReport)) {
|
||||
String imgUrls = latestReport.getImgUrls();
|
||||
if (Objects.nonNull(experimentReport)) {
|
||||
String imgUrls = experimentReport.getImgUrls();
|
||||
if (!StringUtils.startsWith(imgUrls, "http")) {
|
||||
imgUrls = "http://" + serverIp + imgUrls;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ public class ExperimentReportServiceImpl extends ServiceImpl<ExperimentReportMap
|
||||
@Override
|
||||
public List<ExperimentReport> getByExperimentId(String experimentId) {
|
||||
return list(new LambdaQueryWrapper<ExperimentReport>().eq(ExperimentReport::getExperimentId, experimentId));
|
||||
} @Override
|
||||
public List<ExperimentReport> getPassedByExperimentId(String experimentId) {
|
||||
return list(new LambdaQueryWrapper<ExperimentReport>().eq(ExperimentReport::getExperimentId, experimentId).eq(ExperimentReport::getStatus,ExperimentReportStatus.PASSED));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user