|
|
@ -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<String, Object> 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<String, Object> radarMapOfTrafficIndicators(String startDate, String direction, String periodType) { |
|
|
|
List<Map<String, Object>> mapOne = gantryMetricsStatisticsDataMapper.radarMapOfTrafficIndicators(startDate, direction, periodType); |
|
|
|
if (mapOne.isEmpty()) { |
|
|
|
return null; |
|
|
|
Map<String, Object> 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<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("crowdingRate", rates[0]); |
|
|
|
map.put("trafficCompositionRate", rates[1]); |
|
|
|
map.put("saturationRate", formattedAvgSaturationRate); |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<ComprehensiveIndexQuery> comprehensiveIndexQuery(ComprehensiveIndexQuery comprehensiveIndexQuery) { |
|
|
|
return gantryMetricsStatisticsDataMapper.comprehensiveIndexQuery(comprehensiveIndexQuery); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static int findMaxCountKey(Map<Integer, Integer> counts) { |
|
|
|
// 初始化一个 Pair 类型来存储当前的最大计数及对应的键
|
|
|
|