From 6bad808389ec9d4c7331bb471c1410b50893fc1c Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 28 三月 2023 15:35:23 +0800
Subject: [PATCH] 四向车下命令时计算移动距离

---
 src/main/java/com/zy/core/thread/ShuttleThread.java |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/ShuttleThread.java b/src/main/java/com/zy/core/thread/ShuttleThread.java
index 03e30b5..7cd4f70 100644
--- a/src/main/java/com/zy/core/thread/ShuttleThread.java
+++ b/src/main/java/com/zy/core/thread/ShuttleThread.java
@@ -341,21 +341,27 @@
                 ArrayList pathList = JSON.parseObject(data.toString(), ArrayList.class);
                 //鍙栫涓�鏉¤矾寰�
                 Object o1 = pathList.get(commandStep);
-                ArrayList path = JSON.parseObject(o1.toString(), ArrayList.class);
+                ArrayList objectPath = JSON.parseObject(o1.toString(), ArrayList.class);
+                ArrayList<NavigateNode> path = new ArrayList<>();
+                for (Object o2 : objectPath) {
+                    NavigateNode navigateNode = JSON.parseObject(o2.toString(), NavigateNode.class);
+                    path.add(navigateNode);
+                }
+                Integer allDistance = NavigateUtils.getCurrentPathAllDistance(path);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
 
                 size = Integer.parseInt(map.get("pathSize").toString());
                 //寮�濮嬭矾寰�
-                JSONObject startPath = JSON.parseObject(path.get(0).toString());
+                NavigateNode startPath = path.get(0);
                 //鐩爣璺緞
-                JSONObject endPath = JSON.parseObject(path.get(path.size() - 1).toString());
+                NavigateNode endPath = path.get(path.size() - 1);
 
                 command.setCommandWord((short) 1);
-                command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getIntValue("x"), startPath.getIntValue("y")));
+                command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY()));
                 command.setMiddleCodeNum((short) 0);
-                command.setDistCodeNum(NavigatePositionConvert.xyToPosition(endPath.getIntValue("x"), endPath.getIntValue("y")));
-                command.setStartToDistDistance(1000);
+                command.setDistCodeNum(NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY()));
+                command.setStartToDistDistance(allDistance);
                 command.setMiddleToDistDistance(1000);
-                command.setRunDirection(ShuttleRunDirection.get(startPath.get("direction").toString()).id);
+                command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id);
                 command.setPalletLift((short) 1);
                 command.setForceMoveDistance(1000);
                 command.setChargeSwitch((short) 2);
@@ -431,6 +437,10 @@
 
                 //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting
                 shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.WAITING);
+                //璁剧疆鍥涘悜绌挎杞︿负绌洪棽鐘舵��
+                shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE);
+                //浠诲姟鍙锋竻闆�
+                shuttleProtocol.setTaskNo((short) 0);
 
                 News.info("鍥涘悜绌挎杞︿换鍔℃墽琛屽畬鎴愮瓑寰呯‘璁や腑锛岀┛姊溅鍙�={}锛屼换鍔℃暟鎹�={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command));
             }

--
Gitblit v1.9.1