liyatao 5 сар өмнө
parent
commit
338dc80915

+ 20 - 7
onemap-modules/onemap-overlap/src/main/java/com/onemap/overlap/service/impl/SQLiteImp.java

@@ -16,6 +16,8 @@ import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.sqlite.SQLiteConfig;
 
@@ -45,27 +47,38 @@ public class SQLiteImp implements SQLiteService {
             Boolean reultUpdate = statement.execute(sqlUpdate);
             String querySQL = "select 图层名,合法方式,有效性 from 管控信息表";
             //ResultSet resultSet = sqliteHelper.executeQuery(querySQL,new RowMapper<String>(){});
+            List<String> sqlOverlap = new ArrayList<>();
             ResultSet resultSet = statement.executeQuery(querySQL);
-//            while (resultSet.hasN()) {
             while (resultSet.next()) {
                 String layerName = resultSet.getString("图层名");
                 String type = resultSet.getString("合法方式");
                 String isValid = resultSet.getString("有效性");
                 if(isValid.equals("有效")){
                     if(type.equals("外部")){
-                        String update = String.format("update 当前检查图斑 as c set 合法性说明 = case when 合法性说明 is null then '' else 合法性说明 || ';' end || '疑似%s内建设',面积 = case when 面积 is null then '' else 面积 end || ST_Area(ST_Intersection(c.geom,d.geom)) || ';' from %s d, idx_当前检查图斑_geom a, %s b where (a.xmax >= b.xmin  and a.xmin <= b.xmax and a.ymax >= b.ymin and a.ymin <= b.ymax) and (a.rowid = c.rowid  and b.rowid = d.rowid) and intersects(c.geom, d.geom) and st_intersection(c.geom,d.geom)  is not null;",layerName ,layerName,"idx_"+layerName+"_geom");
-                        Boolean resultUpdateOverlap = statement.execute(update);
+                        String updateOutside = String.format("update 当前检查图斑 as c set 合法性说明 = case when 合法性说明 is null then '' else 合法性说明 || ';' end || '疑似%s内建设',面积 = case when 面积 is null then '' else 面积 end || ST_Area(ST_Intersection(c.geom,d.geom)) || ';' from %s d, idx_当前检查图斑_geom a, %s b where (a.xmax >= b.xmin  and a.xmin <= b.xmax and a.ymax >= b.ymin and a.ymin <= b.ymax) and (a.rowid = c.rowid  and b.rowid = d.rowid) and intersects(c.geom, d.geom) and st_intersection(c.geom,d.geom)  is not null;",layerName ,layerName,"idx_"+layerName+"_geom");
+                        //statement.addBatch(updateOutside);
+                        //Boolean resultUpdateOverlap = statement.execute(update);
+                        sqlOverlap.add(updateOutside);
                     }
                     if(type.equals("内部")){
-                        String update = String.format("update 当前检查图斑 as c set 合法性说明 = case when 合法性说明 is null then '' else 合法性说明 || ';' end || '符合%s用地',面积 = case when 面积 is null then '' else 面积  end || ST_Area(ST_Intersection(c.geom,d.geom))|| ';' from %s d, idx_当前检查图斑_geom a, %s b where (a.xmax >= b.xmin  and a.xmin <= b.xmax and a.ymax >= b.ymin and a.ymin <= b.ymax) and (a.rowid = c.rowid  and b.rowid = d.rowid) and intersects(c.geom, d.geom) and st_within(c.geom, d.geom);",layerName ,layerName,"idx_"+layerName+"_geom");
-                        Boolean resultUpdateOverlap = statement.execute(update);
+                        String updateInside = String.format("update 当前检查图斑 as c set 合法性说明 = case when 合法性说明 is null then '' else 合法性说明 || ';' end || '符合%s用地',面积 = case when 面积 is null then '' else 面积  end || ST_Area(ST_Intersection(c.geom,d.geom))|| ';' from %s d, idx_当前检查图斑_geom a, %s b where (a.xmax >= b.xmin  and a.xmin <= b.xmax and a.ymax >= b.ymin and a.ymin <= b.ymax) and (a.rowid = c.rowid  and b.rowid = d.rowid) and intersects(c.geom, d.geom) and st_within(c.geom, d.geom);",layerName ,layerName,"idx_"+layerName+"_geom");
+                        //statement.addBatch(updateInside);
+                        //Boolean resultUpdateOverlap = statement.execute(update);
+                        sqlOverlap.add(updateInside);
                     }
                 }
             }
+            for (String item : sqlOverlap){
+                statement.addBatch(item);
+            }
             String updateInlegal = "update 当前检查图斑  set 合法性判断 = '疑似违法'  where 合法性判断 is null and 合法性说明 like '%疑似%'";
-            Boolean resultUpdateInlegal = statement.execute(updateInlegal);
+            statement.addBatch(updateInlegal);
             String updateLegal = "update  当前检查图斑  set 合法性判断 = '合法用地'  where 合法性判断 is null and 合法性说明 like '%符合%'";
-            Boolean resultUpdateLegal = statement.execute(updateLegal);
+            statement.addBatch(updateLegal);
+            // 执行批量更新
+            statement.executeBatch();
+            // 提交事务
+            //connection.commit();
         } catch (ClassNotFoundException e) {
             e.printStackTrace();
         } catch (SQLException e) {