|
|
@ -1430,79 +1430,81 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
@Override |
|
|
|
public AjaxResult selectStationAnalysis(DcSdhsEventQuery dcSdhsEventQuery) { |
|
|
|
|
|
|
|
List<DcSdhsEvent> eventList = redisCache.getCacheList(RedisKeyConstants.SDHS_EVENT); |
|
|
|
if (eventList == null || eventList.size() == 0) { |
|
|
|
return AjaxResult.error("请先导入数据"); |
|
|
|
} |
|
|
|
|
|
|
|
eventList = eventList.stream().filter(item -> item.getStartTime() != null |
|
|
|
&& item.getStartTime().getTime() >= dcSdhsEventQuery.getStartTime().getTime() |
|
|
|
&& item.getStartTime().getTime() <= dcSdhsEventQuery.getEndTime().getTime()) |
|
|
|
//本期数据
|
|
|
|
List<DcSdhsEvent> thisTimeList = dcSdhsEventMapper.selectStationAnalysis(dcSdhsEventQuery.getType(),dcSdhsEventQuery.getThisTime()); |
|
|
|
Set<String> stationSet = new HashSet<>(); |
|
|
|
List<DcSdhsEvent> thisTimeCloseList = thisTimeList.stream() |
|
|
|
.filter(item -> item.getEventType().equals("交通管制") && item.getEventSubclass().equals("收费站封闭")) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
//分割站点名称, 然后分组
|
|
|
|
Map<String, Long> thisTimeCloseStation = thisTimeCloseList.stream().collect(Collectors.groupingBy(item -> getStationName(item.getTitle()), |
|
|
|
Collectors.counting())); |
|
|
|
//限行
|
|
|
|
List<DcSdhsEvent> thisTimeRestrictionList = thisTimeList.stream() |
|
|
|
.filter(item -> item.getEventType().equals("交通管制") && item.getEventSubclass().equals("收费站限行")) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
//分割站点名称, 然后分组
|
|
|
|
Map<String, Long> thisTimeRestrictionStation = thisTimeRestrictionList.stream().collect(Collectors.groupingBy(item -> getStationName(item.getTitle()), |
|
|
|
Collectors.counting())); |
|
|
|
//合并 站点名称
|
|
|
|
stationSet.addAll(thisTimeCloseStation.keySet()); |
|
|
|
stationSet.addAll(thisTimeRestrictionStation.keySet()); |
|
|
|
|
|
|
|
//筛选方向
|
|
|
|
/*if (StringUtils.isNotEmpty(dcSdhsEventQuery.getDirection())){ |
|
|
|
if (dcSdhsEventQuery.getDirection().equals("1")){ |
|
|
|
//菏泽方向
|
|
|
|
eventList = eventList.stream() |
|
|
|
.filter(item -> item.getDirection().equals("广州方向") |
|
|
|
|| item.getDirection().equals("双向")) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} else if (dcSdhsEventQuery.getDirection().equals("3")){ |
|
|
|
//济南方向
|
|
|
|
eventList = eventList.stream() |
|
|
|
.filter(item -> item.getDirection().equals("济南方向") || item.getDirection().equals("双向")) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
//封闭
|
|
|
|
List<DcSdhsEvent> closeList = eventList.stream() |
|
|
|
//上期数据
|
|
|
|
List<DcSdhsEvent> lastTimeList = dcSdhsEventMapper.selectStationAnalysis(dcSdhsEventQuery.getType(),dcSdhsEventQuery.getLastTime()); |
|
|
|
|
|
|
|
List<DcSdhsEvent> lastTimeCloseList = thisTimeList.stream() |
|
|
|
.filter(item -> item.getEventType().equals("交通管制") && item.getEventSubclass().equals("收费站封闭")) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
//分割站点名称, 然后分组
|
|
|
|
Map<String, Long> closeStation = closeList.stream().collect(Collectors.groupingBy(item -> getStationName(item.getTitle()), |
|
|
|
Map<String, Long> lastTimeCloseStation = lastTimeCloseList.stream().collect(Collectors.groupingBy(item -> getStationName(item.getTitle()), |
|
|
|
Collectors.counting())); |
|
|
|
|
|
|
|
//限行
|
|
|
|
List<DcSdhsEvent> restrictionList = eventList.stream() |
|
|
|
List<DcSdhsEvent> lastTimeRestrictionList = lastTimeList.stream() |
|
|
|
.filter(item -> item.getEventType().equals("交通管制") && item.getEventSubclass().equals("收费站限行")) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
//分割站点名称, 然后分组
|
|
|
|
Map<String, Long> restrictionStation = restrictionList.stream().collect(Collectors.groupingBy(item -> getStationName(item.getTitle()), |
|
|
|
Map<String, Long> lastTimeRestrictionStation = lastTimeRestrictionList.stream().collect(Collectors.groupingBy(item -> getStationName(item.getTitle()), |
|
|
|
Collectors.counting())); |
|
|
|
|
|
|
|
//合并 站点名称
|
|
|
|
Set<String> stationSet = new HashSet<>(); |
|
|
|
stationSet.addAll(closeStation.keySet()); |
|
|
|
stationSet.addAll(restrictionStation.keySet()); |
|
|
|
stationSet.addAll(lastTimeCloseStation.keySet()); |
|
|
|
stationSet.addAll(lastTimeRestrictionStation.keySet()); |
|
|
|
|
|
|
|
|
|
|
|
//收费站统
|
|
|
|
//收费站统计
|
|
|
|
List<Map<String, Object>> list = new ArrayList<>(); |
|
|
|
for (String stationName : stationSet) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
Long allNum = 0L; |
|
|
|
map.put("stationName", stationName); |
|
|
|
if (closeStation.containsKey(stationName)) { |
|
|
|
map.put("close", closeStation.get(stationName)); |
|
|
|
allNum += closeStation.get(stationName); |
|
|
|
map.put("站点名称", stationName); |
|
|
|
if (thisTimeCloseStation.containsKey(stationName)) { |
|
|
|
map.put(dcSdhsEventQuery.getThisTime() + "封闭", thisTimeCloseStation.get(stationName)); |
|
|
|
} else { |
|
|
|
map.put(dcSdhsEventQuery.getThisTime() + "封闭", 0); |
|
|
|
} |
|
|
|
|
|
|
|
if (thisTimeRestrictionStation.containsKey(stationName)) { |
|
|
|
map.put(dcSdhsEventQuery.getThisTime() + "限行", thisTimeRestrictionStation.get(stationName)); |
|
|
|
} else { |
|
|
|
map.put(dcSdhsEventQuery.getThisTime() + "限行", 0); |
|
|
|
} |
|
|
|
|
|
|
|
if (lastTimeCloseStation.containsKey(stationName)) { |
|
|
|
map.put(dcSdhsEventQuery.getLastTime() + "封闭", lastTimeCloseStation.get(stationName)); |
|
|
|
} else { |
|
|
|
map.put("close", 0); |
|
|
|
map.put(dcSdhsEventQuery.getLastTime() + "封闭", 0); |
|
|
|
} |
|
|
|
|
|
|
|
if (restrictionStation.containsKey(stationName)) { |
|
|
|
map.put("restriction", restrictionStation.get(stationName)); |
|
|
|
allNum += restrictionStation.get(stationName); |
|
|
|
if (lastTimeRestrictionStation.containsKey(stationName)) { |
|
|
|
map.put(dcSdhsEventQuery.getLastTime() + "限行", lastTimeRestrictionStation.get(stationName)); |
|
|
|
} else { |
|
|
|
map.put("restriction", 0); |
|
|
|
map.put(dcSdhsEventQuery.getLastTime() + "限行", 0); |
|
|
|
} |
|
|
|
|
|
|
|
map.put("allNum", allNum); |
|
|
|
list.add(map); |
|
|
|
} |
|
|
|
|
|
|
|
//根据总数排序
|
|
|
|
list = list.stream().sorted(Comparator.comparing(item -> Long.parseLong(((Map<String, Object>) item).get("allNum").toString())).reversed()).collect(Collectors.toList()); |
|
|
|
return AjaxResult.success(list); |
|
|
|
} |
|
|
|
|
|
|
@ -1627,29 +1629,8 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public AjaxResult selectAccidentType(DcSdhsEventQuery dcSdhsEventQuery) { |
|
|
|
List<DcSdhsEvent> eventList = redisCache.getCacheList(RedisKeyConstants.SDHS_EVENT); |
|
|
|
if (eventList == null || eventList.size() == 0) { |
|
|
|
return AjaxResult.error("请先导入数据"); |
|
|
|
} |
|
|
|
|
|
|
|
eventList = eventList.stream().filter(item -> item.getStartTime() != null |
|
|
|
&& item.getStartTime().getTime() >= dcSdhsEventQuery.getStartTime().getTime() |
|
|
|
&& item.getStartTime().getTime() <= dcSdhsEventQuery.getEndTime().getTime() |
|
|
|
&& "交通事故".equals(item.getEventType())) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
List<Map<String, Object>> list = new ArrayList<>(); |
|
|
|
|
|
|
|
if (eventList.size() > 0) { |
|
|
|
//根据详细类型 分组计数
|
|
|
|
Map<String, Long> subclass = eventList.stream().collect(Collectors.groupingBy(DcSdhsEvent::getEventSubclass, Collectors.counting())); |
|
|
|
for (String key : subclass.keySet()) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("subclassName", key); |
|
|
|
map.put("num", subclass.get(key)); |
|
|
|
list.add(map); |
|
|
|
} |
|
|
|
list = list.stream().sorted(Comparator.comparing(item -> Long.valueOf(((Map<String, Object>) item).get("num").toString())).reversed()).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
List<Map<String,Object>> list = dcSdhsEventMapper.selectAccidentType(dcSdhsEventQuery.getType(),dcSdhsEventQuery.getThisTime(),dcSdhsEventQuery.getLastTime()); |
|
|
|
|
|
|
|
return AjaxResult.success(list); |
|
|
|
} |
|
|
|