#
vincentlu
2025-03-27 cd67e854d4715bc92a16dc7bffdbde7be1da9957
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/LaneService.java
@@ -37,6 +37,10 @@
    private final Map<String, List<String>> adjacencyCodeMap = new HashMap<>();
    private final Map<String, List<int[]>> laneCodeIdxMap = new HashMap<>();
    private final Map<String, Lane> codeLaneMap = new HashMap<>();
    private boolean initialized = Boolean.FALSE;
    @Autowired
@@ -47,6 +51,10 @@
    private SnowflakeIdWorker snowflakeIdWorker;
    @Autowired
    private ConfigService configService;
    @Autowired
    private MapDataDispatcher mapDataDispatcher;
    // service -------------------------------------------------------
    public Boolean isInitialized() {
        return this.initialized;
@@ -56,13 +64,28 @@
        if (Cools.isEmpty(codeData) || !this.initialized) {
            return null;
        }
        for (Lane lane : this.lanes) {
            if (lane.getCodes().contains(codeData)) {
                return lane;
            }
        }
        return null;
//        if (result == null) {
//            for (Lane lane : this.lanes) {
//                if (lane.getCodes().contains(codeData)) {
//                    return lane;
//                }
//            }
//        }
        return this.codeLaneMap.get(codeData);
    }
    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() {
@@ -83,6 +106,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));
    }
@@ -103,7 +128,6 @@
        this.generateLaneHash();
        this.initialized = Boolean.TRUE;
        log.info("the lane data initialization has been completed in rcs system.");
    }
@@ -111,7 +135,7 @@
        for (Code code : codeList) {
            List<Long> adjacencyNode = routeService.getAdjacencyNode(code.getId());
            this.adjacencyCodeMap.put(code.getData(), adjacencyNode.stream().map(node -> (
                    codeService.getById(node).getData()
                    codeService.getCacheById(node).getData()
            )).collect(Collectors.toList()));
        }
    }
@@ -207,9 +231,9 @@
            return true;
        }
        Code parentCode = codeService.selectByData(parent);
        Code currentCode = codeService.selectByData(current);
        Code neighborCode = codeService.selectByData(neighbor);
        Code parentCode = codeService.getCacheByData(parent);
        Code currentCode = codeService.getCacheByData(current);
        Code neighborCode = codeService.getCacheByData(neighbor);
        double direction1 = this.calculateDirection(parentCode, currentCode);
        double direction2 = this.calculateDirection(currentCode, neighborCode);
@@ -326,4 +350,19 @@
        return sb.toString();
    }
    public void generateLaneCodeIdx(Integer lev) {
        log.info("There is initializing Lane CodeIdxMap......");
        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);
                this.codeLaneMap.put(code, lane);
            }
        }
    }
}