Commit cbaabc92 authored by hanbing's avatar hanbing

[update] 运行评价-干线详细指标查询增加绿灯空放时长

parent 7e81b999
...@@ -123,7 +123,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -123,7 +123,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
} }
@Override @Override
public List<MainlineEvaluateBottomCurveVO> bottomCurve(BottomCurveBO bo) throws Exception { public List<MainlineEvaluateBottomCurveVO> bottomCurve(BottomCurveBO bo) {
String crossId = bo.getCrossId(); String crossId = bo.getCrossId();
Integer scope = bo.getScope(); Integer scope = bo.getScope();
List<String> scopeList = bo.getScopeList(); List<String> scopeList = bo.getScopeList();
...@@ -133,6 +133,15 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -133,6 +133,15 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
Date startTime = bo.getStartTime(); Date startTime = bo.getStartTime();
Date endTime = bo.getEndTime(); Date endTime = bo.getEndTime();
// 从 Kafka 查询绿灯空放时长
KafkaConsumerUtil kafkaConsumerUtil = new KafkaConsumerUtil(bootstrapServers, "bottom-curve-empty-phase");
List<PhaseEmptyResult> phaseEmptyResults =
kafkaConsumerUtil.consumeEmptyPhaseForTimeRange(
emptyPhaseTopic, 0, startTime.getTime(), endTime.getTime());
List<PhaseEmptyResult> crossEmptyPhaseList = phaseEmptyResults.stream()
.filter(p -> crossId.equals(p.getCrossId()))
.collect(Collectors.toList());
String metricCode = StrategyAndMetricsEnum.Metrics.getCodeByName(metricName); String metricCode = StrategyAndMetricsEnum.Metrics.getCodeByName(metricName);
if (scope != 1 && Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.LOAD_BALANCE.getCode())) { if (scope != 1 && Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.LOAD_BALANCE.getCode())) {
throw new RuntimeException("只有路口级别可选择负载均衡度"); throw new RuntimeException("只有路口级别可选择负载均衡度");
...@@ -147,8 +156,24 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -147,8 +156,24 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
if (scope == 0) { // 路口 if (scope == 0) { // 路口
// 查询路口该时段内的所有数据 // 查询路口该时段内的所有数据
List<CrossDataHistPO> crossPOList = crossDataHistMapper.selectByCrossIdAndStartEnd( List<CrossDataHistPOExt> crossPOList = crossDataHistMapper.selectExtByCrossIdAndStartEnd(
crossId, startTimeStamp, endTimeStamp); crossId, startTimeStamp, endTimeStamp);
// 填充相位空放时长
for (CrossDataHistPOExt po : crossPOList) {
// 计算结束时间
Date endTime2 = new Date(po.getStartTime().getTime() + 5 * 60 * 1000); // 增加5分钟
// 遍历每个 PhaseEmptyResult 来查找和累加 duration
for (PhaseEmptyResult phaseEmptyResult : crossEmptyPhaseList) {
if (phaseEmptyResult.getDetectTime() * 1000 >= po.getStartTime().getTime()
&& phaseEmptyResult.getDetectTime() * 1000 <= endTime2.getTime()) {
// 累加 duration
po.setEmptyPhase(po.getEmptyPhase() + phaseEmptyResult.getDuration());
}
}
}
for (String timeStr : timeList) { for (String timeStr : timeList) {
// 解析 timeStr 为 Calendar 对象 // 解析 timeStr 为 Calendar 对象
String[] timeParts = timeStr.split(":"); String[] timeParts = timeStr.split(":");
...@@ -166,7 +191,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -166,7 +191,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
endTimeCal.add(Calendar.MINUTE, minutesSpan); endTimeCal.add(Calendar.MINUTE, minutesSpan);
// 过滤 crossPOList 中的记录 // 过滤 crossPOList 中的记录
List<CrossDataHistPO> filteredList = crossPOList.stream() List<CrossDataHistPOExt> filteredList = crossPOList.stream()
.filter(crossPO -> { .filter(crossPO -> {
// 将 batchTime 转换为小时和分钟 // 将 batchTime 转换为小时和分钟
Calendar batchTimeCal = Calendar.getInstance(); Calendar batchTimeCal = Calendar.getInstance();
...@@ -184,67 +209,80 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -184,67 +209,80 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.NO_STOP_RATE.getCode())) { if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.NO_STOP_RATE.getCode())) {
double v = filteredList.stream() double v = filteredList.stream()
.mapToDouble(CrossDataHistPO::getNoStopRate) .mapToDouble(CrossDataHistPOExt::getNoStopRate)
.average() .average()
.orElse(0.0); .orElse(0.0);
int round = (int) (Math.round(v * 100)); int round = (int) (Math.round(v * 100));
vo.setValue(round); vo.setValue(round);
} else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.STOP_RATE.getCode())) { } else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.STOP_RATE.getCode())) {
double v = filteredList.stream() double v = filteredList.stream()
.mapToDouble(CrossDataHistPO::getOneStopRate) .mapToDouble(CrossDataHistPOExt::getOneStopRate)
.average() .average()
.orElse(0.0); .orElse(0.0);
int round = (int) (Math.round(v * 100)); int round = (int) (Math.round(v * 100));
vo.setValue(round); vo.setValue(round);
} else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.AVERAGE_DELAY.getCode())) { } else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.AVERAGE_DELAY.getCode())) {
double v = filteredList.stream() double v = filteredList.stream()
.mapToInt(CrossDataHistPO::getDelayTime) .mapToInt(CrossDataHistPOExt::getDelayTime)
.average() .average()
.orElse(0.0); .orElse(0.0);
int round = (int) (Math.round(v)); int round = (int) (Math.round(v));
vo.setValue(round); vo.setValue(round);
} else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.MAX_QUEUE_LENGTH.getCode())) { } else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.MAX_QUEUE_LENGTH.getCode())) {
double v = filteredList.stream() double v = filteredList.stream()
.mapToDouble(CrossDataHistPO::getQueueLength) .mapToDouble(CrossDataHistPOExt::getQueueLength)
.max() .max()
.orElse(0.0); .orElse(0.0);
int round = (int) (Math.round(v)); int round = (int) (Math.round(v));
vo.setValue(round); vo.setValue(round);
} else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.STOP_TIMES.getCode())) { } else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.STOP_TIMES.getCode())) {
double v = filteredList.stream() double v = filteredList.stream()
.mapToDouble(CrossDataHistPO::getStopTimes) .mapToDouble(CrossDataHistPOExt::getStopTimes)
.average() .average()
.orElse(0.0); .orElse(0.0);
int round = (int) (Math.round(v)); int round = (int) (Math.round(v));
vo.setValue(round); vo.setValue(round);
} else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.AVERAGE_SPEED.getCode())) { } else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.AVERAGE_SPEED.getCode())) {
double v = filteredList.stream() double v = filteredList.stream()
.mapToDouble(CrossDataHistPO::getSpeed) .mapToDouble(CrossDataHistPOExt::getSpeed)
.average() .average()
.orElse(0.0); .orElse(0.0);
int round = (int) (Math.round(v)); int round = (int) (Math.round(v));
vo.setValue(round); vo.setValue(round);
} else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getCode())) { } else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getCode())) {
double v = filteredList.stream() double v = filteredList.stream()
.mapToDouble(CrossDataHistPO::getGreenLightEfficiency) .mapToDouble(CrossDataHistPOExt::getGreenLightEfficiency)
.average() .average()
.orElse(0.0); .orElse(0.0);
int round = (int) (Math.round(v * 100)); int round = (int) (Math.round(v * 100));
vo.setValue(round); vo.setValue(round);
} else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.SATURATION.getCode())) { } else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.SATURATION.getCode())) {
double v = filteredList.stream() double v = filteredList.stream()
.mapToDouble(CrossDataHistPO::getSturation) .mapToDouble(CrossDataHistPOExt::getSturation)
.average() .average()
.orElse(0.0); .orElse(0.0);
int round = (int) (Math.round(v * 100)); int round = (int) (Math.round(v * 100));
vo.setValue(round); vo.setValue(round);
} else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.LOAD_BALANCE.getCode())) { } else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.LOAD_BALANCE.getCode())) {
double v = filteredList.stream() double v = filteredList.stream()
.mapToDouble(CrossDataHistPO::getLoadBalance) .mapToDouble(CrossDataHistPOExt::getLoadBalance)
.average() .average()
.orElse(0.0); .orElse(0.0);
int round = (int) (Math.round(v)); int round = (int) (Math.round(v));
vo.setValue(round); vo.setValue(round);
} else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.EFFUSION_RATE.getCode())) {
double v = filteredList.stream()
.mapToDouble(CrossDataHistPOExt::getEffusionRate)
.average()
.orElse(0.0);
int round = (int) (Math.round(v * 100));
vo.setValue(round);
} else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.EMPTY_PHASE.getCode())) {
double v = filteredList.stream()
.mapToDouble(CrossDataHistPOExt::getEmptyPhase)
.sum();
int round = (int) (Math.round(v));
vo.setValue(round);
} }
res.add(vo); res.add(vo);
...@@ -884,7 +922,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -884,7 +922,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
String boStartDayStr = dayFormat.format(startDate); String boStartDayStr = dayFormat.format(startDate);
String boEndDayStr = dayFormat.format(endDate); String boEndDayStr = dayFormat.format(endDate);
List<CrossDirDataHistPO> crossDirDataHistPOList = crossDirDataHistMapper.selectByTimeSection( List<CrossDirDataHistPOExt> crossDirDataHistPOList = crossDirDataHistMapper.selectExtByTimeSection(
boStartDayStr, boEndDayStr, startHourMinute, endHourMinute); boStartDayStr, boEndDayStr, startHourMinute, endHourMinute);
List<BaseCrossDirInfoPO> baseCrossDirInfoPOList = List<BaseCrossDirInfoPO> baseCrossDirInfoPOList =
...@@ -959,7 +997,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -959,7 +997,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
private List<String> buildCrossEvaluateList( private List<String> buildCrossEvaluateList(
String crossId, List<BaseCrossDirInfoPO> baseCrossDirInfoPOList, String crossId, List<BaseCrossDirInfoPO> baseCrossDirInfoPOList,
List<CrossDirDataHistPO> crossDirDataHistPOList) { List<CrossDirDataHistPOExt> crossDirDataHistPOList) {
List<String> res = new ArrayList<>(); List<String> res = new ArrayList<>();
...@@ -973,18 +1011,18 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -973,18 +1011,18 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
for (Integer dirCode : dirCodeList) { for (Integer dirCode : dirCodeList) {
List<CrossDirDataHistPO> filteredList = crossDirDataHistPOList.stream() List<CrossDirDataHistPOExt> filteredList = crossDirDataHistPOList.stream()
.filter(item -> crossId.equals(item.getCrossId())) .filter(item -> crossId.equals(item.getCrossId()))
.filter(item -> 1 == item.getInOutType()) .filter(item -> 1 == item.getInOutType())
.filter(item -> dirCode.equals(item.getDirType())) .filter(item -> dirCode.equals(item.getDirType()))
.collect(Collectors.toList()); .collect(Collectors.toList());
Integer maxDelayTime = filteredList.stream() Integer maxDelayTime = filteredList.stream()
.map(CrossDirDataHistPO::getDelayTime) .map(CrossDirDataHistPOExt::getDelayTime)
.max(Integer::compareTo) .max(Integer::compareTo)
.orElse(0); .orElse(0);
Double maxQueueLength = filteredList.stream() Double maxQueueLength = filteredList.stream()
.mapToDouble(CrossDirDataHistPO::getQueueLength) .mapToDouble(CrossDirDataHistPOExt::getQueueLength)
.max() .max()
.orElse(0.0); .orElse(0.0);
...@@ -1005,7 +1043,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -1005,7 +1043,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
private List<MainlineCrossEvaluateVO.DirElement> buildDirElementList( private List<MainlineCrossEvaluateVO.DirElement> buildDirElementList(
String crossId, String metricName, List<BaseCrossDirInfoPO> baseCrossDirInfoPOList, String crossId, String metricName, List<BaseCrossDirInfoPO> baseCrossDirInfoPOList,
List<CrossDirDataHistPO> crossDirDataHistPOList, List<PhaseEmptyResult> crossEmptyPhaseList) { List<CrossDirDataHistPOExt> crossDirDataHistPOList, List<PhaseEmptyResult> crossEmptyPhaseList) {
// 获取路口所有方向 // 获取路口所有方向
List<BaseCrossDirInfoPO> collect = baseCrossDirInfoPOList.stream() List<BaseCrossDirInfoPO> collect = baseCrossDirInfoPOList.stream()
...@@ -1020,7 +1058,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -1020,7 +1058,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
MainlineCrossEvaluateVO.DirElement dirElement = new MainlineCrossEvaluateVO.DirElement(); MainlineCrossEvaluateVO.DirElement dirElement = new MainlineCrossEvaluateVO.DirElement();
dirElement.setDir(dirCode); dirElement.setDir(dirCode);
List<CrossDirDataHistPO> filteredList = crossDirDataHistPOList.stream() List<CrossDirDataHistPOExt> filteredList = crossDirDataHistPOList.stream()
.filter(item -> crossId.equals(item.getCrossId())) .filter(item -> crossId.equals(item.getCrossId()))
.filter(item -> 1 == item.getInOutType()) .filter(item -> 1 == item.getInOutType())
.filter(item -> dirCode.equals(item.getDirType())) .filter(item -> dirCode.equals(item.getDirType()))
...@@ -1037,47 +1075,47 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -1037,47 +1075,47 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
return res; return res;
} }
private Integer calcDirValue(String metricName, List<CrossDirDataHistPO> crossDirDataHistPOList, private Integer calcDirValue(String metricName, List<CrossDirDataHistPOExt> crossDirDataHistPOList,
List<PhaseEmptyResult> dirPhaseEmptyList) { List<PhaseEmptyResult> dirPhaseEmptyList) {
int dirValue = 0; int dirValue = 0;
if (Objects.equals(metricName, StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getDescription())) { if (Objects.equals(metricName, StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getDescription())) {
double average = crossDirDataHistPOList.stream() double average = crossDirDataHistPOList.stream()
.mapToDouble(CrossDirDataHistPO::getGreenLightEfficiency) .mapToDouble(CrossDirDataHistPOExt::getGreenLightEfficiency)
.average() .average()
.orElse(0.0); .orElse(0.0);
dirValue = (int) Math.round(average * 100); dirValue = (int) Math.round(average * 100);
} else if (Objects.equals(metricName, StrategyAndMetricsEnum.Metrics.STOP_TIMES.getDescription())) { } else if (Objects.equals(metricName, StrategyAndMetricsEnum.Metrics.STOP_TIMES.getDescription())) {
double average = crossDirDataHistPOList.stream() double average = crossDirDataHistPOList.stream()
.mapToDouble(CrossDirDataHistPO::getStopTimes) .mapToDouble(CrossDirDataHistPOExt::getStopTimes)
.average() .average()
.orElse(0.0); .orElse(0.0);
dirValue = (int) Math.round(average); dirValue = (int) Math.round(average);
} else if (Objects.equals(metricName, StrategyAndMetricsEnum.Metrics.AVERAGE_DELAY.getDescription())) { } else if (Objects.equals(metricName, StrategyAndMetricsEnum.Metrics.AVERAGE_DELAY.getDescription())) {
double average = crossDirDataHistPOList.stream() double average = crossDirDataHistPOList.stream()
.mapToDouble(CrossDirDataHistPO::getDelayTime) .mapToDouble(CrossDirDataHistPOExt::getDelayTime)
.average() .average()
.orElse(0.0); .orElse(0.0);
dirValue = (int) Math.round(average); dirValue = (int) Math.round(average);
} else if (Objects.equals(metricName, StrategyAndMetricsEnum.Metrics.AVERAGE_SPEED.getDescription())) { } else if (Objects.equals(metricName, StrategyAndMetricsEnum.Metrics.AVERAGE_SPEED.getDescription())) {
double average = crossDirDataHistPOList.stream() double average = crossDirDataHistPOList.stream()
.mapToDouble(CrossDirDataHistPO::getSpeed) .mapToDouble(CrossDirDataHistPOExt::getSpeed)
.average() .average()
.orElse(0.0); .orElse(0.0);
dirValue = (int) Math.round(average); dirValue = (int) Math.round(average);
} else if (Objects.equals(metricName, StrategyAndMetricsEnum.Metrics.MAX_QUEUE_LENGTH.getDescription())) { } else if (Objects.equals(metricName, StrategyAndMetricsEnum.Metrics.MAX_QUEUE_LENGTH.getDescription())) {
double max = crossDirDataHistPOList.stream() double max = crossDirDataHistPOList.stream()
.mapToDouble(CrossDirDataHistPO::getQueueLength) .mapToDouble(CrossDirDataHistPOExt::getQueueLength)
.max() .max()
.orElse(0.0); .orElse(0.0);
dirValue = (int) Math.round(max); dirValue = (int) Math.round(max);
} else if (Objects.equals(metricName, StrategyAndMetricsEnum.Metrics.EFFUSION_RATE.getDescription())) { } else if (Objects.equals(metricName, StrategyAndMetricsEnum.Metrics.EFFUSION_RATE.getDescription())) {
double average = crossDirDataHistPOList.stream() double average = crossDirDataHistPOList.stream()
.mapToDouble(CrossDirDataHistPO::getEffusionRate) .mapToDouble(CrossDirDataHistPOExt::getEffusionRate)
.average() .average()
.orElse(0.0); .orElse(0.0);
dirValue = (int) Math.round(average * 100); dirValue = (int) Math.round(average * 100);
} else if (Objects.equals(metricName, StrategyAndMetricsEnum.Metrics.EMPTY_PHASE.getDescription())) { } else if (Objects.equals(metricName, StrategyAndMetricsEnum.Metrics.EMPTY_PHASE.getDescription())) {
for (CrossDirDataHistPO po : crossDirDataHistPOList) { for (CrossDirDataHistPOExt po : crossDirDataHistPOList) {
// 计算结束时间 // 计算结束时间
Date endTime = new Date(po.getStartTime().getTime() + 5 * 60 * 1000); // 增加5分钟 Date endTime = new Date(po.getStartTime().getTime() + 5 * 60 * 1000); // 增加5分钟
...@@ -1091,7 +1129,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -1091,7 +1129,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
} }
} }
double sum = crossDirDataHistPOList.stream() double sum = crossDirDataHistPOList.stream()
.mapToDouble(CrossDirDataHistPO::getEmptyPhase) .mapToDouble(CrossDirDataHistPOExt::getEmptyPhase)
.sum(); .sum();
dirValue = (int) Math.round(sum); dirValue = (int) Math.round(sum);
} }
...@@ -1099,7 +1137,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -1099,7 +1137,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
} }
private Integer calcNonCoordValue( private Integer calcNonCoordValue(
List<Integer> coordDirCodeList, String crossId, List<CrossDirDataHistPO> crossDirDataHistPOList, List<Integer> coordDirCodeList, String crossId, List<CrossDirDataHistPOExt> crossDirDataHistPOList,
List<BaseCrossDirInfoPO> baseCrossDirInfoPOList) { List<BaseCrossDirInfoPO> baseCrossDirInfoPOList) {
// 筛选非协调方向 // 筛选非协调方向
...@@ -1112,7 +1150,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -1112,7 +1150,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
nonCoordDirCodeList.removeAll(coordDirCodeList); nonCoordDirCodeList.removeAll(coordDirCodeList);
// 查询时段内路口非协调方向数据 // 查询时段内路口非协调方向数据
List<CrossDirDataHistPO> filteredList = crossDirDataHistPOList.stream() List<CrossDirDataHistPOExt> filteredList = crossDirDataHistPOList.stream()
.filter(item -> crossId.equals(item.getCrossId())) .filter(item -> crossId.equals(item.getCrossId()))
.filter(item -> 1 == item.getInOutType()) .filter(item -> 1 == item.getInOutType())
.filter(item -> nonCoordDirCodeList.contains(item.getDirType())) .filter(item -> nonCoordDirCodeList.contains(item.getDirType()))
...@@ -1120,7 +1158,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -1120,7 +1158,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
// 计算非协调方向指标(排队长度) // 计算非协调方向指标(排队长度)
double nonCoordValueDouble = (filteredList.stream() double nonCoordValueDouble = (filteredList.stream()
.mapToDouble(CrossDirDataHistPO::getQueueLength) .mapToDouble(CrossDirDataHistPOExt::getQueueLength)
.max() .max()
.orElse(0.0)); .orElse(0.0));
int nonCoordValue = (int) Math.round(nonCoordValueDouble); int nonCoordValue = (int) Math.round(nonCoordValueDouble);
...@@ -1129,10 +1167,10 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -1129,10 +1167,10 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
} }
private Integer calcCoordValue( private Integer calcCoordValue(
List<Integer> coordDirCodeList, String crossId, List<CrossDirDataHistPO> crossDirDataHistPOList) { List<Integer> coordDirCodeList, String crossId, List<CrossDirDataHistPOExt> crossDirDataHistPOList) {
// 查询时段内路口协调方向数据 // 查询时段内路口协调方向数据
List<CrossDirDataHistPO> filteredList = crossDirDataHistPOList.stream() List<CrossDirDataHistPOExt> filteredList = crossDirDataHistPOList.stream()
.filter(item -> crossId.equals(item.getCrossId())) .filter(item -> crossId.equals(item.getCrossId()))
.filter(item -> 1 == item.getInOutType()) .filter(item -> 1 == item.getInOutType())
.filter(item -> coordDirCodeList.contains(item.getDirType())) .filter(item -> coordDirCodeList.contains(item.getDirType()))
...@@ -1140,7 +1178,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -1140,7 +1178,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
// 计算协调方向指标(不停车通过率) // 计算协调方向指标(不停车通过率)
double coordValueDouble = (filteredList.stream() double coordValueDouble = (filteredList.stream()
.mapToDouble(CrossDirDataHistPO::getNoStopRate) .mapToDouble(CrossDirDataHistPOExt::getNoStopRate)
.average() .average()
.orElse(0.0) * 100); .orElse(0.0) * 100);
int coordValue = (int) Math.round(coordValueDouble); int coordValue = (int) Math.round(coordValueDouble);
......
...@@ -4,6 +4,7 @@ package net.wanji.databus.dao.mapper; ...@@ -4,6 +4,7 @@ package net.wanji.databus.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.databus.dto.MetricHistDTO; import net.wanji.databus.dto.MetricHistDTO;
import net.wanji.databus.po.CrossDataHistPO; import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.databus.po.CrossDataHistPOExt;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -31,4 +32,5 @@ public interface CrossDataHistMapper extends BaseMapper<CrossDataHistPO> { ...@@ -31,4 +32,5 @@ public interface CrossDataHistMapper extends BaseMapper<CrossDataHistPO> {
List<CrossDataHistPO> selectByStartEnd(int startStamp, int endStamp); List<CrossDataHistPO> selectByStartEnd(int startStamp, int endStamp);
List<CrossDataHistPOExt> selectExtByCrossIdAndStartEnd(String crossId, int startStamp, int endStamp);
} }
...@@ -73,4 +73,6 @@ public interface CrossDirDataHistMapper extends BaseMapper<CrossDirDataHistPO> { ...@@ -73,4 +73,6 @@ public interface CrossDirDataHistMapper extends BaseMapper<CrossDirDataHistPO> {
); );
List<CrossDirDataHistPO> selectByTimeSection(String boStartDayStr, String boEndDayStr, String startHourMinuteStr, String endHourMinuteStr); List<CrossDirDataHistPO> selectByTimeSection(String boStartDayStr, String boEndDayStr, String startHourMinuteStr, String endHourMinuteStr);
List<CrossDirDataHistPOExt> selectExtByTimeSection(String boStartDayStr, String boEndDayStr, String startHourMinuteStr, String endHourMinuteStr);
} }
...@@ -2,13 +2,17 @@ package net.wanji.databus.po; ...@@ -2,13 +2,17 @@ package net.wanji.databus.po;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
/** /**
* @author duanruiming * @author duanruiming
* @date 2023/03/12 20:49 * @date 2023/03/12 20:49
*/ */
@EqualsAndHashCode(callSuper = true)
@Data @Data
public class CrossDataHistPOExt extends CrossDataRealtimePO { public class CrossDataHistPOExt extends CrossDataRealtimePO {
@ApiModelProperty(value = "三急一速数量", notes = "") @ApiModelProperty(value = "三急一速数量", notes = "")
private Integer emergencyCount; private Integer emergencyCount;
@ApiModelProperty(value = "绿灯空放时长", notes = "")
private Integer emptyPhase = 0;
} }
...@@ -11,5 +11,8 @@ import lombok.Data; ...@@ -11,5 +11,8 @@ import lombok.Data;
public class CrossDirDataHistPOExt extends CrossDirDataRealtimePO { public class CrossDirDataHistPOExt extends CrossDirDataRealtimePO {
@ApiModelProperty(value = "三急一速数量", notes = "") @ApiModelProperty(value = "三急一速数量", notes = "")
public Integer emergencyCount; public Integer emergencyCount;
@ApiModelProperty(value = "绿灯空放时长")
private Integer emptyPhase = 0;
} }
...@@ -65,6 +65,4 @@ public class CrossDirDataRealtimePO { ...@@ -65,6 +65,4 @@ public class CrossDirDataRealtimePO {
public Double effusionRate; public Double effusionRate;
@ApiModelProperty(value = "绿灯有效利用率", notes = "") @ApiModelProperty(value = "绿灯有效利用率", notes = "")
public Double greenLightEfficiency; public Double greenLightEfficiency;
@ApiModelProperty(value = "绿灯空放时长")
private Integer emptyPhase = 0;
} }
...@@ -123,4 +123,13 @@ ...@@ -123,4 +123,13 @@
order by batch_time order by batch_time
</select> </select>
<select id="selectExtByCrossIdAndStartEnd" resultType="net.wanji.databus.po.CrossDataHistPOExt">
select <include refid="Base_Column_List"></include>
from t_cross_data_hist
where cross_id = #{crossId}
and batch_time <![CDATA[ >= ]]> #{startStamp}
and batch_time <![CDATA[ <= ]]> #{endStamp}
order by batch_time
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -240,4 +240,12 @@ ...@@ -240,4 +240,12 @@
AND in_out_type = 1 AND in_out_type = 1
</select> </select>
<select id="selectExtByTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPOExt">
SELECT <include refid="Base_Column_List"></include>
FROM t_cross_dir_data_hist
WHERE batch_time BETWEEN UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boStartDayStr}, #{startHourMinuteStr}), '%Y-%m-%d%H:%i'))
AND UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boEndDayStr}, #{endHourMinuteStr}), '%Y-%m-%d%H:%i'))
AND in_out_type = 1
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment