From e643b7df9f40f85807634d4e4595f3a48921c9db Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Thu, 1 Sep 2022 10:39:49 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E5=A4=A7=E9=93=81=E8=B0=83=E5=BA=A6?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E6=95=B0=E6=8D=AE=E6=B5=81=E8=BD=AC=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/CTC/rail/dcmd/RailDCMD.java | 302 ++++++++++++++++++ .../cbtc/CTC/rail/dcmd/RailDCMDService.java | 32 ++ 2 files changed, 334 insertions(+) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMD.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDService.java 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 new file mode 100644 index 000000000..c8b86f8a2 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMD.java @@ -0,0 +1,302 @@ +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 new file mode 100644 index 000000000..7a7724918 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDService.java @@ -0,0 +1,32 @@ +package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.member.SimulationMember; +import lombok.extern.slf4j.Slf4j; + +/** + * 调度命令数据流控制 + *

+ * 调度命令分类:
+ * 普通调度命令、施工调度命令、转发调度命令、请求调度命令、长效调度命令、班计划调度命令 + */ +@Slf4j +public class RailDCMDService { + + /** + * 调度命令由调度台开始发出: + *

+ * 调度台1->调度台2
+ * 调度台->车站车务终端
+ * 无线调度命令立即发送:调度台->(通过GSM-R)车载终端
+ * 无线调度命令智能发送:调度台->(中转)车站自律机->(通过无线通信)车载终端
+ * 列控调度命令:调度台->TSR列控限速服务器 + *

+ * 调度命令由车站开始发出:
+ * TDCS2.0车站调度命令管理:请求调度命令、车站调度命令、机车(无线)调度命令 + */ + public void dispatcher (Simulation simulation, SimulationMember sender){ + + } + +} From 6922e2630eb78c86e60d6fdd6c91d5965bd653d8 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Thu, 1 Sep 2022 18:09:38 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E5=A4=A7=E9=93=81=E8=B0=83=E5=BA=A6?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E6=95=B0=E6=8D=AE=E6=B5=81=E8=BD=AC=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/CTC/data/CtcRepository.java | 7 +- .../simulation/cbtc/CTC/rail/dcmd/DCMD.java | 126 ++++++++ .../cbtc/CTC/rail/dcmd/DCMDReceipt.java | 46 +++ .../cbtc/CTC/rail/dcmd/RailDCMD.java | 302 ------------------ .../cbtc/CTC/rail/dcmd/RailDCMDService.java | 101 ++++++ .../rail/dcmd/receiver/DCMDAllReceiver.java | 32 ++ .../rail/dcmd/receiver/DCMDDisReceiver.java | 14 + .../CTC/rail/dcmd/receiver/DCMDReceiver.java | 60 ++++ .../dcmd/receiver/DCMDStationReceiver.java | 15 + .../rail/dcmd/receiver/DCMDTrainReceiver.java | 42 +++ .../rail/dcmd/receiver/DCMDTsrReceiver.java | 15 + 11 files changed, 457 insertions(+), 303 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/DCMD.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/DCMDReceipt.java delete mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMD.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDAllReceiver.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDDisReceiver.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDReceiver.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDStationReceiver.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDTrainReceiver.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDTsrReceiver.java 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; + +} From 8d195c5367b1317d7095e5309c76bfa562aa204a Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 2 Sep 2022 11:10:22 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E3=80=90=E5=89=8D=E7=AB=AF=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E7=82=B9=E5=87=BB=E6=97=B6=E3=80=81=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/training2/Training2Service.java | 170 ++++++++++++------ .../simulation/cbtc/training2/Operation2.java | 5 +- .../rtss/simulation/cbtc/training2/Step2.java | 6 +- 3 files changed, 128 insertions(+), 53 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java index e8f07ada5..d0aa1243a 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java @@ -34,6 +34,7 @@ import org.springframework.util.StringUtils; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.concurrent.Semaphore; import java.util.function.Consumer; @Service @@ -66,6 +67,16 @@ public class Training2Service { @Autowired private StompMessageService stompMessageService; + /** + * 完成步骤接口信号量 + */ + private Semaphore completeStepSemaphore = new Semaphore(1); + + /** + * 完成操作接口信号量 + */ + private Semaphore completeOperationSemaphore = new Semaphore(1); + public void run(Simulation simulation) { Training2 training2 = simulation.getTraining2(); if (training2 == null || !training2.isStarted() || training2.isFinish()) { @@ -81,47 +92,19 @@ public class Training2Service { return; } // 获取步骤中未完成的操作 - Operation2 operation2 = step.getCurrentRunOperation(); - // 操作全部完成的情况,检查步骤完成条件 + Operation2 operation2 = getOperationAndTryTrigger(step, simulation); if (operation2 == null) { - // TODO 后续判断步骤完成情况 - checkTrainStepCompletion(step, simulation); return; } - // 操作是否已触发 - // 没有触发则检查触发状态,如果可以触发则继续,不能触发则返回(同步骤) - if (!Step2.StepStatus.isAlreadyTrigger(operation2.getStatus()) && !operation2.doTriggerVail()) { + // 尝试执行操作 + if (!tryDoOperation(simulation, step, operation2)) { return; } - boolean isRobot = step.getSimulationMember().isRobot(); // 角色是否是机器人 - boolean isClient = operation2 instanceof Operation2.ClientOperation2; // 客户端操作 - // 未操作过 - if (Step2.StepStatus.isUndo(operation2.getStatus())) { - if (isRobot) { - if (isClient) { // 客户端操作 - operation2.doOperated(); - } else { // 仿真操 - Operation2.SimOperation2 simOperation2 = (Operation2.SimOperation2) operation2; - atsOperationDispatcher.execute(simulation, step.getSimulationMember(), - simOperation2.getOperationType().name(), simOperation2.getParams()); - } - } else { // 非机器人,暂停仿真等待用户操作 - pauseOrStartSimulation(simulation, true); - return; - } - } - // 运行阶段,判断是否完成 - if (Step2.StepStatus.isRunning(operation2.getStatus())) { - boolean completion = operation2.doCompletion(); - // 发送操作完成信息 - sendOperationFinish(operation2, simulation); - // 如果是最后一步,直接检查步骤有没有完成 - if (step.getOperations().indexOf(operation2) == (step.getOperations().size() - 1) && completion) { - checkStepCompletionAndSendNext(step, simulation); - } - } + // 操作运行阶段,判断是否完成 + tryCompleteOperation(simulation, step, operation2); } + /** * 预览实训草稿 */ @@ -263,21 +246,32 @@ public class Training2Service { if (Objects.equals(user.getId(), step.getSimulationMember().getId())) { throw new SimulationException(SimulationExceptionType.Invalid_Operation, "无权限操作"); } - boolean result = true; - for (Operation2 operation2 : step.getOperations()) { - if (operation2 instanceof Operation2.ClientOperation2) { // 前端操作,直接判断结果 - operation2.doOperated(); - operation2.doCompletion(); - } else { - result = false; - break; + try { + if (!step.isCompletion()) { + completeStepSemaphore.acquire(); // 控制多次请求 + if (!step.isCompletion()) { //二次判断 + boolean result = true; + for (Operation2 operation2 : step.getOperations()) { + if (operation2 instanceof Operation2.ClientOperation2) { // 前端操作,直接判断结果 + operation2.doOperated(); + operation2.doCompletion(); + } else { + result = false; + break; + } + } + if (result) { + checkStepCompletionAndSendNext(step, simulation); // 直接检查步骤是否完成 + } + // 恢复前端运行 + pauseOrStartSimulation(simulation, false); + } } + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + completeStepSemaphore.release(); } - if (result) { - checkStepCompletionAndSendNext(step, simulation); // 直接检查步骤是否完成 - } - // 恢复前端运行 - pauseOrStartSimulation(simulation, false); return 1; } @@ -307,9 +301,21 @@ public class Training2Service { if (operation == null) { throw new SimulationException(SimulationExceptionType.Invalid_Operation, "不存在操作"); } - operation.doOperated(); - // 恢复前端运行 - pauseOrStartSimulation(simulation, false); + try { + if (!Step2.StepStatus.isCompletion(operation.getStatus())) { + completeOperationSemaphore.acquire(); + if (!Step2.StepStatus.isCompletion(operation.getStatus())) { + operation.doOperated(); //操作过后 + tryCompleteOperation(simulation, step, operation); // 尝试完成 + // 恢复前端运行 + pauseOrStartSimulation(simulation, false); + } + } + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + completeOperationSemaphore.release(); + } return 1; } @@ -515,6 +521,66 @@ public class Training2Service { return true; } + /** + * 获取步骤中操作,并尝试触发 + */ + private Operation2 getOperationAndTryTrigger(Step2 step, Simulation simulation) { + // 获取步骤中未完成的操作 + Operation2 operation2 = step.getCurrentRunOperation(); + // 操作全部完成的情况,检查步骤完成条件 + if (operation2 == null) { + // TODO 后续判断步骤完成情况 + checkTrainStepCompletion(step, simulation); + return null; + } + // 操作是否已触发 + // 没有触发则检查触发状态,如果可以触发则继续,不能触发则返回(同步骤) + if (!Step2.StepStatus.isAlreadyTrigger(operation2.getStatus()) && !operation2.doTriggerVail()) { + return null; + } + return operation2; + } + + /** + * 尝试操作动作 + */ + private boolean tryDoOperation(Simulation simulation, Step2 step, Operation2 operation2) { + boolean isRobot = step.getSimulationMember().isRobot(); // 角色是否是机器人 + boolean isClient = operation2 instanceof Operation2.ClientOperation2; // 客户端操作 + // 未操作过 + if (Step2.StepStatus.isUndo(operation2.getStatus())) { + if (isRobot) { + if (isClient) { // 客户端操作 + operation2.doOperated(); + } else { // 仿真操 + Operation2.SimOperation2 simOperation2 = (Operation2.SimOperation2) operation2; + atsOperationDispatcher.execute(simulation, step.getSimulationMember(), + simOperation2.getOperationType().name(), simOperation2.getParams()); + } + return true; + } else { // 非机器人,暂停仿真等待用户操作 + pauseOrStartSimulation(simulation, true); + return false; + } + } + return true; + } + + /** + * 尝试完成操作 + */ + private void tryCompleteOperation(Simulation simulation, Step2 step, Operation2 operation2) { + if (Step2.StepStatus.isRunning(operation2.getStatus())) { + boolean completion = operation2.doCompletion(); + // 发送操作完成信息 + sendOperationFinish(operation2, simulation); + // 如果是最后一步,直接检查步骤有没有完成 + if (step.getOperations().indexOf(operation2) == (step.getOperations().size() - 1) && completion) { + checkStepCompletionAndSendNext(step, simulation); + } + } + } + /** * 直接完成并尝试触发下一步 */ @@ -528,7 +594,9 @@ public class Training2Service { if (nextStep == null) { return; } - tryTriggerStep(nextStep, simulation); + if (tryTriggerStep(nextStep, simulation)) { + getOperationAndTryTrigger(nextStep, simulation); + } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Operation2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Operation2.java index 575b2156c..e68ea9ec1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Operation2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Operation2.java @@ -84,8 +84,11 @@ public abstract class Operation2 { if (!result) { // 未失败 result = doSuccessVail(); } - if (result) { + // 这里开始时间为空是因为前端触发太快导致,线程还未走操作触发操作 + if (result && this.startTime != null) { this.remainTime = this.operatedTime.getNano() - this.startTime.getNano(); + } else { + this.remainTime = 0; } return result; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Step2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Step2.java index 426576622..8247b8b4a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Step2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Step2.java @@ -156,7 +156,11 @@ public class Step2 { */ public void completionAndCalculate() { // 整步骤完成耗费时间 - this.remainTime = LocalDateTime.now().getNano() - this.startTime.getNano(); + if (this.startTime != null) { + this.remainTime = LocalDateTime.now().getNano() - this.startTime.getNano(); + } else { + this.remainTime = 0; + } // 操作错误总数 this.count = this.operations.stream().mapToInt(o -> o.getCount().get()).sum(); } From 24866371753468362bebbfa6b1c1c7699a494cc9 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 2 Sep 2022 15:59:05 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E3=80=90=E4=B8=AA=E4=BA=BA=E8=8D=89?= =?UTF-8?q?=E7=A8=BF=E6=B7=BB=E5=8A=A0=E6=97=B6=E9=87=8D=E5=90=8D=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/services/training2/Training2DraftService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java b/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java index c085312e9..19490163a 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java @@ -54,7 +54,7 @@ public class Training2DraftService { public CreateTraining2RspVo createTraining(CreateTraining2ReqVo req, AccountVO user) { //校验是否已经有同名的实训 DraftTraining2Example example = new DraftTraining2Example(); - example.createCriteria().andNameEqualTo(req.getName()); + example.createCriteria().andCreatorIdEqualTo(user.getId()).andNameEqualTo(req.getName()); List check = this.trainingDao.selectByExample(example); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertCollectionEmpty(check, "实训已经存在"); // From 84955a996b427d2d260942be479419ee81ae8af9 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 2 Sep 2022 16:48:43 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E3=80=90=E8=8D=89=E7=A8=BF=E5=90=8C?= =?UTF-8?q?=E5=90=8D=E6=A3=80=E9=AA=8C=E3=80=81=E5=8F=91=E5=B8=83=E5=90=8C?= =?UTF-8?q?=E5=90=8D=E6=A3=80=E9=AA=8C=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Training2DraftPublishService.java | 23 ++++++++++--------- .../training2/Training2DraftService.java | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2DraftPublishService.java b/src/main/java/club/joylink/rtss/services/training2/Training2DraftPublishService.java index e10adc7e1..a7fb0efdf 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2DraftPublishService.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2DraftPublishService.java @@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; + import java.util.List; /** @@ -18,7 +19,7 @@ import java.util.List; @Slf4j public class Training2DraftPublishService { @Autowired - private DraftTraining2DAO trainingDao; + private DraftTraining2DAO trainingDao; @Autowired private PublishedTraining2DAO publishedDao; @@ -26,22 +27,22 @@ public class Training2DraftPublishService { * 草稿发布 */ @Transactional(rollbackFor = Exception.class) - public void draftPublish(TrainingDraftPublishReqVo req,Long userId){ - Long draftId=Long.valueOf(req.getDraftId()); - DraftTraining2Example dtExample=new DraftTraining2Example(); + public void draftPublish(TrainingDraftPublishReqVo req, Long userId) { + Long draftId = Long.valueOf(req.getDraftId()); + DraftTraining2Example dtExample = new DraftTraining2Example(); dtExample.createCriteria().andCreatorIdEqualTo(userId).andIdEqualTo(draftId); - List dtFinds= this.trainingDao.selectByExampleWithBLOBs(dtExample); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=dtFinds&&!dtFinds.isEmpty(),"实训草稿不存在"); - DraftTraining2WithBLOBs draft = dtFinds.get(0); + List dtFinds = this.trainingDao.selectByExampleWithBLOBs(dtExample); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != dtFinds && !dtFinds.isEmpty(), "实训草稿不存在"); + DraftTraining2WithBLOBs draft = dtFinds.get(0); // PublishedTraining2WithBLOBs pub = Training2Convertor.convertFrom(draft); //根据要发布的草稿名称来查找已发布的实训 //如果以有同名的则会被覆盖 - PublishedTraining2Example ptExample=new PublishedTraining2Example(); - ptExample.createCriteria().andNameEqualTo(draft.getName()); - List ptFinds= this.publishedDao.selectByExample(ptExample); + PublishedTraining2Example ptExample = new PublishedTraining2Example(); + ptExample.createCriteria().andNameEqualTo(draft.getName()).andMapIdEqualTo(draft.getMapId()); + List ptFinds = this.publishedDao.selectByExample(ptExample); // - if(null!=ptFinds&&!ptFinds.isEmpty()){//已发布实训存在时则直接删除 + if (null != ptFinds && !ptFinds.isEmpty()) {//已发布实训存在时则直接删除 this.publishedDao.deleteByExample(ptExample); } //发布 diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java b/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java index 19490163a..e76437db0 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java @@ -54,7 +54,7 @@ public class Training2DraftService { public CreateTraining2RspVo createTraining(CreateTraining2ReqVo req, AccountVO user) { //校验是否已经有同名的实训 DraftTraining2Example example = new DraftTraining2Example(); - example.createCriteria().andCreatorIdEqualTo(user.getId()).andNameEqualTo(req.getName()); + example.createCriteria().andCreatorIdEqualTo(user.getId()).andNameEqualTo(req.getName()).andMapIdEqualTo(req.getMapId()); List check = this.trainingDao.selectByExample(example); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertCollectionEmpty(check, "实训已经存在"); // From b0ed14c484f0518ba222749c5fe90286b8b01285 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 2 Sep 2022 17:29:03 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E3=80=90=E5=8C=BA=E6=AE=B5=E6=95=85?= =?UTF-8?q?=E9=9A=9C=E7=B1=BB=E5=9E=8B=E5=8F=8D=E5=BA=8F=E5=88=97=E5=8C=96?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/simulation/cbtc/data/map/MayOutOfOrderDevice.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MayOutOfOrderDevice.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MayOutOfOrderDevice.java index c86c77d21..f8560e933 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MayOutOfOrderDevice.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MayOutOfOrderDevice.java @@ -41,6 +41,7 @@ public abstract class MayOutOfOrderDevice extends StatusDevice { @JsonSubTypes.Type(value = Section.AxleFault.class, name = "Section$AxleFault$2"), @JsonSubTypes.Type(value = Section.AxleFault.class, name = "Section$AxleFault$3"), @JsonSubTypes.Type(value = Section.AxleFault.class, name = "Section$AxleFault$4"), + @JsonSubTypes.Type(value = Section.AxleFault.class, name = "Section$AxleFault$5"), @JsonSubTypes.Type(value = Stand.Fault.class, name = "Stand$Fault$1"), @JsonSubTypes.Type(value = Stand.Fault.class, name = "Stand$Fault$2"), @JsonSubTypes.Type(value = Stand.Fault.class, name = "Stand$Fault$3"), @@ -57,7 +58,9 @@ public abstract class MayOutOfOrderDevice extends StatusDevice { return false; device.setFault(this); return true; - }; + } + + ; default void fix(MayOutOfOrderDevice device) { if (this.equals(device.fault)) From 9c3b6487cda8a962e6bbb75a50b3405c848928e3 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Fri, 2 Sep 2022 18:05:08 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E5=A4=A7=E9=93=81=E8=B0=83=E5=BA=A6?= =?UTF-8?q?=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/cbtc/CTC/rail/dcmd/DCMD.java | 4 - .../cbtc/CTC/rail/dcmd/RailDCMDService.java | 232 ++++++++++++++++-- .../rail/dcmd/receiver/DCMDAllReceiver.java | 32 ++- .../CTC/rail/dcmd/receiver/DCMDReceiver.java | 15 +- .../dcmd/receiver/DCMDStationReceiver.java | 3 +- .../rail/dcmd/receiver/DCMDTrainReceiver.java | 36 ++- 6 files changed, 282 insertions(+), 40 deletions(-) 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 index 45891897b..74ad5a6d4 100644 --- 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 @@ -106,10 +106,6 @@ public class DCMD { * 代签 */ PROXY, - /** - * 拒签 - */ - REFUSE, ; } /** 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 9037bb048..a98b2f480 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 @@ -2,15 +2,15 @@ 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.CTC.rail.dcmd.receiver.*; 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; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; /** * 调度命令数据流控制 @@ -52,7 +52,6 @@ public class RailDCMDService { // cmd.setAllReceivers(new DCMDAllReceiver()); cmd.getAllReceivers().setDcmd(cmd); - cmd.getAllReceivers().setPosCreate(true); // 默认设置编辑中状态 cmd.getAllReceivers().setPosEditing(true); // @@ -60,17 +59,149 @@ public class RailDCMDService { // return cmd; } + /////////////////////////////发送调度命令相关/////////////////////////////////////////////////////////////////////////// /** - * 调度命令的发送,如果受令方在超过一定时间内没有签收,则要重新发 + * 创建者(调度台或车站)发送调度命令 + * @param creator 调度命令的创建平台 + * @param dCmdId 调度命令的id */ + public void sendByCreator(Simulation simulation, SimulationMember creator,String dCmdId){ + CtcRepository ctcRepository = simulation.getCtcRepository(); + DCMD cmd = ctcRepository.getDcmdMap().get(dCmdId); + // + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",dCmdId)); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(creator.getId().equals(cmd.getId()),String.format("调度命令(id=%s)的创建平台(SimulationMember.id=%s)校验失败",dCmdId,creator.getId())); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(cmd.getAllReceivers().getPosSend(),String.format("调度命令(id=%s)被创建者(id=%s)重复发送",dCmdId,creator.getId())); + //发送给车站受令者 + cmd.getAllReceivers().getStationReceivers().forEach(stationReceiver->{ + this.sendToStationByCreator(simulation,stationReceiver); + }); + //发送给列控服务器受令者 + cmd.getAllReceivers().getTsrReceivers().forEach(tsrReceiver->{ + this.sendToTsrByCreator(simulation,tsrReceiver); + }); + //发送给调度台受令者 + cmd.getAllReceivers().getDisReceivers().forEach(disReceiver->{ + this.sendToDisByCreator(simulation,disReceiver); + }); + //发送给无线受令者 + cmd.getAllReceivers().getTrainReceivers().forEach(trainReceiver->{ + this.sendToTrainByCreator(simulation,trainReceiver); + }); + //至此该调度命令发送完,则该调度命令进入该创建者的 发令箱 + cmd.getAllReceivers().setPosSend(true); + } + /** + * 发送给车站 + */ + private void sendToStationByCreator(Simulation simulation,DCMDStationReceiver stationReceiver){ + //发送到收令箱 + if(!stationReceiver.getPosReceive()){ + stationReceiver.setPosReceive(true); + stationReceiver.setReceivedTime(this.getSimLocalDateTime()); + } + //todo 向前端发送收令通知 + } + /** + * 发送给列控服务器 + */ + private void sendToTsrByCreator(Simulation simulation,DCMDTsrReceiver tsrReceiver){ + //发送到收令箱 + if(!tsrReceiver.getPosReceive()){ + tsrReceiver.setPosReceive(true); + tsrReceiver.setReceivedTime(this.getSimLocalDateTime()); + } + //todo 向前端发送收令通知 + } + /** + * 发送给调度台 + */ + private void sendToDisByCreator(Simulation simulation,DCMDDisReceiver disReceiver){ + //发送到收令箱 + if(!disReceiver.getPosReceive()){ + disReceiver.setPosReceive(true); + disReceiver.setReceivedTime(this.getSimLocalDateTime()); + } + //todo 向前端发送收令通知 + } + /** + * 发送给无线机车 + */ + private void sendToTrainByCreator(Simulation simulation,DCMDTrainReceiver trainReceiver){ + //通过GSM移动网络,发送到机车收令箱 + if(trainReceiver.isSendViaGSM()){ + if(!trainReceiver.getPosReceive()){ + trainReceiver.setPosReceive(true); + trainReceiver.setReceivedTime(this.getSimLocalDateTime()); + //todo 向前端发送收令通知 + } + } + //车站自律机通过400M专有网络转发到机车收令箱 + //此时先发送到车站自律机收令箱 + if(trainReceiver.isSendViaSRM()){ + if(!trainReceiver.getPosSrmReceive()){ + trainReceiver.setPosSrmReceive(true); + //待自律机根据转发策略发送到机车 + } + } + } + ////////////////////////////////////////自律机/////////////////////////////////////////////// + /** + * 车站自律机智能自动转发无线调度命令服务 + */ + public void srmAutoSendToTrainSv(Simulation simulation,Station srmStation){ + CtcRepository ctcRepository = simulation.getCtcRepository(); + //筛选出车站自律机收令箱中未转发过的调度命令 + List srmTrainReceiversNotSent = new LinkedList<>(); + ctcRepository.getDcmdMap().forEach((dCmdId,dCmd)->{ + List trs= dCmd.getAllReceivers().getTrainReceivers().stream().filter(tr->{ + //todo 还缺少一个判断该机车是否正在经过该车站的条件 + return tr.isSendViaSRM() //须经过自律机转发 + &&srmStation.getCode().equals(tr.getDisStationCode())//车站自律机 + &&tr.getPosSrmReceive()//已经在车站自律机收令箱中 + &&!tr.getPosSrmSend();//自律机未转发过 + }).collect(Collectors.toList()); + if(null!=trs){ + srmTrainReceiversNotSent.addAll(trs); + } + }); + // + srmTrainReceiversNotSent.forEach(str->{ + this.srmSendToTrain(simulation,str); + }); + } + /** + * 自律机转发无线调度命令 + */ + private void srmSendToTrain(Simulation simulation,DCMDTrainReceiver str){ + //自律机转发无线调度命令 + str.setPosSrmSend(true); + //无线调度命令进入机车的收令箱 + str.setPosReceive(true); + str.setReceivedTime(this.getSimLocalDateTime()); + //todo 向前端发送收令通知机车司机签收 + + } + //////////////////////////////////////////////////调度命令监控相关///////////////////////////////////////////////////// + /** + * 调度命令监控服务 + */ + public void dCmdMonitor(Simulation simulation){ + CtcRepository ctcRepository = simulation.getCtcRepository(); + } + + ///////////////////////////////////////////////////最终受令端签收调度命令,开始////////////////////////////////////////// /** * 列控受令者签收调度命令(前端操作) * @param cmdId 调度命令id * @param tsrCode 列控服务器id * @param signedBy 签收人 + * @param signType 签收类型:签收、代签 */ - public void signForTsr(Simulation simulation,String cmdId,String tsrCode,String signedBy){ + public void signForTsr(Simulation simulation,String cmdId,String tsrCode,String signedBy,DCMD.SignStatus signType){ + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType),String.format("调度命令(id=%s)签收类型(%s)不支持",cmdId,signType)); DCMD cmd = this.findDCMD(simulation,cmdId); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); DCMDTsrReceiver target=null; for(DCMDTsrReceiver tsrReceiver:cmd.getAllReceivers().getTsrReceivers()){ if(tsrCode.equals(tsrReceiver.getTsrCode())){ @@ -83,8 +214,11 @@ public class RailDCMDService { // target.setSignedBy(signedBy); target.setSignedTime(this.getSimLocalDateTime()); - target.setSigState(DCMD.SignStatus.SIGNED); - target.setPosSigned(true); + target.setSigState(signType); + switch (signType){ + case PROXY:target.setPosProxySigned(true);break; + case SIGNED:target.setPosSigned(true);break; + } } /** @@ -92,13 +226,15 @@ public class RailDCMDService { * @param cmdId 调度命令id * @param stationCode 车站code * @param signedBy 签收人 + * @param signType 签收类型:签收、代签 */ - public void signForStation(Simulation simulation,String cmdId,String stationCode,String signedBy){ + public void signForStation(Simulation simulation,String cmdId,String stationCode,String signedBy,DCMD.SignStatus signType){ + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType),String.format("调度命令(id=%s)签收类型(%s)不支持",cmdId,signType)); DCMD cmd = this.findDCMD(simulation,cmdId); - Station station = this.getSimStation(simulation,stationCode); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); DCMDStationReceiver target=null; for(DCMDStationReceiver stationReceiver:cmd.getAllReceivers().getStationReceivers()){ - if(station.getCode().equals(stationReceiver.getReceiver().getCode())){ + if(stationCode.equals(stationReceiver.getStationCode())){ target = stationReceiver; break; } @@ -108,14 +244,78 @@ public class RailDCMDService { // target.setSignedBy(signedBy); target.setSignedTime(this.getSimLocalDateTime()); - target.setSigState(DCMD.SignStatus.SIGNED); - target.setPosSigned(true); - + target.setSigState(signType); + switch (signType){ + case PROXY:target.setPosProxySigned(true);break; + case SIGNED:target.setPosSigned(true);break; + } } + /** + * 调度台受令者签收调度命令(前端操作) + * @param cmdId 调度命令id + * @param disCode 调度台code + * @param signedBy 签收人 + * @param signType 签收类型:签收、代签 + */ + public void signForDispatcher(Simulation simulation,String cmdId,String disCode,String signedBy,DCMD.SignStatus signType){ + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType),String.format("调度命令(id=%s)签收类型(%s)不支持",cmdId,signType)); + DCMD cmd = this.findDCMD(simulation,cmdId); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); + DCMDDisReceiver target=null; + for(DCMDDisReceiver disReceiver:cmd.getAllReceivers().getDisReceivers()){ + if(disCode.equals(disReceiver.getDisCode())){ + target = disReceiver; + break; + } + } + // + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=target,String.format("调度命令(id=%s)的调度台受令者(disCode=%s)不存在",cmdId,disCode)); + // + target.setSignedBy(signedBy); + target.setSignedTime(this.getSimLocalDateTime()); + target.setSigState(signType); + switch (signType){ + case PROXY:target.setPosProxySigned(true);break; + case SIGNED:target.setPosSigned(true);break; + } + } + /** + * 无线受令者签收调度命令(前端操作-车载终端) + * @param cmdId 调度命令id + * @param trainNum 车次号 + * @param trainCode 机车号 + * @param signedBy 签收人 + * @param signType 签收类型:签收、代签 + */ + public void signForTrain(Simulation simulation,String cmdId,String trainNum,String trainCode,String signedBy,DCMD.SignStatus signType){ + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType),String.format("调度命令(id=%s)签收类型(%s)不支持",cmdId,signType)); + DCMD cmd = this.findDCMD(simulation,cmdId); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); + DCMDTrainReceiver target=null; + for(DCMDTrainReceiver trainReceiver:cmd.getAllReceivers().getTrainReceivers()){ + if(trainNum.equals(trainReceiver.getTrainNum())&&trainCode.equals(trainReceiver.getTrainCode())){ + target = trainReceiver; + break; + } + } + // + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=target,String.format("调度命令(id=%s)的无线受令者(车次号=%s , 机车号=%s)不存在",cmdId,trainNum,trainCode)); + // + target.setSignedBy(signedBy); + target.setSignedTime(this.getSimLocalDateTime()); + target.setSigState(signType); + switch (signType){ + case PROXY:target.setPosProxySigned(true);break; + case SIGNED:target.setPosSigned(true);break; + } + if(target.isSendViaSRM()){//如果是车站自律机转发的 + target.setPosSrmSigned(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; } /** 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 index 8750e24f9..335e594b5 100644 --- 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 @@ -1,5 +1,7 @@ package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver; +import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.DCMD; +import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import lombok.Getter; import lombok.Setter; @@ -7,11 +9,15 @@ import java.util.LinkedList; import java.util.List; /** - * 调度命令的创建者编制者对调度命令的管理 + * 对应调度命令的宏观管理 */ @Setter @Getter -public class DCMDAllReceiver extends DCMDReceiver { +public class DCMDAllReceiver{ + /** + * 调度命令 + */ + private DCMD dcmd; /** * 该调度命令的调度台受令者 */ @@ -28,5 +34,25 @@ public class DCMDAllReceiver extends DCMDReceiver { * 该调度命令的列控受令者 */ private final List tsrReceivers = new LinkedList<>(); - + //////////////////////////////////////////////////////////////////////// + /** + * 缓存箱 + */ + private Boolean posCache=false; + /** + * 收令箱 + */ + private Boolean posReceive=false; + /** + * 发令箱 + */ + private Boolean posSend=false; + /** + * 签收完成箱 + */ + private Boolean posSigned=false; + /** + * 编辑中 + */ + private Boolean posEditing=false; } 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 index 3b0316813..81694c7b6 100644 --- 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 @@ -31,7 +31,12 @@ public class DCMDReceiver { * 签收时间 */ private LocalDateTime signedTime; - /////////////////////////////////////////////////// + //////////////////////发送相关///////////////////////////// + /** + * 对该受令者已经发送该调度命令的次数 + */ + private Integer sentCount; + //////////////////////位置状态///////////////////////////// /** * 缓存箱 */ @@ -48,13 +53,13 @@ public class DCMDReceiver { * 签收完成箱 */ private Boolean posSigned=false; + /** + * 代签完成箱 + */ + private Boolean posProxySigned=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 index 1f0132d28..8c6957a1a 100644 --- 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 @@ -7,9 +7,10 @@ import lombok.Setter; @Setter @Getter public class DCMDStationReceiver extends DCMDReceiver { + /** * 受令人 */ - private Station receiver; + private String stationCode; } 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 index 5fec94de1..fd2ccef76 100644 --- 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 @@ -11,32 +11,46 @@ import lombok.Setter; @Getter @Setter public class DCMDTrainReceiver extends DCMDReceiver { + /** - * 中转车站 + * 中转车站code *

* 当为Null时,通过GSM-R通信直接发送给机车;
* 当不为空时,通过车站自律机智能中转;
*/ - private Station disStation; + private String disStationCode; /** * 车次号 */ - private String trainNum; + private String trainNum; /** - * 机车号 + * 机车号(train code) */ - private VirtualRealityTrain train; + private String trainCode; //////////////车站自律机对无线调度命令处理状态///////// /** - * 收令箱 + * 自律机收令箱 */ - private Boolean posReceive=false; + private Boolean posSrmReceive = false; /** - * 发令箱 + * 自律机发令箱 */ - private Boolean posSend=false; + private Boolean posSrmSend = false; /** - * 签收完成箱 + * 自律机签收完成箱 */ - private Boolean posSigned=false; + private Boolean posSrmSigned = false; + //////////////////////////////////////////// + /** + * 直接通过手机移动网络直接发送给机车 + */ + public boolean isSendViaGSM(){ + return !isSendViaSRM(); + } + /** + * 通过车站自律机中转发送给机车 + */ + public boolean isSendViaSRM(){ + return null!=disStationCode&&disStationCode.trim().length()>0; + } } From 43898ba1f2aaf31c52e50dbae25fc5799b30e983 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Mon, 5 Sep 2022 09:24:12 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E5=A4=A7=E9=93=81=E8=B0=83=E5=BA=A6?= =?UTF-8?q?=E5=91=BD=E4=BB=A4-receiversManager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/cbtc/CTC/rail/dcmd/DCMD.java | 8 +++--- .../cbtc/CTC/rail/dcmd/RailDCMDService.java | 28 +++++++++---------- ...eceiver.java => DCMDReceiversManager.java} | 11 ++------ 3 files changed, 21 insertions(+), 26 deletions(-) rename src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/{DCMDAllReceiver.java => DCMDReceiversManager.java} (81%) 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 index 74ad5a6d4..ed92cb442 100644 --- 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 @@ -1,6 +1,6 @@ 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.CTC.rail.dcmd.receiver.DCMDReceiversManager; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import lombok.Getter; import lombok.Setter; @@ -83,11 +83,11 @@ public class DCMD { /** * 调度命令正文 */ - private String content; + private String content; /** - * 调度命令的受令者 + * 调度命令的受令者管理 */ - private DCMDAllReceiver allReceivers; + private DCMDReceiversManager receiversManager; ////////////////////////////////////////////////////////////////////////// /** 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 a98b2f480..40e444861 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 @@ -50,10 +50,10 @@ public class RailDCMDService { cmd.setId(String.valueOf(id)); cmd.setCreator(creator); // - cmd.setAllReceivers(new DCMDAllReceiver()); - cmd.getAllReceivers().setDcmd(cmd); + cmd.setReceiversManager(new DCMDReceiversManager()); + cmd.getReceiversManager().setDcmd(cmd); // 默认设置编辑中状态 - cmd.getAllReceivers().setPosEditing(true); + cmd.getReceiversManager().setPosEditing(true); // ctcRepository.getDcmdMap().put(cmd.getId(),cmd); // @@ -71,25 +71,25 @@ public class RailDCMDService { // BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",dCmdId)); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(creator.getId().equals(cmd.getId()),String.format("调度命令(id=%s)的创建平台(SimulationMember.id=%s)校验失败",dCmdId,creator.getId())); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(cmd.getAllReceivers().getPosSend(),String.format("调度命令(id=%s)被创建者(id=%s)重复发送",dCmdId,creator.getId())); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(cmd.getReceiversManager().getPosSend(),String.format("调度命令(id=%s)被创建者(id=%s)重复发送",dCmdId,creator.getId())); //发送给车站受令者 - cmd.getAllReceivers().getStationReceivers().forEach(stationReceiver->{ + cmd.getReceiversManager().getStationReceivers().forEach(stationReceiver->{ this.sendToStationByCreator(simulation,stationReceiver); }); //发送给列控服务器受令者 - cmd.getAllReceivers().getTsrReceivers().forEach(tsrReceiver->{ + cmd.getReceiversManager().getTsrReceivers().forEach(tsrReceiver->{ this.sendToTsrByCreator(simulation,tsrReceiver); }); //发送给调度台受令者 - cmd.getAllReceivers().getDisReceivers().forEach(disReceiver->{ + cmd.getReceiversManager().getDisReceivers().forEach(disReceiver->{ this.sendToDisByCreator(simulation,disReceiver); }); //发送给无线受令者 - cmd.getAllReceivers().getTrainReceivers().forEach(trainReceiver->{ + cmd.getReceiversManager().getTrainReceivers().forEach(trainReceiver->{ this.sendToTrainByCreator(simulation,trainReceiver); }); //至此该调度命令发送完,则该调度命令进入该创建者的 发令箱 - cmd.getAllReceivers().setPosSend(true); + cmd.getReceiversManager().setPosSend(true); } /** * 发送给车站 @@ -154,7 +154,7 @@ public class RailDCMDService { //筛选出车站自律机收令箱中未转发过的调度命令 List srmTrainReceiversNotSent = new LinkedList<>(); ctcRepository.getDcmdMap().forEach((dCmdId,dCmd)->{ - List trs= dCmd.getAllReceivers().getTrainReceivers().stream().filter(tr->{ + List trs= dCmd.getReceiversManager().getTrainReceivers().stream().filter(tr->{ //todo 还缺少一个判断该机车是否正在经过该车站的条件 return tr.isSendViaSRM() //须经过自律机转发 &&srmStation.getCode().equals(tr.getDisStationCode())//车站自律机 @@ -203,7 +203,7 @@ public class RailDCMDService { DCMD cmd = this.findDCMD(simulation,cmdId); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); DCMDTsrReceiver target=null; - for(DCMDTsrReceiver tsrReceiver:cmd.getAllReceivers().getTsrReceivers()){ + for(DCMDTsrReceiver tsrReceiver:cmd.getReceiversManager().getTsrReceivers()){ if(tsrCode.equals(tsrReceiver.getTsrCode())){ target = tsrReceiver; break; @@ -233,7 +233,7 @@ public class RailDCMDService { DCMD cmd = this.findDCMD(simulation,cmdId); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); DCMDStationReceiver target=null; - for(DCMDStationReceiver stationReceiver:cmd.getAllReceivers().getStationReceivers()){ + for(DCMDStationReceiver stationReceiver:cmd.getReceiversManager().getStationReceivers()){ if(stationCode.equals(stationReceiver.getStationCode())){ target = stationReceiver; break; @@ -262,7 +262,7 @@ public class RailDCMDService { DCMD cmd = this.findDCMD(simulation,cmdId); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); DCMDDisReceiver target=null; - for(DCMDDisReceiver disReceiver:cmd.getAllReceivers().getDisReceivers()){ + for(DCMDDisReceiver disReceiver:cmd.getReceiversManager().getDisReceivers()){ if(disCode.equals(disReceiver.getDisCode())){ target = disReceiver; break; @@ -292,7 +292,7 @@ public class RailDCMDService { DCMD cmd = this.findDCMD(simulation,cmdId); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); DCMDTrainReceiver target=null; - for(DCMDTrainReceiver trainReceiver:cmd.getAllReceivers().getTrainReceivers()){ + for(DCMDTrainReceiver trainReceiver:cmd.getReceiversManager().getTrainReceivers()){ if(trainNum.equals(trainReceiver.getTrainNum())&&trainCode.equals(trainReceiver.getTrainCode())){ target = trainReceiver; break; 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/DCMDReceiversManager.java similarity index 81% rename from src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDAllReceiver.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDReceiversManager.java index 335e594b5..96fa95f0c 100644 --- 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/DCMDReceiversManager.java @@ -1,7 +1,6 @@ package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver; import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.DCMD; -import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import lombok.Getter; import lombok.Setter; @@ -13,7 +12,7 @@ import java.util.List; */ @Setter @Getter -public class DCMDAllReceiver{ +public class DCMDReceiversManager { /** * 调度命令 */ @@ -34,21 +33,17 @@ public class DCMDAllReceiver{ * 该调度命令的列控受令者 */ private final List tsrReceivers = new LinkedList<>(); - //////////////////////////////////////////////////////////////////////// + ////////////////////////////////该调度命令在其创建平台中的状态//////////////////////////////////////// /** * 缓存箱 */ private Boolean posCache=false; - /** - * 收令箱 - */ - private Boolean posReceive=false; /** * 发令箱 */ private Boolean posSend=false; /** - * 签收完成箱 + * 签收完成箱(当其所有受令者都签收时为true) */ private Boolean posSigned=false; /** From a1a6d69d8fdc0bb34df69cb7d19fbccde8134a90 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Mon, 5 Sep 2022 11:18:01 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E5=A4=A7=E9=93=81=E8=B0=83=E5=BA=A6?= =?UTF-8?q?=E5=91=BD=E4=BB=A4-select?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CTC/rail/dcmd/RailDCMDFindService.java | 42 +++ .../CTC/rail/dcmd/RailDCMDSendService.java | 160 ++++++++++ .../cbtc/CTC/rail/dcmd/RailDCMDService.java | 295 ++---------------- .../CTC/rail/dcmd/RailDCMDSignService.java | 140 +++++++++ 4 files changed, 369 insertions(+), 268 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDFindService.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDSendService.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDSignService.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDFindService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDFindService.java new file mode 100644 index 000000000..e795c119e --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDFindService.java @@ -0,0 +1,42 @@ +package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd; + +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 org.springframework.stereotype.Component; + +/** + * 调度命令查询服务 + */ +@Slf4j +@Component +public class RailDCMDFindService { + /** + * 调度台查询与自己相关的所有调度命令 + * @param dispatcher 调度台 + */ + public void findForDispatcher(Simulation simulation, SimulationMember dispatcher){ + + } + /** + * 车站查询与自己相关的所有调度命令 + */ + public void findForStation(Simulation simulation, Station station){ + + } + /** + * 列控查询与自己相关的所有调度命令 + */ + public void findForTsr(Simulation simulation, String tsrCode){ + + } + /** + * 无线受令端查询与自己相关的所有调度命令 + * @param trainCode 机车号 + * @param trainNum 车次号 + */ + public void findForTrain(Simulation simulation,String trainNum, String trainCode){ + + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDSendService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDSendService.java new file mode 100644 index 000000000..d6a202634 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDSendService.java @@ -0,0 +1,160 @@ +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.DCMDDisReceiver; +import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDStationReceiver; +import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDTrainReceiver; +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 org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 调度命令发送相关服务 + */ +@Slf4j +@Component +public class RailDCMDSendService { + @Autowired + private RailDCMDService dCmdService; + /** + * 创建者(调度台或车站)发送调度命令 + * @param creator 调度命令的创建平台 + * @param dCmdId 调度命令的id + */ + public void sendByCreator(Simulation simulation, SimulationMember creator, String dCmdId){ + CtcRepository ctcRepository = simulation.getCtcRepository(); + DCMD cmd = ctcRepository.getDcmdMap().get(dCmdId); + // + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd, String.format("调度命令不存在,id=%s", dCmdId)); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(creator.getId().equals(cmd.getId()),String.format("调度命令(id=%s)的创建平台(SimulationMember.id=%s)校验失败",dCmdId,creator.getId())); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(cmd.getReceiversManager().getPosSend(),String.format("调度命令(id=%s)被创建者(id=%s)重复发送",dCmdId,creator.getId())); + //发送给车站受令者 + cmd.getReceiversManager().getStationReceivers().forEach(stationReceiver->{ + this.sendToStationByCreator(simulation,stationReceiver); + }); + //发送给列控服务器受令者 + cmd.getReceiversManager().getTsrReceivers().forEach(tsrReceiver->{ + this.sendToTsrByCreator(simulation,tsrReceiver); + }); + //发送给调度台受令者 + cmd.getReceiversManager().getDisReceivers().forEach(disReceiver->{ + this.sendToDisByCreator(simulation,disReceiver); + }); + //发送给无线受令者 + cmd.getReceiversManager().getTrainReceivers().forEach(trainReceiver->{ + this.sendToTrainByCreator(simulation,trainReceiver); + }); + //至此该调度命令发送完,则该调度命令进入该创建者的 发令箱 + cmd.getReceiversManager().setPosSend(true); + } + /** + * 发送给车站 + */ + private void sendToStationByCreator(Simulation simulation, DCMDStationReceiver stationReceiver){ + //发送到收令箱 + if(!stationReceiver.getPosReceive()){ + stationReceiver.setPosReceive(true); + stationReceiver.setReceivedTime(dCmdService.getSimLocalDateTime()); + } + //todo 向前端发送收令通知 + } + /** + * 发送给列控服务器 + */ + private void sendToTsrByCreator(Simulation simulation, DCMDTsrReceiver tsrReceiver){ + //发送到收令箱 + if(!tsrReceiver.getPosReceive()){ + tsrReceiver.setPosReceive(true); + tsrReceiver.setReceivedTime(dCmdService.getSimLocalDateTime()); + } + //todo 向前端发送收令通知 + } + /** + * 发送给调度台 + */ + private void sendToDisByCreator(Simulation simulation, DCMDDisReceiver disReceiver){ + //发送到收令箱 + if(!disReceiver.getPosReceive()){ + disReceiver.setPosReceive(true); + disReceiver.setReceivedTime(dCmdService.getSimLocalDateTime()); + } + //todo 向前端发送收令通知 + } + /** + * 发送给无线机车 + */ + private void sendToTrainByCreator(Simulation simulation, DCMDTrainReceiver trainReceiver){ + //通过GSM移动网络,发送到机车收令箱 + if(trainReceiver.isSendViaGSM()){ + if(!trainReceiver.getPosReceive()){ + trainReceiver.setPosReceive(true); + trainReceiver.setReceivedTime(dCmdService.getSimLocalDateTime()); + //todo 向前端发送收令通知 + } + } + //车站自律机通过400M专有网络转发到机车收令箱 + //此时先发送到车站自律机收令箱 + if(trainReceiver.isSendViaSRM()){ + if(!trainReceiver.getPosSrmReceive()){ + trainReceiver.setPosSrmReceive(true); + //待自律机根据转发策略发送到机车 + } + } + } + /** + * 车站自律机能否发送无线调度命令检查 + *

+ * 当机车进入车站400M网络覆盖区时可以发送 + */ + private boolean checkSrmCanSendBy400M(Station srmStation, DCMDTrainReceiver dCmdTrain){ + //todo + return true; + } + ////////////////////////////////////////自律机/////////////////////////////////////////////// + /** + * 车站自律机智能自动转发无线调度命令服务 + */ + public void srmAutoSendToTrainSv(Simulation simulation,Station srmStation){ + CtcRepository ctcRepository = simulation.getCtcRepository(); + //筛选出车站自律机收令箱中未转发过的调度命令 + List srmTrainReceiversNotSent = new LinkedList<>(); + ctcRepository.getDcmdMap().forEach((dCmdId,dCmd)->{ + List trs= dCmd.getReceiversManager().getTrainReceivers().stream().filter(tr->{ + // + return tr.isSendViaSRM() //须经过自律机转发 + &&checkSrmCanSendBy400M(srmStation,tr) + &&srmStation.getCode().equals(tr.getDisStationCode())//车站自律机 + &&tr.getPosSrmReceive()//已经在车站自律机收令箱中 + &&!tr.getPosSrmSend();//自律机未转发过 + }).collect(Collectors.toList()); + if(null!=trs){ + srmTrainReceiversNotSent.addAll(trs); + } + }); + // + srmTrainReceiversNotSent.forEach(str->{ + this.srmSendToTrain(simulation,srmStation,str); + }); + } + /** + * 自律机转发无线调度命令 + */ + private void srmSendToTrain(Simulation simulation,Station srmStation,DCMDTrainReceiver str){ + log.debug("==>>自律机车站(code = %s)发送无线调度命令(code = %s)给机车(code = %s)",srmStation.getCode(),str.getDcmd().getCode(),str.getTrainCode()); + //自律机转发无线调度命令 + str.setPosSrmSend(true); + //无线调度命令进入机车的收令箱 + str.setPosReceive(true); + str.setReceivedTime(dCmdService.getSimLocalDateTime()); + //todo 向前端发送收令通知机车司机签收 + + } +} 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 40e444861..010549fc0 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 @@ -7,37 +7,30 @@ 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 org.springframework.stereotype.Component; import java.time.LocalDateTime; -import java.util.LinkedList; -import java.util.List; -import java.util.stream.Collectors; + /** - * 调度命令数据流控制 + * 调度命令基础服务 *

* 调度命令分类:
* 普通调度命令、施工调度命令、转发调度命令、请求调度命令、长效调度命令、班计划调度命令 + * 调度命令由调度台开始发出: + *

+ * 调度台1->调度台2
+ * 调度台->车站车务终端
+ * 无线调度命令立即发送:调度台->(通过GSM-R)车载终端
+ * 无线调度命令智能发送:调度台->(中转)车站自律机->(通过无线通信)车载终端
+ * 列控调度命令:调度台->TSR列控限速服务器 + *

+ * 调度命令由车站开始发出:
+ * TDCS2.0车站调度命令管理:请求调度命令、车站调度命令、机车(无线)调度命令 */ @Slf4j +@Component public class RailDCMDService { - /** - * 调度命令由调度台开始发出: - *

- * 调度台1->调度台2
- * 调度台->车站车务终端
- * 无线调度命令立即发送:调度台->(通过GSM-R)车载终端
- * 无线调度命令智能发送:调度台->(中转)车站自律机->(通过无线通信)车载终端
- * 列控调度命令:调度台->TSR列控限速服务器 - *

- * 调度命令由车站开始发出:
- * TDCS2.0车站调度命令管理:请求调度命令、车站调度命令、机车(无线)调度命令 - */ - public void dispatcher (Simulation simulation, SimulationMember sender){ - //todo 将前端发送来的调度命令转换为 RailDCMD - DCMD cmd = new DCMD(); - - } /** * 新建调度命令 * @param creator 调度台或车站 @@ -59,261 +52,27 @@ public class RailDCMDService { // return cmd; } - /////////////////////////////发送调度命令相关/////////////////////////////////////////////////////////////////////////// /** - * 创建者(调度台或车站)发送调度命令 - * @param creator 调度命令的创建平台 - * @param dCmdId 调度命令的id + * 保存或缓存调度命令 + * @param creator 调度台或车站 + * @param dCmdId 调度命令id + * @param simulation 当前仿真 */ - public void sendByCreator(Simulation simulation, SimulationMember creator,String dCmdId){ - CtcRepository ctcRepository = simulation.getCtcRepository(); - DCMD cmd = ctcRepository.getDcmdMap().get(dCmdId); - // - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",dCmdId)); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(creator.getId().equals(cmd.getId()),String.format("调度命令(id=%s)的创建平台(SimulationMember.id=%s)校验失败",dCmdId,creator.getId())); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(cmd.getReceiversManager().getPosSend(),String.format("调度命令(id=%s)被创建者(id=%s)重复发送",dCmdId,creator.getId())); - //发送给车站受令者 - cmd.getReceiversManager().getStationReceivers().forEach(stationReceiver->{ - this.sendToStationByCreator(simulation,stationReceiver); - }); - //发送给列控服务器受令者 - cmd.getReceiversManager().getTsrReceivers().forEach(tsrReceiver->{ - this.sendToTsrByCreator(simulation,tsrReceiver); - }); - //发送给调度台受令者 - cmd.getReceiversManager().getDisReceivers().forEach(disReceiver->{ - this.sendToDisByCreator(simulation,disReceiver); - }); - //发送给无线受令者 - cmd.getReceiversManager().getTrainReceivers().forEach(trainReceiver->{ - this.sendToTrainByCreator(simulation,trainReceiver); - }); - //至此该调度命令发送完,则该调度命令进入该创建者的 发令箱 - cmd.getReceiversManager().setPosSend(true); - } - /** - * 发送给车站 - */ - private void sendToStationByCreator(Simulation simulation,DCMDStationReceiver stationReceiver){ - //发送到收令箱 - if(!stationReceiver.getPosReceive()){ - stationReceiver.setPosReceive(true); - stationReceiver.setReceivedTime(this.getSimLocalDateTime()); - } - //todo 向前端发送收令通知 - } - /** - * 发送给列控服务器 - */ - private void sendToTsrByCreator(Simulation simulation,DCMDTsrReceiver tsrReceiver){ - //发送到收令箱 - if(!tsrReceiver.getPosReceive()){ - tsrReceiver.setPosReceive(true); - tsrReceiver.setReceivedTime(this.getSimLocalDateTime()); - } - //todo 向前端发送收令通知 - } - /** - * 发送给调度台 - */ - private void sendToDisByCreator(Simulation simulation,DCMDDisReceiver disReceiver){ - //发送到收令箱 - if(!disReceiver.getPosReceive()){ - disReceiver.setPosReceive(true); - disReceiver.setReceivedTime(this.getSimLocalDateTime()); - } - //todo 向前端发送收令通知 - } - /** - * 发送给无线机车 - */ - private void sendToTrainByCreator(Simulation simulation,DCMDTrainReceiver trainReceiver){ - //通过GSM移动网络,发送到机车收令箱 - if(trainReceiver.isSendViaGSM()){ - if(!trainReceiver.getPosReceive()){ - trainReceiver.setPosReceive(true); - trainReceiver.setReceivedTime(this.getSimLocalDateTime()); - //todo 向前端发送收令通知 - } - } - //车站自律机通过400M专有网络转发到机车收令箱 - //此时先发送到车站自律机收令箱 - if(trainReceiver.isSendViaSRM()){ - if(!trainReceiver.getPosSrmReceive()){ - trainReceiver.setPosSrmReceive(true); - //待自律机根据转发策略发送到机车 - } - } - } - ////////////////////////////////////////自律机/////////////////////////////////////////////// - /** - * 车站自律机智能自动转发无线调度命令服务 - */ - public void srmAutoSendToTrainSv(Simulation simulation,Station srmStation){ - CtcRepository ctcRepository = simulation.getCtcRepository(); - //筛选出车站自律机收令箱中未转发过的调度命令 - List srmTrainReceiversNotSent = new LinkedList<>(); - ctcRepository.getDcmdMap().forEach((dCmdId,dCmd)->{ - List trs= dCmd.getReceiversManager().getTrainReceivers().stream().filter(tr->{ - //todo 还缺少一个判断该机车是否正在经过该车站的条件 - return tr.isSendViaSRM() //须经过自律机转发 - &&srmStation.getCode().equals(tr.getDisStationCode())//车站自律机 - &&tr.getPosSrmReceive()//已经在车站自律机收令箱中 - &&!tr.getPosSrmSend();//自律机未转发过 - }).collect(Collectors.toList()); - if(null!=trs){ - srmTrainReceiversNotSent.addAll(trs); - } - }); - // - srmTrainReceiversNotSent.forEach(str->{ - this.srmSendToTrain(simulation,str); - }); - } - /** - * 自律机转发无线调度命令 - */ - private void srmSendToTrain(Simulation simulation,DCMDTrainReceiver str){ - //自律机转发无线调度命令 - str.setPosSrmSend(true); - //无线调度命令进入机车的收令箱 - str.setPosReceive(true); - str.setReceivedTime(this.getSimLocalDateTime()); - //todo 向前端发送收令通知机车司机签收 + public void save(Simulation simulation, SimulationMember creator , String dCmdId){ } - //////////////////////////////////////////////////调度命令监控相关///////////////////////////////////////////////////// + /** * 调度命令监控服务 + *

+ * 监控调度命令签收情况;综合分析后向前端推送通知 */ - public void dCmdMonitor(Simulation simulation){ + public void monitor(Simulation simulation){ CtcRepository ctcRepository = simulation.getCtcRepository(); - } - - ///////////////////////////////////////////////////最终受令端签收调度命令,开始////////////////////////////////////////// - /** - * 列控受令者签收调度命令(前端操作) - * @param cmdId 调度命令id - * @param tsrCode 列控服务器id - * @param signedBy 签收人 - * @param signType 签收类型:签收、代签 - */ - public void signForTsr(Simulation simulation,String cmdId,String tsrCode,String signedBy,DCMD.SignStatus signType){ - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType),String.format("调度命令(id=%s)签收类型(%s)不支持",cmdId,signType)); - DCMD cmd = this.findDCMD(simulation,cmdId); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); - DCMDTsrReceiver target=null; - for(DCMDTsrReceiver tsrReceiver:cmd.getReceiversManager().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(signType); - switch (signType){ - case PROXY:target.setPosProxySigned(true);break; - case SIGNED:target.setPosSigned(true);break; - } } - /** - * 车站受令者签收调度命令(前端操作) - * @param cmdId 调度命令id - * @param stationCode 车站code - * @param signedBy 签收人 - * @param signType 签收类型:签收、代签 - */ - public void signForStation(Simulation simulation,String cmdId,String stationCode,String signedBy,DCMD.SignStatus signType){ - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType),String.format("调度命令(id=%s)签收类型(%s)不支持",cmdId,signType)); - DCMD cmd = this.findDCMD(simulation,cmdId); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); - DCMDStationReceiver target=null; - for(DCMDStationReceiver stationReceiver:cmd.getReceiversManager().getStationReceivers()){ - if(stationCode.equals(stationReceiver.getStationCode())){ - 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(signType); - switch (signType){ - case PROXY:target.setPosProxySigned(true);break; - case SIGNED:target.setPosSigned(true);break; - } - } - /** - * 调度台受令者签收调度命令(前端操作) - * @param cmdId 调度命令id - * @param disCode 调度台code - * @param signedBy 签收人 - * @param signType 签收类型:签收、代签 - */ - public void signForDispatcher(Simulation simulation,String cmdId,String disCode,String signedBy,DCMD.SignStatus signType){ - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType),String.format("调度命令(id=%s)签收类型(%s)不支持",cmdId,signType)); - DCMD cmd = this.findDCMD(simulation,cmdId); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); - DCMDDisReceiver target=null; - for(DCMDDisReceiver disReceiver:cmd.getReceiversManager().getDisReceivers()){ - if(disCode.equals(disReceiver.getDisCode())){ - target = disReceiver; - break; - } - } - // - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=target,String.format("调度命令(id=%s)的调度台受令者(disCode=%s)不存在",cmdId,disCode)); - // - target.setSignedBy(signedBy); - target.setSignedTime(this.getSimLocalDateTime()); - target.setSigState(signType); - switch (signType){ - case PROXY:target.setPosProxySigned(true);break; - case SIGNED:target.setPosSigned(true);break; - } - } - /** - * 无线受令者签收调度命令(前端操作-车载终端) - * @param cmdId 调度命令id - * @param trainNum 车次号 - * @param trainCode 机车号 - * @param signedBy 签收人 - * @param signType 签收类型:签收、代签 - */ - public void signForTrain(Simulation simulation,String cmdId,String trainNum,String trainCode,String signedBy,DCMD.SignStatus signType){ - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType),String.format("调度命令(id=%s)签收类型(%s)不支持",cmdId,signType)); - DCMD cmd = this.findDCMD(simulation,cmdId); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); - DCMDTrainReceiver target=null; - for(DCMDTrainReceiver trainReceiver:cmd.getReceiversManager().getTrainReceivers()){ - if(trainNum.equals(trainReceiver.getTrainNum())&&trainCode.equals(trainReceiver.getTrainCode())){ - target = trainReceiver; - break; - } - } - // - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=target,String.format("调度命令(id=%s)的无线受令者(车次号=%s , 机车号=%s)不存在",cmdId,trainNum,trainCode)); - // - target.setSignedBy(signedBy); - target.setSignedTime(this.getSimLocalDateTime()); - target.setSigState(signType); - switch (signType){ - case PROXY:target.setPosProxySigned(true);break; - case SIGNED:target.setPosSigned(true);break; - } - if(target.isSendViaSRM()){//如果是车站自律机转发的 - target.setPosSrmSigned(true); - } - } - ///////////////////////////////////////////////////最终受令端签收调度命令,结束///////////////////////////////////////////////////////////////////// - private DCMD findDCMD(Simulation simulation,String cmdId){ + ////////////////////////////////////公共工具方法/////////////////////////////////////////////// + public DCMD findDCMD(Simulation simulation,String cmdId){ CtcRepository ctcRepository = simulation.getCtcRepository(); DCMD cmd= ctcRepository.getDcmdMap().get(cmdId); return cmd; @@ -321,11 +80,11 @@ public class RailDCMDService { /** * 获取仿真当前时间 */ - private LocalDateTime getSimLocalDateTime(){ + public LocalDateTime getSimLocalDateTime(){ //暂时设置为系统时间 return LocalDateTime.now(); } - private Station getSimStation(Simulation simulation,String stationCode){ + public 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/RailDCMDSignService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDSignService.java new file mode 100644 index 000000000..42192793f --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDSignService.java @@ -0,0 +1,140 @@ +package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd; + +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDDisReceiver; +import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDStationReceiver; +import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDTrainReceiver; +import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDTsrReceiver; +import club.joylink.rtss.simulation.cbtc.Simulation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 调度命令签收相关服务 + */ +@Component +public class RailDCMDSignService { + @Autowired + private RailDCMDService dCmdService; + /** + * 列控受令者签收调度命令(前端操作) + * @param cmdId 调度命令id + * @param tsrCode 列控服务器id + * @param signedBy 签收人 + * @param signType 签收类型:签收、代签 + */ + public void signForTsr(Simulation simulation, String cmdId, String tsrCode, String signedBy, DCMD.SignStatus signType){ + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType), String.format("调度命令(id=%s)签收类型(%s)不支持", cmdId, signType)); + DCMD cmd = dCmdService.findDCMD(simulation,cmdId); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); + DCMDTsrReceiver target=null; + for(DCMDTsrReceiver tsrReceiver:cmd.getReceiversManager().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(dCmdService.getSimLocalDateTime()); + target.setSigState(signType); + switch (signType){ + case PROXY:target.setPosProxySigned(true);break; + case SIGNED:target.setPosSigned(true);break; + } + + } + /** + * 车站受令者签收调度命令(前端操作) + * @param cmdId 调度命令id + * @param stationCode 车站code + * @param signedBy 签收人 + * @param signType 签收类型:签收、代签 + */ + public void signForStation(Simulation simulation,String cmdId,String stationCode,String signedBy,DCMD.SignStatus signType){ + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType),String.format("调度命令(id=%s)签收类型(%s)不支持",cmdId,signType)); + DCMD cmd = dCmdService.findDCMD(simulation,cmdId); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); + DCMDStationReceiver target=null; + for(DCMDStationReceiver stationReceiver:cmd.getReceiversManager().getStationReceivers()){ + if(stationCode.equals(stationReceiver.getStationCode())){ + target = stationReceiver; + break; + } + } + // + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=target,String.format("调度命令(id=%s)的车站受令者(stationCode=%s)不存在",cmdId,stationCode)); + // + target.setSignedBy(signedBy); + target.setSignedTime(dCmdService.getSimLocalDateTime()); + target.setSigState(signType); + switch (signType){ + case PROXY:target.setPosProxySigned(true);break; + case SIGNED:target.setPosSigned(true);break; + } + } + /** + * 调度台受令者签收调度命令(前端操作) + * @param cmdId 调度命令id + * @param disCode 调度台code + * @param signedBy 签收人 + * @param signType 签收类型:签收、代签 + */ + public void signForDispatcher(Simulation simulation,String cmdId,String disCode,String signedBy,DCMD.SignStatus signType){ + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType),String.format("调度命令(id=%s)签收类型(%s)不支持",cmdId,signType)); + DCMD cmd = dCmdService.findDCMD(simulation,cmdId); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); + DCMDDisReceiver target=null; + for(DCMDDisReceiver disReceiver:cmd.getReceiversManager().getDisReceivers()){ + if(disCode.equals(disReceiver.getDisCode())){ + target = disReceiver; + break; + } + } + // + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=target,String.format("调度命令(id=%s)的调度台受令者(disCode=%s)不存在",cmdId,disCode)); + // + target.setSignedBy(signedBy); + target.setSignedTime(dCmdService.getSimLocalDateTime()); + target.setSigState(signType); + switch (signType){ + case PROXY:target.setPosProxySigned(true);break; + case SIGNED:target.setPosSigned(true);break; + } + } + /** + * 无线受令者签收调度命令(前端操作-车载终端) + * @param cmdId 调度命令id + * @param trainNum 车次号 + * @param trainCode 机车号 + * @param signedBy 签收人 + * @param signType 签收类型:签收、代签 + */ + public void signForTrain(Simulation simulation,String cmdId,String trainNum,String trainCode,String signedBy,DCMD.SignStatus signType){ + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType),String.format("调度命令(id=%s)签收类型(%s)不支持",cmdId,signType)); + DCMD cmd = dCmdService.findDCMD(simulation,cmdId); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId)); + DCMDTrainReceiver target=null; + for(DCMDTrainReceiver trainReceiver:cmd.getReceiversManager().getTrainReceivers()){ + if(trainNum.equals(trainReceiver.getTrainNum())&&trainCode.equals(trainReceiver.getTrainCode())){ + target = trainReceiver; + break; + } + } + // + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=target,String.format("调度命令(id=%s)的无线受令者(车次号=%s , 机车号=%s)不存在",cmdId,trainNum,trainCode)); + // + target.setSignedBy(signedBy); + target.setSignedTime(dCmdService.getSimLocalDateTime()); + target.setSigState(signType); + switch (signType){ + case PROXY:target.setPosProxySigned(true);break; + case SIGNED:target.setPosSigned(true);break; + } + if(target.isSendViaSRM()){//如果是车站自律机转发的 + target.setPosSrmSigned(true); + } + } +}