From 3725597b59664c888faf1e2576a3e1e0d27b0c92 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期六, 14 十月 2023 16:20:07 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/thread/NyShuttleThread.java |   90 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 83 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/NyShuttleThread.java b/src/main/java/com/zy/core/thread/NyShuttleThread.java
index 12e841d..9ad6f5a 100644
--- a/src/main/java/com/zy/core/thread/NyShuttleThread.java
+++ b/src/main/java/com/zy/core/thread/NyShuttleThread.java
@@ -35,6 +35,7 @@
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -386,8 +387,11 @@
             return false;
         }
 
+        checkIOSta(commands, commandStep);//妫�娴嬪皬杞︽槸鍚﹁繘鍑烘彁鍗囨満杈撻�佺珯
+
         NavigateMapData navigateMapData = new NavigateMapData(Utils.getLev(shuttleProtocol.getCurrentLocNo()));
 
+        boolean isLock = false;//鏄惁瑙i攣璺緞
         //鍙栧嚭鍛戒护
         NyShuttleHttpCommand command = null;
         if (commandStep < commands.size()) {
@@ -403,13 +407,15 @@
                 if (shuttleProtocol.getPoint().equals(target)) {
                     //涓婁竴鏉℃寚浠ょ殑鐩爣浣嶇疆鍜屽綋鍓嶅皬杞︿綅缃浉鍚岋紝鍒欒瀹氫笂涓�鏉′换鍔″畬鎴�
                     lastCommand.setComplete(true);
-                    //瑙i攣閿佸畾璺緞锛屼笂涓�鏉¤矾寰勫拰褰撳墠璺緞
+                    //瑙i攣閿佸畾璺緞锛屼笂涓�鏉¤矾寰�
                     List<NavigateNode> nodes = lastCommand.getNodes();
-                    if (command != null && command.getNodes() != null) {
-                        nodes.addAll(command.getNodes());
-                    }
+//                    //瑙i攣褰撳墠璺緞
+//                    if (command != null && command.getNodes() != null) {
+//                        nodes.addAll(command.getNodes());
+//                    }
                     if (nodes != null) {
                         navigateMapData.writeNavigateNodeToRedisMap(nodes, false);//瑙i攣璺緞
+                        isLock = true;//瑙i攣杩囪矾寰�
                     }
                 }
             }else {
@@ -473,9 +479,19 @@
                 whiteList.add(startArr);
             }
 
-            //妫�娴嬭矾寰勬槸鍚﹀彲琛岃蛋
-            if (!checkPath(command.getNodes(), nextNodes, whiteList)) {
-                return false;
+            //瑙i攣杩囪矾寰勶紝鍙娴嬩笅涓�娈佃矾寰勬槸鍚﹀彲璧�(褰撳墠璺緞宸茬粡琚攣瀹氭棤闇�鍐嶆娴�)
+            if (isLock) {
+                //鍙娴嬩笅涓�娈佃矾寰勬槸鍚﹀彲璧�(褰撳墠璺緞宸茬粡琚攣瀹氭棤闇�鍐嶆娴�)
+                //妫�娴嬭矾寰勬槸鍚﹀彲琛岃蛋
+                if (!checkPath(nextNodes == null ? command.getNodes() : nextNodes, null, whiteList)) {
+                    return false;
+                }
+            }else {
+                //妫�娴嬪綋鍓嶈矾寰勫拰涓嬩竴娈佃矾寰�
+                //妫�娴嬭矾寰勬槸鍚﹀彲琛岃蛋
+                if (!checkPath(command.getNodes(), nextNodes, whiteList)) {
+                    return false;
+                }
             }
 
             //閿佸畾璺緞锛岄攣瀹氬綋鍓嶈矾寰勫拰涓嬩竴姝ヨ矾寰�
@@ -790,4 +806,64 @@
         }
     }
 
+    //妫�娴嬪皬杞︽槸鍚﹁繘鍑烘彁鍗囨満杈撻�佺珯
+    public void checkIOSta(List<NyShuttleHttpCommand> commands, int commandStep) {
+        if (commandStep != 0) {
+            NyShuttleHttpCommand lastCommand = commands.get(commandStep - 1);//涓婁竴姝ュ懡浠�
+            if (lastCommand.getRequest().getBody().get("requestType").equals("move")) {
+                //妫�娴嬭捣鐐规槸鍚︿负鎻愬崌鏈鸿緭閫佺珯鐐�
+                NyShuttleProtocol.NyShuttlePointClass start = JSON.parseObject(lastCommand.getRequest().getBody().get("start").toString(), NyShuttleProtocol.NyShuttlePointClass.class);
+                int[] startPoint = NavigatePositionConvert.NyXyzToWCSXyz(start.getX(), start.getY(), start.getZ());
+                if (startPoint[0] == 13 && (startPoint[1] == 22 || startPoint[1] == 38 || startPoint[1] == 57)) {
+                    //杈撻�佺珯鐐逛綅缃�
+
+                    int liftNo;
+                    if (startPoint[1] == 22) {
+                        liftNo = 1;
+                    } else if (startPoint[1] == 38) {
+                        liftNo = 2;
+                    } else {
+                        liftNo = 3;
+                    }
+
+                    HashMap<String, Object> data = new HashMap<>();
+                    data.put("lev", startPoint[2]);
+                    data.put("status", false);//鍑鸿緭閫佺珯
+
+                    //涓嬪彂浠诲姟
+                    MessageQueue.offer(SlaveType.Lift, liftNo, new Task(4, data));
+                }
+            }
+        }
+
+        if (commands.size() == commandStep) {
+            return;
+        }
+        NyShuttleHttpCommand command = commands.get(commandStep);//褰撳墠鍛戒护
+        if (command.getRequest().getBody().get("requestType").equals("move")) {
+            NyShuttleProtocol.NyShuttlePointClass target = JSON.parseObject(command.getRequest().getBody().get("target").toString(), NyShuttleProtocol.NyShuttlePointClass.class);
+            int[] targetPoint = NavigatePositionConvert.NyXyzToWCSXyz(target.getX(), target.getY(), target.getZ());
+            //妫�娴嬬洰鏍囦綅缃槸鍚︿负鎻愬崌鏈鸿緭閫佺珯鐐�
+            if (targetPoint[0] == 13 && (targetPoint[1] == 22 || targetPoint[1] == 38 || targetPoint[1] == 57)) {
+                //杈撻�佺珯鐐逛綅缃�
+
+                int liftNo;
+                if (targetPoint[1] == 22) {
+                    liftNo = 1;
+                } else if (targetPoint[1] == 38) {
+                    liftNo = 2;
+                } else {
+                    liftNo = 3;
+                }
+
+                HashMap<String, Object> data = new HashMap<>();
+                data.put("lev", targetPoint[2]);
+                data.put("status", true);//杩涜緭閫佺珯
+
+                //涓嬪彂浠诲姟
+                MessageQueue.offer(SlaveType.Lift, liftNo, new Task(4, data));
+            }
+        }
+    }
+
 }

--
Gitblit v1.9.1