diff --git a/src/main/java/club/joylink/rtss/services/DraftMapService.java b/src/main/java/club/joylink/rtss/services/DraftMapService.java index 8f6247c75..bc6c253d4 100644 --- a/src/main/java/club/joylink/rtss/services/DraftMapService.java +++ b/src/main/java/club/joylink/rtss/services/DraftMapService.java @@ -1534,6 +1534,7 @@ public class DraftMapService implements IDraftMapService { case NON_OPERATION: case LAST_NON_OPERATION: BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(definitionVO.getSectionCode(), "目标区段必须选择"); + break; case OTHER: break; } diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java index 5dc7e3e08..0b53ac0a1 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java @@ -182,6 +182,12 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { .filter(mapElement -> MapElement.DeviceType.SECTION.equals(mapElement.getDeviceType())) .map(mapElement -> (Section) mapElement) .collect(Collectors.toList()); + // 所有车站 + List 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> overlapMap = new HashMap<>(); List approachList = new ArrayList<>(); @@ -296,58 +302,6 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { // // 生成交路数据 // List generateRoutingList = this.generateRoutings(deviceMap, generatedRouteList, autoSignalList, errorList); - -// // 获取所有转换轨或者折返轨 -// List
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 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 generatedStationRunLevelList = new ArrayList<>(); // generateRunLevel(deviceMap, errorList, generateRoutingList, generatedStationRunLevelList); @@ -355,21 +309,132 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { //目的地码生成 List destinationCodeDefinitionList = new ArrayList<>(); - if (!CollectionUtils.isEmpty(sectionList)) { - for (Section section : sectionList) { - String destinationCode = section.getDestinationCode(); - if (!StringUtils.hasText(destinationCode)) { + if (config.isGenerateDestination()) { + String code = null; + DestinationCodeDefinition.Type type = null; + String description = null; + Section startSection = null; + Section section = null; + Boolean right = null; + List
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; + if (i == stationList.size() - 1) + break; + + List
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
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, autoSignalList, generatedRouteList, generatedOverlapList, flsList, generateCycleList, generatedStationRunLevelList, destinationCodeDefinitionList); } + /** + * 筛选站后折返轨(优先右行站台折返) + * @param stations 所有车站 + * @param right 是否是右端车站 + */ + private List
queryFrontTurnBackList(List stations, Station station, boolean right) { + List
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
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
queryAfterTurnBackList(Station station, boolean right) { + List
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 generateRouteLikeHa1(Signal signal, CodeGenerator routeCodeGenerator, Map> overlapMap, CodeGenerator overlapCodeGenerator, diff --git a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapCiGenerateConfig.java b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapCiGenerateConfig.java index e4a25c568..960d54057 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapCiGenerateConfig.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapCiGenerateConfig.java @@ -69,6 +69,9 @@ public class MapCiGenerateConfig { @ApiModelProperty(value = "若生成进路信号按钮,进路信号按钮是否取最近的一个信号机") private boolean getNearlySignal; + @ApiModelProperty("是否生成目的地码定义(泰雷兹式)") + private boolean generateDestination; + // @ApiModelProperty(value = "是否分开生成ATP联锁和地面信号联锁") // private boolean apartGroundAndAtp; diff --git a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java index bdadf8a98..f58fd91cc 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapDestinationCodeDefinitionVO.java @@ -73,6 +73,9 @@ public class MapDestinationCodeDefinitionVO { vo.code = definition.getCode(); vo.type = definition.getType(); vo.description = definition.getDescription(); + if (definition.getStartSection() != null) { + vo.startSectionCode = definition.getStartSection().getCode(); + } if (definition.getSection() != null) { vo.sectionCode = definition.getSection().getCode(); } @@ -80,6 +83,18 @@ public class MapDestinationCodeDefinitionVO { if (!CollectionUtils.isEmpty(definition.getNecessarySections())) { 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; }