添加<生成目的地码>连锁配置及生成逻辑

This commit is contained in:
joylink_zhangsai 2021-03-08 14:45:35 +08:00
parent 15ec7c7b3b
commit 38e5af449b
4 changed files with 141 additions and 57 deletions

View File

@ -1534,6 +1534,7 @@ public class DraftMapService implements IDraftMapService {
case NON_OPERATION: case NON_OPERATION:
case LAST_NON_OPERATION: case LAST_NON_OPERATION:
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(definitionVO.getSectionCode(), "目标区段必须选择"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(definitionVO.getSectionCode(), "目标区段必须选择");
break;
case OTHER: case OTHER:
break; break;
} }

View File

@ -182,6 +182,12 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
.filter(mapElement -> MapElement.DeviceType.SECTION.equals(mapElement.getDeviceType())) .filter(mapElement -> MapElement.DeviceType.SECTION.equals(mapElement.getDeviceType()))
.map(mapElement -> (Section) mapElement) .map(mapElement -> (Section) mapElement)
.collect(Collectors.toList()); .collect(Collectors.toList());
// 所有车站
List<Station> stationList = deviceMap.values().stream()
.filter(mapElement -> MapElement.DeviceType.STATION.equals(mapElement.getDeviceType()))
.map(mapElement -> (Station) mapElement)
.sorted(Comparator.comparingInt(Station::getSn))
.collect(Collectors.toList());
Map<String, List<RouteOverlap>> overlapMap = new HashMap<>(); Map<String, List<RouteOverlap>> overlapMap = new HashMap<>();
List<Signal> approachList = new ArrayList<>(); List<Signal> approachList = new ArrayList<>();
@ -296,58 +302,6 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
// // 生成交路数据 // // 生成交路数据
// List<MapRoutingDataVO> generateRoutingList = this.generateRoutings(deviceMap, generatedRouteList, autoSignalList, errorList); // List<MapRoutingDataVO> generateRoutingList = this.generateRoutings(deviceMap, generatedRouteList, autoSignalList, errorList);
// // 获取所有转换轨或者折返轨
// List<Section> sectionList = deviceMap.values().stream()
// .filter(mapElement -> mapElement.getDeviceType().equals(MapElement.DeviceType.SECTION))
// .map(mapElement -> ((Section) mapElement)).filter(section -> section.isTurnBackTrack() || section.isTransferTrack())
// .collect(Collectors.toList());
// CodeGenerator routingCodeGenerator = new CodeGenerator("Routing");
// //交路生成
// List<MapRoutingDataVO> generatedRoutingList = new ArrayList<>();
// int size = sectionList.size();
// log.info(String.format("共有折返轨和转换轨[%s]个", size));
// for (int i = 0; i < size - 1; i++) {
// Section startSection = sectionList.get(i);
// for (int j = i + 1; j < size; j++) {
// Section endSection = sectionList.get(j);
// //站台轨之间反向暂不生成
// if(startSection.isNormalStandTrack() && endSection.isNormalStandTrack()){
// boolean noNeed = startSection.getStandList().stream()
// .filter(stand -> !stand.isSmall())
// .anyMatch(stand -> {
// for (Stand stand1 : endSection.getStandList()) {
// if (!stand1.isSmall() && !Objects.equals(stand1.isRight(), stand.isRight())) {
// return true;
// }
// }
// return false;
// });
// if(noNeed) continue;
// }
// // 同一车站间不生成
// if (Objects.equals(startSection.getStation(), endSection.getStation())) {
// continue;
// }
// //生成交路
// MapRoutingDataVO routingData = generateRouting(errorList,
// routingCodeGenerator, startSection, endSection);
// if (Objects.nonNull(routingData)) {
// generatedRoutingList.add(routingData);
// }
// //生成上面交路的回路
// MapRoutingDataVO routingDataLoop = generateRouting(errorList, routingCodeGenerator, endSection, startSection);
// if (Objects.nonNull(routingDataLoop)) {
// if(Objects.nonNull(routingData)){
// routingDataLoop.setCode(routingData.getCode() + "-LOOP");
// routingDataLoop.setName(routingData.getName() + "-LOOP");
// }
// generatedRoutingList.add(routingDataLoop);
// }
//
// }
// }
//站间运行等级生成 //站间运行等级生成
List<MapStationRunLevelVO> generatedStationRunLevelList = new ArrayList<>(); List<MapStationRunLevelVO> generatedStationRunLevelList = new ArrayList<>();
// generateRunLevel(deviceMap, errorList, generateRoutingList, generatedStationRunLevelList); // generateRunLevel(deviceMap, errorList, generateRoutingList, generatedStationRunLevelList);
@ -355,21 +309,132 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
//目的地码生成 //目的地码生成
List<DestinationCodeDefinition> destinationCodeDefinitionList = new ArrayList<>(); List<DestinationCodeDefinition> destinationCodeDefinitionList = new ArrayList<>();
if (!CollectionUtils.isEmpty(sectionList)) { if (config.isGenerateDestination()) {
for (Section section : sectionList) { String code = null;
String destinationCode = section.getDestinationCode(); DestinationCodeDefinition.Type type = null;
if (!StringUtils.hasText(destinationCode)) { String description = null;
Section startSection = null;
Section section = null;
Boolean right = null;
List<Section> necessarySections = null;
Station leftStation = null;
Boolean leftFrontTurnBack = null;
Station rightStation = null;
Boolean rightFrontTurnBack = null;
int codeNum = 1;
for (int i = 0; i < stationList.size(); i++) {
leftStation = stationList.get(i);
if (CollectionUtils.isEmpty(leftStation.getTurnBackList())) //没有折返轨的略过
continue; continue;
if (i == stationList.size() - 1)
break;
List<Section> leftTbSections = queryAfterTurnBackList(leftStation, false);
leftTbSections.addAll(queryFrontTurnBackList(stationList, leftStation, false));
for (Section startTbSection : leftTbSections) {
for (int j = stationList.size() - 1; j >= 0; j--) {
rightStation = stationList.get(j);
if (leftStation.equals(rightStation)) {
break;
}
List<Section> rightTbSections = queryAfterTurnBackList(rightStation, true);
rightTbSections.addAll(queryFrontTurnBackList(stationList, rightStation, true));
for (Section endTbSection : rightTbSections) {
code = String.format("%03d", codeNum++);
type = DestinationCodeDefinition.Type.NORMAL_OPERATION;
description = String.format("%s-%s", leftStation.getName(), rightStation.getName());
necessarySections = List.of(startTbSection, endTbSection);
leftFrontTurnBack = startTbSection.isNormalStandTrack();
rightFrontTurnBack = endTbSection.isNormalStandTrack();
destinationCodeDefinitionList.add(
new DestinationCodeDefinition(code, type, description, startSection, section, right, necessarySections,
leftStation, leftFrontTurnBack, rightStation, rightFrontTurnBack, null, null)
);
}
}
}
}
} else {
if (!CollectionUtils.isEmpty(sectionList)) {
for (Section section : sectionList) {
String destinationCode = section.getDestinationCode();
if (!StringUtils.hasText(destinationCode)) {
continue;
}
destinationCodeDefinitionList.add(new DestinationCodeDefinition(destinationCode, DestinationCodeDefinition.Type.OTHER, section));
} }
destinationCodeDefinitionList.add(new DestinationCodeDefinition(destinationCode, DestinationCodeDefinition.Type.OTHER, section));
} }
} }
return new CiGenerateResult(errorList, approachList, return new CiGenerateResult(errorList, approachList,
autoSignalList, generatedRouteList, generatedOverlapList, flsList, autoSignalList, generatedRouteList, generatedOverlapList, flsList,
generateCycleList, generatedStationRunLevelList, destinationCodeDefinitionList); generateCycleList, generatedStationRunLevelList, destinationCodeDefinitionList);
} }
/**
* 筛选站后折返轨优先右行站台折返
* @param stations 所有车站
* @param right 是否是右端车站
*/
private List<Section> queryFrontTurnBackList(List<Station> stations, Station station, boolean right) {
List<Section> turnBackList = station.getTurnBackList();
if (CollectionUtils.isEmpty(turnBackList) || CollectionUtils.isEmpty(station.getAllNormalStands())) {
return new ArrayList<>();
}
int sn;
if (right) {
sn = station.getSn() - 1;
} else {
sn = station.getSn() + 1;
}
Station adjacentStation = stations.stream().filter(sta -> sta.getSn() == sn).limit(1).findAny().get();
if (CollectionUtils.isEmpty(adjacentStation.getAllNormalStands())) {
return new ArrayList<>();
}
Section leftStandTrack = station.getNormalStand(false).get(0).getSection();
Section rightStandTrack = station.getNormalStand(true).get(0).getSection();
Section adjacentLeftStandTrack = adjacentStation.getNormalStand(false).get(0).getSection();
Section adjacentRightStandTrack = adjacentStation.getNormalStand(true).get(0).getSection();
List<Section> tbSections = new ArrayList<>();
if (right) {
if (rightStandTrack.isTurnBackTrack()
&& !CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(rightStandTrack, adjacentLeftStandTrack, false))) {
tbSections.add(rightStandTrack);
}
if (leftStandTrack.isTurnBackTrack()
&& !CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(adjacentRightStandTrack, leftStandTrack, true))) {
tbSections.add(leftStandTrack);
}
} else {
if (rightStandTrack.isTurnBackTrack()
&& !CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(adjacentLeftStandTrack, rightStandTrack, false))) {
tbSections.add(rightStandTrack);
}
if (leftStandTrack.isTurnBackTrack()
&& !CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(leftStandTrack, adjacentRightStandTrack, true))) {
tbSections.add(leftStandTrack);
}
}
return tbSections;
}
/**
* 筛选站前折返轨
* @param right 是否是右端车站
*/
private List<Section> queryAfterTurnBackList(Station station, boolean right) {
List<Section> turnBackList = station.getTurnBackList();
if (CollectionUtils.isEmpty(turnBackList)) {
return new ArrayList<>();
}
Section standTrack = station.getNormalStand(right).get(0).getSection();
return turnBackList.stream().filter(section -> !section.isNormalStandTrack())
.filter(section -> !CollectionUtils.isEmpty(CalculateService.queryRoutePathsOnDirection(standTrack, section, right)))
.collect(Collectors.toList());
}
private Collection<? extends Route> generateRouteLikeHa1(Signal signal, CodeGenerator routeCodeGenerator, private Collection<? extends Route> generateRouteLikeHa1(Signal signal, CodeGenerator routeCodeGenerator,
Map<String, List<RouteOverlap>> overlapMap, Map<String, List<RouteOverlap>> overlapMap,
CodeGenerator overlapCodeGenerator, CodeGenerator overlapCodeGenerator,

View File

@ -69,6 +69,9 @@ public class MapCiGenerateConfig {
@ApiModelProperty(value = "若生成进路信号按钮,进路信号按钮是否取最近的一个信号机") @ApiModelProperty(value = "若生成进路信号按钮,进路信号按钮是否取最近的一个信号机")
private boolean getNearlySignal; private boolean getNearlySignal;
@ApiModelProperty("是否生成目的地码定义(泰雷兹式)")
private boolean generateDestination;
// @ApiModelProperty(value = "是否分开生成ATP联锁和地面信号联锁") // @ApiModelProperty(value = "是否分开生成ATP联锁和地面信号联锁")
// private boolean apartGroundAndAtp; // private boolean apartGroundAndAtp;

View File

@ -73,6 +73,9 @@ public class MapDestinationCodeDefinitionVO {
vo.code = definition.getCode(); vo.code = definition.getCode();
vo.type = definition.getType(); vo.type = definition.getType();
vo.description = definition.getDescription(); vo.description = definition.getDescription();
if (definition.getStartSection() != null) {
vo.startSectionCode = definition.getStartSection().getCode();
}
if (definition.getSection() != null) { if (definition.getSection() != null) {
vo.sectionCode = definition.getSection().getCode(); vo.sectionCode = definition.getSection().getCode();
} }
@ -80,6 +83,18 @@ public class MapDestinationCodeDefinitionVO {
if (!CollectionUtils.isEmpty(definition.getNecessarySections())) { if (!CollectionUtils.isEmpty(definition.getNecessarySections())) {
vo.runPath =definition.getNecessarySections().stream().map(MapElement::getCode).collect(Collectors.toList()); vo.runPath =definition.getNecessarySections().stream().map(MapElement::getCode).collect(Collectors.toList());
} }
if (definition.getLeftStation() != null) {
vo.stationACode = definition.getLeftStation().getCode();
}
if (definition.getLeftFrontTurnBack() != null) {
vo.stationAFrontTurnBack = definition.getLeftFrontTurnBack();
}
if (definition.getRightStation() != null) {
vo.stationBCode = definition.getRightStation().getCode();
}
if (definition.getRightFrontTurnBack() != null) {
vo.stationBFrontTurnBack = definition.getRightFrontTurnBack();
}
return vo; return vo;
} }