大铁调度命令
This commit is contained in:
parent
71d735a7cb
commit
9c3b6487cd
@ -106,10 +106,6 @@ public class DCMD {
|
||||
* 代签
|
||||
*/
|
||||
PROXY,
|
||||
/**
|
||||
* 拒签
|
||||
*/
|
||||
REFUSE,
|
||||
;
|
||||
}
|
||||
/**
|
||||
|
@ -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<DCMDTrainReceiver> srmTrainReceiversNotSent = new LinkedList<>();
|
||||
ctcRepository.getDcmdMap().forEach((dCmdId,dCmd)->{
|
||||
List<DCMDTrainReceiver> 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;
|
||||
}
|
||||
/**
|
||||
|
@ -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<DCMDTsrReceiver> tsrReceivers = new LinkedList<>();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 缓存箱
|
||||
*/
|
||||
private Boolean posCache=false;
|
||||
/**
|
||||
* 收令箱
|
||||
*/
|
||||
private Boolean posReceive=false;
|
||||
/**
|
||||
* 发令箱
|
||||
*/
|
||||
private Boolean posSend=false;
|
||||
/**
|
||||
* 签收完成箱
|
||||
*/
|
||||
private Boolean posSigned=false;
|
||||
/**
|
||||
* 编辑中
|
||||
*/
|
||||
private Boolean posEditing=false;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,10 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@Getter
|
||||
public class DCMDStationReceiver extends DCMDReceiver {
|
||||
|
||||
/**
|
||||
* 受令人
|
||||
*/
|
||||
private Station receiver;
|
||||
private String stationCode;
|
||||
|
||||
}
|
||||
|
@ -11,32 +11,46 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
public class DCMDTrainReceiver extends DCMDReceiver {
|
||||
|
||||
/**
|
||||
* 中转车站
|
||||
* 中转车站code
|
||||
* <p>
|
||||
* 当为Null时,通过GSM-R通信直接发送给机车;<br>
|
||||
* 当不为空时,通过车站自律机智能中转;<br>
|
||||
*/
|
||||
private Station disStation;
|
||||
private String disStationCode;
|
||||
/**
|
||||
* 车次号
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user