From ed56ae711e18c6f7624dac633c4af3ecfcf09520 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期五, 18 九月 2026 16:40:19 +0800
Subject: [PATCH] fix:报告生成所有带导出值批注的检验项

---
 inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java |  575 ++++++++++++++++++++++++++++++++------------------------
 1 files changed, 327 insertions(+), 248 deletions(-)

diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
index ca5e881..f09b388 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
@@ -281,12 +281,12 @@
 
     /**
      * 鐩寸粦妯℃澘璁㈠崟鐨勯〉绛炬潵婧愭槸璁㈠崟妯℃澘蹇収锛岃�屼笉鏄凡鐢熸垚鐨勬楠岄」銆�
-     *
+     * <p>
      * 浠嶄繚鐣欐瘡涓ā鏉夸笅宸叉湁鐨勬楠岄」璁板綍锛涘鏋滄煇涓ā鏉挎病鏈夆�滄楠岄」鈥濇爣璁帮紝琛ヤ竴鏉′粎鐢ㄤ簬
      * 鎵胯浇妯℃澘鍐呭鐨勮繑鍥炲璞★紝浣垮墠绔篃鑳藉睍绀恒�佸~鍐欒妯℃澘銆�
      */
     private List<InsProduct> mergeDirectTemplateSnapshots(InsOrder order, Integer sampleId,
-                                                           String laboratory, List<InsProduct> products) {
+                                                          String laboratory, List<InsProduct> products) {
         List<InsProduct> source = products == null ? new ArrayList<>() : products;
         List<InsOrderStandardTemplate> snapshots = insOrderStandardTemplateService.list(
                 Wrappers.<InsOrderStandardTemplate>lambdaQuery()
@@ -343,7 +343,7 @@
     }
 
     @Override
-    public Map<String,Object> checkSubmitPlan(Integer orderId, String laboratory) {
+    public Map<String, Object> checkSubmitPlan(Integer orderId, String laboratory) {
         Map<String, Object> map = new HashMap<>();
         List<String> collect = new ArrayList<>();
         if (isDirectTemplateOrder(orderId)) {
@@ -634,7 +634,10 @@
 
         JSONObject values = JSON.parseObject(JSON.toJSONString(dto.getValues() == null
                 ? Collections.emptyMap() : dto.getValues()));
-        List<String> exportValueCoordinates = getExportValueCoordinates(snapshot.getThing()).values().stream()
+        // 妫�楠屾湡闂撮〉闈㈠睍绀虹殑鏄爣鍑嗙淮鎶や腑鐨勬渶鏂版ā鏉匡紝淇濆瓨鏍¢獙蹇呴』浣跨敤鍚屼竴浠芥ā鏉匡紝
+        // 閬垮厤妯℃澘鏂板鈥滃鍑哄�尖�濇壒娉ㄥ悗浠嶆寜涓嬪崟鏃剁殑鏃у揩鐓ц鎶ユ湭閰嶇疆銆�
+        String currentTemplateThing = getCurrentTemplateThing(snapshot);
+        List<String> exportValueCoordinates = getExportValueCoordinates(currentTemplateThing).values().stream()
                 .flatMap(Collection::stream)
                 .distinct()
                 .collect(Collectors.toList());
@@ -777,6 +780,20 @@
     }
 
     /**
+     * 妫�楠屼繚瀛樸�佹彁浜ゆ牎楠岃鍙栨爣鍑嗙淮鎶や腑鐨勫疄鏃舵ā鏉匡紱妯℃澘宸茶鍒犻櫎鎴栧唴瀹逛负绌烘椂鎵嶅洖閫�璁㈠崟蹇収銆�
+     * 妫�楠屽畬鎴愬悗鐨勫睍绀哄拰鎶ュ憡浠嶇敱璁㈠崟蹇収璐熻矗锛屼笉浼氶殢鏍囧噯妯℃澘鍚庣画淇敼鑰屽彉鍖栥��
+     */
+    private String getCurrentTemplateThing(InsOrderStandardTemplate snapshot) {
+        if (snapshot != null && snapshot.getTemplateId() != null) {
+            StandardTemplate currentTemplate = standardTemplateService.getById(snapshot.getTemplateId());
+            if (currentTemplate != null && StrUtil.isNotBlank(currentTemplate.getThing())) {
+                return currentTemplate.getThing();
+            }
+        }
+        return snapshot == null ? null : snapshot.getThing();
+    }
+
+    /**
      * 鐩寸粦妯℃澘璁㈠崟鍙牎楠屾ā鏉夸腑鏍囪涓衡�滃鍑哄�尖�濈殑鍗曞厓鏍硷紝涓嶄娇鐢ㄦ楠岄」鐘舵�佹垨 last_value 鍒ゅ畾銆�
      */
     private List<String> getMissingTemplateExportValues(Integer orderId) {
@@ -791,7 +808,7 @@
         }
         for (InsOrderStandardTemplate snapshot : snapshots) {
             Integer templateId = snapshot.getTemplateId();
-            List<String> coordinates = getExportValueCoordinates(snapshot.getThing()).values().stream()
+            List<String> coordinates = getExportValueCoordinates(getCurrentTemplateThing(snapshot)).values().stream()
                     .flatMap(Collection::stream)
                     .distinct()
                     .collect(Collectors.toList());
@@ -803,12 +820,12 @@
 
             JSONObject recordValues = StrUtil.isBlank(snapshot.getRecordValues())
                     ? new JSONObject() : JSON.parseObject(snapshot.getRecordValues());
-            // 淇濆瓨鏃跺悓鏍峰彧鍙栨ā鏉夸腑鐨勭涓�涓鍑哄�硷紝鎻愪氦鏍¢獙涓庝繚瀛樺彛寰勪繚鎸佷竴鑷淬��
-            String coordinate = coordinates.get(0);
-            JSONObject cell = recordValues.getJSONObject(coordinate);
-            Object value = cell == null ? null : cell.get("v");
-            if (value == null || StringUtils.isBlank(String.valueOf(value))) {
-                missing.add(templateName + "锛�" + coordinate + "锛�");
+            for (String coordinate : coordinates) {
+                JSONObject cell = recordValues.getJSONObject(coordinate);
+                Object value = cell == null ? null : cell.get("v");
+                if (value == null || StringUtils.isBlank(String.valueOf(value))) {
+                    missing.add(templateName + "锛�" + coordinate + "锛�");
+                }
             }
         }
         return missing;
@@ -829,7 +846,7 @@
             throw new ErrorException("妫�楠屽崟涓嶅瓨鍦�");
         }
         Set<Integer> deviceIds = dto.getDeviceIds() == null ? Collections.emptySet() : dto.getDeviceIds().stream()
-                .filter(Objects::nonNull).collect(Collectors.toSet());
+                                                                                       .filter(Objects::nonNull).collect(Collectors.toSet());
         List<InsOrderDeviceRecord> oldRecords = insOrderDeviceRecordMapper.selectList(
                 Wrappers.<InsOrderDeviceRecord>lambdaQuery().eq(InsOrderDeviceRecord::getInsOrderId, dto.getOrderId()));
         Set<Integer> oldIds = oldRecords.stream().map(InsOrderDeviceRecord::getDeviceId).collect(Collectors.toSet());
@@ -926,6 +943,7 @@
 
     /**
      * 鏌ヨ妯℃澘鍐呭
+     *
      * @param order
      * @param insProducts
      */
@@ -1007,6 +1025,7 @@
 
     /**
      * todo: 鍘熷璁板綍妯℃澘娓呴櫎娌℃湁浣跨敤鐨勬楠岄」(鏆傛椂鏈塨ug鏃犳硶浣跨敤)
+     *
      * @param sheet
      * @param itemNameList
      */
@@ -1079,6 +1098,7 @@
 
     /**
      * 鍧愭爣鎷兼帴
+     *
      * @param r 妯潗鏍�
      * @param c 绾靛潗鏍�
      * @return
@@ -1152,7 +1172,7 @@
             int count = 0;
             for (InsProduct product : insProducts) {
                 count++;
-                str +=  (count != 0 ? "\n" : "") + count + "锛�" +
+                str += (count != 0 ? "\n" : "") + count + "锛�" +
                         product.getInspectionItemClass() + " " +
                         product.getInspectionItem() + " " +
                         product.getInspectionItemSubclass();
@@ -1279,7 +1299,7 @@
             // 鐧昏妫�楠岀粨鏋�
             // 鍒ゆ柇鏄惁鏈変笉鍚堟牸, 鏈変笉鍚堟牸涓嶈兘绉诲簱
             // todo: ifs绉诲簱
-            insReportService.isRawMaterial(order,registerInsResults,false);
+            insReportService.isRawMaterial(order, registerInsResults, false);
 
             // 14 鍒ゆ柇褰撳墠鏍峰搧鏄惁涓哄師鏉愭枡, 鍘熸潗鏂欓渶瑕佽繘琛屾暟鎹垎鏋�, 鍒ゆ柇涔嬪墠10鏉℃暟鎹悓涓�涓緵搴斿晢, 鍚屼竴涓楠岄」鐨勫亸宸槸鍚﹁秴杩�10%
             // 鏌ヨifs淇℃伅鑾峰彇鑾峰彇鍓�10涓緵搴斿晢涓�鏍风殑, 妫�楠岄」涓�鏍蜂俊鎭�
@@ -1309,6 +1329,7 @@
 
     /**
      * *****娣诲姞鍒嗘瀽鏁版嵁******
+     *
      * @param productList
      * @param ifsInventoryQuantity
      * @param order
@@ -1399,6 +1420,7 @@
 
     /**
      * *****璁$畻鍋忓樊****
+     *
      * @param data
      * @param targetStr
      * @return
@@ -1424,12 +1446,13 @@
 
     /**
      * *****璁$畻鍋忓樊锛堣姹傚�硷級****
+     *
      * @param asked
      * @param targetStr
      * @return
      */
     public static double isDeviationOverTenPercentByAsked(String asked, String targetStr) {
-        if(!isNumeric(asked)) return 0;
+        if (!isNumeric(asked)) return 0;
         double average = Double.parseDouble(asked);
         double target = Double.parseDouble(targetStr);
         double deviationPercent = Math.abs(target - average) / average * 100;
@@ -1442,6 +1465,7 @@
 
     /**
      * ******鍘熷璁板綍妯℃澘澶嶅埗*****
+     *
      * @param orderId
      * @param ids
      */
@@ -1524,6 +1548,7 @@
 
     /**
      * 妫�楠屼换鍔″鏍�
+     *
      * @param orderId
      * @param laboratory
      * @param type
@@ -1599,7 +1624,7 @@
                     .collect(Collectors.toList());
             if (templateResults.isEmpty()
                     || templateResults.stream().anyMatch(result -> !Objects.equals(result, 0)
-                            && !Objects.equals(result, 1))) {
+                    && !Objects.equals(result, 1))) {
                 throw new ErrorException("璇峰厛濉啓鍏ㄩ儴妯℃澘鐨勬楠岀粨璁�");
             }
             Integer aggregateResult = templateResults.stream().allMatch(result -> Objects.equals(result, 1))
@@ -1777,6 +1802,7 @@
 
     /**
      * 鐢熸垚鎶ュ憡
+     *
      * @param orderId
      */
     private void generateReport(Integer orderId, Integer reportType, Integer writeUserId) {
@@ -1784,19 +1810,19 @@
         //杩欓噷鐨刬nsSamples鏄鍗曚笅鐨勬墍鏈夋牱鍝佸寘鎷�("/")
         List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId));
         if (Objects.equals(reportType, INSPECTION_REPORT)) {
-        for (InsSample insSample : insSamples) {
-            List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
-                    .eq(InsProduct::getInsSampleId, insSample.getId())
-                    .eq(InsProduct::getState, 1)
-                    .ne(InsProduct::getIsBinding, 1));
-            List<Integer> results = insProducts.stream().map(InsProduct::getInsResult).filter(Objects::nonNull).collect(Collectors.toList());
-            if (results.contains(0)) {
-                insSample.setInsResult(0);
-            } else {
-                insSample.setInsResult(1);
+            for (InsSample insSample : insSamples) {
+                List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
+                        .eq(InsProduct::getInsSampleId, insSample.getId())
+                        .eq(InsProduct::getState, 1)
+                        .ne(InsProduct::getIsBinding, 1));
+                List<Integer> results = insProducts.stream().map(InsProduct::getInsResult).filter(Objects::nonNull).collect(Collectors.toList());
+                if (results.contains(0)) {
+                    insSample.setInsResult(0);
+                } else {
+                    insSample.setInsResult(1);
+                }
+                insSampleMapper.updateById(insSample);
             }
-            insSampleMapper.updateById(insSample);
-        }
         }
         InsOrder insOrder = insOrderMapper.selectById(orderId);
         // 鎶芥鍙樻垚濮旀墭妫�楠�
@@ -1818,6 +1844,7 @@
 
     /**
      * 鐢电紗閰嶇疆, 鏌ョ湅閰嶇疆鏍囪瘑
+     *
      * @param id
      * @param laboratory
      * @return
@@ -1829,6 +1856,7 @@
 
     /**
      * 鍘熸潗鏂欐煡鐪嬫爣璇�
+     *
      * @param id
      * @param laboratory
      * @return
@@ -1840,6 +1868,7 @@
 
     /**
      * 鏌ョ湅閲嶅鏍囪瘑
+     *
      * @param id
      * @param laboratory
      * @return
@@ -1851,6 +1880,7 @@
 
     /**
      * 鏂板涓嶅悎鏍煎娴嬪唴瀹�
+     *
      * @return
      */
     @Override
@@ -2047,6 +2077,7 @@
 
     /**
      * 鏌ヨ杩涜揣鍘熷璁板綍
+     *
      * @param insOrderId
      * @return
      */
@@ -2102,6 +2133,7 @@
 
     /**
      * 淇濆瓨鍘熸潗鏂欒繘璐ч獙璇�
+     *
      * @param factoryVerify
      * @return
      */
@@ -2153,22 +2185,34 @@
 
     /**
      * 璁剧疆琛ㄦ牸鏍峰紡
+     *
      * @param max 鏍囪瘑鏈�澶т釜鏁�
      * @return
      */
-    private TableStyle setTableStyle(int max, boolean showResult){
+    private TableStyle setTableStyle(int max, boolean showResult) {
         //璁剧疆鏍峰紡
         TableStyle tableStyle = new TableStyle();
         if (!showResult) {
             switch (max) {
-                case 1: tableStyle.setColWidths(new int[]{650, 3000, 850, 2400, 3100}); break;
-                case 2: tableStyle.setColWidths(new int[]{650, 2800, 850, 2200, 1750, 1750}); break;
-                case 3: tableStyle.setColWidths(new int[]{650, 2600, 850, 1800, 1400, 1400, 1400}); break;
-                case 4: tableStyle.setColWidths(new int[]{650, 2400, 850, 1600, 1125, 1125, 1125, 1125}); break;
-                case 5: tableStyle.setColWidths(new int[]{650, 2200, 850, 1500, 960, 960, 960, 960, 960}); break;
-                default: break;
+                case 1:
+                    tableStyle.setColWidths(new int[]{650, 3000, 850, 2400, 3100});
+                    break;
+                case 2:
+                    tableStyle.setColWidths(new int[]{650, 2800, 850, 2200, 1750, 1750});
+                    break;
+                case 3:
+                    tableStyle.setColWidths(new int[]{650, 2600, 850, 1800, 1400, 1400, 1400});
+                    break;
+                case 4:
+                    tableStyle.setColWidths(new int[]{650, 2400, 850, 1600, 1125, 1125, 1125, 1125});
+                    break;
+                case 5:
+                    tableStyle.setColWidths(new int[]{650, 2200, 850, 1500, 960, 960, 960, 960, 960});
+                    break;
+                default:
+                    break;
             }
-        } else if(max<=5){
+        } else if (max <= 5) {
             for (int i = 1; i <= max; i++) {
                 // 鏍规嵁妫�楠岀粨鏋滀釜鏁颁慨鏀归暱搴�
                 switch (i) {
@@ -2207,30 +2251,31 @@
 
     /**
      * 澶勭悊鏈夌數缂嗛鑹叉爣璇嗙殑妫�娴嬮」
-     * @param cableTags 鐢电紗棰滆壊鏍囪瘑
-     * @param collect   妫�娴嬮」鍒楄〃
+     *
+     * @param cableTags  鐢电紗棰滆壊鏍囪瘑
+     * @param collect    妫�娴嬮」鍒楄〃
      * @param startIndex 璧峰涓嬫爣
      * @param endIndex   缁撴潫涓嬫爣
      * @return
      */
-    private List<SampleProductExportDto> transformSampleProduct(List<String> cableTags,Map<String, List<SampleProductExportDto>> collect,int startIndex,int endIndex){
+    private List<SampleProductExportDto> transformSampleProduct(List<String> cableTags, Map<String, List<SampleProductExportDto>> collect, int startIndex, int endIndex) {
         List<SampleProductExportDto> sampleProductExportDtos = new ArrayList<>();
         for (String s : collect.keySet()) {
             List<String> lastValueList = new ArrayList<>();
             SampleProductExportDto dto = new SampleProductExportDto();
-            BeanUtil.copyProperties(collect.get(s).get(0),dto);
+            BeanUtil.copyProperties(collect.get(s).get(0), dto);
             Set<String> tellSet = new HashSet<>();
             for (int i = startIndex; i < endIndex; i++) {
                 String cableTag = cableTags.get(i);
                 for (SampleProductExportDto sDto : collect.get(s)) {
                     tellSet.add(sDto.getTell());
-                    if(sDto.getCableTag().equals(cableTag)){
+                    if (sDto.getCableTag().equals(cableTag)) {
                         lastValueList.add(sDto.getLastValue());
                     }
                 }
             }
             //鍒囧壊鐢电紗閰嶇疆椤�
-            dto.setTell(String.join("\n",tellSet));
+            dto.setTell(String.join("\n", tellSet));
             dto.setLastValueList(lastValueList);
             sampleProductExportDtos.add(dto);
         }
@@ -2239,10 +2284,11 @@
 
     /**
      * 妫�娴嬮」鎺掑簭
+     *
      * @param sourceMap
      * @param targetMap
      */
-    private void sortSampleProduct(Map<String, List<SampleProductExportDto>> sourceMap,Map<String, List<SampleProductExportDto>> targetMap){
+    private void sortSampleProduct(Map<String, List<SampleProductExportDto>> sourceMap, Map<String, List<SampleProductExportDto>> targetMap) {
         List<Map.Entry<String, List<SampleProductExportDto>>> entries = new ArrayList<>(sourceMap.entrySet());
         entries.sort(Comparator.comparingInt(o -> (o.getValue().get(0).getSort() == null ? 0 : o.getValue().get(0).getSort())));
         for (Map.Entry<String, List<SampleProductExportDto>> entry : entries) {
@@ -2252,6 +2298,7 @@
 
     /**
      * 灏忔姤鍛婄敓鎴�
+     *
      * @param orderId
      * @param insOrder
      * @param insSamples
@@ -2273,7 +2320,7 @@
         //鏌ヨ闆朵欢灞炴��
         IfsPartPropsRecord ifsPartPropsRecord = ifsPartPropsRecordMapper.selectOne(Wrappers.<IfsPartPropsRecord>lambdaQuery()
                 .eq(IfsPartPropsRecord::getIfsInventoryId, ifsInventoryQuantity.getId()));
-        if(Objects.nonNull(ifsPartPropsRecord)){
+        if (Objects.nonNull(ifsPartPropsRecord)) {
             enterFactoryReport.setOuterColor(ifsPartPropsRecord.getOuterColor());
         }
         enterFactoryReport.setQtyArrived(ifsInventoryQuantity.getQtyArrived() == null ? "" :
@@ -2298,7 +2345,7 @@
         List<RowRenderData> rows = new ArrayList<>();
         List<TextRenderData> text = new ArrayList<>();
         RowRenderData rowRenderData = null;
-        List<Map<String,Object>> cableTagEnclosureTables = new ArrayList<>();
+        List<Map<String, Object>> cableTagEnclosureTables = new ArrayList<>();
 
         // 鏌ヨ妫�楠屽唴瀹�
         List<SampleProductExportDto> sampleProductDto2s = insOrderMapper.selectSampleBySampleId(insSamples.stream()
@@ -2311,7 +2358,7 @@
         Integer max = insSamples.stream().mapToInt(InsSample::getQuantity).sum();
         TableRenderData tableRenderData = new TableRenderData();
         String templateName;
-        if(StringUtils.equals(OrderType.WG.getValue(),ifsInventoryQuantity.getOrderType())){
+        if (StringUtils.equals(OrderType.WG.getValue(), ifsInventoryQuantity.getOrderType())) {
             //杩囨护涓嶅垽瀹氱殑妫�娴嬮」
             List<SampleProductExportDto> filterItems = sampleProductDto2s.stream()
                     .filter(f -> !showResult || f.getInsResult() != 3)
@@ -2320,7 +2367,7 @@
             templateName = showResult ? "/static/small-wg-report-template.docx" : "/static/small-wg-detection-template.docx";
             //鏌ヨ妫�楠屽崟娑堟伅
             InsSampleUserVO insSampleUser = insSampleUserMapper.selectUserNameByOrderId(orderId);
-            if(Objects.nonNull(insSampleUser)){
+            if (Objects.nonNull(insSampleUser)) {
                 enterFactoryReport.setPartDesc(insSampleUser.getModel());
                 enterFactoryReport.setInspector(insSampleUser.getInspector());
                 enterFactoryReport.setInspectDate(insSampleUser.getInspectDate());
@@ -2332,7 +2379,7 @@
 
             AtomicInteger finalIndex = new AtomicInteger(1);
             List<String> cableTags = insOrderMapper.selectSampleCableTag(insSample.getId());
-            max = Math.max(cableTags.size(),1);
+            max = Math.max(cableTags.size(), 1);
             //澶勭悊鐢电紗閰嶇疆妫�娴嬮」
             Map<String, List<SampleProductExportDto>> tempMap = new HashMap<>();
             Map<String, List<SampleProductExportDto>> tempMap2 = new HashMap<>();
@@ -2344,41 +2391,41 @@
                 List<SampleProductExportDto> sampleProductExportDtos2;
                 //澶勭悊鐢电紗閰嶇疆椤�
                 Map<String, List<SampleProductExportDto>> collect = listMap2.get(key).stream().collect(Collectors.groupingBy(SampleProductExportDto::getInspectionItemSubclass));
-                if(cableTags.size()>maxCableTag){
-                    sampleProductExportDtos = transformSampleProduct(cableTags,collect,0,maxCableTag);
-                    sampleProductExportDtos2 = transformSampleProduct(cableTags,collect,maxCableTag,cableTags.size());
-                    tempMap2.put(key,sampleProductExportDtos2);
-                }else{
-                    sampleProductExportDtos = transformSampleProduct(cableTags,collect,0,cableTags.size());
+                if (cableTags.size() > maxCableTag) {
+                    sampleProductExportDtos = transformSampleProduct(cableTags, collect, 0, maxCableTag);
+                    sampleProductExportDtos2 = transformSampleProduct(cableTags, collect, maxCableTag, cableTags.size());
+                    tempMap2.put(key, sampleProductExportDtos2);
+                } else {
+                    sampleProductExportDtos = transformSampleProduct(cableTags, collect, 0, cableTags.size());
                 }
-                cableTagItem.put(key,sampleProductExportDtos);
+                cableTagItem.put(key, sampleProductExportDtos);
             }
             //澶勭悊闈炵數缂嗛厤缃娴嬮」
             Map<String, List<SampleProductExportDto>> listMap = filterItems.stream()
                     .filter(f -> StringUtils.isBlank(f.getCableTag()) && StringUtils.isNotBlank(f.getInspectionItem()))
-                    .collect(Collectors.groupingBy(s->s.getInspectionItem()+"&"));
+                    .collect(Collectors.groupingBy(s -> s.getInspectionItem() + "&"));
             //鍚堝苟妫�娴嬮」鍒楄〃
             tempMap.putAll(cableTagItem);
             tempMap.putAll(listMap);
-            sortSampleProduct(tempMap,totalItem);
-            int tagNum = Math.min(max,maxCableTag);
-            List<String> tagList = cableTags.isEmpty()?new ArrayList<>():cableTags.subList(0,tagNum);
+            sortSampleProduct(tempMap, totalItem);
+            int tagNum = Math.min(max, maxCableTag);
+            List<String> tagList = cableTags.isEmpty() ? new ArrayList<>() : cableTags.subList(0, tagNum);
             handlerSampleItems(OrderType.WG.getValue(), totalItem, finalIndex, sampleList, tagNum, text, rows, rowRenderData, resultCh, tagList, true, showResult);
 
-            if(CollectionUtil.isNotEmpty(tempMap2)){
-                sortSampleProduct(tempMap2,cableTagEnclosureItem);
+            if (CollectionUtil.isNotEmpty(tempMap2)) {
+                sortSampleProduct(tempMap2, cableTagEnclosureItem);
                 //鐢熸垚闄勪欢鐢电紗琛ㄦ牸
                 TableRenderData tableRenderData2 = new TableRenderData();
-                List<String> newCableTags = cableTags.subList(maxCableTag,cableTags.size());
+                List<String> newCableTags = cableTags.subList(maxCableTag, cableTags.size());
                 AtomicInteger finalIndex2 = new AtomicInteger(1);
                 List<TextRenderData> newText = new ArrayList<TextRenderData>();
                 List<RowRenderData> newRows = new ArrayList<>();
                 RowRenderData newRowRenderData = null;
                 handlerSampleItems(OrderType.WG.getValue(), cableTagEnclosureItem, finalIndex2, new ArrayList<>(), newCableTags.size(), newText, newRows, newRowRenderData, resultCh, newCableTags, true, showResult);
                 tableRenderData2.setRows(newRows);
-            tableRenderData2.setTableStyle(setTableStyle(newCableTags.size(), showResult));
+                tableRenderData2.setTableStyle(setTableStyle(newCableTags.size(), showResult));
                 HashMap<String, Object> tableMap = new HashMap<>();
-                tableMap.put("enclosureTable",tableRenderData2);
+                tableMap.put("enclosureTable", tableRenderData2);
                 tableMap.put("resultCh", resultCh);
                 tableMap.put("writeUrl", null);
                 tableMap.put("examineUrl", null);
@@ -2398,7 +2445,7 @@
                 resultCh.set("鏈骇鍝佺鍚堢浉鍏虫爣鍑嗚姹傦紝缁忔楠屽悎鏍煎噯浜堝嚭鍘傦紙鐩栫珷鏈夋晥锛�");
             }
 
-        }else{
+        } else {
             templateName = showResult ? "/static/small-report-template.docx" : "/static/small-detection-template.docx";
             // 杞垚Mpa杩涜鎺掑簭
             Map<String, List<SampleProductExportDto>> sortedMap = sampleProductDto2s.stream()
@@ -2406,7 +2453,7 @@
                     .collect(Collectors.groupingBy(SampleProductExportDto::getInspectionItem));
 //            // 鍒涘缓涓�涓� LinkedHashMap 鏉ヤ繚鎸佹彃鍏ラ『搴�
             Map<String, List<SampleProductExportDto>> item = new LinkedHashMap<>();
-            sortSampleProduct(sortedMap,item);
+            sortSampleProduct(sortedMap, item);
 
 
             AtomicInteger finalIndex = new AtomicInteger(1);
@@ -2431,7 +2478,7 @@
                     put("standardMethod", standardMethod2.toString().equals("null") ? "" : standardMethod2);
                     put("orderType", orderType);
                     put("table", tableRenderData);
-                    put("enclosureTables", cableTagEnclosureTables.isEmpty()?null:cableTagEnclosureTables);
+                    put("enclosureTables", cableTagEnclosureTables.isEmpty() ? null : cableTagEnclosureTables);
                     put("resultCh", resultCh);
                     put("writeUrl", null);
                     put("examineUrl", null);
@@ -2460,6 +2507,7 @@
 
     /**
      * 澶勭悊甯歌妫�娴嬮」
+     *
      * @param item
      * @param finalIndex
      * @param sampleList
@@ -2485,7 +2533,7 @@
                     String productName = productDto2.getInspectionItemClass() + productDto2.getInspectionItem() + productDto2.getCableTag();
                     if (map.containsKey(productName)) {
                         // 濡傛灉鍚嶇О宸茬粡瀛樺湪锛屾坊鍔� lastValue 鍊煎埌 lastValueList 鍒楄〃
-                        if(CollectionUtil.isEmpty(map.get(productName).getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(),orderType)){
+                        if (CollectionUtil.isEmpty(map.get(productName).getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(), orderType)) {
                             map.get(productName)
                                     .getLastValueList()
                                     .add(productDto2.getLastValue());
@@ -2495,7 +2543,7 @@
                                 .add(productDto2.getInsResult());
                     } else {
                         // 濡傛灉鍚嶇О涓嶅瓨鍦紝鐩存帴鏀惧叆 map
-                        if(CollectionUtil.isEmpty(productDto2.getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(),orderType)){
+                        if (CollectionUtil.isEmpty(productDto2.getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(), orderType)) {
                             productDto2.setLastValueList(new ArrayList<>()); // 妫�楠屽唴瀹�
                             productDto2.getLastValueList().add(productDto2.getLastValue());
                         }
@@ -2530,7 +2578,7 @@
                     String productName = productDto2.getInspectionItemClass() + productDto2.getInspectionItem() + productDto2.getInspectionItemSubclass() + productDto2.getCableTag();
                     if (map.containsKey(productName)) {
                         // 濡傛灉鍚嶇О宸茬粡瀛樺湪锛屾坊鍔� lastValue 鍊煎埌 lastValueList 鍒楄〃
-                        if(CollectionUtil.isEmpty(map.get(productName).getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(),orderType)){
+                        if (CollectionUtil.isEmpty(map.get(productName).getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(), orderType)) {
                             map.get(productName)
                                     .getLastValueList()
                                     .add(productDto2.getLastValue());
@@ -2540,7 +2588,7 @@
                                 .add(productDto2.getInsResult());
                     } else {
                         // 濡傛灉鍚嶇О涓嶅瓨鍦紝鐩存帴鏀惧叆 map
-                        if(CollectionUtil.isEmpty(productDto2.getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(),orderType)){
+                        if (CollectionUtil.isEmpty(productDto2.getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(), orderType)) {
                             productDto2.setLastValueList(new ArrayList<>()); // 妫�楠屽唴瀹�
                             productDto2.getLastValueList().add(productDto2.getLastValue());
                         }
@@ -2561,7 +2609,7 @@
         });
 
         // 娣诲姞灏忔姤鍛婅〃澶�
-        if(hasAddHead){
+        if (hasAddHead) {
             text = addSmallHead(text, max, rows, cableTagList, showResult);
         }
 
@@ -2581,8 +2629,8 @@
             // 妫�楠岄」鐩�
             TextRenderData middleRenderData2 = new TextRenderData();
             String[] split = sample.getInspectionName().split("&");
-            String itemName = split.length>0?split[0]:sample.getInspectionName();
-            middleRenderData2.setText(itemName+"鈭�"+itemName+i+"_"+finalIndex);
+            String itemName = split.length > 0 ? split[0] : sample.getInspectionName();
+            middleRenderData2.setText(itemName + "鈭�" + itemName + i + "_" + finalIndex);
             Style middleStyle2 = new Style();
             middleStyle2.setFontFamily("瀹嬩綋");
             middleStyle2.setColor("000000");
@@ -2669,7 +2717,7 @@
                     TextRenderData middleRenderData6 = new TextRenderData();
                     middleRenderData6.setText((StringUtils.isNotEmpty(sample.getLastValue()) ?
                             sample.getLastValue() : "")
-                            + "鈭�" + (finalIndex.get() +"_"+ i));
+                            + "鈭�" + (finalIndex.get() + "_" + i));
                     Style middleStyle6 = new Style();
                     middleStyle6.setFontFamily("瀹嬩綋");
                     middleStyle6.setColor("000000");
@@ -2730,13 +2778,13 @@
             }
 
             if (showResult) {
-            TextRenderData middleRenderData7 = new TextRenderData();
-            middleRenderData7.setText(result);
-            Style middleStyle7 = new Style();
-            middleStyle7.setFontFamily("瀹嬩綋");
-            middleStyle7.setColor("000000");
-            middleRenderData7.setStyle(middleStyle7);
-            text.add(middleRenderData7);
+                TextRenderData middleRenderData7 = new TextRenderData();
+                middleRenderData7.setText(result);
+                Style middleStyle7 = new Style();
+                middleStyle7.setFontFamily("瀹嬩綋");
+                middleStyle7.setColor("000000");
+                middleRenderData7.setStyle(middleStyle7);
+                text.add(middleRenderData7);
             }
 
             TextRenderData[] text2 = text.toArray(new TextRenderData[0]);
@@ -2753,6 +2801,7 @@
 
     /**
      * 娣诲姞灏忔姤鍛婅〃澶�
+     *
      * @param text
      * @param max
      * @param rows
@@ -2803,13 +2852,13 @@
             text.add(headRenderData6);
         }
         if (showResult) {
-        TextRenderData headRenderData7 = new TextRenderData();
-        headRenderData7.setText("鍗曢」鍒ゆ柇");
-        Style headStyle7 = new Style();
-        headStyle7.setFontFamily("瀹嬩綋");
-        headStyle7.setColor("000000");
-        headRenderData7.setStyle(headStyle7);
-        text.add(headRenderData7);
+            TextRenderData headRenderData7 = new TextRenderData();
+            headRenderData7.setText("鍗曢」鍒ゆ柇");
+            Style headStyle7 = new Style();
+            headStyle7.setFontFamily("瀹嬩綋");
+            headStyle7.setColor("000000");
+            headRenderData7.setStyle(headStyle7);
+            text.add(headRenderData7);
         }
 
         TextRenderData[] text3 = text.toArray(new TextRenderData[0]);
@@ -2861,13 +2910,13 @@
                 text.add(tagRenderData6);
             }
             if (showResult) {
-            TextRenderData tagRenderData7 = new TextRenderData();
-            tagRenderData7.setText("");
-            Style tagStyle7 = new Style();
-            tagStyle7.setFontFamily("瀹嬩綋");
-            tagStyle7.setColor("000000");
-            tagRenderData7.setStyle(tagStyle7);
-            text.add(tagRenderData7);
+                TextRenderData tagRenderData7 = new TextRenderData();
+                tagRenderData7.setText("");
+                Style tagStyle7 = new Style();
+                tagStyle7.setFontFamily("瀹嬩綋");
+                tagStyle7.setColor("000000");
+                tagRenderData7.setStyle(tagStyle7);
+                text.add(tagRenderData7);
             }
 
             TextRenderData[] text4 = text.toArray(new TextRenderData[0]);
@@ -2878,7 +2927,7 @@
 
         }
         //濡傛灉鏈夌數缂嗛鑹诧紝鐢熸垚棰滆壊鏍囪瘑琛�
-        if(CollectionUtil.isNotEmpty(cableTagList)){
+        if (CollectionUtil.isNotEmpty(cableTagList)) {
             TextRenderData tagRenderData1 = new TextRenderData();
             tagRenderData1.setText("");
             Style tagStyle1 = new Style();
@@ -2921,13 +2970,13 @@
                 text.add(tagRenderData6);
             }
             if (showResult) {
-            TextRenderData tagRenderData7 = new TextRenderData();
-            tagRenderData7.setText("/");
-            Style tagStyle7 = new Style();
-            tagStyle7.setFontFamily("瀹嬩綋");
-            tagStyle7.setColor("000000");
-            tagRenderData7.setStyle(tagStyle7);
-            text.add(tagRenderData7);
+                TextRenderData tagRenderData7 = new TextRenderData();
+                tagRenderData7.setText("/");
+                Style tagStyle7 = new Style();
+                tagStyle7.setFontFamily("瀹嬩綋");
+                tagStyle7.setColor("000000");
+                tagRenderData7.setStyle(tagStyle7);
+                text.add(tagRenderData7);
             }
 
             TextRenderData[] text4 = text.toArray(new TextRenderData[0]);
@@ -2942,6 +2991,7 @@
 
     /**
      * 鍒涘缓澶ф姤鍛�
+     *
      * @param orderId
      * @param insOrder
      * @param
@@ -2949,6 +2999,10 @@
     private void addBitReport(Integer orderId, InsOrder insOrder, Integer reportType, Integer writeUserId) {
         //samples鏄笉鍖呮嫭甯︽湁"/"鐨勬牱鍝�
         List<SampleProductDto> samples = insSampleMapper.selectSampleProductListByOrderId(orderId);
+        boolean directTemplateOrder = isDirectTemplateOrder(orderId);
+        if (!directTemplateOrder && CollectionUtils.isEmpty(samples)) {
+            throw new ErrorException("褰撳墠璁㈠崟鏈壘鍒板彲鐢熸垚鎶ュ憡鐨勬湁鏁堟楠岄」鐩�");
+        }
         InsReport insReport = new InsReport();
         insReport.setCode(insOrder.getEntrustCode());
         insReport.setInsOrderId(orderId);
@@ -3212,12 +3266,6 @@
             }
         }
 
-        Map<String, String> codeStr = new HashMap<>();
-        codeStr.put("鎶ュ憡缂栧彿", insReport.getCode());
-        codeStr.put("鏍峰搧鍚嶇О", defaultReportText(insOrder.getSampleView(), insOrder.getSample()));
-        codeStr.put("瑙勬牸鍨嬪彿", samples.get(0).getModel());
-        codeStr.put("鍙戞斁鏃ユ湡", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
-
         String modelStr = CollUtil.join(models, "\n");
 
         // 妫�娴嬬被鍨�
@@ -3341,7 +3389,10 @@
         List<Map<String, String>> finalDeviceList = deviceList;
         String finalModelStr = modelStr;
 
-        List<Map<String, String>> detectionResultRows = buildDetectionResultRows(orderId, samples);
+        // 鐩寸粦妯℃澘璁㈠崟娌℃湁 ins_product锛屾娴嬮」鐩�佸崟浣嶅拰缁撴灉鍧囦粠璁㈠崟妯℃澘蹇収涓幏鍙栥��
+        List<Map<String, String>> detectionResultRows = directTemplateOrder
+                ? buildTemplateDetectionResultRows(orderId)
+                : buildDetectionResultRows(samples);
         String productName = defaultReportText(insOrder.getSampleView(), insOrder.getSample());
         String customerName = defaultReportText(custom == null ? null : custom.getCompany(), insOrder.getCompany());
         String detectionCategory = defaultReportText(finalOrderType, "濮旀墭妫�娴�");
@@ -3368,7 +3419,7 @@
                 Wrappers.<InsOrderStandardTemplate>lambdaQuery()
                         .eq(InsOrderStandardTemplate::getInsOrderId, orderId)
                         .orderByAsc(InsOrderStandardTemplate::getSort, InsOrderStandardTemplate::getId));
-        boolean newJuTemplateOrder = !templateSnapshots.isEmpty() && isDirectTemplateOrder(orderId);
+        boolean newJuTemplateOrder = !templateSnapshots.isEmpty() && directTemplateOrder;
         if (newJuTemplateOrder) {
             productName = defaultReportText(insOrder.getSampleView(), insOrder.getSample());
             finalModelStr = "/";
@@ -3510,10 +3561,7 @@
     /**
      * 鏂扮増妫�娴嬫姤鍛婄殑缁撴灉琛ㄥ浐瀹氫负鍥涘垪锛氬簭鍙枫�佹娴嬮」鐩�佸崟浣嶃�佹娴嬬粨鏋溿��
      */
-    private List<Map<String, String>> buildDetectionResultRows(Integer orderId, List<SampleProductDto> samples) {
-        if (isDirectTemplateOrder(orderId)) {
-            return buildTemplateDetectionResultRows(orderId);
-        }
+    private List<Map<String, String>> buildDetectionResultRows(List<SampleProductDto> samples) {
         List<Map<String, String>> rows = new ArrayList<>();
         if (CollectionUtils.isEmpty(samples)) {
             return rows;
@@ -3550,7 +3598,7 @@
     }
 
     /**
-     * 鏂拌仛鐩寸粦妯℃澘璁㈠崟锛氫竴涓ā鏉块〉绛惧湪鎶ュ憡涓彧瀵瑰簲涓�鏉℃娴嬮」鐩��
+     * 鏂拌仛鐩寸粦妯℃澘璁㈠崟锛氭ā鏉夸腑姣忎竴涓�滃鍑哄�尖�濇壒娉ㄩ兘瀵瑰簲鎶ュ憡涓殑涓�鏉℃娴嬮」鐩��
      */
     private List<Map<String, String>> buildTemplateDetectionResultRows(Integer orderId) {
         List<InsOrderStandardTemplate> snapshots = insOrderStandardTemplateService.list(
@@ -3560,27 +3608,29 @@
         List<Map<String, String>> rows = new ArrayList<>();
         int sequence = 1;
         for (InsOrderStandardTemplate snapshot : snapshots) {
-            TemplateExportCell exportCell = getFirstTemplateExportCell(snapshot.getThing());
+            List<TemplateExportCell> exportCells = getTemplateExportCells(snapshot.getThing());
             JSONObject recordValues = StrUtil.isBlank(snapshot.getRecordValues())
                     ? new JSONObject() : JSON.parseObject(snapshot.getRecordValues());
-            String result = readTemplateCellText(recordValues, exportCell.resultCoordinate, exportCell.templateValues);
-            if (StringUtils.isBlank(result)) {
-                throw new ErrorException("妯℃澘鈥�" + defaultReportText(snapshot.getName(), "妯℃澘ID " + snapshot.getTemplateId())
-                        + "鈥濈殑瀵煎嚭鍊间笉鑳戒负绌�");
-            }
-            String unit = exportCell.unitCoordinate == null ? null
-                    : readTemplateCellText(recordValues, exportCell.unitCoordinate, exportCell.templateValues);
-            String itemName = exportCell.itemCoordinate == null ? null
-                    : readTemplateCellText(recordValues, exportCell.itemCoordinate, exportCell.templateValues);
+            for (TemplateExportCell exportCell : exportCells) {
+                String result = readTemplateCellText(recordValues, exportCell.resultCoordinate, exportCell.templateValues);
+                if (StringUtils.isBlank(result)) {
+                    throw new ErrorException("妯℃澘鈥�" + defaultReportText(snapshot.getName(), "妯℃澘ID " + snapshot.getTemplateId())
+                            + "鈥濈殑瀵煎嚭鍊间笉鑳戒负绌猴紙" + exportCell.resultCoordinate + "锛�");
+                }
+                String unit = exportCell.unitCoordinate == null ? null
+                        : readTemplateCellText(recordValues, exportCell.unitCoordinate, exportCell.templateValues);
+                String itemName = exportCell.itemCoordinate == null ? null
+                        : readTemplateCellText(recordValues, exportCell.itemCoordinate, exportCell.templateValues);
 
-            Map<String, String> row = new LinkedHashMap<>();
-            row.put("seq", String.valueOf(sequence++));
-            String reportItemName = defaultReportText(itemName,
-                    defaultReportText(snapshot.getName(), "妯℃澘ID " + snapshot.getTemplateId()));
-            row.put("itemName", formatExportItemName(reportItemName));
-            row.put("unit", defaultReportText(unit, "/"));
-            row.put("result", result);
-            rows.add(row);
+                Map<String, String> row = new LinkedHashMap<>();
+                row.put("seq", String.valueOf(sequence++));
+                String reportItemName = defaultReportText(itemName,
+                        defaultReportText(snapshot.getName(), "妯℃澘ID " + snapshot.getTemplateId()));
+                row.put("itemName", formatExportItemName(reportItemName));
+                row.put("unit", defaultReportText(unit, "/"));
+                row.put("result", result);
+                rows.add(row);
+            }
         }
         if (rows.isEmpty()) {
             throw new ErrorException("褰撳墠璁㈠崟鏈壘鍒板彲鐢熸垚鎶ュ憡鐨勫師濮嬭褰曟ā鏉�");
@@ -3588,7 +3638,7 @@
         return rows;
     }
 
-    private TemplateExportCell getFirstTemplateExportCell(String compressedThing) {
+    private List<TemplateExportCell> getTemplateExportCells(String compressedThing) {
         if (StrUtil.isBlank(compressedThing)) {
             throw new ErrorException("鍘熷璁板綍妯℃澘涓虹┖");
         }
@@ -3633,17 +3683,20 @@
             throw new ErrorException("妯℃澘蹇呴』鑷冲皯閰嶇疆涓�涓鍑哄�兼壒娉�");
         }
         exportCells.sort(Comparator.comparingInt((int[] cell) -> cell[0]).thenComparingInt(cell -> cell[1]));
-        int[] firstExport = exportCells.get(0);
-        int resultColumnForRow = resultColumn == null ? firstExport[1] : resultColumn;
-        // 閫氬父鈥滃鍑哄�尖�濇壒娉ㄩ厤缃湪椤圭洰鍚嶇О鍗曞厓鏍硷紱鑻ラ厤缃湪缁撴灉鍗曞厓鏍硷紝鍒欏洖鍒扳�滄娴嬮」鐩�濆垪鍙栧悕绉般��
-        Integer itemColumnForRow = !Objects.equals(firstExport[1], resultColumnForRow)
-                ? firstExport[1] : itemColumn;
-        TemplateExportCell result = new TemplateExportCell();
-        result.resultCoordinate = firstExport[0] + "-" + resultColumnForRow;
-        result.itemCoordinate = itemColumnForRow == null ? null : firstExport[0] + "-" + itemColumnForRow;
-        result.unitCoordinate = unitColumn == null ? null : firstExport[0] + "-" + unitColumn;
-        result.templateValues = templateValues;
-        return result;
+        List<TemplateExportCell> results = new ArrayList<>();
+        for (int[] exportCell : exportCells) {
+            int resultColumnForRow = resultColumn == null ? exportCell[1] : resultColumn;
+            // 閫氬父鈥滃鍑哄�尖�濇壒娉ㄩ厤缃湪椤圭洰鍚嶇О鍗曞厓鏍硷紱鑻ラ厤缃湪缁撴灉鍗曞厓鏍硷紝鍒欏洖鍒扳�滄娴嬮」鐩�濆垪鍙栧悕绉般��
+            Integer itemColumnForRow = !Objects.equals(exportCell[1], resultColumnForRow)
+                    ? exportCell[1] : itemColumn;
+            TemplateExportCell result = new TemplateExportCell();
+            result.resultCoordinate = exportCell[0] + "-" + resultColumnForRow;
+            result.itemCoordinate = itemColumnForRow == null ? null : exportCell[0] + "-" + itemColumnForRow;
+            result.unitCoordinate = unitColumn == null ? null : exportCell[0] + "-" + unitColumn;
+            result.templateValues = templateValues;
+            results.add(result);
+        }
+        return results;
     }
 
     private String readTemplateCellText(JSONObject recordValues, String coordinate, Map<String, String> templateValues) {
@@ -3735,7 +3788,9 @@
         return minimumText + "~" + maximum.stripTrailingZeros().toPlainString() + unit;
     }
 
-    /** 鎶ュ憡椤圭洰鍚嶇О涓嶅睍绀烘ā鏉胯绠楄繃绋嬩腑鐨勨�滃钩鍧囧�尖�濆瓧鏍峰強鍏跺悗鐨勫垎闅旈�楀彿銆� */
+    /**
+     * 鎶ュ憡椤圭洰鍚嶇О涓嶅睍绀烘ā鏉胯绠楄繃绋嬩腑鐨勨�滃钩鍧囧�尖�濆瓧鏍峰強鍏跺悗鐨勫垎闅旈�楀彿銆�
+     */
     private static String formatExportItemName(String itemName) {
         if (StringUtils.isBlank(itemName)) {
             return itemName;
@@ -3771,18 +3826,25 @@
 
     /**
      * 璁$畻琛ㄦ牸鍒楀搴�
+     *
      * @param max 鏈�澶ф楠屼釜鏁�
      * @return
      */
-    private static int[] calcTableColWidths(int max, boolean showResult){
+    private static int[] calcTableColWidths(int max, boolean showResult) {
         if (!showResult) {
             switch (max) {
-                case 1: return new int[]{650, 2200, 2200, 850, 2300, 1800};
-                case 2: return new int[]{650, 1600, 1600, 850, 1900, 1700, 1700};
-                case 3: return new int[]{650, 1400, 1400, 850, 1600, 1375, 1375, 1375};
-                case 4: return new int[]{650, 1250, 1250, 850, 1450, 1140, 1140, 1140, 1140};
-                case 5: return new int[]{650, 1150, 1150, 850, 1300, 980, 980, 980, 980, 980};
-                default: return new int[0];
+                case 1:
+                    return new int[]{650, 2200, 2200, 850, 2300, 1800};
+                case 2:
+                    return new int[]{650, 1600, 1600, 850, 1900, 1700, 1700};
+                case 3:
+                    return new int[]{650, 1400, 1400, 850, 1600, 1375, 1375, 1375};
+                case 4:
+                    return new int[]{650, 1250, 1250, 850, 1450, 1140, 1140, 1140, 1140};
+                case 5:
+                    return new int[]{650, 1150, 1150, 850, 1300, 980, 980, 980, 980, 980};
+                default:
+                    return new int[0];
             }
         }
         int[] colWidths = null;
@@ -3803,16 +3865,16 @@
                 colWidths = new int[]{650, 1100, 1100, 850, 1350, 750, 750, 750, 750, 750, 1200};
                 break;
         }
-        if(ObjectUtils.isNull(colWidths)){
+        if (ObjectUtils.isNull(colWidths)) {
             List<Integer> defaultColWidths = new ArrayList<>(Arrays.asList(650, 1100, 1100, 850, 1350));
             int totalWidth = 3000;//鎬诲搴�
-            int byOneWidth = totalWidth/max;//姣忎竴涓殑瀹藉害
+            int byOneWidth = totalWidth / max;//姣忎竴涓殑瀹藉害
             int realWidth = 0;//瀹為檯瀹藉害
             for (int i = 0; i < max; i++) {
-                realWidth+=byOneWidth;
+                realWidth += byOneWidth;
                 defaultColWidths.add(byOneWidth);
             }
-            defaultColWidths.add(1200+(totalWidth-realWidth));
+            defaultColWidths.add(1200 + (totalWidth - realWidth));
             return defaultColWidths.stream().mapToInt(Integer::intValue).toArray();
         }
         return colWidths;
@@ -3820,6 +3882,7 @@
 
     /**
      * 璋冩暣楂樺害
+     *
      * @param row
      * @param rowHeight
      * @return
@@ -4051,12 +4114,13 @@
 
     /**
      * 娣诲姞鎶ュ憡琛ㄥご
+     *
      * @param sample
      * @param text
      * @param rowRenderData
      * @param rows
      * @param max
-     * @param cableTags 绾胯姱棰滆壊
+     * @param cableTags     绾胯姱棰滆壊
      */
     private static void addHead(SampleProductDto sample, List<TextRenderData> text, RowRenderData rowRenderData, List<RowRenderData> rows, int max, List<String> cableTags, boolean showResult) {
         // 绗竴琛�
@@ -4196,13 +4260,13 @@
             text.add(headRenderData6);
         }
         if (showResult) {
-        TextRenderData headRenderData7 = new TextRenderData();
-        headRenderData7.setText("缁撹@Conclusion");
-        Style headStyle7 = new Style();
-        headStyle7.setFontFamily("瀹嬩綋");
-        headStyle7.setColor("000000");
-        headRenderData7.setStyle(headStyle7);
-        text.add(headRenderData7);
+            TextRenderData headRenderData7 = new TextRenderData();
+            headRenderData7.setText("缁撹@Conclusion");
+            Style headStyle7 = new Style();
+            headStyle7.setFontFamily("瀹嬩綋");
+            headStyle7.setColor("000000");
+            headRenderData7.setStyle(headStyle7);
+            text.add(headRenderData7);
         }
 
         TextRenderData[] text3 = text.toArray(new TextRenderData[0]);
@@ -4262,13 +4326,13 @@
                 text.add(cableRenderData6);
             }
             if (showResult) {
-            TextRenderData cableRenderData7 = new TextRenderData();
-            cableRenderData7.setText("-");
-            Style cableStyle7 = new Style();
-            cableStyle7.setFontFamily("瀹嬩綋");
-            cableStyle7.setColor("000000");
-            cableRenderData7.setStyle(cableStyle7);
-            text.add(cableRenderData7);
+                TextRenderData cableRenderData7 = new TextRenderData();
+                cableRenderData7.setText("-");
+                Style cableStyle7 = new Style();
+                cableStyle7.setFontFamily("瀹嬩綋");
+                cableStyle7.setColor("000000");
+                cableRenderData7.setStyle(cableStyle7);
+                text.add(cableRenderData7);
             }
 
             TextRenderData[] text4 = text.toArray(new TextRenderData[0]);
@@ -4283,16 +4347,17 @@
 
     /**
      * 娣诲姞妫�娴嬪��
-     * @param a   褰撳墠鏍峰搧
+     *
+     * @param a             褰撳墠鏍峰搧
      * @param text
      * @param rowRenderData
      * @param rows
-     * @param max  妫�楠屾暟閲�
+     * @param max           妫�楠屾暟閲�
      * @param resultChList  涓嶇鍚堜俊鎭腑鏂�
      * @param resultEhList  涓嶇鍚堜俊鎭嫳鏂�
      * @param insSamples
-     * @param cableTags 绾胯姱棰滆壊
-     * @param isOneSample 鍒ゆ柇鏄惁鏄彧鏈変竴涓牱鍝�
+     * @param cableTags     绾胯姱棰滆壊
+     * @param isOneSample   鍒ゆ柇鏄惁鏄彧鏈変竴涓牱鍝�
      */
     private int addTestValue(SampleProductDto a,
                              List<TextRenderData> text,
@@ -4827,74 +4892,74 @@
             }
             // 鍒ゅ畾缁撴灉
             if (showResult) {
-            String result = "";
-            if (sample.getInsResult() != null) {
-                switch (sample.getInsResult()) {
-                    case 1:
-                        result = "鈭�";
-                        break;
-                    case 2:
-                        result = "脳";
-                        break;
-                    case 3:
-                        result = "-";
-                        break;
-                }
-            }
-            if (CollectionUtils.isNotEmpty(sample.getLastValueList())) {
-                // 鍒ゆ柇鏄惁鏈変竴涓敊璇�
-                if (sample.getInsResultList().stream().anyMatch(s -> Objects.equals(s, 3))) {
-                    result = "-";
-                } else {
-                    boolean error = sample.getInsResultList().stream().anyMatch(s -> Objects.equals(s, 0));
-                    if (error) {
-                        List<String> collect = new ArrayList<>();
-                        int index = 0;
-                        for (Integer count : sample.getInsResultList()) {
-                            String type;
-                            if (Objects.equals(count, 0)) {
-                                String itemCh = "";
-                                String itemEn = "";
-                                // 娣诲姞涓嶅悎鏍兼弿杩�
-                                // 鍒ゆ柇闀垮害鏄惁涓�1
-                                if (sample.getLastValueList().size() == 1) {
-                                    this.fillReportErrorResult(errorClassItemMapCn, errorClassItemMapEn, sample, itemCh, itemEn);
-                                } else if (CollectionUtils.isNotEmpty(cableTags)) {
-                                    // 鍒ゆ柇鏄惁鏈夌數缂嗛厤缃�, 涓嶆槸鐨勮瘽鍙兘涓哄師鏉愭枡
-                                    // 娣诲姞涓嶅悎鏍兼弿杩�
-                                    itemCh = (max == 1 ? "" : cableTags.get(index));
-                                    itemEn = (max == 1 ? "" : "The " + Integer.toString(index + 1) + " time ");
-                                    this.fillReportErrorResult(errorClassItemMapCn, errorClassItemMapEn, sample, itemCh, itemEn);
-                                } else {
-                                    // 娣诲姞涓嶅悎鏍兼弿杩�
-                                    itemCh = (max == 1 ? "" : "绗�" + Integer.toString(index + 1) + "娆�");
-                                    itemEn = (max == 1 ? "" : "The " + Integer.toString(index + 1) + " time ");
-                                    this.fillReportErrorResult(errorClassItemMapCn, errorClassItemMapEn, sample, itemCh, itemEn);
-                                }
-                                type = "脳";
-                            } else {
-                                type = "鈭�";
-                            }
-                            collect.add(type);
-                            index++;
-                        }
-                        result = CollUtil.join(collect, " ");
-                        ;
-                    } else {
-                        result = "鈭�";
+                String result = "";
+                if (sample.getInsResult() != null) {
+                    switch (sample.getInsResult()) {
+                        case 1:
+                            result = "鈭�";
+                            break;
+                        case 2:
+                            result = "脳";
+                            break;
+                        case 3:
+                            result = "-";
+                            break;
                     }
                 }
-            }
+                if (CollectionUtils.isNotEmpty(sample.getLastValueList())) {
+                    // 鍒ゆ柇鏄惁鏈変竴涓敊璇�
+                    if (sample.getInsResultList().stream().anyMatch(s -> Objects.equals(s, 3))) {
+                        result = "-";
+                    } else {
+                        boolean error = sample.getInsResultList().stream().anyMatch(s -> Objects.equals(s, 0));
+                        if (error) {
+                            List<String> collect = new ArrayList<>();
+                            int index = 0;
+                            for (Integer count : sample.getInsResultList()) {
+                                String type;
+                                if (Objects.equals(count, 0)) {
+                                    String itemCh = "";
+                                    String itemEn = "";
+                                    // 娣诲姞涓嶅悎鏍兼弿杩�
+                                    // 鍒ゆ柇闀垮害鏄惁涓�1
+                                    if (sample.getLastValueList().size() == 1) {
+                                        this.fillReportErrorResult(errorClassItemMapCn, errorClassItemMapEn, sample, itemCh, itemEn);
+                                    } else if (CollectionUtils.isNotEmpty(cableTags)) {
+                                        // 鍒ゆ柇鏄惁鏈夌數缂嗛厤缃�, 涓嶆槸鐨勮瘽鍙兘涓哄師鏉愭枡
+                                        // 娣诲姞涓嶅悎鏍兼弿杩�
+                                        itemCh = (max == 1 ? "" : cableTags.get(index));
+                                        itemEn = (max == 1 ? "" : "The " + Integer.toString(index + 1) + " time ");
+                                        this.fillReportErrorResult(errorClassItemMapCn, errorClassItemMapEn, sample, itemCh, itemEn);
+                                    } else {
+                                        // 娣诲姞涓嶅悎鏍兼弿杩�
+                                        itemCh = (max == 1 ? "" : "绗�" + Integer.toString(index + 1) + "娆�");
+                                        itemEn = (max == 1 ? "" : "The " + Integer.toString(index + 1) + " time ");
+                                        this.fillReportErrorResult(errorClassItemMapCn, errorClassItemMapEn, sample, itemCh, itemEn);
+                                    }
+                                    type = "脳";
+                                } else {
+                                    type = "鈭�";
+                                }
+                                collect.add(type);
+                                index++;
+                            }
+                            result = CollUtil.join(collect, " ");
+                            ;
+                        } else {
+                            result = "鈭�";
+                        }
+                    }
+                }
 
-            if (showResult) {
-            TextRenderData headRenderData7 = new TextRenderData();
-            headRenderData7.setText(result);
-            Style headStyle7 = new Style();
-            headStyle7.setFontFamily("瀹嬩綋");
-            headStyle7.setColor("000000");
-            headRenderData7.setStyle(headStyle7);
-            text.add(headRenderData7);
-            }
+                if (showResult) {
+                    TextRenderData headRenderData7 = new TextRenderData();
+                    headRenderData7.setText(result);
+                    Style headStyle7 = new Style();
+                    headStyle7.setFontFamily("瀹嬩綋");
+                    headStyle7.setColor("000000");
+                    headRenderData7.setStyle(headStyle7);
+                    text.add(headRenderData7);
+                }
             }
 
             TextRenderData[] text2 = text.toArray(new TextRenderData[0]);
@@ -4976,11 +5041,12 @@
 
     /**
      * NBSP锛堥潪闂存柇绌烘牸锛� 杞垚 鏅�氱┖鏍�
+     *
      * @param oldStr
      * @return
      */
-    private String normalizedSpaces(String oldStr){
-        if(StringUtils.isBlank(oldStr)){
+    private String normalizedSpaces(String oldStr) {
+        if (StringUtils.isBlank(oldStr)) {
             return oldStr;
         }
         return oldStr.replaceAll("\u00A0", " ").trim();
@@ -4988,6 +5054,7 @@
 
     /**
      * 娣诲姞鎶ュ憡缁撹涓嫳鏂�
+     *
      * @param sample
      * @param itemCh
      * @param itemEn
@@ -5047,6 +5114,7 @@
 
     /**
      * 鏍煎紡鍖栦慨鏀规楠岄」
+     *
      * @param sampleProductDto2s
      */
     private void formatProducts(List<SampleProductExportDto> sampleProductDto2s) {
@@ -5116,6 +5184,7 @@
 
     /**
      * 娣诲姞缁撳熬
+     *
      * @param text
      * @param rowRenderData
      * @param rows
@@ -5147,6 +5216,7 @@
 
     /**
      * 鍒ゆ柇褰撳墠鍐呭鏄惁鏄瀛﹁鏁版硶
+     *
      * @param str
      * @return
      */
@@ -5163,6 +5233,7 @@
 
     /**
      * 淇敼瑕佹眰鎻忚堪鐨勭瀛﹁鏁版硶
+     *
      * @param input
      */
     public static String convertToScientificNotation(String input) {
@@ -5192,6 +5263,7 @@
 
     /**
      * 灞曠ず鎴愮瀛﹁鏁版硶
+     *
      * @param number
      * @return
      */
@@ -5288,6 +5360,7 @@
 
     /**
      * 鏍规嵁瑕佹眰鎻忚堪淇濈暀缁撴灉灏忔暟鐐逛綅鏁�
+     *
      * @param reference
      * @param value
      * @return
@@ -5356,6 +5429,7 @@
 
     /**
      * 淇濈暀浣嶆暟, 濡傛灉绛変簬0 杩斿洖鎵惧埌鐨勪竴涓潪0浣嶆暟
+     *
      * @param number 褰撳墠鏁板瓧
      * @param scale  鍘熸湰淇濈暀鐨勪綅鏁�
      * @return
@@ -5394,9 +5468,10 @@
 
     /**
      * *****淇濆瓨鍏冩闃块噷杩涜揣楠岃瘉鍘熷璁板綍*****
-     * @param insOrderId 璁㈠崟Id
-     * @param examineUserId  澶嶆牳浜篒d
-     * @param writeUserId  妫�楠屽憳Id
+     *
+     * @param insOrderId    璁㈠崟Id
+     * @param examineUserId 澶嶆牳浜篒d
+     * @param writeUserId   妫�楠屽憳Id
      */
     private void reportFactoryVerify(Integer insOrderId, Integer examineUserId, Integer writeUserId) {
         // 鏌ヨ杩涜揣楠岃瘉鍘熷璁板綍
@@ -5549,6 +5624,7 @@
 
     /**
      * ***鏍煎紡鍖栬繘鍘傞獙璇佸唴瀹�****
+     *
      * @param basicType
      * @return
      */
@@ -5578,6 +5654,7 @@
 
     /**
      * ***word杞崲pdf***
+     *
      * @param path
      * @return
      */
@@ -5626,6 +5703,7 @@
 
     /**
      * *****淇敼鎴愬搧鎶芥牱鐘舵��******
+     *
      * @param insSamples
      * @param order
      */
@@ -5663,6 +5741,7 @@
 
     /**
      * 娣诲姞宸ユ椂
+     *
      * @param userId
      * @param insProduct
      * @param insOrder

--
Gitblit v1.9.3