From d41b62733157067f352b43f9a6e635cedb0b6986 Mon Sep 17 00:00:00 2001
From: rain <1679827795@qq.com>
Date: Tue, 13 Jan 2026 10:05:13 +0800
Subject: [PATCH] 优化区域模块的geom格式

---
 drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml |   41 ++++++++++++++++-------------------------
 1 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml b/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml
index ecc0d0f..46a84c4 100644
--- a/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml
+++ b/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml
@@ -52,7 +52,7 @@
         ad.longitude,
         ad.latitude,
         ad.area_size,
-        concat(ST_AsText(ad.geom), ' | ', ST_SRID(ad.geom)) as geom,
+        concat(ST_AsText(ST_SwapXY(ad.geom)), ' | ', ST_SRID(ad.geom)) as geom,
         ad.area_type,
         ad.trigger_condition,
         ad.response_mechanism,
@@ -88,17 +88,6 @@
             </if>
             <if test="param2.areaSize != null and param2.areaSize != ''">
                 and ad.area_size = #{param2.areaSize}
-            </if>
-            <if test="param2.geom != null and param2.geom != ''">
-                and ST_Equals(
-                    ad.geom,
-                    ST_SRID(
-                        ST_GeomFromText(
-                            trim(case when instr(#{param2.geom}, '|') &gt; 0 then substring_index(#{param2.geom}, '|', 1) else #{param2.geom} end)
-                        ),
-                        case when instr(#{param2.geom}, '|') &gt; 0 then cast(trim(substring_index(#{param2.geom}, '|', -1)) as unsigned) else 4326 end
-                    )
-                )
             </if>
             <if test="param2.areaType != null and param2.areaType != ''">
                 and ad.area_type = #{param2.areaType}
@@ -137,7 +126,7 @@
         ad.longitude,
         ad.latitude,
         ad.area_size,
-        concat(ST_AsText(ad.geom), ' | ', ST_SRID(ad.geom)) as geom,
+        concat(ST_AsText(ST_SwapXY(ad.geom)), ' | ', ST_SRID(ad.geom)) as geom,
         ad.area_type,
         ad.trigger_condition,
         ad.response_mechanism,
@@ -402,12 +391,13 @@
             #{areaSize},
             <choose>
                 <when test="geom != null and geom != ''">
-                    ST_SRID(
-                        ST_GeomFromText(
-                            trim(case when instr(#{geom}, '|') &gt; 0 then substring_index(#{geom}, '|', 1) else #{geom} end)
-                        ),
-                        case when instr(#{geom}, '|') &gt; 0 then cast(trim(substring_index(#{geom}, '|', -1)) as unsigned) else 4326 end
-                    )
+                    case
+                        when instr(#{geom}, '|') &gt; 0 then ST_GeomFromText(
+                            trim(substring_index(#{geom}, '|', 1)),
+                            cast(trim(substring_index(#{geom}, '|', -1)) as unsigned)
+                        )
+                        else ST_GeomFromText(trim(#{geom}))
+                    end
                 </when>
                 <otherwise>null</otherwise>
             </choose>,
@@ -438,12 +428,13 @@
             <if test="latitude != null">latitude = #{latitude},</if>
             <if test="areaSize != null">area_size = #{areaSize},</if>
             <if test="geom != null and geom != ''">
-                geom = ST_SRID(
-                    ST_GeomFromText(
-                        trim(case when instr(#{geom}, '|') &gt; 0 then substring_index(#{geom}, '|', 1) else #{geom} end)
-                    ),
-                    case when instr(#{geom}, '|') &gt; 0 then cast(trim(substring_index(#{geom}, '|', -1)) as unsigned) else 4326 end
-                ),
+                geom = case
+                    when instr(#{geom}, '|') &gt; 0 then ST_GeomFromText(
+                        trim(substring_index(#{geom}, '|', 1)),
+                        cast(trim(substring_index(#{geom}, '|', -1)) as unsigned)
+                    )
+                    else ST_GeomFromText(trim(#{geom}))
+                end,
             </if>
             <if test="areaType != null">area_type = #{areaType},</if>
             <if test="triggerCondition != null">trigger_condition = #{triggerCondition},</if>

--
Gitblit v1.9.3