调度命令

This commit is contained in:
xzb 2022-09-14 15:43:38 +08:00
parent 4c5225e19d
commit cc73a5448f
21 changed files with 245 additions and 158 deletions

View File

@ -114,12 +114,20 @@ public class CtcRepository {
*/
private AtomicInteger dispatchCommandIdGenerator = new AtomicInteger(0);
/**
* 调度命令受令单位id生成器
* 调度命令记录行id生成器
*/
private AtomicInteger disCmdRcvCompanyIdGenerator = new AtomicInteger(0);
private AtomicInteger disCmdIdGenerator = new AtomicInteger(0);
/**
* 调度命令号生成器
*/
private AtomicInteger disCmdCodeGenerator = new AtomicInteger(0);
/**
* 调度命令受令单位记录行id生成器
*/
private AtomicInteger disCmdRcIdGenerator = new AtomicInteger(0);
/**
* 新版调度命令
* k - 调度命令id
* k - 调度命令记录id即cmdId
*/
private final Map<String, DisCmd> disCmdMap = new ConcurrentHashMap<>();
/**

View File

@ -28,10 +28,10 @@ public class RailCtcDisCmdOperateHandler {
private DisCmdFindService disCmdFindService;
/**
* 新建调度命令仅仅是生成一个调度命令号返回
* 新建调度命令
*/
@OperateHandlerMapping(type = Operation.Type.CTC_NEW_DIS_COMMAND)
public String create(Simulation simulation) {
public DisCmdCreateRspVo create(Simulation simulation) {
return disCmdService.create(simulation);
}
/**
@ -43,21 +43,21 @@ public class RailCtcDisCmdOperateHandler {
}
/**
* 发送调度命令给通信服务器
* @param disCmdCode 调度命令号
* @param cmdId 调度命令记录id
*/
@OperateHandlerMapping(type = Operation.Type.CTC_SEND_DIS_COMMAND)
public void send(Simulation simulation, String disCmdCode) {
disCmdService.send(simulation, disCmdCode);
public void send(Simulation simulation, String cmdId) {
disCmdService.send(simulation, cmdId);
}
/**
* 处理前端发送来的正常签收指令
* @param disCmdCode 调度命令号
* @param cmdId 调度命令记录id
* @param rcId 对于该调度命令的受令单位id
* @param signer 实际签收人(仿真成员)
*/
@OperateHandlerMapping(type = Operation.Type.CTC_SIGN_DIS_COMMAND)
public void sign(Simulation simulation, String disCmdCode, String rcId, SimulationMember signer) {
disCmdSignService.sign(simulation, disCmdCode, rcId, signer);
public void sign(Simulation simulation, String cmdId, String rcId, SimulationMember signer) {
disCmdSignService.sign(simulation, cmdId, rcId, signer);
}
/**
* 处理前端发送来的代签签收指令
@ -70,31 +70,31 @@ public class RailCtcDisCmdOperateHandler {
}
/**
* 处理前端发送来的拒签指令
* @param disCmdCode 调度命令号
* @param cmdId 调度命令记录id
* @param rcId 对于该调度命令的受令单位id
* @param signer 实际拒签人(仿真成员)
*/
@OperateHandlerMapping(type = Operation.Type.CTC_SIGN_REJECT_DIS_COMMAND)
public void rejectSign(Simulation simulation, String disCmdCode, String rcId, SimulationMember signer) {
disCmdSignService.rejectSign(simulation, disCmdCode, rcId, signer);
public void rejectSign(Simulation simulation, String cmdId, String rcId, SimulationMember signer) {
disCmdSignService.rejectSign(simulation, cmdId, rcId, signer);
}
/**
* 阅读调度命令
* @param disCmdCode 调度命令号
* @param rcId 对于该调度命令的受令单位记录id
* @param cmdId 调度命令记录id
* @param rcId 对于该调度命令的受令单位记录id
*/
@OperateHandlerMapping(type = Operation.Type.CTC_READ_DIS_COMMAND)
public void read(Simulation simulation, String disCmdCode, String rcId) {
disCmdService.read(simulation, disCmdCode, rcId);
public void read(Simulation simulation, String cmdId, String rcId) {
disCmdService.read(simulation, cmdId, rcId);
}
/**
* 查看调度命令的回执记录
* @param disCmdCode 调度命令号
* @param cmdId 调度命令记录id
*/
@OperateHandlerMapping(type = Operation.Type.CTC_QUERY_RECEIPT_DIS_COMMAND)
public List<ReceiptVo> findReceipts(Simulation simulation, String disCmdCode) {
return disCmdReceiptService.findReceipts(simulation, disCmdCode);
public List<ReceiptVo> findReceipts(Simulation simulation, String cmdId) {
return disCmdReceiptService.findReceipts(simulation, cmdId);
}
/**
@ -110,11 +110,11 @@ public class RailCtcDisCmdOperateHandler {
/**
* 删除缓存箱中的某条调度命令
* @param cpId 调度命令的创建平台识别号
* @param disCmdCode
* @param cmdId
*/
@OperateHandlerMapping(type = Operation.Type.CTC_DELETE_DIS_COMMAND)
public void deleteFromCache(Simulation simulation,String cpId,String disCmdCode){
disCmdService.deleteFromCache(simulation,cpId,disCmdCode);
public void deleteFromCache(Simulation simulation,String cpId,String cmdId){
disCmdService.deleteFromCache(simulation,cpId,cmdId);
}
/**
* 清空缓存箱中的所有调度命令

View File

@ -10,6 +10,14 @@ import java.util.Map;
*/
@Data
public class DisCmd {
/**
* 调度命令记录行id(全局唯一)
*/
private String cmdId;
/**
* 调度命令号(不一定唯一)
*/
private String cmdCode;
/**
* 调度命令的创建平台识别号
*/
@ -18,10 +26,6 @@ public class DisCmd {
* 标题
*/
private String title;
/**
* 调度命令号(唯一)
*/
private String code;
/**
* 中转识别号
*/

View File

@ -19,11 +19,10 @@ import java.util.List;
@RequestMapping("/simulation")
public class DisCmdApiController {
/**
* 新建调度命令仅仅是生成一个调度命令号返回
* @return 调度命令号
* 新建调度命令
*/
@PostMapping("/1-5471-194-903/operate/CTC_NEW_DIS_COMMAND")
public String create() {
public DisCmdCreateRspVo create() {
return null;
}
/**
@ -136,17 +135,17 @@ public class DisCmdApiController {
*/
private String cpId;
/**
* 要删除的调度命令
* 要删除的调度命令记录id
*/
private String disCmdCode;
private String cmdId;
}
@Data
public static class FindReceiptsReqVo{
/**
* 调度命令
* 调度命令记录id
*/
private String disCmdCode;
private String cmdId;
}
@Data
public static class FindReqVo{
@ -168,16 +167,16 @@ public class DisCmdApiController {
@Data
public static class SendReqVo{
/**
* 调度命令
* 调度命令记录id
*/
private String disCmdCode;
private String cmdId;
}
@Data
public static class SignReqVo{
/**
* 调度命令
* 调度命令记录id
*/
private String disCmdCode;
private String cmdId;
/**
* 对于该调度命令的受令单位记录id
*/
@ -186,9 +185,9 @@ public class DisCmdApiController {
@Data
public static class ReadReqVo{
/**
* 调度命令
* 调度命令记录id
*/
private String disCmdCode;
private String cmdId;
/**
* 对于该调度命令的受令单位记录id
*/
@ -197,9 +196,9 @@ public class DisCmdApiController {
@Data
public static class RejectSignReqVo{
/**
* 调度命令
* 调度命令记录id
*/
private String disCmdCode;
private String cmdId;
/**
* 对于该调度命令的受令单位记录id
*/

View File

@ -11,13 +11,17 @@ import java.time.LocalDateTime;
public class DisCmdRcvCompany {
/**
* 调度命令(唯一)
* 调度命令记录行id(全局唯一)
*/
private String disCmdCode;
private String cmdId;
/**
* 调度命令号(不一定唯一)
*/
private String cmdCode;
/**
* 唯一id,记录id
*/
private String id;
private String rcId;
/**
* 受令单位类型
*/

View File

@ -22,9 +22,13 @@ public class DisCmdSendCompany {
*/
private String code;
/**
* 调度命令(唯一)
* 调度命令记录行id(全局唯一)
*/
private String disCmdCode;
private String cmdId;
/**
* 调度命令号(不一定唯一)
*/
private String cmdCode;
//////////////////运行时数据////////////////
/**
* 调度命令对应发令单的状态

View File

@ -16,7 +16,8 @@ public class DisCmdConvertor {
public static DisCmdRspVo convert(DisCmd from){
DisCmdRspVo to = new DisCmdRspVo();
to.setAuthState(from.getAuthState());
to.setCode(from.getCode());
to.setCmdId(from.getCmdId());
to.setCmdCode(from.getCmdCode());
to.setAuthTime(from.getAuthTime());
to.setContent(from.getContent());
to.setChiefOnDuty(from.getChiefOnDuty());
@ -35,7 +36,8 @@ public class DisCmdConvertor {
}
public static DisCmdSendCompanyVo convert(DisCmdSendCompany from){
DisCmdSendCompanyVo to = new DisCmdSendCompanyVo();
to.setDisCmdCode(from.getDisCmdCode());
to.setCmdId(from.getCmdId());
to.setCmdCode(from.getCmdCode());
to.setCode(from.getCode());
to.setName(from.getName());
to.setSendTime(from.getSendTime());
@ -45,7 +47,8 @@ public class DisCmdConvertor {
return to;
}
public static DisCmdSendCompany convert(DisCmdSendCompanyVo from,DisCmdSendCompany to){
to.setDisCmdCode(from.getDisCmdCode());
to.setCmdId(from.getCmdId());
to.setCmdCode(from.getCmdCode());
to.setCode(from.getCode());
to.setName(from.getName());
to.setSendTime(from.getSendTime());
@ -56,9 +59,10 @@ public class DisCmdConvertor {
}
public static DisCmdRcvCompanyVo convert(DisCmdRcvCompany from){
DisCmdRcvCompanyVo to = new DisCmdRcvCompanyVo();
to.setDisCmdCode(from.getDisCmdCode());
to.setCmdCode(from.getCmdCode());
to.setCmdId(from.getCmdId());
to.setDisCode(from.getDisCode());
to.setId(from.getId());
to.setRcId(from.getRcId());
to.setName(from.getName());
to.setState(from.getState().name());
to.setSignBy(from.getSignBy());
@ -78,9 +82,10 @@ public class DisCmdConvertor {
}
public static DisCmdRcvCompany convert(DisCmdRcvCompanyVo from){
DisCmdRcvCompany to = new DisCmdRcvCompany();
to.setDisCmdCode(from.getDisCmdCode());
to.setCmdId(from.getCmdId());
to.setCmdCode(from.getCmdCode());
to.setDisCode(from.getDisCode());
to.setId(from.getId());
to.setRcId(from.getRcId());
to.setName(from.getName());
to.setState(DisCmdRcvCompany.Status.valueOf(from.getState()));
to.setSignBy(from.getSignBy());
@ -102,7 +107,8 @@ public class DisCmdConvertor {
//
to.setCpId(from.getCpId());
to.setAuthState(from.getAuthState());
to.setCode(from.getCode());
to.setCmdId(from.getCmdId());
to.setCmdCode(from.getCmdCode());
to.setContent(from.getContent());
to.setChiefOnDuty(from.getChiefOnDuty());
to.setChiefOnDutyAuth(from.getChiefOnDutyAuth());
@ -126,7 +132,7 @@ public class DisCmdConvertor {
}
to.getRcvCompanies().clear();
from.getRcvCompanies().forEach((fRc)->{
to.getRcvCompanies().put(fRc.getId(),DisCmdConvertor.convert(fRc));
to.getRcvCompanies().put(fRc.getRcId(),DisCmdConvertor.convert(fRc));
});
return to;
}

View File

@ -97,7 +97,7 @@ public class DisCmdFindService {
//
if(hasCmd){
DisCmdRspVo cmdVo = DisCmdConvertor.convert(cmd);
rsp.getCmdMap().put(cmdVo.getCode(),cmdVo);
rsp.getCmdMap().put(cmdVo.getCmdId(),cmdVo);
}
});

View File

@ -151,7 +151,7 @@ public class DisCmdLoopService {
rc.setLastWarningForTimeoutUnsigned(disCmdService.getNow(simulation));//保证暂时只发送一次
LocalDateTime rTime = rc.getReceiveTime().plusSeconds(60L);
if(disCmdService.getNow(simulation).compareTo(rTime)>=0){//60秒内未签收
notify.getRcs().add(new DisCmdTimeout60UnsignedRspVo.DisCmdRc(rc.getDisCmdCode(),rc.getId()));
notify.getRcs().add(new DisCmdTimeout60UnsignedRspVo.DisCmdRc(rc.getCmdId(),rc.getCmdCode(),rc.getRcId()));
}
}
});

View File

@ -19,17 +19,18 @@ public class DisCmdReceiptService {
private DisCmdService disCmdService;
/**
* 查看调度命令的回执记录
* @param disCmdCode 调度命令号
* @param cmdId 调度命令记录id
*/
public List<ReceiptVo> findReceipts(Simulation simulation, String disCmdCode){
DisCmd cmd = disCmdService.findDisCmd(simulation,disCmdCode);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != cmd, String.format("仿真(%s),调度命令(%s)不存在", simulation.getId(), disCmdCode));
public List<ReceiptVo> findReceipts(Simulation simulation, String cmdId){
DisCmd cmd = disCmdService.findDisCmd(simulation,cmdId);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != cmd, String.format("仿真(%s),调度命令id(%s)不存在", simulation.getId(), cmdId));
List<ReceiptVo> rsp = new ArrayList<>();
//
DisCmdSendCompany sc = cmd.getSendCompany();
if(null!=sc.getSendTime()){
ReceiptVo rtv = new ReceiptVo();
rtv.setDisCmdCode(cmd.getCode());
rtv.setCmdId(cmd.getCmdId());
rtv.setCmdCode(cmd.getCmdCode());
rtv.setState(ReceiptVo.Status.Sent.name());
rtv.setTime(sc.getSendTime());
rtv.setScCompany(sc.getName());
@ -37,7 +38,8 @@ public class DisCmdReceiptService {
}
if(null!=sc.getSignedTime()){
ReceiptVo rtv = new ReceiptVo();
rtv.setDisCmdCode(cmd.getCode());
rtv.setCmdId(cmd.getCmdId());
rtv.setCmdCode(cmd.getCmdCode());
rtv.setState(ReceiptVo.Status.AllSigned.name());
rtv.setTime(sc.getSignedTime());
rtv.setScCompany(sc.getName());
@ -47,7 +49,8 @@ public class DisCmdReceiptService {
cmd.getRcvCompanies().values().forEach(rc->{
if(null!=rc.getReceiveTime()){
ReceiptVo rtv = new ReceiptVo();
rtv.setDisCmdCode(cmd.getCode());
rtv.setCmdId(cmd.getCmdId());
rtv.setCmdCode(cmd.getCmdCode());
rtv.setState(ReceiptVo.Status.Received.name());
rtv.setTime(rc.getReceiveTime());
switch (rc.getType()){
@ -67,7 +70,8 @@ public class DisCmdReceiptService {
}
if(null!=rc.getTransReceiveTime()){
ReceiptVo rtv = new ReceiptVo();
rtv.setDisCmdCode(cmd.getCode());
rtv.setCmdId(cmd.getCmdId());
rtv.setCmdCode(cmd.getCmdCode());
rtv.setTime(rc.getTransReceiveTime());
rtv.setState(ReceiptVo.Status.TrainSrmReceived.name());
rtv.setSrmStation(rc.getTransStationCode());
@ -75,7 +79,8 @@ public class DisCmdReceiptService {
}
if(null!=rc.getTransSendTime()){
ReceiptVo rtv = new ReceiptVo();
rtv.setDisCmdCode(cmd.getCode());
rtv.setCmdId(cmd.getCmdId());
rtv.setCmdCode(cmd.getCmdCode());
rtv.setTime(rc.getTransSendTime());
rtv.setState(ReceiptVo.Status.TrainSrmSent.name());
rtv.setSrmStation(rc.getTransStationCode());
@ -83,7 +88,8 @@ public class DisCmdReceiptService {
}
if(null!=rc.getSignTime()){
ReceiptVo rtv = new ReceiptVo();
rtv.setDisCmdCode(cmd.getCode());
rtv.setCmdId(cmd.getCmdId());
rtv.setCmdCode(cmd.getCmdCode());
rtv.setTime(rc.getSignTime());
rtv.setSignedBy(rc.getSignBy());//todo:暂时
switch (rc.getType()){
@ -109,7 +115,8 @@ public class DisCmdReceiptService {
}
if(null!=rc.getReadTime()){
ReceiptVo rtv = new ReceiptVo();
rtv.setDisCmdCode(cmd.getCode());
rtv.setCmdId(cmd.getCmdId());
rtv.setCmdCode(cmd.getCmdCode());
rtv.setState(ReceiptVo.Status.Read.name());
rtv.setTime(rc.getReadTime());
switch (rc.getType()){
@ -129,7 +136,8 @@ public class DisCmdReceiptService {
}
if(null!=rc.getRejectSignTime()){
ReceiptVo rtv = new ReceiptVo();
rtv.setDisCmdCode(cmd.getCode());
rtv.setCmdId(cmd.getCmdId());
rtv.setCmdCode(cmd.getCmdCode());
rtv.setState(ReceiptVo.Status.Rejected.name());
rtv.setTime(rc.getRejectSignTime());
switch (rc.getType()){

View File

@ -6,6 +6,7 @@ import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.DisCmd;
import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.DisCmdRcvCompany;
import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.DisCmdSendCompany;
import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.convertor.DisCmdConvertor;
import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo.DisCmdCreateRspVo;
import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo.DisCmdRspVo;
import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo.DisCmdSrcVo;
import club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo.DisCmdTimeout60UnsignedRspVo;
@ -36,23 +37,28 @@ public class DisCmdService {
/**
* 新建调度命令仅仅是生成一个调度命令号返回
*/
public String create(Simulation simulation){
public DisCmdCreateRspVo create(Simulation simulation){
CtcRepository ctcRepository = simulation.getCtcRepository();
int id = ctcRepository.getDispatchCommandIdGenerator().getAndIncrement();
return String.valueOf(id);
int cmdId = ctcRepository.getDisCmdIdGenerator().incrementAndGet();
int cmdCode = ctcRepository.getDisCmdCodeGenerator().incrementAndGet();
//
DisCmdCreateRspVo rsp = new DisCmdCreateRspVo();
rsp.setCmdId(String.valueOf(cmdId));
rsp.setCmdCode(String.valueOf(cmdCode));
return rsp;
}
/**
* 删除缓存箱中的某条调度命令
* @param cpId 调度命令的创建平台识别号
* @param disCmdCode
* @param cmdId
*/
public void deleteFromCache(Simulation simulation,String cpId,String disCmdCode){
public void deleteFromCache(Simulation simulation,String cpId,String cmdId){
CtcRepository ctcRepository = simulation.getCtcRepository();
DisCmd cmd = ctcRepository.getDisCmdMap().get(disCmdCode);
DisCmd cmd = this.findDisCmd(simulation,cmdId);
if(null != cmd){
final boolean can = cpId.equals(cmd.getCpId())&&DisCmdSendCompany.Status.Cache.equals(cmd.getSendCompany().getState());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(can, String.format("仿真(%s),调度命令(%s)的删除校验失败", simulation.getId(),disCmdCode));
ctcRepository.getDisCmdMap().remove(disCmdCode);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(can, String.format("仿真(%s),调度命令id(%s)的删除校验失败", simulation.getId(),cmdId));
ctcRepository.getDisCmdMap().remove(cmdId);
}
}
/**
@ -64,7 +70,7 @@ public class DisCmdService {
List<String> clearList = new ArrayList<>();
ctcRepository.getDisCmdMap().values().forEach(cmd->{
if(cpId.equals(cmd.getCpId())&&DisCmdSendCompany.Status.Cache.equals(cmd.getSendCompany().getState())){
clearList.add(cmd.getCode());
clearList.add(cmd.getCmdId());
}
});
clearList.forEach(cmdId->{
@ -78,21 +84,24 @@ public class DisCmdService {
this.saveParamValid(disCmdVo);
CtcRepository ctcRepository = simulation.getCtcRepository();
//完善请求参数
disCmdVo.getSendCompany().setDisCmdCode(disCmdVo.getCode());
disCmdVo.getSendCompany().setCmdId(disCmdVo.getCmdId());
disCmdVo.getSendCompany().setCmdCode(disCmdVo.getCmdCode());
disCmdVo.getRcvCompanies().forEach(rc->{
rc.setDisCmdCode(disCmdVo.getCode());
if(null == rc.getId() || rc.getId().trim().length()<=0){
rc.setId(String.valueOf(ctcRepository.getDisCmdRcvCompanyIdGenerator().getAndIncrement()));
rc.setCmdId(disCmdVo.getCmdId());
rc.setCmdCode(disCmdVo.getCmdCode());
if(null == rc.getRcId() || rc.getRcId().trim().length()<=0){
rc.setRcId(String.valueOf(ctcRepository.getDisCmdRcIdGenerator().incrementAndGet()));
}
});
//
DisCmd disCmd = ctcRepository.getDisCmdMap().get(disCmdVo.getCode());
DisCmd disCmd = ctcRepository.getDisCmdMap().get(disCmdVo.getCmdId());
if(null == disCmd){
disCmd = new DisCmd();
disCmd.setCode(disCmdVo.getCode());
disCmd.setCmdId(disCmdVo.getCmdId());
disCmd.setCmdCode(disCmdVo.getCmdCode());
}
DisCmdConvertor.convert(disCmdVo,disCmd);
ctcRepository.getDisCmdMap().put(disCmd.getCode(),disCmd);
ctcRepository.getDisCmdMap().put(disCmd.getCmdId(),disCmd);
}
/**
* 参数校验
@ -102,22 +111,22 @@ public class DisCmdService {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(vo.getTitle().length() <= 20, "命令标题最大长度20");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(vo.getContent(), "命令正文不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(vo.getContent().length() <= 200, "命令正文最大长度200");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(vo.getCode(), "命令号不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(vo.getCode().length() <= 10, "命令号最大长度10");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(vo.getCmdCode(), "命令号不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(vo.getCmdCode().length() <= 10, "命令号最大长度10");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(vo.getSender(), "发令人不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(vo.getRcvCompanies(), "收令人不能为空");
}
/**
* 发送调度命令给通信服务器
* @param disCmdCode 调度命令号
* @param cmdId 调度命令记录id
*/
public void send(Simulation simulation,String disCmdCode){
DisCmd cmd = this.findDisCmd(simulation,disCmdCode);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd, String.format("仿真(%s),调度命令(%s)不存在", simulation.getId(),disCmdCode));
public void send(Simulation simulation,String cmdId){
DisCmd cmd = this.findDisCmd(simulation,cmdId);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd, String.format("仿真(%s),调度命令id(%s)不存在", simulation.getId(),cmdId));
//发令单位
DisCmdSendCompany sc= cmd.getSendCompany();
//只有在缓存或保存状态的才能发送
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(DisCmdSendCompany.Status.Cache.equals(sc.getState()),String.format("仿真(%s),调度命令(%s)发送方状态不为缓存状态", simulation.getId(),disCmdCode));
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(DisCmdSendCompany.Status.Cache.equals(sc.getState()),String.format("仿真(%s),调度命令id(%s)发送方状态不为缓存状态", simulation.getId(),cmdId));
//修改发送单位状态为发令
sc.setState(DisCmdSendCompany.Status.Send);
sc.setSendTime(this.getNow(simulation));
@ -125,14 +134,14 @@ public class DisCmdService {
/**
* 阅读调度命令
* @param disCmdCode 调度命令号
* @param rcId 对于该调度命令的受令单位记录id
* @param cmdId 调度命令记录id
* @param rcId 对于该调度命令的受令单位记录id
*/
public void read(Simulation simulation, String disCmdCode, String rcId){
DisCmd cmd = simulation.getCtcRepository().getDisCmdMap().get(disCmdCode);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != cmd, String.format("仿真(%s),调度命令(%s)不存在", simulation.getId(), disCmdCode));
List<DisCmdRcvCompany> rcs = cmd.getRcvCompanies().values().stream().filter(rc -> { return rcId.equals(rc.getId()); }).collect(Collectors.toList());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != rcs && !rcs.isEmpty(), String.format("仿真(%s),调度命令(%s)的受令单位(%s)不存在", simulation.getId(), disCmdCode, rcId));
public void read(Simulation simulation, String cmdId, String rcId){
DisCmd cmd = this.findDisCmd(simulation,cmdId);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != cmd, String.format("仿真(%s),调度命令(%s)不存在", simulation.getId(), cmdId));
List<DisCmdRcvCompany> rcs = cmd.getRcvCompanies().values().stream().filter(rc -> { return rcId.equals(rc.getRcId()); }).collect(Collectors.toList());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != rcs && !rcs.isEmpty(), String.format("仿真(%s),调度命令id(%s)的受令单位(%s)不存在", simulation.getId(), cmdId, rcId));
DisCmdRcvCompany rc = rcs.get(0);
rc.setReadTime(this.getNow(simulation));
}
@ -160,8 +169,8 @@ public class DisCmdService {
* 注意如果向列控服务器推送通知则系统自动处理通知签收
*/
public void sendNotifyToRcvCompany(Simulation simulation,DisCmdRcvCompany rc){
DisCmdRspVo disCmdVo = DisCmdConvertor.convert(this.findDisCmd(simulation,rc.getDisCmdCode()));
disCmdVo.setRcId(rc.getId());
DisCmdRspVo disCmdVo = DisCmdConvertor.convert(this.findDisCmd(simulation,rc.getCmdId()));
disCmdVo.setRcId(rc.getRcId());
//
SocketMessageVO<DisCmdRspVo> nt = SocketMessageFactory.buildDisCmdAddNotify(simulation.getId(),disCmdVo);
//
@ -196,8 +205,8 @@ public class DisCmdService {
* 列控服务器自动阅读签收调度命令
*/
private void tsrHandleCmdNotify(Simulation simulation,DisCmdRcvCompany rc){
this.read(simulation,rc.getDisCmdCode(),rc.getId());
disCmdSignService.sign(simulation,rc.getDisCmdCode(),rc.getId(),null);
this.read(simulation,rc.getCmdId(),rc.getRcId());
disCmdSignService.sign(simulation,rc.getCmdId(),rc.getRcId(),null);
//todo: 列控业务处理
}
/**
@ -234,11 +243,11 @@ public class DisCmdService {
return null!=list&&!list.isEmpty()?list.get(0):null;
}
/**
* 根据调度命令获取调度命令
* 根据调度命令id获取调度命令
*/
public DisCmd findDisCmd(Simulation simulation, String disCmdCode){
public DisCmd findDisCmd(Simulation simulation, String cmdId){
CtcRepository ctcRepository = simulation.getCtcRepository();
return ctcRepository.getDisCmdMap().get(disCmdCode);
return ctcRepository.getDisCmdMap().get(cmdId);
}
/**
* 获取仿真当前时间

View File

@ -19,17 +19,17 @@ public class DisCmdSignService {
private DisCmdService disCmdService;
/**
* 处理前端发送来的正常签收指令
* @param disCmdCode 调度命令号
* @param cmdId 调度命令记录id
* @param rcId 对于该调度命令的受令单位id
* @param signer 实际签收人(仿真成员)
*/
public void sign(Simulation simulation, String disCmdCode, String rcId, SimulationMember signer) {
DisCmd cmd = simulation.getCtcRepository().getDisCmdMap().get(disCmdCode);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != cmd, String.format("仿真(%s),调度命令(%s)不存在", simulation.getId(), disCmdCode));
List<DisCmdRcvCompany> rcs = cmd.getRcvCompanies().values().stream().filter(rc -> { return rcId.equals(rc.getId()); }).collect(Collectors.toList());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != rcs && !rcs.isEmpty(), String.format("仿真(%s),调度命令(%s)的受令单位(%s)不存在", simulation.getId(), disCmdCode, rcId));
public void sign(Simulation simulation, String cmdId, String rcId, SimulationMember signer) {
DisCmd cmd = disCmdService.findDisCmd(simulation,cmdId);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != cmd, String.format("仿真(%s),调度命令id(%s)不存在", simulation.getId(), cmdId));
List<DisCmdRcvCompany> rcs = cmd.getRcvCompanies().values().stream().filter(rc -> { return rcId.equals(rc.getRcId()); }).collect(Collectors.toList());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != rcs && !rcs.isEmpty(), String.format("仿真(%s),调度命令id(%s)的受令单位(%s)不存在", simulation.getId(), cmdId, rcId));
DisCmdRcvCompany rc = rcs.get(0);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(DisCmdRcvCompany.Status.Received.equals(rc.getState()),String.format("仿真(%s),调度命令(%s)的受令单位(%s)非接收状态,不能签收", simulation.getId(), disCmdCode, rcId));
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(DisCmdRcvCompany.Status.Received.equals(rc.getState()),String.format("仿真(%s),调度命令id(%s)的受令单位(%s)非接收状态,不能签收", simulation.getId(), cmdId, rcId));
//
rc.setState(DisCmdRcvCompany.Status.Signed);
rc.setSignTime(disCmdService.getNow(simulation));
@ -43,16 +43,16 @@ public class DisCmdSignService {
* @param signer 实际签收人(仿真成员)
*/
public void signProxy(Simulation simulation, DisCmdProxySignReqVo proxySignReqVo, SimulationMember signer){
final String disCmdCode = proxySignReqVo.getDisCmdCode();
final String cmdId = proxySignReqVo.getCmdId();
final String rcId = proxySignReqVo.getRcId();
final String nameOfExpectedSigner = proxySignReqVo.getNameOfExpectedSigner();
//
DisCmd cmd = simulation.getCtcRepository().getDisCmdMap().get(disCmdCode);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != cmd, String.format("仿真(%s),调度命令(%s)不存在", simulation.getId(), disCmdCode));
List<DisCmdRcvCompany> rcs = cmd.getRcvCompanies().values().stream().filter(rc -> { return rcId.equals(rc.getId()); }).collect(Collectors.toList());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != rcs && !rcs.isEmpty(), String.format("仿真(%s),调度命令(%s)的受令单位(%s)不存在", simulation.getId(), disCmdCode, rcId));
DisCmd cmd = disCmdService.findDisCmd(simulation,cmdId);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != cmd, String.format("仿真(%s),调度命令id(%s)不存在", simulation.getId(), cmdId));
List<DisCmdRcvCompany> rcs = cmd.getRcvCompanies().values().stream().filter(rc -> { return rcId.equals(rc.getRcId()); }).collect(Collectors.toList());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != rcs && !rcs.isEmpty(), String.format("仿真(%s),调度命令(%s)的受令单位(%s)不存在", simulation.getId(), cmdId, rcId));
DisCmdRcvCompany rc = rcs.get(0);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(DisCmdRcvCompany.Status.Received.equals(rc.getState()),String.format("仿真(%s),调度命令(%s)的受令单位(%s)非接收状态,不能签收", simulation.getId(), disCmdCode, rcId));
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(DisCmdRcvCompany.Status.Received.equals(rc.getState()),String.format("仿真(%s),调度命令(%s)的受令单位(%s)非接收状态,不能签收", simulation.getId(), cmdId, rcId));
//
rc.setState(DisCmdRcvCompany.Status.Signed);
rc.setSignTime(disCmdService.getNow(simulation));
@ -66,17 +66,17 @@ public class DisCmdSignService {
*/
/**
* 处理前端发送来的拒签指令
* @param disCmdCode 调度命令号
* @param cmdId 调度命令记录id
* @param rcId 对于该调度命令的受令单位id
* @param signer 实际拒签人(仿真成员)
*/
public void rejectSign(Simulation simulation, String disCmdCode, String rcId, SimulationMember signer) {
DisCmd cmd = simulation.getCtcRepository().getDisCmdMap().get(disCmdCode);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != cmd, String.format("仿真(%s),调度命令(%s)不存在", simulation.getId(), disCmdCode));
List<DisCmdRcvCompany> rcs = cmd.getRcvCompanies().values().stream().filter(rc -> { return rcId.equals(rc.getId()); }).collect(Collectors.toList());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != rcs && !rcs.isEmpty(), String.format("仿真(%s),调度命令(%s)的受令单位(%s)不存在", simulation.getId(), disCmdCode, rcId));
public void rejectSign(Simulation simulation, String cmdId, String rcId, SimulationMember signer) {
DisCmd cmd = disCmdService.findDisCmd(simulation,cmdId);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != cmd, String.format("仿真(%s),调度命令id(%s)不存在", simulation.getId(), cmdId));
List<DisCmdRcvCompany> rcs = cmd.getRcvCompanies().values().stream().filter(rc -> { return rcId.equals(rc.getRcId()); }).collect(Collectors.toList());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != rcs && !rcs.isEmpty(), String.format("仿真(%s),调度命令id(%s)的受令单位(%s)不存在", simulation.getId(), cmdId, rcId));
DisCmdRcvCompany rc = rcs.get(0);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(DisCmdRcvCompany.Status.Received.equals(rc.getState()),String.format("仿真(%s),调度命令(%s)的受令单位(%s)非接收状态,不能拒签", simulation.getId(), disCmdCode, rcId));
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(DisCmdRcvCompany.Status.Received.equals(rc.getState()),String.format("仿真(%s),调度命令id(%s)的受令单位(%s)非接收状态,不能拒签", simulation.getId(), cmdId, rcId));
//
rc.setState(DisCmdRcvCompany.Status.Reject);
rc.setRejectSignTime(disCmdService.getNow(simulation));

View File

@ -0,0 +1,19 @@
package club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo;
import lombok.Data;
/**
* 新建调度命令响应
*/
@Data
public class DisCmdCreateRspVo {
/**
* 调度命令记录行id(全局唯一)
*/
private String cmdId;
/**
* 调度命令号(不一定唯一)
*/
private String cmdCode;
}

View File

@ -8,9 +8,9 @@ import lombok.Data;
@Data
public class DisCmdProxySignReqVo {
/**
* 调度命令唯一id
* 调度命令记录行id(全局唯一)
*/
private String disCmdCode;
private String cmdId;
/**
* 受令单位记录唯一id
*/

View File

@ -12,13 +12,17 @@ import java.time.LocalDateTime;
public class DisCmdRcvCompanyVo {
/**
* 调度命令(唯一),由后端生成
* 调度命令记录行id(全局唯一)
*/
private String disCmdCode;
private String cmdId;
/**
* 调度命令号(不一定唯一)
*/
private String cmdCode;
/**
* 唯一id,受令单位记录id,由后端生成
*/
private String id;
private String rcId;
/**
* 受令单位类型[Dispatcher(调度台) Station(车站) Train(无线机车) Tsr(列控服务器)]
* @see DisCmdRcvCompany.Type

View File

@ -16,9 +16,13 @@ public class DisCmdRspVo {
*/
private String title;
/**
* 调度命令(唯一)
* 调度命令记录行id(全局唯一)
*/
private String code;
private String cmdId;
/**
* 调度命令号(不一定唯一)
*/
private String cmdCode;
/**
* 中转识别号
*/

View File

@ -26,9 +26,13 @@ public class DisCmdSendCompanyVo {
*/
private String code;
/**
* 调度命令(唯一)
* 调度命令记录行id(全局唯一)
*/
private String disCmdCode;
private String cmdId;
/**
* 调度命令号(不一定唯一)
*/
private String cmdCode;
//////////////////运行时数据////////////////
/**
* 调度命令对应发令单的状态[Cache(缓存) Send(发送) Signed(签收完成)]

View File

@ -19,9 +19,13 @@ public class DisCmdSrcVo {
*/
private String title;
/**
* 调度命令(唯一)
* 调度命令记录行id(全局唯一)
*/
private String code;
private String cmdId;
/**
* 调度命令号(不一定唯一)
*/
private String cmdCode;
/**
* 中转识别号
*/

View File

@ -3,6 +3,7 @@ package club.joylink.rtss.simulation.cbtc.CTC.rail.cmd.vo;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
@ -11,23 +12,28 @@ import java.util.List;
*/
@Data
public class DisCmdTimeout60UnsignedRspVo {
private List<DisCmdRc> rcs = new ArrayList<>();
private List<DisCmdRc> rcs = new ArrayList<>();
@Getter
@Setter
public static class DisCmdRc {
/**
* 调度命令号
*/
private String disCmdCode;
/**
* 该调度命令的受令单位在后端的记录id
*/
private String rcId;
@Getter
@Setter
public static class DisCmdRc {
/**
* 调度命令记录行id(全局唯一)
*/
private String cmdId;
/**
* 调度命令号(不一定唯一)
*/
private String cmdCode;
/**
* 该调度命令的受令单位在后端的记录id
*/
private String rcId;
public DisCmdRc(String disCmdCode,String rcId) {
this.disCmdCode = disCmdCode;
this.rcId = rcId;
}
public DisCmdRc(String cmdId, String cmdCode, String rcId) {
this.cmdId = cmdId;
this.cmdCode = cmdCode;
this.rcId = rcId;
}
}
}

View File

@ -26,7 +26,7 @@ public class FindAllDisCmdForHolderRspVo {
private String trainNum;
////////////////////////与持有者相关的调度命令的相关信息///////////////////
/**
* 调度命令列表
* 调度命令列表,key为cmdId
*/
private Map<String, DisCmdRspVo> cmdMap = new HashMap<>();
/**

View File

@ -10,9 +10,13 @@ import java.time.LocalDateTime;
@Data
public class ReceiptVo {
/**
* 调度命令
* 调度命令记录行id(全局唯一)
*/
private String disCmdCode;
private String cmdId;
/**
* 调度命令号(不一定唯一)
*/
private String cmdCode;
/**
* 回执状态[Sent(已发送) AllSigned(已全部签收) Received(已接收) Signed(已签收) ProxySigned(已代签) Read(已阅读) Rejected(已拒签) TrainSrmReceived(车站自律机中转接收无线调令) TrainSrmSent(车站自律机中转发送无线调令)]
* @see ReceiptVo.Status