Commit 0dadb193 authored by duanruiming's avatar duanruiming

[add] 优化监测-AI干线优化绿信比百分比

parent 85336f67
...@@ -120,9 +120,14 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService { ...@@ -120,9 +120,14 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
int end = (int) (System.currentTimeMillis() / 1000) + 300; int end = (int) (System.currentTimeMillis() / 1000) + 300;
List<CrossDirDataHistPO> dirDataHistPOS = crossDirDataHistMapper.selectDirDataList(crossId, dirList, start, end); List<CrossDirDataHistPO> dirDataHistPOS = crossDirDataHistMapper.selectDirDataList(crossId, dirList, start, end);
if (!CollectionUtils.isEmpty(dirDataHistPOS)) { if (!CollectionUtils.isEmpty(dirDataHistPOS)) {
Map<Integer, List<CrossDirDataHistPO>> dirHistMap = dirDataHistPOS.stream().collect(Collectors.groupingBy(CrossDirDataHistPO::getDirType));
Integer dir = null;
for (Map.Entry<Integer, List<CrossDirDataHistPO>> entry : dirHistMap.entrySet()) {
dir = entry.getKey();
List<CrossDirDataHistPO> value = entry.getValue();
Double greenTimeRatio = 0.0; Double greenTimeRatio = 0.0;
List<GreenBeltKeyCrossFlowTimeVO.Detail> details = new ArrayList<>(); List<GreenBeltKeyCrossFlowTimeVO.Detail> details = new ArrayList<>();
for (CrossDirDataHistPO dirDataHistPO : dirDataHistPOS) { for (CrossDirDataHistPO dirDataHistPO : value) {
GreenBeltKeyCrossFlowTimeVO.Detail detail = new GreenBeltKeyCrossFlowTimeVO.Detail(); GreenBeltKeyCrossFlowTimeVO.Detail detail = new GreenBeltKeyCrossFlowTimeVO.Detail();
detail.setCrossId(crossId); detail.setCrossId(crossId);
String crossName = baseCrossInfoCache.getCrossName(crossId); String crossName = baseCrossInfoCache.getCrossName(crossId);
...@@ -140,34 +145,29 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService { ...@@ -140,34 +145,29 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
} }
if (StringUtils.equalsIgnoreCase(crossId, optResult.getCrossId()) && Objects.equals(curDir, dirType) if (StringUtils.equalsIgnoreCase(crossId, optResult.getCrossId()) && Objects.equals(curDir, dirType)
&& dirDataHistPO.getStartTime().getTime() == optResult.getStartTime().getTime()) { && dirDataHistPO.getStartTime().getTime() == optResult.getStartTime().getTime()) {
detail.setGreenTimeRatio(optResult.getGreenTimeRatio()); detail.setGreenTimeRatio(optResult.getGreenTimeRatio() * 100);
greenTimeRatio = optResult.getGreenTimeRatio(); greenTimeRatio = optResult.getGreenTimeRatio() * 100;
} }
} }
details.add(detail); details.add(detail);
} }
if (!CollectionUtils.isEmpty(details)) { if (!CollectionUtils.isEmpty(details)) {
Map<String, List<GreenBeltKeyCrossFlowTimeVO.Detail>> dirMap = details.stream().collect(Collectors.groupingBy(GreenBeltKeyCrossFlowTimeVO.Detail::getDir));
for (Map.Entry<String, List<GreenBeltKeyCrossFlowTimeVO.Detail>> entry : dirMap.entrySet()) {
String dir = entry.getKey();
GreenBeltKeyCrossFlowTimeVO greenBeltKeyCrossFlowTimeVO = new GreenBeltKeyCrossFlowTimeVO(); GreenBeltKeyCrossFlowTimeVO greenBeltKeyCrossFlowTimeVO = new GreenBeltKeyCrossFlowTimeVO();
List<GreenBeltKeyCrossFlowTimeVO.Detail> value = entry.getValue();
String crossName = ""; String crossName = "";
if (!CollectionUtils.isEmpty(value)) { if (!CollectionUtils.isEmpty(value)) {
GreenBeltKeyCrossFlowTimeVO.Detail detail = value.get(0); GreenBeltKeyCrossFlowTimeVO.Detail detail = details.get(0);
crossName = detail.getCrossName(); crossName = detail.getCrossName();
} }
greenBeltKeyCrossFlowTimeVO.setCrossName(crossName); greenBeltKeyCrossFlowTimeVO.setCrossName(crossName);
greenBeltKeyCrossFlowTimeVO.setDirName(GreenBeltDirEnum.getInDirName(Integer.valueOf(dir))); greenBeltKeyCrossFlowTimeVO.setDirName(GreenBeltDirEnum.getInDirName(Integer.valueOf(dir)));
List<GreenBeltKeyCrossFlowTimeVO.Detail> collect = value.stream().sorted(Comparator.comparing(GreenBeltKeyCrossFlowTimeVO.Detail::getStartTime)).collect(Collectors.toList()); List<GreenBeltKeyCrossFlowTimeVO.Detail> collect = details.stream().sorted(Comparator.comparing(GreenBeltKeyCrossFlowTimeVO.Detail::getStartTime)).collect(Collectors.toList());
greenBeltKeyCrossFlowTimeVO.setDetailList(collect); greenBeltKeyCrossFlowTimeVO.setDetailList(collect);
results.add(greenBeltKeyCrossFlowTimeVO); results.add(greenBeltKeyCrossFlowTimeVO);
} }
} }
} }
// 关键路口历史数据
return results; return results;
} catch (Exception e) { } catch (Exception e) {
log.error("绿波关键路口流量绿信比查询异常:", e); log.error("绿波关键路口流量绿信比查询异常:", e);
......
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