ソースを参照

根据表格字段生成缓冲区

gushoubang 9 ヶ月 前
コミット
76bb800759

+ 19 - 0
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/controller/analyse/CreateUtilsDBController.java

@@ -1,5 +1,6 @@
 package com.onemap.analyse.controller.analyse;
 
+import com.onemap.analyse.domain.vo.BufferColumnTablesVo;
 import com.onemap.analyse.domain.vo.BufferTablesVo;
 import com.onemap.analyse.domain.vo.DifferenceTablesVo;
 import com.onemap.analyse.domain.vo.IntersectsTableWktVo;
@@ -43,6 +44,24 @@ public class CreateUtilsDBController extends BaseController {
         return RequestResult.success(result);
     }
 
+    /**
+     * 生成表空间数据的缓冲区,根据字段生成
+     *
+     * @param bufferColumnTablesVo
+     * @return
+     */
+    @PostMapping("/buffer/field/tables")
+    @Slave
+    public RequestResult bufferTables(@RequestBody BufferColumnTablesVo bufferColumnTablesVo) {
+        String newTable = createUtilsDBService.bufferTable(
+                bufferColumnTablesVo.getTableName(),
+                bufferColumnTablesVo.getColumn());
+
+        Map<String, String> result = new HashMap<>();
+        result.put("tableName", newTable);
+        return RequestResult.success(result);
+    }
+
     /**
      * 生成表tableNameB空间数据的差集,B-ST_Intersection(A,B)
      *

+ 9 - 0
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/domain/vo/BufferColumnTablesVo.java

@@ -0,0 +1,9 @@
+package com.onemap.analyse.domain.vo;
+
+import lombok.Data;
+
+@Data
+public class BufferColumnTablesVo {
+    String tableName;
+    String column;
+}

+ 15 - 4
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/mapper/vector/CreateUtilsDBMapper.java

@@ -16,6 +16,17 @@ public interface CreateUtilsDBMapper {
                      @Param("radius") float radius,
                      @Param("newTableName") String newTableName);
 
+    /**
+     * 计算tableName 空间数据的缓冲区,根据字段列生成,并存储成新的表
+     *
+     * @param tableName
+     * @param column
+     * @return
+     */
+    void bufferColumnTable(@Param("tableName") String tableName,
+                           @Param("column") String column,
+                           @Param("newTableName") String newTableName);
+
     /**
      * 生成表tableNameB空间数据的差集,B-ST_Intersection(A,B)
      *
@@ -29,7 +40,7 @@ public interface CreateUtilsDBMapper {
                           @Param("tableIdsA") List<Integer> tableIdsA,
                           @Param("tableNameB") String tableNameB,
                           @Param("newTableName") String newTableName,
-                          @Param("temporaryTable")String temporaryTable);
+                          @Param("temporaryTable") String temporaryTable);
 
     /**
      * 计算tableName 空间数据的缓冲区,并存储成新的表
@@ -39,7 +50,7 @@ public interface CreateUtilsDBMapper {
      * @return
      */
     void intersectionTableWkt(@Param("tableName") String tableName,
-                     @Param("tableIds") List<Integer> tableIds,
-                     @Param("ewkt") String ewkt,
-                     @Param("newTableName") String newTableName);
+                              @Param("tableIds") List<Integer> tableIds,
+                              @Param("ewkt") String ewkt,
+                              @Param("newTableName") String newTableName);
 }

+ 9 - 0
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/CreateUtilsDBService.java

@@ -15,6 +15,15 @@ public interface CreateUtilsDBService {
      */
     String bufferTable(String tableName, float radius);
 
+    /**
+     * 生成表空间数据的缓冲区,根据表列生成
+     *
+     * @param tableName
+     * @param column
+     * @return
+     */
+    String bufferTable(String tableName, String column);
+
     /**
      * 生成表tableNameB空间数据的差集,B-ST_Intersection(A,B)
      *

+ 8 - 0
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/impl/CreateUtilsDBServiceImpl.java

@@ -20,6 +20,14 @@ public class CreateUtilsDBServiceImpl implements CreateUtilsDBService {
         return newTableName;
     }
 
+    @Override
+    public String bufferTable(String tableName,  String column) {
+        long timestamp = System.currentTimeMillis();
+        String newTableName = tableName + "_buffer_"  + timestamp;
+        createUtilsDBMapper.bufferColumnTable(tableName, column, newTableName);
+        return newTableName;
+    }
+
     @Override
     public String differenceTables(String tableNameA, List<Integer> tableIdsA, String tableNameB) {
         long timestamp = System.currentTimeMillis();

+ 12 - 4
onemap-modules/onemap-analyse/src/main/resources/mapper/oracle/vector/CreateUtilsDBMapper.xml

@@ -5,7 +5,13 @@
 <mapper namespace="com.onemap.analyse.mapper.vector.CreateUtilsDBMapper">
     <insert id="bufferTable">
         CREATE TABLE "${newTableName}" AS
-        SELECT id,public.ST_Buffer(geom, #{radius}) AS geom
+        SELECT id, public.ST_Buffer(geom::public.geography, #{radius}) AS geom
+        FROM "${tableName}"
+        WHERE geom IS NOT NULL
+    </insert>
+    <insert id="bufferColumnTable">
+        CREATE TABLE "${newTableName}" AS
+        SELECT id, public.ST_Buffer(geom::public.geography, ${column}) AS geom
         FROM "${tableName}"
         WHERE geom IS NOT NULL
     </insert>
@@ -38,12 +44,13 @@
             <foreach collection="tableIdsA" item="tableId" open="(" close=")" separator=",">
                 #{tableId}
             </foreach>
-        </if>;
+        </if>
+        ;
 
         DROP TABLE IF EXISTS "${temporaryTable}";
     </insert>
 
-    <insert id="intersectionTableWkt" >
+    <insert id="intersectionTableWkt">
         CREATE TABLE "${newTableName}" AS
         SELECT id,public.ST_Intersection(inTbale.geom, public.st_geomfromewkt(#{ewkt})) AS geom
         FROM "${tableName}" inTbale
@@ -53,6 +60,7 @@
             <foreach collection="tableIds" item="tableId" open="(" close=")" separator=",">
                 #{tableId}
             </foreach>
-        </if>;
+        </if>
+        ;
     </insert>
 </mapper>

+ 0 - 3
onemap-modules/onemap-analyse/src/main/resources/mapper/oracle/vector/TableDateMapper.xml

@@ -3,7 +3,6 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.onemap.analyse.mapper.vector.TableDataMapper">
-
     <select id="getRawTable" resultType="Map">
         SELECT
         <foreach item="column" collection="columns" separator=",">
@@ -78,7 +77,6 @@
         JOIN
         "${rawTableName}" a
         ON a.id = b.id
-
         <if test="ids != null and ids.size()>0 ">
             WHERE
             a.id::VARCHAR IN
@@ -87,5 +85,4 @@
             </foreach>
         </if>
     </select>
-
 </mapper>