#
luxiaotao1123
2024-12-23 766bcd63a19f7acaff2f5ed2cd1cb016894978ea
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("{} 号AGV检索[{}] ===>> [{}]路径失败......", 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);
        }
    }