#
luxiaotao1123
2024-12-30 3209b7899f99fbc567c24be9709ba289f33ea73b
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/MapDataDispatcher.java
@@ -18,7 +18,9 @@
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
@@ -197,7 +199,6 @@
    }
    public String[][] initWaveMatrix(Integer lev) {
        log.info("There is initializing Wave Matrix......");
        lev = Optional.ofNullable(lev).orElse(MAP_DEFAULT_LEV);
        String[][] codeMatrix = getCodeMatrix(lev);
@@ -459,19 +460,37 @@
        }
        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) {
@@ -486,11 +505,11 @@
            if (Cools.isEmpty(codeList, vehicle)) {
                return;
            }
            long time = System.currentTimeMillis() / 1000;
//            long time = System.currentTimeMillis() / 1000;
            int serial = 1;
            for (String code : codeList) {
                int[] node = getCodeMatrixIdx(lev, code);
                dynamicMatrix[node[0]][node[1]] = new DynamicNode(vehicle, serial, time);
                dynamicMatrix[node[0]][node[1]] = new DynamicNode(vehicle, serial);
                serial++;
            }
        } else {