From d1022dab44c4916c2935d10f5b04c7e7bbaa5dad Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期四, 21 十一月 2024 16:26:34 +0800
Subject: [PATCH] 调整

---
 inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java |   66 ++++++++++++++++++++++++++++++--
 1 files changed, 61 insertions(+), 5 deletions(-)

diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java
index 9c4bbb2..a57cadf 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java
@@ -63,6 +63,7 @@
     @Override
     public List<StandardProductList> selectStandardProductList(InsSample insSample) {
         String[] models = insSample.getModel().split("-(?=[^-]*$)");//鎷嗗垎鏈�鍚庝竴涓��-銆�
+        String[] models1 = insSample.getModel().split(";(?=[^;]*$)");//鎷嗗垎鏈�鍚庝竴涓��-銆�
         List<Integer> ids = Arrays.stream(insSample.getStandardMethodListId().split(","))
                 .map(String::trim).map(Integer::parseInt).collect(Collectors.toList());
         List<StandardProductList> list = standardProductListMapper.selectDetail(ids, 1, models[0]);
@@ -102,9 +103,16 @@
                         } else {
                             if (sections.get(i).contains("&")) {
                                 String[] split = sections.get(i).split("&");
-                                isIf = getIsIf(split[0], models[1]) && getIsIf(split[1], models[1]);
+                                isIf = getIsIf(split[0], models1[1]) && getIsIf(split[1], models[1].split(";")[0]);
                             } else {
-                                isIf = getIsIf(sections.get(i), models[1]);
+                                if (ObjectUtils.isNotEmpty(models[1].split(";")[0])){
+                                    isIf = getIsIf(sections.get(i), models[1].split(";")[0]);
+                                    if (!isIf) {
+                                        isIf = getIsIf(sections.get(i), models1[1]);
+                                    }
+                                }else {
+                                    isIf = getIsIf(sections.get(i), models1[1]);
+                                }
                             }
                             if (isIf) {
                                 a.setSection(sections.get(i));
@@ -127,15 +135,59 @@
             standardProductList.setMethodS(code);
             return standardProductList;
         }).collect(Collectors.toList());
+        //鎸夌収鐢佃矾璇曢獙--杈愬皠璇曢獙--娓╂箍搴﹁瘯楠�--鐜璇曢獙杩涜鎺掑簭
+        // 瀹氫箟鑷畾涔夋帓搴忓櫒
+        Comparator<StandardProductList> testTypeComparator = (o1, o2) -> {
+            String[] order = {"鐢佃矾璇曢獙", "杈愬皠璇曢獙", "娓╂箍搴﹁瘯楠�", "鐜璇曢獙","鍔熺巼璇曢獙"};
+            int index1 = -1;
+            int index2 = -1;
+            // 鎵惧嚭涓や釜瀵硅薄 鍦ㄨ嚜瀹氫箟椤哄簭鏁扮粍涓殑浣嶇疆
+            for (int i = 0; i < order.length; i++) {
+                if (o1.getInspectionItem().equals(order[i])) {
+                    index1 = i;
+                }
+                if (o2.getInspectionItem().equals(order[i])) {
+                    index2 = i;
+                }
+                if (index1 != -1 && index2 != -1) {
+                    break; // 涓や釜浣嶇疆閮芥壘鍒颁簡锛屽彲浠ラ��鍑哄惊鐜�
+                }
+            }
+            // 姣旇緝浣嶇疆
+            int compareResult = Integer.compare(index1, index2);
+            // 濡傛灉鏄幆澧冭瘯楠岋紝涓斾袱涓璞″湪涓绘楠岄」鐩笂鎺掑簭鐩稿悓锛屽垯鐢ㄦ绾ф楠岄」鐩帓搴�
+            if (compareResult == 0 && order[index1].equals("鐜璇曢獙")) {
+                String[] subOrder = {"鍐叉按璇曢獙", "鎸姩璇曢獙"};
+                int subIndex1 = -1;
+                int subIndex2 = -1;
+                for (int i = 0; i < subOrder.length; i++) {
+                    if (o1.getInspectionItemSubclass().equals(subOrder[i])) {
+                        subIndex1 = i;
+                    }
+                    if (o2.getInspectionItemSubclass().equals(subOrder[i])) {
+                        subIndex2 = i;
+                    }
+                    if (subIndex1 != -1 && subIndex2 != -1) {
+                        break; // 涓や釜娆$骇浣嶇疆閮芥壘鍒颁簡锛屽彲浠ラ��鍑哄惊鐜�
+                    }
+                }
+                compareResult = Integer.compare(subIndex1, subIndex2);
+            }
+            // 姣旇緝浣嶇疆
+            return compareResult;
+        };
+        // 瀵瑰垪琛ㄨ繘琛屾帓搴�
+        Collections.sort(list, testTypeComparator);
         return list;
     }
 
     private boolean getIsIf(String str, String model) {
         Matcher matcher = Pattern.compile("\\d+(\\.\\d+)?").matcher(model);
         String model2 = "";
-        while (matcher.find()) {
+        if (matcher.find()) {
             model2 += matcher.group();
-            break;
+        }else {
+            model2=model;
         }
         if (str.contains("鈮�") || str.contains(">=")) {
             String param = str.replace("鈮�", "").replace(">=", "");
@@ -151,7 +203,11 @@
             return new BigDecimal(model2).compareTo(new BigDecimal(param)) < 0;
         } else if (str.contains("=")) {
             String param = str.replace("=", "");
-            return new BigDecimal(model2).compareTo(new BigDecimal(param)) == 0;
+            if (matcher.find()) {
+                return new BigDecimal(model2).compareTo(new BigDecimal(param)) == 0;
+            }else {
+                return model2.equals(param);
+            }
         }
         return false;
     }

--
Gitblit v1.9.3