From 3d7bf12a7d6f139624a2dacd1bd80781d7f658e5 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期一, 30 十二月 2024 14:46:47 +0800 Subject: [PATCH] # --- zy-acs-flow/src/map/constants.js | 2 zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/RetreatNavigateService.java | 26 +++++-------- zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MapDataWsScheduler.java | 2 zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/AStarNavigateService.java | 14 ++----- zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/LaneService.java | 38 ++++++++++++++++++- zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java | 2 6 files changed, 53 insertions(+), 31 deletions(-) diff --git a/zy-acs-flow/src/map/constants.js b/zy-acs-flow/src/map/constants.js index 58869f5..8ab6ce1 100644 --- a/zy-acs-flow/src/map/constants.js +++ b/zy-acs-flow/src/map/constants.js @@ -1,5 +1,5 @@ -export const ANIMATE_DURING_TIME = 300; +export const ANIMATE_DURING_TIME = 600; export const MAP_DEFAULT_ROTATION = 270; diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MapDataWsScheduler.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MapDataWsScheduler.java index 3c7e5ab..5b5f82b 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MapDataWsScheduler.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MapDataWsScheduler.java @@ -33,7 +33,7 @@ @Component public class MapDataWsScheduler { - public static final int WEBSOCKET_BROADCAST_INTERVAL = 300; + public static final int WEBSOCKET_BROADCAST_INTERVAL = 600; private ExecutorService singleThreadExecutor; diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/LaneService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/LaneService.java index 12eb100..cbfedb2 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/LaneService.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/LaneService.java @@ -37,6 +37,8 @@ private final Map<String, List<String>> adjacencyCodeMap = new HashMap<>(); + private final Map<String, List<int[]>> laneCodeIdxMap = new HashMap<>(); + private boolean initialized = Boolean.FALSE; @Autowired @@ -47,6 +49,10 @@ private SnowflakeIdWorker snowflakeIdWorker; @Autowired private ConfigService configService; + @Autowired + private MapDataDispatcher mapDataDispatcher; + + // service ------------------------------------------------------- public Boolean isInitialized() { return this.initialized; @@ -64,13 +70,25 @@ return null; } + public List<int[]> getLaneCodeIdxList(String codeData) { + if (Cools.isEmpty(codeData)) { + return new ArrayList<>(); + } + List<int[]> list = this.laneCodeIdxMap.get(codeData); + if (null == list) { + return new ArrayList<>(); + } + return list; + } + + // launcher ------------------------------------------------------- + @PostConstruct public void init() { Integer lev = MapDataDispatcher.MAP_DEFAULT_LEV; String laneDataStr = redis.getValue(RedisConstant.MAP_LANE_DATA, String.valueOf(lev)); if (!Cools.isEmpty(laneDataStr)) { this.lanes = GsonUtils.fromJsonToList(laneDataStr, Lane.class); - this.initialized = Boolean.TRUE; } else { StopWatch stopWatch = new StopWatch(); @@ -84,6 +102,8 @@ redis.setValue(RedisConstant.MAP_LANE_DATA, String.valueOf(lev), GsonUtils.toJson(this.lanes)); } + this.generateLaneCodeIdx(null); + this.initialized = Boolean.TRUE; // System.out.println(GsonUtils.toJson(this.lanes)); } @@ -104,7 +124,6 @@ this.generateLaneHash(); - this.initialized = Boolean.TRUE; log.info("the lane data initialization has been completed in rcs system."); } @@ -327,4 +346,19 @@ return sb.toString(); } + public void generateLaneCodeIdx(Integer lev) { + log.info("There is initializing Lane CodeIdxMap......"); + long l = System.currentTimeMillis(); + if (Cools.isEmpty(this.lanes)) { + return; + } + for (Lane lane : this.lanes) { + List<int[]> codeIdxList = new ArrayList<>(); + for (String code : lane.getCodes()) { + int[] codeMatrixIdx = mapDataDispatcher.getCodeMatrixIdx(lev, code); + codeIdxList.add(codeMatrixIdx); + this.laneCodeIdxMap.put(code, codeIdxList); + } + } + } } diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java index d98b6d3..cda8676 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java @@ -212,7 +212,7 @@ for (int i = 0; i < dynamicMatrix.length; i++) { for (int j = 0; j < dynamicMatrix[i].length; j++) { - if (i == codeMatrixIdx[0] && j == codeMatrixIdx[1]) { continue; } +// if (i == codeMatrixIdx[0] && j == codeMatrixIdx[1]) { continue; } DynamicNode node = dynamicMatrix[i][j]; if (node.getVehicle().equals(agvNo)) { diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/RetreatNavigateService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/RetreatNavigateService.java index 0451ee4..7e9cbc3 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/RetreatNavigateService.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/RetreatNavigateService.java @@ -124,29 +124,26 @@ // lane if (pointOfTurn) { - Lane lane = laneService.search(node.getCodeData()); - if (null != lane) { + List<int[]> laneCodeIdxList = laneService.getLaneCodeIdxList(node.getCodeData()); + if (!Cools.isEmpty(laneCodeIdxList)) { Set<String> lanVehicleSet = new HashSet<>(); - for (String laneCodeData : lane.getCodes()) { + for (int[] codeMatrixIdx : laneCodeIdxList) { // overlap with sponsor + String laneCodeData = codeMatrix[codeMatrixIdx[0]][codeMatrixIdx[1]]; if (avoidPathList.contains(laneCodeData)) { lanVehicleSet.add(sponsor); } - int[] laneCodeMatrixIdx = mapDataDispatcher.getCodeMatrixIdx(null, laneCodeData); - // scan dynamicMatrix or WaveMatrix - DynamicNode laneDynamicNode = dynamicMatrix[laneCodeMatrixIdx[0]][laneCodeMatrixIdx[1]]; + DynamicNode laneDynamicNode = dynamicMatrix[codeMatrixIdx[0]][codeMatrixIdx[1]]; String laneVehicle = laneDynamicNode.getVehicle(); assert !laneVehicle.equals(DynamicNodeType.BLOCK.val); if (!laneVehicle.equals(DynamicNodeType.ACCESS.val)) { if (!laneVehicle.equals(agvNo)) { lanVehicleSet.add(laneVehicle); -// redis.setObject(RedisConstant.AGV_TO_STANDBY_FLAG, laneVehicle, true, 30); } } } - if (lanVehicleSet.size() + 1 > maxAgvCountInLane) { phaseSecond = false; // there is a running way continue; @@ -155,6 +152,7 @@ weight += WEIGHT_CALC_FACTOR * 2; } } + } Code code = codeService.selectByData(node.getCodeData()); @@ -224,24 +222,20 @@ for (RetreatNavigateNode node : neighborNodes) { // lane - Lane lane = laneService.search(node.getCodeData()); - if (null != lane) { + List<int[]> laneCodeIdxList = laneService.getLaneCodeIdxList(node.getCodeData()); + if (!Cools.isEmpty(laneCodeIdxList)) { Set<String> lanVehicleSet = new HashSet<>(); - for (String laneCodeData : lane.getCodes()) { - int[] laneCodeMatrixIdx = mapDataDispatcher.getCodeMatrixIdx(null, laneCodeData); - // scan dynamicMatrix or WaveMatrix - DynamicNode laneDynamicNode = dynamicMatrix[laneCodeMatrixIdx[0]][laneCodeMatrixIdx[1]]; + for (int[] codeMatrixIdx : laneCodeIdxList) { + DynamicNode laneDynamicNode = dynamicMatrix[codeMatrixIdx[0]][codeMatrixIdx[1]]; String laneVehicle = laneDynamicNode.getVehicle(); assert !laneVehicle.equals(DynamicNodeType.BLOCK.val); if (!laneVehicle.equals(DynamicNodeType.ACCESS.val)) { if (!laneVehicle.equals(agvNo)) { lanVehicleSet.add(laneVehicle); -// redis.setObject(RedisConstant.AGV_TO_STANDBY_FLAG, laneVehicle, true, 30); } } } - if (lanVehicleSet.size() + 1 > maxAgvCountInLane) { continue; } diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/AStarNavigateService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/AStarNavigateService.java index 9e9e982..656cd63 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/AStarNavigateService.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/AStarNavigateService.java @@ -121,30 +121,24 @@ } // 鍗曞贩閬撹溅杈嗗杞芥暟閲� - Lane lane = laneService.search(node.getCodeData()); - if (null != lane) { + List<int[]> laneCodeIdxList = laneService.getLaneCodeIdxList(node.getCodeData()); + if (!Cools.isEmpty(laneCodeIdxList)) { Set<String> lanVehicleSet = new HashSet<>(); - List<String> laneCodes = lane.getCodes(); - for (String laneCodeData : laneCodes) { - int[] laneCodeMatrixIdx = mapDataDispatcher.getCodeMatrixIdx(null, laneCodeData); - // scan dynamicMatrix or WaveMatrix - DynamicNode laneDynamicNode = dynamicMatrix[laneCodeMatrixIdx[0]][laneCodeMatrixIdx[1]]; + for (int[] codeMatrixIdx : laneCodeIdxList) { + DynamicNode laneDynamicNode = dynamicMatrix[codeMatrixIdx[0]][codeMatrixIdx[1]]; String laneVehicle = laneDynamicNode.getVehicle(); assert !laneVehicle.equals(DynamicNodeType.BLOCK.val); if (!laneVehicle.equals(DynamicNodeType.ACCESS.val)) { if (!laneVehicle.equals(agvNo)) { lanVehicleSet.add(laneVehicle); -// redis.setObject(RedisConstant.AGV_TO_STANDBY_FLAG, laneVehicle, true, 30); } } } - if (lanVehicleSet.size() + 1 > maxAgvCountInLane) { continue; } } - //鎵惧埌鐩爣缁撶偣灏辫繑鍥� if (isEndNode) { -- Gitblit v1.9.1