diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapController2.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapController2.java new file mode 100644 index 000000000..d33fbd8b0 --- /dev/null +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapController2.java @@ -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 { +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationService.java b/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationService.java index 6b939cfed..220862f4b 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationService.java @@ -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); } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrSwitch.java b/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrSwitch.java index cfbc31b2d..5d4d3077b 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrSwitch.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrSwitch.java @@ -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); } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrTrack.java b/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrTrack.java index 3d95aa9c8..6a484eea1 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrTrack.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrTrack.java @@ -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) { diff --git a/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrdRepositoryBuilder.java b/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrdRepositoryBuilder.java index 3d82ddd94..8b726746d 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrdRepositoryBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrdRepositoryBuilder.java @@ -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; diff --git a/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRepoService.java b/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRepoService.java new file mode 100644 index 000000000..a6bcaacbb --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRepoService.java @@ -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()); + } + +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRepository.java b/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRepository.java index 0c2137b55..9c969ee28 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRepository.java @@ -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 sectionMap; Map switchMap; @@ -17,6 +19,7 @@ public class CommonRepository { Map 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() { + + } }