| | |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | public Map<String, List<String>> queryCodeListFromDynamicNode(Integer lev, Set<String> vehicles) { |
| | | if (Cools.isEmpty(vehicles)) { |
| | | return new HashMap<>(); |
| | | } |
| | | lev = Optional.ofNullable(lev).orElse(MapDataDispatcher.MAP_DEFAULT_LEV); |
| | | |
| | | DynamicNode[][] dynamicMatrix = mapDataDispatcher.getDynamicMatrix(lev); |
| | | String[][] codeMatrix = mapDataDispatcher.getCodeMatrix(lev); |
| | | |
| | | Map<String, List<SortCodeDto>> map = new HashMap<>(vehicles.size()); |
| | | |
| | | for (int i = 0; i < codeMatrix.length; i++) { |
| | | for (int j = 0; j < codeMatrix[i].length; j++) { |
| | | DynamicNode dynamicNode = dynamicMatrix[i][j]; |
| | | String vehicle = dynamicNode.getVehicle(); |
| | | |
| | | if (vehicles.contains(vehicle)) { |
| | | int serial = dynamicNode.getSerial(); |
| | | map.computeIfAbsent(vehicle, k -> new ArrayList<>()).add(new SortCodeDto(codeMatrix[i][j], serial)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Map<String, List<String>> result = new HashMap<>(vehicles.size()); |
| | | for (Map.Entry<String, List<SortCodeDto>> entry : map.entrySet()) { |
| | | List<String> codeDataList = entry.getValue().stream() |
| | | .sorted(Comparator.comparingInt(SortCodeDto::getSerial)) |
| | | .map(SortCodeDto::getCode) |
| | | .collect(Collectors.toList()); |
| | | result.put(entry.getKey(), codeDataList); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | } |