Commit e1fa78ea authored by duanruiming's avatar duanruiming

[update] 态势监测-全天流量

parent d07dc610
...@@ -225,4 +225,11 @@ public class TrendController { ...@@ -225,4 +225,11 @@ public class TrendController {
List<HotspotCrossVO> hotspotCrossVOS = trendService.hotspotCross(); List<HotspotCrossVO> hotspotCrossVOS = trendService.hotspotCross();
return JsonViewObject.newInstance().success(hotspotCrossVOS); return JsonViewObject.newInstance().success(hotspotCrossVOS);
} }
@ApiOperation(value = "前五交通流量", notes = "前五交通流量", response = JsonViewObject.class)
@GetMapping(value = "/top5Flow")
public JsonViewObject top5Flow() throws Exception {
List<RunningEvaluateMetricsDetailVO> hotspotCrossVOS = trendService.top5Flow();
return JsonViewObject.newInstance().success(hotspotCrossVOS);
}
} }
\ No newline at end of file
...@@ -48,4 +48,6 @@ public interface TrendService { ...@@ -48,4 +48,6 @@ public interface TrendService {
OptTypeVO optType(CrossIdBO crossIdBO); OptTypeVO optType(CrossIdBO crossIdBO);
List<HotspotCrossVO> hotspotCross() throws Exception; List<HotspotCrossVO> hotspotCross() throws Exception;
List<RunningEvaluateMetricsDetailVO> top5Flow() throws Exception;
} }
...@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUnit; ...@@ -5,6 +5,7 @@ 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;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.enums.*; import net.wanji.common.enums.*;
import net.wanji.common.utils.tool.CrossUtil; import net.wanji.common.utils.tool.CrossUtil;
import net.wanji.common.utils.tool.StringUtils; import net.wanji.common.utils.tool.StringUtils;
...@@ -57,6 +58,7 @@ import java.util.stream.Collectors; ...@@ -57,6 +58,7 @@ import java.util.stream.Collectors;
* @date 2023/2/8 10:31 * @date 2023/2/8 10:31
*/ */
@Service @Service
@Slf4j
public class TrendServiceImpl implements TrendService { public class TrendServiceImpl implements TrendService {
private final GreenwaveInfoMapper greenwaveInfoMapper; private final GreenwaveInfoMapper greenwaveInfoMapper;
private final BaseCrossInfoMapper baseCrossInfoMapper; private final BaseCrossInfoMapper baseCrossInfoMapper;
...@@ -90,6 +92,7 @@ public class TrendServiceImpl implements TrendService { ...@@ -90,6 +92,7 @@ public class TrendServiceImpl implements TrendService {
private final LaneSnapshotDataQueryService laneSnapshotDataQueryService; private final LaneSnapshotDataQueryService laneSnapshotDataQueryService;
private final DirectionMappingsConfig directionMappingsConfig; private final DirectionMappingsConfig directionMappingsConfig;
private final CrossDataHistMapper crossDataHistMapper; private final CrossDataHistMapper crossDataHistMapper;
private final RunningEvaluateServiceImpl runningEvaluateService;
// 用于计算路口状态,key为方向,value为状态 // 用于计算路口状态,key为方向,value为状态
private Map<Integer, Integer> preStatus = new HashMap<Integer, Integer>() {{ private Map<Integer, Integer> preStatus = new HashMap<Integer, Integer>() {{
...@@ -116,7 +119,7 @@ public class TrendServiceImpl implements TrendService { ...@@ -116,7 +119,7 @@ public class TrendServiceImpl implements TrendService {
CrossDirDataHistMapper crossDirDataHistMapper, EventAlarmMapper eventAlarmMapper, CrossDirDataHistMapper crossDirDataHistMapper, EventAlarmMapper eventAlarmMapper,
RidInfoMapper ridInfoMapper, BaseCrossDirInfoMapper baseCrossDirInfoMapper, RidInfoMapper ridInfoMapper, BaseCrossDirInfoMapper baseCrossDirInfoMapper,
CrossSchemeOptLogMapper crossSchemeOptLogMapper, GreenwaveCrossMapper greenwaveCrossMapper, CrossDirDataRealtimeMapper crossDirDataRealtimeMapper, GreenwaveHistMapper greenwaveHistMapper, GreenwaveRealtimeMapper greenwaveRealtimeMapper, SceneStrategyIdeaMapper strategyIdeaMapper, StrategyMapper strategyMapper, BaseCrossSchedulesMapper baseCrossSchedulesMapper, BaseCrossSchedulesPlanMapper baseCrossSchedulesPlanMapper, BaseCrossSectionMapper baseCrossSectionMapper, BaseCrossSchemeMapper crossSchemeMapper, BaseCrossSchemeMapper baseCrossSchemeMapper, BaseCrossPhaseMapper baseCrossPhaseMapper, BaseCrossPhaseLightsMapper crossPhaseLightsMapper, BaseCrossLaneLightsMapper baseCrossLaneLightsMapper, CrossBaseLaneInfoMapper crossBaseLaneInfoMapper, CrossTurnDataHistMapper crossTurnDataHistMapper, @Qualifier("greenwaveSceneMapper") GreenwaveSceneMapper greenwaveSceneMapper, @Qualifier("sceneStrategyMapper") SceneStrategyMapper sceneStrategyMapper, @Qualifier("sceneMapper") SceneMapper sceneMapper, @Qualifier("baseCrossPlanMapper") BaseCrossPlanMapper baseCrossPlanMapper, MainlineEvaluateServiceImpl mainlineEvaluateServiceImpl, CrossLaneDataHistMapper crossLaneDataHistMapper, LaneSnapshotDataQueryService laneSnapshotDataQueryService, DirectionMappingsConfig directionMappingsConfig, CrossSchemeOptLogMapper crossSchemeOptLogMapper, GreenwaveCrossMapper greenwaveCrossMapper, CrossDirDataRealtimeMapper crossDirDataRealtimeMapper, GreenwaveHistMapper greenwaveHistMapper, GreenwaveRealtimeMapper greenwaveRealtimeMapper, SceneStrategyIdeaMapper strategyIdeaMapper, StrategyMapper strategyMapper, BaseCrossSchedulesMapper baseCrossSchedulesMapper, BaseCrossSchedulesPlanMapper baseCrossSchedulesPlanMapper, BaseCrossSectionMapper baseCrossSectionMapper, BaseCrossSchemeMapper crossSchemeMapper, BaseCrossSchemeMapper baseCrossSchemeMapper, BaseCrossPhaseMapper baseCrossPhaseMapper, BaseCrossPhaseLightsMapper crossPhaseLightsMapper, BaseCrossLaneLightsMapper baseCrossLaneLightsMapper, CrossBaseLaneInfoMapper crossBaseLaneInfoMapper, CrossTurnDataHistMapper crossTurnDataHistMapper, @Qualifier("greenwaveSceneMapper") GreenwaveSceneMapper greenwaveSceneMapper, @Qualifier("sceneStrategyMapper") SceneStrategyMapper sceneStrategyMapper, @Qualifier("sceneMapper") SceneMapper sceneMapper, @Qualifier("baseCrossPlanMapper") BaseCrossPlanMapper baseCrossPlanMapper, MainlineEvaluateServiceImpl mainlineEvaluateServiceImpl, CrossLaneDataHistMapper crossLaneDataHistMapper, LaneSnapshotDataQueryService laneSnapshotDataQueryService, DirectionMappingsConfig directionMappingsConfig,
CrossDataHistMapper crossDataHistMapper) { CrossDataHistMapper crossDataHistMapper, RunningEvaluateServiceImpl runningEvaluateService) {
this.greenwaveInfoMapper = greenwaveInfoMapper; this.greenwaveInfoMapper = greenwaveInfoMapper;
this.baseCrossInfoMapper = baseCrossInfoMapper; this.baseCrossInfoMapper = baseCrossInfoMapper;
this.crossDataRealtimeMapper = crossDataRealtimeMapper; this.crossDataRealtimeMapper = crossDataRealtimeMapper;
...@@ -149,6 +152,7 @@ public class TrendServiceImpl implements TrendService { ...@@ -149,6 +152,7 @@ public class TrendServiceImpl implements TrendService {
this.laneSnapshotDataQueryService = laneSnapshotDataQueryService; this.laneSnapshotDataQueryService = laneSnapshotDataQueryService;
this.directionMappingsConfig = directionMappingsConfig; this.directionMappingsConfig = directionMappingsConfig;
this.crossDataHistMapper = crossDataHistMapper; this.crossDataHistMapper = crossDataHistMapper;
this.runningEvaluateService = runningEvaluateService;
} }
@Override @Override
...@@ -1669,19 +1673,19 @@ public class TrendServiceImpl implements TrendService { ...@@ -1669,19 +1673,19 @@ public class TrendServiceImpl implements TrendService {
@Override @Override
public List<HotspotCrossVO> hotspotCross() throws Exception { public List<HotspotCrossVO> hotspotCross() throws Exception {
try {
List<HotspotCrossVO> hotspotCrossVOS = new ArrayList<>(); List<HotspotCrossVO> hotspotCrossVOS = new ArrayList<>();
List<AbnormalCrossListVO> signalCrossRealTimeList =
LambdaQueryWrapper<CrossDataRealtimePO> queryWrapper = new LambdaQueryWrapper<>(); crossDataRealtimeMapper.selectAbnormalCross(null, null, null);
queryWrapper.select(CrossDataRealtimePO::getCrossId, CrossDataRealtimePO::getStartTime, CrossDataRealtimePO::getBatchTime) if (!CollectionUtils.isEmpty(signalCrossRealTimeList)) {
.orderByDesc(CrossDataRealtimePO::getCongestionIndex) Optional<AbnormalCrossListVO> max = signalCrossRealTimeList.stream().max(Comparator.comparingDouble(AbnormalCrossListVO::getCongestionIndex));
.last("limit 1"); AbnormalCrossListVO abnormalCrossListVO = new AbnormalCrossListVO();
List<CrossDataRealtimePO> crossRealtimePOS = crossDataRealtimeMapper.selectList(queryWrapper); if (max.isPresent()) {
if (!CollectionUtils.isEmpty(crossRealtimePOS) && crossRealtimePOS.size() == 1) { abnormalCrossListVO = max.get();
CrossDataRealtimePO crossDataRealtimePO = crossRealtimePOS.get(0);
// 查询当前拥堵指数最大,历史表中一个小时以内数据 // 查询当前拥堵指数最大,历史表中一个小时以内数据
LambdaQueryWrapper<CrossDirDataHistPO> histQuery = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CrossDirDataHistPO> histQuery = new LambdaQueryWrapper<>();
histQuery.eq(CrossDirDataHistPO::getCrossId, crossDataRealtimePO.getCrossId()) histQuery.eq(CrossDirDataHistPO::getCrossId, abnormalCrossListVO.getId())
.between(CrossDirDataHistPO::getBatchTime, crossDataRealtimePO.getBatchTime() - 3600, crossDataRealtimePO.getBatchTime()); .between(CrossDirDataHistPO::getBatchTime, abnormalCrossListVO.getBatchTime() - 3600, abnormalCrossListVO.getBatchTime());
List<CrossDirDataHistPO> histPOS = crossDirDataHistMapper.selectList(histQuery); List<CrossDirDataHistPO> histPOS = crossDirDataHistMapper.selectList(histQuery);
if (!CollectionUtils.isEmpty(histPOS)) { if (!CollectionUtils.isEmpty(histPOS)) {
Map<Date, List<CrossDirDataHistPO>> map = histPOS.stream().collect(Collectors.groupingBy(CrossDirDataHistPO::getStartTime)); Map<Date, List<CrossDirDataHistPO>> map = histPOS.stream().collect(Collectors.groupingBy(CrossDirDataHistPO::getStartTime));
...@@ -1699,12 +1703,51 @@ public class TrendServiceImpl implements TrendService { ...@@ -1699,12 +1703,51 @@ public class TrendServiceImpl implements TrendService {
} }
hotspotCrossVO.setDetailList(detailVOS); hotspotCrossVO.setDetailList(detailVOS);
hotspotCrossVO.setTimeStamp(entry.getKey()); hotspotCrossVO.setTimeStamp(entry.getKey());
hotspotCrossVO.setCrossId(abnormalCrossListVO.getId());
hotspotCrossVOS.add(hotspotCrossVO); hotspotCrossVOS.add(hotspotCrossVO);
} }
} }
} }
} }
} }
}
return hotspotCrossVOS;
} catch (Exception e) {
log.error("重点路口监测异常:", e);
throw new Exception(e);
}
}
@Override
public List<RunningEvaluateMetricsDetailVO> top5Flow() throws Exception {
List<RunningEvaluateMetricsDetailVO> hotspotCrossVOS = null;
try {
hotspotCrossVOS = new ArrayList<>();
List<AbnormalCrossListVO> signalCrossRealTimeList =
crossDataRealtimeMapper.selectAbnormalCross(null, null, null);
if (!CollectionUtils.isEmpty(signalCrossRealTimeList)) {
List<AbnormalCrossListVO> top5 = signalCrossRealTimeList.stream()
.sorted(Comparator.comparingDouble(AbnormalCrossListVO::getCongestionIndex))
.collect(Collectors.toList());
Collections.reverse(top5);
top5 = top5.subList(0, Math.min(top5.size(), 5));
if (!CollectionUtils.isEmpty(top5)) {
for (AbnormalCrossListVO abnormalCrossListVO : top5) {
String crossId = abnormalCrossListVO.getId();
MetricsDetailBO metricsDetailBO = new MetricsDetailBO();
metricsDetailBO.setCrossId(crossId);
metricsDetailBO.setDate(new Date(1705456500000L));
metricsDetailBO.setMinutes(60 * 2);
RunningEvaluateMetricsDetailVO result = runningEvaluateService.metricsDetail(metricsDetailBO);
result.setCrossId(crossId);
hotspotCrossVOS.add(result);
}
}
}
} catch (Exception e) {
log.error("全天流量监测异常:", e);
throw new Exception(e);
}
return hotspotCrossVOS; return hotspotCrossVOS;
} }
} }
...@@ -15,6 +15,7 @@ import java.util.List; ...@@ -15,6 +15,7 @@ import java.util.List;
@Data @Data
@ApiModel(value = "重点路口监测实体", description = "重点路口监测实体") @ApiModel(value = "重点路口监测实体", description = "重点路口监测实体")
public class HotspotCrossVO { public class HotspotCrossVO {
private String crossId;
private Date timeStamp; private Date timeStamp;
private List<DetailVO> detailList; private List<DetailVO> detailList;
@Data @Data
......
...@@ -18,6 +18,7 @@ import java.util.Objects; ...@@ -18,6 +18,7 @@ import java.util.Objects;
@NoArgsConstructor @NoArgsConstructor
@ApiModel(value = "RunningEvaluateMetricsDetailVO", description = "评价指标查询返回值") @ApiModel(value = "RunningEvaluateMetricsDetailVO", description = "评价指标查询返回值")
public class RunningEvaluateMetricsDetailVO { public class RunningEvaluateMetricsDetailVO {
private String crossId;
@ApiModelProperty(value = "状态列表") @ApiModelProperty(value = "状态列表")
private List<ProblemStatus> problemStatusList; private List<ProblemStatus> problemStatusList;
@ApiModelProperty(value = "问题方案列表") @ApiModelProperty(value = "问题方案列表")
......
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