Merge branch 'test-zhouyin' into test-training2-zhouyin

This commit is contained in:
tiger_zhou 2022-09-01 14:00:03 +08:00
commit 9d1677128f
10 changed files with 402 additions and 67 deletions

View File

@ -32,7 +32,7 @@ public enum BusinessExceptionAssertEnum implements BusinessExceptionAssert {
OPERATION_REPEAT(10016, "operation repeat"), OPERATION_REPEAT(10016, "operation repeat"),
SIMULATION_EXCEPTION_FOR_SHOW(10017, ""), //错误信息用于展示给仿真用户 SIMULATION_EXCEPTION_FOR_SHOW(10017, ""), //错误信息用于展示给仿真用户
OPERATION_FAIL(10018, "操作失败"), OPERATION_FAIL(10018, "操作失败"),
STATION_DETAIL_NOT_FOUND_RD_PLAN_ITEM(10019,"站细卡控未找到对应的接发车计划"),
DATA_ERROR(11000, "data error"), DATA_ERROR(11000, "data error"),
REPEAT_RUN_PLAN_FROM_CTC_UPDATE_DATA(11200,"repeat run plan"), REPEAT_RUN_PLAN_FROM_CTC_UPDATE_DATA(11200,"repeat run plan"),

View File

@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@ -17,6 +18,14 @@ public class CascoControl {
private Route route; private Route route;
private List<String> errorList = new ArrayList<>(); private List<String> errorList = new ArrayList<>();
private String tripNum; private String tripNum;
// private boolean force;
public CascoControl(Simulation simulation, Station station, Route route, String tripNum/*,Boolean force*/) {
this.simulation = simulation;
this.station = station;
this.route = route;
this.tripNum = tripNum;
// this.force = Objects.isNull(force) ? false : force.booleanValue();
}
public void addErrorMsg(String msg){ public void addErrorMsg(String msg){
this.errorList.add(msg); this.errorList.add(msg);

View File

@ -73,6 +73,14 @@ public class CtcEffectRepository {
*/ */
private final Map<String,CtcEffectRepository.RegularTrainLineRepository> updateReguarTrainLineMap = new ConcurrentHashMap<>(); private final Map<String,CtcEffectRepository.RegularTrainLineRepository> updateReguarTrainLineMap = new ConcurrentHashMap<>();
/**
* 股道更新区域从生效区来的数据
*/
private final Map<String, StationTrackSectionRepository> updateStationTrackSectionMap = new ConcurrentHashMap<>();
/**
* 出入口更新区域从生效区来的数据
*/
private final Map<String, CtcEffectRepository.StationDoorRepository> updateDoorMap = new ConcurrentHashMap<>();
/** /**
* 获取生效区的运行计划 * 获取生效区的运行计划
* *
@ -576,5 +584,7 @@ public class CtcEffectRepository {
this.doorRepository.clear(); this.doorRepository.clear();
this.regularTrainLineMap.clear(); this.regularTrainLineMap.clear();
updateReguarTrainLineMap.clear(); updateReguarTrainLineMap.clear();
updateStationTrackSectionMap.clear();
this.updateDoorMap.clear();
} }
} }

View File

@ -11,7 +11,7 @@ import lombok.Setter;
@Setter @Setter
@Getter @Getter
@NoArgsConstructor @NoArgsConstructor
public class TrackSection { public class TrackSection implements Cloneable {
/** /**
* 编码 * 编码
*/ */
@ -122,4 +122,13 @@ public class TrackSection {
public enum StandType { public enum StandType {
NO, LOW, HIGH NO, LOW, HIGH
} }
public TrackSection clone() {
try {
return (TrackSection) super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return null;
}
} }

View File

@ -46,7 +46,7 @@ public class CtcManageIOGateOperateHandler {
@OperateHandlerMapping(type = Operation.Type.STATION_IO_GATE_PUBLISH) @OperateHandlerMapping(type = Operation.Type.STATION_IO_GATE_PUBLISH)
public void publist(Simulation simulation, String stationCode){ public void publist(Simulation simulation, String stationCode){
ctcManageService.publishData(simulation, CtcRepository.CtcFZKType.STATION_DETAIL,stationCode); ctcManageService.publishData(simulation, CtcRepository.CtcFZKType.IO_GATE,stationCode);
} }
} }

View File

@ -232,6 +232,7 @@ public class CtcRunPlanParam implements Cloneable {
* 运行计划车次信息 * 运行计划车次信息
* private String tripNumber; * private String tripNumber;
*/ */
this.tripNumber = tl.getArriveTipNum();
/** /**
@ -449,6 +450,21 @@ public class CtcRunPlanParam implements Cloneable {
return p; return p;
} }
/* public boolean getTrackDiscordant(){
if(Objects.isNull(trackDiscordant)){
return false;
}
return this.trackDiscordant.booleanValue();
}
public boolean getEntryOutDiscordant(){
if(Objects.isNull(entryOutDiscordant)){
return false;
}
return this.entryOutDiscordant.booleanValue();
}*/
/** /**
* 初始化车次信息 * 初始化车次信息
*/ */

View File

@ -2,10 +2,7 @@ package club.joylink.rtss.simulation.cbtc.CTC.service;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService; import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcEffectRepository; import club.joylink.rtss.simulation.cbtc.CTC.data.*;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
import club.joylink.rtss.simulation.cbtc.CTC.data.RouteSequence;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.map.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -13,6 +10,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
@ -23,7 +21,8 @@ import java.util.stream.Collectors;
public class CTCService { public class CTCService {
@Autowired @Autowired
private CiApiService ciApiService; private CiApiService ciApiService;
@Resource
private CascoControlService cascoControlService;
/** /**
* 创建了新的运行计划item * 创建了新的运行计划item
*/ */
@ -161,7 +160,12 @@ public class CTCService {
line.setAutoTrigger(trigger); line.setAutoTrigger(trigger);
} }
private List<String> cascoControl(CascoControl cc,boolean force){
if(Objects.equals(true,force)){
return Collections.emptyList();
}
return this.cascoControlService.checkCascoControlRoute(cc);
}
/** /**
* *
* @param simulation * @param simulation
@ -179,6 +183,11 @@ public class CTCService {
List<String> conflictInfo = new ArrayList<>(); List<String> conflictInfo = new ArrayList<>();
CtcRepository ctcRepository = simulation.getCtcRepository(); CtcRepository ctcRepository = simulation.getCtcRepository();
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)) { //列车进路防错办 if (StringUtils.hasText(tripNumber) && !Objects.equals(true, force)) { //列车进路防错办
List<RouteSequence.Line> lines = ctcRepository.findRouteSequenceLines(station.getCode(), tripNumber); List<RouteSequence.Line> lines = ctcRepository.findRouteSequenceLines(station.getCode(), tripNumber);
if (!CollectionUtils.isEmpty(lines)) { if (!CollectionUtils.isEmpty(lines)) {

View File

@ -1,20 +1,27 @@
package club.joylink.rtss.simulation.cbtc.CTC.service; package club.joylink.rtss.simulation.cbtc.CTC.service;
import club.joylink.rtss.simulation.cbtc.CTC.data.CascoControl; import club.joylink.rtss.exception.BusinessException;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcEffectRepository; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository; import club.joylink.rtss.simulation.cbtc.CI.data.StationDirection;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog; import club.joylink.rtss.simulation.cbtc.CTC.data.*;
import club.joylink.rtss.simulation.cbtc.Simulation; 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 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 lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Case;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.Objects; import static club.joylink.rtss.simulation.cbtc.CTC.data.TrackSection.DirectionType;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
@ -29,59 +36,249 @@ public class CascoControlService {
Station station = cc.getStation(); Station station = cc.getStation();
Simulation simulation = cc.getSimulation(); Simulation simulation = cc.getSimulation();
String stationCode = station.getCode(); String stationCode = station.getCode();
CtcRepository ctcRepository = simulation.getCtcRepository(); CtcRepository ctcRepository = simulation.getCtcRepository();
CtcEffectRepository effectRepository = ctcRepository.getCtcEffectRepository(); CtcEffectRepository effectRepository = ctcRepository.getCtcEffectRepository();
Map<String, CtcStationRunPlanLog> runPlanLogMap = simulation.getCtcRepository().getSimulationRunPlanMap().get(stationCode); List<String> errMsgList = cc.getErrorList();
Optional<CtcStationRunPlanLog> runPlanLogOptional = null; boolean isDepart = cc.getRoute().getType() == Route.Type.DEPARTURE;
if(Objects.nonNull(runPlanLogMap) && !runPlanLogMap.isEmpty()){ CtcStationRunPlanLog runPlanLog;
runPlanLogOptional = this.checkForRunPlan(cc); 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();
} }
// List<CtcStationRunPlanLog> allRunPlanLogList = runPlanLogMap.values().stream().filter(d->d.getChangeType() == null && d.isSign()).collect(Collectors.toList()); CtcStationRunPlanLog.RunPlanItem runPlan = this.findRunPlanFromPlan(isDepart,runPlanLog,errMsgList);
if(Objects.isNull(runPlan)){
String depart = this.departToChar(isDepart);
String msg = String.format("未找到行车计划的接发车计划 车站[%s] 车次[%s] [%s]", runPlanLog.getStation().getCode(), runPlanLog.getTripNumber(),depart);
log.error(msg);
errMsgList.add(msg);
return errMsgList;
}
CtcEffectRepository.StationDoorRepository doorRepository = effectRepository.getUpdateDoorMap().get(stationCode);
CtcEffectRepository.StationTrackSectionRepository stationTrackRepository = effectRepository.getUpdateStationTrackSectionMap().get(stationCode);
CtcEffectRepository.RegularTrainLineRepository regularTrainLineRepository = effectRepository.getUpdateReguarTrainLineMap().get(stationCode);
CtcEffectRepository.StationDoorRepository doorRepository = effectRepository.getDoorRepository().get(stationCode); if(Objects.isNull(doorRepository)){
if(Objects.nonNull(doorRepository)){ String msg = String.format("未找到对应的出入口站细数据,车站[%s]",stationCode);
if(runPlanLogOptional.isPresent()){ log.error(msg);
return Lists.newArrayList(msg);
} }
return cc.getErrorList(); if(Objects.isNull(stationTrackRepository)){
String msg = String.format("未找到对应的股道站细数据,车站[%s]",stationCode);
log.error(msg);
return Lists.newArrayList(msg);
} }
this.checkRegularTrainLine(isDepart,runPlan,regularTrainLineRepository,runPlanLog,errMsgList);
CtcEffectRepository.StationTrackSectionRepository stationTrackRepository = effectRepository.getStationTrackSectionMap().get(stationCode); this.doorCheckDetail(isDepart,runPlan,doorRepository,runPlanLog,errMsgList);
if(Objects.nonNull(stationTrackRepository)){ this.checkStationTrackDetail(isDepart,runPlan,stationTrackRepository,runPlanLog,errMsgList);
return errMsgList;
}
return null;
} }
private Optional<CtcStationRunPlanLog> checkForRunPlan(/*List<CtcStationRunPlanLog> allRunPlanLogList,*/CascoControl cc){ private boolean trackAndDoor(Boolean d){
CtcStationRunPlanLog runPlanLog = cc.getSimulation().getCtcRepository().getRunPlan(cc.getStation().getCode(),cc.getTripNum()); return Objects.isNull(d) ? false: d.booleanValue();
if(Objects.isNull(runPlanLog)){ }
cc.addErrorMsg(String.format("未在计划中找到对应的车次[%s]",cc.getTripNum()));
/**
* 根据接发车获取行车计划的接发车计划
* @param isDepart
* @param runPlanLog
* @param errMsgList
* @return
*/
private CtcStationRunPlanLog.RunPlanItem findRunPlanFromPlan(boolean isDepart,CtcStationRunPlanLog runPlanLog,List<String> errMsgList){
CtcStationRunPlanLog.RunPlanItem runPlan = runPlanLog.getArriveRunPlan();
if(isDepart){
runPlan = runPlanLog.getDepartRunPlan();
} }
if(!Objects.isNull(runPlanLog.getChangeType()) && !runPlanLog.isSign()){ /*if(Objects.isNull(runPlan)){
cc.addErrorMsg(String.format("未在计划中找到对应的车次[%s]",cc.getTripNum())); String msg = String.format("未找到行车计划的接发车计划 车站[%s] 车次[%s] [%s]", runPlanLog.getStation().getCode(), runPlanLog.getTripNumber(),depart);
} log.error(msg);
return Optional.of(runPlanLog); errMsgList.add(msg);
/*Map<String,CtcStationRunPlanLog> tripNumMap = allRunPlanLogList.stream().collect(Collectors.toMap(CtcStationRunPlanLog::getTripNumber, Function.identity(),(v1,v2)->v1)); BusinessExceptionAssertEnum.STATION_DETAIL_NOT_FOUND_RD_PLAN_ITEM.assertNotNull(runPlan,msg);
CtcStationRunPlanLog runPlanLog = tripNumMap.get(cc.getTripNum());
if(Objects.isNull(runPlanLog)){
cc.addErrorMsg(String.format("未在计划中找到对应的车次[%s]",cc.getTripNum()));
}*/ }*/
return runPlan;
} }
private void checkCascoForStationTrack(CtcEffectRepository.StationTrackSectionRepository stationTrackRepository){ /**
* 根据车辆计划接发车车次查找对应更新区的车辆固定径路数据
* @param isDepart
* @param regularTrainLineRepository
* @param runPlanLog
* @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("");
return;
}
final String tripNum = runPlan.getTripNumber();
RegularTrainLine rtl = regularTrainLineRepository.getDataMap().values().stream().filter(d->{
String tmpNum = d.getArriveTipNum();
if(isDepart){
tmpNum = d.getLeaveTipNum();
}
return Objects.equals(tripNum,tmpNum);
}).findFirst().orElse(null);
if(Objects.isNull(rtl)){
return;
}
StationDirection sd = rtl.getEnter();
if(isDepart){
sd = rtl.getOut();
}
if(Objects.equals(false,trackAndDoor(runPlanLog.getTrackDiscordant())) && !Objects.equals(runPlan.getTrackSection().getCode(),rtl.getMasterStand().getCode())){
//股道不一致检测
errMsg.add("股道固定径路不一致");
}
if(Objects.equals(false,trackAndDoor(runPlanLog.getEntryOutDiscordant())) && !Objects.equals(runPlan.getStationDirection().getCode(),sd.getCode())){
//出入口不一致检测
errMsg.add("出入口固定径路不一致");
}
} }
private void checkCascoForDoor(CtcEffectRepository.StationDoorRepository doorRepository,CtcStationRunPlanLog runPlanLog){ /**
CtcStationRunPlanLog.RunPlanItem departPlan = runPlanLog.getDepartRunPlan(); * 获取对应的执行计划
CtcStationRunPlanLog.RunPlanItem arrivePlan = runPlanLog.getArriveRunPlan(); * @param cc
if(Objects.nonNull(departPlan)){ * @return
*/
private CtcStationRunPlanLog checkForRunPlan(CascoControl cc){
String stationCode = cc.getStation().getCode();
String tripNum = cc.getTripNum();
CtcStationRunPlanLog runPlanLog = cc.getSimulation().getCtcRepository().getRunPlan(stationCode,tripNum);
return runPlanLog;
}
/**
* 检测接发计划与股道接发车方向是否一致
* @param isDepart
* @param stationTrackRepository
* @param runPlanLog
* @param errMsg
*/
private void checkStationTrackDetail(boolean isDepart,CtcStationRunPlanLog.RunPlanItem runPlan,CtcEffectRepository.StationTrackSectionRepository stationTrackRepository,CtcStationRunPlanLog runPlanLog,List<String> errMsg){
if(!CollectionUtils.isEmpty(errMsg)){
return;
}
String departChar = this.departToChar(isDepart);
Section masterSection = runPlan.getTrackSection();
TrackSection ts = 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());
log.error(d);
errMsg.add(d);
return;
} }
if(Objects.nonNull(arrivePlan)){
checkStationTrackForTransfinite(ts,runPlanLog,errMsg,departChar);
checkStationTrackForTrainType(ts,runPlanLog,errMsg);
}
/**
* 行车计划股道超限检测
* @param ts
* @param runPlanLog
* @param errMsg
* @param departChar
*/
private void checkStationTrackForTransfinite(TrackSection ts,CtcStationRunPlanLog runPlanLog,List<String> errMsg,String departChar){
if(Objects.isNull(runPlanLog.getTransfinite())){
return;
} }
CtcStationRunPlanLog.TransfiniteType sTT = ts.getTransfinite();
//大于一级超限
boolean transfiniteThanMoreOne =(runPlanLog.getTransfinite() == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_TWO_LEVEL ||
runPlanLog.getTransfinite() == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_SUPER);
//大于二级超限
boolean trainfiniteThanMoreTwo = runPlanLog.getTransfinite() == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_SUPER;
String d = 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());
}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());
}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());
}
if(Objects.equals(false,Strings.isNullOrEmpty(d))){
log.error(d);
errMsg.add(d);
}
}
/**
* 行车计划股道列车类型检测
* @param ts
* @param runPlanLog
* @param errMsg
*/
private void checkStationTrackForTrainType(TrackSection ts,CtcStationRunPlanLog runPlanLog,List<String> errMsg){
boolean trainTypeMatch = false;
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:
break;
}
if(trainTypeMatch){
String d = String.format("计划列车类型与股道类型不匹配,股道[%s] 股道区段[%s] 设置列车类型[%s],列车类型[%s]",ts.getCode(),ts.getSectionCode(),tt,runPlanLog.isPassengerTrain()?"":"");
errMsg.add(d);
}
}
/**
* 计划与出入口检测明细
* @param isDepart 是否是发车计划
* @param doorRepository
* @param runPlanLog
*/
private void doorCheckDetail(boolean isDepart,CtcStationRunPlanLog.RunPlanItem runPlan,CtcEffectRepository.StationDoorRepository doorRepository,CtcStationRunPlanLog runPlanLog,List<String> errMsgList){
if(!CollectionUtils.isEmpty(errMsgList)){
return;
}
String depart = this.departToChar(isDepart);
StationDirection sd = runPlan.getStationDirection();
StationDirection doorDir = 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()));
}
boolean isTransfinite = Objects.nonNull(runPlanLog.getTransfinite()) && 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()));
return;
}
if(!doorDir.isTravelTrain() && Objects.equals(true,runPlanLog.isPassengerTrain())){
//出入口不支持客车但是计划是客车
errMsgList.add(String.format("出入口[%s],[%s]不允许客车,车站[%s],车次[%s]"
,sd.getCode(),depart,runPlanLog.getStation().getCode(),runPlanLog.getTripNumber()));
return;
}
if(!doorDir.isGoodsTrain() && Objects.equals(false,runPlanLog.isPassengerTrain())){
//出入口不支持货车但是计划是货车
errMsgList.add(String.format("出入口[%s],[%s]不允许货车,车站[%s],车次[%s]"
,sd.getCode(),depart,runPlanLog.getStation().getCode(),runPlanLog.getTripNumber()));
return;
}
}
private String departToChar(boolean isDepart){
return isDepart ? "":"";
} }
} }

View File

@ -418,19 +418,53 @@ public class CtcManageService {
*/ */
public void stationUpdateFromEffect(Simulation simulation, String stationCode){ public void stationUpdateFromEffect(Simulation simulation, String stationCode){
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(Objects.isNull(stationCode), String.format("车站号不能为空")); BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(Objects.isNull(stationCode), String.format("车站号不能为空"));
CtcEffectRepository effectRepository = simulation.getCtcRepository().getCtcEffectRepository(); CtcEffectRepository repository = simulation.getCtcRepository().getCtcEffectRepository();
CtcEffectRepository.RegularTrainLineRepository regularTrainLineRepository = effectRepository.getRegularTrainLineMap().get(stationCode); CtcEffectRepository.RegularTrainLineRepository regularTrainLineRepository = repository.getRegularTrainLineMap().get(stationCode);
boolean isEmptyData = Objects.isNull(regularTrainLineRepository) || regularTrainLineRepository.getDataMap().isEmpty(); boolean isEmptyData = Objects.isNull(regularTrainLineRepository) || regularTrainLineRepository.getDataMap().isEmpty();
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(isEmptyData, String.format("当前生效区没有数据,无法更新")); // BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(isEmptyData, String.format("当前生效区没有数据,无法更新"));
CtcEffectRepository.StationTrackSectionRepository sourceStationTrack = repository.getStationTrackSectionMap().get(stationCode);
CtcEffectRepository.StationDoorRepository sourceDoor = repository.getDoorRepository().get(stationCode);
if(Objects.nonNull(sourceStationTrack)){
CtcEffectRepository.StationTrackSectionRepository stationTrack = repository.getUpdateStationTrackSectionMap().get(stationCode);
if(Objects.isNull(stationTrack)){
stationTrack = new CtcEffectRepository.StationTrackSectionRepository();
repository.getUpdateStationTrackSectionMap().put(stationCode,stationTrack);
}
if(stationTrack.version() != sourceStationTrack.version()){
stationTrack.resetVersion(sourceStationTrack.version());
for (TrackSection value : sourceStationTrack.getDataMap().values()) {
stationTrack.save(value.clone());
}
}
}
if(Objects.nonNull(sourceDoor)){
CtcEffectRepository.StationDoorRepository door = repository.getUpdateDoorMap().get(stationCode);
if(Objects.isNull(door)){
door = new CtcEffectRepository.StationDoorRepository();
repository.getUpdateDoorMap().put(stationCode,door);
}
if(door.version() != sourceDoor.version()){
door.resetVersion(sourceDoor.version());
for (StationDirection d : sourceDoor.getDataMap().values()) {
door.save(d.clone());
}
}
}
if(Objects.equals(true,isEmptyData)){
return;
}
CtcEffectRepository.RegularTrainLineRepository updateRepository = simulation.getCtcRepository().getCtcEffectRepository().getUpdateReguarTrainLineMap().get(stationCode); CtcEffectRepository.RegularTrainLineRepository updateRepository = simulation.getCtcRepository().getCtcEffectRepository().getUpdateReguarTrainLineMap().get(stationCode);
if(Objects.isNull(updateRepository)){ if(Objects.isNull(updateRepository)){
updateRepository = new CtcEffectRepository.RegularTrainLineRepository(); updateRepository = new CtcEffectRepository.RegularTrainLineRepository();
simulation.getCtcRepository().getCtcEffectRepository().getUpdateReguarTrainLineMap().put(stationCode,updateRepository); simulation.getCtcRepository().getCtcEffectRepository().getUpdateReguarTrainLineMap().put(stationCode,updateRepository);
} }
if(updateRepository.version() != regularTrainLineRepository.version()){ if(updateRepository.version() != regularTrainLineRepository.version()){
updateRepository.resetVersion(regularTrainLineRepository.version()); updateRepository.resetVersion(regularTrainLineRepository.version());
for (RegularTrainLine val : regularTrainLineRepository.getDataMap().values()) { for (RegularTrainLine val : regularTrainLineRepository.getDataMap().values()) {
updateRepository.save(val); updateRepository.save(val.clone());
} }
}else{ }else{
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(true, String.format("当前生效区与更新区的版本一致,无法更新")); BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(true, String.format("当前生效区与更新区的版本一致,无法更新"));
@ -446,8 +480,12 @@ public class CtcManageService {
public FZkVO<List<RegularTrainLineVO>> loadUpdateRegularTrainLineList(Simulation simulation, String stationCode){ public FZkVO<List<RegularTrainLineVO>> loadUpdateRegularTrainLineList(Simulation simulation, String stationCode){
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(Objects.isNull(stationCode), String.format("车站号不能为空")); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(Objects.isNull(stationCode), String.format("车站号不能为空"));
CtcEffectRepository repository = simulation.getCtcRepository().getCtcEffectRepository(); CtcEffectRepository repository = simulation.getCtcRepository().getCtcEffectRepository();
CtcEffectRepository.RegularTrainLineRepository tLRepository = repository.getUpdateReguarTrainLineMap().get(stationCode); CtcEffectRepository.RegularTrainLineRepository tLRepository = repository.getUpdateReguarTrainLineMap().get(stationCode);
List<RegularTrainLineVO> list = this.loadRegularTrainLineData(tLRepository); List<RegularTrainLineVO> list = this.loadRegularTrainLineData(tLRepository);
return FZkVO.of(CollectionUtils.isEmpty(list)?0:tLRepository.version(),list); return FZkVO.of(CollectionUtils.isEmpty(list)?0:tLRepository.version(),list);
} }

View File

@ -3,6 +3,7 @@ package club.joylink.rtss.simulation.cbtc.build;
import club.joylink.rtss.entity.Ibp; import club.joylink.rtss.entity.Ibp;
import club.joylink.rtss.simulation.cbtc.CI.data.StationDirection; import club.joylink.rtss.simulation.cbtc.CI.data.StationDirection;
import club.joylink.rtss.simulation.cbtc.CTC.data.*; import club.joylink.rtss.simulation.cbtc.CTC.data.*;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
@ -349,36 +350,82 @@ public class SimulationBuilder {
Map<String, CtcEffectRepository.StationTrackSectionRepository> stationTrackRepositoryMap = ctcRepository.getCtcManageRepository().getTrackSectionRepository(); Map<String, CtcEffectRepository.StationTrackSectionRepository> stationTrackRepositoryMap = ctcRepository.getCtcManageRepository().getTrackSectionRepository();
Map<String, CtcEffectRepository.StationDoorRepository> doorRepository = ctcRepository.getCtcManageRepository().getDoorRepository(); Map<String, CtcEffectRepository.StationDoorRepository> doorRepository = ctcRepository.getCtcManageRepository().getDoorRepository();
Map<String, CtcEffectRepository.StationTrackSectionRepository> effectStationTrackMap = ctcRepository.getCtcEffectRepository().getStationTrackSectionMap();
Map<String, CtcEffectRepository.StationDoorRepository> effectDoorMap = ctcRepository.getCtcEffectRepository().getDoorRepository();
Map<String, CtcEffectRepository.StationTrackSectionRepository> updateStationTrackMap = ctcRepository.getCtcEffectRepository().getUpdateStationTrackSectionMap();
Map<String, CtcEffectRepository.StationDoorRepository> updateDoorMap = ctcRepository.getCtcEffectRepository().getUpdateDoorMap();
for (Station station : stationList) { for (Station station : stationList) {
String stationCode = station.getCode(); String stationCode = station.getCode();
CtcEffectRepository.StationTrackSectionRepository rep = stationTrackRepositoryMap.get(stationCode); CtcEffectRepository.StationTrackSectionRepository rep = stationTrackRepositoryMap.get(stationCode);
CtcEffectRepository.StationDoorRepository doorRep = doorRepository.get(stationCode); CtcEffectRepository.StationDoorRepository doorRep = doorRepository.get(stationCode);
if(rep == null){ if(rep == null){
rep = new CtcEffectRepository.StationTrackSectionRepository(); rep = new CtcEffectRepository.StationTrackSectionRepository();
rep.incrementVersionOne();
stationTrackRepositoryMap.put(stationCode,rep); stationTrackRepositoryMap.put(stationCode,rep);
} }
if(doorRep == null){ if(doorRep == null){
doorRep = new CtcEffectRepository.StationDoorRepository(); doorRep = new CtcEffectRepository.StationDoorRepository();
doorRep.incrementVersionOne();
doorRepository.put(stationCode,doorRep); doorRepository.put(stationCode,doorRep);
} }
for (StationDirection sd : station.getStationDirectionMap().values()) { for (StationDirection sd : station.getStationDirectionMap().values()) {
// StationIOGate ioGate = new StationIOGate();
// ioGate.setCode(sd.getCode());
// ioGate.setIoName(sd.getName());
// ioGate.setDirection(sd.getLabelEnum());
doorRep.save(sd.clone()); doorRep.save(sd.clone());
} }
for (Stand stand : station.getAllStandList()) { for (Stand stand : station.getAllStandList()) {
TrackSection ts = new TrackSection(stand.getSection()); TrackSection ts = new TrackSection(stand.getSection());
rep.save(ts); rep.save(ts);
} }
} }
//复制编辑区的股道出入口到生效编辑区
copyEditToTargetForStationTrack(stationTrackRepositoryMap,effectStationTrackMap);
copyEditToTargetForStationTrack(stationTrackRepositoryMap,updateStationTrackMap);
copyEditToTargetForDoor(doorRepository,effectDoorMap);
copyEditToTargetForDoor(doorRepository,updateDoorMap);
} }
private static void copyEditToTargetForStationTrack(Map<String, ? extends CtcEffectRepository.StationTrackSectionRepository> source, Map<String, CtcEffectRepository.StationTrackSectionRepository> target){
for (Map.Entry<String, ? extends CtcEffectRepository.StationTrackSectionRepository> entry : source.entrySet()) {
String stationCode = entry.getKey();
CtcEffectRepository.StationTrackSectionRepository val = entry.getValue();
CtcEffectRepository.StationTrackSectionRepository targetRepository = target.get(stationCode);
if(Objects.isNull(targetRepository)){
targetRepository = new CtcEffectRepository.StationTrackSectionRepository();
targetRepository.resetVersion(val.version());
target.put(stationCode,targetRepository);
}
for (Map.Entry<String, TrackSection> valEntry : val.getDataMap().entrySet()) {
String code = valEntry.getKey();
TrackSection vals = valEntry.getValue();
targetRepository.getDataMap().put(code,vals);
}
}
}
private static void copyEditToTargetForDoor(Map<String, ? extends CtcEffectRepository.StationDoorRepository> source, Map<String, CtcEffectRepository.StationDoorRepository> target){
for (Map.Entry<String, ? extends CtcEffectRepository.StationDoorRepository> entry : source.entrySet()) {
String stationCode = entry.getKey();
CtcEffectRepository.StationDoorRepository val = entry.getValue();
CtcEffectRepository.StationDoorRepository targetRepository = target.get(stationCode);
if(Objects.isNull(targetRepository)){
targetRepository = new CtcEffectRepository.StationDoorRepository();
targetRepository.resetVersion(val.version());
target.put(stationCode,targetRepository);
}
for (Map.Entry<String, StationDirection> valEntry : val.getDataMap().entrySet()) {
String code = valEntry.getKey();
StationDirection vals = valEntry.getValue();
targetRepository.getDataMap().put(code,vals);
}
}
}
public static List<String> checkRunPlanAndBuildLostRoutePaths(Map<String, List<TripPlan>> serverTripMap, public static List<String> checkRunPlanAndBuildLostRoutePaths(Map<String, List<TripPlan>> serverTripMap,
Map<String, List<RoutePath>> routePathMap) { Map<String, List<RoutePath>> routePathMap) {
Map<String, String> errMsgMap = new HashMap<>(); Map<String, String> errMsgMap = new HashMap<>();