浏览代码

提交spotoverlap微服务模块代码(内部合法情况)

wanger 2 月之前
父节点
当前提交
cde6dadb67

+ 8 - 0
onemap-modules/onemap-spotoverlap/src/main/java/com/onemap/spotoverlap/mapper/yzt/YztMapper.java

@@ -51,4 +51,12 @@ public interface YztMapper {
                         @Param("decimalPlaces") String decimalPlaces,
                         @Param("querywhere") String querywhere
     );
+
+
+    void executeAnalyseNb(@Param("tablename") String tablename,
+                        @Param("analyseTablename") String analyseTablename,
+                        @Param("analyseLayername") String analyseLayername,
+                        @Param("decimalPlaces") String decimalPlaces,
+                        @Param("querywhere") String querywhere
+    );
 }

+ 6 - 5
onemap-modules/onemap-spotoverlap/src/main/java/com/onemap/spotoverlap/service/impl/yzt/YztServiceImpl.java

@@ -721,11 +721,12 @@ public class YztServiceImpl implements IYztService {
                 if (type.equals("外部")) {
                     yztMapper.executeAnalyse(tablename, tableName, layerName, decimalPlaces, null);
                 } else if (type.equals("内部")) {
-                    String updateInside = String.format("update  " + tablename + "  as c set " +
-                            "合法性说明 = case when c.合法性说明 is null then '' else c.合法性说明 || ';' end || '符合%s用地'," +
-                            "面积 = case when 面积 is null then '' else 面积  end || round(cast( ST_Area(ST_Intersection(c.geom,d.geom)) as numeric), 2) || ';' " +
-                            "from %s d where ST_Covers ( c.geom, d.geom )", layerName, tableName);
-                    sqlOverlap.add(updateInside);
+                    yztMapper.executeAnalyseNb(tablename, tableName, layerName, decimalPlaces, null);
+//                    String updateInside = String.format("update  " + tablename + "  as c set " +
+//                            "合法性说明 = case when c.合法性说明 is null then '' else c.合法性说明 || ';' end || '符合%s用地'," +
+//                            "面积 = case when 面积 is null then '' else 面积  end || round(cast( ST_Area(ST_Intersection(c.geom,d.geom)) as numeric), 2) || ';' " +
+//                            "from %s d where ST_Covers ( c.geom, d.geom )", layerName, tableName);
+//                    sqlOverlap.add(updateInside);
                 }
             }
             String updateInlegal = "update " + tablename + "  set 合法性判断 = '疑似违法'  where 合法性说明 like '%疑似%'";

+ 27 - 0
onemap-modules/onemap-spotoverlap/src/main/resources/mapper/postgresql/yzt/YztMapper.xml

@@ -105,4 +105,31 @@
         WHERE eee.swid = C.swid
     </update>
 
+    <update id="executeAnalyseNb">
+        --ST_Covers 内部合法
+        UPDATE ${tablename} AS C
+        SET 合法性说明 = C.合法性说明 || ( CASE WHEN eee.a_id IS NULL THEN ';' ELSE '符合'||#{analyseLayername}||'用地;' END ),
+        面积 = C.面积 || ( CASE WHEN eee.a_id IS NULL THEN ';' ELSE eee.totalarea || ';' END ),
+        编号集合 = C.编号集合 || ( CASE WHEN eee.a_id IS NULL THEN ';' ELSE eee.targetid || ';' END ),
+        面积集合 = C.面积集合 || ( CASE WHEN eee.a_id IS NULL THEN ';' ELSE eee.targetarea || ';' END )
+        FROM ( SELECT ccc.swid, bbb.* FROM ${tablename} ccc
+        LEFT JOIN ( SELECT a_id, STRING_AGG ( CAST ( b_id AS VARCHAR ), ',' ) AS targetid,
+        STRING_AGG ( CAST ( round( CAST ( intersection_area AS NUMERIC ), cast(#{decimalPlaces} as int) ) AS VARCHAR ),
+        ',' ) AS targetarea,
+        round( SUM ( CAST ( intersection_area AS NUMERIC ) ), cast(#{decimalPlaces} as int) ) AS totalarea
+        FROM ( SELECT A.swid AS a_id, b.swid AS b_id, st_area ( A.geom ) AS
+        intersection_area
+        FROM ${tablename} A JOIN ${analyseTablename} b ON ST_Covers ( b.geom, A.geom )
+        WHERE
+        1 = 1
+        <if test="querywhere != null and querywhere != ''">
+            and #{querywhere}
+        </if>
+        ) aaa
+        GROUP BY a_id ORDER BY a_id
+        ) bbb ON bbb.a_id = ccc.swid
+        ) eee
+        WHERE eee.swid = C.swid
+    </update>
+
 </mapper>