From ec64ae80f200feb0bff28b841e56cf6e6500fab3 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, 25 Dec 2024 10:57:28 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BA=A4=E9=80=9A=E6=B5=81=20=E5=85=A8?=
 =?UTF-8?q?=E8=B7=AF=E6=AE=B5=E8=BD=A6=E6=B5=81=E9=87=8F=E5=88=86=E6=9E=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../business/DcGantryStatisticsDataMapper.xml | 80 +++++++------------
 1 file changed, 27 insertions(+), 53 deletions(-)

diff --git a/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml b/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml
index 19622a37..ecba750a 100644
--- a/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml
+++ b/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml
@@ -5,7 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 <mapper namespace="com.zc.business.mapper.DcGantryStatisticsDataMapper">
     <resultMap type="map" id="countMap">
         <result property="volume" column="total_traffic_volume"/>
-        <result property="name" column="interval_name"/>
+        <result property="name" column="facility_name"/>
         <result property="totalPassengerFlow" column="total_passenger_flow"/>
         <result property="typeSpecialVehicleFlow" column="type_special_vehicle_flow"/>
         <result property="typeTruckFlow" column="type_truck_flow"/>
@@ -204,75 +204,49 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="realTimeTrafficFlow" resultMap="countMap" resultType="map" >
         SELECT
-        intervals.interval_name,
-        intervals.stake_make,
-        intervals.end_make,
+        ps.facility_code,
+        ps.facility_name,
         COALESCE(SUM(dgsd.traffic_volume), 0) AS total_traffic_volume,
         COALESCE(SUM(dgsd.type1_passenger_flow), 0) +
         COALESCE(SUM(dgsd.type2_passenger_flow), 0) +
         COALESCE(SUM(dgsd.type3_passenger_flow), 0) +
         COALESCE(SUM(dgsd.type4_passenger_flow), 0) AS total_passenger_flow,
 
-        COALESCE(SUM(dgsd.type1_truck_flow ), 0) +
-        COALESCE(SUM(dgsd.type2_truck_flow ), 0) +
-        COALESCE(SUM(dgsd.type3_truck_flow ), 0) +
-        COALESCE(SUM(dgsd.type4_truck_flow ), 0) +
-        COALESCE(SUM(dgsd.type5_truck_flow ), 0) +
-        COALESCE(SUM(dgsd.type6_truck_flow ), 0) AS type_truck_flow,
-
-        COALESCE(SUM(dgsd.type1_special_vehicle_flow ), 0) +
-        COALESCE(SUM(dgsd.type2_special_vehicle_flow ), 0) +
-        COALESCE(SUM(dgsd.type3_special_vehicle_flow ), 0) +
-        COALESCE(SUM(dgsd.type4_special_vehicle_flow ), 0) +
-        COALESCE(SUM(dgsd.type5_special_vehicle_flow ), 0) +
-        COALESCE(SUM(dgsd.type6_special_vehicle_flow ), 0) AS type_special_vehicle_flow
+        COALESCE(SUM(dgsd.type1_truck_flow), 0) +
+        COALESCE(SUM(dgsd.type2_truck_flow), 0) +
+        COALESCE(SUM(dgsd.type3_truck_flow), 0) +
+        COALESCE(SUM(dgsd.type4_truck_flow), 0) +
+        COALESCE(SUM(dgsd.type5_truck_flow), 0) +
+        COALESCE(SUM(dgsd.type6_truck_flow), 0) AS type_truck_flow,
 
+        COALESCE(SUM(dgsd.type1_special_vehicle_flow), 0) +
+        COALESCE(SUM(dgsd.type2_special_vehicle_flow), 0) +
+        COALESCE(SUM(dgsd.type3_special_vehicle_flow), 0) +
+        COALESCE(SUM(dgsd.type4_special_vehicle_flow), 0) +
+        COALESCE(SUM(dgsd.type5_special_vehicle_flow), 0) +
+        COALESCE(SUM(dgsd.type6_special_vehicle_flow), 0) AS type_special_vehicle_flow
         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', 'K133+588', '平阴南立交' UNION ALL
-        SELECT 'K133+588', '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', 'K182+987', '梁山立交' UNION ALL
-        SELECT 'K182+987', 'K190+495', '信楼枢纽' UNION ALL
-        SELECT 'K190+495', 'K202+979', '嘉祥西立交'
-        )AS intervals
-        LEFT JOIN (
-        SELECT
-        facility_code,
-        stake_mark,
-        facility_name,
-        direction
-        FROM
-        dc_facility
-        WHERE
-        direction = #{direction}
-        ) AS ps ON ps.stake_mark BETWEEN CONCAT(intervals.stake_make, '+0') AND CONCAT(intervals.end_make, '+0')
-        LEFT JOIN dc_gantry_statistics_data dgsd ON ps.facility_code = dgsd.gantry_code
-        AND
+        dc_facility ps
+        LEFT JOIN
+        dc_gantry_statistics_data dgsd ON ps.facility_code = dgsd.gantry_code
+        AND dgsd.period_type = #{periodType}
+        AND (
         <if test="periodType == 1">
             YEAR(dgsd.statistical_date) = #{startDate}
         </if>
         <if test="periodType == 3">
-            DATE_FORMAT(dgsd.statistical_date, '%Y-%m')= #{startDate}
+            DATE_FORMAT(dgsd.statistical_date, '%Y-%m') = #{startDate}
         </if>
         <if test="periodType == 4">
             DATE(dgsd.statistical_date) = DATE(#{startDate})
         </if>
-        AND dgsd.period_type =#{periodType}
+        )
+        WHERE
+        ps.direction = #{direction}
+        AND ps.facility_type = '10'
         GROUP BY
-        intervals.interval_name,
-        intervals.stake_make,
-        intervals.end_make;
+        ps.facility_code,
+        ps.facility_name;
 
     </select>