From 01af9cb1c94e459184ad4d9836662094f14bac7e Mon Sep 17 00:00:00 2001
From: value <z1292839451@163.com>
Date: 星期二, 16 四月 2024 00:15:27 +0800
Subject: [PATCH] 增加标准对于产品标准的区分,修复若干其她bug

---
 inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java |   22 +++++++++++++++++++++-
 1 files changed, 21 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..85b7357 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,12 +449,15 @@
                         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);
+                insOrder.setState(4);
+                insOrderMapper.updateById(insOrder);
             } catch (IOException e) {
                 throw new RuntimeException(e);
             }

--
Gitblit v1.9.3