Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-xzb1
This commit is contained in:
commit
c601eae73f
@ -4,10 +4,7 @@ import club.joylink.rtss.services.training2.Training2RuleService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -24,15 +21,21 @@ public class TrainingRuleController {
|
||||
|
||||
|
||||
/**
|
||||
* 根据地图生成
|
||||
* @param groupId
|
||||
* @return
|
||||
* 根据仿真生成
|
||||
*/
|
||||
@PostMapping("{groupId}/generate")
|
||||
public List<String> generateTraining(@PathVariable String 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")
|
||||
public void test(@PathVariable String groupId){
|
||||
training2RuleService.test(groupId);
|
||||
|
@ -98,6 +98,17 @@ public class Training2RuleService {
|
||||
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) {
|
||||
Simulation simulation = simulationManager.getById(groupId , Simulation.class);
|
||||
Switch aSwitch = simulation.getRepository().getByCode("W32728", Switch.class);
|
||||
|
@ -263,11 +263,9 @@ public enum BgSceneStatusRule {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Signal signal = (Signal) mapElement;
|
||||
List<Route> fltRouteList = signal.getRouteList().stream().filter(Route::isFlt).collect(Collectors.toList());
|
||||
fltRouteList.forEach(route -> {
|
||||
openRouteDirect(simulation, route);
|
||||
route.setFleetMode(true);
|
||||
});
|
||||
Route route = signal.getRouteList().get(0);
|
||||
openRouteDirect(simulation, route);
|
||||
route.setFleetMode(true);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
|
@ -22,9 +22,8 @@ public enum MapDeviceRule {
|
||||
List<Station> stationList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList()
|
||||
.stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation() && !s.isDepot())
|
||||
.sorted(Comparator.comparing(MapStationNewVO::getSn))
|
||||
.map(MapStationNewVO::getCode)
|
||||
.map(code -> simulation.getRepository().getByCode(code, Station.class))
|
||||
.collect(Collectors.toList());
|
||||
.map(MapStationNewVO::getCode).map(code -> simulation.getRepository().getByCode(code, Station.class))
|
||||
.filter(Station::isInterlock).collect(Collectors.toList());
|
||||
return generateRandomElement(stationList, NUMBER);
|
||||
}
|
||||
},
|
||||
@ -38,7 +37,7 @@ public enum MapDeviceRule {
|
||||
Station firstStation = stationList.get(0);
|
||||
Station lastStation = stationList.get(stationList.size() - 1);
|
||||
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;
|
||||
// 去除第一个与最后一个站的站台
|
||||
if (firstStation.equals(stand.getStation()) || lastStation.equals(stand.getStation())) {
|
||||
@ -47,7 +46,6 @@ public enum MapDeviceRule {
|
||||
if (!stand.isVisible() || !stand.hasDoor() || stand.isSmall()) { // 特殊站台
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}).sorted(Comparator.comparingInt(stand -> stand.getStation().getSn())).collect(Collectors.toList());
|
||||
return MapDeviceRule.generateRandomElement(standList, NUMBER);
|
||||
@ -63,7 +61,7 @@ public enum MapDeviceRule {
|
||||
Station firstStation = stationList.get(0);
|
||||
Station lastStation = stationList.get(stationList.size() - 1);
|
||||
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;
|
||||
// 去除第一个与最后一个站的站台
|
||||
if (firstStation.equals(stand.getStation()) || lastStation.equals(stand.getStation())) {
|
||||
@ -88,10 +86,12 @@ public enum MapDeviceRule {
|
||||
if (route.getStart() == null || route.getStart().isVirtual()) {
|
||||
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;
|
||||
}
|
||||
if (route.getStart().getDeviceStation()!= null && route.getStart().getDeviceStation().isDepot()) {
|
||||
if (route.getStart().getDeviceStation() != null
|
||||
&& (route.getStart().getDeviceStation().isDepot() || !route.getStart().getDeviceStation().isInterlock())) {
|
||||
return false;
|
||||
}
|
||||
if (route.getSectionList().size() < 2) {
|
||||
@ -122,6 +122,9 @@ public enum MapDeviceRule {
|
||||
.filter(aSwitch -> {
|
||||
if (aSwitch.getDeviceStation() != null && aSwitch.getDeviceStation().isDepot())
|
||||
return false;
|
||||
if (!aSwitch.getDeviceStation().isInterlock()) {
|
||||
return false;
|
||||
}
|
||||
if (aSwitch.isSingleLock()) {
|
||||
return false;
|
||||
}
|
||||
@ -137,7 +140,7 @@ public enum MapDeviceRule {
|
||||
.filter(aSwitch -> {
|
||||
if (aSwitch.getDeviceStation() != null && aSwitch.getDeviceStation().isDepot())
|
||||
return false;
|
||||
if (!aSwitch.getDeviceStation().isHasControlMode()) {
|
||||
if (!aSwitch.getDeviceStation().isHasControlMode() || !aSwitch.getDeviceStation().isInterlock()) {
|
||||
return false;
|
||||
}
|
||||
if (aSwitch.isSingleLock()) {
|
||||
@ -169,14 +172,20 @@ public enum MapDeviceRule {
|
||||
if (route.getStart().getStation() != null && route.getStart().getStation().isDepot()) {
|
||||
return false;
|
||||
}
|
||||
if (route.getStart().getStation() != null && !route.getStart().getStation().isInterlock()) {
|
||||
return false;
|
||||
}
|
||||
if (route.getStart().getDeviceStation() != null && route.getStart().getDeviceStation().isDepot()) {
|
||||
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 true;
|
||||
}).map(route -> route.getStart()).distinct().collect(Collectors.toList());
|
||||
}).map(Route::getStart).distinct().collect(Collectors.toList());
|
||||
return MapDeviceRule.generateRandomElement(signalList, NUMBER);
|
||||
}
|
||||
},
|
||||
@ -214,7 +223,16 @@ public enum MapDeviceRule {
|
||||
public List<Station> filterMapDeviceList(Simulation simulation) {
|
||||
//找到所有有控制模式的车站
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -262,6 +280,9 @@ public enum MapDeviceRule {
|
||||
if (deviceStation != null && deviceStation.isDepot()) {
|
||||
return false;
|
||||
}
|
||||
if (deviceStation != null && !deviceStation.isInterlock()) {
|
||||
return false;
|
||||
}
|
||||
Section axleCounterSection = section.findAxleCounterSection();
|
||||
if (axleCounterSection != null) {
|
||||
Station axleDeviceStation = axleCounterSection.getDeviceStation();
|
||||
|
Loading…
Reference in New Issue
Block a user