修改实训生成bug;修正加载实训时的角色选择逻辑

This commit is contained in:
joylink_zhangsai 2022-09-30 17:32:24 +08:00
parent 15780897a6
commit 689a6f433a
9 changed files with 106 additions and 105 deletions

View File

@ -19,10 +19,10 @@ import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.training.*;
import club.joylink.rtss.vo.client.trainingUsage.UserTrainingListVO;
import club.joylink.rtss.vo.client.trainingUsage.UserTrainingQueryVO;
import club.joylink.rtss.vo.client.trainingUsage.UserTrainingVO;
import club.joylink.rtss.vo.client.training.*;
import club.joylink.rtss.vo.map.MapGraphDataNewVO;
import club.joylink.rtss.vo.map.graph.MapAutomaticRouteButtonVO;
import club.joylink.rtss.vo.map.graph.MapCycleButtonVO;
@ -764,7 +764,7 @@ public class TrainingV1Service implements ITrainingV1Service {
}
}
if (deviceCode != null) {
SimulationMember member = simulation.findMemberByDeviceCode(deviceCode);
SimulationMember member = simulation.findMemberByRoleAndDeviceCode(SimulationMember.Type.STATION_SUPERVISOR, deviceCode);
if (member != null) {
memberManager.playRole(simulation, accountVO.getId(), member.getId());
}

View File

@ -42,10 +42,11 @@ public interface GeneratorNew {
* @param config
* @param mapDevice
* @param operateDefinitionVO
* @param setDeviceCode
* @return
*/
default TrainingNewVO build(GenerateConfig config, Simulation simulation, MapElement mapDevice, Object mapButton,
OperateDefinitionVO operateDefinitionVO) {
OperateDefinitionVO operateDefinitionVO, boolean setDeviceCode) {
boolean railway = simulation.getRepository().getConfig().isRailway();
// 现地设置站控
if (BusinessConsts.MapPrd.PrdType.Type01.equals(config.getPrdType())) {
@ -74,9 +75,10 @@ public interface GeneratorNew {
TrainingNewVO trainingVO = new TrainingNewVO(config, operateDefinitionVO);
// 设置每一步操作的设备
List<OperateStepVO> stepList = operateDefinitionVO.getStepVOList();
if (setDeviceCode) {
if (stepList.stream().anyMatch(s -> StringUtils.hasText(s.getCodeType()))) {
stepList.forEach(s -> {
if (StringUtils.hasText(s.getCodeType()) && s.getDeviceCode() == null) {
if (StringUtils.hasText(s.getCodeType())) {
//根据codeType对应类型 取当前设备相关的设备code进行设置,目前仅信号机进路操作支持
switch (TrainingConsts.CodeType.valueOf(s.getCodeType())) {
case SIGNAL:
@ -137,15 +139,14 @@ public interface GeneratorNew {
});
} else {
if (MapElement.DeviceType.ROUTE.equals(mapDevice.getDeviceType())) {
if (!railway) {
stepList.get(0).setDeviceCode(((Route) mapDevice).getStart().getCode());
}
} else {
if (!"bar".equals(stepList.get(0).getDeviceType())) { //为处理转为站控实训操作正确但结束实训判为错误的bug
stepList.get(0).setDeviceCode(mapDevice.getCode());
}
}
}
}
Map<String, OperatePlaceholderVO> placeholderVOMap = operateDefinitionVO.getPlaceholderVOMap();
// 设置定位
if (MapElement.DeviceType.ROUTE.equals(mapDevice.getDeviceType())) {

View File

@ -52,7 +52,7 @@ public class ControlGeneratorNew implements GeneratorNew {
// 其他操作不生成
continue;
}
trainingVOList.add(build(config, simulation, station, null,operateDefinitionVO));
trainingVOList.add(build(config, simulation, station, null,operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}

View File

@ -176,7 +176,7 @@ public class SectionGeneratorNew implements GeneratorNew {
// 其他操作不生成
continue;
}
trainingVOList.add(this.build(config, simulation, section, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, section, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}

View File

@ -44,12 +44,12 @@ public class SignalGeneratorNew implements GeneratorNew {
simulation.getBuildParams().getMap().getGraphDataNew().getCycleButtonList()
.stream().filter(mapCycleButtonVO -> mapCycleButtonVO.getCycleCode().equals(cycle.getCode()))
.forEach(button -> {
trainingVOList.add(this.build(config, simulation, cycle, button, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, cycle, button, operateDefinitionVO, true));
this.resetSimulation(simulation);
});
continue;
} else {
trainingVOList.add(this.build(config, simulation, cycle, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, cycle, null, operateDefinitionVO, true));
}
// 仿真重置
this.resetSimulation(simulation);
@ -67,12 +67,12 @@ public class SignalGeneratorNew implements GeneratorNew {
simulation.getBuildParams().getMap().getGraphDataNew().getCycleButtonList()
.stream().filter(mapCycleButtonVO -> mapCycleButtonVO.getCycleCode().equals(cycle.getCode()))
.forEach(button -> {
trainingVOList.add(this.build(config, simulation, cycle, button, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, cycle, button, operateDefinitionVO, true));
this.resetSimulation(simulation);
});
continue;
} else {
trainingVOList.add(this.build(config, simulation, cycle, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, cycle, null, operateDefinitionVO, true));
}
// 仿真重置
this.resetSimulation(simulation);
@ -106,7 +106,7 @@ public class SignalGeneratorNew implements GeneratorNew {
if (route.isGuide()) { // 引导进路跳过
continue;
}
trainingVOList.add(this.build(config, simulation, route, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, route, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}
@ -131,7 +131,7 @@ public class SignalGeneratorNew implements GeneratorNew {
stepVOList.get(0).setTip(String.format("鼠标左键点击【信号机%s】", route.getStart().getShowName()));
stepVOList.get(1).setTip(String.format("鼠标左键点击【信号机%s】", route.getDestination().getShowName()));
}
trainingVOList.add(this.build(config, simulation, route, mapRouteNewVO, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, route, mapRouteNewVO, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}
@ -148,7 +148,7 @@ public class SignalGeneratorNew implements GeneratorNew {
if (repository.getConfig().isSignalHumanControlBeforeSetAtsControlOrCIAutoTrigger()) {
routeList.forEach(route -> route.setAtsControl(false));
}
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO, true));
this.resetSimulation(simulation);
continue;
} else {
@ -165,7 +165,7 @@ public class SignalGeneratorNew implements GeneratorNew {
route.setAtsControl(false);
}
}
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
@ -176,7 +176,7 @@ public class SignalGeneratorNew implements GeneratorNew {
case Signal_Close_Auto_Setting: {
if (!CollectionUtils.isEmpty(routeList)) {
if (routeLikeHa1 || operateDefinitionVO.onlyOperateSignal()) {
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO, true));
this.resetSimulation(simulation);
continue;
} else {
@ -189,7 +189,7 @@ public class SignalGeneratorNew implements GeneratorNew {
if (route.isGuide()) { // 引导进路跳过
continue;
}
trainingVOList.add(this.build(config, simulation, route, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, route, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}
@ -212,7 +212,7 @@ public class SignalGeneratorNew implements GeneratorNew {
continue;
}
deviceStatusModifyTool.openRouteDirect(simulation, route);
trainingVOList.add(this.build(config, simulation, route, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, route, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}
@ -233,7 +233,7 @@ public class SignalGeneratorNew implements GeneratorNew {
stepVOList.get(1).setTip(String.format("鼠标左键点击【信号机%s】", route.getStart().getShowName()));
}
deviceStatusModifyTool.openRouteDirect(simulation, route);
trainingVOList.add(this.build(config, simulation, route, mapRouteNewVO, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, route, mapRouteNewVO, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}
@ -248,7 +248,7 @@ public class SignalGeneratorNew implements GeneratorNew {
deviceStatusModifyTool.closeSignalDirectly(route.getStart());
deviceStatusModifyTool.loadManualTrainOfGroup(simulation, "001", signal.getSection(), signal.isRight());
// todo 在接近区段设置一辆列车
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}
@ -262,7 +262,7 @@ public class SignalGeneratorNew implements GeneratorNew {
continue;
}
this.deviceStatusModifyTool.openRouteDirect(simulation, route);
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}
@ -279,7 +279,7 @@ public class SignalGeneratorNew implements GeneratorNew {
this.deviceStatusModifyTool.openRouteDirect(simulation, route);
this.deviceStatusModifyTool.closeSignalDirectly(route.getStart());
signal.setForbidden(true);
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}
@ -298,7 +298,7 @@ public class SignalGeneratorNew implements GeneratorNew {
for (Route route : routeList) {
route.setAtsControl(false);
}
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
} else {
@ -307,7 +307,7 @@ public class SignalGeneratorNew implements GeneratorNew {
continue;
}
route.setAtsControl(false);
trainingVOList.add(this.build(config, simulation, route, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, route, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}
@ -329,12 +329,12 @@ public class SignalGeneratorNew implements GeneratorNew {
simulation.getBuildParams().getMap().getGraphDataNew().getAutomaticRouteButtonList()
.stream().filter(automaticRouteButtonVO -> automaticRouteButtonVO.getAutomaticRouteCode().equals(route.getCode()))
.forEach(button -> {
trainingVOList.add(this.build(config, simulation, route.getStart(), button, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, route.getStart(), button, operateDefinitionVO, true));
this.resetSimulation(simulation);
});
continue;
} else {
trainingVOList.add(this.build(config, simulation, route.getStart(), null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, route.getStart(), null, operateDefinitionVO, true));
}
// 仿真重置
this.resetSimulation(simulation);
@ -355,12 +355,12 @@ public class SignalGeneratorNew implements GeneratorNew {
simulation.getBuildParams().getMap().getGraphDataNew().getAutomaticRouteButtonList()
.stream().filter(automaticRouteButtonVO -> automaticRouteButtonVO.getAutomaticRouteCode().equals(route.getCode()))
.forEach(button -> {
trainingVOList.add(this.build(config, simulation, signal, button, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, signal, button, operateDefinitionVO, true));
this.resetSimulation(simulation);
});
continue;
} else {
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO, true));
}
// 仿真重置
this.resetSimulation(simulation);
@ -378,13 +378,13 @@ public class SignalGeneratorNew implements GeneratorNew {
for (Route route : arcRouteList) {
route.setCiControl(true);
}
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
} else {
for (Route route : arcRouteList) {
route.setCiControl(true);
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}
@ -415,11 +415,11 @@ public class SignalGeneratorNew implements GeneratorNew {
}
deviceStatusModifyTool.loadManualTrainOfGroup(simulation, "001", signal.getSection(), signal.isRight());
if (operateDefinitionVO.onlyOperateSignal()) {
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO, true));
this.resetSimulation(simulation);
break;
}
trainingVOList.add(this.build(config, simulation, route, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, route, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}
@ -483,7 +483,7 @@ public class SignalGeneratorNew implements GeneratorNew {
// 其他操作不生成
continue;
}
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}

View File

@ -35,7 +35,7 @@ public class SpeedLimitGeneratorNew implements GeneratorNew {
case Cancel_All_Limit_Speed: // 取消全线临时限速
List<MapTempSpeedLimitVO> tempSpeedLimitList = simulation.getBuildParams().getMap().getGraphDataNew().getTempSpeedLimitList();
tempSpeedLimitList.forEach(mapTempSpeedLimitVO -> {
trainingVOList.add(this.build(config, simulation,null,mapTempSpeedLimitVO, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation,null,mapTempSpeedLimitVO, operateDefinitionVO, true));
this.resetSimulation(simulation);
});
break;
@ -44,7 +44,7 @@ public class SpeedLimitGeneratorNew implements GeneratorNew {
}
@Override
public TrainingNewVO build(GenerateConfig config, Simulation simulation, MapElement nullableDevice, Object mapButton, OperateDefinitionVO operateDefinitionVO) {
public TrainingNewVO build(GenerateConfig config, Simulation simulation, MapElement nullableDevice, Object mapButton, OperateDefinitionVO operateDefinitionVO, boolean setDeviceCode) {
// 实训基本信息
TrainingNewVO trainingVO = new TrainingNewVO(config, operateDefinitionVO);

View File

@ -104,7 +104,7 @@ public class StandGeneratorNew implements GeneratorNew {
// 其他操作不生成
continue;
}
trainingVOList.add(this.build(config, simulation, stand,null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, stand,null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}

View File

@ -153,7 +153,7 @@ public class StationGeneratorNew implements GeneratorNew {
simulation.getBuildParams().getMap().getGraphDataNew().getTbStrategyList()
.stream().filter(turnBackStrategyO -> turnBackStrategyO.getStationCode().equals(station.getCode()))
.forEach(button -> {
trainingVOList.add(this.build(config, simulation, station,button, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, station,button, operateDefinitionVO, true));
this.resetSimulation(simulation);
});
continue;
@ -181,7 +181,7 @@ public class StationGeneratorNew implements GeneratorNew {
List<Switch> collect = switchList.stream().filter(
aSwitch -> Objects.equals(aSwitch.getDeviceStation(), station)).collect(Collectors.toList());
collect.forEach(aSwitch -> aSwitch.setFault(Switch.SwitchFault.SPLIT));
trainingVOList.add(this.build(config, simulation, station, button, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, station, button, operateDefinitionVO, true));
this.resetSimulation(simulation);
});
continue;
@ -210,7 +210,7 @@ public class StationGeneratorNew implements GeneratorNew {
station.setControlMode(Station.ControlMode.Local);
List<Switch> switchList1 = simulation.getRepository().getSwitchList();
switchList1.stream().filter(aSwitch -> Objects.equals(aSwitch.getDeviceStation(), station)).forEach(aSwitch -> aSwitch.setSingleLock(true));
trainingVOList.add(this.build(config, simulation, station, button, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, station, button, operateDefinitionVO, true));
this.resetSimulation(simulation);
});
continue;
@ -219,7 +219,7 @@ public class StationGeneratorNew implements GeneratorNew {
station.setControlMode(Station.ControlMode.Local);
List<Switch> switchList1 = simulation.getRepository().getSwitchList();
switchList1.stream().filter(aSwitch -> Objects.equals(aSwitch.getDeviceStation(), station)).forEach(aSwitch -> aSwitch.setSingleLock(true));
trainingVOList.add(this.build(config, simulation, station, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, station, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
break;
@ -235,7 +235,7 @@ public class StationGeneratorNew implements GeneratorNew {
station.setControlMode(Station.ControlMode.Local);
List<Switch> switchList1 = simulation.getRepository().getSwitchList();
switchList1.stream().filter(aSwitch -> Objects.equals(aSwitch.getDeviceStation(), station)).forEach(aSwitch -> aSwitch.setSingleLock(true));
trainingVOList.add(this.build(config, simulation, station, button, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, station, button, operateDefinitionVO, true));
this.resetSimulation(simulation);
});
return;
@ -244,7 +244,7 @@ public class StationGeneratorNew implements GeneratorNew {
station.setControlMode(Station.ControlMode.Local);
List<Switch> switchList1 = simulation.getRepository().getSwitchList();
switchList1.stream().filter(aSwitch -> Objects.equals(aSwitch.getDeviceStation(), station)).forEach(aSwitch -> aSwitch.setSingleLock(true));
trainingVOList.add(this.build(config, simulation, station, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, station, null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}
@ -304,7 +304,7 @@ public class StationGeneratorNew implements GeneratorNew {
// 其他操作不生成
continue;
}
trainingVOList.add(build(config, simulation, station,null, operateDefinitionVO));
trainingVOList.add(build(config, simulation, station,null, operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}

View File

@ -125,7 +125,7 @@ public class SwitchGeneratorNew implements GeneratorNew {
// 其他操作不生成
continue;
}
trainingVOList.add(this.build(config, simulation, aSwitch, null,operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, aSwitch, null,operateDefinitionVO, true));
// 仿真重置
this.resetSimulation(simulation);
}