轨道交通仿真仓库构建修改

This commit is contained in:
walker-sheng 2021-04-22 10:27:50 +08:00
parent 7b6cb60ba3
commit e7db868c99
7 changed files with 65 additions and 7 deletions

View File

@ -0,0 +1,14 @@
package club.joylink.rtss.controller.draft;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 新版草稿地图接口使用缓存数据不分散到多个表
*/
@RestController
@RequestMapping("/api/draftMap")
@Slf4j
public class DraftMapController2 {
}

View File

@ -2,7 +2,9 @@ package club.joylink.rtss.simulation.rt;
import club.joylink.rtss.services.MapService;
import club.joylink.rtss.simulation.SimulationManager;
import club.joylink.rtss.simulation.rt.CIL.CilLogicService;
import club.joylink.rtss.simulation.rt.SRD.SrdLogicService;
import club.joylink.rtss.simulation.rt.repo.CommonRepoService;
import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.map.MapVO;
import org.springframework.beans.factory.annotation.Autowired;
@ -14,10 +16,12 @@ import java.util.Objects;
public class RtSimulationService {
@Autowired
private MapService mapService;
@Autowired
private SimulationManager simulationManager;
@Autowired
private CommonRepoService commonRepoService;
@Autowired
private CilLogicService cilLogicService;
@Autowired
private SrdLogicService srdLogicService;
@ -37,6 +41,8 @@ public class RtSimulationService {
* @param mapVO
*/
private void loadData(RtSimulation rtSimulation, MapVO mapVO) {
this.commonRepoService.buildRepository(rtSimulation, mapVO);
this.cilLogicService.buildRepository(rtSimulation, mapVO);
this.srdLogicService.buildRepository(rtSimulation, mapVO);
}
}

View File

@ -43,10 +43,14 @@ public class SrSwitch extends SrDevice {
}
if (this.a.leftTrack != null) { // a左侧存在
this.a.setRightTrack(this.b);
this.b.setLeftTrack(this.a);
this.a.setRightFlankTrack(this.c);
this.c.setLeftFlankTrack(this.a);
} else { // a右侧存在
this.a.setLeftTrack(this.b);
this.b.setRightTrack(this.a);
this.a.setLeftFlankTrack(this.c);
this.c.setRightFlankTrack(this.a);
}
}

View File

@ -49,22 +49,18 @@ public class SrTrack extends SrDevice implements Debug {
public void setLeftTrack(SrTrack left) {
this.leftTrack = left;
left.setRightTrack(this);
}
public void setLeftFlankTrack(SrTrack leftFlank) {
this.leftFlankTrack = leftFlank;
leftFlank.setRightTrack(this);
}
public void setRightTrack(SrTrack right) {
this.rightTrack = right;
right.setLeftTrack(this);
}
public void setRightFlankTrack(SrTrack rightFlank) {
this.rightFlankTrack = rightFlank;
rightFlank.setLeftTrack(this);
}
void setSrSwitch(SrSwitch srSwitch) {

View File

@ -44,12 +44,14 @@ public class SrdRepositoryBuilder {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(left,
String.format("区段[%s]的左关联区段[%s]不存在", srTrack.getId(), sectionVO.getLeftSectionCode()));
srTrack.setLeftTrack(left);
left.setRightTrack(srTrack);
}
if (StringUtils.hasText(sectionVO.getRightSectionCode())) {
SrTrack right = trackMap.get(sectionVO.getRightSectionCode());
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(right,
String.format("区段[%s]的右关联区段[%s]不存在", srTrack.getId(), sectionVO.getRightSectionCode()));
srTrack.setRightTrack(right);
right.setLeftTrack(srTrack);
}
// 构建轨道和计轴关系
SrAXC axc;

View File

@ -0,0 +1,28 @@
package club.joylink.rtss.simulation.rt.repo;
import club.joylink.rtss.services.cache.ICacheService;
import club.joylink.rtss.simulation.rt.RtSimulation;
import club.joylink.rtss.vo.client.map.MapVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class CommonRepoService {
@Autowired
private ICacheService iCacheService;
public void buildRepository(RtSimulation rtSimulation, MapVO mapVO) {
CommonRepository commonRepository = (CommonRepository) iCacheService.get(this.buildKey(mapVO));
if (commonRepository == null) {
commonRepository = CommonRepositoryBuilder.buildFrom(mapVO);
this.iCacheService.put(this.buildKey(mapVO), commonRepository);
}
rtSimulation.addRepository(commonRepository);
}
private String buildKey(MapVO mapVO) {
return String.format("CommonRepo-%s-%s", mapVO.getId(), mapVO.getVersion());
}
}

View File

@ -1,11 +1,13 @@
package club.joylink.rtss.simulation.rt.repo;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.SimulationRepository;
import java.util.HashMap;
import java.util.Map;
public class CommonRepository {
public class CommonRepository extends SimulationRepository {
public static final String NAME = "COMMON";
Map<String, CommonSection> sectionMap;
Map<String, CommonSwitch> switchMap;
@ -17,6 +19,7 @@ public class CommonRepository {
Map<String, CommonOverlap> overlapMap;
public CommonRepository() {
super(NAME);
this.sectionMap = new HashMap<>();
this.switchMap = new HashMap<>();
this.signalMap = new HashMap<>();
@ -40,4 +43,9 @@ public class CommonRepository {
String.format("不存在id为[%s]的区段", id));
return commonSection;
}
@Override
public void initState() {
}
}