diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcSdhsEventMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcSdhsEventMapper.java index d325c698..9b5e3dcf 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcSdhsEventMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcSdhsEventMapper.java @@ -76,4 +76,9 @@ public interface DcSdhsEventMapper boolean deleteByTimeRange(@Param("startTime") String startTime,@Param("endTime") String endTime); List> selectRegionAnalysis(@Param("type") String type,@Param("thisTime") String thisTime, @Param("lastTime") String lastTime); + + List selectStationAnalysis(@Param("type") String type,@Param("time") String time); + + List> selectAccidentType(@Param("type") String type,@Param("thisTime") String thisTime, @Param("lastTime") String lastTime); + } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java index 5c07f7ad..3fefd4ae 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java @@ -1430,79 +1430,81 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { @Override public AjaxResult selectStationAnalysis(DcSdhsEventQuery dcSdhsEventQuery) { - List 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 thisTimeList = dcSdhsEventMapper.selectStationAnalysis(dcSdhsEventQuery.getType(),dcSdhsEventQuery.getThisTime()); + Set stationSet = new HashSet<>(); + List thisTimeCloseList = thisTimeList.stream() + .filter(item -> item.getEventType().equals("交通管制") && item.getEventSubclass().equals("收费站封闭")) + .collect(Collectors.toList()); + //分割站点名称, 然后分组 + Map thisTimeCloseStation = thisTimeCloseList.stream().collect(Collectors.groupingBy(item -> getStationName(item.getTitle()), + Collectors.counting())); + //限行 + List thisTimeRestrictionList = thisTimeList.stream() + .filter(item -> item.getEventType().equals("交通管制") && item.getEventSubclass().equals("收费站限行")) .collect(Collectors.toList()); + //分割站点名称, 然后分组 + Map 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 closeList = eventList.stream() + //上期数据 + List lastTimeList = dcSdhsEventMapper.selectStationAnalysis(dcSdhsEventQuery.getType(),dcSdhsEventQuery.getLastTime()); + + List lastTimeCloseList = thisTimeList.stream() .filter(item -> item.getEventType().equals("交通管制") && item.getEventSubclass().equals("收费站封闭")) .collect(Collectors.toList()); //分割站点名称, 然后分组 - Map closeStation = closeList.stream().collect(Collectors.groupingBy(item -> getStationName(item.getTitle()), + Map lastTimeCloseStation = lastTimeCloseList.stream().collect(Collectors.groupingBy(item -> getStationName(item.getTitle()), Collectors.counting())); - //限行 - List restrictionList = eventList.stream() + List lastTimeRestrictionList = lastTimeList.stream() .filter(item -> item.getEventType().equals("交通管制") && item.getEventSubclass().equals("收费站限行")) .collect(Collectors.toList()); //分割站点名称, 然后分组 - Map restrictionStation = restrictionList.stream().collect(Collectors.groupingBy(item -> getStationName(item.getTitle()), + Map lastTimeRestrictionStation = lastTimeRestrictionList.stream().collect(Collectors.groupingBy(item -> getStationName(item.getTitle()), Collectors.counting())); - //合并 站点名称 - Set stationSet = new HashSet<>(); - stationSet.addAll(closeStation.keySet()); - stationSet.addAll(restrictionStation.keySet()); + stationSet.addAll(lastTimeCloseStation.keySet()); + stationSet.addAll(lastTimeRestrictionStation.keySet()); + - //收费站统 + //收费站统计 List> list = new ArrayList<>(); for (String stationName : stationSet) { Map 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) 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 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> list = new ArrayList<>(); - if (eventList.size() > 0) { - //根据详细类型 分组计数 - Map subclass = eventList.stream().collect(Collectors.groupingBy(DcSdhsEvent::getEventSubclass, Collectors.counting())); - for (String key : subclass.keySet()) { - Map 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) item).get("num").toString())).reversed()).collect(Collectors.toList()); - } + List> list = dcSdhsEventMapper.selectAccidentType(dcSdhsEventQuery.getType(),dcSdhsEventQuery.getThisTime(),dcSdhsEventQuery.getLastTime()); return AjaxResult.success(list); } diff --git a/zc-business/src/main/resources/mapper/business/DcSdhsEventMapper.xml b/zc-business/src/main/resources/mapper/business/DcSdhsEventMapper.xml index 6baf8149..878a3616 100644 --- a/zc-business/src/main/resources/mapper/business/DcSdhsEventMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcSdhsEventMapper.xml @@ -109,6 +109,68 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" on t1.city = t3.city + + insert into dc_sdhs_event