【大铁调度命令背景保存】
This commit is contained in:
parent
a0580a6435
commit
97184b1867
@ -1,6 +1,8 @@
|
|||||||
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.data;
|
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.data;
|
||||||
|
|
||||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -10,36 +12,57 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
|
|
||||||
public class DisCmdDb {
|
public class DisCmdDb {
|
||||||
private ReentrantLock locker = new ReentrantLock();
|
private ReentrantLock locker = new ReentrantLock();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调度命令
|
* 调度命令
|
||||||
* key-cmdId
|
* key-cmdId
|
||||||
*/
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
private final Map<String, DisCmd> cmdMap = new HashMap<>();
|
private final Map<String, DisCmd> cmdMap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调度命令发令或受令单位状态
|
* 调度命令发令或受令单位状态
|
||||||
* key-cpId
|
* key-cpId
|
||||||
*/
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
private final Map<String, DisCmdCompanyState> cmdStateMap = new HashMap<>();
|
private final Map<String, DisCmdCompanyState> cmdStateMap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调度命令回执
|
* 调度命令回执
|
||||||
* key-cmdId
|
* key-cmdId
|
||||||
*/
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
private final Map<String, List<DisCmdReceipt>> cmdReceiptMap = new HashMap<>();
|
private final Map<String, List<DisCmdReceipt>> cmdReceiptMap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调度命令记录行id生成器
|
* 调度命令记录行id生成器
|
||||||
*/
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
private final AtomicLong disCmdId = new AtomicLong(0);
|
private final AtomicLong disCmdId = new AtomicLong(0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调度命令号生成器
|
* 调度命令号生成器
|
||||||
*/
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
private final AtomicLong disCmdCode = new AtomicLong(0);
|
private final AtomicLong disCmdCode = new AtomicLong(0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调度命令单位记录行id生成器
|
* 调度命令单位记录行id生成器
|
||||||
*/
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
private final AtomicLong disCmdCpId = new AtomicLong(0);
|
private final AtomicLong disCmdCpId = new AtomicLong(0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调度命令回执id生成器
|
* 调度命令回执id生成器
|
||||||
*/
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
private final AtomicLong disCmdReceiptId = new AtomicLong(0);
|
private final AtomicLong disCmdReceiptId = new AtomicLong(0);
|
||||||
|
|
||||||
public String getCmdId() {
|
public String getCmdId() {
|
||||||
|
@ -0,0 +1,118 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.data.storage.ctc;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.data.DisCmd;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.data.DisCmdCompanyState;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.data.DisCmdDb;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.data.DisCmdReceipt;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CTC调度命令背景数据
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class StorageDisCmdDb {
|
||||||
|
|
||||||
|
private Map<String, DisCmd> cmdMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度命令发令或受令单位状态
|
||||||
|
* key-cpId
|
||||||
|
*/
|
||||||
|
private Map<String, DisCmdCompanyState> cmdStateMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度命令回执
|
||||||
|
* key-cmdId
|
||||||
|
*/
|
||||||
|
private Map<String, List<DisCmdReceipt>> cmdReceiptMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度命令记录行id生成器
|
||||||
|
*/
|
||||||
|
private Long disCmdId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度命令号生成器
|
||||||
|
*/
|
||||||
|
private Long disCmdCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度命令单位记录行id生成器
|
||||||
|
*/
|
||||||
|
private Long disCmdCpId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度命令回执id生成器
|
||||||
|
*/
|
||||||
|
private Long disCmdReceiptId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 序列化成剧本数据
|
||||||
|
*/
|
||||||
|
public static StorageDisCmdDb convert2Storage(DisCmdDb disCmdDb) {
|
||||||
|
if (disCmdDb.getCmdMap().isEmpty()) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
StorageDisCmdDb storageDisCmdDb = new StorageDisCmdDb();
|
||||||
|
storageDisCmdDb.setCmdMap(disCmdDb.getCmdMap());
|
||||||
|
if (!disCmdDb.getCmdStateMap().isEmpty()) {
|
||||||
|
storageDisCmdDb.setCmdStateMap(disCmdDb.getCmdStateMap());
|
||||||
|
}
|
||||||
|
if (!disCmdDb.getCmdReceiptMap().isEmpty()) {
|
||||||
|
storageDisCmdDb.setCmdReceiptMap(disCmdDb.getCmdReceiptMap());
|
||||||
|
}
|
||||||
|
if (disCmdDb.getDisCmdId().get() > 0) {
|
||||||
|
storageDisCmdDb.setDisCmdId(disCmdDb.getDisCmdId().get());
|
||||||
|
}
|
||||||
|
if (disCmdDb.getDisCmdCode().get() > 0) {
|
||||||
|
storageDisCmdDb.setDisCmdCode(disCmdDb.getDisCmdCode().get());
|
||||||
|
}
|
||||||
|
if (disCmdDb.getDisCmdCpId().get() > 0) {
|
||||||
|
storageDisCmdDb.setDisCmdCpId(disCmdDb.getDisCmdCpId().get());
|
||||||
|
}
|
||||||
|
if (disCmdDb.getDisCmdReceiptId().get() > 0) {
|
||||||
|
storageDisCmdDb.setDisCmdReceiptId(disCmdDb.getDisCmdReceiptId().get());
|
||||||
|
}
|
||||||
|
return storageDisCmdDb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反序列化数据
|
||||||
|
*/
|
||||||
|
public void convert(DisCmdDb disCmdDb) {
|
||||||
|
if (cmdMap != null) {
|
||||||
|
disCmdDb.getCmdMap().putAll(cmdMap);
|
||||||
|
}
|
||||||
|
if (cmdStateMap != null) {
|
||||||
|
disCmdDb.getCmdStateMap().putAll(cmdStateMap);
|
||||||
|
}
|
||||||
|
if (cmdReceiptMap != null) {
|
||||||
|
disCmdDb.getCmdReceiptMap().putAll(cmdReceiptMap);
|
||||||
|
}
|
||||||
|
if (disCmdId != null) {
|
||||||
|
disCmdDb.getDisCmdId().set(disCmdId);
|
||||||
|
}
|
||||||
|
if (disCmdCode != null) {
|
||||||
|
disCmdDb.getDisCmdCode().set(disCmdCode);
|
||||||
|
}
|
||||||
|
if (disCmdCpId != null) {
|
||||||
|
disCmdDb.getDisCmdCpId().set(disCmdCpId);
|
||||||
|
}
|
||||||
|
if (disCmdReceiptId != null) {
|
||||||
|
disCmdDb.getDisCmdReceiptId().set(disCmdReceiptId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -66,6 +66,11 @@ public class StorageSimulationCtcDataRepository {
|
|||||||
*/
|
*/
|
||||||
private List<StorageRailDispatchCommand> dispatchCommandList;
|
private List<StorageRailDispatchCommand> dispatchCommandList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度命令数据
|
||||||
|
*/
|
||||||
|
private StorageDisCmdDb storageDisCmdDb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存剧本数据
|
* 保存剧本数据
|
||||||
*
|
*
|
||||||
@ -75,8 +80,7 @@ public class StorageSimulationCtcDataRepository {
|
|||||||
this.storageCtcZoneData = StorageCtcZoneData.convert2Storage(repository.getCtcZoneRepository());
|
this.storageCtcZoneData = StorageCtcZoneData.convert2Storage(repository.getCtcZoneRepository());
|
||||||
this.storageCtcEffectData = StorageCtcEffectData.convert2Storage(repository.getCtcEffectRepository());
|
this.storageCtcEffectData = StorageCtcEffectData.convert2Storage(repository.getCtcEffectRepository());
|
||||||
if (!repository.getAllRunPlanList().isEmpty()) {
|
if (!repository.getAllRunPlanList().isEmpty()) {
|
||||||
this.runPlanLogList = repository.getAllRunPlanList().stream()
|
this.runPlanLogList = repository.getAllRunPlanList().stream().map(StorageCtcRunPlanLog::convert2Storage).collect(Collectors.toList());
|
||||||
.map(r -> StorageCtcRunPlanLog.convert2Storage(r)).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
if (repository.routeSequenceMapIsNotEmpty()) {
|
if (repository.routeSequenceMapIsNotEmpty()) {
|
||||||
this.routeSequenceMap = new HashMap<>();
|
this.routeSequenceMap = new HashMap<>();
|
||||||
@ -107,6 +111,8 @@ public class StorageSimulationCtcDataRepository {
|
|||||||
.map(StorageRailDispatchCommand::convert2Storage).collect(Collectors.toList());
|
.map(StorageRailDispatchCommand::convert2Storage).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 调度命令
|
||||||
|
this.storageDisCmdDb = StorageDisCmdDb.convert2Storage(repository.getDisCmdDb());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,12 +164,16 @@ public class StorageSimulationCtcDataRepository {
|
|||||||
if (this.dispatchCommandList != null && !this.dispatchCommandList.isEmpty()) {
|
if (this.dispatchCommandList != null && !this.dispatchCommandList.isEmpty()) {
|
||||||
this.dispatchCommandList.forEach(command -> repository.addDispatchCommand(command.recover2Simulation(simulation)));
|
this.dispatchCommandList.forEach(command -> repository.addDispatchCommand(command.recover2Simulation(simulation)));
|
||||||
}
|
}
|
||||||
|
// 调度命令
|
||||||
|
if (this.storageDisCmdDb != null) {
|
||||||
|
this.storageDisCmdDb.convert(repository.getDisCmdDb());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNotEmpty() {
|
public boolean isNotEmpty() {
|
||||||
return this.storageCtcZoneData != null || this.storageCtcEffectData != null || this.runPlanLogList != null
|
return this.storageCtcZoneData != null || this.storageCtcEffectData != null || this.runPlanLogList != null
|
||||||
|| this.routeSequenceMap != null || this.ticketId != null || this.railTicketList != null
|
|| this.routeSequenceMap != null || this.ticketId != null || this.railTicketList != null
|
||||||
|| this.greenLicensesList != null || this.redLicenseList != null || this.dispatchCommandId != null
|
|| this.greenLicensesList != null || this.redLicenseList != null || this.dispatchCommandId != null
|
||||||
|| this.dispatchCommandList != null;
|
|| this.dispatchCommandList != null || this.storageDisCmdDb != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user