【地图设备筛选、背景设置修改】

This commit is contained in:
weizhihong 2022-12-06 08:57:33 +08:00
parent 3ff942aaa4
commit 47987c9040
2 changed files with 57 additions and 31 deletions

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.vo.training2.rule; package club.joylink.rtss.vo.training2.rule;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.RunLevel; import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
@ -236,12 +237,10 @@ public enum BgSceneStatusRule {
public String doHandle(Simulation simulation, MapElement mapElement) { public String doHandle(Simulation simulation, MapElement mapElement) {
Section section = (Section) mapElement; Section section = (Section) mapElement;
section.setRouteLock(true); section.setRouteLock(true);
section.setLockRight(true); if (section.isCross()) {
if(!CollectionUtils.isEmpty(section.getLogicList())) { section.getLogicList().get(0).setRouteLock(true);
section.getLogicList().forEach(s -> { } else if (section.isShowLogic()) {
s.setRouteLock(true); section.getLogicList().forEach(s -> s.setRouteLock(true));
s.setLockRight(true);
});
} }
return getBgScene(simulation); return getBgScene(simulation);
} }
@ -285,7 +284,7 @@ public enum BgSceneStatusRule {
public String doHandle(Simulation simulation, MapElement mapElement) { public String doHandle(Simulation simulation, MapElement mapElement) {
Section section = (Section) mapElement; Section section = (Section) mapElement;
section.setSpeedUpLimit(5); section.setSpeedUpLimit(5);
return null; return getBgScene(simulation);
} }
}, },
SECTION_CONFIRM_AXIS_VALID_BG_SCENE("设置计轴生效背景") { SECTION_CONFIRM_AXIS_VALID_BG_SCENE("设置计轴生效背景") {
@ -325,7 +324,7 @@ public enum BgSceneStatusRule {
VirtualRealityTrain train = (VirtualRealityTrain) simulation.getRepository().getVrDeviceMap().values().stream() VirtualRealityTrain train = (VirtualRealityTrain) simulation.getRepository().getVrDeviceMap().values().stream()
.filter(o -> o instanceof VirtualRealityTrain).findFirst().get(); .filter(o -> o instanceof VirtualRealityTrain).findFirst().get();
BgSceneStatusRule.trainOnline(simulation, train, section, stand.isRight()); BgSceneStatusRule.trainOnline(simulation, train, section, stand.isRight());
return null; return getBgScene(simulation);
} }
}, },
/** /**
@ -362,7 +361,13 @@ public enum BgSceneStatusRule {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement) { public String doHandle(Simulation simulation, MapElement mapElement) {
Stand stand = (Stand) 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); return getBgScene(simulation);
} }
}, },

View File

@ -4,10 +4,12 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.vo.map.graph.MapStationNewVO; import club.joylink.rtss.vo.map.graph.MapStationNewVO;
import lombok.Getter; import lombok.Getter;
import org.springframework.util.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Getter @Getter
@ -65,45 +67,32 @@ public enum MapDeviceRule {
SECTION_LIST("区段列表") { SECTION_LIST("区段列表") {
@Override @Override
public List<Section> filterMapDeviceList(Simulation simulation) { public List<Section> filterMapDeviceList(Simulation simulation) {
List<Route> routeList = ROUTE_LIST.filterMapDeviceList(simulation); List<Section> sectionList = querySectionListByFunction(simulation, Section::isAxleCounterSection);
List<Section> sectionList = new ArrayList<>(100);
routeList.forEach(route -> sectionList.addAll(route.getSectionList()));
return generateRandomElement(sectionList, 2); return generateRandomElement(sectionList, 2);
} }
}, },
SECTION_STAND_TURN_BACK_LIST("折返区段列表") { SECTION_LOGIC_LIST("逻辑区段列表") {
@Override @Override
public List<Section> filterMapDeviceList(Simulation simulation) { public List<Section> filterMapDeviceList(Simulation simulation) {
List<Section> sectionList = simulation.getRepository().getSectionList().stream() List<Section> sectionList = querySectionListByFunction(simulation, Section::isLogicSection);
.filter(section -> section.isStandTrack() && section.isTurnBackTrack()) return generateRandomElement(sectionList, 2);
.collect(Collectors.toList());
return MapDeviceRule.generateRandomElement(sectionList, 2);
} }
}, },
SECTION_NO_AXLE_COUNTER_LIST("非计轴区段列表") { SECTION_PHYSICAL_LIST("物理区段列表") {
@Override @Override
public List<Section> filterMapDeviceList(Simulation simulation) { public List<Section> filterMapDeviceList(Simulation simulation) {
List<String> stationCodeList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList() List<Section> sectionList = querySectionListByFunction(simulation, Section::isAxleCounterSection);
.stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode)
.collect(Collectors.toList());
List<Section> sectionList = simulation.getRepository().getSectionList().stream()
.filter(section -> stationCodeList.contains(section.getDeviceStation().getCode()) && !section.isAxleCounter())
.collect(Collectors.toList());
return generateRandomElement(sectionList, 2); return generateRandomElement(sectionList, 2);
} }
}, },
SECTION_AXLE_COUNTER_LIST("道岔计轴区段列表") { SECTION_AXLE_COUNTER_LIST("道岔计轴区段列表") {
@Override @Override
public List<Section> filterMapDeviceList(Simulation simulation) { public List<Section> filterMapDeviceList(Simulation simulation) {
List<String> stationCodeList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList() List<Section> sectionList = querySectionListByFunction(simulation, Section::isSwitchAxleCounterSection);
.stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode)
.collect(Collectors.toList());
List<Section> sectionList = simulation.getRepository().getSectionList().stream()
.filter(section -> stationCodeList.contains(section.getDeviceStation().getCode()) && section.isAxleCounter())
.collect(Collectors.toList());
return generateRandomElement(sectionList, 2); return generateRandomElement(sectionList, 2);
} }
} },
; ;
private String description; private String description;
@ -133,4 +122,36 @@ public enum MapDeviceRule {
} }
return givenList; return givenList;
} }
/**
* 筛选符合条件的方法
* @param simulation 仿真
* @param filterFunction 筛选条件
* @return 返回区段列表
*/
private static List<Section> querySectionListByFunction(Simulation simulation, Function<Section, Boolean> 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());
}
} }