瀏覽代碼

套合分析生成导出相关接口提交

wanger 1 年之前
父節點
當前提交
cec195ab2f

+ 0 - 22
onemap-modules/onemap-overlap/src/main/java/com/onemap/overlap/config/ResourceMappingEvent.java

@@ -1,22 +0,0 @@
-//package com.onemap.overlap.config;
-//
-//import org.springframework.context.ApplicationEvent;
-//
-//public class ResourceMappingEvent extends ApplicationEvent {
-//    private final String pathPattern;
-//    private final String location;
-//
-//    public ResourceMappingEvent(Object source, String pathPattern, String location) {
-//        super(source);
-//        this.pathPattern = pathPattern;
-//        this.location = location;
-//    }
-//
-//    public String getPathPattern() {
-//        return pathPattern;
-//    }
-//
-//    public String getLocation() {
-//        return location;
-//    }
-//}

+ 0 - 47
onemap-modules/onemap-overlap/src/main/java/com/onemap/overlap/config/ResourceMappingEventListener.java

@@ -1,47 +0,0 @@
-//package com.onemap.overlap.config;
-//
-//import com.onemap.overlap.utils.SpatialiteUtils;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.beans.factory.annotation.Value;
-//import org.springframework.context.ApplicationListener;
-//import org.springframework.stereotype.Component;
-//import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
-//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-//
-//import java.io.File;
-//import java.sql.Connection;
-//import java.sql.ResultSet;
-//import java.sql.Statement;
-//
-//@Component
-//public class ResourceMappingEventListener implements WebMvcConfigurer, ApplicationListener<ResourceMappingEvent> {
-//
-//    private ResourceHandlerRegistry curregistry;
-//    @Value("${spatialite.filepath}")
-//    String dbpath;
-//
-//    @Override
-//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
-//        this.curregistry = registry;
-//        try {
-//            Connection connection = SpatialiteUtils.getSpatialiteConnection(dbpath);
-//            Statement statement = connection.createStatement();
-//            String querySQL = "select * from t_analyse_vector";
-//            ResultSet resultSet = statement.executeQuery(querySQL);
-//            while (resultSet.next()) {
-//                registry.addResourceHandler(resultSet.getString("tablename") + "/**")
-//                        .addResourceLocations("file:" + resultSet.getString("path") + File.separator);
-//            }
-//            connection.close();
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-//    }
-//
-//    @Override
-//    public void onApplicationEvent(ResourceMappingEvent event) {
-//        // 监听到资源映射事件,动态添加新的资源映射
-//        curregistry.addResourceHandler(event.getPathPattern() + "/**")
-//                .addResourceLocations("file:" + event.getLocation() + File.separator);
-//    }
-//}

+ 0 - 20
onemap-modules/onemap-overlap/src/main/java/com/onemap/overlap/config/ResourceMappingPublisher.java

@@ -1,20 +0,0 @@
-//package com.onemap.overlap.config;
-//
-//import org.springframework.context.ApplicationEventPublisher;
-//import org.springframework.stereotype.Component;
-//
-//@Component
-//public class ResourceMappingPublisher {
-//
-//    private final ApplicationEventPublisher applicationEventPublisher;
-//
-//    public ResourceMappingPublisher(ApplicationEventPublisher applicationEventPublisher) {
-//        this.applicationEventPublisher = applicationEventPublisher;
-//    }
-//
-//    // 发布资源映射更新事件
-//    public void publishResourceMappingEvent(String pathPattern, String location) {
-//        ResourceMappingEvent event = new ResourceMappingEvent(this, pathPattern, location);
-//        applicationEventPublisher.publishEvent(event);
-//    }
-//}

+ 4 - 4
onemap-modules/onemap-overlap/src/main/java/com/onemap/overlap/controller/DataController.java

@@ -223,9 +223,9 @@ public class DataController {
      * @return
      */
     @RequestMapping("/getTableGeoms")
-    public RequestResult getTableGeoms(String tablename) {
+    public RequestResult getTableGeoms(String tablename, String swid) {
         try {
-            return dataService.getTableGeoms(tablename);
+            return dataService.getTableGeoms(tablename, swid);
         } catch (Exception e) {
             e.printStackTrace();
             return RequestResult.error("失败", null);
@@ -253,9 +253,9 @@ public class DataController {
      * @return
      */
     @RequestMapping("/getTableRecord")
-    public RequestResult getTableRecord(String tablename, Integer page, Integer limit) {
+    public RequestResult getTableRecord(String tablename, Integer page, Integer limit, String swid, String hfxpd) {
         try {
-            return dataService.getTableRecord(tablename, page, limit);
+            return dataService.getTableRecord(tablename, page, limit, swid, hfxpd);
         } catch (Exception e) {
             e.printStackTrace();
             return RequestResult.error("失败", null);

+ 2 - 2
onemap-modules/onemap-overlap/src/main/java/com/onemap/overlap/service/DataService.java

@@ -34,11 +34,11 @@ public interface DataService {
 
     RequestResult getImageUrls(String tableid, String uuid);
 
-    RequestResult getTableGeoms(String tablename);
+    RequestResult getTableGeoms(String tablename, String swid);
 
     RequestResult getFeatureBySwid(String tablename, String swid);
 
-    RequestResult getTableRecord(String tablename, Integer page, Integer limit);
+    RequestResult getTableRecord(String tablename, Integer page, Integer limit, String swid, String hfxpd);
 
     RequestResult getMapConfig(String key);
 

+ 62 - 20
onemap-modules/onemap-overlap/src/main/java/com/onemap/overlap/service/impl/DataImp.java

@@ -1,5 +1,6 @@
 package com.onemap.overlap.service.impl;
 
+import cn.hutool.http.useragent.Browser;
 import com.onemap.common.core.utils.StringUtils;
 import com.onemap.common.core.web.domain.RequestResult;
 import com.onemap.common.security.utils.SecurityUtils;
@@ -20,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.swing.*;
 import java.awt.*;
 import java.io.*;
 import java.nio.file.*;
@@ -295,7 +297,8 @@ public class DataImp implements DataService {
         try {
             Connection connection = SpatialiteUtils.getSpatialiteConnection(dbpath);
             Statement statement = connection.createStatement();
-            String querySQL = "select layername,type,isvalid from t_model where modelname = '" + modelname + "'";
+            String querySQL = "select layername,type,isvalid from t_model where modelname = '" + modelname + "' union all " +
+                    "select layername , '外部', '失效' from  t_base_vector where layername not in (select layername from t_model where modelname = '" + modelname + "')";
             ResultSet resultSet = statement.executeQuery(querySQL);
             List<Map> res = new ArrayList<Map>();
             while (resultSet.next()) {
@@ -509,11 +512,14 @@ public class DataImp implements DataService {
     }
 
     @Override
-    public RequestResult getTableGeoms(String tablename) {
+    public RequestResult getTableGeoms(String tablename, String swid) {
         try {
             Connection connection = SpatialiteUtils.getSpatialiteConnection(dbpath);
             Statement statement = connection.createStatement();
             String querySQL = "select swid , astext(geom) as geom from  " + tablename;
+            if (StringUtils.isNotEmpty(swid)) {
+                querySQL += " where swid =  '" + swid + "'";
+            }
             ResultSet resultSet = statement.executeQuery(querySQL);
             List<Map> res = new ArrayList<Map>();
             while (resultSet.next()) {
@@ -522,8 +528,14 @@ public class DataImp implements DataService {
                 cur.put("geom", resultSet.getString("geom"));
                 res.add(cur);
             }
+            querySQL = "select serviceproj from t_analyse_vector t where t.tablename = '" + tablename + "'";
+            resultSet = statement.executeQuery(querySQL);
+            String proj = resultSet.getString("serviceproj");
             connection.close();
-            return RequestResult.success("查询成功!", res);
+            Map<String, Object> result = new HashMap<>();
+            result.put("geom", res);
+            result.put("proj", proj);
+            return RequestResult.success("查询成功!", result);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -558,11 +570,18 @@ public class DataImp implements DataService {
     }
 
     @Override
-    public RequestResult getTableRecord(String tablename, Integer page, Integer limit) {
+    public RequestResult getTableRecord(String tablename, Integer page, Integer limit, String swid, String hfxpd) {
         try {
             Connection connection = SpatialiteUtils.getSpatialiteConnection(dbpath);
             Statement statement = connection.createStatement();
-            String querySQL = "select * from  " + tablename + " order by swid LIMIT " + limit + " OFFSET " + ((page - 1) * limit);
+            String querySQL = "select * from  " + tablename + " where 1 = 1 ";
+            if (StringUtils.isNotEmpty(swid)) {
+                querySQL += " and swid like '%" + swid + "%'";
+            }
+            if (StringUtils.isNotEmpty(hfxpd)) {
+                querySQL += " and 合法性判断 = '" + hfxpd + "'";
+            }
+            querySQL += "order by swid LIMIT " + limit + " OFFSET " + ((page - 1) * limit);
             ResultSet resultSet = statement.executeQuery(querySQL);
             ResultSetMetaData metaData = resultSet.getMetaData();
             int columnCount = metaData.getColumnCount();
@@ -582,7 +601,13 @@ public class DataImp implements DataService {
                 }
                 res.add(cur);
             }
-            String countSQL = "select count(1) as count from  " + tablename;
+            String countSQL = "select count(1) as count from  " + tablename + " where 1 = 1 ";
+            if (StringUtils.isNotEmpty(swid)) {
+                countSQL += " and swid like '%" + swid + "%'";
+            }
+            if (StringUtils.isNotEmpty(hfxpd)) {
+                countSQL += " and 合法性判断 = '" + hfxpd + "'";
+            }
             ResultSet countSet = statement.executeQuery(countSQL);
             Integer count = countSet.getInt("count");
             connection.close();
@@ -861,16 +886,16 @@ public class DataImp implements DataService {
             statement.execute(updateSql);
 
             //TODO 更新geoserver样式 为checkedstyle
-            querySQL = "select servicename  from t_analyse_vector t where tablename = '" + tablename + "'";
-            resultSet = statement.executeQuery(querySQL);
-            String datasource = resultSet.getString("servicename");
-            querySQL = "select uri , username , password, workspace from t_geoserver ";
-            resultSet = statement.executeQuery(querySQL);
-            String geoserverurl = resultSet.getString("uri");
-            String geoserverusername = resultSet.getString("username");
-            String geoserverpassword = resultSet.getString("password");
-            String geoserverworkspace = resultSet.getString("workspace");
-            GeoServer.updateStyle(checkedstyle, geoserverurl, geoserverusername, geoserverpassword, datasource);
+//            querySQL = "select servicename  from t_analyse_vector t where tablename = '" + tablename + "'";
+//            resultSet = statement.executeQuery(querySQL);
+//            String datasource = resultSet.getString("servicename");
+//            querySQL = "select uri , username , password, workspace from t_geoserver ";
+//            resultSet = statement.executeQuery(querySQL);
+//            String geoserverurl = resultSet.getString("uri");
+//            String geoserverusername = resultSet.getString("username");
+//            String geoserverpassword = resultSet.getString("password");
+//            String geoserverworkspace = resultSet.getString("workspace");
+//            GeoServer.updateStyle(checkedstyle, geoserverurl, geoserverusername, geoserverpassword, datasource);
 
             resultSet.close();
             statement.close();
@@ -894,23 +919,40 @@ public class DataImp implements DataService {
 
     @Override
     public RequestResult exportReport(String modelname, String tablename, String layername, HttpServletRequest request, HttpServletResponse response) {
-        String folderPath = localFilePath + "/" + layername + "/" + "report";
+        String folderPath = localFilePath + "" + layername + "\\" + "report";
         File folder = new File(folderPath);
-        if (!folder.exists()) {
+        if (folder.exists()) {
+            // TODO 系统打开文件夹
+            try {
+                Runtime.getRuntime().exec("explorer.exe " + folderPath);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            return RequestResult.success("导出成功", 1);
+        } else {
             folder.mkdirs();
         }
         String excelpath = folderPath + "/" + layername + "report.xlsx";
         String wordpath = folderPath + "/" + layername + "report.docx";
+        String shppath = folderPath + "/" + layername + ".shp";
         try {
             String[] exportField = exportFields.split(",");
             ExcelExport.export(dbpath, excelpath, tablename, modelname, exportField);
             WordExport.export(dbpath, wordpath, tablename, modelname, exportField);
-            String[] filelist = {excelpath, wordpath};
-            FileToZipDownload.download(filelist, request, response);
+            SpatiaLiteToShapefile.execute(dbpath, shppath, shpWkid, tablename);
+// TODO           压缩包数据流下载
+//            String[] filelist = {excelpath, wordpath};
+//            FileToZipDownload.download(filelist, request, response);
         } catch (Exception e) {
             e.printStackTrace();
             return RequestResult.error("导出失败", e.toString());
         }
+        // TODO 系统打开文件夹
+        try {
+            Runtime.getRuntime().exec("explorer.exe " + folderPath);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
         return RequestResult.success("导出成功", 1);
     }
 

+ 2 - 1
onemap-modules/onemap-overlap/src/main/java/com/onemap/overlap/utils/ShpToSpatiaLite.java

@@ -113,7 +113,8 @@ public class ShpToSpatiaLite {
                 fields.add(fieldName);
             }
         } catch (IOException e) {
-            e.printStackTrace();
+//            e.printStackTrace();
+            System.out.println("shppath参数为空!");
         }
         return fields;
     }

+ 2 - 2
onemap-modules/onemap-overlap/src/main/java/com/onemap/overlap/utils/WebViewExample.java

@@ -14,14 +14,14 @@ public class WebViewExample extends Application {
         // 创建 WebView
         WebView webView = new WebView();
         // 加载 Web 页面
-        webView.getEngine().load("http://192.168.60.52:9206");
+        webView.getEngine().load("http://127.0.0.1:8080");
 
         // 布局
         StackPane root = new StackPane();
         root.getChildren().add(webView);
 
         // 设置场景和舞台
-        Scene scene = new Scene(root, 1200, 800);
+        Scene scene = new Scene(root, 1800, 1000);
         primaryStage.setTitle("图斑套合分析工具");
         primaryStage.setScene(scene);
         primaryStage.show();

+ 4 - 4
onemap-modules/onemap-overlap/src/main/resources/application.yml

@@ -9,10 +9,10 @@ spring:
       request-timeout: 999999999
   resources:
     static-locations: classpath:/static/
-  redis:
-    host: localhost
-    port: 6379
-    password:
+#  redis:
+#    host: localhost
+#    port: 6379
+#    password:
 # tomcat配置
 server:
   port: 9206