Commit e2b2a4e6 authored by hanbing's avatar hanbing

[add] 信号评价,评价指标-拥堵指数

parent 28a598c5
......@@ -12,4 +12,6 @@ public class CrossDirDataHistAvgBO {
private Integer avgFlow;
// 平均排队长度
private Double avgQueueLength;
// 平均拥堵指数
private Double avgIndex;
}
......@@ -81,14 +81,41 @@ public class EvaluateServiceImpl implements EvaluateService {
// 路口排队长度
List<EvaluateMetricsVO.QueueLengthElement> queueLength = buildQueueLength(crossId, minutes);
evaluateMetricsVO.setQueueLength(queueLength);
// // 拥堵指数
// List<EvaluateMetricsVO.TrafficIndexElement> trafficIndex = buildTrafficIndex();
// evaluateMetricsVO.setTrafficIndex(trafficIndex);
// 拥堵指数
List<EvaluateMetricsVO.TrafficIndexElement> trafficIndex = buildTrafficIndex(crossId, minutes);
evaluateMetricsVO.setTrafficIndex(trafficIndex);
// // todo 溢流率
// evaluateMetricsVO.setOverFlowRate(null);
return evaluateMetricsVO;
}
private List<EvaluateMetricsVO.TrafficIndexElement> buildTrafficIndex(String crossId, Integer minutes) {
List<EvaluateMetricsVO.TrafficIndexElement> res = new ArrayList<>();
// 实时数据
Map<Integer, List<CrossDirDataRealtimePO>> dirObjMapRealtime = getRealTimeData(crossId);
// 历史数据
Map<Integer, List<CrossDirDataHistAvgBO>> dirObjMapHist = getHistData(crossId, minutes);
for (Integer dir : dirObjMapRealtime.keySet()) {
EvaluateMetricsVO.TrafficIndexElement trafficIndexElement = new EvaluateMetricsVO.TrafficIndexElement();
trafficIndexElement.setDir(dir);
List<CrossDirDataRealtimePO> realtimeObj = dirObjMapRealtime.get(dir);
if (CollectionUtil.isNotEmpty(realtimeObj)) {
CrossDirDataRealtimePO crossDirDataRealtimePO = realtimeObj.get(0);
trafficIndexElement.setCurrentIndex(crossDirDataRealtimePO.getTrafficIndex());
}
List<CrossDirDataHistAvgBO> histObj = dirObjMapHist.get(dir);
if (CollectionUtil.isNotEmpty(histObj)) {
CrossDirDataHistAvgBO crossDirDataHistAvgBO = histObj.get(0);
trafficIndexElement.setCompareIndex(crossDirDataHistAvgBO.getAvgIndex());
}
res.add(trafficIndexElement);
}
return res;
}
private List<EvaluateMetricsVO.QueueLengthElement> buildQueueLength(String crossId, Integer minutes) {
List<EvaluateMetricsVO.QueueLengthElement> res = new ArrayList<>();
// 实时数据
......
......@@ -27,7 +27,7 @@
<select id="selectByCrossIdInOutTimestamp" resultType="net.wanji.opt.bo.CrossDirDataHistAvgBO">
SELECT dir_type as dirType, avg(capacity) as avgCapacity, avg(flow) as avgFlow,
avg(queue_length) as avgQueueLength
avg(queue_length) as avgQueueLength, avg(traffic_index) as avgIndex
FROM t_cross_dir_data_hist
WHERE cross_id = #{crossId}
AND in_out_type = #{inOutType}
......
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