【实训加载到某步出现提示BUG】

【角色替换扮演置NULL问题】
【信号机增加引导关键道岔属性】
This commit is contained in:
weizhihong 2023-05-31 15:20:43 +08:00
parent 4e5e83202c
commit a1a9929f4d
5 changed files with 62 additions and 6 deletions

View File

@ -523,6 +523,7 @@ public class Training2Service {
throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "实训不存在");
}
Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
loadTrainingPre(simulation);
// 重置仿真状态
// groupSimulationService.planOver(group);
simulationService.reset(group);
@ -603,6 +604,7 @@ public class Training2Service {
* 加载实训数据
*/
private void loadTraining(Simulation simulation, DraftTraining2WithBLOBs draftTraining2, LoginUserInfoVO loginUserInfoVO) {
loadTrainingPre(simulation);
// 没有背景不做加载加载的时候不做背景加载开始的时候重新加载背景即可
if (!StringUtils.isEmpty(draftTraining2.getBgSceneJson())) {
groupSimulationService.loadScenes(simulation.getId(), draftTraining2.getBgSceneJson());
@ -623,6 +625,17 @@ public class Training2Service {
simulationLifeCycleService.pause(simulation);
}
/**
* 仿真加载实训时前置清空方法
* @param simulation 仿真
*/
private void loadTrainingPre(Simulation simulation) {
if (simulation.getTraining2() != null) { // 如果仿真存在旧的实训
removeTrainingJob(simulation);
clearJumpStep(simulation);
}
}
/**
* 判断实训步骤是否完成
*/
@ -674,7 +687,7 @@ public class Training2Service {
}
}
// 发送步骤提示信息,需要跳过步骤不发消息
if (!step.isPrompt() && !simulation.getTraining2().isJumpStep(step)) {
if (!step.isPrompt() && !simulation.getTraining2().haveJumpStep()) {
step.setPrompt(true); // 标识已发送过消息
applicationContext.publishEvent(new SimulationStepTipEvent(this, simulation, step));
}
@ -929,8 +942,10 @@ public class Training2Service {
addTrainingJob(simulation, training2);
// 启动仿真
simulationLifeCycleService.resume(simulation);
// 发送开始消息
trainingStatusMessage(simulation, 1);
// 发送开始消息,跳转不发送消息
if (!training2.haveJumpStep()) {
trainingStatusMessage(simulation, 1);
}
}
/**
@ -938,8 +953,10 @@ public class Training2Service {
*/
private void clearJumpStep(Simulation simulation) {
simulation.updateSpeed(Simulation.MIN_SPEED);
simulation.getTraining2().setJumpToStep(null);
simulation.getTraining2().finish();
if (simulation.getTraining2() != null) {
simulation.getTraining2().setJumpToStep(null);
simulation.getTraining2().finish();
}
}
/**

View File

@ -185,8 +185,11 @@ public class SimulationManager {
String oldMemberId = simulationUser.getMemberId();
if (oldMemberId != null) {
SimulationMember old = simulation.getSimulationMemberById(oldMemberId);
this.memberPlayChange(simulation, old, null);
if (Objects.equals(old.getUserId(), userId)) { // 这里做同用户对比防止角色替换时置NULL问题
this.memberPlayChange(simulation, old, null);
}
}
log.info("memberId:" + memberId + ";userId:" + userId);
this.memberPlayChange(simulation, simulationMember, simulationUser);
} else {
this.memberPlayChange(simulation, simulationMember, null);

View File

@ -7,6 +7,7 @@ import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.support.StationTurnBackStrategyOption;
import club.joylink.rtss.simulation.cbtc.data.vr.*;
import club.joylink.rtss.vo.map.MapCISwitchVO;
import club.joylink.rtss.vo.map.MapGraphDataNewVO;
import club.joylink.rtss.vo.map.MapVO;
import club.joylink.rtss.vo.map.RealLineConfigVO;
@ -114,6 +115,8 @@ public class MapDeviceBuilder {
MapDeviceBuilder.buildCatenary(graphData, elementMap, errMsgList, mapDataBuildResult.getCatenaryMap());
//应答器
MapDeviceBuilder.buildResponderDataRef(graphData, elementMap, errMsgList, mapDataBuildResult.getSectionRespondersMap());
// 设置信号机引导关键道岔信息
initSignalGuideKeySwitch(graphData, elementMap, errMsgList);
if (mapDataBuildResult.getErrMsgList().isEmpty()) {
Map<String, Set<Section>> sectionArriveMap = MapDeviceBuilder.buildNormalStandTrackAdjoinSections(mapDataBuildResult.getDeviceMap());
mapDataBuildResult.setSectionArriveNearMap(sectionArriveMap);
@ -1568,4 +1571,26 @@ public class MapDeviceBuilder {
private static boolean isCross(String type) {
return Objects.equals(type, BusinessConsts.Section.SectionType.Type05);
}
/**
* 初始化信号机的引导关键道岔设置作用于引导信号的开放
* @param graphData 地图信息
* @param elementMap 设备信息
* @param errMsgList 错误提示信息
*/
private static void initSignalGuideKeySwitch(MapGraphDataNewVO graphData, Map<String, MapElement> elementMap, List<String> errMsgList) {
graphData.getSignalList().stream().filter(s -> !CollectionUtils.isEmpty(s.getGuideKeySwitchList())).forEach(s -> {
List<SwitchElement> switchElementList = new ArrayList<>(s.getGuideKeySwitchList().size());
for (MapCISwitchVO ciSwitchVO : s.getGuideKeySwitchList()) {
Switch aSwitch = (Switch) elementMap.get(ciSwitchVO.getSwitchCode());
if (Objects.isNull(aSwitch)) {
errMsgList.add(String.format("编码为[%s]的道岔不存在", ciSwitchVO.getSwitchCode()));
} else {
switchElementList.add(new SwitchElement(aSwitch, ciSwitchVO.isNormal()));
}
}
Signal signal = (Signal) elementMap.get(s.getCode());
signal.setGuideKeySwitchList(switchElementList);
});
}
}

View File

@ -159,6 +159,11 @@ public class Signal extends DelayUnlockDevice {
*/
private List<Signal> replaceSignals;
/**
* 信号机引导关键道岔列表
*/
private List<SwitchElement> guideKeySwitchList;
// ------------------状态属性---------------------
private int mode;

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.vo.map.graph;
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
import club.joylink.rtss.vo.map.MapCISwitchVO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
@ -202,6 +203,11 @@ public class MapSignalNewVO {
*/
private String srCode;
/**
* 引导关键道岔列表
*/
private List<MapCISwitchVO> guideKeySwitchList;
@JsonIgnore
public boolean isShunting() {
return Signal.SignalType.SHUNTING.equals(this.type);