From 8ecad328df8465b3d81c15e37943f6e9d3adf86b Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期一, 23 十月 2023 16:32:33 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/NyShuttleThread.java | 73 +++++++++++++++++++++++++++++++++++- 1 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/zy/core/thread/NyShuttleThread.java b/src/main/java/com/zy/core/thread/NyShuttleThread.java index 9a8b6d1..8c24a1b 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,6 +387,8 @@ return false; } + checkIOSta(commands, commandStep);//妫�娴嬪皬杞︽槸鍚﹁繘鍑烘彁鍗囨満杈撻�佺珯 + NavigateMapData navigateMapData = new NavigateMapData(Utils.getLev(shuttleProtocol.getCurrentLocNo())); boolean isLock = false;//鏄惁瑙i攣璺緞 @@ -411,7 +414,10 @@ // nodes.addAll(command.getNodes()); // } if (nodes != null) { - navigateMapData.writeNavigateNodeToRedisMap(nodes, false);//瑙i攣璺緞 + boolean result = navigateMapData.writeNavigateNodeToRedisMap(nodes, false);//瑙i攣璺緞 + if (!result) { + return false;//瑙i攣澶辫触 + } isLock = true;//瑙i攣杩囪矾寰� } } @@ -497,7 +503,10 @@ nodes.addAll(nextNodes); } if (nodes != null) { - navigateMapData.writeNavigateNodeToRedisMap(nodes, true);//鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢� + boolean result = navigateMapData.writeNavigateNodeToRedisMap(nodes, true);//鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢� + if (!result) { + return false;//璺緞閿佸畾澶辫触 + } } } @@ -803,4 +812,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