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] =?UTF-8?q?=E5=A4=A7=E9=93=81=E8=B0=83=E5=BA=A6=E5=91=BD?= =?UTF-8?q?=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; + } }