From 0f5a5a759221bde50ace126eae797326837f5f72 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期三, 16 十月 2024 16:15:12 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java |   63 ++++++++++++++++++++-----------
 1 files changed, 41 insertions(+), 22 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java
index 32bfa74..820c458 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java
@@ -14,6 +14,7 @@
 import com.zy.asrs.wcs.rcs.News;
 import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
 import com.zy.asrs.wcs.rcs.entity.Device;
+import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType;
 import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
 import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
 import com.zy.asrs.wcs.rcs.service.DeviceService;
@@ -283,9 +284,9 @@
     }
 
     /**
-     * 鎼滅储閬胯搴撲綅锛岄�氳繃灏忚溅鍙峰拰鐩爣搴撲綅
+     * 鎼滅储鍙敤搴撲綅锛岄�氳繃灏忚溅鍙峰拰鐩爣搴撲綅
      */
-    public String searchStandByLocNo(Integer shuttleNo, Long hostId, String locNo) {
+    public String searchAvailableLocNo(Integer shuttleNo, Long hostId, String currentLocNo, List<String> locNos) {
         BasShuttle basShuttle = basShuttleService.getOne(new LambdaQueryWrapper<BasShuttle>()
                 .eq(BasShuttle::getShuttleNo, shuttleNo)
                 .eq(BasShuttle::getHostId, hostId));
@@ -293,33 +294,18 @@
             throw new CoolException("灏忚溅鍩虹鏁版嵁涓嶅瓨鍦�");
         }
 
-        String idleLoc = basShuttle.getIdleLoc();
-        if (Cools.isEmpty(idleLoc)) {
-            throw new CoolException("灏忚溅閬胯鏁版嵁涓嶅瓨鍦�");
-        }
-
-        int lev = Utils.getLev(locNo);//褰撳墠妤煎眰
-        List<String> standbyLoc = JSON.parseArray(idleLoc, String.class);
-        if (standbyLoc.isEmpty()) {
-            throw new CoolException("閬胯鏁版嵁寮傚父");
-        }
-        //鑾峰彇褰撳墠灞傞伩璁╀綅缃�
-        List<String> currentLevStandByLoc = new ArrayList<>();
-        for (String loc : standbyLoc) {
-            if (Utils.getLev(loc) == lev) {
-                currentLevStandByLoc.add(loc);
-            }
-        }
-        if (currentLevStandByLoc.isEmpty()) {
+        if (locNos.isEmpty()) {
             throw new CoolException("褰撳墠灞傛棤閬胯浣嶇疆");
         }
 
+        int lev = Utils.getLev(currentLocNo);
+
         Integer finalDistance = ShuttleDispatcher.INF;
         String recentLoc = null;
-        for (String loc : currentLevStandByLoc) {
+        for (String loc : locNos) {
             //褰撳墠绌挎杞﹀埌閬胯浣嶈绠�
             List<NavigateNode> currentShuttlePath = NavigateUtils.calc(
-                    locNo
+                    currentLocNo
                     , loc
                     , NavigationMapType.NORMAL.id
                     , Utils.getShuttlePoints(shuttleNo, lev)
@@ -367,6 +353,18 @@
 
             ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
             if (shuttleProtocol == null) {
+                continue;
+            }
+
+            if (shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.OFFLINE)) {
+                continue;
+            }
+
+            if(!shuttleThread.isDeviceIdle()) {
+                continue;
+            }
+
+            if(shuttleProtocol.getCurrentLocNo() == null) {
                 continue;
             }
 
@@ -441,5 +439,26 @@
         return levCount < Integer.parseInt(dict.getValue());
     }
 
+    //鍒嗘瀽鍑哄簱璺緞寰呮満搴撲綅
+    public String analyzeOutPathWaitLoc(String startLoc, String targetLoc, Device shuttleDevice) {
+        //璁$畻璺緞骞跺垎瑙f垚涓ゆ鍔ㄤ綔
+        List<NavigateNode> nodeList = NavigateUtils.calc(startLoc, targetLoc, NavigationMapType.DFX.id, Utils.getShuttlePoints(Integer.parseInt(shuttleDevice.getDeviceNo()), Utils.getLev(startLoc)));
+        if (nodeList == null) {
+            News.error("{} dash {} can't find navigate path!", startLoc, targetLoc);
+            return null;
+        }
+        //鑾峰彇鍒嗘璺緞
+        ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(nodeList);
+        if (data.size() <= 1) {
+            return null;//涓ょ偣涔嬮棿鍙湁涓�娈佃矾寰�
+        }
+
+        //鍙栧嚭鍊掓暟绗簩娈佃矾寰�
+        ArrayList<NavigateNode> navigateNodes = data.get(data.size() - 2);
+        NavigateNode startNode = navigateNodes.get(0);
+        String lastPathStartLoc = Utils.getLocNo(startNode.getX(), startNode.getY(), startNode.getZ());
+        return lastPathStartLoc;
+    }
+
 
 }

--
Gitblit v1.9.1