From c459808efab29dc1b8439fbb90556bdb16f4c88b Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期三, 01 四月 2026 22:40:59 +0800
Subject: [PATCH] feat: 优化支付时显示任务ID

---
 ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml |   44 +++++++++++++++++++++++++++++++++-----------
 1 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml b/ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml
index 5d8d093..984d7f1 100644
--- a/ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml
@@ -30,7 +30,7 @@
     <select id="selectVehicleGpsList" parameterType="VehicleGps" resultMap="VehicleGpsResult">
         <include refid="selectVehicleGpsVo"/>
         <where>  
-            <if test="vehicleNo != null  and vehicleNo != ''"> and vehicle_no = #{vehicleNo}</if>
+            <if test="vehicleNo != null  and vehicleNo != ''"> and v.vehicle_no like concat('%', #{vehicleNo}, '%')</if>
             <if test="longitude != null "> and longitude = #{longitude}</if>
             <if test="latitude != null "> and latitude = #{latitude}</if>
             <if test="speed != null "> and speed = #{speed}</if>
@@ -112,13 +112,19 @@
     </select>
 
     <delete id="deleteVehicleGpsBeforeDate">
-        delete g from tb_vehicle_gps g
-        where g.collect_time &lt; (
-            select date_sub(max(collect_time), interval 2 day)
-            from tb_vehicle_gps g2
-            where g2.vehicle_id = g.vehicle_id
-        )
+        delete from tb_vehicle_gps
+        where collect_time &lt; DATE_SUB(NOW(), INTERVAL 2 MONTH)
     </delete>
+
+    <delete id="deleteVehicleGpsBeforeDateBatch">
+        delete from tb_vehicle_gps
+        where collect_time &lt; DATE_SUB(NOW(), INTERVAL 2 MONTH)
+        LIMIT #{batchSize}
+    </delete>
+
+    <update id="optimizeVehicleGpsTable">
+        OPTIMIZE TABLE tb_vehicle_gps
+    </update>
 
     <select id="selectGpsDataByTimeRange" resultMap="VehicleGpsResult">
         select gps_id, vehicle_id, device_id, longitude, latitude, altitude, speed, direction, 
@@ -127,13 +133,29 @@
         where vehicle_id = #{vehicleId}
           and collect_time &gt;= #{startTime}
           and collect_time &lt;= #{endTime}
-        order by collect_time
     </select>
 
+    <!-- 鏌ヨ娲昏穬杞﹁締ID锛堜紭鍖栵細浣跨敤GROUP BY鏇夸唬DISTINCT锛屾彁鍗囨�ц兘锛� -->
     <select id="selectActiveVehicleIds" resultType="Long">
-        select distinct vehicle_id
+        select vehicle_id
         from tb_vehicle_gps
-        where collect_time &gt;= DATE_SUB(NOW(), INTERVAL 7 DAY)
-        order by vehicle_id
+        where collect_time &gt;= #{startTime}
+    </select>
+    
+    <!-- 鏌ヨ鏈璁$畻鐨凣PS鍧愭爣锛堜紭鍖栵細浣跨敤NOT EXISTS鏇夸唬LEFT JOIN ... IS NULL锛� -->
+    <select id="selectUncalculatedGps" resultMap="VehicleGpsResult">
+        SELECT g.gps_id, g.vehicle_id, g.device_id, g.longitude, g.latitude, g.altitude, 
+               g.speed, g.direction, g.collect_time, g.device_report_time, 
+               g.platform_process_time, g.create_time, v.vehicle_no
+        FROM tb_vehicle_gps g
+        INNER JOIN tb_vehicle_info v ON g.vehicle_id = v.vehicle_id
+        WHERE g.vehicle_id = #{vehicleId}
+          AND g.collect_time &gt;= #{startTime}
+          AND g.collect_time &lt;= #{endTime}
+          AND NOT EXISTS (
+              SELECT 1 FROM tb_vehicle_gps_calculated c 
+              WHERE c.gps_id = g.gps_id
+          )
+        ORDER BY g.collect_time
     </select>
 </mapper> 
\ No newline at end of file

--
Gitblit v1.9.1