From c3db115095084be321594058fb545578c4d4f32b Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 25 十二月 2024 15:04:52 +0800
Subject: [PATCH] #

---
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java |   55 ++++++++++++++++++++++---------------------------------
 1 files changed, 22 insertions(+), 33 deletions(-)

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 c7c9dd0..a6cc742 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
@@ -17,6 +17,7 @@
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.time.StopWatch;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import java.util.*;
@@ -29,6 +30,8 @@
 @Component("mapService")
 public class MapService {
 
+    @Value("${floyd.enable}")
+    private Boolean floydEnable;
     @Autowired
     private CodeService codeService;
     @Autowired
@@ -54,7 +57,9 @@
         NavigateNode startNode = new NavigateNode(startMapIdx[0], startMapIdx[1], startCode.getData());
         NavigateNode endNode = new NavigateNode(endMapIdx[0], endMapIdx[1], endCode.getData());
 
+        long startTime = System.currentTimeMillis();
         NavigateNode finishNode = aStarNavigateService.execute(agvNo, startNode, endNode, lock, blackList, segment);
+//        System.out.println("AStart spend time: " + (System.currentTimeMillis() - startTime));
 
         if (null == finishNode) {
             log.warn("{} 鍙稟GV妫�绱{}] ===>> [{}]璺緞澶辫触......", agvNo, startCode.getData(), endCode.getData());
@@ -92,6 +97,9 @@
      * 瀵诲潃 ===>> Floyd
      */
     public synchronized List<String> validFeasibility(Code startCode, Code endCode) {
+        if (!floydEnable) {
+            return Arrays.asList("00000001", "00000002", "00000003", "00000004", "00000005", "00000006");
+        }
 
         int startIdx = floydNavigateService.codeIdx(startCode.getId());
         int endIdx = floydNavigateService.codeIdx(endCode.getId());
@@ -198,14 +206,20 @@
 
 
             Integer serial = dynamicNode.getSerial();
+            long time = dynamicNode.getTime();
 
             List<String> resetCodeList = new ArrayList<>();
 
             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; }
+
                     DynamicNode node = dynamicMatrix[i][j];
-                    if (node.getVehicle().equals(agvNo) && node.getSerial() < serial) {
-                        resetCodeList.add(codeMatrix[i][j]);
+                    if (node.getVehicle().equals(agvNo)) {
+                        if (node.getSerial() < serial || node.getTime() != time) {
+                            resetCodeList.add(codeMatrix[i][j]);
+                        }
                     }
                 }
             }
@@ -221,7 +235,7 @@
             }
 
         } catch (Exception e) {
-            log.error("TrafficService.unlockPath", e);
+            log.error("MapService.unlockPath", e);
         }
 
     }
@@ -253,7 +267,7 @@
         NavigateNode originNode = new NavigateNode(codeMatrixIdx[0], codeMatrixIdx[1], code);
 
         List<NavigateNode> includeList = new ArrayList<>();
-        List<NavigateNode> existNodes = new ArrayList<>();
+        Set<NavigateNode> existNodes = new HashSet<>();
 
         includeList.add(originNode);
         existNodes.add(originNode);
@@ -265,7 +279,7 @@
 
     public void spreadWaveNode(NavigateNode originNode, NavigateNode currNode
             , String[][] codeMatrix, String[][] cdaMatrix, Double radiusLen
-            , List<NavigateNode> includeList, List<NavigateNode> existNodes) {
+            , List<NavigateNode> includeList, Set<NavigateNode> existNodes) {
         int x = currNode.getX();
         int y = currNode.getY();
 
@@ -277,7 +291,7 @@
 
     public void extendNeighborNodes(NavigateNode originNode, NavigateNode nextNode
             , String[][] codeMatrix, String[][] cdaMatrix, Double radiusLen
-            , List<NavigateNode> includeList, List<NavigateNode> existNodes) {
+            , List<NavigateNode> includeList, Set<NavigateNode> existNodes) {
 
         int x = nextNode.getX();
         int y = nextNode.getY();
@@ -287,7 +301,7 @@
             return;
         }
 
-        if (this.isExist(nextNode, existNodes)) {
+        if (existNodes.contains(nextNode)) {
             return;
         }
 
@@ -313,22 +327,6 @@
 
             }
         }
-    }
-
-    private boolean isExist(NavigateNode node, List<NavigateNode> existNodes) {
-        for (NavigateNode existNode : existNodes) {
-            if (this.isSame(node, existNode)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private boolean isSame(NavigateNode o1, NavigateNode o2) {
-        if (Cools.isEmpty(o1, o2)) {
-            return false;
-        }
-        return o1.getX() == o2.getX() && o1.getY() == o2.getY();
     }
 
     // v2 BFS ------------------------------------------------------------------------------
@@ -380,7 +378,7 @@
         }
 
         // If the node has already been visited, skip it
-        if (this.isExist0(nextNode, visited)) {
+        if (visited.contains(nextNode)) {
             return;
         }
 
@@ -408,15 +406,6 @@
                 queue.offer(nextNode);
             }
         }
-    }
-
-    private boolean isExist0(NavigateNode node, Set<NavigateNode> existNodes) {
-        for (NavigateNode existNode : existNodes) {
-            if (this.isSame(node, existNode)) {
-                return true;
-            }
-        }
-        return false;
     }
 
 

--
Gitblit v1.9.1