zss
2025-01-13 476740c4330135b38be6a32f54dbe1bbcd32476a
inspect-server/src/main/java/com/yuanchu/mom/utils/WordUtils.java
@@ -18,6 +18,7 @@
import com.yuanchu.mom.exception.ErrorException;
import com.yuanchu.mom.mapper.*;
import com.yuanchu.mom.pojo.*;
import com.yuanchu.mom.vo.InsProductResult2VO;
import org.apache.commons.io.IOUtils;
import org.apache.poi.openxml4j.util.ZipSecureFile;
import org.apache.poi.xwpf.usermodel.*;
@@ -25,6 +26,7 @@
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTVMerge;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STMerge;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@@ -94,7 +96,7 @@
    GiveCode giveCode;
    //生成站点电路试验报告
    //生成站点电路试验报告(天线)
    public void generateWord(String term, InsOrderState insOrderState) {
        AtomicInteger lable = new AtomicInteger(1);
        AtomicInteger index = new AtomicInteger();
@@ -138,29 +140,29 @@
            int portRow = ports % 8 == 0 ? ports / 8 : ports / 8 + 1;
            //先判断是1简单版还是0复杂版
            if (insOrderState.getVersion() == 1) {
                if (inspectionItemSubclass.equals("电压驻波比")) {
                if (inspectionItemSubclass.contains("电压驻波比")) {
                    aa += 2 * portRow;
                }
                if (inspectionItemSubclass.equals("同极化隔离度")) {
                if (inspectionItemSubclass.contains("同极化隔离度")) {
                    aa += 1 * portRow;
                }
                if (inspectionItemSubclass.equals("隔离度")) {
                if (inspectionItemSubclass.contains("同列隔离度")) {
                    aa += 1 * portRow;
                }
                if (inspectionItemSubclass.equals("端口间隔离度")) {
                if (inspectionItemSubclass.contains("端口间隔离度")) {
                    aa += 1 * portRow;
                }
                if (inspectionItemSubclass.equals("异极化隔离度")) {
                if (inspectionItemSubclass.contains("异极化隔离度")) {
                    aa += 1 * portRow;
                }
                if (inspectionItemSubclass.equals("互调")) {
                if (inspectionItemSubclass.contains("互调")) {
                    aa += (angles + 1) * portRow * often;
                }
            } else {
                if (inspectionItemSubclass.equals("电压驻波比")) {
                if (inspectionItemSubclass.contains("电压驻波比")) {
                    aa += (angles + 1) * portRow;
                }
                if (inspectionItemSubclass.equals("同极化隔离度")) {
                if (inspectionItemSubclass.contains("同极化隔离度")) {
                    List<InsProductResult2> result2s = productResult2s.stream().filter(insProductResult2 ->
                            insProductMapper.selectById(insProductResult2.getInsProductId())
                                    .getInspectionItemSubclass().equals("同极化隔离度") && insProductResult2.getFrequency().equals(s)
@@ -168,15 +170,15 @@
                    int length = result2s.get(0).getPort().split(",").length;
                    aa += (angles + 1) * (length % (ports > 8 ? 4 : (ports + 1) / 2) == 0 ? length / (ports > 8 ? 4 : (ports + 1) / 2) : length / (ports > 8 ? 4 : (ports + 1) / 2) + 1);
                }
                if (inspectionItemSubclass.equals("隔离度")) {
                if (inspectionItemSubclass.contains("同列隔离度")) {
                    List<InsProductResult2> result2s = productResult2s.stream().filter(insProductResult2 ->
                            insProductMapper.selectById(insProductResult2.getInsProductId())
                                    .getInspectionItemSubclass().equals("隔离度") && insProductResult2.getFrequency().equals(s)
                                    .getInspectionItemSubclass().equals("同列隔离度") && insProductResult2.getFrequency().equals(s)
                    ).collect(Collectors.toList());
                    int length = result2s.get(0).getPort().split(",").length;
                    aa += (angles + 1) * (length % (ports > 8 ? 4 : (ports + 1) / 2) == 0 ? length / (ports > 8 ? 4 : (ports + 1) / 2) : length / (ports > 8 ? 4 : (ports + 1) / 2) + 1);
                }
                if (inspectionItemSubclass.equals("端口间隔离度")) {
                if (inspectionItemSubclass.contains("端口间隔离度")) {
                    List<InsProductResult2> result2s = productResult2s.stream().filter(insProductResult2 ->
                            insProductMapper.selectById(insProductResult2.getInsProductId())
                                    .getInspectionItemSubclass().equals("端口间隔离度") && insProductResult2.getFrequency().equals(s)
@@ -184,7 +186,7 @@
                    int length = result2s.get(0).getPort().split(",").length;
                    aa += (angles + 1) * (length % (ports > 8 ? 4 : (ports + 1) / 2) == 0 ? length / (ports > 8 ? 4 : (ports + 1) / 2) : length / (ports > 8 ? 4 : (ports + 1) / 2) + 1);
                }
                if (inspectionItemSubclass.equals("异极化隔离度")) {
                if (inspectionItemSubclass.contains("异极化隔离度")) {
                    List<InsProductResult2> result2s = productResult2s.stream().filter(insProductResult2 ->
                            insProductMapper.selectById(insProductResult2.getInsProductId())
                                    .getInspectionItemSubclass().equals("异极化隔离度") && insProductResult2.getFrequency().equals(s)
@@ -192,16 +194,16 @@
                    int length = result2s.get(0).getPort().split(",").length;
                    aa += (angles + 1) * (length % (ports > 8 ? 4 : (ports + 1) / 2) == 0 ? length / (ports > 8 ? 4 : (ports + 1) / 2) : length / (ports > 8 ? 4 : (ports + 1) / 2) + 1);
                }
                if (inspectionItemSubclass.equals("互调")) {
                if (inspectionItemSubclass.contains("互调")) {
                    aa += (angles + 1) * portRow * often;
                }
                if (inspectionItemSubclass.equals("最大耦合度")) {
                if (inspectionItemSubclass.contains("最大耦合度")) {
                    aa += (angles + 1);
                }
                if (inspectionItemSubclass.equals("最小耦合度")) {
                if (inspectionItemSubclass.contains("最小耦合度")) {
                    aa += (angles + 1);
                }
                if (inspectionItemSubclass.equals("幅度偏差")) {
                if (inspectionItemSubclass.contains("幅度偏差")) {
                    List<InsProductResult2> result2s = productResult2s.stream().filter(insProductResult2 ->
                            insProductMapper.selectById(insProductResult2.getInsProductId())
                                    .getInspectionItemSubclass().equals("幅度偏差")&& insProductResult2.getFrequency().equals(s)
@@ -209,7 +211,7 @@
                    int length = result2s.get(0).getPort().split(",").length;
                    aa += (angles + 1) * (length % 8 == 0 ? length / 8 : length / 8 + 1);
                }
                if (inspectionItemSubclass.equals("最大相位偏差")) {
                if (inspectionItemSubclass.contains("最大相位偏差")) {
                    List<InsProductResult2> result2s = productResult2s.stream().filter(insProductResult2 ->
                            insProductMapper.selectById(insProductResult2.getInsProductId())
                                    .getInspectionItemSubclass().equals("最大相位偏差")&& insProductResult2.getFrequency().equals(s)
@@ -265,7 +267,7 @@
                    } else {
                        if (insOrderState.getVersion() == 1) {
                            //非电调版本(简单版)
                            if (inspectionItemSubclass.equals("电压驻波比") && i <= 2 * portRow) {
                            if (inspectionItemSubclass.contains("电压驻波比") && i <= 2 * portRow) {
                                cc = 2 * portRow;
                                if (itemSet.add("电压驻波比")) {
                                    index.getAndIncrement();
@@ -365,7 +367,7 @@
                                    cells.add(cellRenderData);
                                }
                            }
                            if (inspectionItemSubclass.equals("同极化隔离度") && i > cc && i <= cc + portRow) {
                            if (inspectionItemSubclass.contains("同极化隔离度") && i > cc && i <= cc + portRow) {
                                dd = cc + portRow;
                                if (itemSet.add("同极化隔离度")) {
                                    index.getAndIncrement();
@@ -457,13 +459,13 @@
                                    cells.add(cellRenderData);
                                }
                            }
                            if (inspectionItemSubclass.equals("隔离度") && i > (dd == 0 ? cc : dd) && i <= (dd == 0 ? cc : dd) + portRow) {
                            if (inspectionItemSubclass.contains("同列隔离度") && i > (dd == 0 ? cc : dd) && i <= (dd == 0 ? cc : dd) + portRow) {
                                ee = (dd == 0 ? cc : dd) + portRow;
                                if (itemSet.add("隔离度")) {
                                if (itemSet.add("同列隔离度")) {
                                    index.getAndIncrement();
                                }
                                List<InsProduct> products = insProducts.stream()
                                        .filter(insProduct -> insProduct.getInspectionItemSubclass().equals("隔离度"))
                                        .filter(insProduct -> insProduct.getInspectionItemSubclass().equals("同列隔离度"))
                                        .collect(Collectors.toList());
                                List<InsProductResult2> result2s = productResult2s.stream()
                                        .filter(insProductResult2 -> insProductResult2.getFrequency().equals(s) && insProductResult2.getInsProductId().equals(products.get(0).getId()))
@@ -549,7 +551,7 @@
                                    cells.add(cellRenderData);
                                }
                            }
                            if (inspectionItemSubclass.equals("端口间隔离度") && i > (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) && i <= (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) + portRow) {
                            if (inspectionItemSubclass.contains("端口间隔离度") && i > (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) && i <= (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) + portRow) {
                                ff = (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) + portRow;
                                if (itemSet.add("端口间隔离度")) {
                                    index.getAndIncrement();
@@ -641,7 +643,7 @@
                                    cells.add(cellRenderData);
                                }
                            }
                            if (inspectionItemSubclass.equals("异极化隔离度") && i >(ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff)&& i <= (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) + portRow) {
                            if (inspectionItemSubclass.contains("异极化隔离度") && i >(ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff)&& i <= (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) + portRow) {
                                gg = (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) + portRow;
                                if (itemSet.add("异极化隔离度")) {
                                    index.getAndIncrement();
@@ -733,7 +735,7 @@
                                    cells.add(cellRenderData);
                                }
                            }
                            if (inspectionItemSubclass.equals("互调") && i > (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg)) {
                            if (inspectionItemSubclass.contains("互调") && i > (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg)) {
                                if (itemSet.add("互调")) {
                                    index.getAndIncrement();
                                }
@@ -827,7 +829,7 @@
                            }
                        } else {
                            //电调版本(复杂版)
                            if (inspectionItemSubclass.equals("电压驻波比") && i <= (angles + 1) * portRow) {
                            if (inspectionItemSubclass.contains("电压驻波比") && i <= (angles + 1) * portRow) {
                                cc = (angles + 1) * portRow;
                                if (itemSet.add("电压驻波比")) {
                                    index.getAndIncrement();
@@ -928,7 +930,7 @@
                                    cells.add(cellRenderData);
                                }
                            }
                            if (inspectionItemSubclass.equals("同极化隔离度")) {
                            if (inspectionItemSubclass.contains("同极化隔离度")) {
                                List<InsProduct> products = insProducts.stream().filter(insProduct -> insProduct.getInspectionItemSubclass().equals("同极化隔离度")).collect(Collectors.toList());
                                List<InsProductResult2> result2s = productResult2s.stream()
                                        .filter(insProductResult2 -> insProductResult2.getFrequency().equals(s) && insProductResult2.getInsProductId().equals(products.get(0).getId()))
@@ -1051,8 +1053,8 @@
                                    }
                                }
                            }
                            if (inspectionItemSubclass.equals("隔离度")) {
                                List<InsProduct> products = insProducts.stream().filter(insProduct -> insProduct.getInspectionItemSubclass().equals("隔离度")).collect(Collectors.toList());
                            if (inspectionItemSubclass.contains("同列隔离度")) {
                                List<InsProduct> products = insProducts.stream().filter(insProduct -> insProduct.getInspectionItemSubclass().equals("同列隔离度")).collect(Collectors.toList());
                                List<InsProductResult2> result2s = productResult2s.stream()
                                        .filter(insProductResult2 -> insProductResult2.getFrequency().equals(s) && insProductResult2.getInsProductId().equals(products.get(0).getId()))
                                        .collect(Collectors.toList());
@@ -1061,7 +1063,7 @@
                                int k = (angles + 1) * portRow2;
                                if (i > (dd == 0 ? cc : dd) && i <= (dd == 0 ? cc : dd) + k) {
                                    ee = (dd == 0 ? cc : dd) + k;
                                    if (itemSet.add("隔离度")) {
                                    if (itemSet.add("同列隔离度")) {
                                        index.getAndIncrement();
                                    }
                                    //隔离度所在行
@@ -1174,7 +1176,7 @@
                                    }
                                }
                            }
                            if (inspectionItemSubclass.equals("端口间隔离度")) {
                            if (inspectionItemSubclass.contains("端口间隔离度")) {
                                List<InsProduct> products = insProducts.stream().filter(insProduct -> insProduct.getInspectionItemSubclass().equals("端口间隔离度")).collect(Collectors.toList());
                                List<InsProductResult2> result2s = productResult2s.stream()
                                        .filter(insProductResult2 -> insProductResult2.getFrequency().equals(s) && insProductResult2.getInsProductId().equals(products.get(0).getId()))
@@ -1297,7 +1299,7 @@
                                    }
                                }
                            }
                            if (inspectionItemSubclass.equals("异极化隔离度")) {
                            if (inspectionItemSubclass.contains("异极化隔离度")) {
                                List<InsProduct> products = insProducts.stream().filter(insProduct -> insProduct.getInspectionItemSubclass().equals("异极化隔离度")).collect(Collectors.toList());
                                List<InsProductResult2> result2s = productResult2s.stream()
                                        .filter(insProductResult2 -> insProductResult2.getFrequency().equals(s) && insProductResult2.getInsProductId().equals(products.get(0).getId()))
@@ -1419,7 +1421,7 @@
                                        }
                                    }
                                }
                            if (inspectionItemSubclass.equals("互调") && i > (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) && i <= ((gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) + (angles + 1) * portRow * often)) {
                            if (inspectionItemSubclass.contains("互调") && i > (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) && i <= ((gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) + (angles + 1) * portRow * often)) {
                                    hh = (int) ((gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) + (angles + 1) * portRow * often);
                                    if (itemSet.add("互调")) {
                                        index.getAndIncrement();
@@ -1516,7 +1518,7 @@
                                        cells.add(cellRenderData);
                                    }
                                }
                            if (inspectionItemSubclass.equals("最大耦合度") && i > (hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) && i <= ((hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) + (angles + 1))) {
                            if (inspectionItemSubclass.contains("最大耦合度") && i > (hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) && i <= ((hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) + (angles + 1))) {
                                    mm = ((hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) + (angles + 1));
                                    if (itemSet.add("最大耦合度")) {
                                        index.getAndIncrement();
@@ -1609,7 +1611,7 @@
                                        cells.add(cellRenderData);
                                    }
                                }
                            if (inspectionItemSubclass.equals("最小耦合度") && i > (mm == 0 ? (hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) : mm) && i <= ((mm == 0 ? (hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) : mm) + (angles + 1))) {
                            if (inspectionItemSubclass.contains("最小耦合度") && i > (mm == 0 ? (hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) : mm) && i <= ((mm == 0 ? (hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) : mm) + (angles + 1))) {
                                    nn = (mm == 0 ? (hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) : mm) + (angles + 1);
                                    if (itemSet.add("最小耦合度")) {
                                        index.getAndIncrement();
@@ -1702,7 +1704,7 @@
                                        cells.add(cellRenderData);
                                    }
                                }
                            if (inspectionItemSubclass.equals("幅度偏差")) {
                            if (inspectionItemSubclass.contains("幅度偏差")) {
                                    List<InsProduct> products = insProducts.stream().filter(insProduct -> insProduct.getInspectionItemSubclass().equals("幅度偏差")).collect(Collectors.toList());
                                    List<InsProductResult2> result2s = productResult2s.stream()
                                            .filter(insProductResult2 -> insProductResult2.getFrequency().equals(s) && insProductResult2.getInsProductId().equals(products.get(0).getId()))
@@ -1808,7 +1810,7 @@
                                        }
                                    }
                                }
                            if (inspectionItemSubclass.equals("最大相位偏差")) {
                            if (inspectionItemSubclass.contains("最大相位偏差")) {
                                    List<InsProduct> products = insProducts.stream().filter(insProduct -> insProduct.getInspectionItemSubclass().equals("最大相位偏差")).collect(Collectors.toList());
                                    List<InsProductResult2> result2s = productResult2s.stream()
                                            .filter(insProductResult2 -> insProductResult2.getFrequency().equals(s) && insProductResult2.getInsProductId().equals(products.get(0).getId()))
@@ -1948,6 +1950,303 @@
            });
        ZipSecureFile.setMinInflateRatio(0.0001);
        InputStream inputStream = this.getClass().getResourceAsStream("/static/word1.docx");
        ConfigureBuilder builder = Configure.builder();
        builder.useSpringEL(true);
        XWPFTemplate template = XWPFTemplate.compile(inputStream, builder.build()).render(
                new HashMap<String, Object>() {{
                    put("title", title);
                    put("tables", tables);
                }});
        String name = insOrder.getEntrustCode().replace("/", "") + "-" +insSample.getSampleCode()+"-"+ title + ".docx";
        String url = UUID.randomUUID() + "_" + name;
        try {
            template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl + "/" + url)));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        // 处理合并单元格的问题
        String path = wordUrl + "/" + url;
        try {
            ZipSecureFile.setMinInflateRatio(0.0001);
            FileInputStream stream = new FileInputStream(path);
            XWPFDocument document = new XWPFDocument(stream);
            List<XWPFTable> xwpfTables = document.getTables();
            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++) {
                    for (int k = 0; k < xwpfTables.get(i).getRows().get(j).getTableCells().size(); k++) {
                        if (xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().indexOf("∑") > -1) {
                            String[] split = xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().split("∑");
                            if (set1.add(split[1])) {
                                Map<String, Integer> map = new HashMap<>();
                                map.put("sr", j);
                                map.put("sc", k);
                                map.put("er", j + 0);
                                map.put("ec", k + 0);
                                maps.put(split[1], map);
                            } else {
                                Map<String, Integer> map1 = maps.get(split[1]);
                                if (j == map1.get("sr")) {
                                    map1.put("ec", map1.get("ec") + 1);
                                } else if (k == map1.get("sc")) {
                                    map1.put("er", map1.get("er") + 1);
                                }
                            }
                            String str = xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().split("∑")[0];
                            xwpfTables.get(i).getRows().get(j).getTableCells().get(k).removeParagraph(0);
                            xwpfTables.get(i).getRows().get(j).getTableCells().get(k).setText(str);
                            xwpfTables.get(i).getRows().get(j).getTableCells().get(k).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
                            xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getParagraphArray(0).setAlignment(org.apache.poi.xwpf.usermodel.ParagraphAlignment.CENTER);
                        }
                    }
                }
                // 单元格排序, 避免格式错乱
                List<Map.Entry<String, Map<String, Integer>>> entries = new ArrayList<>(maps.entrySet());
                entries.sort((o1, o2) -> o1.getValue().get("sc") - o2.getValue().get("sc"));
                // 按照顺序添加进集合
                List<String> list = new ArrayList<>();
                for (Map.Entry<String, Map<String, Integer>> entry : entries) {
                    list.add(entry.getKey());
                }
                /*List<String> list = new ArrayList<>();
                for (String s : maps.keySet()) {
                    list.add(s);
                }*/
                for (int a = list.size() - 1; a >= 0; a--) {
                    Map<String, Integer> v = maps.get(list.get(a));
                    for (int j = 0; j < v.get("er") - v.get("sr") + 1; j++) {
                        if (v.get("ec") > v.get("sc")) {
                            try {
                                TableTools.mergeCellsHorizonal(xwpfTables.get(i), v.get("sr") + j, v.get("sc"), v.get("ec"));
                            } catch (Exception e) {
                            }
                        }
                    }
                    if (v.get("er") > v.get("sr")) {
                        try {
                            TableTools.mergeCellsVertically(xwpfTables.get(i), v.get("sc"), v.get("sr"), v.get("er"));
                        } catch (Exception e) {
                        }
                    }
                }
            }
            FileOutputStream fileOutputStream = new FileOutputStream(path);
            document.write(fileOutputStream);
            fileOutputStream.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        InsOrderFile insOrderFile = new InsOrderFile();
        insOrderFile.setInsOrderId(insOrderState.getInsOrderId());
        insOrderFile.setInsSampleId(insOrderState.getInsSampleId());
        insOrderFile.setFileName(name);
        insOrderFile.setType(2);
        insOrderFile.setFileUrl(url);
        insOrderFile.setSonLaboratory("电路试验");
        insOrderFileMapper.insert(insOrderFile);
    }
    //生成站点电路试验报告(无源器件)
    public void generateWord2(String term, InsOrderState insOrderState) {
        AtomicInteger index = new AtomicInteger();
        String title = term + "电路参数";
        List<Map<String, Object>> tables = new ArrayList<>();
        //查询订单
        InsOrder insOrder = insOrderMapper.selectById(insOrderState.getInsOrderId());
        //查询样品
        InsSample insSample = insSampleMapper.selectById(insOrderState.getInsSampleId());
        //查询项目
        List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
                .eq(InsProduct::getState,1)
                .eq(InsProduct::getInsSampleId, insSample.getId())
                .eq(InsProduct::getSonLaboratory, "电路试验"));
        //计算行数
        List<InsProductResult2VO> result2VOS = new ArrayList<>();
        List<InsProductResult2VO> insProductResult2VOS = insProductResult2Mapper.selectWordHang(insOrderState.getNum(), insProducts.stream().map(InsProduct::getId).collect(Collectors.toList()));
        for (InsProductResult2VO insProductResult2VO : insProductResult2VOS) {
            String[] split = insProductResult2VO.getPort().split(",");
            String value = insProductResult2VO.getValue().replace("[[", "").replace("]]", "");
            if (split.length>1){
                for (int i = 0; i < split.length; i++) {
                    InsProductResult2VO insProductResult2VO1 = new InsProductResult2VO();
                    BeanUtils.copyProperties(insProductResult2VO,insProductResult2VO1);
                    //端口
                    insProductResult2VO1.setPort(split[i]);
                    //值
                    try{
                        insProductResult2VO1.setValue(value.split(",")[i].replace("\"",""));
                    }catch (Exception e){
                        insProductResult2VO1.setValue("");
                    }
                    result2VOS.add(insProductResult2VO1);
                }
            }
            else {
                insProductResult2VO.setValue(value.replace("\"",""));
                result2VOS.add(insProductResult2VO);
            }
        }
        List<RowRenderData> rows = new ArrayList<>();
        Set<String> itemSet = new HashSet<>();
        //表格的行数
        for (int i = 0; i < result2VOS.size(); i++) {
                RowRenderData rowRenderData = new RowRenderData();
                RowStyle rowStyle = new RowStyle();
                rowStyle.setHeight(40);
                rowRenderData.setRowStyle(rowStyle);
                List<CellRenderData> cells = new ArrayList<>();
                //表格的列数
                for (int j = 0; j < 8; j++) {
                    CellRenderData cellRenderData = new CellRenderData();
                    CellStyle cellStyle = new CellStyle();
                    cellStyle.setVertAlign(XWPFTableCell.XWPFVertAlign.CENTER);
                    cellRenderData.setCellStyle(cellStyle);
                    List<ParagraphRenderData> paragraphRenderDataList = new ArrayList<>();
                    ParagraphRenderData paragraphRenderData = new ParagraphRenderData();
                    ParagraphStyle paragraphStyle = new ParagraphStyle();
                    paragraphStyle.setAlign(ParagraphAlignment.CENTER);
                    paragraphRenderData.setParagraphStyle(paragraphStyle);
                    List<RenderData> renderData = new ArrayList<>();
                    TextRenderData textRenderData = new TextRenderData();
                    Style style = new Style();
                    style.setFontFamily("宋体");
                    style.setColor("000000");
                    textRenderData.setStyle(style);
                    if (j==0){
                        //第一列(序号)
                        if (itemSet.add(result2VOS.get(i).getInspectionItemSubclass())) {
                            index.getAndIncrement();
                        }
                        textRenderData.setText(index + "∑1" + index);
                        renderData.add(textRenderData);
                        paragraphRenderData.setContents(renderData);
                        paragraphRenderDataList.add(paragraphRenderData);
                        cellRenderData.setParagraphs(paragraphRenderDataList);
                        cells.add(cellRenderData);
                    }
                    else if (j==1){
                        //第二列(检验项目)
                        textRenderData.setText(result2VOS.get(i).getInspectionItemSubclass()+ "∑2" + index);
                        renderData.add(textRenderData);
                        paragraphRenderData.setContents(renderData);
                        paragraphRenderDataList.add(paragraphRenderData);
                        cellRenderData.setParagraphs(paragraphRenderDataList);
                        cells.add(cellRenderData);
                    }
                    else if (j==2){
                        //第三列(单位)
                        textRenderData.setText(result2VOS.get(i).getUnit()+ "∑3" + index);
                        renderData.add(textRenderData);
                        paragraphRenderData.setContents(renderData);
                        paragraphRenderDataList.add(paragraphRenderData);
                        cellRenderData.setParagraphs(paragraphRenderDataList);
                        cells.add(cellRenderData);
                    }
                    else if (j==3){
                        //第四列(标准与要求)
                        textRenderData.setText(result2VOS.get(i).getAsk());
                        renderData.add(textRenderData);
                        paragraphRenderData.setContents(renderData);
                        paragraphRenderDataList.add(paragraphRenderData);
                        cellRenderData.setParagraphs(paragraphRenderDataList);
                        cells.add(cellRenderData);
                    }
                    else if (j==4){
                        //第五列(端口)
                        try{
                            textRenderData.setText(result2VOS.get(i).getPort());
                        }catch (Exception e){
                            textRenderData.setText("");
                        }
                        renderData.add(textRenderData);
                        paragraphRenderData.setContents(renderData);
                        paragraphRenderDataList.add(paragraphRenderData);
                        cellRenderData.setParagraphs(paragraphRenderDataList);
                        cells.add(cellRenderData);
                    }
                    else if (j==5){
                        //第六列(频段)
                        try{
                            textRenderData.setText(result2VOS.get(i).getFrequency());
                        }catch (Exception e){
                            textRenderData.setText("");
                        }
                        renderData.add(textRenderData);
                        paragraphRenderData.setContents(renderData);
                        paragraphRenderDataList.add(paragraphRenderData);
                        cellRenderData.setParagraphs(paragraphRenderDataList);
                        cells.add(cellRenderData);
                    }
                    else if (j==6){
                        //第七列(检验值)
                        try{
                            textRenderData.setText(result2VOS.get(i).getValue());
                        }catch (Exception e){
                            textRenderData.setText("");
                        }
                        renderData.add(textRenderData);
                        paragraphRenderData.setContents(renderData);
                        paragraphRenderDataList.add(paragraphRenderData);
                        cellRenderData.setParagraphs(paragraphRenderDataList);
                        cells.add(cellRenderData);
                    }
                    else {
                        //最后一列(结论)
                        try{
                            if (result2VOS.get(i).getResult().equals("1")) {
                                textRenderData.setText("合格");
                            }else if (result2VOS.get(i).getResult().equals("0")){
                                textRenderData.setText("不合格");
                            }else {
                                textRenderData.setText("不判定");
                            }
                        }catch (Exception e){
                            textRenderData.setText("");
                        }
                        renderData.add(textRenderData);
                        paragraphRenderData.setContents(renderData);
                        paragraphRenderDataList.add(paragraphRenderData);
                        cellRenderData.setParagraphs(paragraphRenderDataList);
                        cells.add(cellRenderData);
                    }
                }
                rowRenderData.setCells(cells);
                if (rowRenderData.getCells().size() != 0) {
                    rows.add(rowRenderData);
                }
            }
        TableRenderData tableRenderData = new TableRenderData();
        tableRenderData.setRows(rows);
        int countSize = tableRenderData.getRows().get(0).getCells().size();
        for (RowRenderData row : tableRenderData.getRows()) {
                if (row.getCells().size() != countSize) {
                    throw new ErrorException("每行单元格不相等");
                }
        }
        TableStyle tableStyle = new TableStyle();
        tableStyle.setWidth(XWPFTable.DEFAULT_PERCENTAGE_WIDTH);
        tableStyle.setAlign(TableRowAlign.CENTER);
        BorderStyle borderStyle = new BorderStyle();
        borderStyle.setColor("000000");
        borderStyle.setType(XWPFTable.XWPFBorderType.THICK);
        borderStyle.setSize(4);
        tableStyle.setLeftBorder(borderStyle);
        tableStyle.setTopBorder(borderStyle);
        tableStyle.setRightBorder(borderStyle);
        tableStyle.setBottomBorder(borderStyle);
        tableRenderData.setTableStyle(tableStyle);
        Map<String, Object> table = new HashMap<>();
        table.put("table", tableRenderData);
        tables.add(table);
        ZipSecureFile.setMinInflateRatio(0.0001);
        InputStream inputStream = this.getClass().getResourceAsStream("/static/word2.docx");
        ConfigureBuilder builder = Configure.builder();
        builder.useSpringEL(true);
@@ -2421,7 +2720,11 @@
                InsOrderState orderState = insOrderStateMapper.selectById(insOrderUser.getInsOrderStateId());
                if (orderState.getLaboratory().equals("电路试验")) {
                    orderState.setNum(insOrderUser.getNum());
                    getWord1(insOrderUser.getTerm(), orderState, tables2);
                    if(!insOrder.getSampleType().equals("无源器件")){
                        getWord1(insOrderUser.getTerm(), orderState, tables2);
                    }else {
                        getWord2(insOrderUser.getTerm(), orderState, tables2);
                    }
                }
            }
        }
@@ -2783,25 +3086,24 @@
    }
    //电路报告用于总报告的方法
    //电路报告用于总报告的方法(天线)
    private void getWord1(String term, InsOrderState insOrderState,List<Map<String, Object>> tables2) {
        AtomicInteger lable = new AtomicInteger(1);
        AtomicInteger index = new AtomicInteger();
        String title = term + "电路参数";
        InsSample insSample = insSampleMapper.selectById(insOrderState.getInsSampleId());
            //查询项目
            List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
        //查询项目
        List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
                    .eq(InsProduct::getState,1)
                    .eq(InsProduct::getInsSampleId, insSample.getId())
                    .eq(InsProduct::getSonLaboratory, "电路试验"));
            //获取最大端口数量,角度数量,频段数量
            List<InsProductResult2> insProductResult2s = insProductResult2Mapper.selectList(Wrappers.<InsProductResult2>lambdaQuery()
        //获取最大端口数量,角度数量,频段数量
        List<InsProductResult2> insProductResult2s = insProductResult2Mapper.selectList(Wrappers.<InsProductResult2>lambdaQuery()
                    .eq(InsProductResult2::getNum, insOrderState.getNum())
                    .in(InsProductResult2::getInsProductId, insProducts.stream().map(InsProduct::getId).collect(Collectors.toList())));
            //按照频段分表(查询所有频段)
            List<String> frequencys = insProductResult2s.stream().map(InsProductResult2::getFrequency).distinct().collect(Collectors.toList());
            frequencys.forEach(s -> {
        //按照频段分表(查询所有频段)
        List<String> frequencys = insProductResult2s.stream().map(InsProductResult2::getFrequency).distinct().collect(Collectors.toList());
        frequencys.forEach(s -> {
                int ports = 0;//端口数
                int angles = 0;//角度数
                List<InsProductResult2> productResult2s = insProductResult2s.stream().filter(insProductResult2 -> insProductResult2.getFrequency().equals(s)).collect(Collectors.toList());
@@ -2824,29 +3126,30 @@
                int portRow = ports % 8 == 0 ? ports / 8 : ports / 8 + 1;
                //先判断是1简单版还是0复杂版
                if (insOrderState.getVersion() == 1) {
                    if (inspectionItemSubclass.equals("电压驻波比")) {
                    if (inspectionItemSubclass.contains("电压驻波比")) {
                        aa += 2 * portRow;
                    }
                    if (inspectionItemSubclass.equals("同极化隔离度")) {
                    if (inspectionItemSubclass.contains("同极化隔离度")) {
                        aa += 1 * portRow;
                    }
                    if (inspectionItemSubclass.equals("隔离度")) {
                    if (inspectionItemSubclass.contains("同列隔离度")) {
                        aa += 1 * portRow;
                    }
                    if (inspectionItemSubclass.equals("端口间隔离度")) {
                    if (inspectionItemSubclass.contains("端口间隔离度")) {
                        aa += 1 * portRow;
                    }
                    if (inspectionItemSubclass.equals("异极化隔离度")) {
                    if (inspectionItemSubclass.contains("异极化隔离度")) {
                        aa += 1 * portRow;
                    }
                    if (inspectionItemSubclass.equals("互调")) {
                    if (inspectionItemSubclass.contains("互调")) {
                        aa += (angles + 1) * portRow * often;
                    }
                } else {
                    if (inspectionItemSubclass.equals("电压驻波比")) {
                }
                else {
                    if (inspectionItemSubclass.contains("电压驻波比")) {
                        aa += (angles + 1) * portRow;
                    }
                    if (inspectionItemSubclass.equals("同极化隔离度")) {
                    if (inspectionItemSubclass.contains("同极化隔离度")) {
                        List<InsProductResult2> result2s = productResult2s.stream().filter(insProductResult2 ->
                                insProductMapper.selectById(insProductResult2.getInsProductId())
                                        .getInspectionItemSubclass().equals("同极化隔离度") && insProductResult2.getFrequency().equals(s)
@@ -2854,15 +3157,15 @@
                        int length = result2s.get(0).getPort().split(",").length;
                        aa += (angles + 1) * (length % (ports > 8 ? 4 : (ports + 1) / 2) == 0 ? length / (ports > 8 ? 4 : (ports + 1) / 2) : length / (ports > 8 ? 4 : (ports + 1) / 2) + 1);
                    }
                    if (inspectionItemSubclass.equals("隔离度")) {
                    if (inspectionItemSubclass.contains("同列隔离度")) {
                        List<InsProductResult2> result2s = productResult2s.stream().filter(insProductResult2 ->
                                insProductMapper.selectById(insProductResult2.getInsProductId())
                                        .getInspectionItemSubclass().equals("隔离度") && insProductResult2.getFrequency().equals(s)
                                        .getInspectionItemSubclass().equals("同列隔离度") && insProductResult2.getFrequency().equals(s)
                        ).collect(Collectors.toList());
                        int length = result2s.get(0).getPort().split(",").length;
                        aa += (angles + 1) * (length % (ports > 8 ? 4 : (ports + 1) / 2) == 0 ? length / (ports > 8 ? 4 : (ports + 1) / 2) : length / (ports > 8 ? 4 : (ports + 1) / 2) + 1);
                    }
                    if (inspectionItemSubclass.equals("端口间隔离度")) {
                    if (inspectionItemSubclass.contains("端口间隔离度")) {
                        List<InsProductResult2> result2s = productResult2s.stream().filter(insProductResult2 ->
                                insProductMapper.selectById(insProductResult2.getInsProductId())
                                        .getInspectionItemSubclass().equals("端口间隔离度") && insProductResult2.getFrequency().equals(s)
@@ -2870,7 +3173,7 @@
                        int length = result2s.get(0).getPort().split(",").length;
                        aa += (angles + 1) * (length % (ports > 8 ? 4 : (ports + 1) / 2) == 0 ? length / (ports > 8 ? 4 : (ports + 1) / 2) : length / (ports > 8 ? 4 : (ports + 1) / 2) + 1);
                    }
                    if (inspectionItemSubclass.equals("异极化隔离度")) {
                    if (inspectionItemSubclass.contains("异极化隔离度")) {
                        List<InsProductResult2> result2s = productResult2s.stream().filter(insProductResult2 ->
                                insProductMapper.selectById(insProductResult2.getInsProductId())
                                        .getInspectionItemSubclass().equals("异极化隔离度") && insProductResult2.getFrequency().equals(s)
@@ -2878,16 +3181,16 @@
                        int length = result2s.get(0).getPort().split(",").length;
                        aa += (angles + 1) * (length % (ports > 8 ? 4 : (ports + 1) / 2) == 0 ? length / (ports > 8 ? 4 : (ports + 1) / 2) : length / (ports > 8 ? 4 : (ports + 1) / 2) + 1);
                    }
                    if (inspectionItemSubclass.equals("互调")) {
                    if (inspectionItemSubclass.contains("互调")) {
                        aa += (angles + 1) * portRow * often;
                    }
                    if (inspectionItemSubclass.equals("最大耦合度")) {
                    if (inspectionItemSubclass.contains("最大耦合度")) {
                        aa += (angles + 1);
                    }
                    if (inspectionItemSubclass.equals("最小耦合度")) {
                    if (inspectionItemSubclass.contains("最小耦合度")) {
                        aa += (angles + 1);
                    }
                    if (inspectionItemSubclass.equals("幅度偏差")) {
                    if (inspectionItemSubclass.contains("幅度偏差")) {
                        List<InsProductResult2> result2s = productResult2s.stream().filter(insProductResult2 ->
                                insProductMapper.selectById(insProductResult2.getInsProductId())
                                        .getInspectionItemSubclass().equals("幅度偏差")&& insProductResult2.getFrequency().equals(s)
@@ -2895,7 +3198,7 @@
                        int length = result2s.get(0).getPort().split(",").length;
                        aa += (angles + 1) * (length % 8 == 0 ? length / 8 : length / 8 + 1);
                    }
                    if (inspectionItemSubclass.equals("最大相位偏差")) {
                    if (inspectionItemSubclass.contains("最大相位偏差")) {
                        List<InsProductResult2> result2s = productResult2s.stream().filter(insProductResult2 ->
                                insProductMapper.selectById(insProductResult2.getInsProductId())
                                        .getInspectionItemSubclass().equals("最大相位偏差")&& insProductResult2.getFrequency().equals(s)
@@ -2951,7 +3254,7 @@
                        } else {
                            if (insOrderState.getVersion() == 1) {
                                //非电调版本(简单版)
                                if (inspectionItemSubclass.equals("电压驻波比") && i <= 2 * portRow) {
                                if (inspectionItemSubclass.contains("电压驻波比") && i <= 2 * portRow) {
                                    cc = 2 * portRow;
                                    if (itemSet.add("电压驻波比")) {
                                        index.getAndIncrement();
@@ -3051,7 +3354,7 @@
                                        cells.add(cellRenderData);
                                    }
                                }
                                if (inspectionItemSubclass.equals("同极化隔离度") && i > cc && i <= cc + portRow) {
                                if (inspectionItemSubclass.contains("同极化隔离度") && i > cc && i <= cc + portRow) {
                                    dd = cc + portRow;
                                    if (itemSet.add("同极化隔离度")) {
                                        index.getAndIncrement();
@@ -3143,13 +3446,13 @@
                                        cells.add(cellRenderData);
                                    }
                                }
                                if (inspectionItemSubclass.equals("隔离度") && i > (dd == 0 ? cc : dd) && i <= (dd == 0 ? cc : dd) + portRow) {
                                if (inspectionItemSubclass.contains("同列隔离度") && i > (dd == 0 ? cc : dd) && i <= (dd == 0 ? cc : dd) + portRow) {
                                    ee = (dd == 0 ? cc : dd) + portRow;
                                    if (itemSet.add("隔离度")) {
                                    if (itemSet.add("同列隔离度")) {
                                        index.getAndIncrement();
                                    }
                                    List<InsProduct> products = insProducts.stream()
                                            .filter(insProduct -> insProduct.getInspectionItemSubclass().equals("隔离度"))
                                            .filter(insProduct -> insProduct.getInspectionItemSubclass().equals("同列隔离度"))
                                            .collect(Collectors.toList());
                                    List<InsProductResult2> result2s = productResult2s.stream()
                                            .filter(insProductResult2 -> insProductResult2.getFrequency().equals(s) && insProductResult2.getInsProductId().equals(products.get(0).getId()))
@@ -3235,7 +3538,7 @@
                                        cells.add(cellRenderData);
                                    }
                                }
                                if (inspectionItemSubclass.equals("端口间隔离度") && i > (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) && i <= (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) + portRow) {
                                if (inspectionItemSubclass.contains("端口间隔离度") && i > (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) && i <= (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) + portRow) {
                                    ff = (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) + portRow;
                                    if (itemSet.add("端口间隔离度")) {
                                        index.getAndIncrement();
@@ -3327,7 +3630,7 @@
                                        cells.add(cellRenderData);
                                    }
                                }
                                if (inspectionItemSubclass.equals("异极化隔离度") && i >(ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff)&& i <= (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) + portRow) {
                                if (inspectionItemSubclass.contains("异极化隔离度") && i >(ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff)&& i <= (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) + portRow) {
                                    gg = (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) + portRow;
                                    if (itemSet.add("异极化隔离度")) {
                                        index.getAndIncrement();
@@ -3419,7 +3722,7 @@
                                        cells.add(cellRenderData);
                                    }
                                }
                                if (inspectionItemSubclass.equals("互调") && i > (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg)) {
                                if (inspectionItemSubclass.contains("互调") && i > (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg)) {
                                    if (itemSet.add("互调")) {
                                        index.getAndIncrement();
                                    }
@@ -3513,7 +3816,7 @@
                                }
                            } else {
                                //电调版本(复杂版)
                                if (inspectionItemSubclass.equals("电压驻波比") && i <= (angles + 1) * portRow) {
                                if (inspectionItemSubclass.contains("电压驻波比") && i <= (angles + 1) * portRow) {
                                    cc = (angles + 1) * portRow;
                                    if (itemSet.add("电压驻波比")) {
                                        index.getAndIncrement();
@@ -3614,7 +3917,7 @@
                                        cells.add(cellRenderData);
                                    }
                                }
                                if (inspectionItemSubclass.equals("同极化隔离度")) {
                                if (inspectionItemSubclass.contains("同极化隔离度")) {
                                    List<InsProduct> products = insProducts.stream().filter(insProduct -> insProduct.getInspectionItemSubclass().equals("同极化隔离度")).collect(Collectors.toList());
                                    List<InsProductResult2> result2s = productResult2s.stream()
                                            .filter(insProductResult2 -> insProductResult2.getFrequency().equals(s) && insProductResult2.getInsProductId().equals(products.get(0).getId()))
@@ -3737,8 +4040,8 @@
                                        }
                                    }
                                }
                                if (inspectionItemSubclass.equals("隔离度")) {
                                    List<InsProduct> products = insProducts.stream().filter(insProduct -> insProduct.getInspectionItemSubclass().equals("隔离度")).collect(Collectors.toList());
                                if (inspectionItemSubclass.contains("同列隔离度")) {
                                    List<InsProduct> products = insProducts.stream().filter(insProduct -> insProduct.getInspectionItemSubclass().equals("同列隔离度")).collect(Collectors.toList());
                                    List<InsProductResult2> result2s = productResult2s.stream()
                                            .filter(insProductResult2 -> insProductResult2.getFrequency().equals(s) && insProductResult2.getInsProductId().equals(products.get(0).getId()))
                                            .collect(Collectors.toList());
@@ -3747,7 +4050,7 @@
                                    int k = (angles + 1) * portRow2;
                                    if (i > (dd == 0 ? cc : dd) && i <= (dd == 0 ? cc : dd) + k) {
                                        ee = (dd == 0 ? cc : dd) + k;
                                        if (itemSet.add("隔离度")) {
                                        if (itemSet.add("同列隔离度")) {
                                            index.getAndIncrement();
                                        }
                                        //隔离度所在行
@@ -3860,7 +4163,7 @@
                                        }
                                    }
                                }
                                if (inspectionItemSubclass.equals("端口间隔离度")) {
                                if (inspectionItemSubclass.contains("端口间隔离度")) {
                                    List<InsProduct> products = insProducts.stream().filter(insProduct -> insProduct.getInspectionItemSubclass().equals("端口间隔离度")).collect(Collectors.toList());
                                    List<InsProductResult2> result2s = productResult2s.stream()
                                            .filter(insProductResult2 -> insProductResult2.getFrequency().equals(s) && insProductResult2.getInsProductId().equals(products.get(0).getId()))
@@ -3983,7 +4286,7 @@
                                        }
                                    }
                                }
                                if (inspectionItemSubclass.equals("异极化隔离度")) {
                                if (inspectionItemSubclass.contains("异极化隔离度")) {
                                    List<InsProduct> products = insProducts.stream().filter(insProduct -> insProduct.getInspectionItemSubclass().equals("异极化隔离度")).collect(Collectors.toList());
                                    List<InsProductResult2> result2s = productResult2s.stream()
                                            .filter(insProductResult2 -> insProductResult2.getFrequency().equals(s) && insProductResult2.getInsProductId().equals(products.get(0).getId()))
@@ -4105,7 +4408,7 @@
                                        }
                                    }
                                }
                                if (inspectionItemSubclass.equals("互调") && i > (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) && i <= ((gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) + (angles + 1) * portRow * often)) {
                                if (inspectionItemSubclass.contains("互调") && i > (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) && i <= ((gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) + (angles + 1) * portRow * often)) {
                                    hh = (int) ((gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) + (angles + 1) * portRow * often);
                                    if (itemSet.add("互调")) {
                                        index.getAndIncrement();
@@ -4202,7 +4505,7 @@
                                        cells.add(cellRenderData);
                                    }
                                }
                                if (inspectionItemSubclass.equals("最大耦合度") && i > (hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) && i <= ((hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) + (angles + 1))) {
                                if (inspectionItemSubclass.contains("最大耦合度") && i > (hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) && i <= ((hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) + (angles + 1))) {
                                    mm = ((hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) + (angles + 1));
                                    if (itemSet.add("最大耦合度")) {
                                        index.getAndIncrement();
@@ -4295,7 +4598,7 @@
                                        cells.add(cellRenderData);
                                    }
                                }
                                if (inspectionItemSubclass.equals("最小耦合度") && i > (mm == 0 ? (hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) : mm) && i <= ((mm == 0 ? (hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) : mm) + (angles + 1))) {
                                if (inspectionItemSubclass.contains("最小耦合度") && i > (mm == 0 ? (hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) : mm) && i <= ((mm == 0 ? (hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) : mm) + (angles + 1))) {
                                    nn = (mm == 0 ? (hh==0?(gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg):hh) : mm) + (angles + 1);
                                    if (itemSet.add("最小耦合度")) {
                                        index.getAndIncrement();
@@ -4388,7 +4691,7 @@
                                        cells.add(cellRenderData);
                                    }
                                }
                                if (inspectionItemSubclass.equals("幅度偏差")) {
                                if (inspectionItemSubclass.contains("幅度偏差")) {
                                    List<InsProduct> products = insProducts.stream().filter(insProduct -> insProduct.getInspectionItemSubclass().equals("幅度偏差")).collect(Collectors.toList());
                                    List<InsProductResult2> result2s = productResult2s.stream()
                                            .filter(insProductResult2 -> insProductResult2.getFrequency().equals(s) && insProductResult2.getInsProductId().equals(products.get(0).getId()))
@@ -4494,7 +4797,7 @@
                                        }
                                    }
                                }
                                if (inspectionItemSubclass.equals("最大相位偏差")) {
                                if (inspectionItemSubclass.contains("最大相位偏差")) {
                                    List<InsProduct> products = insProducts.stream().filter(insProduct -> insProduct.getInspectionItemSubclass().equals("最大相位偏差")).collect(Collectors.toList());
                                    List<InsProductResult2> result2s = productResult2s.stream()
                                            .filter(insProductResult2 -> insProductResult2.getFrequency().equals(s) && insProductResult2.getInsProductId().equals(products.get(0).getId()))
@@ -4635,6 +4938,194 @@
            });
    }
    //电路报告用于总报告的方法(无源器件)
    private void getWord2(String term, InsOrderState insOrderState,List<Map<String, Object>> tables2){
        AtomicInteger index = new AtomicInteger();
        String title = term + "电路参数";
        //查询样品
        InsSample insSample = insSampleMapper.selectById(insOrderState.getInsSampleId());
        //查询项目
        List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
                .eq(InsProduct::getState,1)
                .eq(InsProduct::getInsSampleId, insSample.getId())
                .eq(InsProduct::getSonLaboratory, "电路试验"));
        //计算行数
        List<InsProductResult2VO> result2VOS = new ArrayList<>();
        List<InsProductResult2VO> insProductResult2VOS = insProductResult2Mapper.selectWordHang(insOrderState.getNum(), insProducts.stream().map(InsProduct::getId).collect(Collectors.toList()));
        for (InsProductResult2VO insProductResult2VO : insProductResult2VOS) {
            String[] split = insProductResult2VO.getPort().split(",");
            String value = insProductResult2VO.getValue().replace("[[", "").replace("]]", "");
            if (split.length>1){
                for (int i = 0; i < split.length; i++) {
                    InsProductResult2VO insProductResult2VO1 = new InsProductResult2VO();
                    BeanUtils.copyProperties(insProductResult2VO,insProductResult2VO1);
                    //端口
                    insProductResult2VO1.setPort(split[i]);
                    //值
                    insProductResult2VO1.setValue(value.split(",")[i].replace("\"",""));
                    result2VOS.add(insProductResult2VO1);
                }
            }
            else {
                insProductResult2VO.setValue(value.replace("\"",""));
                result2VOS.add(insProductResult2VO);
            }
        }
        List<RowRenderData> rows = new ArrayList<>();
        Set<String> itemSet = new HashSet<>();
        //表格的行数
        for (int i = 0; i < result2VOS.size(); i++) {
            RowRenderData rowRenderData = new RowRenderData();
            RowStyle rowStyle = new RowStyle();
            rowStyle.setHeight(40);
            rowRenderData.setRowStyle(rowStyle);
            List<CellRenderData> cells = new ArrayList<>();
            //表格的列数
            for (int j = 0; j < 8; j++) {
                CellRenderData cellRenderData = new CellRenderData();
                CellStyle cellStyle = new CellStyle();
                cellStyle.setVertAlign(XWPFTableCell.XWPFVertAlign.CENTER);
                cellRenderData.setCellStyle(cellStyle);
                List<ParagraphRenderData> paragraphRenderDataList = new ArrayList<>();
                ParagraphRenderData paragraphRenderData = new ParagraphRenderData();
                ParagraphStyle paragraphStyle = new ParagraphStyle();
                paragraphStyle.setAlign(ParagraphAlignment.CENTER);
                paragraphRenderData.setParagraphStyle(paragraphStyle);
                List<RenderData> renderData = new ArrayList<>();
                TextRenderData textRenderData = new TextRenderData();
                Style style = new Style();
                style.setFontFamily("宋体");
                style.setColor("000000");
                textRenderData.setStyle(style);
                if (j==0){
                    //第一列(序号)
                    if (itemSet.add(result2VOS.get(i).getInspectionItemSubclass())) {
                        index.getAndIncrement();
                    }
                    textRenderData.setText(index + "∑1" + index);
                    renderData.add(textRenderData);
                    paragraphRenderData.setContents(renderData);
                    paragraphRenderDataList.add(paragraphRenderData);
                    cellRenderData.setParagraphs(paragraphRenderDataList);
                    cells.add(cellRenderData);
                }
                else if (j==1){
                    //第二列(检验项目)
                    textRenderData.setText(result2VOS.get(i).getInspectionItemSubclass()+ "∑2" + index);
                    renderData.add(textRenderData);
                    paragraphRenderData.setContents(renderData);
                    paragraphRenderDataList.add(paragraphRenderData);
                    cellRenderData.setParagraphs(paragraphRenderDataList);
                    cells.add(cellRenderData);
                }
                else if (j==2){
                    //第三列(单位)
                    textRenderData.setText(result2VOS.get(i).getUnit()+ "∑3" + index);
                    renderData.add(textRenderData);
                    paragraphRenderData.setContents(renderData);
                    paragraphRenderDataList.add(paragraphRenderData);
                    cellRenderData.setParagraphs(paragraphRenderDataList);
                    cells.add(cellRenderData);
                }
                else if (j==3){
                    //第四列(标准与要求)
                    textRenderData.setText(result2VOS.get(i).getAsk());
                    renderData.add(textRenderData);
                    paragraphRenderData.setContents(renderData);
                    paragraphRenderDataList.add(paragraphRenderData);
                    cellRenderData.setParagraphs(paragraphRenderDataList);
                    cells.add(cellRenderData);
                }
                else if (j==4){
                    //第五列(端口)
                    try{
                        textRenderData.setText(result2VOS.get(i).getPort());
                    }catch (Exception e){
                        textRenderData.setText("");
                    }
                    renderData.add(textRenderData);
                    paragraphRenderData.setContents(renderData);
                    paragraphRenderDataList.add(paragraphRenderData);
                    cellRenderData.setParagraphs(paragraphRenderDataList);
                    cells.add(cellRenderData);
                }
                else if (j==5){
                    //第六列(频段)
                    try{
                        textRenderData.setText(result2VOS.get(i).getFrequency());
                    }catch (Exception e){
                        textRenderData.setText("");
                    }
                    renderData.add(textRenderData);
                    paragraphRenderData.setContents(renderData);
                    paragraphRenderDataList.add(paragraphRenderData);
                    cellRenderData.setParagraphs(paragraphRenderDataList);
                    cells.add(cellRenderData);
                }
                else if (j==6){
                    //第七列(检验值)
                    try{
                        textRenderData.setText(result2VOS.get(i).getValue());
                    }catch (Exception e){
                        textRenderData.setText("");
                    }
                    renderData.add(textRenderData);
                    paragraphRenderData.setContents(renderData);
                    paragraphRenderDataList.add(paragraphRenderData);
                    cellRenderData.setParagraphs(paragraphRenderDataList);
                    cells.add(cellRenderData);
                }
                else {
                    //最后一列(结论)
                    try{
                        if (result2VOS.get(i).getResult().equals("1")) {
                            textRenderData.setText("合格");
                        }else if (result2VOS.get(i).getResult().equals("0")){
                            textRenderData.setText("不合格");
                        }else {
                            textRenderData.setText("不判定");
                        }
                    }catch (Exception e){
                        textRenderData.setText("");
                    }
                    renderData.add(textRenderData);
                    paragraphRenderData.setContents(renderData);
                    paragraphRenderDataList.add(paragraphRenderData);
                    cellRenderData.setParagraphs(paragraphRenderDataList);
                    cells.add(cellRenderData);
                }
            }
            rowRenderData.setCells(cells);
            if (rowRenderData.getCells().size() != 0) {
                rows.add(rowRenderData);
            }
        }
        TableRenderData tableRenderData = new TableRenderData();
        tableRenderData.setRows(rows);
        int countSize = tableRenderData.getRows().get(0).getCells().size();
        for (RowRenderData row : tableRenderData.getRows()) {
            if (row.getCells().size() != countSize) {
                throw new ErrorException("每行单元格不相等");
            }
        }
        TableStyle tableStyle = new TableStyle();
        tableStyle.setWidth(XWPFTable.DEFAULT_PERCENTAGE_WIDTH);
        tableStyle.setAlign(TableRowAlign.CENTER);
        BorderStyle borderStyle = new BorderStyle();
        borderStyle.setColor("000000");
        borderStyle.setType(XWPFTable.XWPFBorderType.THICK);
        borderStyle.setSize(4);
        tableStyle.setLeftBorder(borderStyle);
        tableStyle.setTopBorder(borderStyle);
        tableStyle.setRightBorder(borderStyle);
        tableStyle.setBottomBorder(borderStyle);
        tableRenderData.setTableStyle(tableStyle);
        Map<String, Object> table2 = new HashMap<>();
        table2.put("table2", tableRenderData);
        table2.put("title", title);
        tables2.add(table2);
    }
    // 水平合并单元格
    private static void mergeCellsHorizontally(XWPFTable table, int row, int fromCol, int toCol) {
        for (int i = fromCol; i <= toCol; i++) {