From f5041d3a0a706809bc351ff6d0694935f33abc9f Mon Sep 17 00:00:00 2001
From: value <z1292839451@163.com>
Date: 星期一, 15 四月 2024 07:17:11 +0800
Subject: [PATCH] 新增报告插入二维码
---
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
index 36c8f4a..41312ec 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -27,6 +27,8 @@
import com.yuanchu.mom.service.InsOrderService;
import com.yuanchu.mom.service.StandardTemplateService;
import com.yuanchu.mom.utils.GiveCode;
+import com.yuanchu.mom.utils.JackSonUtil;
+import com.yuanchu.mom.utils.MatrixToImageWriter;
import com.yuanchu.mom.utils.QueryWrappers;
import com.yuanchu.mom.vo.InsOrderPlanVO;
import org.apache.poi.xwpf.usermodel.TableRowAlign;
@@ -76,6 +78,9 @@
@Value("${wordUrl}")
private String wordUrl;
+
+ @Value("${twoCode}")
+ private String twoCode;
@Resource
private GiveCode giveCode;
@@ -419,6 +424,18 @@
table.put("tableSize", tables.size() + 1);
});
List<Map<String, String>> deviceList = insOrderMapper.selectDeviceList(deviceSet);
+ Map<String, String> codeStr = new HashMap<>();
+ codeStr.put("鎶ュ憡缂栧彿", insReport.getCode());
+ codeStr.put("鏍峰搧鍚嶇О", insOrder.getSample());
+ codeStr.put("瑙勬牸鍨嬪彿", samples.get(0).getModel());
+ codeStr.put("鍙戞斁鏃ユ湡", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+ String codePath;
+ try {
+ codePath = new MatrixToImageWriter().code(JackSonUtil.marshal(codeStr).replaceAll("\\{","")
+ .replaceAll("}","").replaceAll(",","").replaceAll("\"",""), twoCode);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
ConfigureBuilder builder = Configure.builder();
builder.useSpringEL(true);
XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render(
@@ -432,9 +449,10 @@
put("tableSize", tables.size() + 1);
put("standardMethod", standardMethod2);
put("deviceList", deviceList);
+ put("twoCode", Pictures.ofLocal(codePath).create());
}});
try {
- String name = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yy_MM_dd_HH_mm_ss")) + ".docx";
+ String name = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yy_MM_dd&HH_mm_ss")) + ".docx";
template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl + "/" + name)));
insReport.setUrl("/word/" + name);
insReportMapper.insert(insReport);
--
Gitblit v1.9.3