From 5cc40452e260550c709928d0679f6e713448ffe7 Mon Sep 17 00:00:00 2001
From: zyx <zyx123456>
Date: 星期三, 01 十一月 2023 16:50:54 +0800
Subject: [PATCH] 库存编码规则 拣料更改料箱拣料

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

diff --git a/src/main/java/com/zy/common/service/CommonService.java b/src/main/java/com/zy/common/service/CommonService.java
index 1633fd3..f5e4231 100644
--- a/src/main/java/com/zy/common/service/CommonService.java
+++ b/src/main/java/com/zy/common/service/CommonService.java
@@ -144,6 +144,13 @@
             return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
         }
 
+        //瀛樿揣鍒嗙被缂栫爜瑙勫垯
+        locMast = getLocNoCodeStepRule(matNos, locTypeDto);
+        if (locMast != null) {
+            //鎵惧埌搴撲綅锛岃繑鍥瀌to
+            return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
+        }
+
         // 闈犺繎鎽嗘斁瑙勫垯 --- 鐩稿悓璁㈠崟鍙�, 鍚屽ぉ鍚岃鏍肩墿鏂�
         locMast = getLocNoStep3(staDescId, matNos, locTypeDto);
         if (locMast != null) {
@@ -213,6 +220,52 @@
         return locMast;
     }
 
+    /**
+     * 搴撲綅缂栫爜瑙勫垯
+     */
+    private LocMast getLocNoCodeStepRule(List<String> matNos, LocTypeDto locTypeDto) {
+        LocMast locMast = null;
+
+        //搴撲綅缂栫爜瑙勫垯鍙兘鍦ㄧ浉鍚岀紪鐮佽揣鐗╀腑鐢熸晥
+        String matnr = "";
+        for(String matNo : matNos){
+            if("".equals(matnr)){
+                matnr = matNo.substring(0, 4);
+            }
+            if(!matnr.equals(matNo.substring(0, 4))){
+                return null;
+            }
+        }
+
+        // 搴撳尯閿佸畾
+        List<LocRule> locRules = locRuleService.findCode(Cools.isEmpty(matNos) ? null : matNos.get(0),null);
+        if (locRules == null || locRules.isEmpty()) {
+            return null;//娌℃湁搴撲綅瑙勫垯锛岃烦鍑哄綋鍓嶄换鍔�
+        }
+
+        for (LocRule locRule : locRules) {
+            if (locRule == null) {
+                continue;
+            }
+
+            List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd());
+            for (LocMast locMast0 : locMasts) {
+                //棰勭暀绌哄簱浣�
+                if (locMastService.checkEmptyCount(locMast0, 10)) {
+                    return locMast0;
+                }
+            }
+        }
+
+//            if (locRules.get(0).getKeepGo() == 0) {
+//                //鎵句笉鍒扮┖搴撲綅锛屼笖绂佹缁х画瀵绘壘鍏朵粬闈炴贩杞藉尯鍩熷簱浣�
+//                //鎵句笉鍒板簱浣嶏紝鎶涘嚭寮傚父
+//                throw new CoolException("瑙勫垯鍖哄煙娌℃湁绌哄簱浣�");
+//            }
+
+        return locMast;
+    }
+
     // 闈犺繎鎽嗘斁瑙勫垯 --- 鐩稿悓璁㈠崟鍙�, 鍚屽ぉ鍚岃鏍肩墿鏂�
     private LocMast getLocNoStep3(Integer staDescId, List<String> matNos, LocTypeDto locTypeDto) {
         LocMast locMast = null;

--
Gitblit v1.9.1