From 40a8157440e3b906da8f52e07d939d78c3f4c313 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 12 四月 2026 16:14:06 +0800
Subject: [PATCH] feat: 任务增加统计、同步增加通知
---
ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml b/ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml
index 98a65fe..df86c7f 100644
--- a/ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml
@@ -30,17 +30,17 @@
<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>
<if test="direction != null "> and direction = #{direction}</if>
<if test="collectTime != null "> and collect_time = #{collectTime}</if>
<if test="beginTime != null and beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
- AND date_format(collect_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
+ AND collect_time >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
- AND date_format(collect_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
+ AND collect_time <= #{endTime}
</if>
</where>
order by collect_time desc
@@ -110,4 +110,52 @@
<select id="getVehicleIdByNo" parameterType="String" resultType="Long">
select vehicle_id from tb_vehicle_info where vehicle_no = #{vehicleNo}
</select>
+
+ <delete id="deleteVehicleGpsBeforeDate">
+ delete from tb_vehicle_gps
+ where collect_time < DATE_SUB(NOW(), INTERVAL 2 MONTH)
+ </delete>
+
+ <delete id="deleteVehicleGpsBeforeDateBatch">
+ delete from tb_vehicle_gps
+ where collect_time < 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,
+ collect_time, device_report_time, platform_process_time, create_time
+ from tb_vehicle_gps
+ where vehicle_id = #{vehicleId}
+ and collect_time >= #{startTime}
+ and collect_time <= #{endTime}
+ </select>
+
+ <!-- 鏌ヨ娲昏穬杞﹁締ID锛堜紭鍖栵細浣跨敤GROUP BY鏇夸唬DISTINCT锛屾彁鍗囨�ц兘锛� -->
+ <select id="selectActiveVehicleIds" resultType="Long">
+ select vehicle_id
+ from tb_vehicle_gps
+ where collect_time >= #{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 >= #{startTime}
+ AND g.collect_time <= #{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