调度命令

This commit is contained in:
xzb 2022-09-05 18:19:34 +08:00
parent a20441b1ec
commit 335590cd0c
19 changed files with 423 additions and 824 deletions

View File

@ -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());
}
/**
* 更新当前用户实训草稿定位

View File

@ -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<DraftTraining2> 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);
}
/**
* 更新用户实训草稿的地图定位信息
*/

View File

@ -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<String, DCMD> dcmdMap = new ConcurrentHashMap<>();
private final Map<String, DisCmd> disCmdMap = new ConcurrentHashMap<>();
/**
* 调度命令
* k - 调度命令id

View File

@ -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<DisCmdRcvCompany> rcvCompanies;
///////////////////////////////////////////////
/**
* 调度命令类型
*/
public enum Type {
/**
* 正常调度命令
*/
NORMAL,
;
}
}

View File

@ -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
* <p>
* 当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,//发送
;
}
}

View File

@ -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,//签收完成(所有受令者签收完成)
;
}
}

View File

@ -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<DisCmd> 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
});
});
}
}
/**
* 无线调度命令的智能发送
* <p>
* 车站自律机根据策略发送无线调令
*/
public void srmSendLoop(Simulation simulation){
}
/**
* 受令方收件箱收到调令后向前端发送通知来签收调令
* <p>
* 注意当在一定时间内没有签收则须重发通知
*/
public void sendNotifyLoop(Simulation simulation){
}
/**
* 处理前端发送来的签收指令
*/
public void sign(Simulation simulation,String disCmdCode){
}
/**
* 监控签收等
* <p>
* 修改发送单位签收状态
*/
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();
}
}

View File

@ -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,;
}
}

View File

@ -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;
}

View File

@ -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){
}
}

View File

@ -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);
//待自律机根据转发策略发送到机车
}
}
}
/**
* 车站自律机能否发送无线调度命令检查
* <p>
* 当机车进入车站400M网络覆盖区时可以发送
*/
private boolean checkSrmCanSendBy400M(Station srmStation, DCMDTrainReceiver dCmdTrain){
//todo
return true;
}
////////////////////////////////////////自律机///////////////////////////////////////////////
/**
* 车站自律机智能自动转发无线调度命令服务
*/
public void srmAutoSendToTrainSv(Simulation simulation,Station srmStation){
CtcRepository ctcRepository = simulation.getCtcRepository();
//筛选出车站自律机收令箱中未转发过的调度命令
List<DCMDTrainReceiver> srmTrainReceiversNotSent = new LinkedList<>();
ctcRepository.getDcmdMap().forEach((dCmdId,dCmd)->{
List<DCMDTrainReceiver> 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 向前端发送收令通知机车司机签收
}
}

View File

@ -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;
/**
* 调度命令基础服务
* <p>
* 调度命令分类<br>
* 普通调度命令施工调度命令转发调度命令请求调度命令长效调度命令班计划调度命令
* 调度命令由调度台开始发出
* <p>
* 调度台1->调度台2<br>
* 调度台->车站车务终端<br>
* 无线调度命令立即发送调度台->(通过GSM-R)车载终端<br>
* 无线调度命令智能发送调度台->(中转)车站自律机->(通过无线通信)车载终端<br>
* 列控调度命令调度台->TSR列控限速服务器
* <p>
* 调度命令由车站开始发出<br>
* 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){
}
/**
* 调度命令监控服务
* <p>
* 监控调度命令签收情况综合分析后向前端推送通知
*/
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;
}
}

View File

@ -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);
}
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<DCMDDisReceiver> disReceivers = new LinkedList<>();
/**
* 该调度命令的车站受令者
*/
private final List<DCMDStationReceiver> stationReceivers = new LinkedList<>();
/**
* 该调度命令的机车受令者
*/
private final List<DCMDTrainReceiver> trainReceivers = new LinkedList<>();
/**
* 该调度命令的列控受令者
*/
private final List<DCMDTsrReceiver> tsrReceivers = new LinkedList<>();
////////////////////////////////该调度命令在其创建平台中的状态////////////////////////////////////////
/**
* 缓存箱
*/
private Boolean posCache=false;
/**
* 发令箱
*/
private Boolean posSend=false;
/**
* 签收完成箱(当其所有受令者都签收时为true)
*/
private Boolean posSigned=false;
/**
* 编辑中
*/
private Boolean posEditing=false;
}

View File

@ -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;
}

View File

@ -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
* <p>
* 当为Null时通过GSM-R通信直接发送给机车<br>
* 当不为空时通过车站自律机智能中转<br>
*/
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;
}
}

View File

@ -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;
}