From d589bf94e8f1863336d23fdd951049622b64db68 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期五, 22 十一月 2024 16:36:43 +0800
Subject: [PATCH] csv文件调整

---
 inspect-server/src/main/java/com/yuanchu/mom/utils/WordUtils.java |   45 +++++++++++++--------------------------------
 1 files changed, 13 insertions(+), 32 deletions(-)

diff --git a/inspect-server/src/main/java/com/yuanchu/mom/utils/WordUtils.java b/inspect-server/src/main/java/com/yuanchu/mom/utils/WordUtils.java
index 598498c..50dabb3 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/utils/WordUtils.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/utils/WordUtils.java
@@ -25,6 +25,7 @@
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.STMerge;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
+
 import javax.annotation.Resource;
 import java.io.*;
 import java.nio.file.Files;
@@ -1486,22 +1487,13 @@
                 lable.getAndIncrement();
             });
         });
-        String url;
-        try {
-            ZipSecureFile.setMinInflateRatio(0.0001);
-            InputStream inputStream = this.getClass().getResourceAsStream("/static/word1.docx");
-            File file = File.createTempFile("temp", ".tmp");
-            OutputStream outputStream = new FileOutputStream(file);
-            IOUtils.copy(inputStream, outputStream);
-            url = file.getAbsolutePath();
-        } catch (FileNotFoundException e) {
-            throw new ErrorException("鎵句笉鍒版ā鏉挎枃浠�");
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
+
+        ZipSecureFile.setMinInflateRatio(0.0001);
+        InputStream inputStream = this.getClass().getResourceAsStream("/static/word1.docx");
+
         ConfigureBuilder builder = Configure.builder();
         builder.useSpringEL(true);
-        XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render(
+        XWPFTemplate template = XWPFTemplate.compile(inputStream, builder.build()).render(
                 new HashMap<String, Object>() {{
                     put("title", title);
                     put("tables", tables);
@@ -1519,7 +1511,7 @@
             FileInputStream stream = new FileInputStream(path);
             XWPFDocument document = new XWPFDocument(stream);
             List<XWPFTable> xwpfTables = document.getTables();
-            for (int i = 1; i < xwpfTables.size(); i++) {
+            for (int i = 0; i < xwpfTables.size(); i++) {
                 Set<String> set1 = new HashSet<>();
                 Map<String, Map<String, Integer>> maps = new HashMap<>();
                 for (int j = 0; j < xwpfTables.get(i).getRows().size(); j++) {
@@ -2089,20 +2081,8 @@
                 tables4.add(table4);
             }
         }
-
-        String url;
-        try {
-            ZipSecureFile.setMinInflateRatio(0.0001);
-            InputStream inputStream = this.getClass().getResourceAsStream("/static/report-template.docx");
-            File file = File.createTempFile("temp", ".tmp");
-            OutputStream outputStream = new FileOutputStream(file);
-            IOUtils.copy(inputStream, outputStream);
-            url = file.getAbsolutePath();
-        } catch (FileNotFoundException e) {
-            throw new ErrorException("鎵句笉鍒版ā鏉挎枃浠�");
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
+        ZipSecureFile.setMinInflateRatio(0.0001);
+        InputStream inputStream = this.getClass().getResourceAsStream("/static/report-template.docx");
         StringBuilder standardMethod2 = new StringBuilder();
         for (String s : standardMethod) {
             standardMethod2.append("锛沑n").append(s);
@@ -2138,7 +2118,9 @@
         List<Map<String, String>> finalDeviceList = deviceList;
         List<Map<String, String>> sampleList = insSampleMapper.selectSampleList(orderId);
         Integer userId = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery()
-                .eq(InsSampleUser::getInsSampleId, orderId).last("limit 1")).getUserId();
+                .eq(InsSampleUser::getInsSampleId, orderId)
+                .eq(InsSampleUser::getState,0)
+                .last("limit 1")).getUserId();
         String signatureUrl;
         try {
             signatureUrl = userMapper.selectById(userId).getSignatureUrl();
@@ -2180,7 +2162,7 @@
             title3 = "杈愬皠鏂瑰悜鍥惧弬鏁�";
         }
         String finalTitle = title3;
-        XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render(
+        XWPFTemplate template = XWPFTemplate.compile(inputStream, builder.build()).render(
                 new HashMap<String, Object>() {{
                     put("order", insOrder);
                     put("report", insReport);
@@ -3745,7 +3727,6 @@
             } else {
                 table.getRow(row).getCell(i).getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.CONTINUE);
             }
-
         }
     }
 

--
Gitblit v1.9.3