同步站细功能

This commit is contained in:
tiger_zhou 2022-09-09 10:17:26 +08:00
parent eaf30840a1
commit 4d0205f578
3 changed files with 134 additions and 89 deletions

View File

@ -13,6 +13,7 @@ import java.util.Objects;
@Data
@NoArgsConstructor
public class CascoControl {
private Simulation simulation;
private Station station;
private Route route;

View File

@ -186,6 +186,7 @@ public class CTCService {
CascoControl cc = new CascoControl(simulation,station,route,tripNumber);
List<String> errCCMsg = this.cascoControl(cc,Objects.isNull(force) ? false:force.booleanValue());//站细卡控
if(Objects.equals(false,CollectionUtils.isEmpty(errCCMsg))){
//站细检测错误的信息
return errCCMsg;
}
if (StringUtils.hasText(tripNumber) && !Objects.equals(true, force)) { //列车进路防错办

View File

@ -1,27 +1,22 @@
package club.joylink.rtss.simulation.cbtc.CTC.service;
import club.joylink.rtss.exception.BusinessException;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.CI.data.StationDirection;
import club.joylink.rtss.simulation.cbtc.CTC.data.*;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Case;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import static club.joylink.rtss.simulation.cbtc.CTC.data.TrackSection.DirectionType;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
@Service
@Slf4j
@ -29,34 +24,54 @@ public class CascoControlService {
/**
*
* @param cc
* @param cc 卡控参数
* @return
*/
public List<String> checkCascoControlRoute(CascoControl cc){
Station station = cc.getStation();
Simulation simulation = cc.getSimulation();
String stationCode = station.getCode();
CheckData checkData = this.findCheckData(cc,simulation.getCtcRepository().getCtcEffectRepository());
if(checkData.isJustReturn()){
//说明没有行车计划需要立刻返回
return Collections.emptyList();
}
if(Objects.equals(false,CollectionUtils.isEmpty(cc.getErrorList()))){
return cc.getErrorList();
}
this.checkRegularTrainLine(checkData,cc.getErrorList());
this.doorCheckDetail(checkData,cc.getErrorList());
this.checkStationTrackDetail(checkData,cc.getErrorList());
return cc.getErrorList();
}
CtcRepository ctcRepository = simulation.getCtcRepository();
CtcEffectRepository effectRepository = ctcRepository.getCtcEffectRepository();
List<String> errMsgList = cc.getErrorList();
/**
* 获取检测固定径路出入口股道必要的参数数据
* @param cc
* @param effectRepository
* @return
*/
private CheckData findCheckData(CascoControl cc,CtcEffectRepository effectRepository){
String stationCode = cc.getStation().getCode();
CheckData data = new CheckData();
boolean isDepart = cc.getRoute().getType() == Route.Type.DEPARTURE;
data.setDepart(isDepart);
CtcStationRunPlanLog runPlanLog;
try{
//在TDCS界面创建进路如果车次号没有在计划中就直接返回先按照之前的逻辑运行
runPlanLog = this.checkForRunPlan(cc);
}catch (BusinessException e){
log.error("站明检测失败 msg:" + e.getMessage(),e);
log.error(e.getMessage() + " errorCode:[{}]",e.getCode());
return Collections.emptyList();
data.setJustReturn(true);
return data;
}
CtcStationRunPlanLog.RunPlanItem runPlan = this.findRunPlanFromPlan(isDepart,runPlanLog,errMsgList);
CtcStationRunPlanLog.RunPlanItem runPlan = this.findRunPlanFromPlan(isDepart,runPlanLog);
if(Objects.isNull(runPlan)){
String depart = this.departToChar(isDepart);
String depart = data.departToChar();
String msg = String.format("未找到行车计划的接发车计划 车站[%s] 车次[%s] [%s]", runPlanLog.getStation().getCode(), runPlanLog.getTripNumber(),depart);
log.error(msg);
errMsgList.add(msg);
return errMsgList;
cc.addErrorMsg(msg);
return data;
}
CtcEffectRepository.StationDoorRepository doorRepository = effectRepository.getUpdateDoorMap().get(stationCode);
CtcEffectRepository.StationTrackSectionRepository stationTrackRepository = effectRepository.getUpdateStationTrackSectionMap().get(stationCode);
@ -65,20 +80,22 @@ public class CascoControlService {
if(Objects.isNull(doorRepository)){
String msg = String.format("未找到对应的出入口站细数据,车站[%s]",stationCode);
log.error(msg);
return Lists.newArrayList(msg);
cc.addErrorMsg(msg);
return data;
}
if(Objects.isNull(stationTrackRepository)){
String msg = String.format("未找到对应的股道站细数据,车站[%s]",stationCode);
log.error(msg);
return Lists.newArrayList(msg);
cc.addErrorMsg(msg);
return data;
}
this.checkRegularTrainLine(isDepart,runPlan,regularTrainLineRepository,runPlanLog,errMsgList);
this.doorCheckDetail(isDepart,runPlan,doorRepository,runPlanLog,errMsgList);
this.checkStationTrackDetail(isDepart,runPlan,stationTrackRepository,runPlanLog,errMsgList);
return errMsgList;
data.setRunPlanLog(runPlanLog);
data.setRunPlan(runPlan);
data.setStationTrackRepository(stationTrackRepository);
data.setDoorRepository(doorRepository);
data.setRegularTrainLineRepository(regularTrainLineRepository);
return data;
}
private boolean trackAndDoor(Boolean d){
return Objects.isNull(d) ? false: d.booleanValue();
}
@ -87,56 +104,59 @@ public class CascoControlService {
* 根据接发车获取行车计划的接发车计划
* @param isDepart
* @param runPlanLog
* @param errMsgList
* @return
*/
private CtcStationRunPlanLog.RunPlanItem findRunPlanFromPlan(boolean isDepart,CtcStationRunPlanLog runPlanLog,List<String> errMsgList){
private CtcStationRunPlanLog.RunPlanItem findRunPlanFromPlan(boolean isDepart,CtcStationRunPlanLog runPlanLog){
CtcStationRunPlanLog.RunPlanItem runPlan = runPlanLog.getArriveRunPlan();
if(isDepart){
runPlan = runPlanLog.getDepartRunPlan();
}
/*if(Objects.isNull(runPlan)){
String msg = String.format("未找到行车计划的接发车计划 车站[%s] 车次[%s] [%s]", runPlanLog.getStation().getCode(), runPlanLog.getTripNumber(),depart);
log.error(msg);
errMsgList.add(msg);
BusinessExceptionAssertEnum.STATION_DETAIL_NOT_FOUND_RD_PLAN_ITEM.assertNotNull(runPlan,msg);
}*/
return runPlan;
}
/**
* 根据车辆计划接发车车次查找对应更新区的车辆固定径路数据
* @param isDepart
* @param regularTrainLineRepository
* @param runPlanLog
* @param checkData
* @param errMsg
*/
private void checkRegularTrainLine(boolean isDepart,CtcStationRunPlanLog.RunPlanItem runPlan,CtcEffectRepository.RegularTrainLineRepository regularTrainLineRepository,CtcStationRunPlanLog runPlanLog,List<String> errMsg){
if(Objects.isNull(regularTrainLineRepository) || Objects.equals(true,CollectionUtils.isEmpty(errMsg))){
log.error("");
private void checkRegularTrainLine(CheckData checkData,List<String> errMsg){
CtcEffectRepository.RegularTrainLineRepository regularTrainLineRepository = checkData.getRegularTrainLineRepository();
if(Objects.isNull(regularTrainLineRepository) || Objects.equals(false,CollectionUtils.isEmpty(errMsg))){
log.error("未找到固定径路的数据车站[{}],车次[{}],方向[{}]",checkData.getRunPlanLog().getStation().getCode(),checkData.getRunPlan().getTripNumber(),checkData.departToChar());
return;
}
final String tripNum = runPlan.getTripNumber();
//根据接发车获取对应的列车固定径路的数据
final String tripNum = checkData.runPlan.getTripNumber();
RegularTrainLine rtl = regularTrainLineRepository.getDataMap().values().stream().filter(d->{
String tmpNum = d.getArriveTipNum();
if(isDepart){
if(checkData.isDepart()){
tmpNum = d.getLeaveTipNum();
}
return Objects.equals(tripNum,tmpNum);
}).findFirst().orElse(null);
if(Objects.isNull(rtl)){
log.error("未找到列车的固定径路 车站[{}],对应车次[{}],方向[{}]",checkData.runPlan.getStation().getCode(),tripNum,checkData.departToChar());
return;
}
StationDirection sd = rtl.getEnter();
if(isDepart){
if(checkData.isDepart()){
sd = rtl.getOut();
}
if(Objects.equals(false,trackAndDoor(runPlanLog.getTrackDiscordant())) && !Objects.equals(runPlan.getTrackSection().getCode(),rtl.getMasterStand().getCode())){
boolean trackSectionEQ = Objects.equals(checkData.runPlan.getTrackSection().getCode(),rtl.getMasterStand().getCode());
boolean doorEQ = Objects.equals(checkData.runPlan.getStationDirection().getCode(),sd.getCode());
//检测运行股道与固定径路是否一致
if(Objects.equals(false,trackAndDoor(checkData.runPlanLog.getTrackDiscordant())) && Objects.equals(false,trackSectionEQ)){
//股道不一致检测
errMsg.add("股道固定径路不一致");
log.error("检测股道是否一致 计划车站[{}],计划股道[{}],径路车站[{}],径路股道[{}],车次[{}],方向[{}],固定径路[{}]",checkData.runPlan.getStation().getCode()
,checkData.runPlan.getTrackSection().getCode(),rtl.getStation().getCode(),rtl.getMasterStand().getCode(),checkData.runPlan.getTripNumber(),checkData.departToChar(),rtl.getCode());
errMsg.add(String.format("运行股道固定径路[%s]不一致",rtl.getMasterStand().getName()));
}
if(Objects.equals(false,trackAndDoor(runPlanLog.getEntryOutDiscordant())) && !Objects.equals(runPlan.getStationDirection().getCode(),sd.getCode())){
//检测出入口与固定径路是否一致
if(Objects.equals(false,trackAndDoor(checkData.runPlanLog.getEntryOutDiscordant())) && Objects.equals(false,doorEQ)){
//出入口不一致检测
errMsg.add("出入口固定径路不一致");
log.error("检测出入口是否一致 计划车站[{}],计划股道[{}],径路车站[{}],径路股道[{}],车次[{}],方向[{}],固定径路[{}]",checkData.runPlan.getStation().getCode()
,checkData.runPlan.getTrackSection().getCode(),rtl.getStation().getCode(),rtl.getMasterStand().getCode(),checkData.runPlan.getTripNumber(),checkData.departToChar(),rtl.getCode());
errMsg.add(String.format("运行出入口固定径路[%s]不一致",sd.getName()));
}
}
@ -154,27 +174,25 @@ public class CascoControlService {
/**
* 检测接发计划与股道接发车方向是否一致
* @param isDepart
* @param stationTrackRepository
* @param runPlanLog
* @param checkData
* @param errMsg
*/
private void checkStationTrackDetail(boolean isDepart,CtcStationRunPlanLog.RunPlanItem runPlan,CtcEffectRepository.StationTrackSectionRepository stationTrackRepository,CtcStationRunPlanLog runPlanLog,List<String> errMsg){
if(!CollectionUtils.isEmpty(errMsg)){
private void checkStationTrackDetail(CheckData checkData,List<String> errMsg){
if(Objects.equals(false,CollectionUtils.isEmpty(errMsg))){
return;
}
String departChar = this.departToChar(isDepart);
Section masterSection = runPlan.getTrackSection();
TrackSection ts = stationTrackRepository.getDataMap().get(masterSection.getCode());
String departChar = checkData.departToChar();
Section masterSection = checkData.runPlan.getTrackSection();
TrackSection ts = checkData.stationTrackRepository.getDataMap().get(masterSection.getCode());
if(Objects.isNull(ts)){
String d = String.format("未找到对应的股道[%s],车站[%s],车号[%s],股道[%s]",departChar,runPlanLog.getStation().getCode(),runPlanLog.getTripNumber(),masterSection.getCode());
String d = String.format("未找到对应的股道 方向[%s],车站[%s],车号[%s],股道[%s]",departChar,checkData.runPlanLog.getStation().getCode(),checkData.runPlanLog.getTripNumber(),masterSection.getCode());
log.error(d);
errMsg.add(d);
return;
}
checkStationTrackForTransfinite(ts,runPlanLog,errMsg,departChar);
checkStationTrackForTrainType(ts,runPlanLog,errMsg);
checkStationTrackForTransfinite(ts,checkData.runPlanLog,errMsg,departChar);
checkStationTrackForTrainType(ts,checkData.runPlanLog,errMsg);
}
/**
@ -194,20 +212,24 @@ public class CascoControlService {
runPlanLog.getTransfinite() == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_SUPER);
//大于二级超限
boolean trainfiniteThanMoreTwo = runPlanLog.getTransfinite() == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_SUPER;
String d = null;
String logMsg = null;
String msg = null;
if(sTT == CtcStationRunPlanLog.TransfiniteType.NO && runPlanLog.getTransfinite() != CtcStationRunPlanLog.TransfiniteType.NO){
//股道不能超限但是计划超限
d = String.format("股道[%s],车站[%s],车次[%s],[%s],不支持超限,但行车计划超限[%s]",ts.getCode(),runPlanLog.getStation().getCode(),runPlanLog.getTripNumber(),departChar,runPlanLog.getTransfinite());
logMsg = String.format("车站[%s],股道[%s],车次[%s],方向[%s],不支持超限,但行车计划超限[%s]",runPlanLog.getStation().getCode(),ts.getCode(),runPlanLog.getTripNumber(),departChar,runPlanLog.getTransfinite());
msg = String.format("车站[%s],股道[%s] 不支持超限",runPlanLog.getStation().getName(),ts.getName());
}else if(sTT == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_ONE_LEVEL && transfiniteThanMoreOne){
//股道是一级超限但是计划是二级或是超级
d = String.format("股道[%s],车站[%s],车次[%s],[%s],一级超限,但行车计划超限[%s]",ts.getCode(),runPlanLog.getStation().getCode(),runPlanLog.getTripNumber(),departChar,runPlanLog.getTransfinite());
logMsg = String.format("车站[%s],股道[%s],车次[%s],方向[%s],一级超限,但行车计划超限[%s]",runPlanLog.getStation().getCode(),ts.getCode(),runPlanLog.getTripNumber(),departChar,runPlanLog.getTransfinite());
msg = String.format("车站[%s],股道[%s] 只支持一级超限",runPlanLog.getStation().getName(),ts.getName());
}else if(sTT == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_TWO_LEVEL && trainfiniteThanMoreTwo){
//股道是二级超限但是计划是超级
d = String.format("股道[%s],车站[%s],车次[%s],[%s],二级超限,但行车计划超限[%s]",ts.getCode(),runPlanLog.getStation().getCode(),runPlanLog.getTripNumber(),departChar,runPlanLog.getTransfinite());
logMsg = String.format("车站[%s],股道[%s],车次[%s],方向[%s],二级超限,但行车计划超限[%s]",runPlanLog.getStation().getCode(),ts.getCode(),runPlanLog.getTripNumber(),departChar,runPlanLog.getTransfinite());
msg = String.format("车站[%s],股道[%s] 只支持二级超限",runPlanLog.getStation().getName(),ts.getName());
}
if(Objects.equals(false,Strings.isNullOrEmpty(d))){
log.error(d);
errMsg.add(d);
if(Objects.equals(false,Strings.isNullOrEmpty(logMsg))){
log.error(logMsg);
errMsg.add(msg);
}
}
@ -222,9 +244,11 @@ public class CascoControlService {
TrackSection.TrainType tt = ts.getTrainType();
switch (tt){
case PASSENGER:
//检测客车但是计划中不是客车
trainTypeMatch = Objects.equals(false,runPlanLog.isPassengerTrain());
break;
case GOODS_VAN:
//检测货车但是计划中不是货车
trainTypeMatch = Objects.equals(true,runPlanLog.isPassengerTrain());
break;
default:
@ -232,53 +256,72 @@ public class CascoControlService {
}
if(trainTypeMatch){
String d = String.format("计划列车类型与股道类型不匹配,股道[%s] 股道区段[%s] 设置列车类型[%s],列车类型[%s]",ts.getCode(),ts.getSectionCode(),tt,runPlanLog.isPassengerTrain()?"":"");
errMsg.add(d);
log.error(d);
errMsg.add(String.format("计划列车类型与股道类型不匹配"));
}
}
/**
* 计划与出入口检测明细
* @param isDepart 是否是发车计划
* @param doorRepository
* @param runPlanLog
* @param checkData
* @param errMsgList
*/
private void doorCheckDetail(boolean isDepart,CtcStationRunPlanLog.RunPlanItem runPlan,CtcEffectRepository.StationDoorRepository doorRepository,CtcStationRunPlanLog runPlanLog,List<String> errMsgList){
private void doorCheckDetail(CheckData checkData,List<String> errMsgList){
if(!CollectionUtils.isEmpty(errMsgList)){
return;
}
String depart = this.departToChar(isDepart);
StationDirection sd = runPlan.getStationDirection();
StationDirection doorDir = doorRepository.getDataMap().get(sd.getCode());
String depart = checkData.departToChar();
StationDirection sd = checkData.runPlan.getStationDirection();
StationDirection doorDir = checkData.doorRepository.getDataMap().get(sd.getCode());
if(Objects.isNull(doorDir)){
errMsgList.add(String.format("根据计划方向[%s] 没有找到出入口[%s]数据,车站[%s],车次[%s]"
,depart,sd.getCode(),runPlanLog.getStation().getCode(),runPlanLog.getTripNumber()));
String d = String.format("根据计划方向[%s] 没有找到出入口数据 出入口[%s],车站[%s],车次[%s]"
,depart,sd.getCode(),checkData.runPlanLog.getStation().getCode(),checkData.runPlanLog.getTripNumber());
log.error(d);
errMsgList.add("未找到计划方向对应的出入口数据");
}
boolean isTransfinite = Objects.nonNull(runPlanLog.getTransfinite()) && runPlanLog.getTransfinite() != CtcStationRunPlanLog.TransfiniteType.NO;
boolean isTransfinite = Objects.nonNull(checkData.runPlanLog.getTransfinite()) && checkData.runPlanLog.getTransfinite() != CtcStationRunPlanLog.TransfiniteType.NO;
if(!doorDir.isAllowOverrun() && isTransfinite){
// 出入口不能超限但是计划超限
errMsgList.add(String.format("出入口[%s],[%s]不允许超限,但是计划超限,车站[%s],车次[%s]"
,sd.getCode(),depart,runPlanLog.getStation().getCode(),runPlanLog.getTripNumber()));
String d = String.format("出入口方向[%s],车站[%s]不允许超限,但是计划超限,车站[%s],车次[%s]"
,sd.getCode(),depart,checkData.runPlanLog.getStation().getCode(),checkData.runPlanLog.getTripNumber());
log.error(d);
errMsgList.add(String.format("出入口[%s]不允许超限",doorDir.getName()));
return;
}
if(!doorDir.isTravelTrain() && Objects.equals(true,runPlanLog.isPassengerTrain())){
if(!doorDir.isTravelTrain() && Objects.equals(true,checkData.runPlanLog.isPassengerTrain())){
//出入口不支持客车但是计划是客车
errMsgList.add(String.format("出入口[%s],[%s]不允许客车,车站[%s],车次[%s]"
,sd.getCode(),depart,runPlanLog.getStation().getCode(),runPlanLog.getTripNumber()));
String d = String.format("出入口方向[%s],车站[%s]不允许客车,车站[%s],车次[%s]"
,sd.getCode(),depart,checkData.runPlanLog.getStation().getCode(),checkData.runPlanLog.getTripNumber());
log.error(d);
errMsgList.add(String.format("出入口[%s]不支持接发客车",doorDir.getName()));
return;
}
if(!doorDir.isGoodsTrain() && Objects.equals(false,runPlanLog.isPassengerTrain())){
if(!doorDir.isGoodsTrain() && Objects.equals(false,checkData.runPlanLog.isPassengerTrain())){
//出入口不支持货车但是计划是货车
errMsgList.add(String.format("出入口[%s],[%s]不允许货车,车站[%s],车次[%s]"
,sd.getCode(),depart,runPlanLog.getStation().getCode(),runPlanLog.getTripNumber()));
String d=String.format("出入口[%s],[%s]不允许货车,车站[%s],车次[%s]"
,sd.getCode(),depart,checkData.runPlanLog.getStation().getCode(),checkData.runPlanLog.getTripNumber());
log.error(d);
errMsgList.add(String.format("出入口[%s]不支持接发货车",doorDir.getName()));
return;
}
}
private String departToChar(boolean isDepart){
return isDepart ? "":"";
}
@Data
@NoArgsConstructor
public static class CheckData{
private CtcStationRunPlanLog runPlanLog;
private CtcStationRunPlanLog.RunPlanItem runPlan;
private CtcEffectRepository.StationDoorRepository doorRepository;
private CtcEffectRepository.StationTrackSectionRepository stationTrackRepository;
private CtcEffectRepository.RegularTrainLineRepository regularTrainLineRepository;
private boolean justReturn;
private boolean isDepart;
public String departToChar(){
return isDepart ? "":"";
}
}
}