大铁调度命令数据流转实现

This commit is contained in:
xzb 2022-09-01 18:09:38 +08:00
parent e643b7df9f
commit 6922e2630e
11 changed files with 457 additions and 303 deletions

View File

@ -6,6 +6,7 @@ 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 club.joylink.rtss.simulation.cbtc.CTC.param.CtcRunPlanParam;
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.DCMD;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
@ -112,7 +113,11 @@ public class CtcRepository {
* 调度命令id生成器
*/
private AtomicInteger dispatchCommandIdGenerator = new AtomicInteger(0);
/**
* 新版调度命令
* k - 调度命令id
*/
private final Map<String, DCMD> dcmdMap = new ConcurrentHashMap<>();
/**
* 调度命令
* k - 调度命令id

View File

@ -0,0 +1,126 @@
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd;
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDAllReceiver;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
/**
* 调度命令数据定义
*/
@Getter
@Setter
public class DCMD {
/**
* 唯一id
*/
private String id;
/**
* 标题
*/
private String title;
/**
* 调度命令号
*/
private String code;
/**
* 中转识别号
*/
private String transitId;
/**
* 发令时间
*/
private LocalDateTime sendTime;
/**
* 发令人
*/
private String sender;
/**
* 发令单位(用户手写)
*/
private String company;
/**
* 调度命令创建平台(调度台或车站)
*/
private SimulationMember creator;
/**
* 授权时间
*/
private LocalDateTime authTime;
/**
* 值班主任(仿真成员)
*/
private SimulationMember chiefOnDuty;
/**
* 需值班主任授权
*/
private Boolean chiefOnDutyAuth=false;
/**
* 授权状态
*/
private String authState;
/**
* 定稿时间
*/
private LocalDateTime finishedTime;
/**
* 审核人(仿真成员)
*/
private SimulationMember reviewer;
/**
* 日计划号
*/
private String dailyPlanNum;
/**
* 拟令人(起草者设计者)
*/
private String designer;
/**
* 调度命令类型
*/
private Type type;
/**
* 调度命令正文
*/
private String content;
/**
* 调度命令的受令者
*/
private DCMDAllReceiver allReceivers;
//////////////////////////////////////////////////////////////////////////
/**
* 签收状态
*/
public enum SignStatus {
/**
*未签收
*/
UNSIGNED,
/**
* 签收
*/
SIGNED,
/**
* 代签
*/
PROXY,
/**
* 拒签
*/
REFUSE,
;
}
/**
* 调度命令类型
*/
public enum Type {
/**
* 正常调度命令
*/
NORMAL,;
}
}

View File

@ -0,0 +1,46 @@
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
/**
* 回执的定义
*/
@Getter
@Setter
public class DCMDReceipt {
/**
* 回执唯一id
*/
private String id;
/**
* 调度命令号
*/
private String code;
/**
* 回执状态
*/
private String state;
/**
* 回执时间
*/
private LocalDateTime time;
/**
* 签收单位
*/
private String sigCompany;
/**
* 签收人
*/
private String signedBy;
/**
* 车次号
*/
private String trainNum;
/**
* 机车号
*/
private VirtualRealityTrain train;
}

View File

@ -1,302 +0,0 @@
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 调度命令数据定义
*/
@Data
public class RailDCMD {
/**
* 标题
*/
private String title;
/**
* 调度命令号
*/
private String code;
/**
* 中转识别号
*/
private String transitId;
/**
* 当前状态
* <p>
* 调度命令流转状态
*/
private FlowStatus flowStatus = FlowStatus.INIT;
/**
* 发令时间
*/
private LocalDateTime sendTime;
/**
* 发令者信息发令人和发令单位
*/
private DCMDSender sender;
/**
* 调度命令正文
*/
private String content;
/**
* 调度命令类型
*/
private Type type;
/////////////////////////////////TO:调度命令受令者调度命令的状态/////////////////////////////////////////////////
/**
* 受令单位(即接收调度命令的车站)
* <p>
* 选填
*/
private Map<Station, DCMDStationReceiver> stationReceivers = new HashMap<>();
/**
* 无线受令(即列车车载设备受令)
* <p>
* 选填
*/
private List<DCMDTrainReceiver> trainReceivers = new ArrayList<>();
/**
* 调度台受令
* <p>
* 选填
*/
private List<DCMDDisReceiver> disReceivers = new ArrayList<>();
/**
* TSR列控服务器受令
* <p>
* 选填
*/
private List<DCMDTsrReceiver> tsrReceivers = new ArrayList<>();
//////////////////////////////////////////////////////////////////////////
/**
* 发令人定义
* <p>
* 调度台和车站二选一
*/
@Data
public static class DCMDSender{
/**
* 调度命令的编写者(仿真成员)
*/
private String authorId;
/**
* 调度台code
*/
private String disCode;
/**
* 车站code
*/
private String stationCode;
}
/**
* TSR列控服务器受令
*/
@Data
public static class DCMDTsrReceiver{
/**
* 调度命令流转状态
*/
private FlowStatus flowStatus = FlowStatus.INIT;
/**
* 受令列控服务器code
*/
private String tsrCode;
/**
* 收令时间
*/
private LocalDateTime receivedTime;
/**
* 签收状态
*/
private SignStatus sigState = SignStatus.UNSIGNED;
/**
* 签收人
*/
private String signedBy;
/**
* 签收时间
*/
private LocalDateTime time;
}
/**
* 调度台受令
*/
@Data
public static class DCMDDisReceiver{
/**
* 调度命令流转状态
*/
private FlowStatus flowStatus = FlowStatus.INIT;
/**
* 受令调度台code
*/
private String disCode;
/**
* 收令时间
*/
private LocalDateTime receivedTime;
/**
* 签收状态
*/
private SignStatus sigState = SignStatus.UNSIGNED;
/**
* 签收人
*/
private String signedBy;
/**
* 签收时间
*/
private LocalDateTime time;
}
/**
* 车载受令
*/
@Data
public static class DCMDTrainReceiver{
/**
* 中转车站
* <p>
* 当为Null时通过GSM-R通信直接发送给机车<br>
* 当不为空时通过车站自律机智能中转<br>
*/
private Station disStation;
/**
* 调度命令流转状态(对应中转车站)
*/
private FlowStatus flowStatusWithStation = FlowStatus.INIT;
/**
* 车次号
*/
private String trainNum;
/**
* 机车号
*/
private VirtualRealityTrain train;
/**
* 调度命令流转状态(对应机车)
*/
private FlowStatus flowStatusWithTrain = FlowStatus.INIT;
/**
* 收令时间
*/
private LocalDateTime receivedTime;
/**
* 签收状态
*/
private SignStatus sigState = SignStatus.UNSIGNED;
/**
* 签收人
*/
private String signedBy;
/**
* 签收时间
*/
private LocalDateTime time;
}
/**
* 车站受令
*/
@Data
public static class DCMDStationReceiver {
/**
* 调度命令流转状态
*/
private FlowStatus flowStatus = FlowStatus.INIT;
/**
* 受令人
*/
private Station receiver;
/**
* 收令时间
*/
private LocalDateTime receivedTime;
/**
* 签收状态
*/
private SignStatus sigState = SignStatus.UNSIGNED;
/**
* 签收人
*/
private String signedBy;
/**
* 签收时间
*/
private LocalDateTime time;
}
/**
* 签收状态
*/
public enum SignStatus {
/**
*未签收
*/
UNSIGNED,
/**
* 签收
*/
SIGNED,
/**
* 代签
*/
PROXY,
/**
* 拒签
*/
REFUSE,
;
}
/**
* 流转状态
*/
public enum FlowStatus{
/**
* 初始未知
*/
INIT,
/**
* 编辑中
*/
EDITING,
/**
* 缓存(草稿箱中)
*/
CACHE,
/**
* 已经接收(收件箱中)
*/
RECEIVED,
/**
* 已经发送(发件箱中)
*/
SEND,
;
}
/**
* 调度命令类型
*/
public enum Type {
/**
* 正常调度命令
*/
NORMAL,
/**
* 请求调度命令
*/
REQUEST,;
}
}

View File

@ -1,9 +1,17 @@
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository;
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDAllReceiver;
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDStationReceiver;
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDTsrReceiver;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import lombok.extern.slf4j.Slf4j;
import java.time.LocalDateTime;
/**
* 调度命令数据流控制
* <p>
@ -26,7 +34,100 @@ public class RailDCMDService {
* TDCS2.0车站调度命令管理请求调度命令车站调度命令机车(无线)调度命令
*/
public void dispatcher (Simulation simulation, SimulationMember sender){
//todo 将前端发送来的调度命令转换为 RailDCMD
DCMD cmd = new DCMD();
}
/**
* 新建调度命令
* @param creator 调度台或车站
*/
public DCMD create(Simulation simulation, SimulationMember creator){
CtcRepository ctcRepository = simulation.getCtcRepository();
int id = ctcRepository.getDispatchCommandIdGenerator().getAndIncrement();
//
DCMD cmd = new DCMD();
cmd.setId(String.valueOf(id));
cmd.setCreator(creator);
//
cmd.setAllReceivers(new DCMDAllReceiver());
cmd.getAllReceivers().setDcmd(cmd);
cmd.getAllReceivers().setPosCreate(true);
// 默认设置编辑中状态
cmd.getAllReceivers().setPosEditing(true);
//
ctcRepository.getDcmdMap().put(cmd.getId(),cmd);
//
return cmd;
}
/**
* 调度命令的发送如果受令方在超过一定时间内没有签收则要重新发
*/
/**
* 列控受令者签收调度命令前端操作
* @param cmdId 调度命令id
* @param tsrCode 列控服务器id
* @param signedBy 签收人
*/
public void signForTsr(Simulation simulation,String cmdId,String tsrCode,String signedBy){
DCMD cmd = this.findDCMD(simulation,cmdId);
DCMDTsrReceiver target=null;
for(DCMDTsrReceiver tsrReceiver:cmd.getAllReceivers().getTsrReceivers()){
if(tsrCode.equals(tsrReceiver.getTsrCode())){
target = tsrReceiver;
break;
}
}
//
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=target,String.format("调度命令(id=%s)的TSR列控服务器受令者(tsrCode=%s)不存在",cmdId,tsrCode));
//
target.setSignedBy(signedBy);
target.setSignedTime(this.getSimLocalDateTime());
target.setSigState(DCMD.SignStatus.SIGNED);
target.setPosSigned(true);
}
/**
* 车站受令者签收调度命令前端操作
* @param cmdId 调度命令id
* @param stationCode 车站code
* @param signedBy 签收人
*/
public void signForStation(Simulation simulation,String cmdId,String stationCode,String signedBy){
DCMD cmd = this.findDCMD(simulation,cmdId);
Station station = this.getSimStation(simulation,stationCode);
DCMDStationReceiver target=null;
for(DCMDStationReceiver stationReceiver:cmd.getAllReceivers().getStationReceivers()){
if(station.getCode().equals(stationReceiver.getReceiver().getCode())){
target = stationReceiver;
break;
}
}
//
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=target,String.format("调度命令(id=%s)的车站受令者(stationCode=%s)不存在",cmdId,stationCode));
//
target.setSignedBy(signedBy);
target.setSignedTime(this.getSimLocalDateTime());
target.setSigState(DCMD.SignStatus.SIGNED);
target.setPosSigned(true);
}
private DCMD findDCMD(Simulation simulation,String cmdId){
CtcRepository ctcRepository = simulation.getCtcRepository();
DCMD cmd= ctcRepository.getDcmdMap().get(cmdId);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在id=%s",cmdId));
return cmd;
}
/**
* 获取仿真当前时间
*/
private LocalDateTime getSimLocalDateTime(){
//暂时设置为系统时间
return LocalDateTime.now();
}
private Station getSimStation(Simulation simulation,String stationCode){
Station station = simulation.getRepository().getByCode(stationCode, Station.class);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=station,String.format("仿真车站不存在id=%s",stationCode));
return station;
}
}

View File

@ -0,0 +1,32 @@
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver;
import lombok.Getter;
import lombok.Setter;
import java.util.LinkedList;
import java.util.List;
/**
* 调度命令的创建者编制者对调度命令的管理
*/
@Setter
@Getter
public class DCMDAllReceiver extends DCMDReceiver {
/**
* 该调度命令的调度台受令者
*/
private final List<DCMDDisReceiver> disReceivers = new LinkedList<>();
/**
* 该调度命令的车站受令者
*/
private final List<DCMDStationReceiver> stationReceivers = new LinkedList<>();
/**
* 该调度命令的机车受令者
*/
private final List<DCMDTrainReceiver> trainReceivers = new LinkedList<>();
/**
* 该调度命令的列控受令者
*/
private final List<DCMDTsrReceiver> tsrReceivers = new LinkedList<>();
}

View File

@ -0,0 +1,14 @@
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class DCMDDisReceiver extends DCMDReceiver {
/**
* 受令调度台code
*/
private String disCode;
}

View File

@ -0,0 +1,60 @@
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver;
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.DCMD;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
/**
* 当调度命令创建编辑时创建编辑者即是一个 Receiver
*/
@Getter
@Setter
public class DCMDReceiver {
/**
* 调度命令
*/
private DCMD dcmd;
/**
* 收令时间
*/
private LocalDateTime receivedTime;
/**
* 签收状态
*/
private DCMD.SignStatus sigState = DCMD.SignStatus.UNSIGNED;
/**
* 签收人
*/
private String signedBy;
/**
* 签收时间
*/
private LocalDateTime signedTime;
///////////////////////////////////////////////////
/**
* 缓存箱
*/
private Boolean posCache=false;
/**
* 收令箱
*/
private Boolean posReceive=false;
/**
* 发令箱
*/
private Boolean posSend=false;
/**
* 签收完成箱
*/
private Boolean posSigned=false;
/**
* 编辑中
*/
private Boolean posEditing=false;
/**
* 接收者即创建者
*/
private Boolean posCreate=false;
}

View File

@ -0,0 +1,15 @@
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class DCMDStationReceiver extends DCMDReceiver {
/**
* 受令人
*/
private Station receiver;
}

View File

@ -0,0 +1,42 @@
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import lombok.Getter;
import lombok.Setter;
/**
* 无线受令者
*/
@Getter
@Setter
public class DCMDTrainReceiver extends DCMDReceiver {
/**
* 中转车站
* <p>
* 当为Null时通过GSM-R通信直接发送给机车<br>
* 当不为空时通过车站自律机智能中转<br>
*/
private Station disStation;
/**
* 车次号
*/
private String trainNum;
/**
* 机车号
*/
private VirtualRealityTrain train;
//////////////车站自律机对无线调度命令处理状态/////////
/**
* 收令箱
*/
private Boolean posReceive=false;
/**
* 发令箱
*/
private Boolean posSend=false;
/**
* 签收完成箱
*/
private Boolean posSigned=false;
}

View File

@ -0,0 +1,15 @@
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class DCMDTsrReceiver extends DCMDReceiver{
/**
* 受令列控服务器code
*/
private String tsrCode;
}