From e9cc4510b4f2ea87aba5b05f00b29065b252d961 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Tue, 6 Sep 2022 16:59:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E5=BA=A6=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/CTC/data/CtcRepository.java | 4 + .../simulation/cbtc/CTC/rail/cmd/DisCmd.java | 7 +- .../cbtc/CTC/rail/cmd/DisCmdRcvCompany.java | 64 ++++-- .../cbtc/CTC/rail/cmd/DisCmdSendCompany.java | 21 +- .../cbtc/CTC/rail/cmd/DisCmdService.java | 192 ++++++++++++++++-- .../rail/cmd/convertor/DisCmdConvertor.java | 24 +++ .../CTC/rail/cmd/vo/DisCmdHolderEnum.java | 11 + .../CTC/rail/cmd/vo/DisCmdRcvCompanyVo.java | 14 ++ .../CTC/rail/cmd/vo/DisCmdSendCompanyVo.java | 14 ++ .../cbtc/CTC/rail/cmd/vo/DisCmdVo.java | 15 ++ .../cmd/vo/FindAllDisCmdForHolderRspVo.java | 27 +++ 11 files changed, 350 insertions(+), 43 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/convertor/DisCmdConvertor.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdHolderEnum.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdRcvCompanyVo.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdSendCompanyVo.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdVo.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/FindAllDisCmdForHolderRspVo.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 10eca4ac7..a61ab21fb 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 @@ -113,6 +113,10 @@ public class CtcRepository { * 调度命令id生成器 */ private AtomicInteger dispatchCommandIdGenerator = new AtomicInteger(0); + /** + * 调度命令受令单位id生成器 + */ + private AtomicInteger disCmdRcvCompanyIdGenerator = new AtomicInteger(0); /** * 新版调度命令 * k - 调度命令id diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmd.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmd.java index 7216264d1..966341257 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmd.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmd.java @@ -1,7 +1,5 @@ package club.joylink.rtss.simulation.cbtc.CTC.rail.cmd; - -import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import lombok.Data; import java.time.LocalDateTime; import java.util.List; @@ -38,7 +36,7 @@ public class DisCmd { /** * 值班主任(仿真成员) */ - private SimulationMember chiefOnDuty; + private String chiefOnDuty; /** * 需值班主任授权 */ @@ -54,7 +52,7 @@ public class DisCmd { /** * 审核人(仿真成员) */ - private SimulationMember reviewer; + private String reviewer; /** * 日计划号 */ @@ -91,5 +89,6 @@ public class DisCmd { */ NORMAL, ; + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmdRcvCompany.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmdRcvCompany.java index 95f6f71e2..f4e288568 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmdRcvCompany.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmdRcvCompany.java @@ -1,7 +1,7 @@ package club.joylink.rtss.simulation.cbtc.CTC.rail.cmd; +import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import lombok.Data; - import java.time.LocalDateTime; /** @@ -10,77 +10,107 @@ import java.time.LocalDateTime; @Data public class DisCmdRcvCompany { + /** + * 调度命令号(唯一) + */ + private String disCmdCode; + /** + * 唯一id,记录id + */ + private String id; /** * 受令单位类型 */ - private Type type; + private Type type; /** * 受令单位名称 */ - private String name; + private String name; //////////////////受令者///////////////////// /** * 车站受令者code */ - private String stationCode; + private String stationCode; /** * 调度台受令者code */ - private String disCode; + private String disCode; /** * 列控服务器受令者code */ - private String tsrCode; + private String tsrCode; //////////////////受令者train//////////////////////// /** * 无线调度命令,true-通过手机移动网络直接发送,false-通过车站专有网络发送 */ - private Boolean trainViaGsmR = true; + private Boolean trainViaGsmR = true; /** * 中转车站code *
* 当trainViaGsmR=false时,不为空。 */ - private String transStationCode; + private String transStationCode; /** * 车次号 */ - private String trainNum; + private String trainNum; /** * 机车号(train code) */ - private String trainCode; + private String trainCode; /////////////////////运行时数据////////////////// /** * 最终受令端对于调度命令的状态 */ - private Status state; + private Status state; /** * 最终受令端对于调度命令的接收时间 */ - private LocalDateTime receiveTime; + private LocalDateTime receiveTime; /** * 最终受令端对于调度命令的签收时间 */ - private LocalDateTime signTime; + private LocalDateTime signTime; + /** + * 最终受令端对于调度命令的实际签收人 + */ + private SimulationMember signByReal; /** * 无线调度命令的中转站对调度命令的状态 */ - private TransStatus transStatus; + private TransStatus transStatus; /** * 无线调度命令的中转站对调度命令的接收时间 */ - private LocalDateTime transReceiveTime; + private LocalDateTime transReceiveTime; /** * 无线调度命令的中转站对调度命令的发送时间 */ - private LocalDateTime transSendTime; + private LocalDateTime transSendTime; + /** + * 自律机是否执行转发调度命令 + */ + private boolean exeTransSend = false; + /** + * 向最终受令单位的前端推送通知的次数,前端签收后将停止推送通知 + */ + private int countForReceiveNotify = 0; + /** + * 下一次向前端推送通知的时刻,注意使用的是计时机系统时间而不是仿真系统时间 + *
+ * 单位为毫秒
+ */
+ private long timeForNextReceiveNotify = System.currentTimeMillis();
+ /**
+ * 记录上次向前端推送签收调度命的通知的时间
+ */
+ private LocalDateTime lastSendReceiveNotifyTime;
///////////////////////////////////////////////
/**
* 发令单位类型
*/
- public static enum Type {
+ public enum Type {
Dispatcher,//调度台
Station,//车站
Train,//无线
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmdSendCompany.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmdSendCompany.java
index 6f03a181c..daf06769c 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmdSendCompany.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmdSendCompany.java
@@ -9,32 +9,39 @@ import java.time.LocalDateTime;
*/
@Data
public class DisCmdSendCompany {
-
/**
* 发令单位类型
*/
- private Type type;
+ private Type type;
/**
* 发令单位名称
*/
- private String name;
+ private String name;
+ /**
+ * 发令单位code
+ */
+ private String code;
+ /**
+ * 调度命令号(唯一)
+ */
+ private String disCmdCode;
//////////////////运行时数据////////////////
/**
* 调度命令对应发令单的状态
*/
- private Status state;
+ private Status state;
/**
* 发令时间
*/
- private LocalDateTime sendTime;
+ private LocalDateTime sendTime;
/**
* 是否执行过发令(非业务状态)
*/
- private boolean exeSend = false;
+ private boolean exeSend = false;
/**
* 签收完成时间
*/
- private LocalDateTime signedTime;
+ private LocalDateTime signedTime;
//////////////////////////////////////////
/**
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmdService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmdService.java
index a466d0849..b0081b8aa 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmdService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmdService.java
@@ -2,7 +2,12 @@ package club.joylink.rtss.simulation.cbtc.CTC.rail.cmd;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository;
+import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.convertor.DisCmdConvertor;
+import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo.DisCmdHolderEnum;
+import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo.DisCmdVo;
+import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo.FindAllDisCmdForHolderRspVo;
import club.joylink.rtss.simulation.cbtc.Simulation;
+import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
@@ -31,7 +36,7 @@ public class DisCmdService {
disCmd.getSendCompany().setState(DisCmdSendCompany.Status.Cache);
}
/**
- * 发送调度命令
+ * 发送调度命令给通信服务器
* @param disCmdCode 调度命令号
*/
public void send(Simulation simulation,String disCmdCode){
@@ -46,13 +51,13 @@ public class DisCmdService {
sc.setSendTime(this.getNow(simulation));
}
/**
- * 接收调度命令
+ * 通信服务器分发调度命令
*/
- public void receiveLoop(Simulation simulation){
+ public void distributeLoop(Simulation simulation){
CtcRepository ctcRepository = simulation.getCtcRepository();
- List
- * 修改发送单位签收状态
*/
public void monitorLoop(Simulation simulation){
+ simulation.getCtcRepository().getDisCmdMap().values().forEach(cmd->{
+ DisCmdSendCompany sendCompany = cmd.getSendCompany();
+ //监控受令方签收情况来更新发令方签收状态
+ if(!DisCmdSendCompany.Status.Signed.equals(sendCompany.getState())){
+ boolean signed = true;
+ for(DisCmdRcvCompany rc:cmd.getRcvCompanies()){
+ if(!DisCmdRcvCompany.Status.Signed.equals(rc.getState())){
+ signed = false;
+ break;
+ }
+ }
+ if(signed){
+ sendCompany.setState(DisCmdSendCompany.Status.Signed);
+ sendCompany.setSignedTime(this.getNow(simulation));
+ }
+ }
+ //todo: 根据监控向前端推送其他通知
+
+ });
}
+
+ /**
+ * 查询与持有者相关的调度命令
+ * @param holderType 持有者类型
+ * @param holderCode 持有者code,如调度台、车站、列控的code,列车除了有code还有车次
+ * @param trainNum 车次,当持有者类型为机车时才有效
+ */
+ private FindAllDisCmdForHolderRspVo findAllForHolder(Simulation simulation, DisCmdHolderEnum holderType,String holderCode,String trainNum){
+ FindAllDisCmdForHolderRspVo rsp = new FindAllDisCmdForHolderRspVo();
+ simulation.getCtcRepository().getDisCmdMap().values().forEach(cmd->{
+ boolean hasCmd = false;
+ DisCmdSendCompany sc = cmd.getSendCompany();
+ List
+ * 注意如果向列控服务器推送通知,则系统自动处理通知签收
+ */
+ private void sendNotifyToRcvCompany(Simulation simulation,DisCmdRcvCompany rc){
+
+ }
+ /**
+ * 判断机车是否在该车站内(todo:暂时不考虑上下行)
+ * @param stationCode 车站code
+ * @param trainNum 车次号
+ * @param trainCode 机车号
+ * @param simulation 仿真
+ */
+ private boolean checkTrainInStation(Simulation simulation,String trainNum,String trainCode,String stationCode){
+ //todo
+ return true;
+ }
/**
* 根据调度命令号获取调度命令
*/
- public DisCmd find(Simulation simulation,String disCmdCode){
+ private DisCmd find(Simulation simulation,String disCmdCode){
CtcRepository ctcRepository = simulation.getCtcRepository();
return ctcRepository.getDisCmdMap().get(disCmdCode);
}
/**
- * 获取仿真当前时间(暂时)
+ * 获取仿真当前时间
*/
- public LocalDateTime getNow(Simulation simulation){
- return LocalDateTime.now();
+ private LocalDateTime getNow(Simulation simulation){
+ return simulation.getSystemTime();
}
}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/convertor/DisCmdConvertor.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/convertor/DisCmdConvertor.java
new file mode 100644
index 000000000..c429d72f6
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/convertor/DisCmdConvertor.java
@@ -0,0 +1,24 @@
+package club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.convertor;
+
+import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.DisCmd;
+import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.DisCmdRcvCompany;
+import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.DisCmdSendCompany;
+import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo.DisCmdRcvCompanyVo;
+import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo.DisCmdSendCompanyVo;
+import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo.DisCmdVo;
+
+public class DisCmdConvertor {
+
+ public static DisCmdVo convert(DisCmd from){
+
+ return null;
+ }
+ public static DisCmdSendCompanyVo convert(DisCmdSendCompany from){
+
+ return null;
+ }
+ public static DisCmdRcvCompanyVo convert(DisCmdRcvCompany from){
+
+ return null;
+ }
+}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdHolderEnum.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdHolderEnum.java
new file mode 100644
index 000000000..bd6c4e74a
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdHolderEnum.java
@@ -0,0 +1,11 @@
+package club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo;
+/**
+ * 发令或受令实体类型
+ */
+public enum DisCmdHolderEnum {
+ Dispatcher,//调度台
+ Station,//车站
+ Train,//无线
+ Tsr,//列控服务器
+ ;
+}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdRcvCompanyVo.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdRcvCompanyVo.java
new file mode 100644
index 000000000..a30566749
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdRcvCompanyVo.java
@@ -0,0 +1,14 @@
+package club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo;
+
+import lombok.Data;
+
+/**
+ * 受令单位
+ */
+@Data
+public class DisCmdRcvCompanyVo {
+ /**
+ * 调度命令号(唯一)
+ */
+ private String disCmdCode;
+}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdSendCompanyVo.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdSendCompanyVo.java
new file mode 100644
index 000000000..86e06d72c
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdSendCompanyVo.java
@@ -0,0 +1,14 @@
+package club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo;
+
+import lombok.Data;
+
+/**
+ * 发令单位
+ */
+@Data
+public class DisCmdSendCompanyVo {
+ /**
+ * 调度命令号(唯一)
+ */
+ private String disCmdCode;
+}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdVo.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdVo.java
new file mode 100644
index 000000000..0ba01a38d
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/DisCmdVo.java
@@ -0,0 +1,15 @@
+package club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo;
+
+import lombok.Data;
+
+@Data
+public class DisCmdVo {
+ /**
+ * 标题
+ */
+ private String title;
+ /**
+ * 调度命令号(唯一)
+ */
+ private String code;
+}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/FindAllDisCmdForHolderRspVo.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/FindAllDisCmdForHolderRspVo.java
new file mode 100644
index 000000000..bbf28d2ac
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/vo/FindAllDisCmdForHolderRspVo.java
@@ -0,0 +1,27 @@
+package club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo;
+
+import lombok.Data;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 为某个持有者返回与其相关的所有调度命令
+ */
+@Data
+public class FindAllDisCmdForHolderRspVo {
+
+ /**
+ * 调度命令列表
+ */
+ private Map