修改获取仿真日志接口的实现;站台设置停站时间增加对列车设置停站时间功能

This commit is contained in:
joylink_zhangsai 2021-08-26 16:11:41 +08:00
parent c362c47fcd
commit b6a6bd1c89
10 changed files with 85 additions and 47 deletions

View File

@ -806,4 +806,15 @@ public interface BusinessConsts {
WITHIN_A_WEEK,
WEEKEND,
}
enum Regulation{
/** 时刻表调度 */
TIME_TABLE_REGULATION,
/** 行车间隔调度 - 前调 */
HEADWAY_REGULATION_FRONT,
/** 行车间隔调度 - 前调 + 后调 */
HEADWAY_REGULATION_FRONT_AND_BACK,
/** 关闭自动调度 */
REGULATION_OFF,
}
}

View File

@ -392,6 +392,8 @@ public class Operation {
Train_Set_Deviation,
/** 取消偏离【泰雷兹】 */
Train_Cancel_Deviation,
/** 列车调度 */
Train_Regulation,
//--------------------------- 司机 ---------------------------
/** 改变列车的牵引/制动力 */

View File

@ -125,8 +125,8 @@ public class StandOperateHandler {
* 设置停站时间
*/
@OperateHandlerMapping(type = Operation.Type.Stand_Set_Park_Time)
public void setParkTime(Simulation simulation, String standCode, int parkingTime, boolean parkingAlwaysValid) {
atsStandService.setParkTime(simulation, standCode, parkingTime, parkingAlwaysValid);
public void setParkTime(Simulation simulation, String standCode, int parkingTime, boolean parkingAlwaysValid, String groupNumber) {
atsStandService.setParkTime(simulation, standCode, parkingTime, parkingAlwaysValid, groupNumber);
}
/**

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc.ATS.operation.handler;
import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping;
@ -100,10 +101,10 @@ public class TrainOperateHandler {
* @param simulation
* @param sectionCode 区段编号
* @param groupNumber 车组号
* @param dn 目的地码可为空
* @param sn 服务号/表号可为空
* @param tn 行程号/序号/车次号可为空
* @param cn 乘务组号可为空
* @param dn 目的地码可为空
* @param sn 服务号/表号可为空
* @param tn 行程号/序号/车次号可为空
* @param cn 乘务组号可为空
*/
@OperateHandlerMapping(type = Operation.Type.Train_Add_Train_Trace)
public void addTrainTrace(Simulation simulation, String sectionCode, String groupNumber,
@ -377,4 +378,9 @@ public class TrainOperateHandler {
public void cancelCBTCRoute(Simulation simulation, List<String> routeCodes) {
atsTrainService.cancelCBTCRoute(simulation, routeCodes);
}
@OperateHandlerMapping(type = Operation.Type.Train_Regulation)
public void regulation(Simulation simulation, String groupNumber, BusinessConsts.Regulation regulation) {
}
}

View File

@ -37,13 +37,16 @@ public class AtsStandService {
@Autowired
private CiApiService ciApiService;
public int trainParkingAndGetParkTime(Simulation simulation, Section section) {
public int trainParkingAndGetParkTime(Simulation simulation, Section section, String groupNumber) {
List<Stand> standList = section.getStandList();
int parkTime = -1;
for (Stand stand : standList) {
log.debug(String.format("站台[%s(%s)]列车停靠", stand.getName(), stand.getCode()));
stand.setTrainParking(true);
if (stand.getParkingTime() > 0) {
Integer integer = stand.getParkingTimeMap().get(groupNumber);
if (integer != null) {
parkTime = integer;
} else {
parkTime = stand.getParkingTime();
if (!stand.isParkingAlwaysValid()) { // 如果停站时间一次有效清除
stand.setParkingTime(-1);
@ -232,9 +235,13 @@ public class AtsStandService {
/**
* 设置停站时间
*/
public void setParkTime(Simulation simulation, String standCode, int parkingTime, boolean parkingAlwaysValid) {
public void setParkTime(Simulation simulation, String standCode, int parkingTime, boolean parkingAlwaysValid, String groupNumber) {
Stand stand = getStand(simulation, standCode);
stand.setParkingTime(parkingTime);
if (StringUtils.hasText(groupNumber)) {
stand.addTrainParkingTime(groupNumber, parkingTime);
} else {
stand.setParkingTime(parkingTime);
}
stand.setParkingAlwaysValid(parkingAlwaysValid);
}

View File

@ -140,7 +140,7 @@ public class AtsTrainMonitorService {
this.realRunRecordService.recordTrainRealRun(simulation, train, station, standTrack, true);
train.updateArriveInfo(systemTime.toLocalTime(), station, standTrack);
if (!CollectionUtils.isEmpty(standTrack.getStandList())) {
int parkTime = this.atsStandService.trainParkingAndGetParkTime(simulation, standTrack);
int parkTime = this.atsStandService.trainParkingAndGetParkTime(simulation, standTrack, train.getGroupNumber());
if (parkTime < 0) {
parkTime = this.getParkTimeOf(simulation, train, standTrack);
}

View File

@ -1002,29 +1002,10 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
@Override
public PageVO<SimulationLog> getLog(String group, SimulationLogPagedQueryVO queryVO) {
List<SimulationLog> logs = getSimulationByGroup(group).getLogs();
//根据时间筛选
if (!CollectionUtils.isEmpty(logs)) {
if (queryVO.getStartTime() != null || queryVO.getEndTime() != null) {
logs = logs.stream().filter(log -> {
boolean flag = true;
if (queryVO.getStartTime() != null) {
flag = flag && !log.getTime().isBefore(queryVO.getStartTime());
}
if (queryVO.getEndTime() != null) {
flag = flag && !log.getTime().isAfter(queryVO.getEndTime());
}
return flag;
}).collect(Collectors.toList());
}
}
PageVO<SimulationLog> pageVO = new PageVO<>();
pageVO.setPageSize(queryVO.getPageSize());
if (CollectionUtils.isEmpty(logs)) {
pageVO.setPageNum(1);
pageVO.setList(new ArrayList<>());
pageVO.setTotal(0);
} else {
//根据时间筛选
if (!CollectionUtils.isEmpty(logs)) {
//根据分页信息筛选
int maxPageNum = logs.size() / queryVO.getPageSize() + 1;
int pageNum = Math.min(maxPageNum, queryVO.getPageNum());
@ -1033,13 +1014,22 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
int end = pageNum * queryVO.getPageSize();
start = Math.min(start, logs.size() - 1);
end = Math.min(end, logs.size());
if (start >= logs.size()) {
start = logs.size() - 1;
}
pageVO.setPageNum(pageNum);
pageVO.setTotal(logs.size());
pageVO.setList(logs.subList(start, end));
logs = logs.stream()
.filter(log -> {
if (queryVO.getStartTime() != null && log.getTime().isBefore(queryVO.getStartTime()))
return false;
if (queryVO.getEndTime() != null && log.getTime().isAfter(queryVO.getEndTime()))
return false;
return true;
})
.skip(start)
.limit(end - start)
.collect(Collectors.toList());
pageVO.setList(logs);
} else {
pageVO.setPageNum(1);
pageVO.setList(new ArrayList<>());
pageVO.setTotal(0);
}
return pageVO;
}

View File

@ -5,14 +5,13 @@ import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import io.netty.util.internal.ConcurrentSet;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.CollectionUtils;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* 站台
@ -109,7 +108,7 @@ public class Stand extends MayOutOfOrderDevice {
/**
* 指定跳停车辆编号(车组号)
*/
private Set<String> skipSet = Collections.synchronizedSet(new HashSet());
private Set<String> skipSet = Collections.synchronizedSet(new HashSet<>());
/**
* 跳停一直有效
@ -138,6 +137,9 @@ public class Stand extends MayOutOfOrderDevice {
*/
private int parkingTime;
/** 列车-停站时间map */
private final Map<String, Integer> parkingTimeMap = new ConcurrentHashMap<>();
/**
* 停车设置状态一直有效/一次有效
*/
@ -184,6 +186,7 @@ public class Stand extends MayOutOfOrderDevice {
this.runLevelTime = 0;
this.runLevelTimeForever = false;
this.parkingTime = -1;
this.clearTrainParkingTime();
this.parkingAlwaysValid = false;
this.typeStrategy = this.defaultTypeStrategy;
this.noStatus = false;
@ -334,6 +337,14 @@ public class Stand extends MayOutOfOrderDevice {
this.setRemainTime(0);
}
public void addTrainParkingTime(String groupNumber, int parkingTime) {
this.parkingTimeMap.put(groupNumber, parkingTime);
}
public void clearTrainParkingTime() {
this.parkingTimeMap.clear();
}
/**
* 站台折返类型策略
*/

View File

@ -10,9 +10,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter;
import org.springframework.util.CollectionUtils;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.*;
/**
* 站台状态
@ -76,6 +74,8 @@ public class StandStatus extends DeviceStatus {
/**停车时间(自动为-1*/
private int parkingTime;
private Map<String, Integer> parkingTimeMap;
/**停车设置状态(一直有效/一次有效)*/
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean parkingAlwaysValid;
@ -116,6 +116,7 @@ public class StandStatus extends DeviceStatus {
this.runLevelTimeForever = stand.isRunLevelTimeForever();
this.trainLimit = stand.getTrainLimit();
this.parkingTime = stand.getParkingTime();
this.parkingTimeMap = new HashMap<>(stand.getParkingTimeMap());
this.parkingAlwaysValid = stand.isParkingAlwaysValid();
this.typeStrategy = stand.getTypeStrategy();
this.noStatus = stand.isNoStatus();
@ -182,6 +183,7 @@ public class StandStatus extends DeviceStatus {
if (Objects.isNull(this.skipSet) ||
(this.skipSet.size() != stand.getSkipSet().size())) {
this.skipSet = new HashSet<>(stand.getSkipSet());
status.setSkipSet(this.skipSet);
change = true;
}
status.setSkipSet(this.skipSet );
@ -210,6 +212,11 @@ public class StandStatus extends DeviceStatus {
status.setParkingTime(this.parkingTime);
change = true;
}
if (!Objects.equals(this.parkingTimeMap, stand.getParkingTimeMap())) {
this.parkingTimeMap = new HashMap<>(stand.getParkingTimeMap());
status.setParkingTimeMap(parkingTimeMap);
change = true;
}
if (!Objects.equals(this.parkingAlwaysValid, stand.isParkingAlwaysValid())) {
this.parkingAlwaysValid = stand.isParkingAlwaysValid();
status.setParkingAlwaysValid(this.parkingAlwaysValid);

View File

@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter;
import lombok.Setter;
import java.util.Map;
import java.util.Set;
/**
@ -73,6 +74,9 @@ public class StandStatusVO extends DeviceStatusVO {
/**停车时间(自动为-1*/
private Integer parkingTime;
/** 列车-停站时间 */
private Map<String, Integer> parkingTimeMap;
/**停车设置状态(一直有效/一次有效)*/
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean parkingAlwaysValid;