diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java index 61168d1ba..39feb3071 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java @@ -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 dcmdMap = new ConcurrentHashMap<>(); /** * 调度命令 * k - 调度命令id diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/DCMD.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/DCMD.java new file mode 100644 index 000000000..45891897b --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/DCMD.java @@ -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,; + + } + +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/DCMDReceipt.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/DCMDReceipt.java new file mode 100644 index 000000000..68bbfb008 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/DCMDReceipt.java @@ -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; +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMD.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMD.java deleted file mode 100644 index c8b86f8a2..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMD.java +++ /dev/null @@ -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; - /** - * 当前状态 - *

- * 调度命令流转状态 - */ - private FlowStatus flowStatus = FlowStatus.INIT; - /** - * 发令时间 - */ - private LocalDateTime sendTime; - /** - * 发令者信息:发令人和发令单位 - */ - private DCMDSender sender; - /** - * 调度命令正文 - */ - private String content; - /** - * 调度命令类型 - */ - private Type type; - - - /////////////////////////////////TO:调度命令受令者;调度命令的状态///////////////////////////////////////////////// - /** - * 受令单位(即接收调度命令的车站) - *

- * 选填 - */ - private Map stationReceivers = new HashMap<>(); - /** - * 无线受令(即列车车载设备受令) - *

- * 选填 - */ - private List trainReceivers = new ArrayList<>(); - /** - * 调度台受令 - *

- * 选填 - */ - private List disReceivers = new ArrayList<>(); - /** - * TSR列控服务器受令 - *

- * 选填 - */ - private List tsrReceivers = new ArrayList<>(); - ////////////////////////////////////////////////////////////////////////// - /** - * 发令人定义 - *

- * 调度台和车站二选一 - */ - @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{ - /** - * 中转车站 - *

- * 当为Null时,通过GSM-R通信直接发送给机车;
- * 当不为空时,通过车站自律机智能中转;
- */ - 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,; - } - -} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDService.java index 7a7724918..9037bb048 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDService.java @@ -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; + /** * 调度命令数据流控制 *

@@ -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; + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDAllReceiver.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDAllReceiver.java new file mode 100644 index 000000000..8750e24f9 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDAllReceiver.java @@ -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 disReceivers = new LinkedList<>(); + /** + * 该调度命令的车站受令者 + */ + private final List stationReceivers = new LinkedList<>(); + /** + * 该调度命令的机车受令者 + */ + private final List trainReceivers = new LinkedList<>(); + /** + * 该调度命令的列控受令者 + */ + private final List tsrReceivers = new LinkedList<>(); + +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDDisReceiver.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDDisReceiver.java new file mode 100644 index 000000000..a82b96d1c --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDDisReceiver.java @@ -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; + +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDReceiver.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDReceiver.java new file mode 100644 index 000000000..3b0316813 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDReceiver.java @@ -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; + +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDStationReceiver.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDStationReceiver.java new file mode 100644 index 000000000..1f0132d28 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDStationReceiver.java @@ -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; + +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDTrainReceiver.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDTrainReceiver.java new file mode 100644 index 000000000..5fec94de1 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDTrainReceiver.java @@ -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 { + /** + * 中转车站 + *

+ * 当为Null时,通过GSM-R通信直接发送给机车;
+ * 当不为空时,通过车站自律机智能中转;
+ */ + private Station disStation; + /** + * 车次号 + */ + private String trainNum; + /** + * 机车号 + */ + private VirtualRealityTrain train; + //////////////车站自律机对无线调度命令处理状态///////// + /** + * 收令箱 + */ + private Boolean posReceive=false; + /** + * 发令箱 + */ + private Boolean posSend=false; + /** + * 签收完成箱 + */ + private Boolean posSigned=false; +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDTsrReceiver.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDTsrReceiver.java new file mode 100644 index 000000000..c4a3d3864 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDTsrReceiver.java @@ -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; + +}