武汉8号线
This commit is contained in:
parent
a5a0b3f105
commit
3cd2f52f38
@ -6,7 +6,6 @@ import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
|
||||
@ -15,7 +14,6 @@ import club.joylink.rtss.vo.ws.TrainPosition;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
@ -36,6 +34,7 @@ public class NewAtsTrainLoadService {
|
||||
stands = station.getRdStandList();
|
||||
}*/
|
||||
VirtualRealityTrain.Door door = train.getDoor1();
|
||||
train.setSpeed(tp.getSpeed());
|
||||
if(tp.isRight()){
|
||||
door = train.getDoor2();
|
||||
}
|
||||
@ -55,14 +54,16 @@ public class NewAtsTrainLoadService {
|
||||
door.setClose(tp.isCloseDoor());
|
||||
train.setSpeed(99F);
|
||||
}
|
||||
|
||||
}
|
||||
public void loadTripNumberTrain(Simulation simulation, TrainPosition tp,Section section) {
|
||||
|
||||
|
||||
|
||||
public VirtualRealityTrain loadTripNumberTrain(Simulation simulation, TrainPosition tp,Section section) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
Map<String,VirtualRealityTrain> trainMap = repository.getAllVrTrain().stream().collect(Collectors.toMap(VirtualRealityTrain::getGroupNumber,Function.identity()));
|
||||
if(Objects.equals(false,trainMap.containsKey(tp.getGroupNum()))){
|
||||
log.error("没有找到对应车组号 param:{}",tp);
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
VirtualRealityTrain virtualRealityTrain = repository.queryOnlineTrainBy(tp.getGroupNum());
|
||||
@ -77,6 +78,7 @@ public class NewAtsTrainLoadService {
|
||||
virtualRealityTrain.setRunLevel(RunLevel.IL);
|
||||
trainOnline(simulation, section, tp, virtualRealityTrain);
|
||||
}
|
||||
return virtualRealityTrain;
|
||||
}
|
||||
|
||||
|
||||
@ -95,22 +97,16 @@ public class NewAtsTrainLoadService {
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(section.isPhysical(), "列车需加载到物理区段上");
|
||||
//重叠检测
|
||||
SectionPosition headPosition = new SectionPosition(section, tp.getLocation() - section.getKmMin());
|
||||
// SectionPosition headPosition = new SectionPosition(section, section.getStopPointByDirection(right));
|
||||
// SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false);
|
||||
// boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
|
||||
// if(willOverlap){
|
||||
// return;
|
||||
// }
|
||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
|
||||
|
||||
// 列车上线并构建ATS监控列车信息
|
||||
manualTrainOnlineAndSupervise(simulation, train, headPosition, right);
|
||||
manualTrainOnlineAndSupervise(simulation, train, headPosition, right,tp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 人工车上线并监控
|
||||
*/
|
||||
private void manualTrainOnlineAndSupervise(Simulation simulation, VirtualRealityTrain train, SectionPosition headPosition, boolean right) {
|
||||
train.initManualTrain(headPosition, right);
|
||||
private void manualTrainOnlineAndSupervise(Simulation simulation, VirtualRealityTrain train, SectionPosition headPosition, boolean right,TrainPosition tp) {
|
||||
train.initManualTrain(headPosition, right,tp);
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
//设置列车预选模式、驾驶模式、运行级别
|
||||
if (!headPosition.getSection().anyZcWorking()) {
|
||||
@ -130,4 +126,7 @@ public class NewAtsTrainLoadService {
|
||||
repository.addTrainInfo(trainInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,38 +1,24 @@
|
||||
package club.joylink.rtss.simulation.cbtc.ATS.service;
|
||||
|
||||
|
||||
import club.joylink.rtss.constants.MapPrdTypeEnum;
|
||||
import club.joylink.rtss.simulation.SimulationManager;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
import club.joylink.rtss.vo.client.SocketMessageVO;
|
||||
import club.joylink.rtss.vo.client.WebSocketMessageType;
|
||||
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
|
||||
import club.joylink.rtss.vo.ws.TrainPosition;
|
||||
import club.joylink.rtss.websocket.StompMessageService;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class TrainPositionService {
|
||||
|
||||
|
||||
@Resource
|
||||
private NewAtsTrainLoadService newAtsTrainLoadService;
|
||||
@Resource
|
||||
private SimulationManager simulationManager;
|
||||
@Resource
|
||||
StompMessageService messageService;
|
||||
TrainPositionTimeOverService timeOverService;
|
||||
|
||||
|
||||
/**
|
||||
@ -44,91 +30,11 @@ public class TrainPositionService {
|
||||
public void initTrainOrUpdate(String mapName,String json){
|
||||
TrainPosition tp = JsonUtils.read(json, TrainPosition.class);
|
||||
tp.setReceiveTime(System.currentTimeMillis());
|
||||
// log.info(tp.toString());
|
||||
List<Simulation> simulationList = this.findSimulationList(mapName);
|
||||
if(Objects.equals(true, CollectionUtils.isEmpty(simulationList))){
|
||||
log.error("未找到对应的类型的仿真,无法渲染列车位置 param:{}",json);
|
||||
return;
|
||||
}
|
||||
// boolean d = true;
|
||||
SocketMessageVO<TrainPosition> vo = SocketMessageFactory.buildBasic(WebSocketMessageType.YJDDZH_TRAIN_POSITION,tp);
|
||||
this.messageService.send(vo);
|
||||
log.info(json);
|
||||
// SocketMessageVO<TrainPosition> vo = SocketMessageFactory.buildBasic(WebSocketMessageType.YJDDZH_TRAIN_POSITION,tp);
|
||||
// this.messageService.send(vo);
|
||||
this.timeOverService.addTrainAccept(mapName,tp);
|
||||
|
||||
for (Simulation sim : simulationList) {
|
||||
List<Section> sectionList = findDirectionAllSection(sim,tp.getRoadType());
|
||||
Section section = this.findSecion(sectionList,tp);
|
||||
// if(d){
|
||||
// tp.setSectionCode(section.getCode());
|
||||
// log.info(tp.toString());
|
||||
// d = false;
|
||||
// }
|
||||
if(Objects.isNull(section)){
|
||||
log.error("未找到对应的区段 param:{}",json);
|
||||
return;
|
||||
}
|
||||
log.info(tp.toString());
|
||||
this.newAtsTrainLoadService.loadTripNumberTrain(sim,tp,section);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据传入的参数 定位对应的所在的区段
|
||||
* @param sectionList
|
||||
* @param tp
|
||||
* @return
|
||||
*/
|
||||
private Section findSecion(List<Section> sectionList,TrainPosition tp){
|
||||
// int i = 0;
|
||||
// Section findSection;
|
||||
for (Section section : sectionList) {
|
||||
if(tp.isRight()){
|
||||
if(tp.getLocation() <= section.getKmMax()){
|
||||
return section;
|
||||
}
|
||||
}else{
|
||||
if(tp.getLocation() <= section.getKmMax() && tp.getLocation() >= section.getKmMin()){
|
||||
return section;
|
||||
}
|
||||
}
|
||||
// i++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据车辆方向获取对应的区段并升序排序
|
||||
* @param sim
|
||||
* @param roadType
|
||||
* @return
|
||||
*/
|
||||
private synchronized List<Section> findDirectionAllSection(Simulation sim,Section.SectionRoadType roadType){
|
||||
String key = sim.getId() + "-" + roadType.name();
|
||||
List<Section> list = simulationManager.getSectionDir(key);
|
||||
if(Objects.equals(true,CollectionUtils.isEmpty(list))){
|
||||
list = sim.getRepository().getSectionList();
|
||||
|
||||
list = list.stream().filter(d->d.getRoadType() == roadType && Objects.nonNull(d.getKmMin()))
|
||||
.sorted(Comparator.comparing(Section::getKmMin)).collect(Collectors.toList());
|
||||
simulationManager.putSectionDirCache(key,list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应线路的仿真,并且地图类型为 MapPrdTypeEnum.YJDDZH
|
||||
* @param mapName
|
||||
* @return
|
||||
*/
|
||||
private List<Simulation> findSimulationList(String mapName){
|
||||
return this.simulationManager.getSimulationList().stream().filter(d->{
|
||||
if(d instanceof Simulation){
|
||||
Simulation sim = (Simulation) d;
|
||||
SimulationBuildParams params = sim.getBuildParams();
|
||||
return Objects.equals(mapName,params.getMap().getName()) && params.getProdType() == MapPrdTypeEnum.YJDDZH;
|
||||
}
|
||||
return false;
|
||||
}).map(d->(Simulation) d).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,134 @@
|
||||
package club.joylink.rtss.simulation.cbtc.ATS.service;
|
||||
|
||||
|
||||
import club.joylink.rtss.simulation.SimulationManager;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.status.TrainStatus;
|
||||
import club.joylink.rtss.vo.ws.TrainPosition;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class TrainPositionTimeOverService {
|
||||
@Resource
|
||||
private SimulationManager simulationManager;
|
||||
@Resource
|
||||
NewAtsTrainLoadService newAtsTrainLoadService;
|
||||
@Value("${yjddzh.receiveTimeOver:60}")
|
||||
private Integer receiveTimeOver;
|
||||
|
||||
private static final Map<String, TrainPosition> TRAIN_POSITION_MAP = new ConcurrentHashMap<>();
|
||||
private static final Map<String,List<String>> TRAIN_SIMULATION_EXIST_MAP = new ConcurrentHashMap<>();
|
||||
private static synchronized boolean checkExist(String key,Simulation simulation){
|
||||
List<String> list = TRAIN_SIMULATION_EXIST_MAP.get(key);
|
||||
if(CollectionUtils.isEmpty(list)){
|
||||
list = new ArrayList<>();
|
||||
list.add(simulation.getId());
|
||||
TRAIN_SIMULATION_EXIST_MAP.put(key,list);
|
||||
return true;
|
||||
}else if(list.contains(simulation.getId())){
|
||||
return false;
|
||||
}else{
|
||||
list.add(simulation.getId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public void addTrainAccept(String mapName ,TrainPosition train){
|
||||
String key = String.format("%s,%s",mapName,train.getGroupNum());
|
||||
|
||||
TRAIN_POSITION_MAP.put(key,train);
|
||||
TRAIN_SIMULATION_EXIST_MAP.remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据车辆方向获取对应的区段并升序排序
|
||||
* @param sim
|
||||
* @param roadType
|
||||
* @return
|
||||
*/
|
||||
private synchronized List<Section> findDirectionAllSection(Simulation sim, Section.SectionRoadType roadType){
|
||||
String key = sim.getId() + "-" + roadType.name();
|
||||
List<Section> list = simulationManager.getSectionDir(key);
|
||||
if(Objects.equals(true, CollectionUtils.isEmpty(list))){
|
||||
list = sim.getRepository().getSectionList();
|
||||
|
||||
list = list.stream().filter(d->d.getRoadType() == roadType && Objects.nonNull(d.getKmMin()))
|
||||
.sorted(Comparator.comparing(Section::getKmMin)).collect(Collectors.toList());
|
||||
simulationManager.putSectionDirCache(key,list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* 根据传入的参数 定位对应的所在的区段
|
||||
* @param sectionList
|
||||
* @param tp
|
||||
* @return
|
||||
*/
|
||||
private Section findSecion(List<Section> sectionList,TrainPosition tp){
|
||||
for (Section section : sectionList) {
|
||||
if(tp.isRight()){
|
||||
if(tp.getLocation() <= section.getKmMax()){
|
||||
return section;
|
||||
}
|
||||
}else{
|
||||
if(tp.getLocation() <= section.getKmMax() && tp.getLocation() >= section.getKmMin()){
|
||||
return section;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void trainInitOrUpdate(Simulation simulation){
|
||||
String mapName = simulation.getBuildParams().getMap().getName();
|
||||
|
||||
for (Map.Entry<String,TrainPosition> entry: TRAIN_POSITION_MAP.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
TrainPosition tp = entry.getValue();
|
||||
if(!StringUtils.startsWithIgnoreCase(key,mapName)){
|
||||
continue;
|
||||
}
|
||||
if(tp.receiveTimeOver(this.receiveTimeOver)){
|
||||
if(Objects.isNull(tp.getGroupNum())){
|
||||
log.error("错误的数据:" + tp);
|
||||
continue;
|
||||
}
|
||||
if(checkExist(key,simulation)){
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
TrainStatus ts = new TrainStatus(tp.getGroupNum());
|
||||
ts.setGroupNumber(tp.getGroupNum());
|
||||
repository.addDeviceInfo(ts);
|
||||
repository.deleteSuperviseTrain(tp.getGroupNum());
|
||||
repository.deleteOnlineTrain(tp.getGroupNum());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
List<Section> sectionList = findDirectionAllSection(simulation,tp.getRoadType());
|
||||
Section section = this.findSecion(sectionList,tp);
|
||||
if(Objects.isNull(section)){
|
||||
log.error("未找到对应的区段 param:{}",tp);
|
||||
continue;
|
||||
}
|
||||
this.newAtsTrainLoadService.loadTripNumberTrain(simulation,tp,section);
|
||||
}
|
||||
}
|
||||
|
||||
public void run(Simulation simulation){
|
||||
simulation.addJob(SimulationModule.YJDDZH.name(), () -> trainInitOrUpdate(simulation), SimulationConstants.YJDDZH_LOGIC_LOOP_RATE);
|
||||
}
|
||||
|
||||
}
|
@ -1,46 +1,223 @@
|
||||
package club.joylink.rtss.simulation.cbtc.work;
|
||||
|
||||
import club.joylink.rtss.entity.Ibp;
|
||||
import club.joylink.rtss.services.ICommandService;
|
||||
import club.joylink.rtss.services.IMapService;
|
||||
import club.joylink.rtss.services.iscs.IscsDeviceService;
|
||||
import club.joylink.rtss.services.iscs.IscsSystemResourcesService;
|
||||
import club.joylink.rtss.services.publishData.IbpService;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.ATSLogicLoop;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.ATSMessageCollectAndDispatcher;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.CiLogic;
|
||||
import club.joylink.rtss.simulation.cbtc.DeviceStatusService;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.SimulationIdGenerator;
|
||||
import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
|
||||
import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
|
||||
import club.joylink.rtss.simulation.cbtc.build.UserConfigDataBuilder;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
import club.joylink.rtss.simulation.cbtc.depot.DepotService;
|
||||
import club.joylink.rtss.simulation.cbtc.device.virtual.VRDeviceLogicLoop;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationUser;
|
||||
import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO;
|
||||
import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher;
|
||||
import club.joylink.rtss.simulation.rt.pis.PisStatusPublisher;
|
||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.vo.client.CommandDefinitionVO;
|
||||
import club.joylink.rtss.vo.client.iscs.device.IscsDeviceVO;
|
||||
import club.joylink.rtss.vo.client.iscs.systemRes.IscsSystemResourcesQueryVO;
|
||||
import club.joylink.rtss.vo.client.iscs.systemRes.IscsSystemResourcesVO;
|
||||
import club.joylink.rtss.vo.client.runplan.RunPlanVO;
|
||||
import club.joylink.rtss.vo.client.runplan.user.RunPlanParkingTimeVO;
|
||||
import club.joylink.rtss.vo.client.runplan.user.RunPlanRunlevelVO;
|
||||
import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO;
|
||||
import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam;
|
||||
import club.joylink.rtss.vo.map.MapVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class EmergencySimulationWorkServiceImpl implements SimulationWorkService {
|
||||
@Autowired
|
||||
private IMapService iMapService;
|
||||
@Autowired
|
||||
private ICommandService iCommandService;
|
||||
@Autowired
|
||||
private IbpService ibpService;
|
||||
@Autowired
|
||||
private IscsDeviceService iscsDeviceService;
|
||||
@Autowired
|
||||
private IscsSystemResourcesService iscsSystemResourcesService;
|
||||
@Autowired
|
||||
private DepotService depotService;
|
||||
@Autowired
|
||||
private SimulationWorkServiceManager simulationWorkServiceManager;
|
||||
@Autowired
|
||||
private ATSLogicLoop atsLogicLoop;
|
||||
@Autowired
|
||||
private ATSMessageCollectAndDispatcher atsMessageCollectAndDispatcher;
|
||||
@Autowired
|
||||
private VRDeviceLogicLoop vrDeviceLogicLoop;
|
||||
@Autowired
|
||||
private CiLogic ciLogic;
|
||||
@Autowired
|
||||
private DeviceStatusService deviceStatusService;
|
||||
@Override
|
||||
public Simulation.Type getType() {
|
||||
return Simulation.Type.EMERGENCY;
|
||||
}
|
||||
|
||||
private SimulationBuildParams prepareSimulationParams(long mapId, SimulationWorkParamVO workParamVO, LoginUserInfoVO loginUserInfoVO) {
|
||||
// 获取地图数据
|
||||
MapVO mapVO = iMapService.getMapDetail(mapId);
|
||||
// List<RunPlanRunlevelVO> runLevelList = this.prepareRunLevelData(loginUserInfoVO, mapId);
|
||||
// List<RunPlanParkingTimeVO> parkTimeList = this.prepareParkTimeData(loginUserInfoVO, mapId);
|
||||
// 获取操作定义数据
|
||||
List<CommandDefinitionVO> operationDefinitionList = iCommandService
|
||||
.queryDefinitionsByLineCode(mapVO.getLineCode());
|
||||
SimulationBuildParams.SimulationBuildParamsBuilder builder = SimulationBuildParams.builder();
|
||||
// 都有的属性构造
|
||||
builder.loginUserInfo(loginUserInfoVO)
|
||||
.workParamVO(workParamVO)
|
||||
.createTime(LocalDateTime.now())
|
||||
.map(mapVO)
|
||||
// .userRunLevelList(runLevelList)
|
||||
// .userParkTimeList(parkTimeList)
|
||||
.operationDefinitionList(operationDefinitionList);
|
||||
//运行图选择性构造
|
||||
/* LocalDate runPlanDate = SimulationConstants.getRunPlanDate();
|
||||
RunPlanVO runPlanVO = findRunPlan(workParamVO, loginUserInfoVO.getAccountVO().getId(), mapId);
|
||||
if (Objects.nonNull(runPlanVO)) {
|
||||
runPlanVO.setRunDate(runPlanDate);
|
||||
builder.runPlan(runPlanVO);
|
||||
SchedulingPlanNewVO schedulingPlanNewVO;
|
||||
if (loginUserInfoVO.isProjectDeviceLogin()) { // 如果是项目设备登录,找通用日期的派班计划
|
||||
schedulingPlanNewVO = schedulingService.queryCommonSchedulingPlanOfDay(mapId, runPlanDate);
|
||||
} else {
|
||||
schedulingPlanNewVO = schedulingService
|
||||
.querySchedulingPlanUserFirst(loginUserInfoVO.getAccountVO().getId(), runPlanVO.getId(), runPlanDate);
|
||||
}
|
||||
builder.schedulingPlan(schedulingPlanNewVO);
|
||||
}*/
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Simulation create(long mapId, SimulationWorkParamVO workParamVO, LoginUserInfoVO loginUserInfoVO) {
|
||||
return null;
|
||||
checkParam(workParamVO);
|
||||
SimulationBuildParams params = prepareSimulationParams(mapId, workParamVO, loginUserInfoVO);
|
||||
String group = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), mapId);
|
||||
Simulation simulation = new Simulation(group);
|
||||
simulation.setBuildParams(params);
|
||||
return simulation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData(Simulation simulation) {
|
||||
|
||||
SimulationBuildParams params = simulation.getBuildParams();
|
||||
// ibp数据
|
||||
List<Ibp> ibps = ibpService.queryEntities(params.getMap().getId());
|
||||
params.getMap().setIbpList(ibps);
|
||||
// iscs设备
|
||||
List<IscsDeviceVO> iscsDevices = iscsDeviceService.getListByMapId(params.getMap().getId());
|
||||
params.getMap().setIscsDeviceList(iscsDevices);
|
||||
// iscs资源
|
||||
IscsSystemResourcesQueryVO queryVO = new IscsSystemResourcesQueryVO();
|
||||
queryVO.setMapId(params.getMap().getId());
|
||||
List<IscsSystemResourcesVO> resourceList = iscsSystemResourcesService.criteriaQuery(queryVO);
|
||||
params.getMap().setIscsSystemResourceList(resourceList);
|
||||
// 加载地图数据
|
||||
loadMapData(simulation);
|
||||
// 车辆段
|
||||
depotService.loadDepotTrain(simulation);
|
||||
// 添加仿真用户
|
||||
SimulationUser simulationUser = new SimulationUser(simulation, params.getLoginUserInfo());
|
||||
simulation.addSimulationUser(simulationUser);
|
||||
// 添加仿真成员
|
||||
simulationWorkServiceManager.buildMember(simulation);
|
||||
}
|
||||
private void loadMapData(Simulation simulation) {
|
||||
SimulationBuildParams buildParams = simulation.getBuildParams();
|
||||
simulation.setBuildParams(buildParams);
|
||||
if (Objects.nonNull(buildParams.getLoginUserInfo())) {
|
||||
simulation.setCreatorId(buildParams.getLoginUserInfo().getAccountVO().getIdStr());
|
||||
simulation.setProject(buildParams.getLoginUserInfo().getProject());
|
||||
simulation.setProjectVO(buildParams.getLoginUserInfo().getProjectInfo());
|
||||
}
|
||||
// 线路配置参数
|
||||
simulation.getRepository().setConfig(SimulationBuilder.buildConfig(buildParams.getMap().getConfigVO(),
|
||||
buildParams.getMap().getGraphDataNew().getMapFunctionConfig()));
|
||||
simulation.getRepository().getConfig()
|
||||
.setRouteLikeHa1(buildParams.getMap().getGraphDataNew().getGenerateConfig().isLikeHa1());
|
||||
simulation.getRepository().getConfig()
|
||||
.setOverlapSettingByTrigger(buildParams.getMap().getGraphDataNew().getGenerateConfig().isOverlapSettingByTrigger());
|
||||
simulation.getRepository().getConfig()
|
||||
.setSharingECStations(buildParams.getMap().getGraphDataNew().getGenerateConfig().getSharingECStations());
|
||||
simulation.getRepository().getConfig()
|
||||
.setHandleDepot(buildParams.getMap().getGraphDataNew().getGenerateConfig().isHandleDepot());
|
||||
// 地图数据构建
|
||||
SimulationBuilder.SimulationDeviceBuildResult mapDataBuildResult = SimulationBuilder.checkAndBuildMapData(buildParams.getMap());
|
||||
// ibp数据构建
|
||||
SimulationBuilder.buildIbpData(mapDataBuildResult, buildParams.getMap().getIbpList());
|
||||
// iscs设备构建
|
||||
SimulationBuilder.buildIscsDevices(mapDataBuildResult, buildParams.getMap().getIscsDeviceList());
|
||||
|
||||
simulation.getRepository().setDeviceMap(mapDataBuildResult.getDeviceMap());
|
||||
simulation.getRepository().setSectionArriveNearMap(mapDataBuildResult.getSectionArriveNearMap());
|
||||
simulation.getRepository().setVrDeviceMap(mapDataBuildResult.getVrDeviceMap());
|
||||
simulation.getRepository().setRoutePathMap(mapDataBuildResult.getRoutePathMap());
|
||||
simulation.getRepository().setDestinationMap(mapDataBuildResult.getDestinationMap());
|
||||
simulation.getRepository().setRoutingList(mapDataBuildResult.getRoutingList());
|
||||
simulation.getRepository().getCatenaryMap().putAll(mapDataBuildResult.getCatenaryMap());
|
||||
simulation.getRepository().getSectionRespondersMap().putAll(mapDataBuildResult.getSectionRespondersMap());
|
||||
simulation.getRepository().setParkingTracksMap(mapDataBuildResult.getParkingTracksMap());
|
||||
UserConfigDataBuilder.buildRunLevel(simulation.getRepository(), buildParams.getUserRunLevelList(),
|
||||
buildParams.getMap(), mapDataBuildResult.getErrMsgList());
|
||||
UserConfigDataBuilder.buildParkTime(simulation.getRepository(), buildParams.getUserParkTimeList(),
|
||||
buildParams.getMap(), mapDataBuildResult.getErrMsgList());
|
||||
if (!CollectionUtils.isEmpty(mapDataBuildResult.getErrMsgList())) { // 存在数据异常
|
||||
mapDataBuildResult.getErrMsgList().forEach(errMsg -> log.warn(String.format("地图数据异常:%s", errMsg)));
|
||||
simulation.setMapDataError(true);
|
||||
simulation.addDataErrMsgs(mapDataBuildResult.getErrMsgList());
|
||||
}
|
||||
// 加载ISCS资源
|
||||
// SimulationBuilder.loadIscsResources(simulation, buildParams.getMap().getIscsSystemResourceList());
|
||||
// 加载运行图
|
||||
// SimulationBuilder.checkAndLoadRunPlan(simulation, buildParams.getRunPlan());
|
||||
// 加载派班计划
|
||||
// SimulationBuilder.checkAndLoadSchedulingPlan(simulation, buildParams.getSchedulingPlan());
|
||||
// 加载车辆段route path
|
||||
// SimulationBuilder.loadDepotInOutRoutePath(simulation);
|
||||
}
|
||||
@Override
|
||||
public void addJobs(Simulation simulation) {
|
||||
atsLogicLoop.addJobsForTrainPosition(simulation);
|
||||
atsMessageCollectAndDispatcher.addJobs(simulation);
|
||||
vrDeviceLogicLoop.addJobsForTrainPosition(simulation);
|
||||
|
||||
ciLogic.addJobsForTrainPosition(simulation);
|
||||
// timeOverService.run(simulation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessagePublisher(Simulation simulation) {
|
||||
|
||||
simulation.addMessagePublisher(new IscsStatusPublisher(simulation));
|
||||
simulation.addMessagePublisher(new PisStatusPublisher(simulation));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Simulation simulation) {
|
||||
|
||||
deviceStatusService.init(simulation);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user