From d9a0b7a278e76f9738f8eeb05ce13a4ef8e5cbcf Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期四, 31 七月 2025 14:49:50 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/impl/TrafficControlImplThread.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/zy/core/thread/impl/TrafficControlImplThread.java b/src/main/java/com/zy/core/thread/impl/TrafficControlImplThread.java index f15a5c2..9a3a6de 100644 --- a/src/main/java/com/zy/core/thread/impl/TrafficControlImplThread.java +++ b/src/main/java/com/zy/core/thread/impl/TrafficControlImplThread.java @@ -9,6 +9,7 @@ import com.zy.common.utils.NavigatePositionConvert; import com.zy.common.utils.NavigateUtils; import com.zy.common.utils.RedisUtil; +import com.zy.common.utils.ShuttleOperaUtils; import com.zy.core.News; import com.zy.core.cache.SlaveConnection; import com.zy.core.enums.RedisKeyType; @@ -35,6 +36,8 @@ private HashMap<Integer, HashMap<String, List<Integer>>> levNodesMap = null; + private HashMap<Integer,Long> shuttleReportErrorMap = new HashMap<>(); + private HashMap<Integer,Long> pathIdleShuttleMap = new HashMap<>(); private HashMap<Integer,Long> applyRecordsMap = new HashMap<>(); private HashMap<String, List<NavigateNode>> taskNodesMap = new HashMap<>(); private List<TrafficControlDataModel> trafficControlDataList = new ArrayList<>(); @@ -443,6 +446,11 @@ @Override public synchronized boolean applyTrafficControl(List<NavigateNode> totalNodeList, List<NavigateNode> nodeList, Integer shuttleNo, Integer taskNo) { + ShuttleOperaUtils shuttleOperaUtils = SpringUtils.getBean(ShuttleOperaUtils.class); + if (shuttleOperaUtils == null) { + return false; + } + //鏇存柊浜ょ淇℃伅 redisUtil.set(RedisKeyType.TRAFFIC_CONTROL_MAP.key, trafficControlDataList); @@ -508,6 +516,30 @@ //妫�娴嬭矾寰勬槸鍚︽湁灏忚溅 for (String loc : totalLocList) { if(shuttleLocList.contains(loc)) { + ShuttleThread pathShuttleThread = Utils.searchShuttle(loc); + if (pathShuttleThread == null) { + return false; + } + + ShuttleProtocol shuttleProtocol = pathShuttleThread.getStatus(); + if(shuttleProtocol == null) { + return false; + } + + if (pathShuttleThread.isIdle()) { + if(pathIdleShuttleMap.containsKey(shuttleProtocol.getShuttleNo())) { + Long idleTime = pathIdleShuttleMap.get(shuttleProtocol.getShuttleNo()); + if((System.currentTimeMillis() - idleTime) > 1000 * 10) { + //妫�娴嬮殰纰嶇墿杞� + boolean checkObstacle = shuttleOperaUtils.checkObstacle(shuttleProtocol.getCurrentLocNo(), new ArrayList<Integer>() {{ + add(shuttleNo); + }}); + pathIdleShuttleMap.remove(shuttleProtocol.getShuttleNo()); + } + }else { + pathIdleShuttleMap.put(shuttleProtocol.getShuttleNo(), System.currentTimeMillis()); + } + } return false;//node has shuttle } } @@ -566,6 +598,7 @@ controlDataModel.setTotalNodeList(newTotalNodeList); trafficControlDataList.set(i, controlDataModel); + shuttleReportErrorMap.remove(shuttleNo); return true; } } @@ -574,6 +607,25 @@ } @Override + public boolean trafficReportError(Integer shuttleNo, Integer taskNo) { + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); + if (shuttleThread == null) { + return false; + } + + if(shuttleReportErrorMap.containsKey(shuttleNo)) { + Long errorTime = shuttleReportErrorMap.get(shuttleNo); + if((System.currentTimeMillis() - errorTime) > 1000 * 10) { + shuttleReportErrorMap.remove(shuttleNo); + shuttleThread.restartCalcPath(); + } + }else { + shuttleReportErrorMap.put(shuttleNo, System.currentTimeMillis()); + } + return true; + } + + @Override public synchronized boolean cancelTrafficControl(Integer shuttleNo, Integer taskNo) { //妫�娴嬭溅瀛愭槸鍚﹀瓨鍦ㄧ鍒� for (int i = 0; i < trafficControlDataList.size(); i++) { -- Gitblit v1.9.1