#
luxiaotao1123
2025-01-06 b9eef68cc85d30b892a1cd50829341d3dae743b9
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/RetreatNavigateService.java
@@ -23,6 +23,7 @@
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
/**
@@ -95,7 +96,7 @@
            List<RetreatNavigateNode> enableNodes = new ArrayList<>();
            ArrayList<RetreatNavigateNode> neighborNodes = this.getNeighborNodes(currentNode, existNodes, codeMatrix);
            List<RetreatNavigateNode> neighborNodes = this.getNeighborNodes(currentNode, existNodes, codeMatrix);
            boolean pointOfTurn = neighborNodes.size() >= 2;
            label: for (RetreatNavigateNode node : neighborNodes) {
                if (node.getCodeData().equals(breakPoint)) { continue; }
@@ -123,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;
@@ -154,6 +152,7 @@
                            weight += WEIGHT_CALC_FACTOR * 2;
                        }
                    }
                }
                Code code = codeService.selectByData(node.getCodeData());
@@ -212,7 +211,7 @@
                RetreatNavigateNode currentNode = openQueue.poll();
                List<RetreatNavigateNode> enableNodes = new ArrayList<>();
                ArrayList<RetreatNavigateNode> neighborNodes = this.getNeighborNodes(currentNode, existNodes, codeMatrix);
                List<RetreatNavigateNode> neighborNodes = this.getNeighborNodes(currentNode, existNodes, codeMatrix);
                // 第一步:获取有效转弯点
                if (null == availablePointOfTurn) {
@@ -223,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;
                                }
@@ -319,12 +314,12 @@
    }
    // 获取四周节点
    private ArrayList<RetreatNavigateNode> getNeighborNodes(RetreatNavigateNode currentNode, Set<RetreatNavigateNode> existNodes, String[][] codeMatrix) {
    private List<RetreatNavigateNode> getNeighborNodes(RetreatNavigateNode currentNode, Set<RetreatNavigateNode> existNodes, String[][] codeMatrix) {
        int x = currentNode.getX();
        int y = currentNode.getY();
        ArrayList<RetreatNavigateNode> neighbourNodes = new ArrayList<>();
        List<RetreatNavigateNode> neighbourNodes = new CopyOnWriteArrayList<>();
        List<RetreatNavigateNode> possibleNodes = Arrays.asList(
                new RetreatNavigateNode(x, y + 1), // right