#
luxiaotao1123
2025-01-08 aa6f20d98b5d8e18ae56f9562a78d403a5417b48
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/LaneService.java
@@ -37,6 +37,8 @@
    private final Map<String, List<String>> adjacencyCodeMap = new HashMap<>();
    private final Map<String, List<int[]>> laneCodeIdxMap = new HashMap<>();
    private boolean initialized = Boolean.FALSE;
    @Autowired
@@ -47,6 +49,10 @@
    private SnowflakeIdWorker snowflakeIdWorker;
    @Autowired
    private ConfigService configService;
    @Autowired
    private MapDataDispatcher mapDataDispatcher;
    // service -------------------------------------------------------
    public Boolean isInitialized() {
        return this.initialized;
@@ -64,13 +70,25 @@
        return null;
    }
    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() {
        Integer lev = MapDataDispatcher.MAP_DEFAULT_LEV;
        String laneDataStr = redis.getValue(RedisConstant.MAP_LANE_DATA, String.valueOf(lev));
        if (!Cools.isEmpty(laneDataStr)) {
            this.lanes = GsonUtils.fromJsonToList(laneDataStr, Lane.class);
            this.initialized = Boolean.TRUE;
        } else {
            StopWatch stopWatch = new StopWatch();
@@ -84,6 +102,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));
    }
@@ -104,7 +124,6 @@
        this.generateLaneHash();
        this.initialized = Boolean.TRUE;
        log.info("the lane data initialization has been completed in rcs system.");
    }
@@ -208,9 +227,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);
@@ -327,4 +346,19 @@
        return sb.toString();
    }
    public void generateLaneCodeIdx(Integer lev) {
        log.info("There is initializing Lane CodeIdxMap......");
        long l = System.currentTimeMillis();
        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);
            }
        }
    }
}