Commit 275a0db4 authored by duanruiming's avatar duanruiming

[add] 路口干线监测增加缓存

parent e81c1ce7
......@@ -51,6 +51,9 @@ public class TrendServiceV2Impl implements TrendServiceV2 {
@Resource
private StrategyGreenOptHistMapper greenOptHistMapper;
private static List<OptMonitoringVO> greenListCache = new ArrayList<>(10);
private static List<OptMonitoringVO> crossListCache = new ArrayList<>(80);
@Override
public List<CrossGreenStatusTimeRateVO> crossGreenStatusTimeRate() {
List<CrossGreenStatusTimeRateVO> crossGreenStatusTimeRateVOS = holoEventMapper.selectCrossGreenStatusTimeRate();
......@@ -204,6 +207,7 @@ public class TrendServiceV2Impl implements TrendServiceV2 {
}
}
});
greenListCache = optMonitoringVOS;
return optMonitoringVOS;
}
......@@ -216,14 +220,14 @@ public class TrendServiceV2Impl implements TrendServiceV2 {
String crossId = optMonitoringVO.getId();
for (CrossLastOptResultDTO optResultDTO : optResultDTOS) {
String id = optResultDTO.getId();
String type = optMonitoringVO.getType();
optMonitoringVO.setTypeDesc(EventInfoTypeEnum.getOptDesc(type));
if (StringUtils.endsWithIgnoreCase(id, crossId)) {
Date optTime = optResultDTO.getOptTime();
Integer duration = optResultDTO.getDuration();
String type = optResultDTO.getType();
// 优化时间计算
optMonitoringVO.setOptTime(optTime);
optMonitoringVO.setOptStatus(0);
optMonitoringVO.setTypeDesc(EventInfoTypeEnum.getOptDesc(type));
if (Objects.nonNull(optTime)) {
// 空放优化中,6秒钟结束,当前时间小于开始时间+持续时间
if (Objects.equals(EventInfoTypeEnum.PHASE_EMPTY.getEventType(), type) && (current - optTime.getTime() > 6 * 1000)) {
......@@ -238,14 +242,25 @@ public class TrendServiceV2Impl implements TrendServiceV2 {
}
}
});
crossListCache = optMonitoringVOS;
return optMonitoringVOS;
}
@Override
public List<OptMonitoringVO> eventAlarmRealTimeList() throws Exception {
List<OptMonitoringVO> results = new ArrayList<>(80);
List<OptMonitoringVO> greenList = crossOptMonitoringList();
List<OptMonitoringVO> crossList = greenOptMonitoringList();
List<OptMonitoringVO> results = new ArrayList<>(90);
List<OptMonitoringVO> greenList = new ArrayList<>(10);
List<OptMonitoringVO> crossList = new ArrayList<>(80);
if (!CollectionUtils.isEmpty(greenListCache)) {
greenList = greenListCache;
} else {
greenList = greenOptMonitoringList();
}
if (!CollectionUtils.isEmpty(crossListCache)) {
crossList = crossListCache;
} else {
crossList = crossOptMonitoringList();
}
results.addAll(greenList);
results.addAll(crossList);
List<OptMonitoringVO> sort = results.stream().sorted(Comparator.comparing(OptMonitoringVO::getStartTime).reversed()).collect(Collectors.toList());
......
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