Browse Source

交通流统计 列表

develop
王兴琳 6 months ago
parent
commit
f3055194eb
  1. 21
      zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java
  2. 10
      zc-business/src/main/java/com/zc/business/mapper/DcGantryStatisticsDataMapper.java
  3. 2
      zc-business/src/main/java/com/zc/business/service/IDcGantryMetricsStatisticsDataService.java
  4. 2
      zc-business/src/main/java/com/zc/business/service/IDcGantryStatisticsDataService.java
  5. 5
      zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java
  6. 9
      zc-business/src/main/java/com/zc/business/service/impl/IDcGantryMetricsStatisticsDataServiceImpl.java
  7. 55
      zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml

21
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<Map<String,String>> 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<Map<String, Object>> mapList = dcGantryMetricsStatisticsDataService.sectionTrafficIndexAnalysis(startDate,direction,periodType,ranking);
// 将查询结果封装为成功响应并返回
return AjaxResult.success(mapList);

10
zc-business/src/main/java/com/zc/business/mapper/DcGantryStatisticsDataMapper.java

@ -47,5 +47,15 @@ public interface DcGantryStatisticsDataMapper extends BaseMapper<DcGantryStatist
List<Map<String, String>> realTimeTrafficFlow(@Param("startDate") String startDate, @Param("direction")String direction, @Param("periodType")String periodType );
List<Map<String, Object>> trafficPeriodAnalysis(@Param("startDate") String startDate, @Param("direction")String direction, @Param("periodType")String periodType);
/**
* 交通流统计 列表
* @param startDate
* @param endDate
* @param direction
* @param periodType
* @return
*/
List<Map<String, String>> trafficFlowStatistics(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("direction")String direction, @Param("periodType")String periodType);
}

2
zc-business/src/main/java/com/zc/business/service/IDcGantryMetricsStatisticsDataService.java

@ -41,7 +41,7 @@ public interface IDcGantryMetricsStatisticsDataService extends IService<DcGantry
*/
List<DcGantryMetricsStatisticsData> gantryMetricsData(DcGantryMetricsStatisticsData request);
List<Map<String, Object>> sectionTrafficIndexAnalysis(String startDate, String direction, String periodType,int ranking);
List<Map<String, Object>> sectionTrafficIndexAnalysis(String startDate, String direction, String periodType,Long ranking);
List<Map<String, Object>> passIndicatorTimeDistribution(String startDate, String direction, String periodType);

2
zc-business/src/main/java/com/zc/business/service/IDcGantryStatisticsDataService.java

@ -53,5 +53,5 @@ public interface IDcGantryStatisticsDataService extends IService<DcGantryStatist
List<Map<String, String>> trafficPeriodAnalysis(String startDate, String direction, String periodType);
List<Map<String, String>> trafficFlowStatistics(String startDate, String endDate, String direction, String periodType);
}

5
zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java

@ -217,6 +217,11 @@ public class DcGantryStatisticsDataImpl extends ServiceImpl<DcGantryStatisticsDa
return aggregatedList;
}
@Override
public List<Map<String, String>> trafficFlowStatistics(String startDate, String endDate, String direction, String periodType) {
return dcGantryStatisticsDataMapper.trafficFlowStatistics(startDate,endDate,direction,periodType);
}
public List<Map<String, String>> aggregateTrafficVolume(List<Map<String, Object>> dataList) {
// 创建一个Map,用于存储整点时间的流量数据
Map<Integer, Integer> aggregatedData = new HashMap<>();

9
zc-business/src/main/java/com/zc/business/service/impl/IDcGantryMetricsStatisticsDataServiceImpl.java

@ -173,7 +173,7 @@ public class IDcGantryMetricsStatisticsDataServiceImpl
* @return
*/
@Override
public List<Map<String, Object>> sectionTrafficIndexAnalysis(String startDate, String direction, String periodType, int ranking) {
public List<Map<String, Object>> sectionTrafficIndexAnalysis(String startDate, String direction, String periodType, Long ranking) {
List<Map<String, Object>> mapListOne = gantryMetricsStatisticsDataMapper.sectionTrafficIndexAnalysis(startDate, direction, periodType);
List<Map<String, Object>> mapList = new ArrayList<>();
Map<Integer, List<Map<String, Object>>> 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<String, Object> 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<String, Object>) map).get("saturationRate")).reversed());
mapList.sort(Comparator.comparingDouble(map -> Double.parseDouble(((Map<String, Object>) map).get("saturationRate").toString())).reversed());
}
if (ranking == 2) {
mapList.sort(Comparator.comparingInt(map -> (Integer) ((Map<String, Object>) map).get("crowdingRate")).reversed());
@ -247,6 +249,7 @@ public class IDcGantryMetricsStatisticsDataServiceImpl
if (ranking == 3) {
mapList.sort(Comparator.comparingInt(map -> (Integer) ((Map<String, Object>) map).get("trafficCompositionRate")).reversed());
}
}
return mapList;
}

55
zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml

@ -15,6 +15,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="direction" column="direction"/>
<result property="statisticalDate" column="statistical_date"/>
</resultMap>
<resultMap type="map" id="trafficFlowStatisticsMap">
<result property="intervalName" column="interval_name"/>
<result property="stakeMake" column="stake_make"/>
<result property="endMake" column="end_make"/>
<result property="facilityCode" column="facility_code"/>
<result property="direction" column="direction"/>
<result property="statisticalDate" column="statistical_date"/>
<result property="facilityName" column="facility_name"/>
<result property="trafficVolume" column="traffic_volume"/>
<result property="periodType" column="period_type"/>
</resultMap>
<!-- 插入或更新交通路段数据 -->
<insert id="insertOrUpdate" parameterType="com.zc.business.domain.DcGantryStatisticsData">
INSERT INTO
@ -250,5 +261,49 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND dg.period_type = '5'
</select>
<select id="trafficFlowStatistics" resultMap="trafficFlowStatisticsMap" resultType="map" >
SELECT
i.interval_name,
i.stake_make ,
i.end_make,
ps.facility_code ,
ps.facility_name ,
ps.direction ,
dgsd.traffic_volume ,
dgsd.statistical_date,
dgsd.period_type
FROM
(
SELECT 'K054+394' AS stake_make, 'K059+289' AS end_make, '殷家林枢纽-大学城立交' AS interval_name UNION ALL
SELECT 'K059+289', 'K072+847', '大学城立交-长清立交' UNION ALL
SELECT 'K072+847', 'K083+835', '长清立交-松竹枢纽' UNION ALL
SELECT 'K083+835', 'K086+499', '松竹枢纽-孝里立交' UNION ALL
SELECT 'K086+499', 'K099+750', '孝里立交-平阴北立交' UNION ALL
SELECT 'K099+750', 'K105+904', '平阴北立交-平阴立交' UNION ALL
SELECT 'K105+904', 'K117+878', '平阴立交-孔村枢纽' UNION ALL
SELECT 'K117+878', 'K126+233', '孔村枢纽-平阴南立交' UNION ALL
SELECT 'K126+233', 'K145+933', '平阴南立交-东平立交' UNION ALL
SELECT 'K145+933', 'K155+652', '东平立交-东平湖枢纽' UNION ALL
SELECT 'K155+652', 'K173+950', '东平湖枢纽-梁山东立交' UNION ALL
SELECT 'K173+950', 'K179+396', '梁山东立交-梁山立交' UNION ALL
SELECT 'K179+396', 'K190+495', '梁山立交-嘉祥西立交' UNION ALL
SELECT 'K190+495', 'K202+979', '嘉祥西立交'
) AS i
JOIN dc_facility AS ps
ON ps.stake_mark BETWEEN CONCAT(i.stake_make, '+0') AND CONCAT(i.end_make, '+0')
<if test="direction != null">
AND ps.direction = #{direction}
</if>
JOIN dc_gantry_statistics_data AS dgsd
ON ps.facility_code = dgsd.gantry_code
AND DATE(dgsd.statistical_date) BETWEEN #{startDate} AND #{endDate}
<if test="periodType != null">
AND dgsd.period_type = #{periodType}
</if>
ORDER BY
dgsd.statistical_date DESC;
</select>
</mapper>

Loading…
Cancel
Save