Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
joylink_zhangsai 2021-01-27 19:05:33 +08:00
commit ec71cf4c20
16 changed files with 336 additions and 38 deletions

View File

@ -453,6 +453,12 @@ public class RunPlanDraftService implements IRunPlanDraftService {
List<RunPlanArriveConfigVO> arriveConfigList = tripConfigVO.getArriveConfigList();
arriveConfigList.stream().map(RunPlanTripTimeVO::new).forEach(timeVO -> tripVO.getTimeList().add(timeVO));
if (Objects.equals(tripVO.getEndSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getLast().getSectionCode())) {
tripVO.setEndTime(tripConfigVO.getEndTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME));
}
if (Objects.equals(tripVO.getStartSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getFirst().getSectionCode())) {
tripVO.setStartTime(tripConfigVO.getStartTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME));
}
newTripList.add(tripVO);
}
} else {
@ -753,6 +759,9 @@ public class RunPlanDraftService implements IRunPlanDraftService {
if (Objects.equals(tripVO.getEndSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getLast().getSectionCode())) {
tripVO.setEndTime(tripConfig.getEndTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME));
}
if (Objects.equals(tripVO.getStartSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getFirst().getSectionCode())) {
tripVO.setStartTime(tripConfig.getStartTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME));
}
if (CollectionUtils.isEmpty(runPlanVO.getTripList())) {
runPlanVO.setTripList(new ArrayList<>());

View File

@ -429,7 +429,7 @@ public class RunPlanGenerator {
}
}
private void setTripTerminalTime(RunPlanTripVO runPlanTripVO, LinkedList<RunPlanTripTimeVO> tripTimeList, int reentryTime) {
public void setTripTerminalTime(RunPlanTripVO runPlanTripVO, LinkedList<RunPlanTripTimeVO> tripTimeList, int reentryTime) {
setTripStartTime(runPlanTripVO, tripTimeList, reentryTime);
setTripEndTime(runPlanTripVO, tripTimeList, reentryTime);
}

View File

@ -12,6 +12,7 @@ import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.map.MapVO;
import club.joylink.rtss.vo.client.map.newmap.MapRunLevelQueryVO;
@ -82,7 +83,17 @@ public class RunPlanRunlevelService implements IRunPlanRunlevelService {
list.forEach(l -> {
Section startSection = (Section) deviceMap.get(l.getStartSectionCode());
Section endSection = (Section) deviceMap.get(l.getEndSectionCode());
Float distance = CalculateService.calculateDistance(startSection, endSection, l.getRight());
Float distance;
if((startSection.isStandTrack() && endSection.isTransferTrack()) || (endSection.isStandTrack() && startSection.isTransferTrack())){
try{
distance = CalculateService.calculateDistance(startSection, endSection, l.getRight());
}catch (SimulationException e){
distance = CalculateService.calculateDistance(startSection, endSection, !l.getRight());
}
}else{
distance = CalculateService.calculateDistance(startSection, endSection, l.getRight());
}
RunPlanRunlevel entity = new RunPlanRunlevel();
entity.setId(l.getId());
entity.setMapId(l.getMapId());

View File

@ -157,6 +157,10 @@ public class AtsPlanService {
hold = this.atsStandService.isHoldTrain(target);
}
// 更新跳停状态
if (jump && Objects.equals(tripPlan.getLastStationPlan().getStation(), target.getStation())) {
// 最后一站不跳停
jump = false;
}
if (!Objects.equals(train.isJump(), jump)) {
if (jump) {
this.onboardAtpApiService.setJump(simulation, train.getGroupNumber());
@ -365,7 +369,8 @@ public class AtsPlanService {
}
LocalTime arriveTime = systemTime.plusSeconds(intervalRunTime);
train.updateEstimatedArriveInfo(nextStationPlan.getSection(), arriveTime);
if (this.atsStandService.isJump(nextStationPlan.getSection(), train.getGroupNumber())) {
if (!tripPlan.isLastPlan(nextStationPlan) &&
this.atsStandService.isJump(nextStationPlan.getSection(), train.getGroupNumber())) {
this.onboardAtpApiService.setJump(simulation, train.getGroupNumber());
}
} else {

View File

@ -205,10 +205,15 @@ public class AtsTrainLoadService {
RoutePath routePath = this.selectDefaultRoutePath(repository, stationPlan.getSection(), nextStationPlan.getSection());
right = routePath.isRight();
int t = current.toSecondOfDay() - stationPlan.getLeaveTime().toSecondOfDay();
float s = routePath.getLength();
float s = routePath.getLenFromSection(stationPlan.getSection());
//-最后区段+后右停车点 + 前区段-前右停车点 -左停车点+前左停车点
s= right?
s-nextStationPlan.getSection().getLen()+nextStationPlan.getSection().getStopPointByDirection(right)+stationPlan.getSection().getLen()-stationPlan.getSection().getStopPointByDirection(right)
:
s-nextStationPlan.getSection().getStopPointByDirection(right)+stationPlan.getSection().getStopPointByDirection(right);
int totalTime = nextStationPlan.getArriveTime().toSecondOfDay() - stationPlan.getLeaveTime().toSecondOfDay();
float moveDistance = s / totalTime * t; // 移动的距离
headPosition = routePath.getSectionPositionOfLen(moveDistance);
headPosition = routePath.getSectionPositionOfLen(moveDistance,stationPlan.getSection());
SectionPosition nextTargetPosition = new SectionPosition(nextStationPlan.getSection(),
nextStationPlan.getSection().getStopPointByDirection(right));
if (headPosition.isAheadOf(nextTargetPosition, right)) {
@ -426,6 +431,8 @@ public class AtsTrainLoadService {
trainInfo.updateEstimatedArriveInfo(endStationPlan.getSection(), endStationPlan.getArriveTime());
train.updateNextStationPlan(endStationPlan.getStation(), endStationPlan.getSection(), tripPlan.isPlanParking(endStationPlan));
break;
} else if (passedSectionStopPoint(headPosition, endStationPlan.getSection(), right)) {
continue;
} else {
RoutePath routePath = this.selectDefaultRoutePath(repository, startStationPlan.getSection(), endStationPlan.getSection());
if (routePath.containsSection(headPosition.getSection())) {
@ -454,6 +461,16 @@ public class AtsTrainLoadService {
return false;
}
private boolean passedSectionStopPoint(SectionPosition headPosition, Section funSection, boolean right) {
float d = headPosition.getOffset() - funSection.getStopPointByDirection(right);
if (Objects.equals(headPosition.getSection(), funSection)
&& d > SimulationConstants.PARK_POINT_MAX_OFFSET) {
return true;
}
return false;
}
/**
* 处理碰撞逻辑
* @param simulation

View File

@ -358,6 +358,7 @@ public class RouteService {
if (simulation.getSystemTime().isAfter(route.getSettingStartTime().plusSeconds(10))) {
route.settingFailed();
simulation.getRepository().removeSettingRoute(route);
route.setLock(false);
log.info(String.format("进路[%s]办理失败取消办理2", route.debugStr()));
return;
}

View File

@ -110,36 +110,79 @@ public class RoutePath {
this.end.getStation().getName(), this.end.getName());
}
public SectionPosition getSectionPositionOfLen(float runLen) {
public float getLenFromSection(Section fromSection){
List<Section> list = new ArrayList<>();
if(sectionList.contains(fromSection)){
int i = sectionList.indexOf(fromSection);
list.addAll(sectionList.subList(i,sectionList.size()));
}else{
list.add(start);
list.addAll(this.sectionList);
}
float len = 0;
for (Section section : list) {
if(Objects.equals(section,fromSection)){
continue;
}
len += section.getLen();
}
return len;
}
public SectionPosition getSectionPositionOfLen(float runLen,Section fromSection) {
float remain = runLen;
Section target = null;
Float offset = null;
if (remain < this.length) {
// if (remain < this.length) {
List<Section> list = new ArrayList<>();
if(sectionList.contains(fromSection)){
int i = sectionList.indexOf(fromSection);
list.addAll(sectionList.subList(i,sectionList.size()));
}else{
list.add(start);
list.addAll(this.sectionList);
}
float len = 0;
for (Section section : list) {
len += section.getLen();
}
float addLen;
for (Section section : list) {
float addLen = section.getLen();
if (start == section) {
addLen = right ? section.getLen() - section.getStopPointByDirection(right) : section.getStopPointByDirection(right);
if (runLen < addLen) {
target = section;
offset = right ? section.getStopPointByDirection(right) + remain : section.getStopPointByDirection(right) - remain;
break;
}
}
// else if (this.end == section) {
// addLen = right?section.getStopPointByDirection(right):section.getLen() - section.getStopPointByDirection(right);
// }
else {
addLen = section.getLen();
}
if (remain < addLen) { // 在此区段上
target = section;
if (Objects.equals(this.start, section)) {
if (this.right) {
offset = section.getLen() - (addLen - remain);
} else {
offset = (addLen - remain);
}
} else {
// if (Objects.equals(this.start, section)) {
// if (this.right) {
// offset = section.getLen() - (addLen - remain);
// } else {
// offset = (addLen - remain);
// }
// } else {
if (this.right) {
offset = remain;
} else {
offset = section.getLen() - remain;
offset = addLen - remain;
}
}
// }
break;
} else {
remain -= addLen;
}
}
}
// }
if (Objects.isNull(target) || Objects.isNull(offset)) {
throw new SimulationException(SimulationExceptionType.System_Fault,
String.format("路径[%s]的总距离[%s],未找到距离[%s]对应的区段位置",

View File

@ -164,7 +164,7 @@ public class ATOService {
SectionPosition targetStopPoint = new SectionPosition(target,
target.getStopPointByDirection(right));
Float targetDistance = CalculateService.calculateDistance(headPosition, targetStopPoint, right);
if (Objects.nonNull(targetDistance) && targetDistance < distance) {
if (Objects.nonNull(targetDistance)&& targetDistance >= 0 && targetDistance < distance) {
return targetDistance;
}
} else {

View File

@ -296,7 +296,6 @@ public class PassengerFlowSimulateService {
StandTimePassengerFlowData flowData = standTimePassengerFlowDataMap.get(stand.getCode());
StandTimePassengerFlowData preData = preTimePassengerFlowDataMap.get(stand.getCode());
int add = flowData.getNum() - preData.getNum();
log.debug(String.format("站台[%s]增加乘客: %s", stand.debugStr(), add));
if (add < 0) {
// 列车拉走了站台上的人
if (flowData.getNum() != 0 && preData.getNum() > 1000) {
@ -305,6 +304,7 @@ public class PassengerFlowSimulateService {
add = flowData.getNum();
}
}
log.debug(String.format("站台[%s]增加乘客: %s", stand.debugStr(), add));
int total = standPassengerFlow.plus(add);
sendData.put("standCode", stand.getCode());
sendData.put("num", total);
@ -392,7 +392,7 @@ public class PassengerFlowSimulateService {
// 如果没有数据默认下车5%的人
down = (int) (trainPassengerFlow.getPassengerQuantity() * 0.05);
}
trainPassengerFlow.minus(down);
down = trainPassengerFlow.minus(down);
}
sendData.put("out", down);
// 上车
@ -406,6 +406,7 @@ public class PassengerFlowSimulateService {
}
trainPassengerFlow.plus(up);
sendData.put("in", up);
sendData.put("remain", trainPassengerFlow.getPassengerQuantity());
String json = JsonUtils.writeValueNullableFieldAsString(sendData);
SocketMessageVO<String> message = SocketMessageFactory.build(

View File

@ -24,13 +24,15 @@ public class TrainPassengerFlow {
this.off = false;
}
public void minus(int num) {
public int minus(int num) {
this.off = true;
if (this.passengerQuantity < num) {
num = this.passengerQuantity;
this.passengerQuantity = 0;
} else {
this.passengerQuantity -= num;
}
this.off = true;
return num;
}
public void plus(int up) {

View File

@ -0,0 +1,158 @@
package club.joylink.rtss.simulation.cbtc.passenger.strategy;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.plan.RealRun;
import club.joylink.rtss.simulation.cbtc.data.plan.StationPlan;
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.JumpStrategy;
import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.StandPassenger;
import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.StrategyCalculateData;
import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.TrainPassenger;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.time.LocalTime;
import java.util.*;
@Slf4j
@Component
public class JumpStrategyServiceImpl implements StrategyService<JumpStrategy> {
@Override
public List<JumpStrategy> generateStrategy(StrategyCalculateData data) {
List<JumpStrategy> list = new ArrayList<>();
Stand stand = null;
// 暂时按一个站大客流处理
List<StandPassenger> standPassengerList = data.getAllStandPassengerList();
for (StandPassenger standPassenger : standPassengerList) {
if (standPassenger.isLpf()) {
stand = standPassenger.getStand();
break;
}
}
if (stand == null) {
return null;
}
List<Stand> leftStandList = data.getLeftStandList();
List<Stand> rightStandList = data.getRightStandList();
boolean right = false;
int index = leftStandList.indexOf(stand);
if (index < 0) {
// 不是左向站台
right = true;
index = rightStandList.indexOf(stand);
}
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(index >= 0, String.format("未找到站台[%s]", stand.debugStr()));
log.debug(String.format("生成跳停策略[%s]个", list.size()));
return list;
}
@Override
public void calculate(StrategyCalculateData data, JumpStrategy strategy) {
// 系统时间
LocalTime systemTime = data.getSystemTime().toLocalTime();// 系统当前时间
LocalTime endTime = systemTime.plusMinutes(Config.STRATEGY_CAL_TIME);// 预测计算终点
List<TrainPassenger> trainPassengerList = data.getTrainPassengerList();
Map<String, RealRun> trainPreviousMap = new HashMap<>(); // 列车上一个到站/发车数据
int i = 0;
while (systemTime.isBefore(endTime) && i<1000) { // 在计算时间内
++i;
if (i > 999) {
log.error("死循环--------------------------");
}
LocalTime nextTime = null;
for (TrainPassenger trainPassenger : trainPassengerList) {
String groupNumber = trainPassenger.getGroupNumber();
TripPlan tripPlan = data.queryTripPlan(trainPassenger.getServiceNumber(), trainPassenger.getTripNumber());
if (tripPlan == null) { // 未找到计划跳过
log.warn(String.format("列车[%s-%s|%s]没有找到车次计划",
groupNumber, trainPassenger.getServiceNumber(), trainPassenger.getTripNumber()));
continue;
}
if (tripPlan.isBackup()) {
continue;
}
// 上一实际到发
RealRun realRun = trainPreviousMap.get(groupNumber);
if (realRun == null) {
realRun = data.queryPreviousRealRunData(groupNumber);
if (realRun != null) {
trainPreviousMap.put(groupNumber, realRun);
}
}
List<StationPlan> planList = tripPlan.getPlanList();
int offsetTime = 0;
StationPlan nextStationPlan = null;
if (realRun != null &&
Objects.equals(tripPlan.getServiceNumber(), realRun.getServiceNumber()) &&
Objects.equals(tripPlan.getTripNumber(), realRun.getTripNumber())) {
// 上一实际运行数据存在且在当前计划中
// 查询实际运行到的车站计划
StationPlan stationPlan = tripPlan.queryStationPlanByStationCode(realRun.getStationCode());
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(stationPlan);
LocalTime leaveTime = stationPlan.getLeaveTime();
if (realRun.isArrive()) {
// 是到达车站的计划预测离站
LocalTime arriveTime = stationPlan.getArriveTime();
if (!tripPlan.isFirstPlan(stationPlan)) {
offsetTime = realRun.getTime().toLocalTime().toSecondOfDay() - arriveTime.toSecondOfDay();
}
RealRun leave = this.handleTrainLeave(data, strategy, trainPassenger, tripPlan, stationPlan, offsetTime);
trainPreviousMap.put(groupNumber, leave);
} else {
offsetTime = realRun.getTime().toLocalTime().toSecondOfDay() - leaveTime.toSecondOfDay();
}
if (tripPlan.isLastPlan(stationPlan)) {
// 最后一个到发计划获取下一个折返后车次计划
TripPlan nextTripPlan = data.queryNextTripPlan(tripPlan);
if (nextTripPlan != null) {
tripPlan = nextTripPlan;
nextStationPlan = nextTripPlan.getFirstStationPlan();
}
} else {
nextStationPlan = tripPlan.queryNextStationPlanByStationCode(realRun.getStationCode());
}
} else {
for (StationPlan stationPlan : planList) {
if (stationPlan.getArriveTime().compareTo(systemTime) >= 0) {
nextStationPlan = stationPlan;
break;
}
}
}
if (nextStationPlan != null) {
LocalTime arriveTime = nextStationPlan.getArriveTime();
RealRun arrive = this.buildRealRun(groupNumber, tripPlan, nextStationPlan, true, arriveTime, offsetTime, data.getSystemTime());
data.addRealRun(arrive);
RealRun leave = this.handleTrainLeave(data, strategy, trainPassenger, tripPlan, nextStationPlan, offsetTime);
data.addRealRun(leave);
trainPreviousMap.put(groupNumber, leave);
if (nextTime == null || leave.getTime().toLocalTime().isBefore(nextTime)) {
nextTime = leave.getTime().toLocalTime();
}
}
}
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(nextTime);
systemTime = nextTime;
}
strategy.setCoTarget(strategy.getTarget1()*strategy.getW1()+strategy.getTarget2()*strategy.getW2());
}
private RealRun handleTrainLeave(StrategyCalculateData data, JumpStrategy strategy, TrainPassenger trainPassenger,
TripPlan tripPlan, StationPlan stationPlan, int offsetTime) {
Stand stand = strategy.getStand();
LocalTime arriveTime = stationPlan.getArriveTime();
LocalTime leaveTime = stationPlan.getLeaveTime();
// 生成预测实际运行图
RealRun leave = this.buildRealRun(trainPassenger.getGroupNumber(), tripPlan, stationPlan, false, leaveTime, offsetTime, data.getSystemTime());
data.addRealRun(leave);
// 大客流站计算指标
if (Objects.equals(stationPlan.getSection(), stand.getSection())) {
}
return leave;
}
}

View File

@ -58,6 +58,7 @@ public class LargePassengerFlowStrategyService {
for (ParkTimeStrategy parkTimeStrategy : parkTimeStrategies) {
this.parkTimeStrategyService.calculate(strategyCalculateData.clone(), parkTimeStrategy);
parkTimeStrategy.buildDescription();
parkTimeStrategy.handleTarget();
log.info(String.format("停站时间策略[%s]计算指标为:%s", parkTimeStrategy.getDescription(),
parkTimeStrategy.targetDebugStr()));
}

View File

@ -79,15 +79,6 @@ public class ParkTimeStrategyServiceImpl implements StrategyService<ParkTimeStra
LocalTime nextTime = null;
for (TrainPassenger trainPassenger : trainPassengerList) {
String groupNumber = trainPassenger.getGroupNumber();
TripPlan tripPlan = data.queryTripPlan(trainPassenger.getServiceNumber(), trainPassenger.getTripNumber());
if (tripPlan == null) { // 未找到计划跳过
log.warn(String.format("列车[%s-%s|%s]没有找到车次计划",
groupNumber, trainPassenger.getServiceNumber(), trainPassenger.getTripNumber()));
continue;
}
if (tripPlan.isBackup()) {
continue;
}
// 上一实际到发
RealRun realRun = trainPreviousMap.get(groupNumber);
if (realRun == null) {
@ -96,6 +87,20 @@ public class ParkTimeStrategyServiceImpl implements StrategyService<ParkTimeStra
trainPreviousMap.put(groupNumber, realRun);
}
}
TripPlan tripPlan;
if (realRun != null) {
tripPlan = data.queryTripPlan(realRun.getServiceNumber(), realRun.getTripNumber());
} else {
tripPlan = data.queryTripPlan(trainPassenger.getServiceNumber(), trainPassenger.getTripNumber());
}
if (tripPlan == null) { // 未找到计划跳过
log.warn(String.format("列车[%s-%s|%s]没有找到车次计划",
groupNumber, trainPassenger.getServiceNumber(), trainPassenger.getTripNumber()));
continue;
}
if (tripPlan.isBackup()) {
continue;
}
List<StationPlan> planList = tripPlan.getPlanList();
int offsetTime = 0;
StationPlan nextStationPlan = null;
@ -114,7 +119,6 @@ public class ParkTimeStrategyServiceImpl implements StrategyService<ParkTimeStra
offsetTime = realRun.getTime().toLocalTime().toSecondOfDay() - arriveTime.toSecondOfDay();
}
RealRun leave = this.handleTrainLeave(data, strategy, trainPassenger, tripPlan, stationPlan, offsetTime);
trainPreviousMap.put(groupNumber, leave);
} else {
offsetTime = realRun.getTime().toLocalTime().toSecondOfDay() - leaveTime.toSecondOfDay();
@ -152,7 +156,6 @@ public class ParkTimeStrategyServiceImpl implements StrategyService<ParkTimeStra
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(nextTime);
systemTime = nextTime;
}
strategy.setCoTarget(strategy.getTarget1()*strategy.getW1()+strategy.getTarget2()*strategy.getW2());
}
private RealRun handleTrainLeave(StrategyCalculateData data, ParkTimeStrategy strategy, TrainPassenger trainPassenger,
@ -169,9 +172,6 @@ public class ParkTimeStrategyServiceImpl implements StrategyService<ParkTimeStra
float min = Math.min(Math.min(wait, predict), remain); // 实际上车人数
standPassenger.minus(min);
trainPassenger.plus(min);
// 生成预测实际运行图
RealRun leave = this.buildRealRun(trainPassenger.getGroupNumber(), tripPlan, stationPlan, false, leaveTime, offsetTime, data.getSystemTime());
data.addRealRun(leave);
// 大客流站计算指标
if (Objects.equals(stationPlan.getSection(), stand.getSection())) {
// 时刻表偏差
@ -181,6 +181,9 @@ public class ParkTimeStrategyServiceImpl implements StrategyService<ParkTimeStra
// 乘客等待时间(按人数统计不考虑时间)
strategy.addTarget2(standPassenger.getWait());
}
// 生成预测实际运行图
RealRun leave = this.buildRealRun(trainPassenger.getGroupNumber(), tripPlan, stationPlan, false, leaveTime, offsetTime, data.getSystemTime());
data.addRealRun(leave);
return leave;
}
}

View File

@ -0,0 +1,22 @@
package club.joylink.rtss.simulation.cbtc.passenger.strategy.data;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import lombok.Getter;
@Getter
public class JumpStrategy extends Strategy {
/**
* 站台
*/
Stand stand;
public JumpStrategy(Stand stand) {
this.stand = stand;
}
@Override
public String buildDescription() {
this.description = String.format("站台%s设置跳停", stand.debugStr());
return this.description;
}
}

View File

@ -47,4 +47,8 @@ public abstract class Strategy {
public String targetDebugStr() {
return String.format("指标1-时刻表偏差为:[%s],指标2-等待乘客数为:[%s],综合指标为:[%s]",this.target1, this.target2, this.coTarget);
}
}
public void handleTarget() {
this.coTarget = this.target1 * this.w1 + this.target2 * this.w2;
}
}

View File

@ -30,6 +30,10 @@ public class StrategyCalculateData {
Map<String, StandPassenger> standPassengerMap = new ConcurrentHashMap<>();
List<Stand> leftStandList;
List<Stand> rightStandList;
List<TrainPassenger> trainPassengerList;
private StrategyCalculateData() {
@ -56,6 +60,21 @@ public class StrategyCalculateData {
StandPassenger standPassenger = new StandPassenger(standPassengerFlow);
this.standPassengerMap.put(standPassenger.getStand().getCode(), standPassenger);
}
List<Stand> leftList = new ArrayList<>();
List<Stand> rightList = new ArrayList<>();
for (StandPassengerFlow standPassengerFlow : allStandPassengerFlow) {
Stand stand = standPassengerFlow.getStand();
if (stand.isRight()) {
rightList.add(stand);
} else {
leftList.add(stand);
}
}
leftList.sort(Comparator.comparing((stand) -> stand.getStation().getSn()));
rightList.sort(Comparator.comparing((stand) -> stand.getStation().getSn()));
Collections.reverse(leftList);
this.leftStandList = leftList;
this.rightStandList = rightList;
List<TrainPassenger> tpList = new ArrayList<>();
for (TrainPassengerFlow trainPassengerFlow : allTrainPassengerFlow) {
if (!StringUtils.hasText(trainPassengerFlow.getTrain().getServiceNumber())) {
@ -85,6 +104,8 @@ public class StrategyCalculateData {
standPassengerMap.put(code, standPassenger.clone());
});
obj.standPassengerMap = standPassengerMap;
obj.leftStandList = this.leftStandList;
obj.rightStandList = this.rightStandList;
List<TrainPassenger> tpList = new ArrayList<>();
for (TrainPassenger trainPassenger : this.trainPassengerList) {
tpList.add(trainPassenger.clone());