From 6e02d92c3b9c240fa78a343b67ddf0db12d840e6 Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期五, 22 八月 2025 17:00:56 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/impl/TrafficControlImplThread.java | 35 ++++++++++++++++++++++++++++------- 1 files changed, 28 insertions(+), 7 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 1f3f4f2..f1655fa 100644 --- a/src/main/java/com/zy/core/thread/impl/TrafficControlImplThread.java +++ b/src/main/java/com/zy/core/thread/impl/TrafficControlImplThread.java @@ -56,6 +56,17 @@ List<TrafficControlDataModel> allTrafficControl = getAllTrafficControl(); //鏇存柊浜ょ淇℃伅 redisUtil.set(RedisKeyType.TRAFFIC_CONTROL_MAP.key, allTrafficControl); + + for (TrafficControlDataModel dataModel : allTrafficControl) { + Integer shuttleNo = dataModel.getShuttleNo(); + Integer taskNo = dataModel.getTaskNo(); + + Object object1 = redisUtil.get(RedisKeyType.TRAFFIC_CONTROL_SUCCESS_APPLY.key + shuttleNo + "_" + taskNo); + if(object1 == null) { + redisUtil.set(RedisKeyType.TRAFFIC_CONTROL_SUCCESS_APPLY.key + shuttleNo + "_" + taskNo, 1, 60 * 60); + } + } + Thread.sleep(200); }catch (Exception e){ e.printStackTrace(); @@ -163,10 +174,14 @@ Long idleTime = pathIdleShuttleMap.get(shuttleProtocol.getShuttleNo()); if((System.currentTimeMillis() - idleTime) > 1000 * 10) { //妫�娴嬮殰纰嶇墿杞� - boolean checkObstacle = shuttleOperaUtils.checkObstacle(shuttleProtocol.getCurrentLocNo(), new ArrayList<Integer>() {{ + int checkObstacle = shuttleOperaUtils.checkObstacle(shuttleProtocol.getCurrentLocNo(), new ArrayList<Integer>() {{ add(shuttleNo); - }}); + }}, totalNodeList); pathIdleShuttleMap.remove(shuttleProtocol.getShuttleNo()); + + if (checkObstacle == 2) { + pathShuttleThread.restartCalcPath(); + } } }else { pathIdleShuttleMap.put(shuttleProtocol.getShuttleNo(), System.currentTimeMillis()); @@ -187,6 +202,10 @@ } if(totalLocList.contains(locNo)) { + String first = totalLocList.get(0); + if(first.equals(locNo)) {//filter first node + continue; + } return false; } } @@ -199,7 +218,8 @@ operateTrafficControl(param); applyRecordsMap.remove(shuttleNo); - News.info("receipt traffic {},{}", shuttleNo, taskNo); + redisUtil.set(RedisKeyType.TRAFFIC_CONTROL_SUCCESS_APPLY.key + shuttleNo + "_" + taskNo, 1, 60 * 60); + News.info("[RCS Debug] receipt traffic {},{}", shuttleNo, taskNo); return true; } @@ -259,7 +279,7 @@ } @Override - public synchronized boolean cancelTrafficControl(Integer shuttleNo, Integer taskNo) { + public boolean cancelTrafficControl(Integer shuttleNo, Integer taskNo) { TrafficControlDataModel dataModel = queryTrafficControl(shuttleNo, taskNo); if (dataModel == null) { return false; @@ -273,7 +293,7 @@ } @Override - public synchronized boolean forceCancelTrafficControl(Integer shuttleNo) { + public boolean forceCancelTrafficControl(Integer shuttleNo) { TrafficControlDataModel dataModel = queryTrafficControl(shuttleNo); if (dataModel == null) { return false; @@ -323,7 +343,7 @@ public synchronized boolean operateTrafficControl(OperateTrafficControlParam param) { long startTime = System.currentTimeMillis(); String operaType = param.getOperaType(); - News.info("Operate Traffic Control is Start " + operaType); + News.info("[RCS Debug] Operate Traffic Control is Start " + operaType); boolean result = false; if (operaType.equals("add")) { @@ -342,7 +362,7 @@ new ArrayList<>(model.getTotalNodeList()) )) .collect(Collectors.toList()); - News.info("Operate Traffic Control is end " + (System.currentTimeMillis() - startTime) + "ms"); + News.info("[RCS Debug] Operate Traffic Control is end " + (System.currentTimeMillis() - startTime) + "ms"); return result; } @@ -381,6 +401,7 @@ } trafficControlDataList.remove(idx);//鍙栨秷绠″埗 + redisUtil.del(RedisKeyType.TRAFFIC_CONTROL_SUCCESS_APPLY.key + shuttleNo + "_" + taskNo); return true; } -- Gitblit v1.9.1