Commit 893b5c55 authored by duanruiming's avatar duanruiming

[add] 小时流量统计优化

parent fda6a763
......@@ -412,7 +412,7 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
// 按时间段分组
Map<String, List<MetricHistDTO>> groupedByTime = metricHistDTOList.stream()
.collect(Collectors.groupingBy(metricHistDTO -> {
long timestampInMillSeconds = metricHistDTO.getBatchTime() * 1000L;
long timestampInMillSeconds = metricHistDTO.getBatchTime() * 1000L - 300000;
Date date = new Date(timestampInMillSeconds);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
int minuteOfDay = date.getMinutes() + date.getHours() * 60;
......
......@@ -1938,10 +1938,13 @@ public class TrendServiceImpl implements TrendService {
top5IndexVO.setCrossId(crossId);
//metricsDetailBO.setDate(DateUtil.offsetDay(new Date(1705456500000L), -1));
Date date = new Date();
DateTime start = DateUtil.offsetDay(DateUtil.offsetHour(date, 2), -1);
DateTime end = DateUtil.offsetDay(DateUtil.offsetHour(date, 2), 0);
int startStamp = (int) (start.getTime() / 1000); // 10位时间戳
int endStamp = (int) (end.getTime() / 1000 + 300);
LocalDateTime now = LocalDateTime.now();
LocalDateTime startDate = now.plusHours(1).minusDays(1).withMinute(0).withSecond(0).withNano(0);
LocalDateTime endDate = now.withMinute(0).withSecond(0).withNano(0);
long startL = startDate.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
long endL = endDate.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
int startStamp = (int) (startL / 1000);
int endStamp = (int) (endL / 1000);
List<MetricHistDTO> metricHistDTOS = crossDataHistMapper.selectMetricHistDTO(crossId, startStamp, endStamp);
// 使用全量数据按时间粒度聚合指标
List<RunningEvaluateMetricsDetailVO.CrossMetrics> crossMetrics = RunningEvaluateServiceImpl.buildMetricsList(metricHistDTOS, 60);
......
......@@ -116,7 +116,7 @@
from t_cross_data_hist
where cross_id = #{crossId}
and batch_time <![CDATA[ >= ]]> #{startStamp}
and batch_time <![CDATA[ <= ]]> #{endStamp}
and batch_time <![CDATA[ < ]]> #{endStamp}
order by batch_time
</select>
......
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