diff --git a/src/main/java/club/joylink/rtss/services/DraftMapService.java b/src/main/java/club/joylink/rtss/services/DraftMapService.java index 434665c47..9322f9b6a 100644 --- a/src/main/java/club/joylink/rtss/services/DraftMapService.java +++ b/src/main/java/club/joylink/rtss/services/DraftMapService.java @@ -1439,7 +1439,7 @@ public class DraftMapService implements IDraftMapService { String logicData = entity.getLogicData(); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(StringUtils.hasText(logicData)); List vos = JsonUtils.read(logicData, JsonUtils.getCollectionType(ArrayList.class, MapDestinationCodeDefinitionVO.class)); - Optional first = vos.stream().filter(vo -> Objects.equals(vo.getCode(), code)).limit(1).findFirst(); + Optional first = vos.stream().filter(vo -> Objects.equals(vo.getCode(), code)).findFirst(); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(first.isPresent()); return first.get(); } @@ -1482,7 +1482,7 @@ public class DraftMapService implements IDraftMapService { String logicData = entity.getLogicData(); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(StringUtils.hasText(logicData)); List vos = JsonUtils.read(logicData, JsonUtils.getCollectionType(ArrayList.class, MapDestinationCodeDefinitionVO.class)); - Optional first = vos.stream().filter(vo -> vo.getCode().equals(definitionVO.getCode())).limit(1).findFirst(); + Optional first = vos.stream().filter(vo -> vo.getCode().equals(definitionVO.getCode())).findFirst(); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(first.isPresent()); MapDestinationCodeDefinitionVO old = first.get(); vos.set(vos.indexOf(old), definitionVO); 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 0d27e2606..dafbcda0c 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java @@ -510,7 +510,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { } else { sn = station.getSn() + 1; } - Station adjacentStation = stations.stream().filter(sta -> sta.getSn() == sn).limit(1).findAny().get(); + Station adjacentStation = stations.stream().filter(sta -> sta.getSn() == sn).findAny().get(); if (CollectionUtils.isEmpty(adjacentStation.getAllNormalStands())) { return new ArrayList<>(); } diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java index c64adfce9..9e8de83c0 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java @@ -463,7 +463,7 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService { routeVO.setEndSectionCode(departureRoute.getEndSectionCode()); List buttons = signalCode_button_map.get(destination.getCode()); MapSignalButtonVO endButton = buttons.stream().filter(vo -> MapSignalButtonVO.Type.PICK.equals(vo.getType())) - .limit(1).findAny().orElse(null); + .findAny().orElse(null); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(endButton, String.format("以信号机[%s]、[%s]为始终端的通过进路,终端信号机无列车信号按钮", signal.getCode(), destination.getCode())); routeVO.setBtnCodeList(Arrays.asList(buttonVO.getCode(), endButton.getCode())); @@ -534,7 +534,7 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService { if (!CollectionUtils.isEmpty(buttons)) { Optional pickButtonOptional = buttons.stream() .filter(vo -> MapSignalButtonVO.Type.PICK.equals(vo.getType())) - .limit(1).findAny(); + .findAny(); if (pickButtonOptional.isPresent()) { MapSignalButtonVO endButton = pickButtonOptional.get(); Route route = new Route(routeCodeGenerator.next(), "L_" + startSignal.getShowName() + "-" + endSignal.getShowName()); diff --git a/src/main/java/club/joylink/rtss/services/org/OrgScoringRuleService.java b/src/main/java/club/joylink/rtss/services/org/OrgScoringRuleService.java index ad7aadb6e..2da8d1ca2 100644 --- a/src/main/java/club/joylink/rtss/services/org/OrgScoringRuleService.java +++ b/src/main/java/club/joylink/rtss/services/org/OrgScoringRuleService.java @@ -151,12 +151,12 @@ public class OrgScoringRuleService implements IOrgScoringRuleService { if (CollectionUtils.isEmpty(rels)) { return null; } else { - OrgScoringRuleRel rel = rels.stream().filter(orgRuleRel -> orgRuleRel.getOrgId().equals(orgId)).limit(1).findAny().orElse(null); + OrgScoringRuleRel rel = rels.stream().filter(orgRuleRel -> orgRuleRel.getOrgId().equals(orgId)).findAny().orElse(null); if (rel == null) { return null; } else { OrgScoringRuleWithBLOBs rule = rules.stream().filter(orgRule -> orgRule.getId().equals(rel.getRuleId())) - .limit(1).findAny().orElse(null); + .findAny().orElse(null); if (rule == null) { return null; } else { diff --git a/src/main/java/club/joylink/rtss/services/training/TrainingV1Service.java b/src/main/java/club/joylink/rtss/services/training/TrainingV1Service.java index ec43095b3..715b472f3 100644 --- a/src/main/java/club/joylink/rtss/services/training/TrainingV1Service.java +++ b/src/main/java/club/joylink/rtss/services/training/TrainingV1Service.java @@ -733,7 +733,6 @@ public class TrainingV1Service implements ITrainingV1Service { if (!CollectionUtils.isEmpty(graphDataNew.getCycleButtonList())) { Optional any = graphDataNew.getCycleButtonList().stream() .filter(b -> b.getCode().equals(code)) - .limit(1) .findAny(); if (any.isPresent()) { deviceCode = any.get().getStationCode(); @@ -742,7 +741,6 @@ public class TrainingV1Service implements ITrainingV1Service { if (deviceCode == null && !CollectionUtils.isEmpty(graphDataNew.getAutomaticRouteButtonList())) { Optional any = graphDataNew.getAutomaticRouteButtonList().stream() .filter(b -> b.getCode().equals(code)) - .limit(1) .findAny(); if (any.isPresent()) { deviceCode = any.get().getStationCode(); @@ -751,7 +749,6 @@ public class TrainingV1Service implements ITrainingV1Service { if (deviceCode == null && !CollectionUtils.isEmpty(graphDataNew.getTbStrategyList())) { Optional any = graphDataNew.getTbStrategyList().stream() .filter(b -> b.getCode().equals(code)) - .limit(1) .findAny(); if (any.isPresent()) { deviceCode = any.get().getStationCode(); @@ -760,7 +757,6 @@ public class TrainingV1Service implements ITrainingV1Service { if (deviceCode == null && !CollectionUtils.isEmpty(graphDataNew.getTotalGuideLockButtonVOList())) { Optional any = graphDataNew.getTotalGuideLockButtonVOList().stream() .filter(b -> b.getCode().equals(code)) - .limit(1) .findAny(); if (any.isPresent()) { deviceCode = any.get().getStationCode(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CILogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CILogicLoop.java deleted file mode 100644 index 667fdacf1..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CILogicLoop.java +++ /dev/null @@ -1,385 +0,0 @@ -//package club.joylink.rtss.simulation.cbtc.CI; -// -//import club.joylink.rtss.simulation.cbtc.ATP.ground.GroundAtpApiService; -//import club.joylink.rtss.simulation.cbtc.ATS.AtsApiService; -//import club.joylink.rtss.simulation.cbtc.CI.service.*; -//import club.joylink.rtss.simulation.cbtc.Simulation; -//import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; -//import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; -//import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; -//import club.joylink.rtss.simulation.cbtc.data.map.*; -//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; -//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter; -//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; -//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; -//import lombok.extern.slf4j.Slf4j; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.stereotype.Component; -//import org.springframework.util.CollectionUtils; -// -//import java.util.List; -// -///** -// * CI主线逻辑循环 -// */ -//@Slf4j -//@Component -//public class CILogicLoop { -// -// @Autowired -// private RouteService routeService; -// -// @Autowired -// private AutoSignalService autoSignalService; -// -// @Autowired -// private SectionService sectionService; -// -// @Autowired -// private SignalService signalService; -// -// @Autowired -// private SwitchService switchService; -// -// @Autowired -// private GroundAtpApiService groundAtpApiService; -// -// @Autowired -// private AtsApiService atsApiService; -// -// public void run(Simulation simulation) { -//// long start = System.currentTimeMillis(); -// // 设备状态采集(从虚拟真实设备采集) -// this.getStatusFromVRDevice(simulation); -// // 进路逻辑 -// this.routeLogic(simulation); -// -// // 自动信号逻辑 -// this.autoSignalLogic(simulation); -// -// // 延时解锁设备逻辑 -// this.deviceDelayUnlockLogic(simulation); -// -//// long end = System.currentTimeMillis(); -//// System.out.println(String.format("------------CI逻辑耗时: %s ms", (end-start))); -// } -// -// private void autoSignalLogic(Simulation simulation) { -// List autoSignalList = simulation.getRepository().getAutoSignalList(); -// if (!CollectionUtils.isEmpty(autoSignalList)) { -// autoSignalList.forEach(autoSignal -> -// this.autoSignalService.updateSignalDisplay(simulation, autoSignal)); -// } -// } -// -// private void deviceDelayUnlockLogic(Simulation simulation) { -// SimulationDataRepository repository = simulation.getRepository(); -// List
sectionList = repository.getSectionList(); -// for (Section section : sectionList) { -// this.sectionService.delayUnlock(simulation, section); -// } -// List switchList = repository.getSwitchList(); -// for (Switch aSwitch : switchList) { -// this.switchService.delayUnlock(simulation, aSwitch); -// } -// } -// -// /** -// * 从虚拟真实设备采集状态 -// * -// * @param simulation -// */ -// public void getStatusFromVRDevice(Simulation simulation) { -// SimulationDataRepository repository = simulation.getRepository(); -// List signalList = getSignalsStatusFromVRDevice(simulation); -// List switchList = getSwitchesStatusFromVRDevice(repository); -// getSectionsStatusFromVRDevice(repository); -// getPsdStatusFromVRDevice(repository); -// // 道岔状态发送ATS -// this.atsApiService.handleDeviceStatus(simulation, signalList); -// this.atsApiService.handleDeviceStatus(simulation, switchList); -// -// // 计轴区段状态发送地面ATP -// this.groundAtpApiService.receiveAndHandleAxleSectionStatus(simulation); -// } -// -// -// /** -// * 进路相关逻辑 -// */ -// public void routeLogic(Simulation simulation) { -// SimulationDataRepository repository = simulation.getRepository(); -// List routeList = repository.getRouteList(); -// for (Route route : routeList) { -// //联锁机故障逻辑 -// Station deviceStation = route.getStart().getDeviceStation(); -// if (deviceStation != null) { -// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { -// continue; -// } -// } -//// Route.CheckFailMessage result = this.routeService.check(simulation, route); -//// if (Objects.nonNull(result)) { -//// route.setSettable(false); -//// } else { -//// route.setSettable(true); -//// } -// // 联锁自动触发判断处理 -// if (route.isCiControl() && !repository.isSettingRoute(route) && -// !route.isNormalUnlock() && route.isCiTrigger()) { -// this.routeService.setting(simulation, route); -// } -// } -// List settingRoutes = repository.getSettingRoutes(); -// if (!CollectionUtils.isEmpty(settingRoutes)) { -// // 获取所有列车方向速度位置信息用以解锁进路 -// for (Route route : settingRoutes) { -// //联锁机故障逻辑 -// Station deviceStation = route.getStart().getDeviceStation(); -// if (deviceStation != null) { -// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { -// continue; -// } -// } -// -// if (route.isNormalUnlock()) { // 进路锁闭,若进路内存在列车,执行正常解锁 -// this.routeService.normalUnlock(simulation, route); -// } -// if (route.isSetting()) { // 进路排列过程 -// this.routeService.settingProgress(simulation, route); -// } -// if (route.isDelayUnlocking()) { // 进路延时解锁过程 -// this.routeService.humanCancelProgress(simulation, route); -// } -// if (route.isLock()) { // 进路信号开放,始终检查联锁条件是否满足 -// this.routeService.lockedRouteCheck(simulation, route); -// } -//// if (route.isLock()) { -// // 进路第一个区段是否占用 -//// Section firstRouteSection = route.getFirstRouteLogicSection(); -//// if (firstRouteSection.isRouteLock() && -//// firstRouteSection.isOccupied()) { -//// route.getStart().setReblockade(true); -//// log.debug(String.format("[%s]因[%s]第一个子区段[%s]进路锁闭且占用而重复封锁", -//// route.getStart().debugStr(), route.debugStr(), firstRouteSection.debugStr())); -//// } -//// if (route.isOpen() && !firstRouteSection.isOccupied()) { -//// route.getStart().setReblockade(false); -//// } -//// } -//// else if (route.isLock() && !route.isNormalUnlock() && !route.isOpen()) { -//// this.routeService.openedRouteCheck(simulation, route); -//// } -// } -// } -// // 延续保护进路解锁 -// List overlapList = repository.getListByType(MapElement.DeviceType.OVERLAP, RouteOverlap.class); -// for (RouteOverlap overlap : overlapList) { -// if (overlap.isLock()) {// 延续保护已锁闭 -// this.routeService.overlapUnlock(simulation, overlap); -// this.routeService.overlapCancelLock(overlap); -// } else { -// // 延续保护锁闭禁止条件释放 -// this.routeService.checkAndAllowOverlap(simulation, overlap); -// } -// if (overlap.isSetting()) { // 延续保护办理中 -// this.routeService.overlapSettingProcess(simulation, overlap); -// } -// } -// // 延续保护触发 -// if (repository.getConfig().isOverlapSettingByTrigger()) { -// for (RouteOverlap overlap : overlapList) { -// this.routeService.checkLockOverlap(simulation, overlap); -// } -// } -// } -// -// /** -// * 从真实设置获取屏蔽门的状态 -// */ -// private void getPsdStatusFromVRDevice(SimulationDataRepository repository) { -// // 站台屏蔽门开关门等状态 -// List psdList = repository.getListByType(MapElement.DeviceType.PSD, PSD.class); -// psdList.forEach(psd -> { -// //联锁机故障 -// Stand stand = psd.getStand(); -// Station deviceStation = stand.getDeviceStation(); -// if (deviceStation != null) { -// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { -// stand.setNoStatus(true); -// psd.setNoStatus(true); -// return; -// } else { -// stand.setNoStatus(false); -// psd.setNoStatus(false); -// } -// if (deviceStation.isInterlockMachineStarting()) -// return; -// } else { -// stand.setNoStatus(false); -// psd.setNoStatus(false); -// } -// -// VirtualRealityScreenDoor vrScreenDoor = psd.getVirtualScreenDoor(); -// psd.apply(vrScreenDoor.isClose(), vrScreenDoor.isLock(), vrScreenDoor.isInterlockRelease()); -// }); -// } -// -// /** -// * 更新区段逻辑 -// */ -// private void getSectionsStatusFromVRDevice(SimulationDataRepository repository) { -// // 区段占用 -// List
axleSectionList = repository.getAxleSectionList(); -// axleSectionList.forEach(section -> { -// //联锁机故障 -// boolean interlockMachineFault = false; -// boolean interlockMachineStarting = false; -// Station deviceStation = section.getDeviceStation(); -// if (deviceStation != null) { -// if (deviceStation.isInterlockMachineStarting()) -// interlockMachineStarting = true; -// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) -// interlockMachineFault = true; -// } -// if (interlockMachineFault) { -// section.setNoStatus(true); -// if (section.isSwitchAxleCounterSection()) { -// section.getLogicList().forEach(switchSection -> switchSection.setNoStatus(true)); -// } -// } else { -// section.setNoStatus(false); -// if (section.isSwitchAxleCounterSection()) { -// section.getLogicList().forEach(switchSection -> switchSection.setNoStatus(false)); -// } -// } -// if (interlockMachineStarting) -// return; -//// if (section.isInvalid() && section.isFault()) { -//// section.setNctOccupied(false); -//// return; -//// } -//// if (section.isFault()) { -//// section.setNctOccupied(true); -//// return; -//// } -// if (Section.AxleFault.UNABLE_COLLECT_STATUS.equals(section.getFault())) -// return; -// VirtualRealitySectionAxleCounter virtualAxleCounter = section.getVirtualAxleCounter(); -// //更新区段故障状态 -// if (!VirtualRealitySectionAxleCounter.Fault.FAULT.equals(virtualAxleCounter.getFault())) { -// if (Section.AxleFault.FAULT.equals(section.getFault())){ -// section.setFault(null); -// } -// } -// //更新区段占用状态 -// if (virtualAxleCounter.isOccupy()) { -// section.axleCounterOccupy(virtualAxleCounter.isRight()); -// } else { -// section.clearOccupy(); -// section.judgeAsValid(); -// } -// //预复位 -// if (!virtualAxleCounter.isPreReset()) { -// List switchList = section.getRelSwitchList(); -// if (!CollectionUtils.isEmpty(switchList)) { -// switchList.forEach(aSwitch -> aSwitch.setPreReset(false)); -// } -// } -// }); -// } -// -// /** -// * 从真实设备获取道岔状态 -// */ -// private List getSwitchesStatusFromVRDevice(SimulationDataRepository repository) { -// // 道岔位置状态 -// List switchList = repository.getListByType(MapElement.DeviceType.SWITCH, Switch.class); -// switchList.forEach(aSwitch -> { -// //联锁机故障逻辑 -// Station deviceStation = aSwitch.getDeviceStation(); -// if (deviceStation != null) { -// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { -// aSwitch.setNoStatus(true); -// return; -// } else { -// aSwitch.setNoStatus(false); -// } -// if (deviceStation.isInterlockMachineStarting()) -// return; -// } else { -// aSwitch.setNoStatus(false); -// } -// -// Switch.SwitchFault fault = (Switch.SwitchFault) aSwitch.getFault(); -// if (fault != null) { -// switch (fault) { -// case SPLIT: -// case SQUEEZE: -// break; -// case NORMAL_SPLIT: { -// VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch(); -// aSwitch.apply(false, virtualSwitch.isReverse()); -// break; -// } -// case REVERSE_SPLIT: { -// VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch(); -// aSwitch.apply(virtualSwitch.isNormal(), false); -// break; -// } -// } -// } else { -// VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch(); -// aSwitch.apply(virtualSwitch.isNormal(), virtualSwitch.isReverse()); -// } -// }); -// return switchList; -// } -// -// /** -// * 从真实设备获取信号机状态 -// */ -// private List getSignalsStatusFromVRDevice(Simulation simulation) { -// SimulationDataRepository repository = simulation.getRepository(); -// List signalList = repository.getSignalList(); -// for (Signal signal : signalList) { -// //联锁机故障逻辑 -// Station deviceStation = signal.getDeviceStation(); -// if (deviceStation != null) { -// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { -// signal.setNoStatus(true); -// continue; -// } else { -// signal.setNoStatus(false); -// } -// if (deviceStation.isInterlockMachineStarting()) -// continue; -// } else { -// signal.setNoStatus(false); -// } -// -// if (signal.isLogicLight() || signal.isVirtual()) { -// continue; -// } else if (signal.isGuideOpen()) { -// int guideRemain = signal.getGuideRemain(); -// if (guideRemain != -1) { // 非无限开放 -// guideRemain -= SimulationModule.CI.getRateMs(); -// if (guideRemain <= 0) { -// // 关闭引导信号 -// this.signalService.close(simulation, signal); -// signal.updateGuideRemain(0); -// } else { -// signal.updateGuideRemain(guideRemain); -// } -// } -// } -// VirtualRealitySignal virtualSignal = signal.getVirtualSignal(); -// signal.apply(virtualSignal.isGreenOpen(), virtualSignal.isYellowOpen(), virtualSignal.isRedOpen()); -// } -// return signalList; -// } -// -// public void addJobs(Simulation simulation) { -// simulation.addJob(SimulationModule.CI.name(), () -> this.run(simulation), SimulationConstants.CI_LOOP_RATE); -// } -//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java deleted file mode 100644 index 259a20b24..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java +++ /dev/null @@ -1,672 +0,0 @@ -//package club.joylink.rtss.simulation.cbtc.CI; -// -//import club.joylink.rtss.exception.BusinessExceptionAssertEnum; -//import club.joylink.rtss.simulation.cbtc.CI.service.*; -//import club.joylink.rtss.simulation.cbtc.Simulation; -//import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; -//import club.joylink.rtss.simulation.cbtc.data.map.*; -//import club.joylink.rtss.simulation.cbtc.data.support.SignalApproachMessage; -//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter; -//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; -//import club.joylink.rtss.simulation.cbtc.exception.SimulationException; -//import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; -//import lombok.extern.slf4j.Slf4j; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.stereotype.Component; -//import org.springframework.util.CollectionUtils; -//import org.springframework.util.StringUtils; -// -//import java.time.LocalTime; -//import java.util.List; -//import java.util.Objects; -//import java.util.Optional; -//import java.util.stream.Collectors; -// -///** -// * CI子系统 -// */ -//@Slf4j -//@Component -//public class CiApiServiceImpl implements CiApiService { -// -// @Autowired -// private SignalService signalService; -// -// @Autowired -// private SectionService sectionService; -// -// @Autowired -// private SwitchService switchService; -// -// @Autowired -// private RouteService routeService; -// -// @Autowired -// private StandService standService; -// -// @Override -// public void blockadeSection(Simulation simulation, String sectionCode) { -// Section section = simulation.getRepository().getByCode(sectionCode, Section.class); -// this.sectionService.blockade(section); -// } -// -// @Override -// public void unblockSection(Simulation simulation, String sectionCode) { -// Section section = simulation.getRepository().getByCode(sectionCode, Section.class); -// this.sectionService.unblock(section); -// } -// -// @Override -// public void blockadeSignal(Simulation simulation, String signalCode) { -// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); -// this.signalService.blockade(simulation, signal); -// } -// -// @Override -// public void unblockSignal(Simulation simulation, String signalCode) { -// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); -// this.signalService.unblock(signal); -// } -// -// @Override -// public void closeSignal(Simulation simulation, String signalCode) { -// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); -// this.signalService.close(simulation, signal); -// } -// -// @Override -// public void reopenSignal(Simulation simulation, String signalCode) { -// // 判断信号机是否是关闭状态、进路是否锁闭、联锁关系是否满足 -// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); -// if (signal.isMainAspect()) { -// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, -// "信号机已经开启,无需重开信号机"); -// } -// Optional routeOptional = simulation.getRepository().getSettingRoutes().stream() -// .filter(route -> route.getStart().equals(signal)).limit(1).findAny(); -// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(routeOptional.isPresent(), "信号机不是已排进路的始端信号机"); -//// settingRoute(simulation, routeOptional.get().getCode()); -// Route lockedRoute = signal.getLockedRoute(); -// if (Objects.isNull(lockedRoute)) { -// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, -// "进路未锁闭,不能重开信号机"); -// } -// if (!this.routeService.isInterlocked(lockedRoute)) { -// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, -// String.format("进路[%s(%s)]联锁关系不满足,不能重开信号机", lockedRoute.getName(), lockedRoute.getCode())); -// } -// this.routeService.routeOpen(simulation, lockedRoute); -// if (lockedRoute.isDelayUnlocking()) { -// lockedRoute.cancelDelayUnlocking(); -// } -// } -// -// @Override -// public void turn(Simulation simulation, String switchCode) { -// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); -// boolean toNormal = aSwitch.judgeTurnToNormal(); -// aSwitch.setLastTurnToNormal(toNormal); -// if (toNormal) { -// if (!this.switchService.turn2NormalPosition(simulation, aSwitch)) { -// log.info(String.format("道岔[%s(%s)]锁闭,不能进行定操", aSwitch.getName(), aSwitch.getCode())); -// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行定操"); -// } -// } else { -// if (!this.switchService.turn2ReversePosition(simulation, aSwitch)) { -// log.info(String.format("道岔[%s(%s)]锁闭,不能进行反操", aSwitch.getName(), aSwitch.getCode())); -// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行反操"); -// } -// } -// } -// -// @Override -// public void turn2NormalPosition(Simulation simulation, String switchCode) { -// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); -// if (!this.switchService.turn2NormalPosition(simulation, aSwitch)) { -// log.info(String.format("道岔[%s(%s)]锁闭,不能进行定操", aSwitch.getName(), aSwitch.getCode())); -// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行定操"); -// } -// } -// -// @Override -// public void turn2ReversePosition(Simulation simulation, String switchCode) { -// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); -// if (!this.switchService.turn2ReversePosition(simulation, aSwitch)) { -// log.info(String.format("道岔[%s(%s)]锁闭,不能进行反操", aSwitch.getName(), aSwitch.getCode())); -// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行反操"); -// } -// } -// -// @Override -// public void singleLockSwitch(Simulation simulation, String switchCode) { -// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); -// this.switchService.singleLock(aSwitch); -// } -// -// @Override -// public void singleUnlockSwitch(Simulation simulation, String switchCode) { -// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); -// this.switchService.singleUnlock(aSwitch); -// } -// -// @Override -// public void blockadeSwitch(Simulation simulation, String switchCode) { -// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); -// //条件检查 -// MapConfig config = simulation.getRepository().getConfig(); -// if (config.isBlockadeCommandOnlyValidInStandbyMode()) { -// boolean standbyMode = simulation.getRepository().getRouteList() -// .stream().filter(route -> route.isRouteSwitch(aSwitch)).anyMatch(route -> !route.isCbtcMode()); //包含该道岔的进路是否有处于后备模式的 -// if (!standbyMode) { -// return; -// } -// } -//// if (config.isSomeCommandNeedInit()) { -//// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(aSwitch.isInit(), aSwitch.debugStr() + "未初始化"); -//// } -// -// this.switchService.blockade(aSwitch); -// } -// -// @Override -// public void unblockSwitch(Simulation simulation, String switchCode) { -// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); -// this.switchService.unblock(aSwitch); -// } -// -// @Override -// public void blockadeSwitchSection(Simulation simulation, String switchCode) { -// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); -// this.switchService.blockade(aSwitch); -// } -// -// @Override -// public void unblockSwitchSection(Simulation simulation, String switchCode) { -// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); -// this.switchService.unblock(aSwitch); -// } -// -// @Override -// public Route.CheckFailMessage routeSettingCheck(Simulation simulation, String routeCode) { -// Route route = simulation.getRepository().getByCode(routeCode, Route.class); -// return this.routeService.check(simulation, route); -// } -// -// @Override -// public void settingRoute(Simulation simulation, String routeCode) { -// Route route = simulation.getRepository().getByCode(routeCode, Route.class); -// this.routeService.setting(simulation, route); -// } -// -// @Override -// public void unlockRoute(Simulation simulation, String routeCode) { -// Route route = simulation.getRepository().getByCode(routeCode, Route.class); -// if (simulation.getRepository().getConfig().isDelayWhenCancelRouteWithAbnormalInterlock()) { -// if (!routeService.isInterlocked(route)) { -// routeService.humanCancel(simulation, route); -// return; -// } -// } -// this.routeService.cancelNoApproachLock(simulation, route); -// } -// -// @Override -// public void forceUnlockRoute(Simulation simulation, String routeCode) { -// Route route = simulation.getRepository().getByCode(routeCode, Route.class); -// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(route.isFleetMode(), -// String.format("进路[%s]已开启自动通过进路,无法取消", route.debugStr())); -// SimulationDataRepository repository = simulation.getRepository(); -// if (routeService.isApproachLock(repository, route)) { -// routeService.humanCancel(simulation, route); -// } else { -// unlockRoute(simulation, route.getCode()); -// } -// } -// -// @Override -// public void humanCancel(Simulation simulation, String routeCode) { -// Route route = simulation.getRepository().getByCode(routeCode, Route.class); -// this.routeService.humanCancel(simulation, route); -// } -// -// @Override -// public void sectionFaultUnlock(Simulation simulation, String sectionCode) { -// Section section = simulation.getRepository().getByCode(sectionCode, Section.class); -// if (section.isCross()) { -// Optional
crossLockedSectionOptional = section.getLogicList().stream().filter(Section::isLocked).findAny(); -// if (crossLockedSectionOptional.isEmpty()) { -// return; -// } -//// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(crossLockedSectionOptional.isPresent(), -//// section.debugStr() + "未锁闭,无需解锁"); -// section = crossLockedSectionOptional.get(); -// } -// if (!section.isLocked()) { -// return; -// } -//// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(section.isLocked(), -//// section.debugStr() + "未锁闭,无需解锁"); -// List lockedRouteList = simulation.getRepository().queryAllLockedRoute(); -// Route lockedRoute = null; -// if (section.isRouteLock()) { -// lockedRoute = section.getRoute(); -//// for (Route route : lockedRouteList) { -//// if (route.containSection(section)) { -//// lockedRoute = route; -//// break; -//// } -//// } -// } else if (section.isOverlapLock()) { -// for (Route route : lockedRouteList) { -// if (route.overlapContainSection(section)) { -// lockedRoute = route; -// break; -// } -// } -// } -// this.sectionService.sectionFaultUnlock(simulation, section, lockedRoute); -// } -// -// @Override -// public void switchSectionFaultUnlock(Simulation simulation, String switchCode) { -// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); -// if (!aSwitch.isLocked()) -// return; -// List lockedRouteList = simulation.getRepository().queryAllLockedRoute(); -// Route lockedRoute = null; -// if (aSwitch.isRouteLock()) { -// lockedRoute = aSwitch.getRoute(); -//// for (Route route : lockedRouteList) { -//// if (route.isRouteSwitch(aSwitch)) { -//// lockedRoute = route; -//// break; -//// } -//// } -// } else if (aSwitch.isOverlapLock()) { -// for (Route route : lockedRouteList) { -// if (route.overlapContainSwitch(aSwitch)) { -// lockedRoute = route; -// break; -// } -// } -// } -// this.switchService.switchFaultUnlock(simulation, aSwitch, lockedRoute); -// } -// -// @Override -// public void setFleetRoute(Simulation simulation, String routeCode) { -// Route route = simulation.getRepository().getByCode(routeCode, Route.class); -// this.routeService.setFleet(route); -// } -// -// @Override -// public void cancelFleetRoute(Simulation simulation, String routeCode) { -// Route route = simulation.getRepository().getByCode(routeCode, Route.class); -// this.routeService.cancelFleet(route); -// } -// -// @Override -// public void setCIAutoTriggerRoute(Simulation simulation, String routeCode) { -// Route route = simulation.getRepository().getByCode(routeCode, Route.class); -// this.routeService.setCIAutoTrigger(route); -// } -// -// @Override -// public void cancelCIAutoTriggerRoute(Simulation simulation, String routeCode) { -// Route route = simulation.getRepository().getByCode(routeCode, Route.class); -// this.routeService.cancelCIAutoTrigger(route); -// } -// -// @Override -// public Route findLockedRouteByStartSignal(Simulation simulation, String signalCode) { -// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); -// return signal.getLockedRoute(); -// } -// -// @Override -// public Route findRouteByStartAndEndSignal(Simulation simulation, String startSignalCode, String endSignalCode) { -// Signal start = simulation.getRepository().getByCode(startSignalCode, Signal.class); -// List routeList = start.getRouteList(); -// if (!CollectionUtils.isEmpty(routeList)) { -// for (Route route : routeList) { -// if (Objects.equals(route.getDestination().getCode(), endSignalCode)) { -// return route; -// } -// } -// } -// return null; -// } -// -// @Override -// public void settingGuideRoute(Simulation simulation, String routeCode) { -// Route route = simulation.getRepository().getByCode(routeCode, Route.class); -// this.routeService.settingGuideRoute(simulation, route); -// } -// -// @Override -// public void closeGuideSignal(Simulation simulation, String signalCode) { -// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); -// this.signalService.close(simulation, signal); -// } -// -// @Override -// public void openScreenDoor(Simulation simulation, String standCode) { -// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); -// if (Objects.nonNull(stand.getPsd())) { -// this.standService.openScreenDoor(simulation, stand.getPsd()); -// } -// } -// -// @Override -// public void closeScreenDoor(Simulation simulation, String standCode) { -// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); -// if (Objects.nonNull(stand.getPsd())) { -// this.standService.closeScreenDoor(simulation, stand.getPsd()); -// } -// } -// -// @Override -// public void standHoldTrain(Simulation simulation, String standCode, boolean center) { -// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); -// this.standService.holdTrain(simulation, stand, center); -// } -// -// @Override -// public void sysHoldTrain(Simulation simulation, String standCode) { -// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); -// this.standService.sysHoldTrain(simulation, stand); -// } -// -// @Override -// public void standHoldTrainCancel(Simulation simulation, String standCode, boolean center) { -// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); -// this.standService.cancelHoldTrain(simulation, stand, center); -// } -// -// @Override -// public void sysHoldTrainCancel(Simulation simulation, String standCode) { -// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); -// this.standService.cancelSysHoldTrain(simulation, stand); -// } -// -// @Override -// public void ibpHoldTrain(Simulation simulation, String standCode) { -// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); -// this.standService.ibpHoldTrain(simulation, stand); -// } -// -// @Override -// public void ibpHoldTrainCancel(Simulation simulation, String standCode) { -// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); -// this.standService.cancelIbpHoldTrain(simulation, stand); -// } -// -// @Override -// public void standHoldTrainCancelAll(Simulation simulation, String standCode) { -// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); -// this.standService.cancelAllHoldTrain(simulation, stand); -// } -// -// @Override -// public void handleSignalApproachMessage(Simulation simulation, -// List approachMessageList) { -// approachMessageList.forEach(approachMessage -> { -// Signal signal = simulation.getRepository().getByCode(approachMessage.getSignalCode(), Signal.class); -// this.signalService.handleApproachMessage(simulation, signal, approachMessage); -// }); -// } -// -// @Override -// public void handleTrainStopMessage(Simulation simulation, VirtualRealityTrain train) { -// this.routeService.handleTrainStopMessage(simulation, train); -// } -// -// /** -// * 办理引导 -// */ -// @Override -// public void setGuide(Simulation simulation, String signalCode, String routeCode) { -// SimulationDataRepository repository = simulation.getRepository(); -// MapConfig config = repository.getConfig(); -// Signal signal; -// Route route = null; -// if (StringUtils.hasText(signalCode)) { -// signal = repository.getByCode(signalCode, Signal.class); -// } else if (StringUtils.hasText(routeCode)) { -// route = repository.getByCode(routeCode, Route.class); -// signal = route.getStart(); -// } else { -// throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("signalCode和routeCode不能都为空"); -// } -// //条件检查 -// if (config.isGuideNeedRouteSettingFirst()) { -// List routeList = signal.getRouteList(); -// BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(routeList, String.format("信号机[%s]非进路始端信号机", signal.getCode())); -// if (route != null) { -// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(route.isLock(), String.format("进路[%s]未办理", route.getCode())); -// } else { -// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(signal.getLockedRoute(), String.format("信号机[%s]无已办理进路", signal.getCode())); -// } -// } -//// if (config.isSomeCommandNeedInit()) { -//// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isInit(), signal.debugStr() + "未初始化"); -//// } -// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isClose(), String.format("信号机[%s]需处于关闭状态", signal.getCode())); -// boolean signalApproachOccupied = signal.getApproachPathList() -// .stream().anyMatch(sectionPath -> sectionPath.getSectionList().stream().anyMatch(Section::isOccupied)); -// if (config.isNeedApproachLockBeforeSetGuide()) { -// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signalApproachOccupied, -// String.format("对%s开放引导操作失败,接近区段没有列车占用", signal.getName())); -// } -// //办理引导进路或开放引导信号 -// if (config.isGuideNeedRouteSettingFirst()) { -// signalService.openGuideSignal(simulation, signal); -// } else { -// if (route != null) { -// if (route.isLock()) { -// signalService.openGuideSignal(simulation, route.getStart()); -// } else { -// routeService.settingGuideRoute(simulation, route); -// } -// } else { -// if (signal.getLockedRoute() != null) { //如果有已锁闭进路 -// signalService.openGuideSignal(simulation, signal); -// } else if (!CollectionUtils.isEmpty(signal.getRouteList())) { //如果signal锁闭进路为null,筛选最合适的进路(直线进路>分叉进路>折返进路) -// List collect = signal.getRouteList().stream() -// .filter(r -> !r.isTurnBack() && CollectionUtils.isEmpty(r.getSwitchList())) -// .collect(Collectors.toList()); -// if (CollectionUtils.isEmpty(collect)) { -// collect = signal.getRouteList().stream().filter(r -> !r.isTurnBack()).collect(Collectors.toList()); -// } -// if (CollectionUtils.isEmpty(collect)) { -// collect = signal.getRouteList(); -// } -// route = collect.get(0); -// routeService.settingGuideRoute(simulation, route); -// } else { //如果信号机没有关联进路 -// signalService.openGuideSignal(simulation, signal); -// } -// } -// } -// } -// -// /** -// * 取消引导 -// */ -// @Override -// public void cancelGuide(Simulation simulation, String signalCode) { -// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); -// signalService.close(simulation, signal); -// if (signal.getLockedRoute() != null) { -// routeService.cancelGuideRoute(simulation, signal.getLockedRoute()); -// } -// } -// -// @Override -// public void setEst(Simulation simulation, ESP esp) { -// esp.update(true); -// } -// -// @Override -// public void cancelEst(Simulation simulation, ESP esp) { -// esp.update(false); -// } -// -// @Override -// public void restart(Simulation simulation, Station station) { -// Station deviceStation; -// if (station.isCentralized()) { -// deviceStation = station; -// } else { -// deviceStation = station.getDeviceStation(); -// } -// deviceStation.setInterlockMachineStarting(false); -// } -// -// @Override -// public void release(Simulation simulation, Station station) { -// -// } -// -// @Override -// public void powerOnUnlock(Simulation simulation, Station station) { -// if (!station.isCentralized()) { -// station = station.getDeviceStation(); -// } -// Station deviceStation = station; -// if (Objects.nonNull(deviceStation.getRestartTime()) -// && deviceStation.getRestartTime().isBefore(LocalTime.now()) -// && ((Simulation.FunctionalType.LESSON.equals(simulation.getBuildParams().getFunctionalType()) -// || Simulation.FunctionalType.EXAM.equals(simulation.getBuildParams().getFunctionalType())) -// ? true : deviceStation.getRestartTime().plusMinutes(8).isAfter(LocalTime.now()))) { -// List
sections = simulation.getRepository().getSectionList(); -// sections.stream().filter(section -> Objects.equals(section.getDeviceStation(), deviceStation)).forEach(Section::faultUnlock); -// return; -// } -// throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("无效操作或连锁机重启过8分钟需手动解锁"); -// } -// -// @Override -// public void standEC(Simulation simulation, Stand stand) { -// if (stand.getEsp() == null) -// return; -// stand.getEsp().update(true); -// } -// -// @Override -// public void cancelStandEC(Simulation simulation, Stand stand) { -// if (stand.getEsp() == null) -// return; -// stand.getEsp().update(false); -// } -// -// @Override -// public void switchForceTurn(Simulation simulation, String switchCode, Boolean normal) { -// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); -// BusinessExceptionAssertEnum.SIMULATION_EXCEPTION_FOR_SHOW.assertTrue(!aSwitch.isLocked() && aSwitch.isSectionOccupied(), -// String.format("对%s强行转岔操作被联锁逻辑取消", aSwitch.getName())); -// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!aSwitch.isLocked(), String.format("道岔[%s]锁闭,无法转动", aSwitch.getCode())); -// if (normal == null) { -// normal = aSwitch.judgeTurnToNormal(); -// } -// switchService.controlSwitch(simulation, aSwitch, normal); -// } -// -// @Override -// public void axlePreReset(Simulation simulation, String sectionCode) { -// Section section = simulation.getRepository().getByCode(sectionCode, Section.class); -// Section axleSection = section.findAxleCounterSection(); -// //条件检查 -// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(axleSection != null && axleSection.isAxleCounter(), -// section.debugStr() + "不是计轴区段也不归属于任何计轴区段"); -// VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter(); -// if (!virtualAxleCounter.isOccupy()) -// Section.AxleFault.ARB.apply(axleSection); -// else -// virtualAxleCounter.preReset(); -// } -// -// @Override -// public void switchAxlePreReset(Simulation simulation, String switchCode) { -// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); -// aSwitch.setPreReset(true); -// } -// -// @Override -// public void switchSqueezeRecovery(Simulation simulation, String switchCode) { -// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); -// Switch.SwitchFault.SQUEEZE.fix(aSwitch); -// } -// -// @Override -// public void switchCommand(Simulation simulation, String switchCode, Boolean auto, Boolean reserve, Boolean normal) { -// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); -// if (auto != null) { -// aSwitch.setAuto(auto); -// } else { -// if (normal != null) { -// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!aSwitch.isAuto(), "道岔未处于人工模式"); -// if (normal) { -// switchService.turn2NormalPosition(simulation, aSwitch); -// } else { -// switchService.turn2ReversePosition(simulation, aSwitch); -// } -// } -// } -// if (reserve != null) { -// aSwitch.setDispatcherReserve(reserve); -// } -// } -// -// @Override -// public void initializeBlock(Simulation simulation, String switchCode) { -// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); -// aSwitch.setInit(true); -// } -// -// @Override -// public void initializeGuide(Simulation simulation, String signalCode) { -// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); -// signal.setInit(true); -// } -// -// @Override -// public void cancelGuideInitialization(Simulation simulation, String signalCode) { -// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); -// signal.setInit(false); -// } -// -// @Override -// public void axleReset(Simulation simulation, String sectionCode) { -// VirtualRealitySectionAxleCounter axle = getAxleCounterAndCheck4Reset(simulation, sectionCode); -// if (!axle.isOccupy()) -// return; -// axle.axleReset(); -// } -// -// @Override -// public void setOverlap(Simulation simulation, String signalCode, String overlapCode) { -// SimulationDataRepository repository = simulation.getRepository(); -// Signal signal = repository.getByCode(signalCode, Signal.class); -// RouteOverlap overlap = repository.getByCode(overlapCode, RouteOverlap.class); -// this.routeService.setOverlap(simulation, signal, overlap); -// } -// -// /** -// * 获取计轴器并为预复位/复位操作检查设备状态 -// */ -// private VirtualRealitySectionAxleCounter getAxleCounterAndCheck4Reset(Simulation simulation, String sectionCode) { -// Section section = simulation.getRepository().getByCode(sectionCode, Section.class); -// Section axleSection = section.findAxleCounterSection(); -// //条件检查 -// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(axleSection != null && axleSection.isAxleCounter(), -// section.debugStr() + "不是计轴区段也不归属于任何计轴区段"); -// VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter(); -// if (simulation.getRepository().getConfig().isStationPreResetBeforeAxlePreReset()) { -// Station deviceStation = axleSection.getDeviceStation(); -// BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(deviceStation, section.debugStr() + "没有所属集中站"); -// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(deviceStation.isPreReset(), deviceStation.debugStr() + "需处于预复位状态"); -// } -// return virtualAxleCounter; -// } -//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java index 8b25725ea..41e705a4f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java @@ -76,7 +76,7 @@ public class CiApiServiceImpl2 implements CiApiService { "信号机已经开启,无需重开信号机"); } Optional routeOptional = simulation.getRepository().getSettingRoutes().stream() - .filter(route -> route.getStart().equals(signal)).limit(1).findAny(); + .filter(route -> route.getStart().equals(signal)).findAny(); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(routeOptional.isPresent(), "信号机不是已排进路的始端信号机"); // settingRoute(simulation, routeOptional.get().getCode()); Route lockedRoute = signal.getLockedRoute(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java index 341c76081..f3a3c5598 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java @@ -10,12 +10,13 @@ public class CtcRepository { /** * key : stationCode */ - private List ctcStationRunPlanLogList = new ArrayList<>(); + private final List ctcStationRunPlanLogList = new ArrayList<>(); /** * 进路序列 */ private final Map routeSequenceMap = new HashMap<>(); + private final Map routeSequenceVOMap = new HashMap<>(); /** * 增加ctc行车日志信息 @@ -24,6 +25,7 @@ public class CtcRepository { */ public void addCtcStationRunPlanLoList(List ctcStationRunPlanLogList) { this.ctcStationRunPlanLogList.addAll(ctcStationRunPlanLogList); + generateRouteSequence(); } /** @@ -43,11 +45,40 @@ public class CtcRepository { public CtcStationRunPlanLog getRunPlan(String stationCode, String tripNumber) { CtcStationRunPlanLog plan = ctcStationRunPlanLogList.stream() .filter(p -> Objects.equals(p.getStation().getCode(), stationCode) && Objects.equals(p.getTripNumber(), tripNumber)) - .limit(1).findAny().orElse(null); + .findAny().orElse(null); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(plan); return plan; } + /** + * 用行车日志生成进路序列 + */ + public void generateRouteSequence() { + Map> stationLineMap = new HashMap<>(); + List lines = new ArrayList<>(); + for (CtcStationRunPlanLog plan : ctcStationRunPlanLogList) { + String stationCode = plan.getStation().getCode(); + CtcStationRunPlanLog.RunPlanItem arriveRunPlan = plan.getArriveRunPlan(); + if (arriveRunPlan != null) { + RouteSequence.Line line = new RouteSequence.Line(arriveRunPlan, false); + List stationLines = stationLineMap.computeIfAbsent(stationCode, (k) -> new ArrayList<>()); + stationLines.add(line); + lines.add(line); + } + CtcStationRunPlanLog.RunPlanItem departRunPlan = plan.getDepartRunPlan(); + if (departRunPlan != null) { + RouteSequence.Line line = new RouteSequence.Line(departRunPlan, true); + List stationLines = stationLineMap.computeIfAbsent(stationCode, (k) -> new ArrayList<>()); + stationLines.add(line); + lines.add(line); + } + } + + for (Map.Entry> entry : stationLineMap.entrySet()) { + routeSequenceMap.put(entry.getKey(), new RouteSequence(stationLineMap, lines)); + } + } + public RouteSequence.Line getRouteSequenceLine(String stationCode, String tripNumber, boolean departure) { RouteSequence routeSequence = routeSequenceMap.get(stationCode); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(routeSequence); @@ -56,5 +87,6 @@ public class CtcRepository { public void reset() { this.ctcStationRunPlanLogList.forEach(ctcStationRunPlanLog -> ctcStationRunPlanLog.reset()); + generateRouteSequence(); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/RouteSequence.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/RouteSequence.java index a3fe98fe1..e01381857 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/RouteSequence.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/RouteSequence.java @@ -7,10 +7,7 @@ import lombok.Getter; import lombok.Setter; import java.time.LocalTime; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 进路序列 @@ -18,17 +15,38 @@ import java.util.Map; @Getter @Setter public class RouteSequence { - private boolean onlyRead; + private boolean readOnly; /** * k - tripNumber */ - private final Map> tripLineMap = new HashMap<>(); + private final Map> tripLineMap; /** * 按时间排序 */ - private final List lines = new LinkedList<>(); + private final List lines; + + public RouteSequence(Map> tripLineMap, List lines) { + class LineComparator implements Comparator { + @Override + public int compare(RouteSequence.Line line, RouteSequence.Line t1) { + if (line == null) + return 1; + if (t1 == null) + return -1; + if (line.getPlanTime().isBefore(t1.getPlanTime())) + return -1; + return 1; + } + } + for (List list : tripLineMap.values()) { + list.sort(new LineComparator()); + } + this.tripLineMap = tripLineMap; + lines.sort(new LineComparator()); + this.lines = lines; + } public void addLine(Line line) { List tripLines = tripLineMap.computeIfAbsent(line.getTripNumber(), (k) -> new LinkedList<>()); @@ -43,7 +61,7 @@ public class RouteSequence { List lines = tripLineMap.get(tripNumber); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertCollectionNotEmpty(lines); Line l = lines.stream().filter(line -> departure == line.isDeparture()) - .limit(1).findAny().orElse(null); + .findAny().orElse(null); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(l); return l; } @@ -69,9 +87,8 @@ public class RouteSequence { } @Getter - public static class Line { - private String tripNumber; - private Section track; + public static class Line implements Comparable{ + CtcStationRunPlanLog.RunPlanItem item; /** * 是自触? */ @@ -83,5 +100,31 @@ public class RouteSequence { private LocalTime startTime; private LocalTime planTime; private Route route; + + public Line(CtcStationRunPlanLog.RunPlanItem item, boolean departure) { + this.item = item; + this.departure = departure; + this.planTime = item.getStationPlan().getArriveTime().minusMinutes(9); + Section track = getTrack(); + Route route = item.getStationDirection().getSignal().getRouteList().stream() + .filter(r -> Objects.equals(track, r.getLastRouteSection())) + .findAny().orElse(null); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(route, + String .format("车次[%s]的[%s]进路找不到", getTripNumber(), departure ? "发车" : "接车")); + this.route = route; + } + + public String getTripNumber() { + return this.item.getTripNumber(); + } + + public Section getTrack() { + return this.item.getTrackSection(); + } + + @Override + public int compareTo(Line line) { + return 0; + } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/PowerSupplyService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/PowerSupplyService.java index 64aa6a1b3..42296f527 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/PowerSupplyService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/PowerSupplyService.java @@ -31,7 +31,7 @@ public class PowerSupplyService { train.updatePowerSupplyStatus(true); continue; } - Optional first = catenaries.stream().filter(catenary -> catenary.isWithinRange(headPosition)).limit(1).findFirst(); + Optional first = catenaries.stream().filter(catenary -> catenary.isWithinRange(headPosition)).findFirst(); if (first.isPresent()) { Catenary catenary = first.get(); train.updatePowerSupplyStatus(catenary.isOn()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java index 5ac2eb0f6..1a6593938 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java @@ -441,7 +441,7 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation any = this.getSimulationMembers().stream() .filter(member -> member.getDevice() != null && Objects.equals(member.getDevice().getCode(), deviceCode)) - .limit(1).findAny(); + .findAny(); return any.orElse(null); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java index baaf6e87f..4ccf6b751 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java @@ -952,7 +952,7 @@ public class InterlockBuilder2 { Section section; if (ftb) { Optional
selectedSectionOptional = preferredSections.stream() - .filter(ns -> ns.isNormalStandTrack() && station.equals(ns.getStation())).limit(1).findAny(); //查询指定的站台轨 + .filter(ns -> ns.isNormalStandTrack() && station.equals(ns.getStation())).findAny(); //查询指定的站台轨 if (selectedSectionOptional.isPresent()) { section = selectedSectionOptional.get(); } else { //没有指定折返轨 @@ -965,7 +965,7 @@ public class InterlockBuilder2 { } } else { Optional
selectedSectionOptional = preferredSections.stream() - .filter(ns -> ns.isTurnBackTrack() && station.equals(ns.getStation())).limit(1).findAny(); + .filter(ns -> ns.isTurnBackTrack() && station.equals(ns.getStation())).findAny(); section = selectedSectionOptional.orElseGet(() -> station.getTurnBackList().get(0)); } return section; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/competition/CompetitionBO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/competition/CompetitionBO.java index f9ff5c1a8..d0572b877 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/competition/CompetitionBO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/competition/CompetitionBO.java @@ -1,8 +1,8 @@ package club.joylink.rtss.simulation.cbtc.competition; -import club.joylink.rtss.simulation.cbtc.script.ScriptBO; import club.joylink.rtss.constants.Client; import club.joylink.rtss.entity.CompetitionWithBLOBs; +import club.joylink.rtss.simulation.cbtc.script.ScriptBO; import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.vo.client.competition.*; import lombok.Getter; @@ -116,7 +116,7 @@ public class CompetitionBO { } public OperationStatisticVO.ItemVO findOperationStatisticItemByActionId(String actionId) { - Optional itemOptional = this.operationStatistic.getItems().stream().filter(item -> actionId.equals(item.getActionId())).limit(1).findFirst(); + Optional itemOptional = this.operationStatistic.getItems().stream().filter(item -> actionId.equals(item.getActionId())).findFirst(); if (itemOptional.isPresent()) { return itemOptional.get(); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java index c767925de..d6627caf5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java @@ -657,7 +657,6 @@ public class SimulationDataRepository { List collect = this.getSuperviseTrainList() .stream() .filter(trainInfo -> trainInfo.getTripNumber().equals(tripNumber)) - .limit(1) .collect(Collectors.toList()); if (CollectionUtils.isEmpty(collect)) { throw new SimulationException(SimulationExceptionType.System_Fault); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java index 6d8997d26..6c2e04ef2 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java @@ -945,7 +945,7 @@ public class Section extends DelayUnlockDevice { * 查询道岔计轴区段关联的岔心 */ private Section queryCross() { - return this.logicList.stream().filter(Section::isCross).limit(1).findAny().orElse(null); + return this.logicList.stream().filter(Section::isCross).findAny().orElse(null); } /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java b/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java index fb5510737..c600207b1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java @@ -51,7 +51,7 @@ public class UserSimulationStatsManager { return; } Set useInfos = userAndUseInfosMap.computeIfAbsent(userId, k -> new HashSet<>()); - Optional infoOptional = useInfos.stream().filter(info -> group.equals(info.getGroup())).limit(1).findFirst(); + Optional infoOptional = useInfos.stream().filter(info -> group.equals(info.getGroup())).findFirst(); if (infoOptional.isPresent()) { //如果记录已经存在 SimulationUseInfo useInfo = infoOptional.get(); useInfo.restart(); @@ -127,7 +127,7 @@ public class UserSimulationStatsManager { if (CollectionUtils.isEmpty(infos)) { return null; } else { - Optional optional = infos.stream().filter(info -> group.equals(info.getGroup())).limit(1).findFirst(); + Optional optional = infos.stream().filter(info -> group.equals(info.getGroup())).findFirst(); return optional.orElse(null); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/script/ScriptBO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/script/ScriptBO.java index 4e504ad34..366b46661 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/script/ScriptBO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/script/ScriptBO.java @@ -421,7 +421,7 @@ public class ScriptBO { public ScriptActionBO.Condition getActionCondition(String actionId) { if (!CollectionUtils.isEmpty(actionList)) { - Optional first = actionList.stream().filter(actionBO -> actionBO.getId().equals(actionId)).limit(1).findFirst(); + Optional first = actionList.stream().filter(actionBO -> actionBO.getId().equals(actionId)).findFirst(); if (first.isPresent()) { return first.get().getCondition(); } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilRouteLogicService.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilRouteLogicService.java index 6a0975bd6..4ee5b1f81 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilRouteLogicService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilRouteLogicService.java @@ -161,7 +161,7 @@ public class CilRouteLogicService { if (CollectionUtils.isEmpty(spList)) return true; return spList.stream().allMatch(sp -> cilRepository.getSwitchById(sp.getCommonSwitch().getId()).getPosition() == sp.getPosition()); - }).limit(1).findAny(); + }).findAny(); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(routeOptional.isPresent(), "无能够办理的进路"); commonRoute = routeOptional.get(); check4SetGuide(cilRepository, commonRoute);