Browse Source

后端接口提交

wanger 1 year ago
parent
commit
492bf7c3f7

+ 6 - 0
onemap-modules/onemap-overlap/pom.xml

@@ -175,6 +175,12 @@
 <!--            <artifactId>gt-jdbc-spatialite</artifactId>-->
 <!--            <version>20.4</version>-->
 <!--        </dependency>-->
+        <dependency>
+            <groupId>javax.media</groupId>
+            <artifactId>jai-core</artifactId>
+            <version>1.1.3</version> <!-- 或者最新版本 -->
+        </dependency>
+
     </dependencies>
 
     <repositories>

+ 18 - 0
onemap-modules/onemap-overlap/src/main/java/com/onemap/overlap/config/CorsConfig.java

@@ -0,0 +1,18 @@
+package com.onemap.overlap.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@Configuration
+public class CorsConfig implements WebMvcConfigurer {
+
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+        registry.addMapping("/**") // 对所有路径应用跨域配置
+                .allowedOrigins("*") // 允许任何域进行跨域访问
+                .allowedMethods("GET", "POST", "PUT", "DELETE") // 允许的请求方法
+                .allowedHeaders("*") // 允许的请求头
+        ;
+    }
+}

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

@@ -0,0 +1,22 @@
+//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;
+//    }
+//}

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

@@ -0,0 +1,47 @@
+//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);
+//    }
+//}

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

@@ -0,0 +1,20 @@
+//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);
+//    }
+//}

+ 70 - 0
onemap-modules/onemap-overlap/src/main/java/com/onemap/overlap/config/ResourcesConfig.java

@@ -0,0 +1,70 @@
+package com.onemap.overlap.config;
+
+import com.onemap.common.core.web.domain.RequestResult;
+import com.onemap.overlap.utils.SpatialiteUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+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;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 通用映射配置
+ *
+ * @author onemap
+ */
+//@Configuration
+@Component
+public class ResourcesConfig implements WebMvcConfigurer {
+
+//    @Value("${spatialite.filepath}")
+//    String dbpath;
+    @Value("${file.temp}")
+    String tempfilepath;
+    @Value("${file.proxy}")
+    String proxypath;
+
+//    private ResourceHandlerRegistry curregistry;
+
+//    @Autowired
+//    public ResourcesConfig(ResourceHandlerRegistry registry) {
+//        this.curregistry = registry;
+//    }
+
+    @Override
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
+        registry.addResourceHandler(proxypath + "/**")
+                .addResourceLocations("file:" + tempfilepath + File.separator);
+//        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();
+//        }
+    }
+
+    // 动态添加新的资源映射
+//    public void addDynamicResourceMapping(String pathPattern, String location) {
+//        curregistry.addResourceHandler(pathPattern + "/**")
+//                .addResourceLocations("file:" + location + File.separator);
+//    }
+}

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

@@ -4,10 +4,9 @@ import cn.hutool.json.JSONObject;
 import com.onemap.common.core.web.domain.RequestResult;
 import com.onemap.overlap.service.DataService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.core.io.InputStreamResource;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
@@ -20,6 +19,15 @@ public class DataController {
     @Autowired
     private DataService dataService;
 
+    @RequestMapping("/start")
+    public void start() {
+        try {
+            dataService.start();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
     /**
      * 导入数据 file/path 二选一 入库到spatialite
      *
@@ -28,9 +36,25 @@ public class DataController {
      * @return
      */
     @PostMapping("/import")
-    public RequestResult importIn(MultipartFile file, String path, String type, String name) {
+    public RequestResult importIn(MultipartFile file, String path, String type, String name, String ufield) {
+        try {
+            return dataService.importIn(file, path, type, name, ufield);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return RequestResult.error("失败", null);
+        }
+    }
+
+    /**
+     * 获取shp文件字段集合
+     *
+     * @param path 前端选择的shp文件的位置
+     * @return
+     */
+    @PostMapping("/getShpFields")
+    public RequestResult getShpFields(String path) {
         try {
-            return dataService.importIn(file, path, type, name);
+            return dataService.getShpFields(path);
         } catch (Exception e) {
             e.printStackTrace();
             return RequestResult.error("失败", null);
@@ -141,4 +165,69 @@ public class DataController {
             return RequestResult.error("失败", null);
         }
     }
+
+    @GetMapping("/{tiftype}/{tableid}/{uuid}.{filetype}")
+    public ResponseEntity<InputStreamResource> getTiff(@PathVariable("tiftype") String tiftype, @PathVariable("tableid") String tableid, @PathVariable("uuid") String uuid, @PathVariable("filetype") String filetype) {
+        return dataService.getTiff(tiftype, tableid, uuid, filetype);
+    }
+
+    /**
+     * 查询图斑前后时相影像地址
+     *
+     * @return
+     */
+    @RequestMapping("/getImageUrls")
+    public RequestResult getImageUrls(String tableid, String uuid) {
+        try {
+            return dataService.getImageUrls(tableid, uuid);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return RequestResult.error("失败", null);
+        }
+    }
+
+    /**
+     * 获取空间表的全量空间数据
+     *
+     * @return
+     */
+    @RequestMapping("/getTableGeoms")
+    public RequestResult getTableGeoms(String tablename) {
+        try {
+            return dataService.getTableGeoms(tablename);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return RequestResult.error("失败", null);
+        }
+    }
+
+    /**
+     * 根据swid获取空间表的属性信息
+     *
+     * @return
+     */
+    @RequestMapping("/getFeatureBySwid")
+    public RequestResult getFeatureBySwid(String tablename, String swid) {
+        try {
+            return dataService.getFeatureBySwid(tablename, swid);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return RequestResult.error("失败", null);
+        }
+    }
+
+    /**
+     * 根据swid获取空间表的属性信息
+     *
+     * @return
+     */
+    @RequestMapping("/getTableRecord")
+    public RequestResult getTableRecord(String tablename, Integer page, Integer limit) {
+        try {
+            return dataService.getTableRecord(tablename, page, limit);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return RequestResult.error("失败", null);
+        }
+    }
 }

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

@@ -1,6 +1,8 @@
 package com.onemap.overlap.service;
 
 import com.onemap.common.core.web.domain.RequestResult;
+import org.springframework.core.io.InputStreamResource;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
@@ -8,7 +10,7 @@ import java.io.IOException;
 
 public interface DataService {
 
-    RequestResult importIn(MultipartFile file, String path, String type, String name);
+    RequestResult importIn(MultipartFile file, String path, String type, String name, String ufield);
 
     RequestResult modellist();
 
@@ -23,4 +25,18 @@ public interface DataService {
     RequestResult modelupdate(HttpServletRequest request);
 
     RequestResult basevectordelete(String tablename);
+
+    RequestResult getShpFields(String path);
+
+    ResponseEntity<InputStreamResource> getTiff(String tiftype, String tableid, String uuid, String filetype);
+
+    RequestResult getImageUrls(String tableid, String uuid);
+
+    RequestResult getTableGeoms(String tablename);
+
+    RequestResult getFeatureBySwid(String tablename, String swid);
+
+    RequestResult getTableRecord(String tablename, Integer page, Integer limit);
+
+    void start();
 }

+ 256 - 9
onemap-modules/onemap-overlap/src/main/java/com/onemap/overlap/service/impl/DataImp.java

@@ -4,25 +4,35 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.onemap.common.core.utils.StringUtils;
 import com.onemap.common.core.web.domain.RequestResult;
 import com.onemap.common.security.utils.SecurityUtils;
+//import com.onemap.overlap.config.ResourcesConfig;
 import com.onemap.overlap.service.DataService;
-import com.onemap.overlap.utils.CustomUtils;
-import com.onemap.overlap.utils.ShpToSpatiaLite;
-import com.onemap.overlap.utils.SpatialiteUtils;
-import com.onemap.overlap.utils.UnPackageUtils;
+import com.onemap.overlap.utils.*;
 import org.apache.poi.xwpf.usermodel.BreakType;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 import org.json.simple.parser.JSONParser;
 import org.json.simple.parser.ParseException;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.InputStreamResource;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.imageio.ImageIO;
+import javax.media.jai.JAI;
 import javax.servlet.http.HttpServletRequest;
-import java.io.File;
-import java.io.IOException;
+import java.awt.image.RenderedImage;
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
 import java.sql.Connection;
 import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
 import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -33,15 +43,36 @@ import java.util.Map;
 public class DataImp implements DataService {
     @Value("${file.temp}")
     String localFilePath;
+    @Value("${file.proxy}")
+    String localFileProxy;
+    @Value("${server.port}")
+    String serverport;
+    @Value("${server.host}")
+    String serverhost;
     @Value("${file.wkid}")
     Integer shpWkid;
     @Value("${spatialite.filepath}")
     String dbpath;
     @Value("${file.prefix}")
     String prefix;
+    @Value("${image.qsx}")
+    String qsx;
+    @Value("${image.hsx}")
+    String hsx;
+    @Value("${qgis}")
+    String qgis;
+    @Value("${swid}")
+    String swid;
 
     @Override
-    public RequestResult importIn(MultipartFile file, String path, String type, String name) {
+    public void start() {
+        // 在后台启动 JavaFX 窗口
+        new Thread(() -> WebViewExample.launchApplication(new String[0])).start();
+        System.out.println("JavaFX 应用启动中...");
+    }
+
+    @Override
+    public RequestResult importIn(MultipartFile file, String path, String type, String name, String ufield) {
         if (file == null && path == null) {
             return RequestResult.error("参数未传递", null);
         }
@@ -108,7 +139,13 @@ public class DataImp implements DataService {
             String filename = fileName.replace(filetype, "").replace(".", "");
             tablename = prefix + filename + "_" + currentTime;
             try {
-                Boolean bool = ShpToSpatiaLite.ImportShpToSpatialite(dbpath, shpPath, shpWkid, tablename);
+                //TODO 用通用sql语句插入  效率慢 且 大数据插入有超长问题
+                //Boolean bool = ShpToSpatiaLite.ImportShpToSpatialite(dbpath, shpPath, shpWkid, tablename, ufield);
+                //TODO 使用QGIS的gdal环境入库
+                String command = qgis + "ogr2ogr.exe -progress -f \"SQLite\" -lco DIM=2 " + dbpath + " " + shpPath + " -overwrite -lco " +
+                        "GEOMETRY_NAME=geom -lco FID=" + swid + " -nln " + tablename + " -nlt PROMOTE_TO_MULTI -lco PRECISION=NO";
+                String msg = ExecuteCMD(command);
+                Boolean bool = msg.contains("...");
                 if (!bool) {
                     return RequestResult.error("shp数据入库失败!");
                 }
@@ -124,6 +161,7 @@ public class DataImp implements DataService {
             if ("base".equals(type)) {//管控数据
                 insertSQL = "insert into t_base_vector (layername , tablename) values ('" + name + "', '" + tablename + "')";
             } else if ("analyse".equals(type)) {//分析图斑
+//                resourcesConfig.publishResourceMappingEvent(tablename, folderpath);
                 insertSQL = "insert into t_analyse_vector (layername , tablename, path) values ('" + name + "', '" + tablename + "', '" + folderpath + "')";
             }
             statement.execute(insertSQL);
@@ -214,7 +252,7 @@ public class DataImp implements DataService {
             Statement statement = connection.createStatement();
             String deleteSQL = "delete from t_model where modelname = '" + modelname + "'";
             statement.execute(deleteSQL);
-            for(int i = 0 ; i < details.size() ; i ++){
+            for (int i = 0; i < details.size(); i++) {
                 JSONObject curObj = (JSONObject) details.get(i);
                 String layername = (String) curObj.get("layername");
                 String isvalid = (String) curObj.get("isvalid");
@@ -256,6 +294,196 @@ public class DataImp implements DataService {
         return RequestResult.error("失败!", null);
     }
 
+    @Override
+    public RequestResult getShpFields(String path) {
+        List<String> fields = ShpToSpatiaLite.getShpFields(path);
+        return RequestResult.success("查询成功", fields);
+    }
+
+    @Override
+    public ResponseEntity<InputStreamResource> getTiff(String tiftype, String tableid, String uuid, String filetype) {
+        Connection connection = null;
+        String folderpath = "";
+        try {
+            connection = SpatialiteUtils.getSpatialiteConnection(dbpath);
+            Statement statement = connection.createStatement();
+            String selectSQL = "select path from  t_analyse_vector where id = '" + tableid + "'";
+            ResultSet resultSet = statement.executeQuery(selectSQL);
+            while (resultSet.next()) {
+                folderpath = resultSet.getString("path");
+            }
+            connection.close();
+            if (StringUtils.isEmpty(folderpath)) {
+                return null;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        String filepath = folderpath + "\\" + tiftype + "\\" + uuid + tiftype + "." + filetype;
+        File file = new File(filepath); // 文件路径
+        InputStream tiffInputStream = null;
+        try {
+            tiffInputStream = new FileInputStream(file);
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
+        // 返回 TIFF 数据流
+        HttpHeaders headers = new HttpHeaders();
+        if ("tif".equals(filetype)) {
+            headers.add(HttpHeaders.CONTENT_TYPE, "image/tiff");
+        } else if ("png".equals(filetype)) {
+            headers.add(HttpHeaders.CONTENT_TYPE, "image/png");
+        }
+        headers.add(HttpHeaders.CONTENT_LENGTH, String.valueOf(file.length()));
+        headers.add(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=image.tif");
+        return ResponseEntity.status(HttpStatus.PARTIAL_CONTENT)
+                .headers(headers)
+                .body(new InputStreamResource(tiffInputStream));
+    }
+
+    @Override
+    public RequestResult getImageUrls(String tableid, String uuid) {
+        // 判读前时相数据有没有
+        String qsxfilepath = localFilePath + "\\" + tableid + "\\" + uuid + qsx + ".tif";
+        File file = new File(qsxfilepath);
+        if (!file.exists()) {
+            //执行文件拷贝
+            try {
+                // 指定要创建的目录路径
+                String directoryPath = localFilePath + "\\" + tableid;
+                // 创建File对象
+                File directory = new File(directoryPath);
+                // 如果目录不存在,则创建它
+                if (!directory.exists()) {
+                    boolean result = directory.mkdirs();
+                    if (result) {
+                        System.out.println("目录创建成功:" + directoryPath);
+                    } else {
+                        System.out.println("目录创建失败:" + directoryPath);
+                    }
+                } else {
+                    System.out.println("目录已存在:" + directoryPath);
+                }
+                Connection connection = null;
+                String folderpath = "";
+                connection = SpatialiteUtils.getSpatialiteConnection(dbpath);
+                Statement statement = connection.createStatement();
+                String selectSQL = "select path from  t_analyse_vector where id = '" + tableid + "'";
+                ResultSet resultSet = statement.executeQuery(selectSQL);
+                while (resultSet.next()) {
+                    folderpath = resultSet.getString("path");
+                }
+                connection.close();
+                if (StringUtils.isEmpty(folderpath)) {
+                    return null;
+                }
+                // 前时相
+                Path qsxpath = Paths.get(folderpath + "\\" + qsx + "\\" + uuid + qsx + ".tif");
+                Path qsxtarget = Paths.get(qsxfilepath);
+                Files.copy(qsxpath, qsxtarget, StandardCopyOption.REPLACE_EXISTING);
+                // 后时相
+                Path hsxpath = Paths.get(folderpath + "\\" + hsx + "\\" + uuid + hsx + ".tif");
+                Path hsxtarget = Paths.get(localFilePath + "\\" + tableid + "\\" + uuid + hsx + ".tif");
+                Files.copy(hsxpath, hsxtarget, StandardCopyOption.REPLACE_EXISTING);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        Map res = new HashMap();
+        res.put("qsx", serverhost + ":" + serverport + "/" + localFileProxy + "/" + tableid + "/" + uuid + qsx + ".tif");
+        res.put("hsx", serverhost + ":" + serverport + "/" + localFileProxy + "/" + tableid + "/" + uuid + hsx + ".tif");
+        return RequestResult.success("查询成功!", res);
+    }
+
+    @Override
+    public RequestResult getTableGeoms(String tablename) {
+        try {
+            Connection connection = SpatialiteUtils.getSpatialiteConnection(dbpath);
+            Statement statement = connection.createStatement();
+            String querySQL = "select swid , astext(geom) as geom from  " + tablename;
+            ResultSet resultSet = statement.executeQuery(querySQL);
+            List<Map> res = new ArrayList<Map>();
+            while (resultSet.next()) {
+                Map cur = new HashMap();
+                cur.put("swid", resultSet.getString("swid"));
+                cur.put("geom", resultSet.getString("geom"));
+                res.add(cur);
+            }
+            connection.close();
+            return RequestResult.success("查询成功!", res);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return RequestResult.error("查询失败!", null);
+    }
+
+    @Override
+    public RequestResult getFeatureBySwid(String tablename, String swid) {
+        try {
+            Connection connection = SpatialiteUtils.getSpatialiteConnection(dbpath);
+            Statement statement = connection.createStatement();
+            String querySQL = "select * from  " + tablename + " where swid = '" + swid + "'";
+            ResultSet resultSet = statement.executeQuery(querySQL);
+            ResultSetMetaData metaData = resultSet.getMetaData();
+            int columnCount = metaData.getColumnCount();
+            List<Map> res = new ArrayList<Map>();
+            while (resultSet.next()) {
+                Map cur = new HashMap();
+                for (int i = 1; i <= columnCount; i++) {
+                    if (!"geom".equals(metaData.getColumnName(i))) {
+                        cur.put(metaData.getColumnName(i), resultSet.getObject(i));
+                    }
+                }
+                res.add(cur);
+            }
+            connection.close();
+            return RequestResult.success("查询成功!", res);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return RequestResult.error("查询失败!", null);
+    }
+
+    @Override
+    public RequestResult getTableRecord(String tablename, Integer page, Integer limit) {
+        try {
+            Connection connection = SpatialiteUtils.getSpatialiteConnection(dbpath);
+            Statement statement = connection.createStatement();
+            String querySQL = "select * from  " + tablename + " order by swid LIMIT " + limit + " OFFSET " + ((page - 1) * limit);
+            ResultSet resultSet = statement.executeQuery(querySQL);
+            ResultSetMetaData metaData = resultSet.getMetaData();
+            int columnCount = metaData.getColumnCount();
+            List<Map> res = new ArrayList<Map>();
+            List<String> fields = new ArrayList<>();
+            for (int i = 1; i <= columnCount; i++) {
+                if (!"geom".equals(metaData.getColumnName(i))) {
+                    fields.add(metaData.getColumnName(i));
+                }
+            }
+            while (resultSet.next()) {
+                Map cur = new HashMap();
+                for (int i = 1; i <= columnCount; i++) {
+                    if (!"geom".equals(metaData.getColumnName(i))) {
+                        cur.put(metaData.getColumnName(i), resultSet.getObject(i));
+                    }
+                }
+                res.add(cur);
+            }
+            String countSQL = "select count(1) as count from  " + tablename;
+            ResultSet countSet = statement.executeQuery(countSQL);
+            Integer count = countSet.getInt("count");
+            connection.close();
+            Map<String, Object> result = new HashMap<>();
+            result.put("count", count);
+            result.put("record", res);
+            result.put("fields", fields);
+            return RequestResult.success("查询成功!", result);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return RequestResult.error("查询失败!", null);
+    }
+
     @Override
     public RequestResult basevector() {
         try {
@@ -306,4 +534,23 @@ public class DataImp implements DataService {
     }
 
 
+    public String ExecuteCMD(String command) {
+        String res = "";
+        try {
+            // 执行命令
+            Process process = Runtime.getRuntime().exec(command);
+            // 获取命令输出
+            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
+            String line;
+            while ((line = reader.readLine()) != null) {
+                System.out.println(line); // 输出命令结果
+                res = line;
+            }
+            // 等待命令执行结束
+            process.waitFor();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return res;
+    }
 }

+ 51 - 10
onemap-modules/onemap-overlap/src/main/java/com/onemap/overlap/utils/ShpToSpatiaLite.java

@@ -3,6 +3,8 @@ package com.onemap.overlap.utils;
 import com.onemap.overlap.utils.SpatialiteUtils;
 import org.geotools.data.DataStore;
 import org.geotools.data.DataStoreFinder;
+import org.geotools.data.shapefile.ShapefileDataStore;
+import org.geotools.data.shapefile.ShapefileDataStoreFactory;
 import org.geotools.data.simple.SimpleFeatureCollection;
 import org.geotools.data.simple.SimpleFeatureIterator;
 import org.geotools.feature.simple.SimpleFeatureBuilder;
@@ -15,14 +17,18 @@ import org.opengis.filter.Filter;
 import org.springframework.beans.factory.annotation.Value;
 
 import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.sql.Statement;
-import java.util.Collections;
+import java.util.*;
 
 public class ShpToSpatiaLite {
 
+    @Value("${swid}")
+    static String swid;
 //    public static void main(String[] args) throws Exception {
 //        String shapefilePath = "D:\\temp\\ccs.shp";
 //        String spatialiteDbPath = "D:\\temp\\mappatchcheck.sqlite";
@@ -53,7 +59,7 @@ public class ShpToSpatiaLite {
      * @return
      * @throws Exception
      */
-    public static Boolean ImportShpToSpatialite(String dbpath, String shppath, Integer wkid, String tablename) {
+    public static Boolean ImportShpToSpatialite(String dbpath, String shppath, Integer wkid, String tablename, String ufield) {
         Connection conn = null;
         try {
             String shapefilePath = shppath;
@@ -63,19 +69,22 @@ public class ShpToSpatiaLite {
             // TODO 2. 解析 Shapefile 数据
             File shapefile = new File(shapefilePath);
             DataStore dataStore = DataStoreFinder.getDataStore(Collections.singletonMap("url", shapefile.toURI().toURL()));
-            String typeName = dataStore.getTypeNames()[0];  // 获取第一个图层的名称
-            SimpleFeatureCollection featureCollection = dataStore.getFeatureSource(typeName).getFeatures();
+            ShapefileDataStore shapefileDataStore = (ShapefileDataStore) dataStore;
+            // 设置字符编码为 GBK,避免乱码
+            shapefileDataStore.setCharset(Charset.forName("GBK"));
+            String typeName = shapefileDataStore.getTypeNames()[0];  // 获取第一个图层的名称
+            SimpleFeatureCollection featureCollection = shapefileDataStore.getFeatureSource(typeName).getFeatures();
             //TODO  3. 创建表结构
-            createSpatialTable(conn, tablename, featureCollection);
+            createSpatialTable(conn, tablename, featureCollection, ufield);
             // TODO 4. 遍历每个要素并插入数据
-            insertFeaturesToSpatialite(conn, featureCollection, tablename, wkid);
+            insertFeaturesToSpatialite(conn, featureCollection, tablename, wkid, ufield);
             // TODO 5. 为几何字段创建空间索引
             createSpatialIndex(conn, tablename);
             // TODO 6. 关闭数据库连接
             conn.close();
             return true;
-        }catch (Exception e){
-            if (conn != null){
+        } catch (Exception e) {
+            if (conn != null) {
                 //conn.close();
             }
             e.printStackTrace();
@@ -83,8 +92,34 @@ public class ShpToSpatiaLite {
         }
     }
 
+    /**
+     * 获取shp文件字段集合
+     *
+     * @param shppath shp文件路径
+     * @return
+     * @throws Exception
+     */
+    public static List<String> getShpFields(String shppath) {
+        List<String> fields = new ArrayList<>();
+        try {
+            File shapefile = new File(shppath);
+            ShapefileDataStore dataStore = null;
+            dataStore = (ShapefileDataStore) DataStoreFinder.getDataStore(Collections.singletonMap("url", shapefile.toURI().toURL()));
+            // 设置字符编码为 GBK,避免乱码
+            dataStore.setCharset(Charset.forName("GBK"));
+            SimpleFeatureType featureType = dataStore.getSchema();
+            for (int i = 0; i < featureType.getAttributeCount(); i++) {
+                String fieldName = featureType.getDescriptor(i).getName().getLocalPart();
+                fields.add(fieldName);
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return fields;
+    }
+
     // 3. 创建空间表结构
-    public static void createSpatialTable(Connection conn, String tableName, SimpleFeatureCollection featureCollection) throws SQLException {
+    public static void createSpatialTable(Connection conn, String tableName, SimpleFeatureCollection featureCollection, String ufield) throws SQLException {
         SimpleFeatureType featureType = featureCollection.getSchema();
         StringBuilder createTableSQL = new StringBuilder();
         Statement stmt = conn.createStatement();
@@ -108,6 +143,8 @@ public class ShpToSpatiaLite {
             }
             createTableSQL.append(fieldName).append(" ").append(fieldType).append(",");
         }
+        // 添加swid
+        createTableSQL.append("swid TEXT").append(",");
         // 添加几何列
         createTableSQL.append("geom GEOMETRY");
         createTableSQL.append(");");
@@ -116,7 +153,7 @@ public class ShpToSpatiaLite {
     }
 
     // 4. 遍历要素并插入数据
-    public static void insertFeaturesToSpatialite(Connection conn, SimpleFeatureCollection featureCollection, String tableName, Integer wkid) throws SQLException {
+    public static void insertFeaturesToSpatialite(Connection conn, SimpleFeatureCollection featureCollection, String tableName, Integer wkid, String ufield) throws SQLException {
         StringBuilder fields = new StringBuilder();
         Statement stmt = conn.createStatement();
         SimpleFeatureType featureType = featureCollection.getSchema();
@@ -127,6 +164,7 @@ public class ShpToSpatiaLite {
             }
             fields.append(fieldName).append(",");
         }
+        fields.append("swid").append(",");
         // 去除末尾的逗号
         fields.append("geom");
         // 遍历所有要素
@@ -143,6 +181,9 @@ public class ShpToSpatiaLite {
                 Object value = feature.getAttribute(i);
                 current.append("'" + value + "'").append(",");
             }
+            //swid处理
+            Object value = feature.getAttribute(ufield);
+            current.append("'" + value + "'").append(",");
             Object geometry = feature.getDefaultGeometry();
             String sql = "INSERT INTO " + tableName + " (" + fields.toString() + ") VALUES (" + current.toString() + "GeomFromText('" + geometry + "', " + wkid + "))";
             stmt.executeUpdate(sql);

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

@@ -0,0 +1,36 @@
+package com.onemap.overlap.utils;
+
+import javafx.application.Application;
+import javafx.application.Platform;
+import javafx.scene.Scene;
+import javafx.scene.layout.StackPane;
+import javafx.scene.web.WebView;
+import javafx.stage.Stage;
+
+public class WebViewExample extends Application {
+
+    @Override
+    public void start(Stage primaryStage) {
+        // 创建 WebView
+        WebView webView = new WebView();
+        // 加载 Web 页面
+        webView.getEngine().load("http://127.0.0.1:9206");
+
+        // 布局
+        StackPane root = new StackPane();
+        root.getChildren().add(webView);
+
+        // 设置场景和舞台
+        Scene scene = new Scene(root, 1200, 800);
+        primaryStage.setTitle("图斑套合分析工具");
+        primaryStage.setScene(scene);
+        primaryStage.show();
+    }
+
+    public static void launchApplication(String[] args) {
+        //Platform.runLater(() -> {
+        // 启动 JavaFX 应用,确保它在 JavaFX 的主线程中运行
+        launch(args);
+        //});
+    }
+}

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

@@ -1,5 +1,10 @@
 # spring配置
 spring:
+  mvc:
+    async:
+      request-timeout: 999999999
+  resources:
+    static-locations: classpath:/static/
   redis:
     host: localhost
     port: 6379
@@ -7,6 +12,7 @@ spring:
 # tomcat配置
 server:
   port: 9206
+  host: http://127.0.0.1
 # swagger配置
 swagger:
   title: 系统模块接口文档
@@ -17,6 +23,18 @@ spatialite:
   filePath: D:\temp\mappatchcheck.sqlite
 # 文件路径配置
 file:
+  # 静态资源路径
   temp: D:\temp\
+  # 代理的服务名称
+  proxy: file
+  # 默认数据坐标系
   wkid: 4525
-  prefix: sw_
+  # 入库的表前缀名
+  prefix: sw_
+# 前后影像标识符
+image:
+  qsx: QDOM
+  hsx: DDOM
+# 入库到SpatiaLite数据库中的唯一属性字段
+swid: swid
+qgis: D:\Program Files\QGIS 3.34.9\bin\

+ 0 - 42
onemap-modules/onemap-overlap/src/main/resources/bootstrap.yml

@@ -1,42 +0,0 @@
-#Feign Client配置
-feign:
-  client:
-    config:
-      FooClient: #contextId
-        connectTimeout: 1000000
-        readTimeout: 2000000
-      default:
-        connectTimeout: 6000000
-        readTimeout: 1000000
-# Tomcat
-server:
-  port: 9206
-
-# Spring
-spring:
-  servlet:
-    multipart:
-      enabled: true
-      max-file-size: 10240MB
-      max-request-size: 10240MB
-  application:
-    # 应用名称
-    name: onemap-overlap
-  profiles:
-    # 环境配置
-    active: dev
-  cloud:
-    nacos:
-      discovery:
-        namespace: spot
-        # 服务注册地址
-        server-addr: 127.0.0.1:8848
-      config:
-        namespace: spot
-        # 配置中心地址
-        server-addr: 127.0.0.1:8848
-        # 配置文件格式
-        file-extension: yml
-        # 共享配置
-        shared-configs:
-          - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}