修改地铁仿真初始化逻辑

This commit is contained in:
joylink_zhangsai 2022-12-02 11:26:52 +08:00
parent d285b24d66
commit ddaf91647a
3 changed files with 11 additions and 9 deletions

View File

@ -56,10 +56,12 @@ public class SimulationServiceImpl implements SimulationService {
@Override
public String createSimulation(long mapId, Long mapFunctionId, SimulationWorkParamVO workParamVO, @NonNull LoginUserInfoVO loginUserInfoVO) {
//获取仿真工作服务
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(workParamVO.getType());
//创建仿真
String simulationId = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), mapId);
Simulation simulation = initService.create(mapId, workParamVO, loginUserInfoVO, simulationId);
simulation.setMapFunctionId(mapFunctionId); // 保存功能ID
simulation.setMapFunctionId(mapFunctionId);
LoginUserInfoVO loginUserInfo = simulation.getBuildParams().getLoginUserInfo();
if (Objects.nonNull(loginUserInfo)) {
simulation.setCreatorId(loginUserInfo.getAccountVO().getIdStr());
@ -67,13 +69,9 @@ public class SimulationServiceImpl implements SimulationService {
simulation.setProjectVO(loginUserInfo.getProjectInfo());
}
// 删除旧仿真保存新仿真
club.joylink.rtss.simulation.Simulation oldSimulation = simulationManager.queryByCreatorId(simulation.getCreatorId());
if (oldSimulation != null) {
groupSimulationService.clearSimulation(oldSimulation.getId());
}
simulation.setMessageSender(this.defaultMessageSender); // 设置默认的消息发布器
simulation.loadModule(); // 加载通用模块
simulationManager.destroy(simulation.getId());
groupSimulationService.clearSimulation(simulation.getId());
simulationManager.saveNew(simulation);
initService.loadData(simulation);

View File

@ -89,7 +89,11 @@ public class VirtualRealityScreenDoor extends ControllableVrDevice<VirtualRealit
@Override
protected void doTurn() {
switch (getCommand()) {
Operation command = getCommand();
if (command == null) {
return;
}
switch (command) {
case K:{
if (this.isOpen2End())
setRemain(0);
@ -105,7 +109,7 @@ public class VirtualRealityScreenDoor extends ControllableVrDevice<VirtualRealit
break;
}
default:
throw new IllegalStateException("Unexpected value: " + getCommand());
throw new IllegalStateException("Unexpected value: " + command);
}
}

View File

@ -201,7 +201,7 @@ public class MetroSimulationWorkServiceImpl implements SimulationWorkService {
@Override
public void init(Simulation simulation) {
// 初始化设备状态
deviceStatusService.init(simulation);
this.reset(simulation);
// 加载仿真可选项
SimulationWorkParamVO workParamVO = simulation.getBuildParams().getWorkParamVO();
Map<SimulationWorkParamVO.Item, String> itemMap = workParamVO.getItemMap();