| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentLinkedQueue; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.IntStream; |
| | | |
| | | /** |
| | | * Created by vincent on 6/6/2024 |
| | |
| | | } |
| | | lev = Optional.ofNullable(lev).orElse(MAP_DEFAULT_LEV); |
| | | |
| | | List<SortCodeDto> codeList = new ArrayList<>(); |
| | | DynamicNode[][] dynamicMatrix = getDynamicMatrix(lev); |
| | | String[][] codeMatrix = this.getCodeMatrix(lev); |
| | | for (int i = 0; i < codeMatrix.length; i++) { |
| | | |
| | | ConcurrentLinkedQueue<SortCodeDto> codeList = new ConcurrentLinkedQueue<>(); |
| | | |
| | | IntStream.range(0, codeMatrix.length).parallel().forEach(i -> { |
| | | for (int j = 0; j < codeMatrix[i].length; j++) { |
| | | DynamicNode dynamicNode = dynamicMatrix[i][j]; |
| | | if (nodeType.equals(dynamicNode.getVehicle())) { |
| | | codeList.add(new SortCodeDto(codeMatrix[i][j], dynamicNode.getSerial())); |
| | | } |
| | | } |
| | | } |
| | | codeList.sort(Comparator.comparingInt(SortCodeDto::getSerial)); |
| | | return codeList.stream().map(SortCodeDto::getCode).collect(Collectors.toList()); |
| | | }); |
| | | |
| | | return codeList.stream() |
| | | .sorted(Comparator.comparingInt(SortCodeDto::getSerial)) |
| | | .map(SortCodeDto::getCode) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // List<SortCodeDto> codeList = new ArrayList<>(); |
| | | |
| | | // for (int i = 0; i < codeMatrix.length; i++) { |
| | | // for (int j = 0; j < codeMatrix[i].length; j++) { |
| | | // DynamicNode dynamicNode = dynamicMatrix[i][j]; |
| | | // if (nodeType.equals(dynamicNode.getVehicle())) { |
| | | // codeList.add(new SortCodeDto(codeMatrix[i][j], dynamicNode.getSerial())); |
| | | // } |
| | | // } |
| | | // } |
| | | // codeList.sort(Comparator.comparingInt(SortCodeDto::getSerial)); |
| | | // return codeList.stream().map(SortCodeDto::getCode).collect(Collectors.toList()); |
| | | } |
| | | |
| | | public void modifyDynamicMatrix(Integer lev, List<String> codeList, String vehicle) { |