From 47987c9040af06869073027c1ae7ae87a94e3304 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Tue, 6 Dec 2022 08:57:33 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=9C=B0=E5=9B=BE=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E3=80=81=E8=83=8C=E6=99=AF=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/training2/rule/BgSceneStatusRule.java | 23 ++++--- .../rtss/vo/training2/rule/MapDeviceRule.java | 65 ++++++++++++------- 2 files changed, 57 insertions(+), 31 deletions(-) diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java index e64049f30..b9c7cd631 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java @@ -1,5 +1,6 @@ package club.joylink.rtss.vo.training2.rule; +import club.joylink.rtss.constants.MapPrdTypeEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.RunLevel; @@ -236,12 +237,10 @@ public enum BgSceneStatusRule { public String doHandle(Simulation simulation, MapElement mapElement) { Section section = (Section) mapElement; section.setRouteLock(true); - section.setLockRight(true); - if(!CollectionUtils.isEmpty(section.getLogicList())) { - section.getLogicList().forEach(s -> { - s.setRouteLock(true); - s.setLockRight(true); - }); + if (section.isCross()) { + section.getLogicList().get(0).setRouteLock(true); + } else if (section.isShowLogic()) { + section.getLogicList().forEach(s -> s.setRouteLock(true)); } return getBgScene(simulation); } @@ -285,7 +284,7 @@ public enum BgSceneStatusRule { public String doHandle(Simulation simulation, MapElement mapElement) { Section section = (Section) mapElement; section.setSpeedUpLimit(5); - return null; + return getBgScene(simulation); } }, SECTION_CONFIRM_AXIS_VALID_BG_SCENE("设置计轴生效背景") { @@ -325,7 +324,7 @@ public enum BgSceneStatusRule { VirtualRealityTrain train = (VirtualRealityTrain) simulation.getRepository().getVrDeviceMap().values().stream() .filter(o -> o instanceof VirtualRealityTrain).findFirst().get(); BgSceneStatusRule.trainOnline(simulation, train, section, stand.isRight()); - return null; + return getBgScene(simulation); } }, /** @@ -362,7 +361,13 @@ public enum BgSceneStatusRule { @Override public String doHandle(Simulation simulation, MapElement mapElement) { Stand stand = (Stand) mapElement; - stand.setTrainLimit(3); + if (MapPrdTypeEnum.LOCAL.equals(simulation.getBuildParams().getProdType())) { + // 现地,设置背景为现地扣车 + stand.setStationHoldTrain(true); + } else { + // 行调,设置背景为中心扣车 + stand.setCenterHoldTrain(true); + } return getBgScene(simulation); } }, diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java index 4d87f5f46..e5da48b39 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java @@ -4,10 +4,12 @@ import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.Getter; +import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.function.Function; import java.util.stream.Collectors; @Getter @@ -65,45 +67,32 @@ public enum MapDeviceRule { SECTION_LIST("区段列表") { @Override public List
filterMapDeviceList(Simulation simulation) { - List routeList = ROUTE_LIST.filterMapDeviceList(simulation); - List
sectionList = new ArrayList<>(100); - routeList.forEach(route -> sectionList.addAll(route.getSectionList())); + List
sectionList = querySectionListByFunction(simulation, Section::isAxleCounterSection); return generateRandomElement(sectionList, 2); } }, - SECTION_STAND_TURN_BACK_LIST("折返区段列表") { + SECTION_LOGIC_LIST("逻辑区段列表") { @Override public List
filterMapDeviceList(Simulation simulation) { - List
sectionList = simulation.getRepository().getSectionList().stream() - .filter(section -> section.isStandTrack() && section.isTurnBackTrack()) - .collect(Collectors.toList()); - return MapDeviceRule.generateRandomElement(sectionList, 2); + List
sectionList = querySectionListByFunction(simulation, Section::isLogicSection); + return generateRandomElement(sectionList, 2); } }, - SECTION_NO_AXLE_COUNTER_LIST("非计轴区段列表") { + SECTION_PHYSICAL_LIST("物理区段列表") { @Override public List
filterMapDeviceList(Simulation simulation) { - List stationCodeList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList() - .stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode) - .collect(Collectors.toList()); - List
sectionList = simulation.getRepository().getSectionList().stream() - .filter(section -> stationCodeList.contains(section.getDeviceStation().getCode()) && !section.isAxleCounter()) - .collect(Collectors.toList()); + List
sectionList = querySectionListByFunction(simulation, Section::isAxleCounterSection); return generateRandomElement(sectionList, 2); } }, SECTION_AXLE_COUNTER_LIST("道岔计轴区段列表") { @Override public List
filterMapDeviceList(Simulation simulation) { - List stationCodeList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList() - .stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode) - .collect(Collectors.toList()); - List
sectionList = simulation.getRepository().getSectionList().stream() - .filter(section -> stationCodeList.contains(section.getDeviceStation().getCode()) && section.isAxleCounter()) - .collect(Collectors.toList()); + List
sectionList = querySectionListByFunction(simulation, Section::isSwitchAxleCounterSection); return generateRandomElement(sectionList, 2); } - } + }, + ; private String description; @@ -133,4 +122,36 @@ public enum MapDeviceRule { } return givenList; } + + /** + * 筛选符合条件的方法 + * @param simulation 仿真 + * @param filterFunction 筛选条件 + * @return 返回区段列表 + */ + private static List
querySectionListByFunction(Simulation simulation, Function filterFunction) { + return simulation.getRepository().getSectionList().stream().filter(section -> { + Station deviceStation = section.getDeviceStation(); + if (deviceStation != null && deviceStation.isDepot()) { + return false; + } + Section axleCounterSection = section.findAxleCounterSection(); + if (axleCounterSection != null) { + Station axleDeviceStation = axleCounterSection.getDeviceStation(); + if (axleDeviceStation != null && axleDeviceStation.isDepot()) { + return false; + } + } + if(StringUtils.isEmpty(section.getName())){ + return false; + } + if (section.getParent() != null && section.getParent().isCross()) { + return false; + } + if (filterFunction != null) { + return filterFunction.apply(section); + } + return true; + }).collect(Collectors.toList()); + } }