From 6017ff0fac73ee771282f8c4711f20ec9ca67bd7 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 07 十一月 2023 08:54:13 +0800
Subject: [PATCH] #Redis Key Type

---
 src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java |   52 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java b/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java
index b9ed6ba..77e40a2 100644
--- a/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java
+++ b/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java
@@ -69,6 +69,18 @@
      * 璋冨害杞﹁締
      */
     public boolean dispatchShuttle(Integer wrkNo, String locNo) {
+        //妫�娴嬬洰鏍囧簱浣嶇粍鏄惁瀛樺湪灏忚溅锛屽瀛樺湪灏忚溅鍒欑洿鎺ユ寚瀹氳杞�
+        WrkMast wrkMast = wrkMastMapper.selectByWorkNo(wrkNo);
+        if (wrkMast != null) {
+            String targetLocNo = wrkMast.getIoType() < 100 ? wrkMast.getLocNo() : wrkMast.getSourceLocNo();
+            List<String> groupLoc = Utils.getGroupLoc(targetLocNo);
+            Integer groupShuttleNo = Utils.checkGroupLocHasShuttle(groupLoc);
+            if (groupShuttleNo != null) {
+                //瀛樺湪灏忚溅锛岀洿鎺ヨ皟搴﹁杞�
+                return shuttleMoveGenerate(wrkNo, locNo, groupShuttleNo);
+            }
+        }
+
         ArrayList<NyShuttleThread> sameLev = new ArrayList<>();//鐩稿悓妤煎眰鐨勭┛姊溅
         ArrayList<NyShuttleThread> diffLev = new ArrayList<>();//涓嶅悓妤煎眰鐨勭┛姊溅
 
@@ -118,7 +130,7 @@
                 //褰撳墠绌挎杞﹀簱浣嶅彿
                 String currentLocNo = shuttleThread.getShuttleProtocol().getCurrentLocNo();
                 //褰撳墠绌挎杞︾嚎绋嬪埌鐩爣鍦扮偣璺濈
-                List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleThread.getSlave().getId(), Utils.getLev(currentLocNo)));//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘
+                List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleThread.getSlave().getId(), Utils.getLev(currentLocNo)), null);//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘
                 if (currentShuttlePath == null) {
                     continue;
                 }
@@ -137,7 +149,8 @@
             WrkMast wrkMast1 = wrkMastMapper.selectByWorkNo(wrkNo);
 
             if (wrkMast1 != null) {
-                int lev = Utils.getLev(wrkMast1.getLocNo());//鐩爣妤煎眰
+                String targetLoc = wrkMast1.getIoType() < 100 ? wrkMast1.getLocNo() : wrkMast1.getSourceLocNo();
+                int lev = Utils.getLev(targetLoc);//鐩爣妤煎眰
 
                 //妫�娴嬬洰鏍囨ゼ灞傝溅鏁伴噺鏄惁灏忎簬鍏佽鐨勬渶澶ф暟閲�
                 boolean checkDispatchMaxNum = checkDispatchMaxNum(lev);
@@ -235,7 +248,7 @@
         if (Utils.getLev(locNo) != shuttleProtocol.getPoint().getZ()) {
             //鐩爣搴撲綅鍜屽皬杞﹀簱浣嶅浜庝笉鍚屼竴妤煎眰锛岄渶瑕侀�氳繃鎻愬崌鏈鸿皟搴�
             //鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満杈撻�佺珯鐐�
-            LiftStaProtocol liftSta = this.getRecentLiftSta(shuttleNo);
+            LiftStaProtocol liftSta = this.getRecentLiftSta(shuttleNo, Utils.getLev(locNo));
             if (liftSta == null) {
                 return false;//娌℃湁鍙敤涓旂┖闂茬殑杈撻�佺珯鐐�
             }
@@ -318,13 +331,32 @@
             }
         }
 
+        //鎼滅储鏄惁瀛樺湪鍓嶅線鐩爣妤煎眰鐨勫皬杞︾Щ鍔ㄥ伐浣滄。
+        for (WrkMast wrkMast : wrkMastMapper.selectShuttleMoveWrk()) {
+            if (wrkMast.getSourceLocNo() == null || wrkMast.getLocNo() == null) {
+                continue;
+            }
+
+            int sourceLev = Utils.getLev(wrkMast.getSourceLocNo());//宸ヤ綔妗f簮妤煎眰
+            int targetLev = Utils.getLev(wrkMast.getLocNo());//宸ヤ綔妗g洰鏍囨ゼ灞�
+            if (sourceLev == lev) {
+                continue;//宸ヤ綔妗fゼ灞傚拰鐩爣妤煎眰鐩稿悓锛岃烦杩�
+            }
+
+            if (targetLev == lev) {
+                levCount++;//宸ヤ綔妗g洰鏍囨ゼ灞傚拰瀹為檯妤煎眰鐩稿悓锛屾暟閲忓鍔�
+                continue;
+            }
+        }
+
+
         return levCount < Integer.parseInt(config.getValue());
     }
 
     /**
      * 鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満杈撻�佺珯鐐�
      */
-    public LiftStaProtocol getRecentLiftSta(Integer shuttleNo) {
+    public LiftStaProtocol getRecentLiftSta(Integer shuttleNo, Integer targetLev) {
         //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
         NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
         if (shuttleThread == null) {
@@ -356,6 +388,16 @@
                 continue;
             }
 
+            //鍒ゆ柇鐩爣妤煎眰绔欑偣鏄惁鏃犳墭鐩�
+            LiftStaProtocol targetLiftStaProtocol = NyLiftUtils.getLiftStaByLev(slave.getId(), targetLev);
+            if (targetLiftStaProtocol == null) {
+                continue;
+            }
+
+            if (targetLiftStaProtocol.getHasTray()) {
+                continue;//鏈夋墭鐩樿烦杩�
+            }
+
             list.add(liftStaProtocol);
         }
 
@@ -372,7 +414,7 @@
             String locNo = liftStaProtocol.getLocNo();//绔欑偣搴撲綅鍙�
 
             //褰撳墠绌挎杞︾嚎绋嬪埌鐩爣鍦扮偣璺濈
-            List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)));//浣跨敤姝e父閫氶亾鍦板浘
+            List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//浣跨敤姝e父閫氶亾鍦板浘
             if (currentShuttlePath == null) {
                 continue;
             }

--
Gitblit v1.9.1