| 
						
						
							
								
							
						
						
					 | 
					@ -154,8 +154,14 @@ public class TrafficAnalysis { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            metricsData.setSaturationLevel(calculateFullSaturationDegree(sectionDataList, direction, periodType)); | 
					 | 
					 | 
					            metricsData.setSaturationLevel(calculateFullSaturationDegree(sectionDataList, direction, periodType)); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            // 计算通道拥挤度
 | 
					 | 
					 | 
					            // 计算通道拥挤度
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            metricsData.setChannelCongestionLevel(calculateSectionChannelCongestionLevel(sectionDataList)); | 
					 | 
					 | 
					            metricsData.setChannelCongestionLevel(calculateSectionChannelCongestionLevel(sectionDataList)); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            // 计算路网整体拥堵的方法
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            DcTrafficMetricsData trafficMetricsData = calculateRoadNetworkCongestion(sectionDataList); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            // 拥堵路段数量
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            metricsData.setCongestedSectionQuantity(trafficMetricsData.getCongestedSectionQuantity()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            // 返回拥堵里程
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            metricsData.setCongestedDistance(trafficMetricsData.getCongestedDistance()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            // 计算路网拥堵指数
 | 
					 | 
					 | 
					            // 计算路网拥堵指数
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            metricsData.setRoadNetworkCongestionLevel(calculateRoadNetworkCongestionLevel(sectionDataList)); | 
					 | 
					 | 
					            metricsData.setRoadNetworkCongestionLevel(trafficMetricsData.getRoadNetworkCongestionLevel()); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            result.add(metricsData); | 
					 | 
					 | 
					            result.add(metricsData); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        }); | 
					 | 
					 | 
					        }); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -369,13 +375,18 @@ public class TrafficAnalysis { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    /** | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					     * 计算路网拥堵指数 | 
					 | 
					 | 
					     * 计算路网整体拥堵的方法。 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					     * @param trafficSectionDataList 交通路段数据列表,包含各个路段的拥堵情况和里程等信息 | 
					 | 
					 | 
					     * | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					     * @return 返回路网整体的拥堵指数,如果输入列表为空则返回null | 
					 | 
					 | 
					     * @param trafficSectionDataList 交通路段数据列表,包含各个路段的交通状况和里程信息。 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @return DcTrafficMetricsData 包含路网整体拥堵指数、拥堵路段数量和拥堵里程的数据对象。 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     */ | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    public Integer calculateRoadNetworkCongestionLevel(List<DcTrafficSectionData> trafficSectionDataList) { | 
					 | 
					 | 
					    public DcTrafficMetricsData calculateRoadNetworkCongestion(List<DcTrafficSectionData> trafficSectionDataList) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        DcTrafficMetricsData metricsData = new DcTrafficMetricsData(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        // 如果输入的交通路段数据为空或为空列表,直接返回一个不含数据的metricsData对象
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (trafficSectionDataList == null || trafficSectionDataList.isEmpty()) { | 
					 | 
					 | 
					        if (trafficSectionDataList == null || trafficSectionDataList.isEmpty()) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            return null; // 列表为空时返回null
 | 
					 | 
					 | 
					            return metricsData; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        // 根据行驶方向对交通数据进行分组,以便分别计算每个方向的拥堵情况
 | 
					 | 
					 | 
					        // 根据行驶方向对交通数据进行分组,以便分别计算每个方向的拥堵情况
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -386,6 +397,8 @@ public class TrafficAnalysis { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        int totalDistance = StakeMarkConstant.calculateRoadLength() * groupedByDirection.size(); | 
					 | 
					 | 
					        int totalDistance = StakeMarkConstant.calculateRoadLength() * groupedByDirection.size(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        // 总拥堵里程,使用AtomicInteger以支持在并发环境中进行累加操作
 | 
					 | 
					 | 
					        // 总拥堵里程,使用AtomicInteger以支持在并发环境中进行累加操作
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        AtomicInteger totalCongestionDistance = new AtomicInteger(); | 
					 | 
					 | 
					        AtomicInteger totalCongestionDistance = new AtomicInteger(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        // 拥堵路段数量
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        AtomicInteger congestedSectionQuantity = new AtomicInteger(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        // 遍历每个方向的数据,计算总拥堵里程
 | 
					 | 
					 | 
					        // 遍历每个方向的数据,计算总拥堵里程
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        groupedByDirection.forEach((directionData, trafficSectionList) -> { | 
					 | 
					 | 
					        groupedByDirection.forEach((directionData, trafficSectionList) -> { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -427,7 +440,12 @@ public class TrafficAnalysis { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                // 如果之前已经有路段被计算过,则根据两个路段之间的距离和默认拥堵距离,计算实际应累加的拥堵距离
 | 
					 | 
					 | 
					                // 如果之前已经有路段被计算过,则根据两个路段之间的距离和默认拥堵距离,计算实际应累加的拥堵距离
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                if (previousAverageSpeed != 0) { | 
					 | 
					 | 
					                if (previousAverageSpeed != 0) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    int congestionDistance = Math.abs(stakeMark - previousStakeMark); | 
					 | 
					 | 
					                    int congestionDistance = Math.abs(stakeMark - previousStakeMark); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    totalCongestionDistance.addAndGet(Math.min(congestionDistance, defaultCongestionDistance)); | 
					 | 
					 | 
					                    if (congestionDistance > StakeMarkConstant.MAX_INTERVAL_MILLIMETER_WAVE_RADAR) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        totalCongestionDistance.addAndGet(defaultCongestionDistance); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    } else { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        totalCongestionDistance.addAndGet(congestionDistance); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        congestedSectionQuantity.addAndGet(1); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                } | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                // 更新辅助变量以备后续计算
 | 
					 | 
					 | 
					                // 更新辅助变量以备后续计算
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -437,10 +455,17 @@ public class TrafficAnalysis { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        }); | 
					 | 
					 | 
					        }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        // 计算并返回路网整体的拥堵指数
 | 
					 | 
					 | 
					        // 计算并返回路网整体的拥堵指数
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        return Math.round((float) totalCongestionDistance.get() / totalDistance * 100); | 
					 | 
					 | 
					        metricsData.setRoadNetworkCongestionLevel(Math.round((float) totalCongestionDistance.get() / totalDistance * 100)); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        // 返回拥堵路段数量
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        metricsData.setCongestedSectionQuantity(congestedSectionQuantity.get()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        // 返回拥堵里程
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        metricsData.setCongestedDistance(totalCongestionDistance.get()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        return metricsData; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    /** | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * 计算路段交通量 | 
					 | 
					 | 
					     * 计算路段交通量 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * | 
					 | 
					 | 
					     * | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |