瀏覽代碼

获取面积转换

gushoubang 9 月之前
父節點
當前提交
596dc0db41

+ 4 - 3
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/controller/analyse/AnalyseUtilsDBController.java

@@ -6,9 +6,10 @@ import com.onemap.common.core.web.controller.BaseController;
 import com.onemap.common.core.web.domain.RequestResult;
 import com.onemap.common.datasource.annotation.Slave;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 /**
  * 基于pgsql里的POSTGIS做的分析数据组件

+ 3 - 1
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/domain/vo/RawTableVo.java

@@ -10,7 +10,9 @@ import java.util.List;
 @Data
 public class RawTableVo {
     private String rawTableName; // 原始表名
-    private List<Integer> ids;  // id
+    private List<String> ids;  // id
     private List<String> columns; // 列名
     private Boolean siweiArea; // 是否需要计算面积
+    private Integer srid;  // srid
+    private Boolean isGeography = true;
 }

+ 0 - 3
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/AnalyseUtilsDBService.java

@@ -1,9 +1,6 @@
 package com.onemap.analyse.service;
 
-import org.springframework.web.bind.annotation.RequestParam;
-
 import java.util.List;
-import java.util.Map;
 
 /**
  * 基于pgsql里的POST做的分析组件

+ 46 - 18
onemap-modules/onemap-analyse/src/main/resources/mapper/oracle/vector/TableDateMapper.xml

@@ -16,18 +16,31 @@
                 </otherwise>
             </choose>
         </foreach>
-        <choose>
-            <when test="siweiArea == true">
-                , public.st_area(geom::public.geography) AS siweiArea
-            </when>
-        </choose>
+        <if test="siweiArea == true">
+            , public.st_area(
+            <choose>
+                <when test="srid!=null">
+                    st_taransform(geom,srid)
+                </when>
+                <otherwise>
+                    geom
+                </otherwise>
+            </choose>
+            <if test="isGeography==true">
+                ::public.geography
+            </if>
+            ) AS siweiArea
+        </if>
         FROM
         "${rawTableName}"
-        WHERE
-        id IN
-        <foreach item="id" collection="ids" open="(" separator="," close=")">
-            #{id}
-        </foreach>
+
+        <if test="ids != null and ids.size()>0 ">
+            WHERE
+            (id::varchar) IN
+            <foreach item="id" collection="ids" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
     </select>
 
     <select id="getTargetTable" resultType="Map">
@@ -46,18 +59,33 @@
         </if>
         public.st_asewkt(b.geom) AS geom
         <if test="siweiArea == true">
-            , public.st_area(b.geom::public.geography) AS siweiArea
+            , public.st_area(
+            <choose>
+                <when test="srid!=null">
+                    st_taransform(b.geom,srid)
+                </when>
+                <otherwise>
+                    b.geom
+                </otherwise>
+            </choose>
+            <if test="isGeography==true">
+                ::public.geography
+            </if>
+            ) AS siweiArea
         </if>
         FROM
-        "${rawTableName}" a
-        JOIN
         "${targetTableName}" b
+        JOIN
+        "${rawTableName}" a
         ON a.id = b.id
-        WHERE
-        a.id IN
-        <foreach item="id" collection="ids" open="(" separator="," close=")">
-            #{id}
-        </foreach>
+
+        <if test="ids != null and ids.size()>0 ">
+            WHERE
+            a.id::VARCHAR IN
+            <foreach item="id" collection="ids" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
     </select>
 
 </mapper>