From f3055194ebf25ac465abb581f3c2b2c8ea0e44f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Wed, 12 Jun 2024 10:10:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A4=E9=80=9A=E6=B5=81=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=20=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DcTrafficStatisticsController.java | 21 ++++++- .../mapper/DcGantryStatisticsDataMapper.java | 10 ++++ ...IDcGantryMetricsStatisticsDataService.java | 2 +- .../IDcGantryStatisticsDataService.java | 2 +- .../impl/DcGantryStatisticsDataImpl.java | 5 ++ ...antryMetricsStatisticsDataServiceImpl.java | 9 ++- .../business/DcGantryStatisticsDataMapper.xml | 55 +++++++++++++++++++ 7 files changed, 98 insertions(+), 6 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java b/zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java index fd7e61ac..355d382b 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java @@ -162,6 +162,25 @@ public class DcTrafficStatisticsController { // 将查询结果封装为成功响应并返回 return AjaxResult.success(dcStatisticsData); } + + /** + * 交通流统计 列表 + * @param startDate + * @param endDate + * @param direction + * @param periodType + * @return + */ + @ApiOperation("交通流统计") + @GetMapping("/history/trafficFlowStatistics") + public AjaxResult trafficFlowStatistics(String startDate, String endDate,String direction,String periodType){ + List> mapList = dcGantryStatisticsDataService.trafficFlowStatistics(startDate,endDate,direction,periodType); + // 将查询结果封装为成功响应并返回 + return AjaxResult.success(mapList); + } + + + /** * 全路段双向实时车流量 * @param startDate 时间 @@ -198,7 +217,7 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String */ @ApiOperation("路段交通指标分析") @GetMapping("/history/sectionTrafficIndexAnalysis") - public AjaxResult sectionTrafficIndexAnalysis(String startDate, String direction,String periodType,int ranking ){ + public AjaxResult sectionTrafficIndexAnalysis(String startDate, String direction,String periodType,Long ranking ){ List> mapList = dcGantryMetricsStatisticsDataService.sectionTrafficIndexAnalysis(startDate,direction,periodType,ranking); // 将查询结果封装为成功响应并返回 return AjaxResult.success(mapList); diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcGantryStatisticsDataMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcGantryStatisticsDataMapper.java index 1909a0ed..bd2fde0b 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcGantryStatisticsDataMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcGantryStatisticsDataMapper.java @@ -47,5 +47,15 @@ public interface DcGantryStatisticsDataMapper extends BaseMapper> realTimeTrafficFlow(@Param("startDate") String startDate, @Param("direction")String direction, @Param("periodType")String periodType ); List> trafficPeriodAnalysis(@Param("startDate") String startDate, @Param("direction")String direction, @Param("periodType")String periodType); + + /** + * 交通流统计 列表 + * @param startDate + * @param endDate + * @param direction + * @param periodType + * @return + */ + List> trafficFlowStatistics(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("direction")String direction, @Param("periodType")String periodType); } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcGantryMetricsStatisticsDataService.java b/zc-business/src/main/java/com/zc/business/service/IDcGantryMetricsStatisticsDataService.java index 69a30014..2ed8f0ef 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcGantryMetricsStatisticsDataService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcGantryMetricsStatisticsDataService.java @@ -41,7 +41,7 @@ public interface IDcGantryMetricsStatisticsDataService extends IService gantryMetricsData(DcGantryMetricsStatisticsData request); - List> sectionTrafficIndexAnalysis(String startDate, String direction, String periodType,int ranking); + List> sectionTrafficIndexAnalysis(String startDate, String direction, String periodType,Long ranking); List> passIndicatorTimeDistribution(String startDate, String direction, String periodType); diff --git a/zc-business/src/main/java/com/zc/business/service/IDcGantryStatisticsDataService.java b/zc-business/src/main/java/com/zc/business/service/IDcGantryStatisticsDataService.java index a0712aa4..506bad3d 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcGantryStatisticsDataService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcGantryStatisticsDataService.java @@ -53,5 +53,5 @@ public interface IDcGantryStatisticsDataService extends IService> trafficPeriodAnalysis(String startDate, String direction, String periodType); - + List> trafficFlowStatistics(String startDate, String endDate, String direction, String periodType); } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java index cef92d43..87e831f7 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java @@ -217,6 +217,11 @@ public class DcGantryStatisticsDataImpl extends ServiceImpl> trafficFlowStatistics(String startDate, String endDate, String direction, String periodType) { + return dcGantryStatisticsDataMapper.trafficFlowStatistics(startDate,endDate,direction,periodType); + } + public List> aggregateTrafficVolume(List> dataList) { // 创建一个Map,用于存储整点时间的流量数据 Map aggregatedData = new HashMap<>(); diff --git a/zc-business/src/main/java/com/zc/business/service/impl/IDcGantryMetricsStatisticsDataServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/IDcGantryMetricsStatisticsDataServiceImpl.java index 5fc6ea39..229fe6ed 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/IDcGantryMetricsStatisticsDataServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/IDcGantryMetricsStatisticsDataServiceImpl.java @@ -173,7 +173,7 @@ public class IDcGantryMetricsStatisticsDataServiceImpl * @return */ @Override - public List> sectionTrafficIndexAnalysis(String startDate, String direction, String periodType, int ranking) { + public List> sectionTrafficIndexAnalysis(String startDate, String direction, String periodType, Long ranking) { List> mapListOne = gantryMetricsStatisticsDataMapper.sectionTrafficIndexAnalysis(startDate, direction, periodType); List> mapList = new ArrayList<>(); Map>> result = mapListOne.stream() @@ -221,7 +221,7 @@ public class IDcGantryMetricsStatisticsDataServiceImpl double avgSaturationRate = count > 0 ? sumSaturationRate / count : 0; // 格式化保留4位小数 - String formattedAvgSaturationRate = String.format("%.4f", avgSaturationRate); + Double formattedAvgSaturationRate = Double.valueOf(String.format("%.4f", avgSaturationRate)); Map map = new HashMap<>(); String description = getDescriptionByIdentification(groupId); @@ -238,8 +238,10 @@ public class IDcGantryMetricsStatisticsDataServiceImpl // System.out.println("平均饱和度:" + formattedAvgSaturationRate); } + if (ranking !=null){ + if (ranking == 1) { - mapList.sort(Comparator.comparingInt(map -> (Integer) ((Map) map).get("saturationRate")).reversed()); + mapList.sort(Comparator.comparingDouble(map -> Double.parseDouble(((Map) map).get("saturationRate").toString())).reversed()); } if (ranking == 2) { mapList.sort(Comparator.comparingInt(map -> (Integer) ((Map) map).get("crowdingRate")).reversed()); @@ -247,6 +249,7 @@ public class IDcGantryMetricsStatisticsDataServiceImpl if (ranking == 3) { mapList.sort(Comparator.comparingInt(map -> (Integer) ((Map) map).get("trafficCompositionRate")).reversed()); } + } return mapList; } diff --git a/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml b/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml index 8efa1702..b5daa978 100644 --- a/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml @@ -15,6 +15,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + + INSERT INTO @@ -250,5 +261,49 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND dg.period_type = '5' +