| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.acs.common.constant.RedisConstant; |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.acs.manager.core.domain.SortCodeDto; |
| | | import com.zy.acs.manager.core.service.astart.domain.DynamicNode; |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | | import com.zy.acs.manager.manager.service.CodeService; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by vincent on 6/6/2024 |
| | |
| | | |
| | | private final RedisSupport redis = RedisSupport.defaultRedisSupport; |
| | | |
| | | public static final Boolean CACHE_CODE_MATRIX = Boolean.FALSE; |
| | | public static final Boolean CACHE_CODE_MATRIX = Boolean.TRUE; |
| | | |
| | | private String[][] codeMatrix; |
| | | |
| | |
| | | |
| | | private int[][] mapMatrix; |
| | | |
| | | public static final Boolean CACHE_TURN_MATRIX = Boolean.FALSE; |
| | | public static final Boolean CACHE_TURN_MATRIX = Boolean.TRUE; |
| | | |
| | | private int[][] turnMatrix; |
| | | |
| | | public static final Boolean CACHE_CDA_MATRIX = Boolean.FALSE; |
| | | public static final Boolean CACHE_CDA_MATRIX = Boolean.TRUE; |
| | | |
| | | private String[][] cdaMatrix; |
| | | |
| | |
| | | } |
| | | |
| | | public String[][] initWaveMatrix(Integer lev) { |
| | | log.info("There is initializing Wave Matrix......"); |
| | | lev = Optional.ofNullable(lev).orElse(MAP_DEFAULT_LEV); |
| | | |
| | | String[][] codeMatrix = getCodeMatrix(lev); |
| | |
| | | } |
| | | |
| | | public synchronized DynamicNode[][] initDynamicMatrix(Integer lev) { |
| | | log.info("There is initializing Dynamic Matrix......"); |
| | | lev = Optional.ofNullable(lev).orElse(MAP_DEFAULT_LEV); |
| | | |
| | | String[][] codeMatrix = getCodeMatrix(lev); |
| | |
| | | } |
| | | |
| | | public synchronized String[][] initCdaMatrix(Integer lev) { |
| | | log.info("There is initializing Cda Matrix......"); |
| | | lev = Optional.ofNullable(lev).orElse(MAP_DEFAULT_LEV); |
| | | |
| | | String[][] codeMatrix = getCodeMatrix(lev); |
| | |
| | | } |
| | | |
| | | public synchronized int[][] initTurnMatrix(Integer lev) { |
| | | log.info("There is initializing Turn Matrix......"); |
| | | lev = Optional.ofNullable(lev).orElse(MAP_DEFAULT_LEV); |
| | | |
| | | String[][] codeMatrix = getCodeMatrix(lev); |
| | |
| | | |
| | | |
| | | public synchronized int[][] initMapMatrix(Integer lev) { |
| | | log.info("There is initializing Map Matrix......"); |
| | | lev = Optional.ofNullable(lev).orElse(MAP_DEFAULT_LEV); |
| | | |
| | | String[][] codeMatrix = getCodeMatrix(lev); |
| | |
| | | } |
| | | |
| | | public synchronized String[][] initCodeMatrix(Integer lev) { |
| | | log.info("【ASTAR】正在计算矩阵数据......"); |
| | | log.info("There is initializing Code Matrix......"); |
| | | lev = Optional.ofNullable(lev).orElse(MAP_DEFAULT_LEV); |
| | | List<Code> codeList = codeService.list(new LambdaQueryWrapper<Code>() |
| | | .eq(Code::getStatus, 1) |
| | |
| | | for (Code code : codeList) { |
| | | Double x = code.getX(); |
| | | Double y = code.getY(); |
| | | if (null == x || null == y) { continue; } |
| | | if (!xIdxList.contains(x)) { |
| | | xIdxList.add(x); |
| | | } |
| | |
| | | } |
| | | |
| | | public List<String> queryCodeListFromDynamicNode(Integer lev, String nodeType) { |
| | | List<String> nodes = new ArrayList<>(); |
| | | if (Cools.isEmpty(nodeType)) { |
| | | return nodes; |
| | | return new ArrayList<>(); |
| | | } |
| | | 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++) { |
| | | for (int j = 0; j < codeMatrix[i].length; j++) { |
| | | if (nodeType.equals(dynamicMatrix[i][j].getVehicle())) { |
| | | nodes.add(codeMatrix[i][j]); |
| | | DynamicNode dynamicNode = dynamicMatrix[i][j]; |
| | | if (nodeType.equals(dynamicNode.getVehicle())) { |
| | | codeList.add(new SortCodeDto(codeMatrix[i][j], dynamicNode.getSerial())); |
| | | } |
| | | } |
| | | } |
| | | return nodes; |
| | | 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) { |