From 618ece4b9b22c2b9a4e85b46f0b3ec99c53e200b Mon Sep 17 00:00:00 2001
From: linwei <872216696@qq.com>
Date: Thu, 02 Apr 2026 16:38:55 +0800
Subject: [PATCH] opt: sql改造其他模块改造12

---
 drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/mapper/GdManageDeviceMapper.xml |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/mapper/GdManageDeviceMapper.xml b/drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/mapper/GdManageDeviceMapper.xml
index fdb9d76..bb6d1e5 100644
--- a/drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/mapper/GdManageDeviceMapper.xml
+++ b/drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/mapper/GdManageDeviceMapper.xml
@@ -69,8 +69,9 @@
         d2.height as height
         from
         ja_gd_manage_device md
-        /* 修改点1:关联条件双向转型 text(规避之前的 bigint = varchar 错误) */
-        left join ja_gd_manage_device d2 on md.device_sn::text = d2.device_sn::text and d2.device_type = '0'
+        left join ja_gd_manage_device d2
+        on md.device_sn::text = d2.device_sn::text
+        and d2.device_type = '0'
         <where>
             <if test="deviceIds != null and deviceIds.size() > 0">
                 and md.id::text in
@@ -79,15 +80,16 @@
                 </foreach>
             </if>
             <if test="devicePayload != null and devicePayload != ''">
-                and md.device_payload like concat('%',#{devicePayload},'%')
+                and md.device_payload like concat('%', #{devicePayload}, '%')
             </if>
             <if test="geom != null and geom != ''">
-                /* 修改点2:增加显式类型转换 ::text,并建议指定 SRID (如 4326) */
-                and ST_Intersects(md.geom, ST_GeomFromText(#{geom}::text, 4326))
+                /* 确保这里是第一个条件时,and 能被 MyBatis 正确处理,或者直接去掉这个 and */
+                and ST_Intersects(md.geom, ST_GeomFromText(#{geom}::text))
             </if>
             <if test="deviceType != null and deviceType != '' ">
                 and md.device_type::text = #{deviceType}::text
             </if>
+            /* 将固定条件放在最前面或最后面,确保逻辑严健 */
             and md.is_deleted = 0
         </where>
     </select>

--
Gitblit v1.9.3