From 34aa40fffdda9155e77a7991ca8c7691102bb0b8 Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期日, 26 四月 2026 11:29:05 +0800
Subject: [PATCH] no message

---
 src/main/java/com/zy/asrs/utils/Utils.java |   37 +++++++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/zy/asrs/utils/Utils.java b/src/main/java/com/zy/asrs/utils/Utils.java
index 1b0fe35..508f9c5 100644
--- a/src/main/java/com/zy/asrs/utils/Utils.java
+++ b/src/main/java/com/zy/asrs/utils/Utils.java
@@ -7,6 +7,7 @@
 import com.core.exception.CoolException;
 import com.zy.asrs.entity.LocMast;
 import com.zy.asrs.entity.RowLastno;
+import com.zy.asrs.service.LocMastService;
 import com.zy.asrs.service.RowLastnoService;
 import com.zy.common.CodeBuilder;
 import com.zy.common.model.LocDetlDto;
@@ -147,8 +148,40 @@
     public static String getShallowLoc(SlaveProperties slaveProperties, String deepLoc) {
         int row = getRow(deepLoc);
         int remainder = (int) Arith.remainder(row, slaveProperties.getGroupCount());
-        int shallowRow = remainder == 1 ? (row + 1) : (row - 1);
+        // 濂囨暟鎺掞紙1, 3...锛夊搴旂殑娴呭簱浣嶆槸 row + 1
+        // 鍋舵暟鎺掞紙2, 4...锛夊搴旂殑娴呭簱浣嶆槸 row - 1
+        int shallowRow = (remainder % 2 != 0) ? (row + 1) : (row - 1);
         return zerofill(String.valueOf(shallowRow), 2) + deepLoc.substring(2);
+    }
+
+    /**
+     * 鑾峰彇 娣卞簱浣嶅搴旂殑娴呭簱浣嶅彿
+     */
+    public static String getShallowLoc(String deepLoc, List<Integer> doubleLocs) {
+        LocMastService locService = SpringUtils.getBean(LocMastService.class);
+        LocMast depLoc = locService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", deepLoc));
+        int row;
+        if (depLoc.getRow1() != 1) {
+            row = depLoc.getRow1() - 1;
+        } else {
+            row = depLoc.getRow1();
+        }
+        boolean contains = doubleLocs.contains(row);
+        LocMast shallowLoc = null;
+        if (!contains) {
+            shallowLoc = locService.selectOne(new EntityWrapper<LocMast>()
+                    .eq("row1", row)
+                    .eq("bay1", depLoc.getBay1())
+                    .eq("lev1", depLoc.getLev1())
+            );
+        } else {
+            shallowLoc = locService.selectOne(new EntityWrapper<LocMast>()
+                    .eq("row1", depLoc.getRow1() + 1)
+                    .eq("bay1", depLoc.getBay1())
+                    .eq("lev1", depLoc.getLev1())
+            );
+        }
+        return shallowLoc.getLocNo();
     }
 
     /**
@@ -156,7 +189,7 @@
      */
     public static Integer getShallowRow(SlaveProperties slaveProperties, Integer deepRow) {
         int remainder = (int) Arith.remainder(deepRow, slaveProperties.getGroupCount());
-        return remainder == 1 ? (deepRow + 1) : (deepRow - 1);
+        return (remainder % 2 != 0) ? (deepRow + 1) : (deepRow - 1);
     }
 
     /**

--
Gitblit v1.9.1