From 632bde0f32999a2b319b706e23d90bc1b5dd8cc2 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期二, 21 四月 2026 17:22:56 +0800
Subject: [PATCH] 1.新增拍照功能

---
 src/main/java/com/zy/common/service/CommonService.java |  100 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 92 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 b0132dd..1b816e1 100644
--- a/src/main/java/com/zy/common/service/CommonService.java
+++ b/src/main/java/com/zy/common/service/CommonService.java
@@ -2012,6 +2012,89 @@
     }
 
     /**
+     * 鍙屼几鍫嗗灈鏈哄悓璐т紭鍏堬細
+     * 鍏堟壘娣卞簱浣嶄腑 standby1 鐩稿悓涓旂姸鎬佷负 F 鐨勮揣浣嶏紝鍐嶆鏌ュ叾瀵瑰簲娴呭簱浣嶆槸鍚︿负绌恒��
+     */
+    private LocMast findDoubleExtensionSameGoodsPreferredLoc(RowLastno rowLastno, RowLastnoType rowLastnoType,
+                                                             Integer crnNo, CrnDepthRuleProfile profile,
+                                                             LocTypeDto locTypeDto, FindLocNoAttributeVo findLocNoAttributeVo) {
+        if (profile == null || !profile.isDoubleExtension() || findLocNoAttributeVo == null
+                || Cools.isEmpty(findLocNoAttributeVo.getStandby1())) {
+            return null;
+        }
+        String standby1 = findLocNoAttributeVo.getStandby1();
+        LinkedHashSet<Integer> processedDeepRows = new LinkedHashSet<Integer>();
+        for (Integer searchRow : profile.getSearchRows()) {
+            if (searchRow == null || !profile.isDeepRow(searchRow) || !processedDeepRows.add(searchRow)) {
+                continue;
+            }
+            Integer shallowRow = profile.getPairedShallowRow(searchRow);
+            if (shallowRow == null) {
+                continue;
+            }
+            List<LocMast> deepLocs = findOccupiedLocsByRow(searchRow, crnNo, findLocNoAttributeVo);
+            if (Cools.isEmpty(deepLocs)) {
+                continue;
+            }
+            List<String> deepLocNos = new ArrayList<String>();
+            for (LocMast deepLoc : deepLocs) {
+                if (deepLoc == null || Cools.isEmpty(deepLoc.getLocNo())) {
+                    continue;
+                }
+                deepLocNos.add(deepLoc.getLocNo());
+            }
+            if (Cools.isEmpty(deepLocNos)) {
+                continue;
+            }
+            List<LocDetl> sameGoodsLocDetls = locDetlService.selectList(new EntityWrapper<LocDetl>()
+                    .eq("standby1", standby1)
+                    .in("loc_no", deepLocNos));
+            if (Cools.isEmpty(sameGoodsLocDetls)) {
+                continue;
+            }
+            LinkedHashSet<String> sameGoodsLocNos = new LinkedHashSet<String>();
+            for (LocDetl locDetl : sameGoodsLocDetls) {
+                if (locDetl == null || Cools.isEmpty(locDetl.getLocNo())) {
+                    continue;
+                }
+                sameGoodsLocNos.add(locDetl.getLocNo());
+            }
+            if (Cools.isEmpty(sameGoodsLocNos)) {
+                continue;
+            }
+            for (LocMast deepLoc : deepLocs) {
+                if (deepLoc == null || !sameGoodsLocNos.contains(deepLoc.getLocNo())) {
+                    continue;
+                }
+                LocMast shallowLoc = findLocByPosition(rowLastno, rowLastnoType, crnNo, shallowRow,
+                        deepLoc.getBay1(), deepLoc.getLev1(), "O");
+                if (!Cools.isEmpty(shallowLoc) && matchesLocType(shallowLoc, locTypeDto)) {
+                    return shallowLoc;
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 鏌ヨ鏌愪竴鎺掍笂鐘舵�佷负 F 鐨勫簱浣嶏紝骞舵寜褰撳墠棰戞/鍓嶅嚑鍒楃瓥鐣ユ帓搴忋��
+     */
+    private List<LocMast> findOccupiedLocsByRow(Integer row, Integer crnNo, FindLocNoAttributeVo findLocNoAttributeVo) {
+        List<LocMast> result = new ArrayList<LocMast>();
+        if (row == null) {
+            return result;
+        }
+        Wrapper<LocMast> wrapper = new EntityWrapper<LocMast>()
+                .eq("row1", row)
+                .eq("loc_sts", "F");
+        if (crnNo != null) {
+            wrapper.eq("crn_no", crnNo);
+        }
+        List<LocMast> locMasts = locMastService.selectList(wrapper);
+        return sortLocCandidates(locMasts, findLocNoAttributeVo, false);
+    }
+
+    /**
      * 鍦ㄤ竴瀵规祬鎺�/娣辨帓涔嬮棿閫夋嫨鐪熸鍙姇鏀剧殑鐩爣搴撲綅銆�
      */
     private LocMast findPairAssignableLoc(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer crnNo,
@@ -2036,11 +2119,8 @@
             }
         }
         for (LocMast shallowLoc : shallowOpenLocs) {
-            LocMast deepBlockingLoc = findLocByPosition(rowLastno, rowLastnoType, crnNo, deepRow, shallowLoc.getBay1(), shallowLoc.getLev1(), "F", "D");
-            if (!Cools.isEmpty(deepBlockingLoc)) {
-                return shallowLoc;
-            }
-            if (findLocByPosition(rowLastno, rowLastnoType, crnNo, deepRow, shallowLoc.getBay1(), shallowLoc.getLev1()) == null) {
+            LocMast deepInStockLoc = findLocByPosition(rowLastno, rowLastnoType, crnNo, deepRow, shallowLoc.getBay1(), shallowLoc.getLev1(), "F");
+            if (!Cools.isEmpty(deepInStockLoc)) {
                 return shallowLoc;
             }
         }
@@ -2069,6 +2149,11 @@
         CrnDepthRuleProfile profile = basCrnDepthRuleService.resolveProfile(rowLastno, crnNo, preferredNearRow);
         if (profile == null || Cools.isEmpty(profile.getSearchRows())) {
             return null;
+        }
+        LocMast sameGoodsPreferredLoc = findDoubleExtensionSameGoodsPreferredLoc(rowLastno, rowLastnoType, crnNo,
+                profile, locTypeDto, findLocNoAttributeVo);
+        if (!Cools.isEmpty(sameGoodsPreferredLoc)) {
+            return sameGoodsPreferredLoc;
         }
         LinkedHashSet<Integer> processedShallowRows = new LinkedHashSet<Integer>();
         boolean singleExtension = profile.isSingleExtension();
@@ -2170,9 +2255,8 @@
                 count++;
                 continue;
             }
-            LocMast deepBlockingLoc = findLocByPosition(rowLastno, rowLastnoType, crnNo, deepRow, shallowLoc.getBay1(), shallowLoc.getLev1(), "F", "D");
-            if (!Cools.isEmpty(deepBlockingLoc) ||
-                    findLocByPosition(rowLastno, rowLastnoType, crnNo, deepRow, shallowLoc.getBay1(), shallowLoc.getLev1()) == null) {
+            LocMast deepInStockLoc = findLocByPosition(rowLastno, rowLastnoType, crnNo, deepRow, shallowLoc.getBay1(), shallowLoc.getLev1(), "F");
+            if (!Cools.isEmpty(deepInStockLoc)) {
                 count++;
             }
         }

--
Gitblit v1.9.1