diff --git a/src/main/java/club/joylink/rtss/services/DraftMapService.java b/src/main/java/club/joylink/rtss/services/DraftMapService.java index 3166b18f0..2caf4e427 100644 --- a/src/main/java/club/joylink/rtss/services/DraftMapService.java +++ b/src/main/java/club/joylink/rtss/services/DraftMapService.java @@ -249,7 +249,8 @@ public class DraftMapService implements IDraftMapService { DraftMapWithBLOBs draftMap = getEntity(id); MapVO mapVO = new MapVO(draftMap); MapDataVO mapDataVO; - mapDataVO = new MapDataVO(this.buildShapeData(draftMap), this.getMapLogicDataNew(id), MapCheckConfig.fromJson(draftMap.getCheckConfig())); + mapDataVO = new MapDataVO(this.buildShapeData(draftMap), this.getMapLogicDataNew(id), + MapCheckConfig.fromJson(draftMap.getCheckConfig())); mapDataVO.setMap3dDataVO(this.find3dMapDataByMapId(id)); mapVO.setMapData(mapDataVO); return mapVO; @@ -350,12 +351,13 @@ public class DraftMapService implements IDraftMapService { @Override public List checkData(MapDataVO mapDataVO) { - List exDataList = null; + List exDataList = new ArrayList<>(); try { + if (mapDataVO.getCheckConfig() == null || mapDataVO.getCheckConfig().isCheck()) { MapVO map = new MapVO(); map.setMapData(mapDataVO); exDataList = SimulationBuilder.checkAndBuildMapData(map).getErrMsgList(); - + } } catch (IllegalStateException e) { if (e.getMessage().startsWith("Duplicate key")) { exDataList = new ArrayList<>(); diff --git a/src/main/java/club/joylink/rtss/simulation/operation/SimulationOperationHandlerManager.java b/src/main/java/club/joylink/rtss/simulation/operation/SimulationOperationHandlerManager.java index ac40e3838..449b1af33 100644 --- a/src/main/java/club/joylink/rtss/simulation/operation/SimulationOperationHandlerManager.java +++ b/src/main/java/club/joylink/rtss/simulation/operation/SimulationOperationHandlerManager.java @@ -15,7 +15,7 @@ import java.util.concurrent.ConcurrentHashMap; @Slf4j @Component public class SimulationOperationHandlerManager implements ApplicationContextAware { - public static final Map handlerMap = new ConcurrentHashMap<>(); + public static final Map handlerMethodMap = new ConcurrentHashMap<>(); @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { @@ -28,9 +28,9 @@ public class SimulationOperationHandlerManager implements ApplicationContextAwar continue; } String name = operationMapping.value(); - BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(handlerMap.containsKey(name)); + BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(handlerMethodMap.containsKey(name)); OperationHandlerMethod handlerMethod = new OperationHandlerMethod(handler, method); - handlerMap.put(name, handlerMethod); + handlerMethodMap.put(name, handlerMethod); log.info(String.format("成功加载仿真操作{name: %s, method: %s::%s}", name, handler.getClass().getName(), method.getName())); } } @@ -38,7 +38,7 @@ public class SimulationOperationHandlerManager implements ApplicationContextAwar public OperationHandlerMethod getHandlerMethod(String operation) { Objects.requireNonNull(operation); - OperationHandlerMethod method = handlerMap.get(operation); + OperationHandlerMethod method = handlerMethodMap.get(operation); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(method, String.format("操作[%s]没有对应的处理方法", operation)); return method; diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java index bfaa01507..dd3583bef 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; public class CilRepository extends SimulationRepository { public static final String NAME = "CIL"; @@ -38,6 +39,7 @@ public class CilRepository extends SimulationRepository { this.psdMap = new HashMap<>(); this.espMap = new HashMap<>(); this.routeMap = new HashMap<>(); + this.supervisedRouteMap = new ConcurrentHashMap<>(); this.autoSignalMap = new HashMap<>(); this.flsMap = new HashMap<>(); this.overlapMap = new HashMap<>(); diff --git a/src/main/java/club/joylink/rtss/simulation/rt/RtSimulation.java b/src/main/java/club/joylink/rtss/simulation/rt/RtSimulation.java index 0ca66c563..9d439cd44 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/RtSimulation.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/RtSimulation.java @@ -10,13 +10,19 @@ import java.time.LocalDateTime; @Getter public class RtSimulation extends Simulation { public static final int TIME_OFFSET_HOUR = 2; + RtSimulationUser creator; MapVO mapVO; MapPrdTypeEnum prdType; - public RtSimulation(String id) { + SimulationIdGenerator idGenerator; + + public RtSimulation(String id, RtSimulationUser creator) { super(id); + this.idGenerator = new SimulationIdGenerator(); + this.creator = creator; + this.addSimulationUser(creator); } public LocalDateTime convertToSystemTime(LocalDateTime dateTime) { diff --git a/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationMember.java b/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationMember.java index 038258525..5912a6c35 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationMember.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationMember.java @@ -3,11 +3,25 @@ package club.joylink.rtss.simulation.rt; import club.joylink.rtss.simulation.SimulationMember; public class RtSimulationMember extends SimulationMember { + String deviceId; + public RtSimulationMember(String id, Role role) { super(id, role); } - public enum Role { + public RtSimulationMember(String id, Role role, String deviceId) { + super(id, role); + this.deviceId = deviceId; + } + public enum Role { + /** + * 行调 + */ + DISP, + /** + * 车站值班员 + */ + LOWS } } 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 1789cd965..476d5f66e 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationService.java @@ -6,14 +6,16 @@ import club.joylink.rtss.simulation.SimulationManager; import club.joylink.rtss.simulation.cbtc.data.vo.SimulationVO; import club.joylink.rtss.simulation.rt.ATS.AtsLogicService; import club.joylink.rtss.simulation.rt.CIL.CilLogicService; -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.simulation.rt.repo.CommonRepository; +import club.joylink.rtss.simulation.rt.repo.CommonStation; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.map.MapVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.List; import java.util.Objects; @Component @@ -34,14 +36,34 @@ public class RtSimulationService { public RtSimulation create(UserVO userVO, Long mapId, MapPrdTypeEnum prdTypeEnum) { Objects.requireNonNull(mapId); MapVO mapVO = this.mapService.getMapDetail(mapId); - RtSimulation rtSimulation = new RtSimulation(SimulationIdGenerator.buildId()); + RtSimulationUser creator = new RtSimulationUser(userVO.getId().toString()); + RtSimulation rtSimulation = new RtSimulation(SimulationIdGenerator.buildId(), creator); rtSimulation.mapVO = mapVO; this.loadData(rtSimulation, mapVO); - this.srdLogicService.addJobs(rtSimulation); this.simulationManager.save(rtSimulation); + this.srdLogicService.addJobs(rtSimulation); + this.cilLogicService.addJobs(rtSimulation); + this.initSimulationMember(rtSimulation); + this.initCreatorPlayMember(rtSimulation); return rtSimulation; } + private void initCreatorPlayMember(RtSimulation rtSimulation) { + if (MapPrdTypeEnum.LOCAL.equals(rtSimulation.getPrdType())) { + List memberList = rtSimulation.querySimulationMembersOfRole(RtSimulationMember.Role.LOWS); + this.simulationManager.memberPlayedByUser(rtSimulation.getId(), memberList.get(0).getId(), rtSimulation.getCreator().getId()); + } + } + + private void initSimulationMember(RtSimulation rtSimulation) { + CommonRepository repository = rtSimulation.getRepository(CommonRepository.NAME, CommonRepository.class); + for (CommonStation station : repository.getStationMap().values()) { + rtSimulation.addSimulationMember( + new RtSimulationMember(rtSimulation.getIdGenerator().next(), + RtSimulationMember.Role.LOWS, station.getId())); + } + } + /** * 加载相关数据 */ diff --git a/src/main/java/club/joylink/rtss/simulation/rt/SimulationIdGenerator.java b/src/main/java/club/joylink/rtss/simulation/rt/SimulationIdGenerator.java index 5ae4bb593..33741f670 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/SimulationIdGenerator.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/SimulationIdGenerator.java @@ -8,4 +8,14 @@ public class SimulationIdGenerator { public static String buildId() { return String.valueOf(sn.incrementAndGet()); } + + private AtomicInteger bsn; + + public SimulationIdGenerator() { + this.bsn = new AtomicInteger(1); + } + + public String next() { + return String.valueOf(this.bsn.getAndIncrement()); + } } 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 e560fe3e0..8c029cd87 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 @@ -2,10 +2,12 @@ package club.joylink.rtss.simulation.rt.repo; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.SimulationRepository; +import lombok.Getter; import java.util.HashMap; import java.util.Map; +@Getter public class CommonRepository extends SimulationRepository { public static final String NAME = "COMMON";