From 8763d2f0bebddcbef6cdab7c94436457495b2caa Mon Sep 17 00:00:00 2001
From: pang.jiabao <pang_jiabao@163.com>
Date: 星期四, 29 一月 2026 15:06:29 +0800
Subject: [PATCH] 入库分配堆垛机做成可配置

---
 src/main/java/com/zy/common/service/CommonService.java |   33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/zy/common/service/CommonService.java b/src/main/java/com/zy/common/service/CommonService.java
index bab0964..b584959 100644
--- a/src/main/java/com/zy/common/service/CommonService.java
+++ b/src/main/java/com/zy/common/service/CommonService.java
@@ -364,11 +364,18 @@
                 basCrnp.setWrkNo(count);
                 basCrnpList.add(basCrnp);
             }
+            final String sortByType;
+            Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "inLocCrn1PriorityAssign").eq("status", 1));
+            if (!Cools.isEmpty(config.getValue()) && config.getValue().equals("Y")) {
+                sortByType = "asc"; // 瀹氫箟 1 鈫� 2 鈫� 3 鐨勪紭鍏堢骇
+            } else {
+                sortByType = "other"; // 瀹氫箟 2 鈫� 3 鈫� 1 鐨勪紭鍏堢骇
+            }
 
             basCrnpList = basCrnpList.stream().sorted(Comparator.comparing(BasCrnp::getWrkNo).thenComparing(BasCrnp::getCrnNo,((o1, o2) -> {
                 // 瀹氫箟 2 鈫� 3 鈫� 1 鐨勪紭鍏堢骇
-                int order1 = getCustomOrder(o1);
-                int order2 = getCustomOrder(o2);
+                int order1 = getCustomOrder(o1,sortByType);
+                int order2 = getCustomOrder(o2,sortByType);
                 return Integer.compare(order1, order2);
             }))).collect(Collectors.toList());
 
@@ -444,12 +451,22 @@
     }
 
     // 杈呭姪鏂规硶锛氬畾涔� crn_no 鐨勬帓搴忎紭鍏堢骇
-    private static int getCustomOrder(Integer crnNo) {
-        switch (crnNo) {
-            case 2: return 1;  // 2 鎺掔涓�
-            case 3: return 2;  // 3 鎺掔浜�
-            case 1: return 3;  // 1 鎺掔涓�
-            default: return 4; // 鍏朵粬鍊兼帓鏈�鍚庯紙濡傛灉鏈夛級
+    private static int getCustomOrder(Integer crnNo, String sort) {
+        switch (sort) {
+            case "other":
+                switch (crnNo) {
+                    case 2:
+                        return 1;  // 2 鎺掔涓�
+                    case 3:
+                        return 2;  // 3 鎺掔浜�
+                    case 1:
+                        return 3;  // 1 鎺掔涓�
+                    default:
+                        return 4; // 鍏朵粬鍊兼帓鏈�鍚庯紙濡傛灉鏈夛級
+                }
+            case "asc":
+            default:
+                return crnNo;
         }
     }
 

--
Gitblit v1.9.1