chenrui
2025-03-24 54bae7fcc7a2dca32b7614b698c52399b2920b4f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
package com.yuanchu.mom.utils;
 
import cn.hutool.core.lang.UUID;
import com.deepoove.poi.data.*;
import com.deepoove.poi.data.style.*;
import com.yuanchu.mom.dto.Exceldata;
import com.yuanchu.mom.mapper.InsOrderFileMapper;
import com.yuanchu.mom.mapper.InsSampleMapper;
import com.yuanchu.mom.pojo.InsOrderFile;
import com.yuanchu.mom.pojo.InsSample;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STMerge;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.io.*;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
 
@Slf4j
@Component
public class FuSheUtils {
    @Value("${wordUrl}")
    private String wordUrl;
 
    @Resource
    InsOrderFileMapper insOrderFileMapper;
 
    @Resource
    InsSampleMapper insSampleMapper;
 
    //近场
    public void getFuSheWord1(String sonLaboratory, InsOrderFile insOrderFile) {
        //读取excel文件内容
        String excelFilePath = wordUrl + "/" + insOrderFile.getFileUrl(); // 更新为你的文件路径
        FileInputStream fileInputStream = null;
        Workbook workbook = null;
        try {
            fileInputStream = new FileInputStream(new File(excelFilePath));
            workbook = new XSSFWorkbook(fileInputStream); // 对于 .xlsx 文件
            XWPFDocument document = new XWPFDocument();
            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);
                String sheetName = sheet.getSheetName();
                Map<String, Object> map1 = new HashMap<>();
                Map<String, Object> datas = new HashMap<>();
                List<Map<String, Object>> list = new ArrayList<>();
                for (Row row : sheet) {
                    if (row.getRowNum() != 1) {
                        HashMap<String, Object> map = 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 {
                                switch (cell.getCellType()) {
                                    case STRING:
                                        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;
                                        }
                                        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");
                                        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 (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);
            }
            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<Double> floatList = new ArrayList<>();
                    for (Map<String, Object> number : hashMaps) {
                        number.put("端口", s1);
                        Double o = (Double) number.get("频率");
                        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);
                    } 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);
            createWord(sonLaboratory, document, exceldata, map, biaozhun, insOrderFile);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭资源
            try {
                if (workbook != null) {
                    workbook.close();
                }
                if (fileInputStream != null) {
                    fileInputStream.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
 
    //远场
    public void getFuSheWord2(String sonLaboratory, InsOrderFile insOrderFile) {
        //读取excel文件内容
        String excelFilePath = wordUrl + "/" + insOrderFile.getFileUrl(); // 更新为你的文件路径
        FileInputStream fileInputStream = null;
        Workbook workbook = null;
 
        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 + "解析的辐射站点报告.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 + "解析的辐射站点报告.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();
        runs.setBold(true); // 设置文本加粗
        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 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;
            XWPFTable table1 = document.createTable(2, cell);
            mergeCellsHorizontally(table1, 1, 0, cell - 1);
            mergeCellsHorizontally(table1, 0, 4, cell - 2);
            table1.setInsideHBorder(XWPFTable.XWPFBorderType.SINGLE, 2, 0, "000000"); // 内部水平边框
            table1.setInsideVBorder(XWPFTable.XWPFBorderType.SINGLE, 2, 0, "000000"); // 内部垂直边框
            table1.setBottomBorder(XWPFTable.XWPFBorderType.SINGLE, 2, 0, "000000");  // 下边框
            table1.setTopBorder(XWPFTable.XWPFBorderType.SINGLE, 2, 0, "000000");     // 上边框
            table1.setLeftBorder(XWPFTable.XWPFBorderType.SINGLE, 2, 0, "000000");    // 左边框
            table1.setRightBorder(XWPFTable.XWPFBorderType.SINGLE, 2, 0, "000000");   // 右边框
            XWPFParagraph paragraph12 = table1.getRow(0).getCell(0).getParagraphArray(0);
            paragraph12.setAlignment(ParagraphAlignment.CENTER);
            XWPFRun run12 = paragraph12.createRun();
            run12.setText("序号");
            XWPFParagraph paragraph13 = table1.getRow(0).getCell(1).getParagraphArray(0);
            paragraph13.setAlignment(ParagraphAlignment.CENTER);
            XWPFRun run13 = paragraph13.createRun();
            run13.setText("检验项目");
            XWPFParagraph paragraph14 = table1.getRow(0).getCell(2).getParagraphArray(0);
            paragraph14.setAlignment(ParagraphAlignment.CENTER);
            XWPFRun run14 = paragraph14.createRun();
            run14.setText("单位");
            XWPFParagraph paragraph15 = table1.getRow(0).getCell(3).getParagraphArray(0);
            paragraph15.setAlignment(ParagraphAlignment.CENTER);
            XWPFRun run15 = paragraph15.createRun();
            run15.setText("标准要求");
            XWPFParagraph paragraph16 = table1.getRow(0).getCell(cell - 1).getParagraphArray(0);
            paragraph16.setAlignment(ParagraphAlignment.CENTER);
            XWPFRun run16 = paragraph16.createRun();
            run16.setText("检验结论");
            XWPFParagraph paragraph17 = table1.getRow(0).getCell(4).getParagraphArray(0);
            paragraph17.setAlignment(ParagraphAlignment.CENTER);
            XWPFRun run17 = paragraph17.createRun();
            run17.setText("检验结果");
            XWPFParagraph paragraph18 = table1.getRow(1).getCell(0).getParagraphArray(0);
            paragraph18.setAlignment(ParagraphAlignment.CENTER);
            XWPFRun run18 = paragraph18.createRun();
            run18.setText("下倾角" + result);
            List<String> collect = Arrays.stream(split).collect(Collectors.toList());
            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("端口")) {
                    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);
                }
            }
            int rowNum = 2;
            for (String s2 : aggregatedMap.keySet()) {
                if (s2.equals("端口") || s2.equals("频率")) {
                    continue;
                }
                List<Map<String, Object>> mapList = aggregatedMap.get(s2);
                // 创建一个表格
                int checkItemRowNum = row;
                for (int i = 0; i < checkItemRowNum; i++) {
                    XWPFTableRow tableRow = table1.createRow();
                    for (XWPFTableCell tableCell : tableRow.getTableCells()) {
                        // 设置单元格内容居中对齐
                        for (XWPFParagraph paragraph : tableCell.getParagraphs()) {
                            paragraph.setAlignment(ParagraphAlignment.CENTER);
                        }
                    }
                }
                //垂直
                mergeCellsVertically(table1, 0, rowNum, rowNum + checkItemRowNum - 1);
                mergeCellsVertically(table1, 1, rowNum, rowNum + checkItemRowNum - 1);
                mergeCellsVertically(table1, 2, rowNum, rowNum + checkItemRowNum - 1);
                mergeCellsVertically(table1, 3, rowNum, rowNum + checkItemRowNum - 1);
                mergeCellsVertically(table1, 4, rowNum, rowNum + 1);
                mergeCellsVertically(table1, cell - 1, rowNum, rowNum + 1);
                mergeCellsVertically(table1, cell - 1, rowNum + 2, rowNum + checkItemRowNum - 2);
                //水平
                mergeCellsHorizontally(table1, rowNum, 5, cell - 2);
                mergeCellsHorizontally(table1, rowNum + checkItemRowNum - 1, 5, cell - 2);
 
                // 设置单元格文本并居中
                XWPFParagraph paragraph = table1.getRow(rowNum).getCell(0).getParagraphArray(0);
                paragraph.setAlignment(ParagraphAlignment.CENTER);
                XWPFRun run = paragraph.createRun();
                run.setText(String.valueOf(size));
                XWPFParagraph paragraph1 = table1.getRow(rowNum).getCell(1).getParagraphArray(0);
                paragraph1.setAlignment(ParagraphAlignment.CENTER);
                XWPFRun run1 = paragraph1.createRun();
                run1.setText(s2);
                // 单位
                XWPFParagraph paragraph2 = table1.getRow(rowNum).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 = table1.getRow(rowNum).getCell(3).getParagraphArray(0);
                paragraph3.setAlignment(ParagraphAlignment.CENTER);
                XWPFRun run3 = paragraph3.createRun();
                String checkItemStandardStr = "";
                if (bz.get(s2) != null) {
                    run3.setText(bz.get(s2).toString());
                    checkItemStandardStr = bz.get(s2).toString();
                } else {
                    run3.setText("");
                }
                XWPFParagraph paragraph4 = table1.getRow(rowNum).getCell(4).getParagraphArray(0);
                paragraph4.setAlignment(ParagraphAlignment.CENTER);
                XWPFRun run4 = paragraph4.createRun();
                run4.setText("频率(MHz)");
                XWPFParagraph paragraph5 = table1.getRow(rowNum).getCell(5).getParagraphArray(0);
                paragraph5.setAlignment(ParagraphAlignment.CENTER);
                XWPFRun run5 = paragraph5.createRun();
                run5.setText("端口");
                XWPFParagraph paragraph6 = table1.getRow(rowNum).getCell(cell - 1).getParagraphArray(0);
                paragraph6.setAlignment(ParagraphAlignment.CENTER);
                XWPFRun run6 = paragraph6.createRun();
                run6.setText("判定");
//                XWPFParagraph paragraph7 = table1.getRow(rowNum + 2 ).getCell(cell - 1).getParagraphArray(0);
//                paragraph7.setAlignment(ParagraphAlignment.CENTER);
//                XWPFRun run7 = paragraph7.createRun();
//                run7.setText("合格");
                XWPFParagraph paragraph8 = table1.getRow(rowNum + checkItemRowNum - 1).getCell(4).getParagraphArray(0);
                paragraph8.setAlignment(ParagraphAlignment.CENTER);
                XWPFRun run8 = paragraph8.createRun();
                run8.setText("平均值");
                XWPFParagraph paragraph9 = table1.getRow(rowNum + checkItemRowNum - 1).getCell(cell - 1).getParagraphArray(0);
                paragraph9.setAlignment(ParagraphAlignment.CENTER);
                XWPFRun run9 = paragraph9.createRun();
                run9.setText("");
                for (int i = 0; i < collect.size(); i++) {
                    String s3 = collect.get(i);
                    if (s3.contains("端口")) {
                        XWPFParagraph paragraph10 = table1.getRow(rowNum + 1).getCell(5 + i).getParagraphArray(0);
                        paragraph10.setAlignment(ParagraphAlignment.CENTER);
                        XWPFRun run10 = paragraph10.createRun();
                        run10.setText(s3);
                    }
                }
                Map<BigDecimal, List<Map<String, Object>>> group = mapList.stream()
                        .collect(Collectors.groupingBy(item -> {
                            BigDecimal value = new BigDecimal(String.valueOf(item.get("频率")));
                            if (value.scale() <= 0 || value.stripTrailingZeros().scale() <= 0) {
                                // 没有小数部分,返回整数字符串
                                return new BigDecimal(value.intValue());
                            } else {
                                // 有小数部分,返回原始值的字符串形式
                                return value;
                            }
                        }));
                group = new TreeMap<>(group);
                int hang = 2;
                Double count = 0.0;
                // 定义 是否合格标记
                boolean passFlag = true;
                // 解析判定条件并解析比较标准值 0 无需判定 1 区间判定 2 小于等于 3 大于等于 4 大于 5 小于
                int checkType = 0;
                double firstParam = 0.0;
                double secondParam = 0.0 ;
                checkItemStandardStr = checkItemStandardStr.trim();
                if(checkItemStandardStr.contains("~") ){
                    checkType = 1;
                    String[] params = checkItemStandardStr.split("~");
                    if(null != params && params.length == 2){
                        firstParam = Double.valueOf(params[0]);
                        secondParam = Double.valueOf(params[1]);
                    }
                } else if(checkItemStandardStr.contains("-") && !(checkItemStandardStr.contains("≤") || checkItemStandardStr.contains("≥") || checkItemStandardStr.contains(">") || checkItemStandardStr.contains("<"))){
                    checkType = 1;
                    String[] params = checkItemStandardStr.split("-");
                    if(null != params && params.length == 2){
                        firstParam = Double.valueOf(params[0]);
                        secondParam = Double.valueOf(params[1]);
                    }
                } else if (checkItemStandardStr.contains("≤")) {
                    checkType = 2;
                    String[] params = checkItemStandardStr.split("≤");
                    if(null != params && params.length == 1){
                        if(params[1].contains("%")){
                            firstParam = Double.valueOf(params[1].substring(0,params[1].length()-1))/100;
                        }else{
                            firstParam = Double.valueOf(params[1]);
                        }
                    }
                }else if(checkItemStandardStr.contains("≥")){
                    checkType = 3;
                    String[] params = checkItemStandardStr.split("≥");
                    if(null != params && params.length == 2){
                        if(params[1].contains("%")){
                            firstParam = Double.valueOf(params[1].substring(0,params[1].length()-1))/100;
                        }else{
                            firstParam = Double.valueOf(params[1]);
                        }
                    }
                }else if(checkItemStandardStr.contains(">")){
                    checkType = 4;
                    String[] params = checkItemStandardStr.split(">");
                    if(null != params && params.length == 2){
                        if(params[1].contains("%")){
                            firstParam = Double.valueOf(params[1].substring(0,params[1].length()-1))/100;
                        }else{
                            firstParam = Double.valueOf(params[1]);
                        }
                    }
                }else if(checkItemStandardStr.contains("<")){
                    checkType = 5;
                    String[] params = checkItemStandardStr.split("<");
                    if(null != params && params.length == 2){
                        if(params[1].contains("%")){
                            firstParam = Double.valueOf(params[1].substring(0,params[1].length()-1))/100;
                        }else{
                            firstParam = Double.valueOf(params[1]);
                        }
                    }
                }
                for (BigDecimal 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 = table1.getRow(rowNum + 1).getCell(i).getText();
                            if (text.equals(port)) {
                                XWPFParagraph paragraph10 = table1.getRow(hang + rowNum).getCell(i).getParagraphArray(0);
                                paragraph10.setAlignment(ParagraphAlignment.CENTER);
                                XWPFRun run10 = paragraph10.createRun();
                                double value = Double.parseDouble(stringObjectMap.get(s2).toString());
                                count = value + count;
                                // 数据判断
                                if(checkType == 1){
                                    if(!(value >= firstParam && value <= secondParam)){
                                        passFlag = false;
                                    }
                                }else if(checkType == 2){
                                    if(value >= firstParam ){
                                        passFlag = false;
                                    }
                                }else if(checkType == 3){
                                    if(value <= firstParam ){
                                        passFlag = false;
                                    }
                                }else if(checkType == 4){
                                    if(value < firstParam ){
                                        passFlag = false;
                                    }
                                }else if(checkType == 5){
                                    if(value > firstParam ){
                                        passFlag = false;
                                    }
                                }
                                run10.setText(String.format("%.2f", value));
                            }
                        }
                    }
                    XWPFParagraph paragraph10 = table1.getRow(hang+rowNum).getCell(4).getParagraphArray(0);
                    paragraph10.setAlignment(ParagraphAlignment.CENTER);
                    XWPFRun run10 = paragraph10.createRun();
                    run10.setText(String.valueOf(aDouble));
                    hang++;
                }
                // 汇总结果
                if(checkType != 0){
                    XWPFParagraph paragraph10 = table1.getRow(rowNum+2).getCell(cell - 1).getParagraphArray(0);
                    XWPFRun run10 = paragraph10.createRun();
                    if(passFlag){
                        run10.setText("合格");
                    }else {
                        run10.setText("不合格");
                    }
                }
 
                XWPFParagraph paragraph11 = table1.getRow(rowNum + checkItemRowNum - 1).getCell(5).getParagraphArray(0);
                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));
                rowNum += checkItemRowNum;
                size++;
            }
        }
        // 输出到文件
        try {
            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 + "解析的辐射站点报告.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.setInsSampleId(insOrderFile.getInsSampleId());
            orderFile.setFileUrl(url);
            orderFile.setType(2);
            orderFile.setFileName(insSample.getSampleCode() + "&" + sonLaboratory + name + "解析的辐射站点报告.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 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);
            table1.setWidth("100%");
 
            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("下倾角" + 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);
                }
            }
            // 初始化行数
            int rowNum = 2;
            for (String s2 : aggregatedMap.keySet()) {
                if (s2.equals("端口") || s2.equals("测试频率(MHZ)")) {
                    continue;
                }
                List<Map<String, Object>> mapList = aggregatedMap.get(s2);
                int checkItemRowNum = row;
                for (int i = 0; i < checkItemRowNum; i++) {
                    // 创建新行 并设置居中
                    XWPFTableRow tableRow = table1.createRow();
                    for (XWPFTableCell tableCell : tableRow.getTableCells()) {
                        // 设置单元格内容居中对齐
                        for (XWPFParagraph paragraph : tableCell.getParagraphs()) {
                            paragraph.setAlignment(ParagraphAlignment.CENTER);
                        }
                    }
                }
//            XWPFTable table = document.createTable(row, cell);
                //垂直
                mergeCellsVertically(table1, 0, rowNum, rowNum +  checkItemRowNum - 1);
                mergeCellsVertically(table1, 1, rowNum, rowNum +  checkItemRowNum - 1);
                mergeCellsVertically(table1, 2, rowNum, rowNum +  checkItemRowNum - 1);
                mergeCellsVertically(table1, 3, rowNum, rowNum +  checkItemRowNum - 1);
                mergeCellsVertically(table1, 4, rowNum, rowNum+1);
                mergeCellsVertically(table1, cell - 1, rowNum, rowNum+1);
                mergeCellsVertically(table1, cell - 1, rowNum+2, rowNum +  checkItemRowNum - 1);
                //水平
                mergeCellsHorizontally(table1, rowNum, 5, cell - 2);
                mergeCellsHorizontally(table1, rowNum + checkItemRowNum - 1, 5, cell - 2);
 
                // 设置单元格文本并居中
                XWPFParagraph paragraph = table1.getRow(rowNum).getCell(0).getParagraphArray(0);
                XWPFRun run = paragraph.createRun();
                run.setText(String.valueOf(size));
 
 
                XWPFParagraph paragraph1 = table1.getRow(rowNum).getCell(1).getParagraphArray(0);
                XWPFRun run1 = paragraph1.createRun();
                run1.setText(s2);
 
                // 单位
                XWPFParagraph paragraph2 = table1.getRow(rowNum).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("");
                }
 
 
                // 定义改检查项标准值
                String checkItemStandardStr = "";
                XWPFParagraph paragraph3 = table1.getRow(rowNum).getCell(3).getParagraphArray(0);
                XWPFRun run3 = paragraph3.createRun();
                if (bz.get(s2) != null) {
                    run3.setText(bz.get(s2).toString());
                    checkItemStandardStr = bz.get(s2).toString();
                } else run3.setText("");
 
 
                XWPFParagraph paragraph4 = table1.getRow(rowNum).getCell(4).getParagraphArray(0);
                paragraph4.setAlignment(ParagraphAlignment.CENTER);
                XWPFRun run4 = paragraph4.createRun();
                run4.setText("频率(MHz)");
 
                XWPFParagraph paragraph5 = table1.getRow(rowNum).getCell(5).getParagraphArray(0);
                XWPFRun run5 = paragraph5.createRun();
                run5.setText("端口");
 
                XWPFParagraph paragraph6 = table1.getRow(rowNum).getCell(cell - 1).getParagraphArray(0);
                XWPFRun run6 = paragraph6.createRun();
                run6.setText("判定");
 
                XWPFParagraph paragraph7 = table1.getRow(rowNum+1).getCell(cell - 1).getParagraphArray(0);
                XWPFRun run7 = paragraph7.createRun();
                run7.setText("合格");
 
 
                XWPFParagraph paragraph8 = table1.getRow(rowNum+checkItemRowNum - 1).getCell(4).getParagraphArray(0);
                XWPFRun run8 = paragraph8.createRun();
                run8.setText("平均值");
 
                XWPFParagraph paragraph9 = table1.getRow(rowNum + checkItemRowNum - 1).getCell(cell - 1).getParagraphArray(0);
                XWPFRun run9 = paragraph9.createRun();
                run9.setText("");
 
                for (int i = 0; i < collect.size() - 1; i++) {
                    String s3 = collect.get(i);
                    if (s3.contains("端口") || s3.contains("P")) {
                        XWPFParagraph paragraph10 = table1.getRow(rowNum+1).getCell(5 + i).getParagraphArray(0);
                        XWPFRun run10 = paragraph10.createRun();
                        run10.setText(s3);
                    }
                }
 
                Map<BigDecimal, List<Map<String, Object>>> group = mapList.stream()
                        .collect(Collectors.groupingBy(item -> {
                            BigDecimal value = new BigDecimal(String.valueOf(item.get("测试频率(MHZ)")));
                            if (value.scale() <= 0 || value.stripTrailingZeros().scale() <= 0) {
                                // 没有小数部分,返回整数字符串
                                return new BigDecimal(value.intValue());
                            } else {
                                // 有小数部分,返回原始值的字符串形式
                                return value;
                            }
                        }));
 
 
                int hang = 2;
                Double count = 0.0;
                // 定义 是否合格标记
                boolean passFlag = true;
                // 解析判定条件并解析比较标准值 0 无需判定 1 区间判定 2 小于等于 3 大于等于
                int checkType = 0;
                double firstParam = 0.0;
                double secondParam = 0.0 ;
                checkItemStandardStr = checkItemStandardStr.trim();
                if(checkItemStandardStr.contains("~") ){
                    checkType = 1;
                    String[] params = checkItemStandardStr.split("~");
                    if(null != params && params.length == 2){
                        firstParam = Double.valueOf(params[0]);
                        secondParam = Double.valueOf(params[1]);
                    }
                } else if(checkItemStandardStr.contains("-") && !(checkItemStandardStr.contains("≤") || checkItemStandardStr.contains("≥") || checkItemStandardStr.contains(">") || checkItemStandardStr.contains("<"))){
                    checkType = 1;
                    String[] params = checkItemStandardStr.split("-");
                    if(null != params && params.length == 2){
                        firstParam = Double.valueOf(params[0]);
                        secondParam = Double.valueOf(params[1]);
                    }
                } else if (checkItemStandardStr.contains("≤")) {
                    checkType = 2;
                    String[] params = checkItemStandardStr.split("≤");
                    if(null != params && params.length == 1){
                        if(params[1].contains("%")){
                            firstParam = Double.valueOf(params[1].substring(0,params[1].length()-1))/100;
                        }else{
                            firstParam = Double.valueOf(params[1]);
                        }
                    }
                }else if(checkItemStandardStr.contains("≥")){
                    checkType = 3;
                    String[] params = checkItemStandardStr.split("≥");
                    if(null != params && params.length == 2){
                        if(params[1].contains("%")){
                            firstParam = Double.valueOf(params[1].substring(0,params[1].length()-1))/100;
                        }else{
                            firstParam = Double.valueOf(params[1]);
                        }
                    }
                }else if(checkItemStandardStr.contains(">")){
                    checkType = 4;
                    String[] params = checkItemStandardStr.split(">");
                    if(null != params && params.length == 2){
                        if(params[1].contains("%")){
                            firstParam = Double.valueOf(params[1].substring(0,params[1].length()-1))/100;
                        }else{
                            firstParam = Double.valueOf(params[1]);
                        }
                    }
                }else if(checkItemStandardStr.contains("<")){
                    checkType = 5;
                    String[] params = checkItemStandardStr.split("<");
                    if(null != params && params.length == 2){
                        if(params[1].contains("%")){
                            firstParam = Double.valueOf(params[1].substring(0,params[1].length()-1))/100;
                        }else{
                            firstParam = Double.valueOf(params[1]);
                        }
                    }
                }
 
                for (BigDecimal 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 = table1.getRow(rowNum+1).getCell(i).getText();
                            if (text.equals(port)) {
                                XWPFParagraph paragraph10 = table1.getRow(hang+rowNum).getCell(i).getParagraphArray(0);
                                XWPFRun run10 = paragraph10.createRun();
                                double value = Double.parseDouble(stringObjectMap.get(s2).toString());
                                count = value + count;
                                // 数据判断
                                if(checkType == 1){
                                    if(!(value >= firstParam && value <= secondParam)){
                                        passFlag = false;
                                    }
                                }else if(checkType == 2){
                                    if(value >= firstParam ){
                                        passFlag = false;
                                    }
                                }else if(checkType == 3){
                                    if(value <= firstParam ){
                                        passFlag = false;
                                    }
                                }else if(checkType == 4){
                                    if(value < firstParam ){
                                        passFlag = false;
                                    }
                                }else if(checkType == 5){
                                    if(value > firstParam ){
                                        passFlag = false;
                                    }
                                }
                                run10.setText(String.format("%.2f",value));
                            }
                        }
                    }
                    XWPFParagraph paragraph10 = table1.getRow(hang+rowNum).getCell(4).getParagraphArray(0);
                    XWPFRun run10 = paragraph10.createRun();
                    run10.setText(String.valueOf(aDouble));
                    hang++;
                }
                // 汇总结果
                if(checkType != 0){
                    XWPFParagraph paragraph10 = table1.getRow(rowNum+2).getCell(cell - 1).getParagraphArray(0);
                    XWPFRun run10 = paragraph10.createRun();
                    if(passFlag){
                        run10.setText("合格");
                    }else {
                        run10.setText("不合格");
                    }
                }
 
                XWPFParagraph paragraph11 = table1.getRow(rowNum + checkItemRowNum - 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)));
                rowNum += checkItemRowNum;
                size++;
            }
        }
    }
 
 
    // 水平合并单元格
    private static void mergeCellsHorizontally(XWPFTable table, int row, int fromCol, int toCol) {
 
        for (int i = fromCol; i <= toCol; i++) {
            if (i == fromCol) {
                table.getRow(row).getCell(i).getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.RESTART);
            } else {
                table.getRow(row).getCell(i).getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.CONTINUE);
            }
 
        }
    }
 
    // 垂直合并单元格
    private static void mergeCellsVertically(XWPFTable table, int col, int fromRow, int toRow) {
        for (int i = fromRow; i <= toRow; i++) {
            if (i == fromRow) {
                table.getRow(i).getCell(col).getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.RESTART);
            } else {
                table.getRow(i).getCell(col).getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.CONTINUE);
            }
        }
    }
 
}