diff --git a/src/main/java/club/joylink/rtss/simulation/Simulation.java b/src/main/java/club/joylink/rtss/simulation/Simulation.java index 3bcb30850..e9c5303a2 100644 --- a/src/main/java/club/joylink/rtss/simulation/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/Simulation.java @@ -463,7 +463,14 @@ public abstract class Simulation dispatcherList = simulation.querySimulationMembersOfRole(SimulationMember.Type.DISPATCHER); - SimulationMember dispatcher = null; - for (SimulationMember member : dispatcherList) { - if (member.isRobot()) { - dispatcher = member; - break; - } - } - if (Objects.isNull(dispatcher)) { - // 行调都被占用,添加新的行调 - dispatcher = this.memberManager.addRole(simulation, SimulationMember.Type.DISPATCHER); - } - this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), dispatcher.getId()); - break; - } - case DEPOT: { - List depoterList = simulation.querySimulationMembersOfRole(SimulationMember.Type.DEPOT_DISPATCHER); - SimulationMember depoter = null; - for (SimulationMember member : depoterList) { - if (member.isRobot()) { - depoter = member; - break; - } - } - if (Objects.isNull(depoter)) { - depoter = this.memberManager.addRole(simulation, SimulationMember.Type.DEPOT_DISPATCHER); - } - this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), depoter.getId()); - break; - } - case SCHEDULING: { - - } - } +// switch (deviceVO.getType()) { +// case LW: { +// // 暂时默认先按配置的车站创建成员 +// LwConfigVO lwConfigVO = deviceVO.buildLwConfig(); +// Station station = simulation.getRepository().getByCode(lwConfigVO.getStationCode(), Station.class); +// SimulationMember member = simulation.getSimulationMember(station, SimulationMember.Type.STATION_SUPERVISOR); +// this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), member.getId()); +// // 现地工作站 +// break; +// } +// case CW: { +// // 行调工作站 +// List dispatcherList = simulation.querySimulationMembersOfRole(SimulationMember.Type.DISPATCHER); +// SimulationMember dispatcher = null; +// for (SimulationMember member : dispatcherList) { +// if (member.isRobot()) { +// dispatcher = member; +// break; +// } +// } +// if (Objects.isNull(dispatcher)) { +// // 行调都被占用,添加新的行调 +// dispatcher = this.memberManager.addRole(simulation, SimulationMember.Type.DISPATCHER); +// } +// this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), dispatcher.getId()); +// break; +// } +// case DEPOT: { +// List depoterList = simulation.querySimulationMembersOfRole(SimulationMember.Type.DEPOT_DISPATCHER); +// SimulationMember depoter = null; +// for (SimulationMember member : depoterList) { +// if (member.isRobot()) { +// depoter = member; +// break; +// } +// } +// if (Objects.isNull(depoter)) { +// depoter = this.memberManager.addRole(simulation, SimulationMember.Type.DEPOT_DISPATCHER); +// } +// this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), depoter.getId()); +// break; +// } +// case SCHEDULING: { +// +// } +// } loginUserInfo.setGroup(simulation.getId()); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/member/MemberManager.java b/src/main/java/club/joylink/rtss/simulation/cbtc/member/MemberManager.java index dfce4c0a5..783e490b8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/member/MemberManager.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/member/MemberManager.java @@ -47,10 +47,10 @@ public class MemberManager { List stationList = simulation.getRepository().getSortedStationList(); for (Station station : stationList) { if (station.isNormal()) { - this.addRole(simulation, SimulationMember.Type.STATION_SUPERVISOR, null, station); + this.addRole(simulation, null, SimulationMember.Type.STATION_SUPERVISOR, null, station); } else if (station.isDepot()) { // 车辆段调度 - this.addRole(simulation, SimulationMember.Type.DEPOT_DISPATCHER, station.getName() + "调度", station); + this.addRole(simulation, null, SimulationMember.Type.DEPOT_DISPATCHER, station.getName() + "调度", station); } // 大铁CTC if (simulation.getRepository().getConfig().isRailway()) { @@ -60,7 +60,7 @@ public class MemberManager { SimulationMember.Type.STATION_SIGNALER, SimulationMember.Type.STATION_PASSENGER, SimulationMember.Type.STATION_SWITCH_MAN, SimulationMember.Type.STATION_FACILITATOR, SimulationMember.Type.STATION_WORKER, SimulationMember.Type.DEVICE_MANAGER - ).forEach(type -> this.addRole(simulation, type, null, station)); + ).forEach(type -> this.addRole(simulation, null, type, null, station)); } } //调度台 @@ -69,14 +69,14 @@ public class MemberManager { List disStationList = simulation.getRepository().getDisStationList(); if (null != disStationList) { for (DisStation disStation : disStationList) { - this.addRole(simulation, SimulationMember.Type.DISPATCHER, disStation.getName() + "调度", disStation); + this.addRole(simulation, null, SimulationMember.Type.DISPATCHER, disStation.getName() + "调度", disStation); } } } // 司机 List vrTrainList = simulation.getRepository().getAllVrTrain(); for (VirtualRealityTrain vrTrain : vrTrainList) { - this.addRole(simulation, SimulationMember.Type.DRIVER, null, vrTrain); + this.addRole(simulation, null, SimulationMember.Type.DRIVER, null, vrTrain); } // 工电调度 this.addRole(simulation, SimulationMember.Type.ELECTRIC_DISPATCHER); @@ -130,18 +130,18 @@ public class MemberManager { } public SimulationMember addRole(Simulation simulation, SimulationMember.Type type) { - SimulationMember member = this.addRole(simulation, type, null, null); + SimulationMember member = this.addRole(simulation, null, type, null, null); SimulationMemberAddEvent memberAddEvent = new SimulationMemberAddEvent(this, simulation, member); this.applicationContext.publishEvent(memberAddEvent); return member; } public SimulationMember addRole(Simulation simulation, SimulationMember.Type type, String name) { - return this.addRole(simulation, type, name, null); + return this.addRole(simulation, null, type, name, null); } public SimulationMember addRole(Simulation simulation, - SimulationMember.Type type, + String id, SimulationMember.Type type, String name, MapElement device) { switch (type) { case DISPATCHER: @@ -174,7 +174,10 @@ public class MemberManager { break; } } - SimulationMember member = new SimulationMember(simulation.getIdGenerator().nextMemberId(), type, device); + if (id == null) { + id = simulation.getIdGenerator().nextMemberId(); + } + SimulationMember member = new SimulationMember(id, type, device); member.setName(name); simulation.addSimulationMember(member); SimulationMemberAddEvent memberAddEvent = new SimulationMemberAddEvent(this, simulation, member); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/work/SimulationWorkServiceManager.java b/src/main/java/club/joylink/rtss/simulation/cbtc/work/SimulationWorkServiceManager.java index 956ca384f..d6c296c36 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/work/SimulationWorkServiceManager.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/work/SimulationWorkServiceManager.java @@ -73,7 +73,7 @@ public class SimulationWorkServiceManager implements ApplicationContextAware { mapElement = repository.getVRByCode(memberVO.getDeviceCode()); } } - memberManager.addRole(simulation, memberVO.getType(), memberVO.getName(), mapElement); + memberManager.addRole(simulation, memberVO.getId(), memberVO.getType(), memberVO.getName(), mapElement); } } @@ -91,10 +91,7 @@ public class SimulationWorkServiceManager implements ApplicationContextAware { * 添加仿真用户 */ public void addSimulationUser(Simulation simulation, SimulationUser simulationUser) { - SimulationUser oldUser = simulation.addSimulationUser(simulationUser); - if (oldUser != null) { - log.warn("[{}]被[{}]替换", oldUser, simulationUser.toString()); - } + simulation.addSimulationUser(simulationUser); SimulationUserEnterEvent userEnterEvent = new SimulationUserEnterEvent(this, simulation, simulationUser); this.applicationContext.publishEvent(userEnterEvent); }