From efa3e3042d30506b8eb3ce662d39c4dd954ae945 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期五, 25 七月 2025 13:35:27 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/thread/impl/NyShuttleThread.java |  127 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 125 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java
index ad23b1c..0baeb1e 100644
--- a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java
+++ b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java
@@ -20,8 +20,11 @@
 import com.zy.common.utils.NavigateMapData;
 import com.zy.common.utils.NavigatePositionConvert;
 import com.zy.common.utils.RedisUtil;
+import com.zy.common.utils.ShuttleOperaUtils;
 import com.zy.core.News;
+import com.zy.core.action.ShuttleAction;
 import com.zy.core.model.DeviceCommandMsgModel;
+import com.zy.core.model.command.ShuttleAssignCommand;
 import com.zy.core.utils.DeviceMsgUtils;
 import com.zy.core.cache.OutputQueue;
 import com.zy.core.enums.*;
@@ -752,6 +755,9 @@
 
     @Override
     public synchronized boolean setProtocolStatus(ShuttleProtocolStatusType status) {
+        if (status.equals(ShuttleProtocolStatusType.IDLE)) {
+            this.shuttleProtocol.setIdleTime(System.currentTimeMillis());
+        }
         this.shuttleProtocol.setProtocolStatus(status);
         return true;
     }
@@ -821,6 +827,13 @@
     }
 
     @Override
+    public boolean setTrafficControl(boolean enable, List<NavigateNode> nodeList) {
+        shuttleProtocol.setTrafficControl(enable);
+        shuttleProtocol.setTrafficControlNodes(nodeList);
+        return true;
+    }
+
+    @Override
     public void updateDeviceDataLogTime(long time) {
         shuttleProtocol.setDeviceDataLog(time);
     }
@@ -839,6 +852,116 @@
         body.put("responseType", "state");
 
         return null;
+    }
+
+    @Override
+    public boolean restartCalcPath() {
+        ConfigService configService = SpringUtils.getBean(ConfigService.class);
+        if (configService == null) {
+            return false;
+        }
+
+        ShuttleAction shuttleAction = SpringUtils.getBean(ShuttleAction.class);
+        if (shuttleAction == null) {
+            return false;
+        }
+
+        ShuttleOperaUtils shuttleOperaUtils = SpringUtils.getBean(ShuttleOperaUtils.class);
+        if (shuttleOperaUtils == null) {
+            return false;
+        }
+
+        ObjectMapper objectMapper = SpringUtils.getBean(ObjectMapper.class);
+        if (objectMapper == null) {
+            return false;
+        }
+
+        boolean trafficControlRestartCalcPath = false;
+        Config trafficControlRestartCalcPathConfig = configService.selectOne(new EntityWrapper<Config>()
+                .eq("code", "trafficControlRestartCalcPath")
+        );
+        if(trafficControlRestartCalcPathConfig != null) {
+            trafficControlRestartCalcPath = trafficControlRestartCalcPathConfig.getValue().equals("Y") ? true : false;
+        }
+
+        if (!trafficControlRestartCalcPath) {
+            return false;
+        }
+
+        if (shuttleProtocol.getTaskNo() == 0) {
+            return false;
+        }
+
+        if (!this.isDeviceIdle()) {
+            return false;
+        }
+
+        Object object = redisUtil.get(RedisKeyType.SHUTTLE_RESTART_CALC_PATH.key + shuttleProtocol.getShuttleNo());
+        if (object != null) {
+            return false;
+        }
+
+        Integer taskNo = shuttleProtocol.getTaskNo();
+        Object obj = redisUtil.get(RedisKeyType.SHUTTLE_WORK_FLAG.key + taskNo);
+        if (obj == null) {
+            return false;
+        }
+
+        ShuttleRedisCommand redisCommand = null;
+        try {
+            redisCommand = objectMapper.readValue(String.valueOf(obj), ShuttleRedisCommand.class);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+
+        if (redisCommand == null) {
+            return false;
+        }
+
+        ShuttleAssignCommand assignCommand = redisCommand.getAssignCommand();
+        String locNo = assignCommand.getLocNo();
+        List<NavigationMapType> mapTypes = assignCommand.getMapTypes();
+        if (locNo == null) {
+            return false;
+        }
+
+        if (mapTypes == null) {
+            return false;
+        }
+
+        String currentLocNo = shuttleProtocol.getCurrentLocNo();
+        List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(currentLocNo, locNo, mapTypes, assignCommand, this);
+        if (commands == null) {
+            return false;
+        }
+
+        if (assignCommand.getTaskMode() == ShuttleTaskModeType.TRANSPORT.id) {
+            List<ShuttleCommand> originCommands = assignCommand.getCommands();
+            if (originCommands == null) {
+                return false;
+            }
+
+            ShuttleCommand firstCommand = originCommands.get(0);
+            ShuttleCommand endCommand = originCommands.get(commands.size() - 1);
+
+            if (firstCommand.getMode() != ShuttleCommandModeType.PALLET_LIFT.id) {
+                return false;
+            }
+
+            if (endCommand.getMode() != ShuttleCommandModeType.PALLET_DOWN.id) {
+                return false;
+            }
+
+            commands.add(0, firstCommand);
+            commands.add(endCommand);
+        }
+
+        assignCommand.setCommands(commands);
+
+        //涓嬪彂浠诲姟
+        shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand);
+        redisUtil.set(RedisKeyType.SHUTTLE_RESTART_CALC_PATH.key + shuttleProtocol.getShuttleNo(), true, 60);
+        return true;
     }
 
     @Override
@@ -867,7 +990,7 @@
             int yp = Integer.parseInt(String.valueOf(nyNode.get("x")));
             int z = Integer.parseInt(String.valueOf(nyNode.get("z")));
 
-            List<List<MapNode>> mapData = navigateMapData.getJsonData(startNode.getZ(), NavigationMapType.NONE.id, null, null);
+            List<List<MapNode>> mapData = navigateMapData.getJsonData(startNode.getZ(), NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null);
             List<MapNode> mapNodes = mapData.get(node.getX());
             MapNode mapNode = mapNodes.get(node.getY());
 
@@ -983,7 +1106,7 @@
             throw new CoolException("鍦板潃鐮佷笉瀛樺湪");
         }
 
-        List<List<MapNode>> mapData = navigateMapData.getJsonData(lev, NavigationMapType.NONE.id, null, null);
+        List<List<MapNode>> mapData = navigateMapData.getJsonData(lev, NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null);
         List<MapNode> mapNodes = mapData.get(locMast.getRow1());
         MapNode mapNode = mapNodes.get(locMast.getBay1());
 

--
Gitblit v1.9.1