Commit 900b7da2 authored by hanbing's avatar hanbing

[update] 围观大数据平台-信号评价时间粒度调整

parent 03a6d8f4
...@@ -147,7 +147,9 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -147,7 +147,9 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
Integer minutesSpan = minutes - 1; // 排除结束时间 Integer minutesSpan = minutes - 1; // 排除结束时间
String metricName = bo.getMetricCode(); String metricName = bo.getMetricCode();
Date startTime = bo.getStartTime(); Date startTime = bo.getStartTime();
startTime = roundDownToNearest5Minutes(startTime);
Date endTime = bo.getEndTime(); Date endTime = bo.getEndTime();
endTime = roundUpToNearest5Minutes(endTime);
// 从 Kafka 查询绿灯空放时长 // 从 Kafka 查询绿灯空放时长
KafkaConsumerUtil kafkaConsumerUtil = new KafkaConsumerUtil(bootstrapServers, "bottom-curve-empty-phase"); KafkaConsumerUtil kafkaConsumerUtil = new KafkaConsumerUtil(bootstrapServers, "bottom-curve-empty-phase");
...@@ -660,6 +662,42 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -660,6 +662,42 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
return res; return res;
} }
/**
* Rounds the given date to the nearest previous 5-minute interval.
*
* @param date the date to be rounded
* @return the rounded date
*/
private Date roundDownToNearest5Minutes(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int unroundedMinutes = calendar.get(Calendar.MINUTE);
int mod = unroundedMinutes % 5;
calendar.add(Calendar.MINUTE, -mod);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
/**
* Rounds the given date to the nearest next 5-minute interval.
*
* @param date the date to be rounded
* @return the rounded date
*/
private Date roundUpToNearest5Minutes(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int unroundedMinutes = calendar.get(Calendar.MINUTE);
int mod = unroundedMinutes % 5;
if (mod != 0) {
calendar.add(Calendar.MINUTE, 5 - mod);
}
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
@Override @Override
public List<MainlineListVO> mainlineList() { public List<MainlineListVO> mainlineList() {
List<MainlineListVO> res = new ArrayList<>(); List<MainlineListVO> res = new ArrayList<>();
......
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