消息推送——ATS构建下一发送消息问题修改

This commit is contained in:
walker-sheng 2021-04-23 15:23:08 +08:00
parent 0f64c9b2c3
commit 34f3c7a94b
2 changed files with 18 additions and 11 deletions

View File

@ -5,6 +5,7 @@ import club.joylink.rtss.simulation.rt.ATS.bo.*;
import club.joylink.rtss.simulation.rt.RtSimulationSubscribeTopic; import club.joylink.rtss.simulation.rt.RtSimulationSubscribeTopic;
import lombok.Getter; import lombok.Getter;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -78,19 +79,19 @@ public class AtsMessagePublisher extends SimulationMessagePublisher {
public Object getNextSendMessage() { public Object getNextSendMessage() {
HashMap<Object, Object> message = new HashMap<>(); HashMap<Object, Object> message = new HashMap<>();
if (!this.switchMap.isEmpty()) { if (!this.switchMap.isEmpty()) {
message.put("switch", this.switchMap.values()); message.put("switch", new ArrayList<>(this.switchMap.values()));
this.switchMap.clear(); this.switchMap.clear();
} }
if (!this.sectionMap.isEmpty()) { if (!this.sectionMap.isEmpty()) {
message.put("section", this.sectionMap.values()); message.put("section", new ArrayList<>(this.sectionMap.values()));
this.sectionMap.clear(); this.sectionMap.clear();
} }
if (!this.signalMap.isEmpty()) { if (!this.signalMap.isEmpty()) {
message.put("signal", this.signalMap.values()); message.put("signal", new ArrayList<>(this.signalMap.values()));
this.signalMap.clear(); this.signalMap.clear();
} }
if (!this.routeMap.isEmpty()) { if (!this.routeMap.isEmpty()) {
message.put("route", this.routeMap.values()); message.put("route", new ArrayList<>(this.routeMap.values()));
this.routeMap.clear(); this.routeMap.clear();
} }
if (message.isEmpty()) { if (message.isEmpty()) {

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.simulation.rt; package club.joylink.rtss.simulation.rt;
import club.joylink.rtss.constants.MapPrdTypeEnum; import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.MapService; import club.joylink.rtss.services.MapService;
import club.joylink.rtss.simulation.SimulationManager; import club.joylink.rtss.simulation.SimulationManager;
import club.joylink.rtss.simulation.cbtc.data.vo.SimulationVO; import club.joylink.rtss.simulation.cbtc.data.vo.SimulationVO;
@ -38,14 +39,19 @@ public class RtSimulationService {
MapVO mapVO = this.mapService.getMapDetail(mapId); MapVO mapVO = this.mapService.getMapDetail(mapId);
RtSimulationUser creator = new RtSimulationUser(userVO.getId().toString()); RtSimulationUser creator = new RtSimulationUser(userVO.getId().toString());
RtSimulation rtSimulation = new RtSimulation(SimulationIdGenerator.buildId(), creator); RtSimulation rtSimulation = new RtSimulation(SimulationIdGenerator.buildId(), creator);
rtSimulation.mapVO = mapVO;
this.loadData(rtSimulation, mapVO);
this.simulationManager.save(rtSimulation); this.simulationManager.save(rtSimulation);
this.srdLogicService.addJobs(rtSimulation); try {
this.cilLogicService.addJobs(rtSimulation); rtSimulation.mapVO = mapVO;
this.atsLogicService.addJobs(rtSimulation); this.loadData(rtSimulation, mapVO);
this.initSimulationMember(rtSimulation); this.srdLogicService.addJobs(rtSimulation);
this.initCreatorPlayMember(rtSimulation); this.cilLogicService.addJobs(rtSimulation);
this.atsLogicService.addJobs(rtSimulation);
this.initSimulationMember(rtSimulation);
this.initCreatorPlayMember(rtSimulation);
} catch (Exception e) {
this.simulationManager.destroy(rtSimulation.getId());
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(String.format("仿真初始化失败"), e);
}
simulationManager.start(rtSimulation.getId()); simulationManager.start(rtSimulation.getId());
return rtSimulation; return rtSimulation;
} }