#
vincentlu
2025-01-13 89c7f6e5bcc21b0e8f83a2bc6d680e2ffe431e6f
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;
@@ -63,6 +69,19 @@
        }
        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() {
@@ -83,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));
    }
@@ -103,7 +124,6 @@
        this.generateLaneHash();
        this.initialized = Boolean.TRUE;
        log.info("the lane data initialization has been completed in rcs system.");
    }
@@ -207,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);
@@ -326,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);
            }
        }
    }
}