轨道交通仿真仓库构建修改
This commit is contained in:
parent
7b6cb60ba3
commit
e7db868c99
@ -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 {
|
||||||
|
}
|
@ -2,7 +2,9 @@ package club.joylink.rtss.simulation.rt;
|
|||||||
|
|
||||||
import club.joylink.rtss.services.MapService;
|
import club.joylink.rtss.services.MapService;
|
||||||
import club.joylink.rtss.simulation.SimulationManager;
|
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.SRD.SrdLogicService;
|
||||||
|
import club.joylink.rtss.simulation.rt.repo.CommonRepoService;
|
||||||
import club.joylink.rtss.vo.UserVO;
|
import club.joylink.rtss.vo.UserVO;
|
||||||
import club.joylink.rtss.vo.client.map.MapVO;
|
import club.joylink.rtss.vo.client.map.MapVO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -14,10 +16,12 @@ import java.util.Objects;
|
|||||||
public class RtSimulationService {
|
public class RtSimulationService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MapService mapService;
|
private MapService mapService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SimulationManager simulationManager;
|
private SimulationManager simulationManager;
|
||||||
|
@Autowired
|
||||||
|
private CommonRepoService commonRepoService;
|
||||||
|
@Autowired
|
||||||
|
private CilLogicService cilLogicService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SrdLogicService srdLogicService;
|
private SrdLogicService srdLogicService;
|
||||||
|
|
||||||
@ -37,6 +41,8 @@ public class RtSimulationService {
|
|||||||
* @param mapVO
|
* @param mapVO
|
||||||
*/
|
*/
|
||||||
private void loadData(RtSimulation rtSimulation, MapVO mapVO) {
|
private void loadData(RtSimulation rtSimulation, MapVO mapVO) {
|
||||||
|
this.commonRepoService.buildRepository(rtSimulation, mapVO);
|
||||||
|
this.cilLogicService.buildRepository(rtSimulation, mapVO);
|
||||||
this.srdLogicService.buildRepository(rtSimulation, mapVO);
|
this.srdLogicService.buildRepository(rtSimulation, mapVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,10 +43,14 @@ public class SrSwitch extends SrDevice {
|
|||||||
}
|
}
|
||||||
if (this.a.leftTrack != null) { // a左侧存在
|
if (this.a.leftTrack != null) { // a左侧存在
|
||||||
this.a.setRightTrack(this.b);
|
this.a.setRightTrack(this.b);
|
||||||
|
this.b.setLeftTrack(this.a);
|
||||||
this.a.setRightFlankTrack(this.c);
|
this.a.setRightFlankTrack(this.c);
|
||||||
|
this.c.setLeftFlankTrack(this.a);
|
||||||
} else { // a右侧存在
|
} else { // a右侧存在
|
||||||
this.a.setLeftTrack(this.b);
|
this.a.setLeftTrack(this.b);
|
||||||
|
this.b.setRightTrack(this.a);
|
||||||
this.a.setLeftFlankTrack(this.c);
|
this.a.setLeftFlankTrack(this.c);
|
||||||
|
this.c.setRightFlankTrack(this.a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,22 +49,18 @@ public class SrTrack extends SrDevice implements Debug {
|
|||||||
|
|
||||||
public void setLeftTrack(SrTrack left) {
|
public void setLeftTrack(SrTrack left) {
|
||||||
this.leftTrack = left;
|
this.leftTrack = left;
|
||||||
left.setRightTrack(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLeftFlankTrack(SrTrack leftFlank) {
|
public void setLeftFlankTrack(SrTrack leftFlank) {
|
||||||
this.leftFlankTrack = leftFlank;
|
this.leftFlankTrack = leftFlank;
|
||||||
leftFlank.setRightTrack(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRightTrack(SrTrack right) {
|
public void setRightTrack(SrTrack right) {
|
||||||
this.rightTrack = right;
|
this.rightTrack = right;
|
||||||
right.setLeftTrack(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRightFlankTrack(SrTrack rightFlank) {
|
public void setRightFlankTrack(SrTrack rightFlank) {
|
||||||
this.rightFlankTrack = rightFlank;
|
this.rightFlankTrack = rightFlank;
|
||||||
rightFlank.setLeftTrack(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSrSwitch(SrSwitch srSwitch) {
|
void setSrSwitch(SrSwitch srSwitch) {
|
||||||
|
@ -44,12 +44,14 @@ public class SrdRepositoryBuilder {
|
|||||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(left,
|
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(left,
|
||||||
String.format("区段[%s]的左关联区段[%s]不存在", srTrack.getId(), sectionVO.getLeftSectionCode()));
|
String.format("区段[%s]的左关联区段[%s]不存在", srTrack.getId(), sectionVO.getLeftSectionCode()));
|
||||||
srTrack.setLeftTrack(left);
|
srTrack.setLeftTrack(left);
|
||||||
|
left.setRightTrack(srTrack);
|
||||||
}
|
}
|
||||||
if (StringUtils.hasText(sectionVO.getRightSectionCode())) {
|
if (StringUtils.hasText(sectionVO.getRightSectionCode())) {
|
||||||
SrTrack right = trackMap.get(sectionVO.getRightSectionCode());
|
SrTrack right = trackMap.get(sectionVO.getRightSectionCode());
|
||||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(right,
|
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(right,
|
||||||
String.format("区段[%s]的右关联区段[%s]不存在", srTrack.getId(), sectionVO.getRightSectionCode()));
|
String.format("区段[%s]的右关联区段[%s]不存在", srTrack.getId(), sectionVO.getRightSectionCode()));
|
||||||
srTrack.setRightTrack(right);
|
srTrack.setRightTrack(right);
|
||||||
|
right.setLeftTrack(srTrack);
|
||||||
}
|
}
|
||||||
// 构建轨道和计轴关系
|
// 构建轨道和计轴关系
|
||||||
SrAXC axc;
|
SrAXC axc;
|
||||||
|
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,11 +1,13 @@
|
|||||||
package club.joylink.rtss.simulation.rt.repo;
|
package club.joylink.rtss.simulation.rt.repo;
|
||||||
|
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
|
import club.joylink.rtss.simulation.SimulationRepository;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class CommonRepository {
|
public class CommonRepository extends SimulationRepository {
|
||||||
|
public static final String NAME = "COMMON";
|
||||||
|
|
||||||
Map<String, CommonSection> sectionMap;
|
Map<String, CommonSection> sectionMap;
|
||||||
Map<String, CommonSwitch> switchMap;
|
Map<String, CommonSwitch> switchMap;
|
||||||
@ -17,6 +19,7 @@ public class CommonRepository {
|
|||||||
Map<String, CommonOverlap> overlapMap;
|
Map<String, CommonOverlap> overlapMap;
|
||||||
|
|
||||||
public CommonRepository() {
|
public CommonRepository() {
|
||||||
|
super(NAME);
|
||||||
this.sectionMap = new HashMap<>();
|
this.sectionMap = new HashMap<>();
|
||||||
this.switchMap = new HashMap<>();
|
this.switchMap = new HashMap<>();
|
||||||
this.signalMap = new HashMap<>();
|
this.signalMap = new HashMap<>();
|
||||||
@ -40,4 +43,9 @@ public class CommonRepository {
|
|||||||
String.format("不存在id为[%s]的区段", id));
|
String.format("不存在id为[%s]的区段", id));
|
||||||
return commonSection;
|
return commonSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initState() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user