| | |
| | | |
| | | private String[][] cdaMatrix; |
| | | |
| | | public Map<String, Boolean> routeCdaMap = new HashMap<>(); |
| | | |
| | | private final CodeService codeService; |
| | | |
| | | private final RouteService routeService; |
| | |
| | | return mapMatrix; |
| | | } |
| | | |
| | | public boolean validRouteCdaKey(String routeCdaKey) { |
| | | if (Cools.isEmpty(routeCdaKey)) { |
| | | return false; |
| | | } |
| | | Boolean result = this.routeCdaMap.get(routeCdaKey); |
| | | if (null == result) { |
| | | return false; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public synchronized void initRouteMap(Integer lev) { |
| | | log.info("There is initializing Route Map......"); |
| | | lev = Optional.ofNullable(lev).orElse(MAP_DEFAULT_LEV); |
| | | Set<String> routeKeys = redis.getMapKeys(RedisConstant.AGV_MAP_ROUTE_HASH_FLAG); |
| | | Set<String> routeCdaKeys = redis.getMapKeys(RedisConstant.AGV_MAP_ROUTE_CDA_HASH_FLAG); |
| | | |
| | | List<Route> routeList = routeService.list(new LambdaQueryWrapper<Route>().eq(Route::getStatus, StatusType.ENABLE.val)); |
| | | if (routeKeys.size() == routeList.size()) { |
| | | if (routeKeys.size() == routeList.size() && routeKeys.size() == routeCdaKeys.size()) { |
| | | for (String routeCdaKey : routeCdaKeys) { |
| | | this.routeCdaMap.put(routeCdaKey, Boolean.TRUE); |
| | | } |
| | | return; |
| | | } |
| | | for (Route route : routeList) { |
| | | Code startCode = codeService.getById(route.getStartCode()); |
| | | int[] startCodeIdx = getCodeMatrixIdx(lev, startCode.getData()); |
| | | Code endCode = codeService.getById(route.getEndCode()); |
| | | int[] codeMatrixIdx = getCodeMatrixIdx(lev, endCode.getData()); |
| | | |
| | | String routeKey = RouteGenerator.generateRouteKey(startCode.getData(), endCode.getData()); |
| | | if (Cools.isEmpty(routeKey)) { |
| | | continue; |
| | | } |
| | | redis.setMap(RedisConstant.AGV_MAP_ROUTE_HASH_FLAG, routeKey, Boolean.TRUE); |
| | | |
| | | String routeCdaKey = RouteGenerator.generateRouteCdaKey(startCodeIdx, codeMatrixIdx); |
| | | if (Cools.isEmpty(routeCdaKey)) { |
| | | continue; |
| | | } |
| | | redis.setMap(RedisConstant.AGV_MAP_ROUTE_CDA_HASH_FLAG, routeCdaKey, Boolean.TRUE); |
| | | this.routeCdaMap.put(routeCdaKey, Boolean.TRUE); |
| | | } |
| | | } |
| | | |