This commit is contained in:
ls
2025-02-09 19:40:50 +08:00
parent df96bfecff
commit 1c1856b0ea
7 changed files with 103 additions and 53 deletions

View File

@@ -287,16 +287,6 @@
</dependency> </dependency>
<!-- AutoPoi Excel工具类--> <!-- AutoPoi Excel工具类-->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<dependency> <dependency>
<groupId>org.jeecgframework.boot3</groupId> <groupId>org.jeecgframework.boot3</groupId>
<artifactId>autopoi-web</artifactId> <artifactId>autopoi-web</artifactId>
@@ -374,6 +364,16 @@
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-crypto</artifactId> <artifactId>hutool-crypto</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.jeecgframework.boot3</groupId>
<artifactId>autopoi</artifactId>
<version>3.7.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.deepoove</groupId>
<artifactId>poi-tl</artifactId>
<version>1.12.2</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -1,4 +1,5 @@
server: server:
ip: 47.102.126.67
port: 8080 port: 8080
undertow: undertow:
# 平替 tomcat server.tomcat.max-swallow-siz undertow该值默认为-1 # 平替 tomcat server.tomcat.max-swallow-siz undertow该值默认为-1

View File

@@ -1,4 +1,5 @@
server: server:
ip: 47.102.126.67
port: 8080 port: 8080
undertow: undertow:
# 平替 tomcat server.tomcat.max-swallow-siz undertow该值默认为-1 # 平替 tomcat server.tomcat.max-swallow-siz undertow该值默认为-1

View File

@@ -14,20 +14,10 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>com.deepoove</groupId>
<artifactId>poi</artifactId> <artifactId>poi-tl</artifactId>
<version>4.1.2</version> <version>1.12.2</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.deepoove</groupId>-->
<!-- <artifactId>poi-tl</artifactId>-->
<!-- <version>1.12.2</version>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>org.jeecgframework.boot</groupId> <groupId>org.jeecgframework.boot</groupId>
<artifactId>physical-system-api</artifactId> <artifactId>physical-system-api</artifactId>

View File

@@ -5,8 +5,12 @@ import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.file.PathUtil; import cn.hutool.core.io.file.PathUtil;
import com.alibaba.fastjson.*;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.Tables;
import com.deepoove.poi.data.style.BorderStyle;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.*; import org.apache.poi.xwpf.usermodel.*;
@@ -17,16 +21,17 @@ import org.jeecg.modules.database.mapper.ExperimentDocMapper;
import org.jeecg.modules.database.service.*; import org.jeecg.modules.database.service.*;
import org.jeecg.modules.system.entity.SysUser; import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysUserService; import org.jeecg.modules.system.service.ISysUserService;
import org.jeecgframework.poi.word.WordExportUtil;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.*; import java.io.File;
import java.io.IOException;
import java.math.BigInteger; import java.math.BigInteger;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* @Description: 试验文档 * @Description: 试验文档
@@ -40,6 +45,8 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
@Value("${jeecg.template.path}") @Value("${jeecg.template.path}")
private String templatePath; private String templatePath;
@Value("${server.ip}")
private String serverIp;
@Autowired @Autowired
private IExperimentService experimentService; private IExperimentService experimentService;
@Autowired @Autowired
@@ -53,6 +60,8 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
@Autowired @Autowired
private IExperimentTestProcessService experimentTestProcessService; private IExperimentTestProcessService experimentTestProcessService;
@Autowired @Autowired
private IExperimentRadiationProcessService experimentRadiationProcessService;
@Autowired
private ITestStandardsService testStandardsService; private ITestStandardsService testStandardsService;
static Map<String, String> docTempalteMap = new HashMap<>(); static Map<String, String> docTempalteMap = new HashMap<>();
@@ -94,20 +103,25 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
} }
log.info("output file path: " + outputFile); log.info("output file path: " + outputFile);
Map<String, Object> params = assembleParams(experimentId, fileName); Map<String, Object> params = assembleParams(experimentId, fileName);
XWPFDocument document = WordExportUtil.exportWord07(absolutePath, params); XWPFTemplate render = XWPFTemplate.compile(absolutePath).render(params);
/* NiceXWPFDocument document = render.getXWPFDocument();
//render
//.writeToFile(outputFile);
//XWPFDocument document = WordExportUtil.exportWord07(absolutePath, params);
List<XWPFHeader> headers = document.getHeaderList(); List<XWPFHeader> headers = document.getHeaderList();
// 遍历所有节,确保每个节的页眉都添加了页码 // 遍历所有节,确保每个节的页眉都添加了页码
for (XWPFHeader h : headers) { for (XWPFHeader h : headers) {
// 添加页码到每个节的页眉 // 添加页码到每个节的页眉
addPageNumberToHeader("报告编号:" + experiment.getExperimentNo(), h); //addPageNumberToHeader("报告编号:" + experiment.getExperimentNo(), h);
} }
try (FileOutputStream out = new FileOutputStream(outputFile)) { try (FileOutputStream out = new FileOutputStream(outputFile)) {
document.write(out); document.write(out);
} }
document.close(); document.close();*/
render.writeToFile(outputFile);
String path = MinioUtil.upload(FileUtil.getInputStream(outputFile), String path = MinioUtil.upload(FileUtil.getInputStream(outputFile),
"experiment_doc/" + experimentId + "/" + version + "/" + experiment.getName() + "-" + fileName + ".docx"); "experiment_doc/" + experimentId + "/" + version + "/" + experiment.getName() + "-" + fileName + ".docx");
return path; return path;
@@ -213,33 +227,76 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
params.put("委托方单位地址", Optional.ofNullable(client).map(Client::getAddress).orElse("")); params.put("委托方单位地址", Optional.ofNullable(client).map(Client::getAddress).orElse(""));
List<ExperimentTestProcess> experimentTestProcesses = experimentTestProcessService.getByExperimentId(experiment.getId()); List<ExperimentTestProcess> experimentTestProcesses = experimentTestProcessService.getByExperimentId(experiment.getId());
if (CollUtil.isNotEmpty(experimentTestProcesses)) { if (CollUtil.isNotEmpty(experimentTestProcesses)) {
String testStandardsId = experimentTestProcesses.get(0).getTestStandardsId(); ExperimentTestProcess experimentTestProcess = experimentTestProcesses.get(0);
String testStandardsId = experimentTestProcess.getTestStandardsId();
Optional<TestStandards> testStandards = Optional.ofNullable(testStandardsService.getById(testStandardsId)); Optional<TestStandards> testStandards = Optional.ofNullable(testStandardsService.getById(testStandardsId));
params.put("标准代号", testStandards.map(TestStandards::getCode).orElse("")); params.put("标准代号", testStandards.map(TestStandards::getCode).orElse(""));
params.put("标准名称", testStandards.map(TestStandards::getName).orElse("")); params.put("标准名称", testStandards.map(TestStandards::getName).orElse(""));
Path lastPathEle = PathUtil.getLastPathEle(Path.of(testStandards.map(TestStandards::getAttachment).orElse("")).getFileName()); Path lastPathEle = PathUtil.getLastPathEle(Path.of(testStandards.map(TestStandards::getAttachment).orElse("")).getFileName());
params.put("依据的文件名称", lastPathEle.toString()); params.put("依据的文件名称", lastPathEle.toString());
String testParameters = experimentTestProcess.getTestParameters();
if (StringUtils.isNotBlank(testParameters)) {
JSONArray jsonObject = JSON.parseArray(testParameters);
String collect = jsonObject.stream().map(v -> ((JSONObject) v).getString("name")).collect(Collectors.joining(","));
params.put("测试参数", collect);
} }
params.put("样品名称", experiment.getExperimentNo()); params.put("测试环境温度", experimentTestProcess.getEnvironmentalTemperature());
params.put("样品型号", experiment.getExperimentNo()); params.put("测试环境湿度", experimentTestProcess.getEnvironmentalHumidity());
params.put("批次", experiment.getExperimentNo()); }
params.put("编号", experiment.getExperimentNo()); List<ExperimentSampleInfo> sampleInfoList = experiment.getSampleInfoList();
params.put("厂家名称", experiment.getExperimentNo()); if (CollUtil.isNotEmpty(sampleInfoList)) {
params.put("数量", experiment.getExperimentNo()); for (int i = 0; i < sampleInfoList.size(); i++) {
params.put("试验日期", experiment.getExperimentNo()); ExperimentSampleInfo info = sampleInfoList.get(i);
params.put("负责人名称", experiment.getExperimentNo()); params.put("table" + i, Tables.of(
params.put("剂量管理员名称", experiment.getExperimentNo()); new String[][] {new String[] {"试验样品名称", info.getSampleName(), "试验样品型号", info.getSampleModel()},
params.put("操作员名称", experiment.getExperimentNo()); new String[] {"批 次", info.getSampleBatch(), "试验样品编号", info.getSampleType()},
params.put("辐射源名称", experiment.getExperimentNo()); new String[] {"生产厂家", info.getSampleManufacturer(), "试验样品数量", sampleInfoList.size() + ""},
params.put("注量率", experiment.getExperimentNo()); new String[] {"放置地点", "", "接收日期", ""},}).border(BorderStyle.DEFAULT).create());
params.put("注量点", experiment.getExperimentNo()); }
params.put("总注量", experiment.getExperimentNo()); }
params.put("温度", experiment.getExperimentNo());
params.put("能量", experiment.getExperimentNo()); params.put("试验日期", experiment.getStartDate() + " ~ " + experiment.getEndDate());
params.put("偏置原理图", experiment.getExperimentNo()); params.put("负责人名称", experiment.getSupervisorName());
params.put("测试参数", experiment.getExperimentNo()); params.put("剂量管理员名称", "");
params.put("测试环境温度", experiment.getExperimentNo()); String operatorName = experiment.getExperimentUserList().stream().map(v -> v.getUserName()).collect(Collectors.joining(","));
params.put("测试环境湿度", experiment.getExperimentNo()); params.put("操作员名称", operatorName);
List<ExperimentRadiationProcess> radiationProcessList = experimentRadiationProcessService.getByExperimentId(experimentId);
if (CollUtil.isNotEmpty(radiationProcessList)) {
String name = radiationProcessList.stream().map(v -> v.getRadiationSource()).collect(Collectors.joining(","));
params.put("辐射源名称", name);
String lv = radiationProcessList.stream().map(v -> v.getMeasurementRate()).collect(Collectors.joining(","));
params.put("辐照注量率", lv);
params.put("累积注量点", "");
String temp = radiationProcessList.stream().map(v -> v.getEnvironmentalTemperature()).collect(Collectors.joining(","));
params.put("辐照环境温度", temp);
}
params.put("辐照总注量", experiment.getExperimentNo());
params.put("实际能量", experiment.getExperimentNo());
String imgUrls = latestReport.getImgUrls();
if (!StringUtils.startsWith(imgUrls, "http")) {
imgUrls = "http://" + serverIp + imgUrls;
}
params.put("偏置原理图", imgUrls);
List<ExperimentDeviationEquipment> deviationEquipmentList = experiment.getDeviationEquipmentList();
String[][] strings = new String[deviationEquipmentList.size() + 1][5];
strings[0] = new String[] {"序号", "名称", "编号", "计量有效期", "备注"};
if (CollUtil.isNotEmpty(deviationEquipmentList)) {
for (int i = 0; i < deviationEquipmentList.size(); i++) {
ExperimentDeviationEquipment deviationEquipment = deviationEquipmentList.get(i);
strings[i + 1] = new String[] {(i + 1) + "",
Optional.ofNullable(deviationEquipment.getEquipmentName()).orElse(""),
Optional.ofNullable(deviationEquipment.getEquipmentNo()).orElse(""),
Optional.ofNullable(deviationEquipment.getMeasurementValidity()).orElse(""),
Optional.ofNullable(deviationEquipment.getRoomNo()).orElse(""),
};
}
}
params.put("装置表格", Tables.of(strings).border(BorderStyle.DEFAULT).create());
return params; return params;
} }

View File

@@ -56,7 +56,7 @@
<java-jwt.version>3.11.0</java-jwt.version> <java-jwt.version>3.11.0</java-jwt.version>
<shiro-redis.version>3.2.2</shiro-redis.version> <shiro-redis.version>3.2.2</shiro-redis.version>
<codegenerate.version>1.4.9</codegenerate.version> <codegenerate.version>1.4.9</codegenerate.version>
<autopoi-web.version>1.4.11</autopoi-web.version> <autopoi-web.version>3.7.0</autopoi-web.version>
<minio.version>8.5.7</minio.version> <minio.version>8.5.7</minio.version>
<justauth-spring-boot-starter.version>1.4.0</justauth-spring-boot-starter.version> <justauth-spring-boot-starter.version>1.4.0</justauth-spring-boot-starter.version>
<dom4j.version>1.6.1</dom4j.version> <dom4j.version>1.6.1</dom4j.version>
@@ -72,6 +72,7 @@
<module>physical-base-core</module> <module>physical-base-core</module>
<module>physical-module-system</module> <module>physical-module-system</module>
<module>physical-launcher</module> <module>physical-launcher</module>
<module>autopoi</module>
</modules> </modules>
<repositories> <repositories>

Binary file not shown.