为了加快仿真创建,去掉遍历所有功能轨构建进路路径的逻辑

This commit is contained in:
joylink_zhangsai 2022-06-30 16:31:21 +08:00
parent c369b355fd
commit 280cafcf13
3 changed files with 34 additions and 36 deletions

View File

@ -1125,41 +1125,43 @@ public class InterlockBuilder2 {
private static void buildRoutePathFromStationRunLevel(MapCiGenerateConfig generateConfig, List<StationRunLevel> stationRunLevelList,
SimulationBuilder.SimulationDeviceBuildResult buildResult,
List<String> errMsgList) {
// long s = System.currentTimeMillis();
// Map<String, List<RoutePath>> routePathMap = buildResult.getRoutePathMap();
// Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
// if (generateConfig != null && generateConfig.isRailway()) {
// List<Section> sections = deviceMap.values().stream()
// .filter(device -> device instanceof Section)
// .map(device -> (Section) device)
// .filter(Section::isFunctionTrack)
// .collect(Collectors.toList());
// for (int i = 0; i < sections.size(); i++) {
// Section start = sections.get(i);
// for (int j = 0; j < sections.size() && i != j; j++) {
// Section end = sections.get(j);
// List<RoutePath> routePaths = CalculateService.queryRoutePathsOnDirection(start, end, true, 100);
// if (!CollectionUtils.isEmpty(routePaths)) {
// routePathMap.put(routePaths.get(0).getKey(), routePaths);
// }
// }
// }
// }
// System.out.println("无脑构建进路路径耗时:" + (System.currentTimeMillis() - s));
Map<String, List<RoutePath>> routePathMap = buildResult.getRoutePathMap();
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
if (generateConfig != null && generateConfig.isRailway()) {
List<Section> sections = deviceMap.values().stream()
.filter(device -> device instanceof Section)
.map(device -> (Section) device)
.filter(Section::isFunctionTrack)
.collect(Collectors.toList());
for (int i = 0; i < sections.size(); i++) {
Section start = sections.get(i);
for (int j = 0; j < sections.size() && i != j; j++) {
Section end = sections.get(j);
List<RoutePath> routePaths = CalculateService.queryRoutePathsOnDirection(start, end, true, 100);
if (!CollectionUtils.isEmpty(routePaths)) {
routePathMap.put(routePaths.get(0).getKey(), routePaths);
}
if (!CollectionUtils.isEmpty(stationRunLevelList)) {
for (StationRunLevel runLevel : stationRunLevelList) {
Section startSection = runLevel.getStartSection();
Section endSection = runLevel.getEndSection();
boolean right = runLevel.isRight();
List<RoutePath> routePaths = CalculateService.queryRoutePathsOnDirection(startSection, endSection, right, 10);
if (CollectionUtils.isEmpty(routePaths)) {
errMsgList.add(String.format("站间运行等级[%s]无法找到路径",
runLevel.debugStr(), startSection.debugStr(), endSection.debugStr()));
} else {
routePathMap.put(routePaths.get(0).getKey(), routePaths);
}
}
}
if (CollectionUtils.isEmpty(stationRunLevelList)) {
return;
}
for (StationRunLevel runLevel : stationRunLevelList) {
Section startSection = runLevel.getStartSection();
Section endSection = runLevel.getEndSection();
boolean right = runLevel.isRight();
List<RoutePath> routePaths = CalculateService.queryRoutePathsOnDirection(startSection, endSection, right, 10);
if (CollectionUtils.isEmpty(routePaths)) {
errMsgList.add(String.format("站间运行等级[%s]无法找到路径",
runLevel.debugStr(), startSection.debugStr(), endSection.debugStr()));
} else {
routePathMap.put(routePaths.get(0).getKey(), routePaths);
}
}
long l = System.currentTimeMillis();
/* 根据交路数据,构建缺失的进路路径 */
for (Routing routing : buildResult.getRoutingList()) {
List<Section> allSections = routing.getAllSections().stream().distinct().collect(Collectors.toList());

View File

@ -100,13 +100,9 @@ public class SimulationBuilder {
loadDepotInOutRoutePath(simulation);
// CTC行车日志数据结构构建
if (simulation.getRepository().getConfig().isHasCTC()) {
LocalDateTime now = LocalDateTime.now();
System.out.println("CTC行车日志耗时" + Duration.between(now, LocalDateTime.now()).getSeconds());
buildCtcRailwayInfo(simulation);
buildCtcStationRunPlanLog(simulation);
now = LocalDateTime.now();
generateRouteSequence(simulation);
System.out.println("CTC进路序列耗时" + Duration.between(now, LocalDateTime.now()).getSeconds());
}
return simulation;
}

View File

@ -650,7 +650,7 @@ public class CalculateService {
for (RoutePath path : list) {
path.calculateDistance();
path.calculateSwitchCount();
log.debug(path.debugStr2());
// log.debug(path.debugStr2());
}
} else {
log.debug(String.format("进路路径[%s]未找到:[%s]",