修改进路序列id生成方式;增加调度命令操作(未完)

This commit is contained in:
joylink_zhangsai 2022-06-24 18:17:48 +08:00
parent 493309b909
commit e3f3d8c097
19 changed files with 296 additions and 25 deletions

View File

@ -1003,6 +1003,9 @@ public class Operation {
* 事故按钮
*/
ASSIST_PRESS_ACCIDENT,
//---------------------------- 调度命令 -------------------------
CTC_SEND_DISPATCH_COMMAND
}
/**

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.CTC;
import club.joylink.rtss.simulation.cbtc.ATS.operation.vo.CtcRunPlanParam;
import club.joylink.rtss.simulation.cbtc.CTC.data.*;
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.*;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.*;

View File

@ -4,15 +4,24 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
import club.joylink.rtss.simulation.cbtc.CTC.data.RailDispatchCommand;
import club.joylink.rtss.simulation.cbtc.CTC.data.RouteSequence;
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.RailDispatchCommandVO;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import io.netty.util.internal.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Set;
import java.util.stream.Collectors;
@Component
public class CTCService {
@ -132,4 +141,28 @@ public class CTCService {
CtcRepository ctcRepository = simulation.getCtcRepository();
return ctcRepository.getRunPlanByRunPlanCode(stationCode, runPlanCode);
}
/**
* 发送调度命令
*/
public void sendDispatchCommand(Simulation simulation, RailDispatchCommandVO vo) {
CtcRepository ctcRepository = simulation.getCtcRepository();
int id = ctcRepository.getDispatchCommandIdGenerator().getAndIncrement();
vo.setId(String.valueOf(id));
RailDispatchCommand command = new RailDispatchCommand(vo);
if (StringUtils.hasText(vo.getSenderId())) {
SimulationMember sender = simulation.getSimulationMemberById(vo.getSenderId());
command.setSender(sender);
}
if (StringUtils.hasText(vo.getReviewerId())) {
SimulationMember reviewer = simulation.getSimulationMemberById(vo.getReviewerId());
command.setReviewer(reviewer);
}
if (!CollectionUtils.isEmpty(vo.getReceiverIds())) {
Set<SimulationMember> receivers = vo.getReceiverIds().stream()
.map(simulation::getSimulationMemberById).collect(Collectors.toSet());
command.setReceivers(receivers);
}
ctcRepository.addDispatchCommand(command);
}
}

View File

@ -1,13 +1,15 @@
package club.joylink.rtss.simulation.cbtc.CTC.data;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.CtcManageRepositoryVO;
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.CtcStationRunPlanLogVO;
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.RouteSequenceVO;
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.TrackViewVO;
import lombok.Getter;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
@ -45,6 +47,11 @@ public class CtcRepository {
*/
private final CtcManageRepositoryVO ctcManageRepositoryVO = new CtcManageRepositoryVO();
/**
* 进路序列id生成器
*/
private AtomicInteger routeSequenceIdGenerator = new AtomicInteger(0);
/**
* 车站-进路序列每个车站都应该有
* k - stationCode
@ -91,7 +98,15 @@ public class CtcRepository {
/******************************************* 以上为车站终端数据:车站为单位 *******************************************/
/**
* 调度命令id生成器
*/
private AtomicInteger dispatchCommandIdGenerator = new AtomicInteger(0);
private final Set<RailDispatchCommand> dispatchCommandSet = new HashSet<>();
public void reset() {
routeSequenceIdGenerator = new AtomicInteger(0);
routeSequenceMap.clear();
routeSequenceVOMap.clear();
trackViewMap.clear();
@ -106,6 +121,8 @@ public class CtcRepository {
}));
// 运行计划状态清除
this.runPlanStatusVOMap.clear();
dispatchCommandIdGenerator = new AtomicInteger(0);
dispatchCommandSet.clear();
}
/**
@ -196,4 +213,8 @@ public class CtcRepository {
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(routeSequence);
return routeSequence.getLine(tripNumber, routeCode);
}
public void addDispatchCommand(RailDispatchCommand command) {
dispatchCommandSet.add(command);
}
}

View File

@ -0,0 +1,95 @@
package club.joylink.rtss.simulation.cbtc.CTC.data;
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.RailDispatchCommandVO;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.Set;
/**
* 大铁调度命令
*/
@Getter
@Setter
@NoArgsConstructor
public class RailDispatchCommand {
private String id;
/**
* 命令标题
*/
private String title;
/**
* 命令号
*/
private String number;
/**
* 发令时间
*/
private LocalDateTime sendTime;
/**
* 发令人
*/
private SimulationMember sender;
/**
* 发令单位
*/
private String companyOfSender;
/**
* 授权时间
*/
private LocalDateTime authorizationTime;
/**
* 授权状态
*/
private String authorizationStatus;
/**
* 定稿时间
*/
private LocalDateTime finalizationTime;
/**
* 审核人
*/
private SimulationMember reviewer;
/**
* 拟令人
*/
private String author;
private Type type;
/**
* 受令人
*/
private Set<SimulationMember> receivers;
public RailDispatchCommand(RailDispatchCommandVO vo) {
this.id = vo.getId();
this.title = vo.getTitle();
this.number = vo.getNumber();
this.sendTime = vo.getSendTime();
this.companyOfSender = vo.getCompanyOfSender();
this.authorizationTime = vo.getAuthorizationTime();
this.authorizationStatus = vo.getAuthorizationStatus();
this.finalizationTime = vo.getFinalizationTime();
this.author = vo.getAuthor();
this.type = vo.getType();
}
public enum Type {
/** 正常调度命令 */
NORMAL
}
}

View File

@ -22,8 +22,6 @@ import java.util.stream.Collectors;
@Getter
@Setter
public class RouteSequence {
public static AtomicInteger idGenerator = new AtomicInteger(0);
private boolean readOnly;
private Station station;
@ -43,10 +41,6 @@ public class RouteSequence {
*/
private final List<Line> lines;
public static void reset() {
idGenerator = new AtomicInteger(0);
}
public RouteSequence(Station station, List<Line> lines) {
this.station = station;
lines.sort((o1, o2) -> {
@ -68,7 +62,7 @@ public class RouteSequence {
}
}
public static Line buildLine(CtcStationRunPlanLog.RunPlanItem item, boolean departure) {
public static Line buildLine(CtcStationRunPlanLog.RunPlanItem item, boolean departure, AtomicInteger idGenerator) {
Section trackSection = item.getTrackSection();
boolean right = item.isRight();
Signal startSignal = null;
@ -206,7 +200,7 @@ public class RouteSequence {
@Setter
private boolean triggered;
public 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.item = item;
this.departure = departure;

View File

@ -299,7 +299,7 @@ public class TrackView {
}
}
enum Process {
public enum Process {
RECEIVING_BLOCK, //办理接车闭塞
RECEIVING, //准备接车
RECEIVING_ROUTE, //办理接车进路

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.simulation.cbtc.CTC.data;
package club.joylink.rtss.simulation.cbtc.CTC.data.vo;
import club.joylink.rtss.simulation.cbtc.ATS.operation.vo.CtcRunPlanParam;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcManageRepository;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.CollectionUtils;

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc.CTC.data;
package club.joylink.rtss.simulation.cbtc.CTC.data.vo;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.CollectionUtils;

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc.CTC.data;
package club.joylink.rtss.simulation.cbtc.CTC.data.vo;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcZone;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import lombok.Getter;
import lombok.Setter;

View File

@ -0,0 +1,88 @@
package club.joylink.rtss.simulation.cbtc.CTC.data.vo;
import club.joylink.rtss.simulation.cbtc.CTC.data.RailDispatchCommand;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.Set;
/**
* 大铁调度命令
*/
@Getter
@Setter
@NoArgsConstructor
public class RailDispatchCommandVO {
private String id;
/**
* 命令标题
*/
private String title;
/**
* 命令号
*/
private String number;
/**
* 发令时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime sendTime;
/**
* 发令人仿真成员id
*/
private String senderId;
/**
* 发令单位
*/
private String companyOfSender;
/**
* 授权时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime authorizationTime;
/**
* 授权状态
*/
private String authorizationStatus;
/**
* 定稿时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime finalizationTime;
/**
* 审核人
*/
private String reviewerId;
/**
* 拟令人
*/
private String author;
/**
* 受令人仿真成员id
*/
private Set<String> receiverIds;
private RailDispatchCommand.Type type;
/**
* webSocket消息类型
*/
enum WsMessageType {
ADD,
UPDATE,
}
}

View File

@ -1,9 +1,9 @@
package club.joylink.rtss.simulation.cbtc.CTC.data;
package club.joylink.rtss.simulation.cbtc.CTC.data.vo;
import club.joylink.rtss.simulation.cbtc.CTC.data.RouteSequence;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.CollectionUtils;
import java.time.LocalTime;
import java.util.*;

View File

@ -1,4 +1,6 @@
package club.joylink.rtss.simulation.cbtc.CTC.data;
package club.joylink.rtss.simulation.cbtc.CTC.data.vo;
import club.joylink.rtss.simulation.cbtc.CTC.data.TrackSection;
/**
* 股道与区段关联信息

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc.CTC.data;
package club.joylink.rtss.simulation.cbtc.CTC.data.vo;
import club.joylink.rtss.simulation.cbtc.CTC.data.TrackView;
import lombok.Getter;
import lombok.Setter;

View File

@ -4,6 +4,7 @@ import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping;
import club.joylink.rtss.simulation.cbtc.CTC.CTCService;
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.RailDispatchCommandVO;
import club.joylink.rtss.simulation.cbtc.Simulation;
import org.springframework.beans.factory.annotation.Autowired;
@ -91,6 +92,7 @@ public class RailCtcOperateHandler {
/**
* CTC办理进路
*
* @param tripNumber 办理列车进路时可以输入车次号
* @param force 是否强制办理
* @param duration 办理调车进路时可以输入时间
@ -99,4 +101,9 @@ public class RailCtcOperateHandler {
public void setRoute(Simulation simulation, String routeCode, String tripNumber, Boolean force, Integer duration) {
ctcService.setRoute(simulation, routeCode, tripNumber, force, duration);
}
@OperateHandlerMapping(type = Operation.Type.CTC_SEND_DISPATCH_COMMAND)
public void sendDispatchCommand(Simulation simulation, RailDispatchCommandVO command) {
ctcService.sendDispatchCommand(simulation, command);
}
}

View File

@ -32,6 +32,7 @@ import org.springframework.util.CollectionUtils;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -112,6 +113,7 @@ public class SimulationBuilder {
public static void generateRouteSequence(Simulation simulation) {
SimulationDataRepository repository = simulation.getRepository();
CtcRepository ctcRepository = simulation.getCtcRepository();
AtomicInteger idGenerator = ctcRepository.getRouteSequenceIdGenerator();
Map<String, List<RouteSequence.Line>> stationLineMap = new HashMap<>();
for (Station station : repository.getStationList()) {
stationLineMap.put(station.getCode(), new ArrayList<>());
@ -120,12 +122,12 @@ public class SimulationBuilder {
List<RouteSequence.Line> lines = stationLineMap.get(plan.getStation().getCode());
CtcStationRunPlanLog.RunPlanItem arriveRunPlan = plan.getArriveRunPlan();
if (arriveRunPlan != null) {
RouteSequence.Line line = RouteSequence.buildLine(arriveRunPlan, false);
RouteSequence.Line line = RouteSequence.buildLine(arriveRunPlan, false, idGenerator);
lines.add(line);
}
CtcStationRunPlanLog.RunPlanItem departRunPlan = plan.getDepartRunPlan();
if (departRunPlan != null) {
RouteSequence.Line line = RouteSequence.buildLine(departRunPlan, true);
RouteSequence.Line line = RouteSequence.buildLine(departRunPlan, true, idGenerator);
lines.add(line);
}
}

View File

@ -407,6 +407,9 @@ public enum WebSocketMessageType {
* 仿真CTC管理端生效区移除操作
*/
SIMULATION_CTC_MANAGER_RUN_PLAN_EFFECT_REMOVE,
/** 调度命令 */
SIMULATION_RAIL_CTC_DISPATCH_COMMAND,
/** ------------ CTC消息信息 ----------- */
;
}

View File

@ -2,7 +2,7 @@ package club.joylink.rtss.vo.client.factory;
import club.joylink.rtss.constants.BusinessConsts.WebSocketSubscribeTopic;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLogVO;
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.CtcStationRunPlanLogVO;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.communication.vo.TrainPosition;
import club.joylink.rtss.simulation.cbtc.conversation.Conversation;

View File

@ -0,0 +1,18 @@
package club.joylink.rtss.websocket;
import lombok.Getter;
/**
* WebSocket消息的二级分类消息模板
*/
@Getter
public class WebSocketMessage {
private String type;
private Object object;
public WebSocketMessage(String type, Object object) {
this.type = type;
this.object = object;
}
}