From a9015e429e40f83afdffd43552d34b82e67a75ff Mon Sep 17 00:00:00 2001
From: JYW <2013732181@qq.com>
Date: 星期一, 29 四月 2024 17:34:10 +0800
Subject: [PATCH] 2024-04-29 自定义注解,给每个接口加上自定义注解

---
 inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 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 15ca9f6..64038ac 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
@@ -276,16 +276,16 @@
             List<Map<String, Object>> tables = new ArrayList<>();
             Set<String> standardMethod = new HashSet<>();
             Set<String> deviceSet = new HashSet<>();
-            AtomicReference<String> models = new AtomicReference<>("");
+            Set<String> models = new HashSet<>();
             AtomicReference<Integer> productSize = new AtomicReference<>(0);
             String[] monthNames = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
             samples.forEach(a -> {
+                models.add(a.getModel());
                 Set<String> templateSet = new HashSet<>();
                 getTemplateThing(set, map2, a);
                 for (InsProduct b : a.getInsProduct()) {
-                    models.set(models.get()+b.getModel());
                     standardMethod.add(b.getMethodS());
-                    productSize.set(productSize.get()+1);
+                    productSize.set(productSize.get() + 1);
                     if (b.getInsProductResult() != null) {
                         List<JSONObject> jsonObjects = JSON.parseArray(b.getInsProductResult().getEquipValue(), JSONObject.class);
                         for (JSONObject jsonObject : jsonObjects) {
@@ -509,7 +509,8 @@
             String url;
             try {
                 InputStream inputStream = this.getClass().getResourceAsStream("/static/report-template.docx");
-                File file = File.createTempFile("temp", ".tmp");OutputStream outputStream = new FileOutputStream(file);
+                File file = File.createTempFile("temp", ".tmp");
+                OutputStream outputStream = new FileOutputStream(file);
                 IOUtils.copy(inputStream, outputStream);
                 url = file.getAbsolutePath();
             } catch (FileNotFoundException e) {
@@ -525,8 +526,7 @@
             tables.forEach(table -> {
                 table.put("tableSize", tables.size() + 1);
             });
-//            List<Map<String, String>> deviceList = insOrderMapper.selectDeviceList(deviceSet);
-            List<Map<String, String>> deviceList = new ArrayList<>();
+            List<Map<String, String>> deviceList = insOrderMapper.selectDeviceList(deviceSet);
             Map<String, String> codeStr = new HashMap<>();
             codeStr.put("鎶ュ憡缂栧彿", insReport.getCode());
             codeStr.put("鏍峰搧鍚嶇О", insOrder.getSample());
@@ -539,6 +539,11 @@
             } catch (Exception e) {
                 throw new RuntimeException(e);
             }
+            String modelStr = "";
+            for (String model : models) {
+                modelStr += "," + model;
+            }
+            String finalModelStr = modelStr;
             ConfigureBuilder builder = Configure.builder();
             builder.useSpringEL(true);
             XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render(
@@ -553,19 +558,19 @@
                         put("standardMethod", standardMethod2);
                         put("deviceList", deviceList);
                         put("twoCode", Pictures.ofLocal(codePath).create());
-                        put("models", models);
+                        put("models", finalModelStr.replace(",", ""));
                         put("productSize", productSize);
                         put("createTime", now.format(DateTimeFormatter.ofPattern("yyyy骞碝M鏈坉d鏃�")));
-                        put("createTimeEn", monthNames[now.getMonthValue()-1]+" "+now.getDayOfMonth()+", "+now.getYear());
+                        put("createTimeEn", monthNames[now.getMonthValue() - 1] + " " + now.getDayOfMonth() + ", " + now.getYear());
                         put("insTime", insOrder.getInsTime().format(DateTimeFormatter.ofPattern("yyyy骞碝M鏈坉d鏃�")));
-                        put("insTimeEn", monthNames[insOrder.getInsTime().getMonthValue()-1]+" "+now.getDayOfMonth()+", "+now.getYear());
+                        put("insTimeEn", monthNames[insOrder.getInsTime().getMonthValue() - 1] + " " + now.getDayOfMonth() + ", " + now.getYear());
                         put("writeUrl", null);
                         put("insUrl", null);
                         put("examineUrl", null);
                         put("ratifyUrl", null);
                     }});
             try {
-                String name = now.format(DateTimeFormatter.ofPattern("yy_MM_dd&HH_mm_ss")) + ".docx";
+                String name = insReport.getCode().replace("/", "") + ".docx";
                 template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl + "/" + name)));
                 insReport.setUrl("/word/" + name);
                 insReportMapper.insert(insReport);
@@ -598,6 +603,7 @@
                 style.put("columnlen", config.get("columnlen"));
                 product.setTemplate(cellData);
                 product.setStyle(style);
+                product.setTemplateName(standardTemplateService.getStandTempNameById(product.getTemplateId()));
             }
         }
     }

--
Gitblit v1.9.3