Commit 89a25181 authored by duanruiming's avatar duanruiming

[update] 微观大数据平台-交通流量优化

parent 7e7199d1
...@@ -259,12 +259,11 @@ public class TrendController { ...@@ -259,12 +259,11 @@ public class TrendController {
return JsonViewObject.newInstance().success(hotspotCrossVOS); return JsonViewObject.newInstance().success(hotspotCrossVOS);
} }
@ApiOperation(value = "前五交通流量", notes = "前五交通流量", response = JsonViewObject.class) @ApiOperation(value = "前五交通流量", notes = "前五交通流量", response = Top5IndexVO.class)
@GetMapping(value = "/top5Flow") @GetMapping(value = "/top5Flow")
public JsonViewObject top5Flow() throws Exception { public JsonViewObject top5Flow() throws Exception {
List<RunningEvaluateMetricsDetailVO> hotspotCrossVOS = trendService.top5Flow(); List<Top5IndexVO> results = trendService.top5Flow();
return JsonViewObject.newInstance().success(hotspotCrossVOS); return JsonViewObject.newInstance().success(results);
} }
@ApiOperation(value = "路口交通状态", notes = "路口交通状态时长比例", response = JsonViewObject.class, @ApiOperation(value = "路口交通状态", notes = "路口交通状态时长比例", response = JsonViewObject.class,
......
...@@ -56,7 +56,7 @@ public interface TrendService { ...@@ -56,7 +56,7 @@ public interface TrendService {
List<HotspotCrossLaneVO> crossLaneData(CommonCrossIdVO commonCrossIdVO) throws Exception; List<HotspotCrossLaneVO> crossLaneData(CommonCrossIdVO commonCrossIdVO) throws Exception;
List<RunningEvaluateMetricsDetailVO> top5Flow() throws Exception; List<Top5IndexVO> top5Flow() throws Exception;
CrossStatusTimeRateVO crossStatusTimeRate(CommonCrossIdVO commonCrossIdVO) throws Exception; CrossStatusTimeRateVO crossStatusTimeRate(CommonCrossIdVO commonCrossIdVO) throws Exception;
......
...@@ -431,7 +431,7 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService { ...@@ -431,7 +431,7 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
} }
private List<RunningEvaluateMetricsDetailVO.CrossMetrics> buildMetricsList( public static List<RunningEvaluateMetricsDetailVO.CrossMetrics> buildMetricsList(
List<MetricHistDTO> metricHistDTOList, Integer minutes) { List<MetricHistDTO> metricHistDTOList, Integer minutes) {
// 按时间段分组 // 按时间段分组
......
package net.wanji.opt.service.impl; package net.wanji.opt.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
...@@ -15,6 +16,7 @@ import net.wanji.common.utils.tool.StringUtils; ...@@ -15,6 +16,7 @@ import net.wanji.common.utils.tool.StringUtils;
import net.wanji.databus.bo.CrossIdBO; import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.dao.entity.*; import net.wanji.databus.dao.entity.*;
import net.wanji.databus.dao.mapper.*; import net.wanji.databus.dao.mapper.*;
import net.wanji.databus.dto.MetricHistDTO;
import net.wanji.databus.po.*; import net.wanji.databus.po.*;
import net.wanji.databus.vo.AbnormalCrossListVO; import net.wanji.databus.vo.AbnormalCrossListVO;
import net.wanji.databus.vo.GreenwaveListVO; import net.wanji.databus.vo.GreenwaveListVO;
...@@ -1822,8 +1824,8 @@ public class TrendServiceImpl implements TrendService { ...@@ -1822,8 +1824,8 @@ public class TrendServiceImpl implements TrendService {
} }
@Override @Override
public List<RunningEvaluateMetricsDetailVO> top5Flow() throws Exception { public List<Top5IndexVO> top5Flow() throws Exception {
List<RunningEvaluateMetricsDetailVO> hotspotCrossVOS = new ArrayList<>(); List<Top5IndexVO> hotspotCrossVOS = new ArrayList<>();
try { try {
List<AbnormalCrossListVO> signalCrossRealTimeList = crossDataRealtimeMapper.selectAbnormalCross(null, null, null); List<AbnormalCrossListVO> signalCrossRealTimeList = crossDataRealtimeMapper.selectAbnormalCross(null, null, null);
if (!CollectionUtils.isEmpty(signalCrossRealTimeList)) { if (!CollectionUtils.isEmpty(signalCrossRealTimeList)) {
...@@ -1835,15 +1837,19 @@ public class TrendServiceImpl implements TrendService { ...@@ -1835,15 +1837,19 @@ public class TrendServiceImpl implements TrendService {
if (!CollectionUtils.isEmpty(top5)) { if (!CollectionUtils.isEmpty(top5)) {
for (AbnormalCrossListVO abnormalCrossListVO : top5) { for (AbnormalCrossListVO abnormalCrossListVO : top5) {
String crossId = abnormalCrossListVO.getId(); String crossId = abnormalCrossListVO.getId();
MetricsDetailBO metricsDetailBO = new MetricsDetailBO(); Top5IndexVO top5IndexVO = new Top5IndexVO();
metricsDetailBO.setCrossId(crossId); top5IndexVO.setCrossId(crossId);
//metricsDetailBO.setDate(DateUtil.offsetDay(new Date(1705456500000L), -1)); //metricsDetailBO.setDate(DateUtil.offsetDay(new Date(1705456500000L), -1));
Date date = new Date(); Date date = new Date();
metricsDetailBO.setDate(DateUtil.offsetDay(DateUtil.offsetHour(date, 2), -1)); DateTime start = DateUtil.offsetDay(DateUtil.offsetHour(date, 2), -1);
metricsDetailBO.setMinutes(60 * 2); DateTime end = DateUtil.offsetDay(DateUtil.offsetHour(date, 2), 0);
RunningEvaluateMetricsDetailVO result = runningEvaluateService.metricsDetail(metricsDetailBO); int startStamp = (int) (start.getTime() / 1000); // 10位时间戳
result.setCrossId(crossId); int endStamp = (int) (end.getTime() / 1000);
hotspotCrossVOS.add(result); List<MetricHistDTO> metricHistDTOS = crossDataHistMapper.selectMetricHistDTO(crossId, startStamp, endStamp);
// 使用全量数据按时间粒度聚合指标
List<RunningEvaluateMetricsDetailVO.CrossMetrics> crossMetrics = RunningEvaluateServiceImpl.buildMetricsList(metricHistDTOS, 120);
top5IndexVO.setMetricsList(crossMetrics);
hotspotCrossVOS.add(top5IndexVO);
} }
} }
} }
...@@ -1978,7 +1984,7 @@ public class TrendServiceImpl implements TrendService { ...@@ -1978,7 +1984,7 @@ public class TrendServiceImpl implements TrendService {
LocalDateTime localDateTime2 = LocalDateTime.ofInstant(end.toInstant(), ZoneId.of("+8")); LocalDateTime localDateTime2 = LocalDateTime.ofInstant(end.toInstant(), ZoneId.of("+8"));
String types = holoEventVO.getTypes(); String types = holoEventVO.getTypes();
queryWrapper.eq(HoloEventInfoPO::getCrossId, crossId); queryWrapper.eq(HoloEventInfoPO::getCrossId, crossId);
queryWrapper.between(HoloEventInfoPO::getDetectTime, localDateTime1, localDateTime2); queryWrapper.between(HoloEventInfoPO::getStartTime, localDateTime1, localDateTime2);
List<HoloEventInfoPO> holoEventInfoPOS = holoEventMapper.selectList(queryWrapper); List<HoloEventInfoPO> holoEventInfoPOS = holoEventMapper.selectList(queryWrapper);
List<HoloEventInfoPO> results = new ArrayList<>(); List<HoloEventInfoPO> results = new ArrayList<>();
if (!CollectionUtils.isEmpty(holoEventInfoPOS) && StringUtils.isNotBlank(types)) { if (!CollectionUtils.isEmpty(holoEventInfoPOS) && StringUtils.isNotBlank(types)) {
......
package net.wanji.opt.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author duanruiming
* @date 2024/06/06 9:49
*/
@Data
@NoArgsConstructor
@ApiModel(value = "Top5IndexVO", description = "前五交通指标实体")
public class Top5IndexVO {
@ApiModelProperty(value = "路口编号")
private String crossId;
@ApiModelProperty(value = "交通指标")
private List<RunningEvaluateMetricsDetailVO.CrossMetrics> metricsList;
}
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