From f4fa36b8094aea5e648de285ed28e0514cb5dfdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Fri, 14 Jun 2024 13:35:44 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=BC=E5=90=88=E6=8C=87=E6=A0=87=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...antryMetricsStatisticsDataServiceImpl.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) 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 7c80c3f4..fb17a98b 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 @@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.exception.ServiceException; +import com.zc.business.domain.ComprehensiveIndexQuery; import com.zc.business.domain.DcGantryMetricsStatisticsData; import com.zc.business.enums.ChannelCongestionLevelEnum; import com.zc.business.enums.StakeMarkRange; @@ -307,7 +308,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<>(); map.put("groupTime", groupId); map.put("Id", id); @@ -317,7 +318,7 @@ public class IDcGantryMetricsStatisticsDataServiceImpl mapTime.add(map); } - // 输出结果 +/* // 输出结果 result.forEach((date, data) -> { System.out.println("统计日期:" + date); data.forEach(entry -> { @@ -325,7 +326,7 @@ public class IDcGantryMetricsStatisticsDataServiceImpl System.out.println(key + ": " + value); }); }); - }); + });*/ return mapTime; } @@ -341,7 +342,12 @@ public class IDcGantryMetricsStatisticsDataServiceImpl public Map radarMapOfTrafficIndicators(String startDate, String direction, String periodType) { List> mapOne = gantryMetricsStatisticsDataMapper.radarMapOfTrafficIndicators(startDate, direction, periodType); if (mapOne.isEmpty()) { - return null; + Map map = new HashMap<>(); + + map.put("crowdingRate", 0); + map.put("trafficCompositionRate", 0); + map.put("saturationRate", 0); + return map; } // 计算crowdingRate和trafficCompositionRate的众数,以及saturationRate的平均值 int[] rates = {0, 0}; // 用于存储众数,第一个元素为crowdingRate众数,第二个为trafficCompositionRate众数 @@ -367,14 +373,20 @@ 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<>(); - map.put("crowdingRate", rates[0]); + + map.put("crowdingRate", rates[0]); map.put("trafficCompositionRate", rates[1]); map.put("saturationRate", formattedAvgSaturationRate); return map; } + @Override + public List comprehensiveIndexQuery(ComprehensiveIndexQuery comprehensiveIndexQuery) { + return gantryMetricsStatisticsDataMapper.comprehensiveIndexQuery(comprehensiveIndexQuery); + } + private static int findMaxCountKey(Map counts) { // 初始化一个 Pair 类型来存储当前的最大计数及对应的键