添加进路排列检查失败日志打印

大客流策略流程
This commit is contained in:
walker-sheng 2021-01-20 18:55:53 +08:00
parent 6f6a323d8d
commit c2d0137c28
14 changed files with 350 additions and 0 deletions

View File

@ -280,6 +280,7 @@ public class RouteService {
public Route.CheckFailMessage setting(Simulation simulation, Route route) { public Route.CheckFailMessage setting(Simulation simulation, Route route) {
Route.CheckFailMessage check = this.check(simulation, route); Route.CheckFailMessage check = this.check(simulation, route);
if (Objects.nonNull(check)) { if (Objects.nonNull(check)) {
log.info(String.format("进路[%s]排列检查失败,无法排列:%s", route.debugStr(), check.debugStr()));
return check; return check;
} }
// 进路开始办理 // 进路开始办理

View File

@ -534,6 +534,10 @@ public class Route extends MapNamedElement {
} }
return JsonUtils.writeValueAsString(map); return JsonUtils.writeValueAsString(map);
} }
public String debugStr() {
return String.format("设备%s,失败原因:%s", this.device.debugStr(), this.reason);
}
} }
} }

View File

@ -56,6 +56,9 @@ public class PassengerFlowSimulateService {
@Autowired @Autowired
private MapPassengerFlowDataService mapPassengerFlowDataService; private MapPassengerFlowDataService mapPassengerFlowDataService;
public List<PassengerFlowSimulationData> getPassengerFlowSimulations() {
return new ArrayList<>(passengerFlowSimulationDataMap.values());
}
public boolean changePassengerFlow(String group, Long passengerFlowId) { public boolean changePassengerFlow(String group, Long passengerFlowId) {
if(!Objects.equals(group2mapPassengerFlowID.get(group),passengerFlowId)){ if(!Objects.equals(group2mapPassengerFlowID.get(group),passengerFlowId)){
@ -550,6 +553,10 @@ public class PassengerFlowSimulateService {
return viewInfo.closeView(mapElement.getDeviceType()); return viewInfo.closeView(mapElement.getDeviceType());
} }
public Simulation getSimulationByGroup(String group) {
return this.groupSimulationCache.getSimulationByGroup(group);
}
static class PassengerFlowViewInfo { static class PassengerFlowViewInfo {
String group; String group;
UserVO user; UserVO user;

View File

@ -1,11 +1,14 @@
package club.joylink.rtss.simulation.cbtc.passenger.data; package club.joylink.rtss.simulation.cbtc.passenger.data;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.StandPassenger;
import club.joylink.rtss.vo.client.passenger.PassengerFlowMessage2TD; import club.joylink.rtss.vo.client.passenger.PassengerFlowMessage2TD;
import lombok.Getter; import lombok.Getter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Getter @Getter
public class PassengerFlowSimulationData { public class PassengerFlowSimulationData {
@ -20,6 +23,11 @@ public class PassengerFlowSimulationData {
*/ */
private List<PassengerFlowMessage2TD> historyPassengerMessage2TD = new ArrayList<>(); private List<PassengerFlowMessage2TD> historyPassengerMessage2TD = new ArrayList<>();
/**
* 出现大客流的站台
*/
private Map<String, StandPassenger> lpfStandMap = new ConcurrentHashMap<>();
public PassengerFlowSimulationData(String group, public PassengerFlowSimulationData(String group,
PassengerFlowData passengerFlowData, PassengerFlowData passengerFlowData,
Map<String, StandPassengerFlow> standPassengerFlowMap, Map<String, StandPassengerFlow> standPassengerFlowMap,
@ -37,4 +45,18 @@ public class PassengerFlowSimulationData {
public List<TrainPassengerFlow> getAllTrainPassengerFlow() { public List<TrainPassengerFlow> getAllTrainPassengerFlow() {
return new ArrayList<>(trainPassengerFlowMap.values()); return new ArrayList<>(trainPassengerFlowMap.values());
} }
public void addLpfStand(StandPassenger standPassenger) {
this.lpfStandMap.put(standPassenger.getStand().getCode(), standPassenger);
}
public void setLpfStands(List<StandPassenger> lpfStandList) {
for (StandPassenger standPassenger : lpfStandList) {
this.lpfStandMap.put(standPassenger.getStand().getCode(), standPassenger);
}
}
public boolean containsLpfStand(Stand stand) {
return this.lpfStandMap.containsKey(stand.getCode());
}
} }

View File

@ -0,0 +1,16 @@
package club.joylink.rtss.simulation.cbtc.passenger.strategy;
public final class Config {
/** 策略向后推算的时间,单位 - 分钟 */
public static final int STRATEGY_CAL_TIME = 30;
/** 站台大客流判断基准值 */
public static final int STAND_LPF_TRIGGER = 800;
/** 站台最大停站时间:单位 - 秒 */
public static final int STAND_MAX_STOP_TIME = 90;
/** 列车最大容量 */
public static final int TRAIN_CAPACITY = 1500;
/** 站台乘客上列车速度: 人/秒 (列车停站上车时间应该是总停站时间-开关门6s+下车4s+发车前确认5s) */
public static final float PASSENGER_ON_SPEED = 12;
/** 列车跳停节省时间,单位 - 秒 */
public static final int TRAIN_PASS_SAVE_TIME = 60;
}

View File

@ -0,0 +1,65 @@
package club.joylink.rtss.simulation.cbtc.passenger.strategy;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
import club.joylink.rtss.simulation.cbtc.passenger.PassengerFlowSimulateService;
import club.joylink.rtss.simulation.cbtc.passenger.data.PassengerFlowSimulationData;
import club.joylink.rtss.simulation.cbtc.passenger.data.StandPassengerFlow;
import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.StrategyCalculateData;
import club.joylink.rtss.websocket.StompMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Component
public class LargePassengerFlowStrategyService {
@Autowired
private PassengerFlowSimulateService passengerFlowSimulateService;
@Autowired
private StompMessageService stompMessageService;
@Scheduled(fixedRate = 300*1000)
public void checkLpf() {
List<PassengerFlowSimulationData> pfSimulationList = this.passengerFlowSimulateService.getPassengerFlowSimulations();
if (CollectionUtils.isEmpty(pfSimulationList)) {
return;
}
for (PassengerFlowSimulationData passengerFlowSimulationData : pfSimulationList) {
// 查询大客流站台
List<StandPassengerFlow> standPassengerFlowList = passengerFlowSimulationData.getAllStandPassengerFlow();
List<StandPassengerFlow> lpfList = new ArrayList<>();
for (StandPassengerFlow standPassengerFlow : standPassengerFlowList) {
if (standPassengerFlow.getPassengerQuantity() > Config.STAND_LPF_TRIGGER) {
lpfList.add(standPassengerFlow);
}
}
if (!lpfList.isEmpty()) {
// 发现大客流计算策略
StrategyCalculateData strategyCalculateData = this.buildStrategyCalculateData(passengerFlowSimulationData);
}
}
}
private StrategyCalculateData buildStrategyCalculateData(PassengerFlowSimulationData passengerFlowSimulationData) {
Simulation simulation = this.passengerFlowSimulateService.getSimulationByGroup(passengerFlowSimulationData.getGroup());
SimulationDataRepository repository = simulation.getRepository();
Map<String, List<TripPlan>> serviceTripsMap = repository.getServiceTripsMap();
StrategyCalculateData strategyCalculateData = new StrategyCalculateData(
serviceTripsMap,
repository.getRealRunRecordList(),
passengerFlowSimulationData.getAllStandPassengerFlow(),
passengerFlowSimulationData.getAllTrainPassengerFlow()
);
return strategyCalculateData;
}
}

View File

@ -0,0 +1,14 @@
package club.joylink.rtss.simulation.cbtc.passenger.strategy;
import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.Strategy;
import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.StrategyCalculateData;
import org.springframework.stereotype.Component;
@Component
public class ParkTimeStrategyServiceImpl implements StrategyService {
@Override
public Strategy calculate(StrategyCalculateData data) {
return null;
}
}

View File

@ -0,0 +1,10 @@
package club.joylink.rtss.simulation.cbtc.passenger.strategy;
import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.Strategy;
import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.StrategyCalculateData;
public interface StrategyService {
Strategy calculate(StrategyCalculateData data);
}

View File

@ -0,0 +1,14 @@
package club.joylink.rtss.simulation.cbtc.passenger.strategy.data;
public class ParkTimeStrategy extends Strategy {
/** 站台code */
String standCode;
/** 停站时间 */
Integer time;
@Override
public String buildDescription() {
this.description = "";
return null;
}
}

View File

@ -0,0 +1,38 @@
package club.joylink.rtss.simulation.cbtc.passenger.strategy.data;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.passenger.data.StandPassengerFlow;
import club.joylink.rtss.simulation.cbtc.passenger.strategy.Config;
import lombok.Getter;
@Getter
public class StandPassenger {
Stand stand;
/** 是否大客流站 */
boolean lpf;
/**
* 站台等待人数
*/
int wait;
private StandPassenger() {
}
public StandPassenger(StandPassengerFlow standPassengerFlow) {
this.stand = standPassengerFlow.getStand();
this.wait = standPassengerFlow.getPassengerQuantity();
if (this.wait > Config.STAND_LPF_TRIGGER) {
this.lpf = true;
}
}
public StandPassenger clone() {
StandPassenger obj = new StandPassenger();
obj.stand = this.stand;
obj.wait = this.wait;
return obj;
}
}

View File

@ -0,0 +1,29 @@
package club.joylink.rtss.simulation.cbtc.passenger.strategy.data;
import lombok.Getter;
@Getter
public class StationPassenger {
/**
* 车站code
*/
String code;
/**
* 车站等待人数
*/
int wait;
public StationPassenger(String code) {
this.code = code;
}
public StationPassenger(String code, int wait) {
this.code = code;
this.wait = wait;
}
public void addPassenger(int num) {
this.wait += num;
}
}

View File

@ -0,0 +1,15 @@
package club.joylink.rtss.simulation.cbtc.passenger.strategy.data;
public abstract class Strategy {
String description;
/** 指标1时刻表偏差 */
Float target1;
/** 指标2乘客等待时间 */
Float target2;
/** 综合指标对指标12加权求和 */
Float coTarget;
public abstract String buildDescription();
}

View File

@ -0,0 +1,79 @@
package club.joylink.rtss.simulation.cbtc.passenger.strategy.data;
import club.joylink.rtss.simulation.cbtc.data.plan.RealRun;
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
import club.joylink.rtss.simulation.cbtc.passenger.data.StandPassengerFlow;
import club.joylink.rtss.simulation.cbtc.passenger.data.TrainPassengerFlow;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class StrategyCalculateData {
/**
* key-服务号
*/
Map<String, List<TripPlan>> planMap;
/**
* key-服务车次号
*/
Map<String, List<RealRun>> runMap;
Map<String, StandPassenger> standPassengerMap;
List<TrainPassenger> trainPassengerList;
private StrategyCalculateData() {
}
public StrategyCalculateData(Map<String, List<TripPlan>> serviceTripsMap,
List<RealRun> realRunRecordList,
List<StandPassengerFlow> allStandPassengerFlow,
List<TrainPassengerFlow> allTrainPassengerFlow) {
this.planMap = new HashMap<>(serviceTripsMap);
Map<String, List<RealRun>> realRunMap = new HashMap<>();
for (RealRun realRun : realRunRecordList) {
String stNumber = realRun.getSTNumber();
List<RealRun> list = realRunMap.get(stNumber);
if (list == null) {
list = new ArrayList<>();
realRunMap.put(stNumber, list);
}
list.add(realRun);
}
this.runMap = realRunMap;
Map<String, StandPassenger> spMap = new HashMap<>();
for (StandPassengerFlow standPassengerFlow : allStandPassengerFlow) {
StandPassenger standPassenger = new StandPassenger(standPassengerFlow);
spMap.put(standPassenger.getStand().getCode(), standPassenger);
}
this.standPassengerMap = spMap;
List<TrainPassenger> tpList = new ArrayList<>();
for (TrainPassengerFlow trainPassengerFlow : allTrainPassengerFlow) {
TrainPassenger trainPassenger = new TrainPassenger(trainPassengerFlow);
tpList.add(trainPassenger);
}
this.trainPassengerList = tpList;
}
public StrategyCalculateData clone() {
StrategyCalculateData obj = new StrategyCalculateData();
obj.planMap = new HashMap<>(this.planMap);
obj.runMap = new HashMap<>(this.runMap);
Map<String, StandPassenger> standPassengerMap = new HashMap<>();
this.standPassengerMap.forEach((code, standPassenger) -> {
standPassengerMap.put(code, standPassenger.clone());
});
obj.standPassengerMap = standPassengerMap;
List<TrainPassenger> tpList = new ArrayList<>();
for (TrainPassenger trainPassenger : this.trainPassengerList) {
tpList.add(trainPassenger.clone());
}
obj.trainPassengerList = tpList;
return obj;
}
}

View File

@ -0,0 +1,36 @@
package club.joylink.rtss.simulation.cbtc.passenger.strategy.data;
import club.joylink.rtss.simulation.cbtc.passenger.data.TrainPassengerFlow;
import lombok.Getter;
@Getter
public class TrainPassenger {
private String groupNumber;
/** 服务号 */
String serviceNumber;
/** 车次号 */
String tripNumber;
/** 列车上人数 */
int remain;
public TrainPassenger() {
}
public TrainPassenger(TrainPassengerFlow tpf) {
this.groupNumber = tpf.getTrain().getGroupNumber();
this.serviceNumber = tpf.getTrain().getServiceNumber();
this.tripNumber = tpf.getTrain().getTripNumber();
this.remain = tpf.getPassengerQuantity();
}
public TrainPassenger clone() {
TrainPassenger obj = new TrainPassenger();
obj.groupNumber = this.groupNumber;
obj.serviceNumber = this.serviceNumber;
obj.tripNumber = this.tripNumber;
obj.remain = this.remain;
return obj;
}
}