修改股道视图数据发送bug
This commit is contained in:
parent
f8a67b7182
commit
1d968dabc5
@ -1,10 +1,7 @@
|
|||||||
package club.joylink.rtss.simulation.cbtc.CTC;
|
package club.joylink.rtss.simulation.cbtc.CTC;
|
||||||
|
|
||||||
import club.joylink.rtss.simulation.cbtc.CTC.data.*;
|
import club.joylink.rtss.simulation.cbtc.CTC.data.*;
|
||||||
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.CtcStationRunPlanLogVO;
|
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.*;
|
||||||
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.RailDispatchCommandVO;
|
|
||||||
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.RouteSequenceVO;
|
|
||||||
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.TrackViewVO;
|
|
||||||
import club.joylink.rtss.simulation.cbtc.CTC.service.CTCService;
|
import club.joylink.rtss.simulation.cbtc.CTC.service.CTCService;
|
||||||
import club.joylink.rtss.simulation.cbtc.CTC.service.CtcDispatchCommandService;
|
import club.joylink.rtss.simulation.cbtc.CTC.service.CtcDispatchCommandService;
|
||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
@ -63,11 +60,29 @@ public class CTCLogicLoop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessageWhenSubscribeCtc(Simulation simulation, String userId) {
|
public void sendMessageWhenSubscribeCtc(Simulation simulation, String userId) {
|
||||||
sendAllTrackViewMessage(simulation, userId);
|
sendAllBusyBoardMessage(simulation, userId);
|
||||||
sendAllRouteSequenceMessage(simulation, userId);
|
|
||||||
sendUnreadDispatchCommand(simulation, userId);
|
sendUnreadDispatchCommand(simulation, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendAllBusyBoardMessage(Simulation simulation, String userId) {
|
||||||
|
CtcRepository ctcRepository = simulation.getCtcRepository();
|
||||||
|
List<BusyBoardVO> list = new ArrayList<>();
|
||||||
|
Map<String, TrackViewVO> trackViewVOMap = ctcRepository.getTrackViewVOMap();
|
||||||
|
Map<String, RouteSequenceVO> routeSequenceVOMap = ctcRepository.getRouteSequenceVOMap();
|
||||||
|
HashSet<String> stationCodes = new HashSet<>(trackViewVOMap.keySet());
|
||||||
|
stationCodes.addAll(routeSequenceVOMap.keySet());
|
||||||
|
for (String stationCode : stationCodes) {
|
||||||
|
TrackViewVO trackViewVO = trackViewVOMap.get(stationCode);
|
||||||
|
RouteSequenceVO routeSequenceVO = routeSequenceVOMap.get(stationCode);
|
||||||
|
BusyBoardVO busyBoardVO = new BusyBoardVO(stationCode, routeSequenceVO, trackViewVO);
|
||||||
|
list.add(busyBoardVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
SocketMessageVO<List<BusyBoardVO>> message
|
||||||
|
= SocketMessageFactory.buildCtcBusyBoardMessage(simulation.getId(), list);
|
||||||
|
stompMessageService.sendToUser(userId, message);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送该成员所属受令方的未读的调度命令
|
* 发送该成员所属受令方的未读的调度命令
|
||||||
*/
|
*/
|
||||||
@ -206,21 +221,8 @@ public class CTCLogicLoop {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendAllTrackViewMessage(Simulation simulation, String userId) {
|
|
||||||
CtcRepository ctcRepository = simulation.getCtcRepository();
|
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
|
||||||
for (TrackViewVO vo : ctcRepository.getTrackViewVOMap().values()) {
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
|
||||||
map.put("stationCode", vo.getStationCode());
|
|
||||||
map.put("trackView", vo);
|
|
||||||
list.add(map);
|
|
||||||
}
|
|
||||||
SocketMessageVO<Object> message = SocketMessageFactory.buildCtcBusyBoardMessage(simulation.getId(), list);
|
|
||||||
stompMessageService.sendToUser(userId, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendTrackViewMessage(Simulation simulation) {
|
private void sendTrackViewMessage(Simulation simulation) {
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
List<BusyBoardVO> list = new ArrayList<>();
|
||||||
CtcRepository ctcRepository = simulation.getCtcRepository();
|
CtcRepository ctcRepository = simulation.getCtcRepository();
|
||||||
Map<String, TrackView> trackViewMap = ctcRepository.getTrackViewMap();
|
Map<String, TrackView> trackViewMap = ctcRepository.getTrackViewMap();
|
||||||
Map<String, TrackViewVO> trackViewVOMap = ctcRepository.getTrackViewVOMap();
|
Map<String, TrackViewVO> trackViewVOMap = ctcRepository.getTrackViewVOMap();
|
||||||
@ -237,27 +239,15 @@ public class CTCLogicLoop {
|
|||||||
changedViewVO = trackViewVO.updateAndReturnChanged(trackView);
|
changedViewVO = trackViewVO.updateAndReturnChanged(trackView);
|
||||||
}
|
}
|
||||||
if (changedViewVO != null) {
|
if (changedViewVO != null) {
|
||||||
Map<String, Object> map = new HashMap<>();
|
BusyBoardVO busyBoardVO = new BusyBoardVO(stationCode, null, changedViewVO);
|
||||||
map.put("stationCode", stationCode);
|
list.add(busyBoardVO);
|
||||||
map.put("trackView", changedViewVO);
|
|
||||||
list.add(map);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SocketMessageVO<Object> message = SocketMessageFactory.buildCtcBusyBoardMessage(simulation.getId(), list);
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
|
SocketMessageVO<List<BusyBoardVO>> message
|
||||||
}
|
= SocketMessageFactory.buildCtcBusyBoardMessage(simulation.getId(), list);
|
||||||
|
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
|
||||||
private void sendAllRouteSequenceMessage(Simulation simulation, String userId) {
|
|
||||||
CtcRepository ctcRepository = simulation.getCtcRepository();
|
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
|
||||||
for (RouteSequenceVO vo : ctcRepository.getRouteSequenceVOMap().values()) {
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
|
||||||
map.put("stationCode", vo.getStationCode());
|
|
||||||
map.put("routeSequence", vo);
|
|
||||||
list.add(map);
|
|
||||||
}
|
}
|
||||||
SocketMessageVO<Object> message = SocketMessageFactory.buildCtcBusyBoardMessage(simulation.getId(), list);
|
|
||||||
stompMessageService.sendToUser(userId, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -267,30 +257,29 @@ public class CTCLogicLoop {
|
|||||||
CtcRepository ctcRepository = simulation.getCtcRepository();
|
CtcRepository ctcRepository = simulation.getCtcRepository();
|
||||||
Map<String, RouteSequence> routeSequenceMap = ctcRepository.getRouteSequenceMap();
|
Map<String, RouteSequence> routeSequenceMap = ctcRepository.getRouteSequenceMap();
|
||||||
Map<String, RouteSequenceVO> routeSequenceVOMap = ctcRepository.getRouteSequenceVOMap();
|
Map<String, RouteSequenceVO> routeSequenceVOMap = ctcRepository.getRouteSequenceVOMap();
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
List<BusyBoardVO> list = new ArrayList<>();
|
||||||
if (CollectionUtils.isEmpty(routeSequenceVOMap)) {
|
if (CollectionUtils.isEmpty(routeSequenceVOMap)) {
|
||||||
for (RouteSequence routeSequence : routeSequenceMap.values()) {
|
for (RouteSequence routeSequence : routeSequenceMap.values()) {
|
||||||
RouteSequenceVO routeSequenceVO = new RouteSequenceVO(routeSequence);
|
RouteSequenceVO routeSequenceVO = new RouteSequenceVO(routeSequence);
|
||||||
routeSequenceVOMap.put(routeSequenceVO.getStationCode(), routeSequenceVO);
|
routeSequenceVOMap.put(routeSequenceVO.getStationCode(), routeSequenceVO);
|
||||||
Map<String, Object> map = new HashMap<>();
|
BusyBoardVO busyBoardVO = new BusyBoardVO(routeSequenceVO.getStationCode(), routeSequenceVO, null);
|
||||||
map.put("stationCode", routeSequenceVO.getStationCode());
|
list.add(busyBoardVO);
|
||||||
map.put("routeSequence", routeSequenceVO);
|
|
||||||
list.add(map);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (RouteSequence routeSequence : routeSequenceMap.values()) {
|
for (RouteSequence routeSequence : routeSequenceMap.values()) {
|
||||||
RouteSequenceVO vo = routeSequenceVOMap.get(routeSequence.getStationCode());
|
RouteSequenceVO vo = routeSequenceVOMap.get(routeSequence.getStationCode());
|
||||||
RouteSequenceVO changed = vo.updateAndReturnChanged(routeSequence);
|
RouteSequenceVO changed = vo.updateAndReturnChanged(routeSequence);
|
||||||
if (changed != null) {
|
if (changed != null) {
|
||||||
Map<String, Object> map = new HashMap<>();
|
BusyBoardVO busyBoardVO = new BusyBoardVO(vo.getStationCode(), changed, null);
|
||||||
map.put("stationCode", vo.getStationCode());
|
list.add(busyBoardVO);
|
||||||
map.put("routeSequence", changed);
|
|
||||||
list.add(map);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SocketMessageVO<Object> message = SocketMessageFactory.buildCtcBusyBoardMessage(simulation.getId(), list);
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
|
SocketMessageVO<List<BusyBoardVO>> message
|
||||||
|
= SocketMessageFactory.buildCtcBusyBoardMessage(simulation.getId(), list);
|
||||||
|
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addJobs(Simulation simulation) {
|
public void addJobs(Simulation simulation) {
|
||||||
@ -300,8 +289,6 @@ public class CTCLogicLoop {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 行车区段运行计划下发
|
* 行车区段运行计划下发
|
||||||
*
|
|
||||||
* @param simulation 仿真
|
|
||||||
*/
|
*/
|
||||||
public void sendZoneRunPlanSend(Simulation simulation) {
|
public void sendZoneRunPlanSend(Simulation simulation) {
|
||||||
List<CtcEffectRepository.CtcStageRunPlanRepository.CtcStageRunPlanVO> allList = simulation.getCtcRepository().getCtcEffectRepository().getChangeStageRunPlan();
|
List<CtcEffectRepository.CtcStageRunPlanRepository.CtcStageRunPlanVO> allList = simulation.getCtcRepository().getCtcEffectRepository().getChangeStageRunPlan();
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
package club.joylink.rtss.simulation.cbtc.CTC.data;
|
|
||||||
|
|
||||||
public class BusyBoard {
|
|
||||||
|
|
||||||
}
|
|
@ -158,7 +158,7 @@ public class CtcRepository {
|
|||||||
/**
|
/**
|
||||||
* 构建占线板股道视图数据
|
* 构建占线板股道视图数据
|
||||||
*/
|
*/
|
||||||
private void buildTrackViewData(Simulation simulation) {
|
public void buildTrackViewData(Simulation simulation) {
|
||||||
for (Station station : simulation.getRepository().getStationList()) {
|
for (Station station : simulation.getRepository().getStationList()) {
|
||||||
trackViewMap.put(station.getCode(), new TrackView(station));
|
trackViewMap.put(station.getCode(), new TrackView(station));
|
||||||
}
|
}
|
||||||
@ -391,4 +391,14 @@ public class CtcRepository {
|
|||||||
.exception(String.format("[id:%s]的票据不存在", ticketId)));
|
.exception(String.format("[id:%s]的票据不存在", ticketId)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateTrackView(String stationCode, String oldTrackCode, String oldTripNumber, RouteSequence.Line routeSequenceLine) {
|
||||||
|
TrackView trackView = getTrackView(stationCode);
|
||||||
|
trackView.remove(oldTrackCode, oldTripNumber, routeSequenceLine);
|
||||||
|
if (routeSequenceLine.isDeparture()) {
|
||||||
|
trackView.addDepartureLine(routeSequenceLine);
|
||||||
|
} else {
|
||||||
|
trackView.addReceivingLine(routeSequenceLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,6 +201,16 @@ public class RouteSequence {
|
|||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
private CtcStationRunPlanLog.RunPlanItem item;
|
private CtcStationRunPlanLog.RunPlanItem item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车次号
|
||||||
|
*/
|
||||||
|
private String tripNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 股道
|
||||||
|
*/
|
||||||
|
private Section track;
|
||||||
/**
|
/**
|
||||||
* 是自触?
|
* 是自触?
|
||||||
*/
|
*/
|
||||||
@ -229,6 +239,8 @@ public class RouteSequence {
|
|||||||
Line(String id, CtcStationRunPlanLog.RunPlanItem item, boolean departure, LocalTime startTime, LocalTime planTime, Route route) {
|
Line(String id, CtcStationRunPlanLog.RunPlanItem item, boolean departure, LocalTime startTime, LocalTime planTime, Route route) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.item = item;
|
this.item = item;
|
||||||
|
this.track = item == null ? null : item.getTrackSection();
|
||||||
|
this.tripNumber = item == null ? null : item.getTripNumber();
|
||||||
this.departure = departure;
|
this.departure = departure;
|
||||||
this.startTime = startTime;
|
this.startTime = startTime;
|
||||||
this.planTime = planTime;
|
this.planTime = planTime;
|
||||||
@ -243,14 +255,6 @@ public class RouteSequence {
|
|||||||
return departure ? "-->" + item.getStation().getName() : item.getStation().getName() + "-->";
|
return departure ? "-->" + item.getStation().getName() : item.getStation().getName() + "-->";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTripNumber() {
|
|
||||||
return this.item.getTripNumber();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Section getTrack() {
|
|
||||||
return this.item.getTrackSection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTrackName() {
|
public String getTrackName() {
|
||||||
Section track = getTrack();
|
Section track = getTrack();
|
||||||
if (track == null) {
|
if (track == null) {
|
||||||
@ -277,7 +281,21 @@ public class RouteSequence {
|
|||||||
return route == null ? null : route.getCode();
|
return route == null ? null : route.getCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateRoute() {
|
public void update() {
|
||||||
|
updateTripNumber();
|
||||||
|
updateTrack();
|
||||||
|
updateRoute();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTripNumber() {
|
||||||
|
this.tripNumber = item == null ? null : item.getTripNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTrack() {
|
||||||
|
this.track = item == null ? null : item.getTrackSection();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateRoute() {
|
||||||
boolean right = isRight();
|
boolean right = isRight();
|
||||||
Signal startSignal;
|
Signal startSignal;
|
||||||
Signal endSignal;
|
Signal endSignal;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package club.joylink.rtss.simulation.cbtc.CTC.data;
|
package club.joylink.rtss.simulation.cbtc.CTC.data;
|
||||||
|
|
||||||
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
|
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||||
@ -75,6 +76,14 @@ public class TrackView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void remove(String trackCode, String tripNumber, RouteSequence.Line routeSequenceLine) {
|
||||||
|
Map<String, Line> tnLineMap = this.trackLineMap.get(trackCode);
|
||||||
|
if (tnLineMap != null) {
|
||||||
|
Line line = tnLineMap.get(tripNumber);
|
||||||
|
line.remove(routeSequenceLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public static class Line {
|
public static class Line {
|
||||||
@ -274,6 +283,14 @@ public class TrackView {
|
|||||||
return "图定终到";
|
return "图定终到";
|
||||||
return departureRoute.getItem().getPlanTimeStr();
|
return departureRoute.getItem().getPlanTimeStr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void remove(RouteSequence.Line routeSequenceLine) {
|
||||||
|
if (Objects.equals(routeSequenceLine, this.receivingRoute)) {
|
||||||
|
receivingRoute = null;
|
||||||
|
} else if (Objects.equals(routeSequenceLine, this.departureRoute)) {
|
||||||
|
departureRoute = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Process {
|
public enum Process {
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.CTC.data.vo;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 占线板消息
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public class BusyBoardVO {
|
||||||
|
private String stationCode;
|
||||||
|
|
||||||
|
private RouteSequenceVO routeSequence;
|
||||||
|
|
||||||
|
private TrackViewVO trackView;
|
||||||
|
|
||||||
|
public BusyBoardVO(String stationCode, RouteSequenceVO routeSequence, TrackViewVO trackView) {
|
||||||
|
this.stationCode = stationCode;
|
||||||
|
this.routeSequence = routeSequence;
|
||||||
|
this.trackView = trackView;
|
||||||
|
}
|
||||||
|
}
|
@ -27,6 +27,8 @@ public class RouteSequenceVO {
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private final Map<String, LineVO> idLineMap;
|
private final Map<String, LineVO> idLineMap;
|
||||||
|
|
||||||
|
private Set<String> deletedLineIds;
|
||||||
|
|
||||||
public RouteSequenceVO() {
|
public RouteSequenceVO() {
|
||||||
lines = new ArrayList<>();
|
lines = new ArrayList<>();
|
||||||
idLineMap = new HashMap<>();
|
idLineMap = new HashMap<>();
|
||||||
@ -50,17 +52,26 @@ public class RouteSequenceVO {
|
|||||||
this.idLineMap.put(line.getId(), line);
|
this.idLineMap.put(line.getId(), line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeLines(Set<String> ids) {
|
||||||
|
for (String id : ids) {
|
||||||
|
idLineMap.remove(id);
|
||||||
|
}
|
||||||
|
lines.removeIf(lineVO -> ids.contains(lineVO.getTripNumber()));
|
||||||
|
}
|
||||||
|
|
||||||
public RouteSequenceVO updateAndReturnChanged(RouteSequence routeSequence) {
|
public RouteSequenceVO updateAndReturnChanged(RouteSequence routeSequence) {
|
||||||
RouteSequenceVO routeSequenceVO = new RouteSequenceVO();
|
RouteSequenceVO changedRsVO = new RouteSequenceVO();
|
||||||
boolean change = false;
|
boolean change = false;
|
||||||
if (!Objects.equals(readOnly, routeSequence.isReadOnly())) {
|
if (!Objects.equals(readOnly, routeSequence.isReadOnly())) {
|
||||||
change = true;
|
change = true;
|
||||||
readOnly = routeSequence.isReadOnly();
|
readOnly = routeSequence.isReadOnly();
|
||||||
routeSequenceVO.setReadOnly(readOnly);
|
changedRsVO.setReadOnly(readOnly);
|
||||||
}
|
}
|
||||||
List<LineVO> lines = routeSequenceVO.getLines();
|
List<LineVO> lineVOS = changedRsVO.getLines();
|
||||||
|
Set<String> deletedLineIds = new HashSet<>(this.idLineMap.keySet());
|
||||||
|
changedRsVO.setDeletedLineIds(deletedLineIds);
|
||||||
for (RouteSequence.Line line : routeSequence.getLines()) {
|
for (RouteSequence.Line line : routeSequence.getLines()) {
|
||||||
// TODO: 2022/6/14 需要考虑修改股道之后,对应的进路序列删除的逻辑
|
deletedLineIds.remove(line.getId());
|
||||||
if (line.getRoute() == null) {
|
if (line.getRoute() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -69,16 +80,20 @@ public class RouteSequenceVO {
|
|||||||
change = true;
|
change = true;
|
||||||
vo = new LineVO(line);
|
vo = new LineVO(line);
|
||||||
addLine(vo);
|
addLine(vo);
|
||||||
lines.add(vo);
|
lineVOS.add(vo);
|
||||||
} else {
|
} else {
|
||||||
LineVO changed = vo.updateAndReturnChanged(line);
|
LineVO changed = vo.updateAndReturnChanged(line);
|
||||||
if (changed != null) {
|
if (changed != null) {
|
||||||
change = true;
|
change = true;
|
||||||
lines.add(changed);
|
lineVOS.add(changed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return change ? routeSequenceVO : null;
|
if (!deletedLineIds.isEmpty()) {
|
||||||
|
removeLines(deletedLineIds);
|
||||||
|
change = true;
|
||||||
|
}
|
||||||
|
return change ? changedRsVO : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -18,7 +18,11 @@ public class TrackViewVO {
|
|||||||
|
|
||||||
private Map<String, Map<String, LineVO>> trackLineMap;
|
private Map<String, Map<String, LineVO>> trackLineMap;
|
||||||
|
|
||||||
/** 被删除的数据 */
|
/**
|
||||||
|
* 被删除的数据
|
||||||
|
* k - trackCode
|
||||||
|
* v - tripNumber
|
||||||
|
*/
|
||||||
private Map<String, Set<String>> deletedMap;
|
private Map<String, Set<String>> deletedMap;
|
||||||
|
|
||||||
public TrackViewVO(TrackView view) {
|
public TrackViewVO(TrackView view) {
|
||||||
@ -59,8 +63,8 @@ public class TrackViewVO {
|
|||||||
|
|
||||||
public TrackViewVO updateAndReturnChanged(TrackView view) {
|
public TrackViewVO updateAndReturnChanged(TrackView view) {
|
||||||
boolean change = false;
|
boolean change = false;
|
||||||
TrackViewVO viewVO = new TrackViewVO();
|
TrackViewVO changedViewVO = new TrackViewVO();
|
||||||
viewVO.setStationCode(view.getStationCode());
|
changedViewVO.setStationCode(view.getStationCode());
|
||||||
|
|
||||||
//股道占用
|
//股道占用
|
||||||
for (Section section : view.getSections()) {
|
for (Section section : view.getSections()) {
|
||||||
@ -68,7 +72,7 @@ public class TrackViewVO {
|
|||||||
if (!Objects.equals(sectionOccupiedMap.get(section.getCode()), occupied)) {
|
if (!Objects.equals(sectionOccupiedMap.get(section.getCode()), occupied)) {
|
||||||
change = true;
|
change = true;
|
||||||
sectionOccupiedMap.put(section.getCode(), occupied);
|
sectionOccupiedMap.put(section.getCode(), occupied);
|
||||||
viewVO.addSectionOccupied(section.getCode(), occupied);
|
changedViewVO.addSectionOccupied(section.getCode(), occupied);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//分行数据
|
//分行数据
|
||||||
@ -82,29 +86,35 @@ public class TrackViewVO {
|
|||||||
LineVO lineVO = lineVOMap.get(line.getTripNumber());
|
LineVO lineVO = lineVOMap.get(line.getTripNumber());
|
||||||
if (lineVO == null) { //没有这条记录
|
if (lineVO == null) { //没有这条记录
|
||||||
change = true;
|
change = true;
|
||||||
viewVO.addLine(trackCode, new LineVO(line));
|
LineVO vo = new LineVO(line);
|
||||||
|
addLine(trackCode, vo);
|
||||||
|
changedViewVO.addLine(trackCode, vo);
|
||||||
} else { //有这条记录
|
} else { //有这条记录
|
||||||
deletedTripNumbers.remove(line.getTripNumber());
|
deletedTripNumbers.remove(line.getTripNumber());
|
||||||
LineVO changedLineVO = lineVO.updateAndReturnChanged(line);
|
LineVO changedLineVO = lineVO.updateAndReturnChanged(line);
|
||||||
if (changedLineVO != null) {
|
if (changedLineVO != null) {
|
||||||
change = true;
|
change = true;
|
||||||
viewVO.addLine(trackCode, changedLineVO);
|
changedViewVO.addLine(trackCode, changedLineVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!deletedTripNumbers.isEmpty()) {
|
if (!deletedTripNumbers.isEmpty()) {
|
||||||
change = true;
|
change = true;
|
||||||
viewVO.addDeletedLine(trackCode, deletedTripNumbers);
|
changedViewVO.addDeletedLine(trackCode, deletedTripNumbers);
|
||||||
|
for (String deletedTripNumber : deletedTripNumbers) {
|
||||||
|
lineVOMap.remove(deletedTripNumber);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!deletedTrackCodes.isEmpty()) {
|
if (!deletedTrackCodes.isEmpty()) {
|
||||||
change = true;
|
change = true;
|
||||||
for (String trackCode : deletedTrackCodes) {
|
for (String trackCode : deletedTrackCodes) {
|
||||||
viewVO.addDeletedLine(trackCode, trackLineMap.get(trackCode).keySet());
|
changedViewVO.addDeletedLine(trackCode, trackLineMap.get(trackCode).keySet());
|
||||||
|
trackLineMap.remove(trackCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return change ? viewVO : null;
|
return change ? changedViewVO : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -7,6 +7,7 @@ import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
|
|||||||
import club.joylink.rtss.simulation.cbtc.CTC.data.RouteSequence;
|
import club.joylink.rtss.simulation.cbtc.CTC.data.RouteSequence;
|
||||||
import club.joylink.rtss.simulation.cbtc.CTC.data.TrackView;
|
import club.joylink.rtss.simulation.cbtc.CTC.data.TrackView;
|
||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -29,28 +30,46 @@ public class CTCService {
|
|||||||
* 创建了新的运行计划item
|
* 创建了新的运行计划item
|
||||||
*/
|
*/
|
||||||
public void runPlanItemCreate(Simulation simulation, Station station, CtcStationRunPlanLog.RunPlanItem item, boolean departure) {
|
public void runPlanItemCreate(Simulation simulation, Station station, CtcStationRunPlanLog.RunPlanItem item, boolean departure) {
|
||||||
CtcRepository ctcRepository = simulation.getCtcRepository();
|
regenerateRouteSequenceAndTrackView(simulation);
|
||||||
//进路序列
|
// CtcRepository ctcRepository = simulation.getCtcRepository();
|
||||||
RouteSequence routeSequence = ctcRepository.getRouteSequence(station.getCode());
|
// //进路序列
|
||||||
AtomicInteger idGenerator = ctcRepository.getRouteSequenceIdGenerator();
|
// RouteSequence routeSequence = ctcRepository.getRouteSequence(station.getCode());
|
||||||
RouteSequence.Line line = RouteSequence.buildLine(item, departure, idGenerator);
|
// AtomicInteger idGenerator = ctcRepository.getRouteSequenceIdGenerator();
|
||||||
routeSequence.addLine(line);
|
// RouteSequence.Line line = RouteSequence.buildLine(item, departure, idGenerator);
|
||||||
//股道视图
|
// routeSequence.addLine(line);
|
||||||
TrackView trackView = ctcRepository.getTrackView(station.getCode());
|
// //股道视图
|
||||||
if (departure) {
|
// TrackView trackView = ctcRepository.getTrackView(station.getCode());
|
||||||
trackView.addDepartureLine(line);
|
// if (departure) {
|
||||||
} else {
|
// trackView.addDepartureLine(line);
|
||||||
trackView.addReceivingLine(line);
|
// } else {
|
||||||
}
|
// trackView.addReceivingLine(line);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 运行计划item更新了
|
* 运行计划item更新了
|
||||||
*/
|
*/
|
||||||
public void runPlanItemUpdate(Simulation simulation, Station station, CtcStationRunPlanLog.RunPlanItem item, boolean departure) {
|
public void runPlanItemUpdate(Simulation simulation, Station station, CtcStationRunPlanLog.RunPlanItem item, boolean departure) {
|
||||||
|
regenerateRouteSequenceAndTrackView(simulation);
|
||||||
|
// CtcRepository ctcRepository = simulation.getCtcRepository();
|
||||||
|
// RouteSequence.Line routeSequenceLine = ctcRepository.getRouteSequenceLine(station.getCode(), item.getTripNumber(), departure);
|
||||||
|
//
|
||||||
|
// String oldTc = routeSequenceLine.getTrackCode();
|
||||||
|
// String oldTn = routeSequenceLine.getTripNumber();
|
||||||
|
//
|
||||||
|
// routeSequenceLine.update();
|
||||||
|
//
|
||||||
|
// ctcRepository.updateTrackView(station.getCode(), oldTc, oldTn, routeSequenceLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重新生成进路序列和股道视图
|
||||||
|
* 该方法应该在车务终端发送阶段计划之后调用
|
||||||
|
*/
|
||||||
|
public void regenerateRouteSequenceAndTrackView(Simulation simulation) {
|
||||||
|
SimulationBuilder.generateRouteSequence(simulation);
|
||||||
CtcRepository ctcRepository = simulation.getCtcRepository();
|
CtcRepository ctcRepository = simulation.getCtcRepository();
|
||||||
RouteSequence.Line routeSequenceLine = ctcRepository.getRouteSequenceLine(station.getCode(), item.getTripNumber(), departure);
|
ctcRepository.buildTrackViewData(simulation);
|
||||||
routeSequenceLine.updateRoute();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,6 +3,7 @@ package club.joylink.rtss.vo.client.factory;
|
|||||||
import club.joylink.rtss.constants.BusinessConsts.WebSocketSubscribeTopic;
|
import club.joylink.rtss.constants.BusinessConsts.WebSocketSubscribeTopic;
|
||||||
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
|
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
|
||||||
import club.joylink.rtss.simulation.cbtc.CTC.data.Ticket;
|
import club.joylink.rtss.simulation.cbtc.CTC.data.Ticket;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.BusyBoardVO;
|
||||||
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.CtcStationRunPlanLogVO;
|
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.CtcStationRunPlanLogVO;
|
||||||
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.RailDispatchCommandVO;
|
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.RailDispatchCommandVO;
|
||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
@ -415,9 +416,9 @@ public class SocketMessageFactory {
|
|||||||
/**
|
/**
|
||||||
* CTC进路序列消息
|
* CTC进路序列消息
|
||||||
*/
|
*/
|
||||||
public static SocketMessageVO<Object> buildCtcBusyBoardMessage(String simulationId,
|
public static SocketMessageVO<List<BusyBoardVO>> buildCtcBusyBoardMessage(String simulationId,
|
||||||
Object message) {
|
List<BusyBoardVO> body) {
|
||||||
return build(WebSocketMessageType.Simulation_RailCtcStatus, simulationId, message);
|
return build(WebSocketMessageType.Simulation_RailCtcStatus, simulationId, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,4 +15,13 @@ public class WebSocketMessage<T, B> {
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
/** 所有数据 */
|
||||||
|
ALL,
|
||||||
|
/** 更新数据 */
|
||||||
|
UPDATE,
|
||||||
|
/** 清除数据 */
|
||||||
|
CLEAR,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user