From 1c02f5b648cd3c58a7db7dcec761071d5daabb26 Mon Sep 17 00:00:00 2001
From: ZY <zc857179121@qq.com>
Date: 星期二, 20 八月 2024 13:24:20 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/wms-dev' into wms-dev

---
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java |  170 +++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 124 insertions(+), 46 deletions(-)

diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java
index 1c6c199..1c1748b 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java
@@ -3,8 +3,7 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.zy.asrs.framework.exception.CoolException;
 import com.zy.asrs.wms.asrs.entity.*;
-import com.zy.asrs.wms.asrs.entity.enums.LocStsType;
-import com.zy.asrs.wms.asrs.entity.enums.OrderSettleType;
+import com.zy.asrs.wms.asrs.entity.enums.*;
 import com.zy.asrs.wms.asrs.entity.param.GeneratePakInParam;
 import com.zy.asrs.wms.asrs.service.*;
 import com.zy.asrs.wms.utils.LocUtils;
@@ -45,6 +44,12 @@
     private TaskDetlFieldLogService taskDetlFieldLogService;
     @Autowired
     private LocUtils locUtils;
+    @Autowired
+    private ShelvesRuleService shelvesRuleService;
+    @Autowired
+    private LanewayRuleService lanewayRuleService;
+    @Autowired
+    private CircleRuleService circleRuleService;
 
     @Override
     public String generateTaskNo(Long taskType) {
@@ -60,31 +65,68 @@
 
     @Override
     public Loc generateEmptyLoc(Long taskType, Integer locTypeHeight) {
-        Loc defaultLoc = null;
-
-        //1.浠庡簱瀛樻垨浠诲姟涓尮閰嶇浉閭诲簱浣�
-        defaultLoc = locUtils.getNeighborEmptyLoc(taskType, locTypeHeight);
-        if (defaultLoc != null) {
-            return defaultLoc;
+        List<ShelvesRule> shelvesRules = shelvesRuleService.list(new LambdaQueryWrapper<ShelvesRule>().eq(ShelvesRule::getStatus, 1).orderByDesc(ShelvesRule::getCreateTime));
+        if(shelvesRules.isEmpty()) {
+            throw new CoolException("鏈厤缃笂鏋惰鍒�");
         }
-
-        //2.鑾峰彇鎺ㄨ崘搴撲綅
-        List<Loc> suggestLoc = locUtils.getSuggestEmptyLoc(taskType, locTypeHeight);
-        //鑾峰彇搴撲綅
-        if (!suggestLoc.isEmpty()) {
-            defaultLoc = locUtils.filterLoc(taskType, suggestLoc);
-            if(defaultLoc != null) {
-                return defaultLoc;
+        ShelvesRule shelvesRule = shelvesRules.get(0);
+        //鍙敤宸烽亾
+        List<Long> laneList = shelvesRule.getLaneList();
+        //鍙敤宸烽亾Row
+        List<Integer> laneRowList = new ArrayList<>();
+        if (laneList != null) {
+            //鑾峰彇宸烽亾
+            List<LanewayRule> lanewayRules = lanewayRuleService.listByIds(laneList);
+            for (LanewayRule lanewayRule : lanewayRules) {
+                laneRowList.addAll(lanewayRule.getLaneX$());
+                laneRowList.addAll(lanewayRule.getLaneY$());
             }
         }
 
-        //3.浠庡叏灞�搴撲綅涓幏鍙�(瀹屾暣宸烽亾)
-        List<Loc> globalLoc = locUtils.getGlobalEmptyLoc(taskType, locTypeHeight);
-        //鑾峰彇搴撲綅
-        if (!globalLoc.isEmpty()) {
-            defaultLoc = locUtils.filterAllLoc(globalLoc);
-            if(defaultLoc != null) {
-                return defaultLoc;
+        Integer currentLev = null;
+        if (shelvesRule.getRuleType().equals(ShelvesRuleType.HIGH.id)) {
+            //浼樺厛绔嬩綋灞�
+            currentLev = circleRuleService.getCurrentValueByFlag(CircleRuleType.LEV.flag);
+        }
+
+        List<ShelvesRuleDetl> ruleDetls = shelvesRule.getRuleDetl$();
+        if(ruleDetls.isEmpty()) {
+            throw new CoolException("鏈厤缃笂鏋惰鍒欐槑缁�");
+        }
+
+        Loc defaultLoc = null;
+
+        for (ShelvesRuleDetl ruleDetl : ruleDetls) {
+            if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.TASK_OR_LOC.id)) {
+                //浠庡簱瀛樻垨浠诲姟涓尮閰嶇浉閭诲簱浣�
+                defaultLoc = locUtils.getNeighborEmptyLoc(taskType, locTypeHeight);
+                if (defaultLoc != null) {
+                    return defaultLoc;
+                }
+            }
+
+            if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.SUGGEST.id)) {
+                //鑾峰彇鎺ㄨ崘搴撲綅
+                List<Loc> suggestLoc = locUtils.getSuggestEmptyLoc(taskType, locTypeHeight, laneRowList, currentLev);
+                //鑾峰彇搴撲綅
+                if (!suggestLoc.isEmpty()) {
+                    defaultLoc = locUtils.filterLoc(taskType, suggestLoc);
+                    if(defaultLoc != null) {
+                        return defaultLoc;
+                    }
+                }
+            }
+
+            if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.COMPLETE.id)) {
+                //浠庡叏灞�搴撲綅涓幏鍙�(瀹屾暣宸烽亾)
+                List<Loc> globalLoc = locUtils.getGlobalEmptyLoc(taskType, locTypeHeight, laneRowList, currentLev);
+                //鑾峰彇搴撲綅
+                if (!globalLoc.isEmpty()) {
+                    defaultLoc = locUtils.filterAllLoc(globalLoc);
+                    if(defaultLoc != null) {
+                        return defaultLoc;
+                    }
+                }
             }
         }
 
@@ -109,34 +151,70 @@
             throw new CoolException("鍟嗗搧涓嶅瓨鍦�");
         }
 
+        List<ShelvesRule> shelvesRules = shelvesRuleService.list(new LambdaQueryWrapper<ShelvesRule>().eq(ShelvesRule::getStatus, 1).orderByDesc(ShelvesRule::getCreateTime));
+        if(shelvesRules.isEmpty()) {
+            throw new CoolException("鏈厤缃笂鏋惰鍒�");
+        }
+        ShelvesRule shelvesRule = shelvesRules.get(0);
+        //鍙敤宸烽亾
+        List<Long> laneList = shelvesRule.getLaneList();
+        //鍙敤宸烽亾Row
+        List<Integer> laneRowList = new ArrayList<>();
+        if (laneList != null) {
+            //鑾峰彇宸烽亾
+            List<LanewayRule> lanewayRules = lanewayRuleService.listByIds(laneList);
+            for (LanewayRule lanewayRule : lanewayRules) {
+                laneRowList.addAll(lanewayRule.getLaneX$());
+                laneRowList.addAll(lanewayRule.getLaneY$());
+            }
+        }
+
+        Integer currentLev = null;
+        if (shelvesRule.getRuleType().equals(ShelvesRuleType.HIGH.id)) {
+            //浼樺厛绔嬩綋灞�
+            currentLev = circleRuleService.getCurrentValueByFlag(CircleRuleType.LEV.flag);
+        }
+
+        List<ShelvesRuleDetl> ruleDetls = shelvesRule.getRuleDetl$();
+        if(ruleDetls.isEmpty()) {
+            throw new CoolException("鏈厤缃笂鏋惰鍒欐槑缁�");
+        }
+
         Loc defaultLoc = null;
 
-        //1.浠庡簱瀛樻垨浠诲姟涓尮閰嶇浉閭诲簱浣�
-        defaultLoc = locUtils.getNeighborLoc(taskType, detl, locTypeHeight);
-        if (defaultLoc != null) {
-            return defaultLoc;
-        }
+        for (ShelvesRuleDetl ruleDetl : ruleDetls) {
+            if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.TASK_OR_LOC.id)) {
+                //浠庡簱瀛樻垨浠诲姟涓尮閰嶇浉閭诲簱浣�
+                defaultLoc = locUtils.getNeighborLoc(taskType, detl, locTypeHeight);
+                if (defaultLoc != null) {
+                    return defaultLoc;
+                }
+            }
 
-        //2.鑾峰彇鎺ㄨ崘搴撲綅
-        List<Loc> suggestLoc = locUtils.getSuggestLoc(taskType, mat.getId(), detl.getBatch(), locTypeHeight);
-        //鑾峰彇搴撲綅
-        if (!suggestLoc.isEmpty()) {
-            defaultLoc = locUtils.filterLoc(taskType, suggestLoc);
-            if(defaultLoc != null) {
-                return defaultLoc;
+            if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.SUGGEST.id)) {
+                //鑾峰彇鎺ㄨ崘搴撲綅
+                List<Loc> suggestLoc = locUtils.getSuggestLoc(taskType, mat.getId(), detl.getBatch(), locTypeHeight, laneRowList, currentLev);
+                //鑾峰彇搴撲綅
+                if (!suggestLoc.isEmpty()) {
+                    defaultLoc = locUtils.filterLoc(taskType, suggestLoc);
+                    if(defaultLoc != null) {
+                        return defaultLoc;
+                    }
+                }
+            }
+
+            if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.COMPLETE.id)) {
+                //浠庡叏灞�搴撲綅涓幏鍙�(瀹屾暣宸烽亾)
+                List<Loc> globalLoc = locUtils.getGlobalLoc(taskType, locTypeHeight, laneRowList, currentLev);
+                //鑾峰彇搴撲綅
+                if (!globalLoc.isEmpty()) {
+                    defaultLoc = locUtils.filterAllLoc(globalLoc);
+                    if(defaultLoc != null) {
+                        return defaultLoc;
+                    }
+                }
             }
         }
-
-        //3.浠庡叏灞�搴撲綅涓幏鍙�(瀹屾暣宸烽亾)
-        List<Loc> globalLoc = locUtils.getGlobalLoc(taskType, locTypeHeight);
-        //鑾峰彇搴撲綅
-        if (!globalLoc.isEmpty()) {
-            defaultLoc = locUtils.filterAllLoc(globalLoc);
-            if(defaultLoc != null) {
-                return defaultLoc;
-            }
-        }
-
         return defaultLoc;
     }
 

--
Gitblit v1.9.1