diff --git a/src/main/java/club/joylink/rtss/controller/training2/TrainingDraftV2Controller.java b/src/main/java/club/joylink/rtss/controller/training2/TrainingDraftV2Controller.java index da26d57f7..9b033356f 100644 --- a/src/main/java/club/joylink/rtss/controller/training2/TrainingDraftV2Controller.java +++ b/src/main/java/club/joylink/rtss/controller/training2/TrainingDraftV2Controller.java @@ -78,6 +78,13 @@ public class TrainingDraftV2Controller { public void resetTrainingBackground(@RequestBody ResetTraining2BackgroudReqVo req, @RequestAttribute AccountVO user) { this.training2DraftService.resetTrainingBackground(req, user.getId()); } + /** + * 重置当前用户的某个实训草稿的内容 + */ + @PostMapping("/reset/{trainingId}") + public void resetTraining(@PathVariable("trainingId") Long trainingId, @RequestAttribute AccountVO user) { + this.training2DraftService.resetTraining(trainingId,user.getId()); + } /** * 更新当前用户实训草稿定位 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 e76437db0..2303e5625 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java @@ -144,7 +144,31 @@ public class Training2DraftService { // this.trainingDao.updateByExampleSelective(b, example); } - + /** + * 重置用户实训草稿 + */ + @Transactional(rollbackFor = Exception.class) + public void resetTraining(Long trainingId,Long userId){ + DraftTraining2Example example = new DraftTraining2Example(); + example.createCriteria().andCreatorIdEqualTo(userId).andIdEqualTo(trainingId); + List find = this.trainingDao.selectByExample(example); + // + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != find && !find.isEmpty(), "实训草稿不存在"); + // + DraftTraining2WithBLOBs b = new DraftTraining2WithBLOBs(); + b.setBgSceneJson(""); + b.setUpdateTime(LocalDateTime.now()); + b.setMapLocationJson(""); + b.setFailureConditionJson(""); + b.setFinalScenesJson(""); + b.setMemberJson(""); + b.setOperaJson(""); + b.setPlayerIdJson(""); + b.setScoringRuleJson(""); + b.setStepJson(""); + // + this.trainingDao.updateByExampleSelective(b, example); + } /** * 更新用户实训草稿的地图定位信息 */ 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 39feb3071..10eca4ac7 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,7 +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.CTC.rail.cmd.DisCmd; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; @@ -117,7 +117,7 @@ public class CtcRepository { * 新版调度命令 * k - 调度命令id */ - private final Map dcmdMap = new ConcurrentHashMap<>(); + private final Map disCmdMap = new ConcurrentHashMap<>(); /** * 调度命令 * 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 new file mode 100644 index 000000000..7216264d1 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmd.java @@ -0,0 +1,95 @@ +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; + +/** + * 调度命令定义 + */ +@Data +public class DisCmd { + /** + * 标题 + */ + private String title; + /** + * 调度命令号(唯一) + */ + private String code; + /** + * 中转识别号 + */ + private String transitId; + /** + * 发令时间 + */ + private LocalDateTime sendTime; + /** + * 发令人 + */ + private String sender; + /** + * 授权时间 + */ + 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 DisCmdSendCompany sendCompany; + /** + * 受令单位列表 + */ + private List rcvCompanies; + /////////////////////////////////////////////// + + /** + * 调度命令类型 + */ + public enum Type { + /** + * 正常调度命令 + */ + 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 new file mode 100644 index 000000000..95f6f71e2 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmdRcvCompany.java @@ -0,0 +1,108 @@ +package club.joylink.rtss.simulation.cbtc.CTC.rail.cmd; + +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 调度命令受令单位 + */ +@Data +public class DisCmdRcvCompany { + + /** + * 受令单位类型 + */ + private Type type; + /** + * 受令单位名称 + */ + private String name; + //////////////////受令者///////////////////// + /** + * 车站受令者code + */ + private String stationCode; + /** + * 调度台受令者code + */ + private String disCode; + /** + * 列控服务器受令者code + */ + private String tsrCode; + //////////////////受令者train//////////////////////// + /** + * 无线调度命令,true-通过手机移动网络直接发送,false-通过车站专有网络发送 + */ + private Boolean trainViaGsmR = true; + /** + * 中转车站code + *

+ * 当trainViaGsmR=false时,不为空。 + */ + private String transStationCode; + /** + * 车次号 + */ + private String trainNum; + /** + * 机车号(train code) + */ + private String trainCode; + /////////////////////运行时数据////////////////// + /** + * 最终受令端对于调度命令的状态 + */ + private Status state; + /** + * 最终受令端对于调度命令的接收时间 + */ + private LocalDateTime receiveTime; + /** + * 最终受令端对于调度命令的签收时间 + */ + private LocalDateTime signTime; + /** + * 无线调度命令的中转站对调度命令的状态 + */ + private TransStatus transStatus; + /** + * 无线调度命令的中转站对调度命令的接收时间 + */ + private LocalDateTime transReceiveTime; + /** + * 无线调度命令的中转站对调度命令的发送时间 + */ + private LocalDateTime transSendTime; + /////////////////////////////////////////////// + + /** + * 发令单位类型 + */ + public static enum Type { + Dispatcher,//调度台 + Station,//车站 + Train,//无线 + Tsr,//列控服务器 + ; + } + + /** + * 受令单位对于调度命令的状态 + */ + public enum Status { + Received,//接收 + Signed,//签收 + ; + } + + /** + * 无线调度命令时中转站对于调度命令的状态 + */ + public enum TransStatus { + Received,//接收 + Sent,//发送 + ; + } +} 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 new file mode 100644 index 000000000..6f03a181c --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmdSendCompany.java @@ -0,0 +1,58 @@ +package club.joylink.rtss.simulation.cbtc.CTC.rail.cmd; + +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 调度命令发令单位 + */ +@Data +public class DisCmdSendCompany { + + /** + * 发令单位类型 + */ + private Type type; + /** + * 发令单位名称 + */ + private String name; + //////////////////运行时数据//////////////// + /** + * 调度命令对应发令单的状态 + */ + private Status state; + /** + * 发令时间 + */ + private LocalDateTime sendTime; + /** + * 是否执行过发令(非业务状态) + */ + private boolean exeSend = false; + /** + * 签收完成时间 + */ + private LocalDateTime signedTime; + ////////////////////////////////////////// + + /** + * 发令单位类型 + */ + public enum Type { + Dispatcher,//调度台 + Station,//车站 + ; + } + + /** + * 发令单位对调度命令的状态 + */ + public enum Status { + Cache,//缓存 + Send,//发送 + Signed,//签收完成(所有受令者签收完成) + ; + } +} 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 new file mode 100644 index 000000000..a466d0849 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/cmd/DisCmdService.java @@ -0,0 +1,128 @@ +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.Simulation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + +@Slf4j +@Component +public class DisCmdService { + /** + * 新建调度命令,仅仅是生成一个调度命令号返回 + */ + public String create(Simulation simulation){ + CtcRepository ctcRepository = simulation.getCtcRepository(); + int id = ctcRepository.getDispatchCommandIdGenerator().getAndIncrement(); + return String.valueOf(id); + } + /** + * 保存调度命令,保存到发送方缓存箱(保存到仓库) + */ + public void save(Simulation simulation,DisCmd disCmd){ + // + CtcRepository ctcRepository = simulation.getCtcRepository(); + ctcRepository.getDisCmdMap().put(disCmd.getCode(),disCmd); + // + disCmd.getSendCompany().setState(DisCmdSendCompany.Status.Cache); + } + /** + * 发送调度命令 + * @param disCmdCode 调度命令号 + */ + public void send(Simulation simulation,String disCmdCode){ + DisCmd cmd = this.find(simulation,disCmdCode); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd, String.format("仿真(%s),调度命令(%s)不存在", simulation.getId(),disCmdCode)); + //发令单位 + DisCmdSendCompany sc= cmd.getSendCompany(); + //只有在缓存或保存状态的才能发送 + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(DisCmdSendCompany.Status.Cache.equals(sc.getState()),String.format("仿真(%s),调度命令(%s)发送方状态不为缓存状态", simulation.getId(),disCmdCode)); + //修改发送单位状态为发令 + sc.setState(DisCmdSendCompany.Status.Send); + sc.setSendTime(this.getNow(simulation)); + } + /** + * 接收调度命令 + */ + public void receiveLoop(Simulation simulation){ + CtcRepository ctcRepository = simulation.getCtcRepository(); + List cmdList= ctcRepository.getDisCmdMap().values().stream().filter(cmd->{ + return DisCmdSendCompany.Status.Send.equals(cmd.getSendCompany().getState()) + &&!cmd.getSendCompany().isExeSend();//发令但未执行 + }).collect(Collectors.toList()); + if(null!=cmdList){ + cmdList.forEach(cmd->{ + cmd.getRcvCompanies().forEach(rc->{ + // + cmd.getSendCompany().setExeSend(true); + // + switch (rc.getType()){ + case Tsr: + case Station: + case Dispatcher:{ + rc.setState(DisCmdRcvCompany.Status.Received); + rc.setReceiveTime(this.getNow(simulation)); + }break; + case Train:{ + if(rc.getTrainViaGsmR()){//通过手机移动网络直接送到机车接收箱 + rc.setState(DisCmdRcvCompany.Status.Received); + rc.setReceiveTime(this.getNow(simulation)); + }else{//通过车站自律机中转,先投送到车站自律机接收箱 + rc.setTransStatus(DisCmdRcvCompany.TransStatus.Received); + rc.setTransReceiveTime(this.getNow(simulation)); + } + } + }//switch + }); + }); + } + } + /** + * 无线调度命令的智能发送 + *

+ * 车站自律机根据策略发送无线调令 + */ + public void srmSendLoop(Simulation simulation){ + + } + /** + * 受令方收件箱收到调令后,向前端发送通知来签收调令 + *

+ * 注意,当在一定时间内没有签收,则须重发通知 + */ + public void sendNotifyLoop(Simulation simulation){ + + } + /** + * 处理前端发送来的签收指令 + */ + public void sign(Simulation simulation,String disCmdCode){ + + } + /** + * 监控签收等 + *

+ * 修改发送单位签收状态 + */ + public void monitorLoop(Simulation simulation){ + + } + //////////////////////////////////工具方法//////////////////////////////// + /** + * 根据调度命令号获取调度命令 + */ + public DisCmd find(Simulation simulation,String disCmdCode){ + CtcRepository ctcRepository = simulation.getCtcRepository(); + return ctcRepository.getDisCmdMap().get(disCmdCode); + } + /** + * 获取仿真当前时间(暂时) + */ + public LocalDateTime getNow(Simulation simulation){ + return LocalDateTime.now(); + } +} 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 deleted file mode 100644 index ed92cb442..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/DCMD.java +++ /dev/null @@ -1,122 +0,0 @@ -package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd; - -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; -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 DCMDReceiversManager receiversManager; - ////////////////////////////////////////////////////////////////////////// - - /** - * 签收状态 - */ - public enum SignStatus { - /** - *未签收 - */ - UNSIGNED, - /** - * 签收 - */ - SIGNED, - /** - * 代签 - */ - PROXY, - ; - } - /** - * 调度命令类型 - */ - 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 deleted file mode 100644 index 68bbfb008..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/DCMDReceipt.java +++ /dev/null @@ -1,46 +0,0 @@ -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/RailDCMDFindService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDFindService.java deleted file mode 100644 index e795c119e..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDFindService.java +++ /dev/null @@ -1,42 +0,0 @@ -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 deleted file mode 100644 index d6a202634..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDSendService.java +++ /dev/null @@ -1,160 +0,0 @@ -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 deleted file mode 100644 index 010549fc0..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDService.java +++ /dev/null @@ -1,92 +0,0 @@ -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.*; -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; - - -/** - * 调度命令基础服务 - *

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

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

- * 调度命令由车站开始发出:
- * TDCS2.0车站调度命令管理:请求调度命令、车站调度命令、机车(无线)调度命令 - */ -@Slf4j -@Component -public class RailDCMDService { - - /** - * 新建调度命令 - * @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.setReceiversManager(new DCMDReceiversManager()); - cmd.getReceiversManager().setDcmd(cmd); - // 默认设置编辑中状态 - cmd.getReceiversManager().setPosEditing(true); - // - ctcRepository.getDcmdMap().put(cmd.getId(),cmd); - // - return cmd; - } - /** - * 保存或缓存调度命令 - * @param creator 调度台或车站 - * @param dCmdId 调度命令id - * @param simulation 当前仿真 - */ - public void save(Simulation simulation, SimulationMember creator , String dCmdId){ - - } - - /** - * 调度命令监控服务 - *

- * 监控调度命令签收情况;综合分析后向前端推送通知 - */ - public void monitor(Simulation simulation){ - CtcRepository ctcRepository = simulation.getCtcRepository(); - - } - ////////////////////////////////////公共工具方法/////////////////////////////////////////////// - public DCMD findDCMD(Simulation simulation,String cmdId){ - CtcRepository ctcRepository = simulation.getCtcRepository(); - DCMD cmd= ctcRepository.getDcmdMap().get(cmdId); - return cmd; - } - /** - * 获取仿真当前时间 - */ - public LocalDateTime getSimLocalDateTime(){ - //暂时设置为系统时间 - return LocalDateTime.now(); - } - 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 deleted file mode 100644 index 42192793f..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/RailDCMDSignService.java +++ /dev/null @@ -1,140 +0,0 @@ -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); - } - } -} 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 deleted file mode 100644 index a82b96d1c..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDDisReceiver.java +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index 81694c7b6..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDReceiver.java +++ /dev/null @@ -1,65 +0,0 @@ -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 Integer sentCount; - //////////////////////位置状态///////////////////////////// - /** - * 缓存箱 - */ - private Boolean posCache=false; - /** - * 收令箱 - */ - private Boolean posReceive=false; - /** - * 发令箱 - */ - private Boolean posSend=false; - /** - * 签收完成箱 - */ - private Boolean posSigned=false; - /** - * 代签完成箱 - */ - private Boolean posProxySigned=false; - /** - * 编辑中 - */ - private Boolean posEditing=false; - -} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDReceiversManager.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDReceiversManager.java deleted file mode 100644 index 96fa95f0c..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDReceiversManager.java +++ /dev/null @@ -1,53 +0,0 @@ -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.util.LinkedList; -import java.util.List; - -/** - * 对应调度命令的宏观管理 - */ -@Setter -@Getter -public class DCMDReceiversManager { - /** - * 调度命令 - */ - private DCMD dcmd; - /** - * 该调度命令的调度台受令者 - */ - private final List disReceivers = new LinkedList<>(); - /** - * 该调度命令的车站受令者 - */ - private final List stationReceivers = new LinkedList<>(); - /** - * 该调度命令的机车受令者 - */ - private final List trainReceivers = new LinkedList<>(); - /** - * 该调度命令的列控受令者 - */ - private final List tsrReceivers = new LinkedList<>(); - ////////////////////////////////该调度命令在其创建平台中的状态//////////////////////////////////////// - /** - * 缓存箱 - */ - private Boolean posCache=false; - /** - * 发令箱 - */ - private Boolean posSend=false; - /** - * 签收完成箱(当其所有受令者都签收时为true) - */ - private Boolean posSigned=false; - /** - * 编辑中 - */ - private Boolean posEditing=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 deleted file mode 100644 index 8c6957a1a..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDStationReceiver.java +++ /dev/null @@ -1,16 +0,0 @@ -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 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 deleted file mode 100644 index fd2ccef76..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDTrainReceiver.java +++ /dev/null @@ -1,56 +0,0 @@ -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 { - - /** - * 中转车站code - *

- * 当为Null时,通过GSM-R通信直接发送给机车;
- * 当不为空时,通过车站自律机智能中转;
- */ - private String disStationCode; - /** - * 车次号 - */ - private String trainNum; - /** - * 机车号(train code) - */ - private String trainCode; - //////////////车站自律机对无线调度命令处理状态///////// - /** - * 自律机收令箱 - */ - private Boolean posSrmReceive = false; - /** - * 自律机发令箱 - */ - private Boolean posSrmSend = false; - /** - * 自律机签收完成箱 - */ - private Boolean posSrmSigned = false; - //////////////////////////////////////////// - /** - * 直接通过手机移动网络直接发送给机车 - */ - public boolean isSendViaGSM(){ - return !isSendViaSRM(); - } - /** - * 通过车站自律机中转发送给机车 - */ - public boolean isSendViaSRM(){ - return null!=disStationCode&&disStationCode.trim().length()>0; - } -} 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 deleted file mode 100644 index c4a3d3864..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/receiver/DCMDTsrReceiver.java +++ /dev/null @@ -1,15 +0,0 @@ -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; - -}