From 032e88451cc03c781401e3feef14057f9cff6f94 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期四, 27 二月 2025 13:43:13 +0800
Subject: [PATCH] 近场报告解析添加指标+平均值保留两位小数+检测依据不加9410

---
 inspect-server/src/main/java/com/yuanchu/mom/utils/FuSheUtils.java |  601 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 545 insertions(+), 56 deletions(-)

diff --git a/inspect-server/src/main/java/com/yuanchu/mom/utils/FuSheUtils.java b/inspect-server/src/main/java/com/yuanchu/mom/utils/FuSheUtils.java
index b95e6fa..82d6a42 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/utils/FuSheUtils.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/utils/FuSheUtils.java
@@ -1,17 +1,21 @@
 package com.yuanchu.mom.utils;
 
+import cn.hutool.core.lang.UUID;
 import com.deepoove.poi.XWPFTemplate;
 import com.deepoove.poi.config.Configure;
 import com.deepoove.poi.config.ConfigureBuilder;
 import com.deepoove.poi.data.*;
 import com.deepoove.poi.data.style.*;
 import com.deepoove.poi.util.TableTools;
+import com.opencsv.CSVReader;
 import com.yuanchu.mom.dto.Exceldata;
 import com.yuanchu.mom.exception.ErrorException;
 import com.yuanchu.mom.mapper.InsOrderFileMapper;
 import com.yuanchu.mom.mapper.InsOrderMapper;
+import com.yuanchu.mom.mapper.InsSampleMapper;
 import com.yuanchu.mom.pojo.InsOrder;
 import com.yuanchu.mom.pojo.InsOrderFile;
+import com.yuanchu.mom.pojo.InsSample;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.openxml4j.util.ZipSecureFile;
@@ -27,8 +31,6 @@
 
 import javax.annotation.Resource;
 import java.io.*;
-import java.nio.file.Files;
-import java.nio.file.Paths;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -43,9 +45,10 @@
     InsOrderFileMapper insOrderFileMapper;
 
     @Resource
-    InsOrderMapper insOrderMapper;
+    InsSampleMapper insSampleMapper;
 
-    public void getFuSheWord(String sonLaboratory, InsOrderFile insOrderFile) {
+    //杩戝満
+    public void getFuSheWord1(String sonLaboratory, InsOrderFile insOrderFile) {
         //璇诲彇excel鏂囦欢鍐呭
         String excelFilePath = wordUrl + "/" + insOrderFile.getFileUrl(); // 鏇存柊涓轰綘鐨勬枃浠惰矾寰�
         FileInputStream fileInputStream = null;
@@ -57,6 +60,8 @@
             Exceldata exceldata = new Exceldata();
             Map<Integer, Object> project = new HashMap<>();
             HashMap<String, Object> datas1 = new HashMap<>();
+            HashMap<String, Object> biaozhun = new HashMap<>();
+            Boolean exitLoop = false;
             for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
                 String s = "";
                 Sheet sheet = workbook.getSheetAt(i);
@@ -86,22 +91,55 @@
                                     default:
                                         System.out.print("NULL\t");
                                 }
-                            } else {
+                            }
+                            else {
                                 switch (cell.getCellType()) {
                                     case STRING:
-                                        if (StringUtils.isNotEmpty(s)) {
-                                            datas.put(s, list);
+                                        if (cell.getColumnIndex() == 1) {
+                                            if (cell.getStringCellValue().equals("鎸囨爣")) {
+                                                for (Cell cell1 : row) {
+                                                    switch (cell1.getCellType()) {
+                                                        case STRING:
+                                                            biaozhun.put(project.get(cell1.getColumnIndex()).toString(), cell1.getStringCellValue());
+                                                            break;
+                                                        case NUMERIC:
+                                                            System.out.print(cell1.getNumericCellValue() + "\t");
+                                                            break;
+                                                        case BOOLEAN:
+                                                            System.out.print(cell1.getBooleanCellValue() + "\t");
+                                                            break;
+                                                        case FORMULA:
+                                                            System.out.print(cell1.getCellFormula() + "\t");
+                                                            break;
+                                                        default:
+                                                            System.out.print("NULL\t");
+                                                    }
+                                                }
+                                            }
+                                            exitLoop = true;
+                                            break;
                                         }
-                                        list = new ArrayList<>();
-                                        s = cell.getStringCellValue();
-                                        datas.put(s, cell.getStringCellValue());
-                                        System.out.print(cell.getStringCellValue() + "\t");
+                                        String value = "zss";
+                                        switch (row.getCell(1).getCellType()){
+                                            case STRING:
+                                                value = cell.getStringCellValue();
+                                                break;
+                                        }
+                                        if (value.equals("zss")){
+                                            if (StringUtils.isNotEmpty(s)) {
+                                                datas.put(s, list);
+                                            }
+                                            list = new ArrayList<>();
+                                            s = cell.getStringCellValue();
+                                            datas.put(s, cell.getStringCellValue());
+                                            System.out.print(cell.getStringCellValue() + "\t");
+                                        }
                                         break;
                                     case NUMERIC:
-                                        int columnIndex = cell.getColumnIndex();
-                                        Object o = project.get(columnIndex);
-                                        map.put(o.toString(), cell.getNumericCellValue());
-                                        System.out.print(cell.getNumericCellValue() + "\t");
+                                            int columnIndex = cell.getColumnIndex();
+                                            Object o = project.get(columnIndex);
+                                            map.put(o.toString(), cell.getNumericCellValue());
+                                            System.out.print(cell.getNumericCellValue() + "\t");
                                         break;
                                     case BOOLEAN:
                                         System.out.print(cell.getBooleanCellValue() + "\t");
@@ -113,12 +151,17 @@
                                         System.out.print("NULL\t");
                                 }
                             }
+                            if (exitLoop) {
+                                exitLoop = false;
+                                break;
+                            }
                             if (map.isEmpty()) {
                                 list.add(map);
                             }
                         }
                     }
                 }
+                list=list.stream().filter(map -> !map.isEmpty()).collect(Collectors.toList());
                 datas.put(s, list);
                 map1.put(sheetName, datas);
                 datas1.putAll(map1);
@@ -126,7 +169,6 @@
             exceldata.setProject(project);
             exceldata.setDataRow(datas1);
             System.out.println(exceldata);
-
             HashMap<String, Object> map = new HashMap<>();
             for (String s : datas1.keySet()) {
                 Map<String, List<HashMap<String, Object>>> numbers = (Map<String, List<HashMap<String, Object>>>) datas1.get(s);
@@ -136,20 +178,21 @@
                     for (Map<String, Object> number : hashMaps) {
                         number.put("绔彛", s1);
                         Double o = (Double) number.get("棰戠巼");
-                        floatList.add(o);
+                        if (o != null) {
+                            floatList.add(o);
+                        }
                     }
                     Double maxValue = Collections.max(floatList);
                     Double minValue = Collections.min(floatList);
-                    if (map.get(minValue + "-" + maxValue + "-" + s) == null) {
-                        map.put(minValue + "-" + maxValue + "-" + s, s1);
+                    if (map.get(minValue + "," + maxValue + "," + s) == null) {
+                        map.put(minValue + "," + maxValue + "," + s, s1);
                     } else {
-                        Object o = map.get(minValue + "-" + maxValue + "-" + s);
-                        map.put(minValue + "-" + maxValue + "-" + s, s1 + "," + o);
+                        Object o = map.get(minValue + "," + maxValue + "," + s);
+                        map.put(minValue + "," + maxValue + "," + s, s1 + "," + o);
                     }
                 }
             }
             System.out.println(map);
-            int size = map.size();
             for (String s1 : map.keySet()) {
                 String o = map.get(s1).toString();
                 List<String> collect = Arrays.stream(o.split(",")).collect(Collectors.toList());
@@ -170,7 +213,7 @@
                 }
             }
             System.out.println(map);
-            createWord(sonLaboratory, document, exceldata, map, insOrderFile);
+            createWord(sonLaboratory, document, exceldata, map, biaozhun, insOrderFile);
         } catch (IOException e) {
             e.printStackTrace();
         } finally {
@@ -188,8 +231,249 @@
         }
     }
 
+    //杩滃満
+    public void getFuSheWord2(String sonLaboratory, InsOrderFile insOrderFile) {
+        //璇诲彇excel鏂囦欢鍐呭
+        String excelFilePath = wordUrl + "/" + insOrderFile.getFileUrl(); // 鏇存柊涓轰綘鐨勬枃浠惰矾寰�
+        FileInputStream fileInputStream = null;
+        Workbook workbook = null;
 
-    public void createWord(String sonLaboratory, XWPFDocument document, Exceldata exceldata, HashMap<String, Object> map, InsOrderFile insOrderFile) throws IOException {
+        try {
+            fileInputStream = new FileInputStream(new File(excelFilePath));
+            workbook = new XSSFWorkbook(fileInputStream); // 瀵逛簬 .xlsx 鏂囦欢
+            XWPFDocument document = new XWPFDocument();
+            for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
+                Exceldata exceldata = new Exceldata();
+                HashMap<Integer, Object> project = new HashMap<>();
+                HashMap<String, Object> biaozhun = new HashMap<>();
+                HashMap<String, Object> pingjunzhi = new HashMap<>();
+                HashMap<String, Object> datas1 = new HashMap<>();
+                HashMap<String, Object> map2 = new HashMap<>();
+                List<Map<String, Object>> list = new ArrayList<>();
+                String jiaodu = "";
+                String port = "";
+                Integer count = 0;
+                Sheet sheet = workbook.getSheetAt(i);
+                Boolean biaoji = false;
+                int lastRowNum = sheet.getLastRowNum();
+                for (Row row : sheet) {
+                    count++;
+                    HashMap<String, Object> map1 = new HashMap<>();
+                    HashMap<String, Object> pingjun = new HashMap<>();
+                    for (Cell cell : row) {
+                        if (row.getRowNum() == 0) {
+                            switch (cell.getCellType()) {
+                                case STRING:
+                                    project.put(cell.getColumnIndex(), cell.getStringCellValue());
+                                    System.out.print(cell.getStringCellValue() + "\t");
+                                    break;
+                                case NUMERIC:
+                                    System.out.print(cell.getNumericCellValue() + "\t");
+                                    break;
+                                case BOOLEAN:
+                                    System.out.print(cell.getBooleanCellValue() + "\t");
+                                    break;
+                                case FORMULA:
+                                    System.out.print(cell.getCellFormula() + "\t");
+                                    break;
+                                default:
+                                    System.out.print("NULL\t");
+                            }
+                        } else if (row.getRowNum() > 2) {
+                            if (cell.getColumnIndex() == 0 && StringUtils.isNotEmpty(cell.getStringCellValue())) {
+                                if (map2.size() != 0) {
+                                    map2.put(port, list);
+                                    datas1.put(jiaodu, map2);
+                                    map2 = new HashMap<>();
+                                }
+                                datas1.put(cell.getStringCellValue(), "");
+                                jiaodu = cell.getStringCellValue();
+                            } else if (cell.getColumnIndex() == 1 && StringUtils.isNotEmpty(cell.getStringCellValue())) {
+                                if (list.size() != 0) {
+                                    map2.put(port, list);
+                                    list = new ArrayList<>();
+                                }
+                                map2.put(cell.getStringCellValue(), "");
+                                port = cell.getStringCellValue();
+
+                            } else {
+                                switch (cell.getCellType()) {
+                                    case STRING:
+                                        String value = cell.getStringCellValue();
+                                        if (value.equals("avg")) {
+                                            for (Cell cell1 : row) {
+                                                switch (cell1.getCellType()) {
+                                                    case STRING:
+
+                                                        break;
+                                                    case NUMERIC:
+                                                        pingjun.put(project.get(cell1.getColumnIndex()).toString(), cell1.getNumericCellValue());
+                                                        System.out.print(cell1.getNumericCellValue() + "\t");
+                                                        break;
+                                                    case BOOLEAN:
+                                                        System.out.print(cell1.getBooleanCellValue() + "\t");
+                                                        break;
+                                                    case FORMULA:
+                                                        String cellFormula = cell1.getCellFormula();
+                                                        Double numericCellValue = cell1.getNumericCellValue();
+                                                        pingjun.put(project.get(cell1.getColumnIndex()).toString(), cell1.getNumericCellValue());
+                                                        System.out.print(cellFormula);
+                                                        break;
+                                                    default:
+                                                        System.out.print("NULL\t");
+                                                }
+
+                                            }
+                                        } else if (value.equals("鎸囨爣")) {
+                                            for (Cell cell1 : row) {
+                                                switch (cell1.getCellType()) {
+                                                    case STRING:
+                                                        biaozhun.put(project.get(cell1.getColumnIndex()).toString(), cell1.getStringCellValue());
+                                                        break;
+                                                    case NUMERIC:
+                                                        System.out.print(cell1.getNumericCellValue() + "\t");
+                                                        break;
+                                                    case BOOLEAN:
+                                                        System.out.print(cell1.getBooleanCellValue() + "\t");
+                                                        break;
+                                                    case FORMULA:
+                                                        System.out.print(cell1.getCellFormula() + "\t");
+                                                        break;
+                                                    default:
+                                                        System.out.print("NULL\t");
+                                                }
+                                            }
+                                        } else {
+                                            biaoji = true;
+                                        }
+                                        break;
+                                    case NUMERIC:
+                                        map1.put(project.get(cell.getColumnIndex()).toString(), cell.getNumericCellValue());
+                                        System.out.print(cell.getNumericCellValue() + "\t");
+                                        break;
+                                    case BOOLEAN:
+                                        System.out.print(cell.getBooleanCellValue() + "\t");
+                                        break;
+                                    case FORMULA:
+                                        System.out.print(cell.getCellFormula() + "\t");
+                                        break;
+                                    default:
+                                        System.out.print("NULL\t");
+                                }
+                            }
+                        }
+                        if (biaoji) {
+                            biaoji = false;
+                            break;
+                        }
+                    }
+                    if (map1.size() != 0) {
+                        list.add(map1);
+                    }
+                    if (pingjun.size() != 0) {
+                        pingjunzhi.put(jiaodu, pingjun);
+                    }
+
+                    if (count == lastRowNum + 1) {
+                        map2.put(port, list);
+                        datas1.put(jiaodu, map2);
+                    }
+                    System.out.println();
+                }
+                exceldata.setProject(project);
+                exceldata.setDataRow(datas1);
+                System.out.println(exceldata);
+
+
+                HashMap<String, Object> map = new HashMap<>();
+                for (String s : datas1.keySet()) {
+                    Map<String, List<HashMap<String, Object>>> numbers = (Map<String, List<HashMap<String, Object>>>) datas1.get(s);
+                    for (String s1 : numbers.keySet()) {
+                        List<HashMap<String, Object>> hashMaps = numbers.get(s1);
+                        List<Integer> floatList = new ArrayList<>();
+                        for (Map<String, Object> number : hashMaps) {
+                            number.put("绔彛", s1);
+                            Double o = (Double) number.get("娴嬭瘯棰戠巼(MHZ)");
+                            floatList.add(o.intValue());
+                        }
+                        Integer maxValue = Collections.max(floatList);
+                        Integer minValue = Collections.min(floatList);
+
+                        if (map.get(minValue + "-" + maxValue + "-" + s) == null) {
+                            map.put(minValue + "-" + maxValue + "-" + s, s1);
+                        } else {
+                            Object o = map.get(minValue + "-" + maxValue + "-" + s);
+                            map.put(minValue + "-" + maxValue + "-" + s, s1 + "," + o);
+                        }
+                    }
+
+                }
+                System.out.println(map);
+
+                for (String s1 : map.keySet()) {
+                    String o = map.get(s1).toString();
+                    List<String> collect = Arrays.stream(o.split(",")).collect(Collectors.toList());
+                    int size1 = -1;
+                    for (String s : datas1.keySet()) {
+                        Map<String, List<HashMap<String, Object>>> o1 = (Map<String, List<HashMap<String, Object>>>) datas1.get(s);
+                        for (String s3 : o1.keySet()) {
+                            List<HashMap<String, Object>> numbers = o1.get(s3);
+                            for (String s2 : collect) {
+                                if (s3.equals(s2)) {
+                                    if (numbers.size() > size1) {
+                                        size1 = numbers.size();
+                                    }
+                                }
+                            }
+                            map.put(s1, o + "," + size1);
+                        }
+                    }
+
+                }
+                System.out.println(map);
+
+                createWord2(sonLaboratory, document, exceldata, map, pingjunzhi, biaozhun, insOrderFile);
+
+            }
+            // 杈撳嚭鍒版枃浠�
+            InsSample insSample = insSampleMapper.selectById(insOrderFile.getInsSampleId());
+            String[] split = insOrderFile.getFileName().split("\\.");
+            String name = insOrderFile.getFileName().replace("#", "&").substring(0, (insOrderFile.getFileName().length() - split[split.length - 1].length()));
+            String url = UUID.randomUUID() + "_" + insSample.getSampleCode() + "_" + sonLaboratory + name + "瑙f瀽鐨勮緪灏勭珯鐐规姤鍛�.docx";
+            url = url.replace("#", "&");
+            FileOutputStream out = new FileOutputStream(wordUrl + "/" + url);
+            document.write(out);
+            out.close();
+            document.close();
+            InsOrderFile orderFile = new InsOrderFile();
+            orderFile.setInsOrderId(insOrderFile.getInsOrderId());
+            orderFile.setInsSampleId(insOrderFile.getInsSampleId());
+            orderFile.setFileUrl(url);
+            orderFile.setType(2);
+            orderFile.setFileName(insSample.getSampleCode() + "&" + sonLaboratory + name + "瑙f瀽鐨勮緪灏勭珯鐐规姤鍛�.docx");
+            orderFile.setSonLaboratory(sonLaboratory);
+            insOrderFileMapper.insert(orderFile);
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            // 鍏抽棴璧勬簮
+            try {
+                if (workbook != null) {
+                    workbook.close();
+                }
+                if (fileInputStream != null) {
+                    fileInputStream.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+
+        }
+    }
+
+    //杩戝満
+    public void createWord(String sonLaboratory, XWPFDocument document, Exceldata exceldata, HashMap<String, Object> map, HashMap<String, Object> bz, InsOrderFile insOrderFile) throws IOException {
         int size = 1;
         XWPFParagraph paragraphs = document.createParagraph();
         XWPFRun runs = paragraphs.createRun();
@@ -197,8 +481,8 @@
         runs.setText("杈愬皠鏂瑰悜鍥惧弬鏁�");
         for (String s : map.keySet()) {
             Map<String, Object> dataRow = exceldata.getDataRow();
-            String result = s.substring(s.lastIndexOf("-") + 1);
-            String result1 = s.substring(0, s.lastIndexOf("-"));
+            String result = s.substring(s.lastIndexOf(",") + 1);
+            String result1 = s.substring(0, s.lastIndexOf(","));
             String o = map.get(s).toString();
             String[] split = o.split(",");
             Integer s1 = Integer.parseInt(split[split.length - 1]);
@@ -298,20 +582,26 @@
                 paragraph1.setAlignment(ParagraphAlignment.CENTER);
                 XWPFRun run1 = paragraph1.createRun();
                 run1.setText(s2);
-                // 璋冪敤鏂规硶鎻愬彇绗竴涓嫭鍙峰唴鐨勫唴瀹�
-                String firstContent = extractFirstContentFromBrackets(s2);
-                if (firstContent != null) {
-                    XWPFParagraph paragraph2 = table.getRow(0).getCell(2).getParagraphArray(0);
-                    paragraph2.setAlignment(ParagraphAlignment.CENTER);
-                    XWPFRun run2 = paragraph2.createRun();
-                    run2.setText(firstContent);
+                // 鍗曚綅
+                XWPFParagraph paragraph2 = table.getRow(0).getCell(2).getParagraphArray(0);
+                XWPFRun run2 = paragraph2.createRun();
+                if (s2.contains("澧炵泭")) {
+                    run2.setText("dBi");
+                } else if (s2.contains("娉㈢摚瀹藉害") || s2.contains("娉㈡潫瀹藉害") || s2.contains("涓嬪�捐")) {
+                    run2.setText("掳");
+                } else if (s2.contains("鍓嶅悗姣�") || s2.contains("浜ゅ弶鏋佸寲") || s2.contains("鏃佺摚鎶戝埗") || s2.contains("涓嬮檷") || s2.contains("闆剁偣濉厖") || s2.contains("鍓摚鐢靛钩")) {
+                    run2.setText("dB");
+                } else if (s2.contains("鏁堢巼") || s2.contains("鎵囧尯鍗犳瘮")) {
+                    run2.setText("%");
                 } else {
-                    System.out.println("娌℃湁鎵惧埌鎷彿鍐呯殑鍐呭銆�");
+                    run2.setText("");
                 }
                 XWPFParagraph paragraph3 = table.getRow(0).getCell(3).getParagraphArray(0);
                 paragraph3.setAlignment(ParagraphAlignment.CENTER);
                 XWPFRun run3 = paragraph3.createRun();
-                run3.setText("/");
+                if (bz.get(s2) != null) {
+                    run3.setText(bz.get(s2).toString());
+                } else run3.setText("");
                 XWPFParagraph paragraph4 = table.getRow(0).getCell(4).getParagraphArray(0);
                 paragraph4.setAlignment(ParagraphAlignment.CENTER);
                 XWPFRun run4 = paragraph4.createRun();
@@ -324,7 +614,7 @@
                 paragraph6.setAlignment(ParagraphAlignment.CENTER);
                 XWPFRun run6 = paragraph6.createRun();
                 run6.setText("/");
-                XWPFParagraph paragraph7 = table.getRow(1).getCell(cell - 1).getParagraphArray(0);
+                XWPFParagraph paragraph7 = table.getRow(2).getCell(cell - 1).getParagraphArray(0);
                 paragraph7.setAlignment(ParagraphAlignment.CENTER);
                 XWPFRun run7 = paragraph7.createRun();
                 run7.setText("鍚堟牸");
@@ -376,28 +666,241 @@
                 paragraph11.setAlignment(ParagraphAlignment.CENTER);
                 XWPFRun run11 = paragraph11.createRun();
                 double v = count / (Double.parseDouble(s1.toString()) * Double.parseDouble(i1.toString()));
-                run11.setText(String.format("%.2f",v));
+                run11.setText(String.format("%.2f", v));
                 size++;
             }
         }
         // 杈撳嚭鍒版枃浠�
         try {
-            InsOrder insOrder = insOrderMapper.selectById(insOrderFile.getInsOrderId());
+            InsSample insSample = insSampleMapper.selectById(insOrderFile.getInsSampleId());
             String[] split = insOrderFile.getFileName().split("\\.");
-            String name = insOrderFile.getFileName().substring(0, (insOrderFile.getFileName().length() - split[split.length - 1].length()));
-            FileOutputStream out = new FileOutputStream(wordUrl + "/" + insOrder.getEntrustCode() + "&" + sonLaboratory + name + "瑙f瀽鐨勮緪灏勭珯鐐规姤鍛�.docx");
+            String name = insOrderFile.getFileName().replace('#', '&').substring(0, (insOrderFile.getFileName().length() - split[split.length - 1].length()));
+            String url = UUID.randomUUID() + "_" + insSample.getSampleCode() + "&" + sonLaboratory + name + "瑙f瀽鐨勮緪灏勭珯鐐规姤鍛�.docx";
+            url.replace("#", "&");
+            FileOutputStream out = new FileOutputStream(wordUrl + "/" + url);
             document.write(out);
             out.close();
             document.close();
             InsOrderFile orderFile = new InsOrderFile();
             orderFile.setInsOrderId(insOrderFile.getInsOrderId());
-            orderFile.setFileUrl(insOrder.getEntrustCode() + "&" + sonLaboratory + name + "瑙f瀽鐨勮緪灏勭珯鐐规姤鍛�.docx");
+            orderFile.setInsSampleId(insOrderFile.getInsSampleId());
+            orderFile.setFileUrl(url);
             orderFile.setType(2);
-            orderFile.setFileName(insOrder.getEntrustCode() + "&" + sonLaboratory + name + "瑙f瀽鐨勮緪灏勭珯鐐规姤鍛�.docx");
+            orderFile.setFileName(insSample.getSampleCode() + "&" + sonLaboratory + name + "瑙f瀽鐨勮緪灏勭珯鐐规姤鍛�.docx");
             orderFile.setSonLaboratory(sonLaboratory);
             insOrderFileMapper.insert(orderFile);
         } catch (IOException e) {
             e.printStackTrace();
+        }
+    }
+
+    //杩滃満
+    public void createWord2(String sonLaboratory, XWPFDocument document, Exceldata exceldata, HashMap<String, Object> map, HashMap<String, Object> pj, HashMap<String, Object> bz, InsOrderFile insOrderFile) throws IOException {
+        int size = 1;
+        for (String s : map.keySet()) {
+            Map<String, Object> dataRow = exceldata.getDataRow();
+            String result = s.substring(s.lastIndexOf("-") + 1);
+            String result1 = s.substring(0, s.lastIndexOf("-"));
+            String o = map.get(s).toString();
+            String[] split = o.split(",");
+            Integer s1 = Integer.parseInt(split[split.length - 1]);
+            Integer i1 = split.length - 1;
+            int row = 3 + s1;
+            int cell = 6 + i1;
+            HashMap<String, Object> o2 = (HashMap<String, Object>) pj.get(result);
+
+            XWPFTable table1 = document.createTable(2, cell);
+
+            mergeCellsHorizontally(table1, 1, 0, cell - 1);
+            mergeCellsHorizontally(table1, 0, 4, cell - 2);
+
+            XWPFParagraph paragraph12 = table1.getRow(0).getCell(0).getParagraphArray(0);
+            XWPFRun run12 = paragraph12.createRun();
+            run12.setText("搴忓彿");
+
+            XWPFParagraph paragraph13 = table1.getRow(0).getCell(1).getParagraphArray(0);
+            XWPFRun run13 = paragraph13.createRun();
+            run13.setText("妫�楠岄」鐩�");
+
+            XWPFParagraph paragraph14 = table1.getRow(0).getCell(2).getParagraphArray(0);
+            XWPFRun run14 = paragraph14.createRun();
+            run14.setText("鍗曚綅");
+
+            XWPFParagraph paragraph15 = table1.getRow(0).getCell(3).getParagraphArray(0);
+            XWPFRun run15 = paragraph15.createRun();
+            run15.setText("鏍囧噯瑕佹眰");
+
+            XWPFParagraph paragraph16 = table1.getRow(0).getCell(cell - 1).getParagraphArray(0);
+            XWPFRun run16 = paragraph16.createRun();
+            run16.setText("妫�楠岀粨璁�");
+
+            XWPFParagraph paragraph17 = table1.getRow(0).getCell(4).getParagraphArray(0);
+            XWPFRun run17 = paragraph17.createRun();
+            run17.setText("妫�楠岀粨鏋�");
+
+            XWPFParagraph paragraph18 = table1.getRow(1).getCell(0).getParagraphArray(0);
+            XWPFRun run18 = paragraph18.createRun();
+            run18.setText("棰戞锛� " + result1 + "MHz " + "涓嬪�捐" + result);
+
+
+            List<String> collect = Arrays.stream(split).collect(Collectors.toList());
+            collect.sort((o1, o21) -> Integer.parseInt(o1.substring((o1.length() - 1))) - Integer.parseInt(o21.substring(o21.length() - 1)));
+
+            List<Map<String, Object>> list = new ArrayList<>();
+
+
+            // 瀵规墍鏈夌殑閿仛鍚�
+            Map<String, List<Map<String, Object>>> aggregatedMap = new HashMap<>();
+
+            Map<String, List<Map<String, Object>>> o1 = (Map<String, List<Map<String, Object>>>) dataRow.get(result);
+            for (String s2 : collect) {
+                if (s2.contains("绔彛") || s2.contains("P")) {
+                    List<Map<String, Object>> mapList = o1.get(s2);
+                    list.addAll(mapList);
+                }
+            }
+
+            // 閬嶅巻姣忎竴涓」鐩�
+            for (Map<String, Object> item : list) {
+                for (String key : item.keySet()) {
+                    // 濡傛灉璇ラ敭鍦� aggregatedMap 涓笉瀛樺湪锛屽垯鍒涘缓涓�涓柊鐨� List
+                    aggregatedMap.putIfAbsent(key, new ArrayList<>());
+                    // 灏嗗綋鍓嶉」鐩坊鍔犲埌瀵瑰簲閿殑 List 涓�
+                    aggregatedMap.get(key).add(item);
+                }
+            }
+
+
+            for (String s2 : aggregatedMap.keySet()) {
+                if (s2.equals("绔彛") || s2.equals("娴嬭瘯棰戠巼(MHZ)")) {
+                    continue;
+                }
+                List<Map<String, Object>> mapList = aggregatedMap.get(s2);
+                // 鍒涘缓涓�涓〃鏍�
+
+                XWPFTable table = document.createTable(row, cell);
+                table.setWidth("100%");
+
+                //鍨傜洿
+                mergeCellsVertically(table, 0, 0, row - 1);
+                mergeCellsVertically(table, 1, 0, row - 1);
+                mergeCellsVertically(table, 2, 0, row - 1);
+                mergeCellsVertically(table, 3, 0, row - 1);
+                mergeCellsVertically(table, 4, 0, 1);
+                mergeCellsVertically(table, cell - 1, 0, 1);
+                mergeCellsVertically(table, cell - 1, 2, row - 2);
+                //姘村钩
+                mergeCellsHorizontally(table, 0, 5, cell - 2);
+                mergeCellsHorizontally(table, row - 1, 5, cell - 2);
+
+                // 璁剧疆鍗曞厓鏍兼枃鏈苟灞呬腑
+                XWPFParagraph paragraph = table.getRow(0).getCell(0).getParagraphArray(0);
+                XWPFRun run = paragraph.createRun();
+                run.setText(String.valueOf(size));
+
+
+                XWPFParagraph paragraph1 = table.getRow(0).getCell(1).getParagraphArray(0);
+                XWPFRun run1 = paragraph1.createRun();
+                run1.setText(s2);
+
+                // 鍗曚綅
+                XWPFParagraph paragraph2 = table.getRow(0).getCell(2).getParagraphArray(0);
+                XWPFRun run2 = paragraph2.createRun();
+                if (s2.contains("澧炵泭")) {
+                    run2.setText("dBi");
+                } else if (s2.contains("娉㈢摚瀹藉害") || s2.contains("娉㈡潫瀹藉害") || s2.contains("涓嬪�捐")) {
+                    run2.setText("掳");
+                } else if (s2.contains("鍓嶅悗姣�") || s2.contains("浜ゅ弶鏋佸寲") || s2.contains("鏃佺摚鎶戝埗") || s2.contains("涓嬮檷") || s2.contains("闆剁偣濉厖") || s2.contains("鍓摚鐢靛钩")) {
+                    run2.setText("dB");
+                } else if (s2.contains("鏁堢巼") || s2.contains("鎵囧尯鍗犳瘮")) {
+                    run2.setText("%");
+                } else {
+                    run2.setText("");
+                }
+
+
+                XWPFParagraph paragraph3 = table.getRow(0).getCell(3).getParagraphArray(0);
+                paragraph3.setAlignment(ParagraphAlignment.CENTER);
+                XWPFRun run3 = paragraph3.createRun();
+                if (bz.get(s2) != null) {
+                    run3.setText(bz.get(s2).toString());
+                } else run3.setText("");
+
+
+                XWPFParagraph paragraph4 = table.getRow(0).getCell(4).getParagraphArray(0);
+                XWPFRun run4 = paragraph4.createRun();
+                run4.setText("棰戠巼锛圡Hz锛�");
+
+                XWPFParagraph paragraph5 = table.getRow(0).getCell(5).getParagraphArray(0);
+                paragraph5.setAlignment(ParagraphAlignment.CENTER);
+                XWPFRun run5 = paragraph5.createRun();
+                run5.setText("绔彛");
+
+                XWPFParagraph paragraph6 = table.getRow(0).getCell(cell - 1).getParagraphArray(0);
+                XWPFRun run6 = paragraph6.createRun();
+                run6.setText("/");
+
+                XWPFParagraph paragraph7 = table.getRow(1).getCell(cell - 1).getParagraphArray(0);
+                XWPFRun run7 = paragraph7.createRun();
+                run7.setText("鍚堟牸");
+
+
+                XWPFParagraph paragraph8 = table.getRow(row - 1).getCell(4).getParagraphArray(0);
+                XWPFRun run8 = paragraph8.createRun();
+                run8.setText("骞冲潎鍊�");
+
+                XWPFParagraph paragraph9 = table.getRow(row - 1).getCell(cell - 1).getParagraphArray(0);
+                XWPFRun run9 = paragraph9.createRun();
+                run9.setText("/");
+
+                for (int i = 0; i < collect.size(); i++) {
+                    String s3 = collect.get(i);
+                    if (s3.contains("绔彛") || s3.contains("P")) {
+                        XWPFParagraph paragraph10 = table.getRow(1).getCell(5 + i).getParagraphArray(0);
+                        XWPFRun run10 = paragraph10.createRun();
+                        run10.setText(s3);
+                    }
+                }
+
+                Map<Integer, List<Map<String, Object>>> group = mapList.stream()
+                        .collect(Collectors.groupingBy(item -> {
+                            Double aDouble = (Double) item.get("娴嬭瘯棰戠巼(MHZ)");
+                            return aDouble.intValue();
+                        }));
+
+
+                int hang = 2;
+                Double count = 0.0;
+                for (Integer aDouble : group.keySet()) {
+                    List<Map<String, Object>> mapList1 = group.get(aDouble);
+                    for (Map<String, Object> stringObjectMap : mapList1) {
+                        String port = stringObjectMap.get("绔彛").toString();
+                        for (int i = 5; i < cell - 1; i++) {
+                            String text = table.getRow(1).getCell(i).getText();
+                            if (text.equals(port)) {
+                                XWPFParagraph paragraph10 = table.getRow(hang).getCell(i).getParagraphArray(0);
+                                XWPFRun run10 = paragraph10.createRun();
+                                count = Double.parseDouble(stringObjectMap.get(s2).toString()) + count;
+                                String project = stringObjectMap.get(s2).toString();
+                                run10.setText(project);
+                            }
+                        }
+                    }
+                    XWPFParagraph paragraph10 = table.getRow(hang).getCell(4).getParagraphArray(0);
+                    XWPFRun run10 = paragraph10.createRun();
+                    run10.setText(String.valueOf(aDouble));
+
+
+                    hang++;
+                }
+
+                XWPFParagraph paragraph11 = table.getRow(row - 1).getCell(5).getParagraphArray(0);
+                XWPFRun run11 = paragraph11.createRun();
+                double v = count / (Double.parseDouble(s1.toString()) * Double.parseDouble(i1.toString()));
+                run11.setText(String.format("%.2f",(double)o2.get(s2)));
+
+                size++;
+            }
         }
     }
 
@@ -424,20 +927,6 @@
                 table.getRow(i).getCell(col).getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.CONTINUE);
             }
         }
-    }
-
-    // 鎻愬彇绗竴涓嫭鍙峰唴鐨勫唴瀹�
-    public static String extractFirstContentFromBrackets(String str) {
-        // 瀹氫箟姝e垯琛ㄨ揪寮忥紝鍖归厤鎷彿鍐呯殑鍐呭锛屽悓鏃舵敮鎸佷腑鏂囧拰鑻辨枃鎷彿
-        Pattern pattern = Pattern.compile("\\锛�(.*?)\\锛墊\\((.*?)\\)");
-        Matcher matcher = pattern.matcher(str);
-
-        // 鏌ユ壘绗竴涓尮閰嶇殑鍐呭
-        if (matcher.find()) {
-            // 鑾峰彇鎷彿鍐呯殑鍐呭锛屽垽鏂槸涓枃鎷彿杩樻槸鑻辨枃鎷彿
-            return matcher.group(1) != null ? matcher.group(1) : matcher.group(2);
-        }
-        return null; // 濡傛灉娌℃湁鎵惧埌鍖归厤椤癸紝鍒欒繑鍥瀗ull
     }
 
 }

--
Gitblit v1.9.3