Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-xzb1

This commit is contained in:
xzb 2022-12-08 15:44:09 +08:00
commit c601eae73f
4 changed files with 57 additions and 24 deletions

View File

@ -4,10 +4,7 @@ import club.joylink.rtss.services.training2.Training2RuleService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A; import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@ -24,15 +21,21 @@ public class TrainingRuleController {
/** /**
* 根据地图生成 * 根据仿真生成
* @param groupId
* @return
*/ */
@PostMapping("{groupId}/generate") @PostMapping("{groupId}/generate")
public List<String> generateTraining(@PathVariable String groupId){ public List<String> generateTraining(@PathVariable String groupId){
return training2RuleService.generateTrainingByRule(groupId); return training2RuleService.generateTrainingByRule(groupId);
} }
/**
* 根据地图与功能生成
*/
@PostMapping("{mapId}/function/{functionId}")
public List<String> generateTrainingByMapIdAndFunId(@PathVariable Long mapId, @PathVariable Long functionId) {
return training2RuleService.generateTrainingByMapIdAndFunId(mapId, functionId);
}
@PostMapping("{groupId}/test") @PostMapping("{groupId}/test")
public void test(@PathVariable String groupId){ public void test(@PathVariable String groupId){
training2RuleService.test(groupId); training2RuleService.test(groupId);

View File

@ -98,6 +98,17 @@ public class Training2RuleService {
return Arrays.asList("生成完成!"); return Arrays.asList("生成完成!");
} }
/**
*
* @param mapId
* @param functionId
* @return
*/
public List<String> generateTrainingByMapIdAndFunId(Long mapId, Long functionId) {
String groupId = simulationService.querySimulationByMapIdAndMapFunction(mapId, functionId);
return generateTrainingByRule(groupId);
}
public void test(String groupId) { public void test(String groupId) {
Simulation simulation = simulationManager.getById(groupId , Simulation.class); Simulation simulation = simulationManager.getById(groupId , Simulation.class);
Switch aSwitch = simulation.getRepository().getByCode("W32728", Switch.class); Switch aSwitch = simulation.getRepository().getByCode("W32728", Switch.class);

View File

@ -263,11 +263,9 @@ public enum BgSceneStatusRule {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement) { public String doHandle(Simulation simulation, MapElement mapElement) {
Signal signal = (Signal) mapElement; Signal signal = (Signal) mapElement;
List<Route> fltRouteList = signal.getRouteList().stream().filter(Route::isFlt).collect(Collectors.toList()); Route route = signal.getRouteList().get(0);
fltRouteList.forEach(route -> { openRouteDirect(simulation, route);
openRouteDirect(simulation, route); route.setFleetMode(true);
route.setFleetMode(true);
});
return getBgScene(simulation); return getBgScene(simulation);
} }
}, },

View File

@ -22,9 +22,8 @@ public enum MapDeviceRule {
List<Station> stationList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList() List<Station> stationList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList()
.stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation() && !s.isDepot()) .stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation() && !s.isDepot())
.sorted(Comparator.comparing(MapStationNewVO::getSn)) .sorted(Comparator.comparing(MapStationNewVO::getSn))
.map(MapStationNewVO::getCode) .map(MapStationNewVO::getCode).map(code -> simulation.getRepository().getByCode(code, Station.class))
.map(code -> simulation.getRepository().getByCode(code, Station.class)) .filter(Station::isInterlock).collect(Collectors.toList());
.collect(Collectors.toList());
return generateRandomElement(stationList, NUMBER); return generateRandomElement(stationList, NUMBER);
} }
}, },
@ -38,7 +37,7 @@ public enum MapDeviceRule {
Station firstStation = stationList.get(0); Station firstStation = stationList.get(0);
Station lastStation = stationList.get(stationList.size() - 1); Station lastStation = stationList.get(stationList.size() - 1);
List<Stand> standList = simulation.getRepository().getStandList().stream().filter(stand -> { List<Stand> standList = simulation.getRepository().getStandList().stream().filter(stand -> {
if (stand.getStation() != null && stand.getStation().isDepot()) if (stand.getStation() != null && (stand.getStation().isDepot() || !stand.getStation().isInterlock()))
return false; return false;
// 去除第一个与最后一个站的站台 // 去除第一个与最后一个站的站台
if (firstStation.equals(stand.getStation()) || lastStation.equals(stand.getStation())) { if (firstStation.equals(stand.getStation()) || lastStation.equals(stand.getStation())) {
@ -47,7 +46,6 @@ public enum MapDeviceRule {
if (!stand.isVisible() || !stand.hasDoor() || stand.isSmall()) { // 特殊站台 if (!stand.isVisible() || !stand.hasDoor() || stand.isSmall()) { // 特殊站台
return false; return false;
} }
return true; return true;
}).sorted(Comparator.comparingInt(stand -> stand.getStation().getSn())).collect(Collectors.toList()); }).sorted(Comparator.comparingInt(stand -> stand.getStation().getSn())).collect(Collectors.toList());
return MapDeviceRule.generateRandomElement(standList, NUMBER); return MapDeviceRule.generateRandomElement(standList, NUMBER);
@ -63,7 +61,7 @@ public enum MapDeviceRule {
Station firstStation = stationList.get(0); Station firstStation = stationList.get(0);
Station lastStation = stationList.get(stationList.size() - 1); Station lastStation = stationList.get(stationList.size() - 1);
List<Stand> standList = simulation.getRepository().getStandList().stream().filter(stand -> { List<Stand> standList = simulation.getRepository().getStandList().stream().filter(stand -> {
if (stand.getStation() != null && stand.getStation().isDepot()) if (stand.getStation() != null && (stand.getStation().isDepot() || !stand.getStation().isInterlock()))
return false; return false;
// 去除第一个与最后一个站的站台 // 去除第一个与最后一个站的站台
if (firstStation.equals(stand.getStation()) || lastStation.equals(stand.getStation())) { if (firstStation.equals(stand.getStation()) || lastStation.equals(stand.getStation())) {
@ -88,10 +86,12 @@ public enum MapDeviceRule {
if (route.getStart() == null || route.getStart().isVirtual()) { if (route.getStart() == null || route.getStart().isVirtual()) {
return false; return false;
} }
if (route.getStart().getStation()!= null && route.getStart().getStation().isDepot()) { if (route.getStart().getStation() != null
&& (route.getStart().getStation().isDepot() || !route.getStart().getStation().isInterlock())) {
return false; return false;
} }
if (route.getStart().getDeviceStation()!= null && route.getStart().getDeviceStation().isDepot()) { if (route.getStart().getDeviceStation() != null
&& (route.getStart().getDeviceStation().isDepot() || !route.getStart().getDeviceStation().isInterlock())) {
return false; return false;
} }
if (route.getSectionList().size() < 2) { if (route.getSectionList().size() < 2) {
@ -122,6 +122,9 @@ public enum MapDeviceRule {
.filter(aSwitch -> { .filter(aSwitch -> {
if (aSwitch.getDeviceStation() != null && aSwitch.getDeviceStation().isDepot()) if (aSwitch.getDeviceStation() != null && aSwitch.getDeviceStation().isDepot())
return false; return false;
if (!aSwitch.getDeviceStation().isInterlock()) {
return false;
}
if (aSwitch.isSingleLock()) { if (aSwitch.isSingleLock()) {
return false; return false;
} }
@ -137,7 +140,7 @@ public enum MapDeviceRule {
.filter(aSwitch -> { .filter(aSwitch -> {
if (aSwitch.getDeviceStation() != null && aSwitch.getDeviceStation().isDepot()) if (aSwitch.getDeviceStation() != null && aSwitch.getDeviceStation().isDepot())
return false; return false;
if (!aSwitch.getDeviceStation().isHasControlMode()) { if (!aSwitch.getDeviceStation().isHasControlMode() || !aSwitch.getDeviceStation().isInterlock()) {
return false; return false;
} }
if (aSwitch.isSingleLock()) { if (aSwitch.isSingleLock()) {
@ -169,14 +172,20 @@ public enum MapDeviceRule {
if (route.getStart().getStation() != null && route.getStart().getStation().isDepot()) { if (route.getStart().getStation() != null && route.getStart().getStation().isDepot()) {
return false; return false;
} }
if (route.getStart().getStation() != null && !route.getStart().getStation().isInterlock()) {
return false;
}
if (route.getStart().getDeviceStation() != null && route.getStart().getDeviceStation().isDepot()) { if (route.getStart().getDeviceStation() != null && route.getStart().getDeviceStation().isDepot()) {
return false; return false;
} }
if (route.isArs() || route.isGuide()) { if (route.getStart().getDeviceStation() != null && !route.getStart().getDeviceStation().isInterlock()) {
return false;
}
if ((!route.isArs()) || route.isGuide()) {
return false; return false;
} }
return true; return true;
}).map(route -> route.getStart()).distinct().collect(Collectors.toList()); }).map(Route::getStart).distinct().collect(Collectors.toList());
return MapDeviceRule.generateRandomElement(signalList, NUMBER); return MapDeviceRule.generateRandomElement(signalList, NUMBER);
} }
}, },
@ -214,7 +223,16 @@ public enum MapDeviceRule {
public List<Station> filterMapDeviceList(Simulation simulation) { public List<Station> filterMapDeviceList(Simulation simulation) {
//找到所有有控制模式的车站 //找到所有有控制模式的车站
List<Station> stationList = simulation.getRepository().getStationList().stream() List<Station> stationList = simulation.getRepository().getStationList().stream()
.filter(Station::isHasControlMode).collect(Collectors.toList()); .filter(s -> s.isHasControlMode() && s.isInterlock()).collect(Collectors.toList());
return MapDeviceRule.generateRandomElement(stationList, NUMBER);
}
},
INTERLOCK_STATION_LIST("联锁车站列表") {
@Override
public List<Station> filterMapDeviceList(Simulation simulation) {
//找到所有有控制模式的车站
List<Station> stationList = simulation.getRepository().getStationList().stream()
.filter(Station::isInterlock).collect(Collectors.toList());
return MapDeviceRule.generateRandomElement(stationList, NUMBER); return MapDeviceRule.generateRandomElement(stationList, NUMBER);
} }
} }
@ -262,6 +280,9 @@ public enum MapDeviceRule {
if (deviceStation != null && deviceStation.isDepot()) { if (deviceStation != null && deviceStation.isDepot()) {
return false; return false;
} }
if (deviceStation != null && !deviceStation.isInterlock()) {
return false;
}
Section axleCounterSection = section.findAxleCounterSection(); Section axleCounterSection = section.findAxleCounterSection();
if (axleCounterSection != null) { if (axleCounterSection != null) {
Station axleDeviceStation = axleCounterSection.getDeviceStation(); Station axleDeviceStation = axleCounterSection.getDeviceStation();