From 656d6f8029f8bf9b2daa9dcc89101a879a70b860 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期三, 03 十二月 2025 23:10:05 +0800
Subject: [PATCH] feat:优先添加执行人

---
 ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml |   63 +++++++++++++++++++++++++++----
 1 files changed, 55 insertions(+), 8 deletions(-)

diff --git a/ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml b/ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml
index e4c2477..2c78bdf 100644
--- a/ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml
@@ -30,15 +30,20 @@
     <select id="selectVehicleGpsList" parameterType="VehicleGps" resultMap="VehicleGpsResult">
         <include refid="selectVehicleGpsVo"/>
         <where>  
-            <if test="vehicleId != null "> and g.vehicle_id = #{vehicleId}</if>
-            <if test="vehicleNo != null and vehicleNo != ''"> and v.vehicle_no like concat('%', #{vehicleNo}, '%')</if>
-            <if test="longitude != null "> and g.longitude = #{longitude}</if>
-            <if test="latitude != null "> and g.latitude = #{latitude}</if>
-            <if test="altitude != null "> and g.altitude = #{altitude}</if>
-            <if test="speed != null "> and g.speed = #{speed}</if>
-            <if test="direction != null "> and g.direction = #{direction}</if>
-            <if test="collectTime != null  and collectTime != ''"> and g.collect_time = #{collectTime}</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') &gt;= date_format(#{beginTime},'%y%m%d')
+            </if>
+            <if test="endTime != null and endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
+                AND date_format(collect_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
+            </if>
         </where>
+        order by collect_time desc
     </select>
     
     <select id="selectVehicleGpsById" parameterType="Long" resultMap="VehicleGpsResult">
@@ -105,4 +110,46 @@
     <select id="getVehicleIdByNo" parameterType="String" resultType="Long">
         select vehicle_id from tb_vehicle_info where vehicle_no = #{vehicleNo}
     </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>
+
+    <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 &gt;= #{startTime}
+          and collect_time &lt;= #{endTime}
+        order by collect_time
+    </select>
+
+    <!-- 鏌ヨ娲昏穬杞﹁締ID锛堜紭鍖栵細娣诲姞LIMIT闄愬埗锛岄伩鍏嶅ぇ琛ㄦ壂鎻忥級 -->
+    <select id="selectActiveVehicleIds" resultType="Long">
+        select distinct vehicle_id
+        from tb_vehicle_gps
+        where collect_time &gt;= #{startTime}
+        order by vehicle_id
+    </select>
+    
+    <!-- 鏌ヨ鏈璁$畻鐨凣PS鍧愭爣锛堜笉鍦╰b_vehicle_gps_calculated琛ㄤ腑鐨勮褰曪級 -->
+    <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
+        LEFT JOIN tb_vehicle_info v ON g.vehicle_id = v.vehicle_id
+        LEFT JOIN tb_vehicle_gps_calculated c ON g.gps_id = c.gps_id
+        WHERE g.vehicle_id = #{vehicleId}
+          AND g.collect_time &gt;= #{startTime}
+          AND g.collect_time &lt;= #{endTime}
+          AND c.gps_id IS NULL  -- 鏈璁$畻鐨凣PS鐐�
+        ORDER BY g.collect_time
+    </select>
 </mapper> 
\ No newline at end of file

--
Gitblit v1.9.1