From 9c7a29e38f53ef2a854508c915306e031cefbabb Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 06 十一月 2024 15:57:01 +0800
Subject: [PATCH] #

---
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/RetreatNavigateService.java |   49 +++++++++++++++++++++++++++++++------------------
 1 files changed, 31 insertions(+), 18 deletions(-)

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 fbb7b26..6d89a53 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
@@ -79,6 +79,7 @@
 
         openQueue.add(start);
         existNodes.add(start);
+        boolean phaseSecond = true;
 
         while (openQueue.size() > 0 && null == finialNode) {
 
@@ -87,6 +88,7 @@
             List<RetreatNavigateNode> enableNodes = new ArrayList<>();
 
             ArrayList<RetreatNavigateNode> neighborNodes = this.getNeighborNodes(currentNode, existNodes);
+            boolean pointOfTurn = neighborNodes.size() >= 2;
             label: for (RetreatNavigateNode node : neighborNodes) {
                 if (node.getCodeData().equals(breakPoint)) { continue; }
 
@@ -103,6 +105,7 @@
                             continue label;
                         }
                         if (1 < mapDataDispatcher.queryCodeListFromDynamicNode(lev, otherWave).size()) {
+                            phaseSecond = false;    // there is a way to go
                             continue label;
                         } else {
                             weight += WEIGHT_CALC_FACTOR;
@@ -111,27 +114,37 @@
                 }
 
                 // lane
-                Lane lane = laneService.search(node.getCodeData());
-                if (null != lane) {
-                    Set<String> lanVehicleSet = new HashSet<>();
+                if (pointOfTurn) {
+                    Lane lane = laneService.search(node.getCodeData());
+                    if (null != lane) {
+                        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]];
-                        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);
+                        for (String laneCodeData : lane.getCodes()) {
+                            // overlap with sponsor
+                            if (avoidPathList.contains(laneCodeData)) {
+                                lanVehicleSet.add(sponsor);
+                            }
+
+                            int[] laneCodeMatrixIdx = mapDataDispatcher.getCodeMatrixIdx(null, laneCodeData);
+                            // scan dynamicMatrix or WaveMatrix
+                            DynamicNode laneDynamicNode = dynamicMatrix[laneCodeMatrixIdx[0]][laneCodeMatrixIdx[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 (lanVehicleSet.size() + 1 > maxAgvCountInLane) {
+                            phaseSecond = false;    // there is a way to go
+                            continue;
+                        }
+                        if (lanVehicleSet.contains(sponsor)) {
+                            weight += WEIGHT_CALC_FACTOR * 2;
+                        }
                     }
                 }
 
@@ -159,7 +172,7 @@
         }
 
 
-        if (null == finialNode) {
+        if (null == finialNode && phaseSecond) {
 //            assert openQueue.size() == 0;
 
             existNodes.clear();

--
Gitblit v1.9.1