添加信号机新字段存储对象逻辑
This commit is contained in:
parent
d90288429d
commit
7027712908
@ -166,6 +166,11 @@ public abstract class Simulation<U extends SimulationUser, M extends Simulation
|
|||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSpeed() {
|
||||||
|
return speed;
|
||||||
|
}
|
||||||
|
|
||||||
private void setSystemTime(LocalDateTime systemTime) {
|
private void setSystemTime(LocalDateTime systemTime) {
|
||||||
this.systemTime = systemTime;
|
this.systemTime = systemTime;
|
||||||
}
|
}
|
||||||
@ -347,9 +352,9 @@ public abstract class Simulation<U extends SimulationUser, M extends Simulation
|
|||||||
this.repositoryMap.put(repository.getName(), repository);
|
this.repositoryMap.put(repository.getName(), repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends SimulationRepository> T getRepository(String name, Class<T> cls) {
|
public <R extends SimulationRepository> R getRepository(String name, Class<R> cls) {
|
||||||
Objects.requireNonNull(name);
|
Objects.requireNonNull(name);
|
||||||
return (T) this.repositoryMap.get(name);
|
return (R) this.repositoryMap.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public M querySimulationMemberById(String id) {
|
public M querySimulationMemberById(String id) {
|
||||||
@ -515,4 +520,9 @@ public abstract class Simulation<U extends SimulationUser, M extends Simulation
|
|||||||
user.unsubscribe(wsSessionId, destination);
|
user.unsubscribe(wsSessionId, destination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SimulationUser> getSimulationUsers() {
|
||||||
|
ArrayList<SimulationUser> list = new ArrayList(this.simulationUserMap.values());
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,9 @@ import club.joylink.rtss.simulation.operation.SimulationOperationDispatcher;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仿真通用接口
|
* 仿真通用接口
|
||||||
@ -17,6 +19,14 @@ public class SimulationCommonController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SimulationOperationDispatcher simulationOperationDispatcher;
|
private SimulationOperationDispatcher simulationOperationDispatcher;
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
public List<SimulationInfoVO> queryInfo() {
|
||||||
|
List<Simulation> simulationList = this.simulationManager.getSimulationList();
|
||||||
|
return simulationList.stream()
|
||||||
|
.map(simulation -> new SimulationInfoVO(simulation))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}/pause")
|
@PutMapping("/{id}/pause")
|
||||||
public void pause(@PathVariable String id) {
|
public void pause(@PathVariable String id) {
|
||||||
this.simulationManager.pause(id);
|
this.simulationManager.pause(id);
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package club.joylink.rtss.simulation;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SimulationInfoVO {
|
||||||
|
String id;
|
||||||
|
String name;
|
||||||
|
Integer speed;
|
||||||
|
LocalDateTime sysTime;
|
||||||
|
Integer state;
|
||||||
|
List<SimulationUserInfoVO> userInfoList;
|
||||||
|
|
||||||
|
public SimulationInfoVO(Simulation simulation) {
|
||||||
|
this.id = simulation.getId();
|
||||||
|
this.name = simulation.debugStr();
|
||||||
|
this.speed = simulation.getSpeed();
|
||||||
|
this.sysTime = simulation.getSystemTime();
|
||||||
|
this.state = simulation.getState();
|
||||||
|
List<SimulationUser> simulationUsers = simulation.getSimulationUsers();
|
||||||
|
this.userInfoList = simulationUsers.stream()
|
||||||
|
.map(user -> new SimulationUserInfoVO((SimulationUser) user))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static class SimulationUserInfoVO {
|
||||||
|
String id;
|
||||||
|
private Map<String, Set<String>> subscribeMap;
|
||||||
|
|
||||||
|
public SimulationUserInfoVO(SimulationUser user) {
|
||||||
|
this.id = user.getId();
|
||||||
|
this.subscribeMap = user.getSubscribeMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -8,6 +8,8 @@ import org.springframework.context.ApplicationContext;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@ -138,4 +140,8 @@ public class SimulationManager {
|
|||||||
this.applicationContext.publishEvent(new SimulationMemberPlayChangeEvent(this, simulation, member));
|
this.applicationContext.publishEvent(new SimulationMemberPlayChangeEvent(this, simulation, member));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Simulation> getSimulationList() {
|
||||||
|
return new ArrayList<>(simulationCache.values());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,4 +76,8 @@ public abstract class SimulationUser {
|
|||||||
this.memberId = null;
|
this.memberId = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Set<String>> getSubscribeMap() {
|
||||||
|
return this.wsSubscribeMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,10 @@ public class StorageSignal extends StorageMayOutOfOrderDevice {
|
|||||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||||
private Boolean reblockade;
|
private Boolean reblockade;
|
||||||
|
|
||||||
|
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||||
|
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||||
|
private Boolean fpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 逻辑点灯/物理点灯
|
* 逻辑点灯/物理点灯
|
||||||
*/
|
*/
|
||||||
@ -108,6 +112,10 @@ public class StorageSignal extends StorageMayOutOfOrderDevice {
|
|||||||
change = true;
|
change = true;
|
||||||
storageSignal.setReblockade(signal.isReblockade());
|
storageSignal.setReblockade(signal.isReblockade());
|
||||||
}
|
}
|
||||||
|
if (signal.isFpl()) {
|
||||||
|
change = true;
|
||||||
|
storageSignal.setFpl(signal.isFpl());
|
||||||
|
}
|
||||||
if (!signal.isLogicLight()) {
|
if (!signal.isLogicLight()) {
|
||||||
change = true;
|
change = true;
|
||||||
storageSignal.setLogicLight(signal.isLogicLight());
|
storageSignal.setLogicLight(signal.isLogicLight());
|
||||||
@ -151,6 +159,7 @@ public class StorageSignal extends StorageMayOutOfOrderDevice {
|
|||||||
signal.setBlockade(blockade != null ? blockade : false);
|
signal.setBlockade(blockade != null ? blockade : false);
|
||||||
signal.setLevel(this.level != null ? this.level : 1);
|
signal.setLevel(this.level != null ? this.level : 1);
|
||||||
signal.setReblockade(this.reblockade != null ? this.reblockade : false);
|
signal.setReblockade(this.reblockade != null ? this.reblockade : false);
|
||||||
|
signal.setFpl(this.fpl != null ? this.fpl : false);
|
||||||
signal.setLogicLight(logicLight != null ? logicLight : true);
|
signal.setLogicLight(logicLight != null ? logicLight : true);
|
||||||
signal.setGreenOpen(greenOpen != null ? greenOpen : false);
|
signal.setGreenOpen(greenOpen != null ? greenOpen : false);
|
||||||
signal.setYellowOpen(yellowOpen != null ? yellowOpen : false);
|
signal.setYellowOpen(yellowOpen != null ? yellowOpen : false);
|
||||||
|
Loading…
Reference in New Issue
Block a user