Commit 5c91161c authored by duanruiming's avatar duanruiming

[update] review-阻塞list判断优化

parent f6282a24
package net.wanji.opt.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
......@@ -24,6 +23,8 @@ import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
import static cn.hutool.core.collection.CollUtil.isNotEmpty;
/**
* @author Kent HAN
* @date 2023/3/10 10:47
......@@ -119,13 +120,13 @@ public class EvaluateServiceImpl implements EvaluateService {
EvaluateMetricsVO.EffusionRateElement effusionRateElement = new EvaluateMetricsVO.EffusionRateElement();
effusionRateElement.setDir(dir);
List<CrossDirDataRealtimePO> realtimeObj = dirObjMapRealtime.get(dir);
if (CollectionUtil.isNotEmpty(realtimeObj)) {
if (isNotEmpty(realtimeObj)) {
CrossDirDataRealtimePO crossDirDataRealtimePO = realtimeObj.get(0);
Double effusionRate = crossDirDataRealtimePO.getEffusionRate();
effusionRateElement.setCurrentRate(effusionRate);
}
List<CrossDirDataHistAvgBO> histObj = dirObjMapHist.get(dir);
if (CollectionUtil.isNotEmpty(histObj)) {
if (isNotEmpty(histObj)) {
CrossDirDataHistAvgBO crossDirDataHistAvgBO = histObj.get(0);
Double avgEffusionRate = crossDirDataHistAvgBO.getAvgEffusionRate();
effusionRateElement.setCompareRate(avgEffusionRate);
......@@ -147,12 +148,12 @@ public class EvaluateServiceImpl implements EvaluateService {
EvaluateMetricsVO.TrafficIndexElement trafficIndexElement = new EvaluateMetricsVO.TrafficIndexElement();
trafficIndexElement.setDir(dir);
List<CrossDirDataRealtimePO> realtimeObj = dirObjMapRealtime.get(dir);
if (CollectionUtil.isNotEmpty(realtimeObj)) {
if (isNotEmpty(realtimeObj)) {
CrossDirDataRealtimePO crossDirDataRealtimePO = realtimeObj.get(0);
trafficIndexElement.setCurrentIndex(crossDirDataRealtimePO.getTrafficIndex());
}
List<CrossDirDataHistAvgBO> histObj = dirObjMapHist.get(dir);
if (CollectionUtil.isNotEmpty(histObj)) {
if (isNotEmpty(histObj)) {
CrossDirDataHistAvgBO crossDirDataHistAvgBO = histObj.get(0);
trafficIndexElement.setCompareIndex(crossDirDataHistAvgBO.getAvgIndex());
}
......@@ -173,12 +174,12 @@ public class EvaluateServiceImpl implements EvaluateService {
EvaluateMetricsVO.QueueLengthElement queueLengthElement = new EvaluateMetricsVO.QueueLengthElement();
queueLengthElement.setDir(dir);
List<CrossDirDataRealtimePO> realtimeObj = dirObjMapRealtime.get(dir);
if (CollectionUtil.isNotEmpty(realtimeObj)) {
if (isNotEmpty(realtimeObj)) {
CrossDirDataRealtimePO crossDirDataRealtimePO = realtimeObj.get(0);
queueLengthElement.setCurrentLength(crossDirDataRealtimePO.getLength());
}
List<CrossDirDataHistAvgBO> histObj = dirObjMapHist.get(dir);
if (CollectionUtil.isNotEmpty(histObj)) {
if (isNotEmpty(histObj)) {
CrossDirDataHistAvgBO crossDirDataHistAvgBO = histObj.get(0);
queueLengthElement.setCompareLength(crossDirDataHistAvgBO.getAvgQueueLength());
}
......@@ -199,13 +200,13 @@ public class EvaluateServiceImpl implements EvaluateService {
EvaluateMetricsVO.CrossFlowElement crossFlowElement = new EvaluateMetricsVO.CrossFlowElement();
crossFlowElement.setDir(dir);
List<CrossDirDataRealtimePO> realtimeObj = dirObjMapRealtime.get(dir);
if (CollectionUtil.isNotEmpty(realtimeObj)) {
if (isNotEmpty(realtimeObj)) {
CrossDirDataRealtimePO crossDirDataRealtimePO = realtimeObj.get(0);
crossFlowElement.setCurrentCapacity(crossDirDataRealtimePO.getCapacity());
crossFlowElement.setCurrentFlow(crossDirDataRealtimePO.getFlow());
}
List<CrossDirDataHistAvgBO> histObj = dirObjMapHist.get(dir);
if (CollectionUtil.isNotEmpty(histObj)) {
if (isNotEmpty(histObj)) {
CrossDirDataHistAvgBO crossDirDataHistAvgBO = histObj.get(0);
crossFlowElement.setCompareCapacity(crossDirDataHistAvgBO.getAvgCapacity());
crossFlowElement.setCompareFlow(crossDirDataHistAvgBO.getAvgFlow());
......@@ -251,7 +252,7 @@ public class EvaluateServiceImpl implements EvaluateService {
long currentSeconds = DateUtil.currentSeconds();
long preSeconds = currentSeconds - (minutes + 5) * 60L;
List<CrossDataHistPO> crossDataHistPOS = crossDataHistMapper.selectByCrossIdAndTimestamp(crossId, preSeconds);
if (CollectionUtil.isNotEmpty(crossDataHistPOS)) {
if (isNotEmpty(crossDataHistPOS)) {
// 路口流量
double avg = crossDataHistPOS.stream()
.mapToInt(CrossDataHistPO::getFlow)
......
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