浏览代码

查询对照表数据

gushoubang 9 月之前
父节点
当前提交
ed96844c9e
共有 1 个文件被更改,包括 26 次插入30 次删除
  1. 26 30
      onemap-modules/onemap-analyse/src/main/resources/mapper/oracle/vector/TableDateMapper.xml

+ 26 - 30
onemap-modules/onemap-analyse/src/main/resources/mapper/oracle/vector/TableDateMapper.xml

@@ -31,37 +31,33 @@
     </select>
 
     <select id="getTargetTable" resultType="Map">
-        DROP TABLE IF EXISTS "${temporaryTable}";
-
-        CREATE TABLE "${temporaryTable}" AS SELECT
-        public.ST_Union ( b.geom ) AS geomRes
-        FROM
-        "${tableNameA}" a,
-        "${tableNameB}" b
-        WHERE
-        public.st_intersects ( a.geom, b.geom )
-        <if test="tableIdsA != null and tableIdsA.size() > 0">
-            AND a.id IN
-            <foreach collection="tableIdsA" item="tableId" open="(" close=")" separator=",">
-                #{tableId}
-            </foreach>
+        SELECT
+        <foreach item="column" collection="columns" separator=",">
+            <choose>
+                <when test="column == 'geom'">
+                </when>
+                <otherwise>
+                    a.${column}
+                </otherwise>
+            </choose>
+        </foreach>
+        <if test="columns != null and !columns.isEmpty()">
+            ,
         </if>
-        ;
-
-        CREATE TABLE "${newTableName}" AS
-        SELECT a.id,public.ST_Difference ( a.geom, b.geomRes ) AS geom
-        FROM
-        "${tableNameA}" a,
-        "${temporaryTable}" b
-        WHERE 1=1
-        <if test="tableIdsA != null and tableIdsA.size() > 0">
-            AND a.id IN
-            <foreach collection="tableIdsA" item="tableId" open="(" close=")" separator=",">
-                #{tableId}
-            </foreach>
+        public.st_asewkt(b.geom) AS geom
+        <if test="siweiArea == true">
+            , public.st_area(b.geom::public.geography) AS siweiArea
         </if>
-        ;
-
-        DROP TABLE IF EXISTS "${temporaryTable}";
+        FROM
+        "${rawTableName}" a
+        JOIN
+        "${targetTableName}" b
+        ON a.id = b.id
+        WHERE
+        a.id IN
+        <foreach item="id" collection="ids" open="(" separator="," close=")">
+            #{id}
+        </foreach>
     </select>
+
 </mapper>