Преглед изворни кода

场景添加抗锯齿,优化SHP图层上传和展示

WQQ пре 2 дана
родитељ
комит
6ae567f8b8
32 измењених фајлова са 157 додато и 44 уклоњено
  1. 1 0
      RuoYi-Vue3/src/supermap-cesium-module/components/viewer/viewer.js
  2. 23 1
      RuoYi-Vue3/src/supermap-cesium-module/js/common/layerManagement.js
  3. 20 24
      RuoYi-Vue3/src/supermap-cesium-module/views/layout/aside.vue
  4. 48 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/watershed/WatershedServiceController.java
  5. BIN
      ruoyi-admin/target/classes/com/ruoyi/web/controller/watershed/WatershedServiceController.class
  6. 0 0
      ruoyi-admin/uploads/models/geojson/28bde72dd24946448f8607da98e9b137.geojson
  7. BIN
      ruoyi-admin/uploads/models/geojson/28bde72dd24946448f8607da98e9b137/河道管理范围.dbf
  8. 0 1
      ruoyi-admin/uploads/models/geojson/28bde72dd24946448f8607da98e9b137/河道管理范围.prj
  9. BIN
      ruoyi-admin/uploads/models/geojson/28bde72dd24946448f8607da98e9b137/河道管理范围.shp
  10. BIN
      ruoyi-admin/uploads/models/geojson/28bde72dd24946448f8607da98e9b137/河道管理范围.shx
  11. 0 0
      ruoyi-admin/uploads/models/geojson/2996a06fc50c453aa337961cb3e33e11.geojson
  12. BIN
      ruoyi-admin/uploads/models/geojson/2996a06fc50c453aa337961cb3e33e11/水闸.dbf
  13. 0 1
      ruoyi-admin/uploads/models/geojson/2996a06fc50c453aa337961cb3e33e11/水闸.prj
  14. BIN
      ruoyi-admin/uploads/models/geojson/2996a06fc50c453aa337961cb3e33e11/水闸.shp
  15. BIN
      ruoyi-admin/uploads/models/geojson/2996a06fc50c453aa337961cb3e33e11/水闸.shx
  16. 0 1
      ruoyi-admin/uploads/models/geojson/9371a64443544a46affdade359485bdd.geojson
  17. BIN
      ruoyi-admin/uploads/models/geojson/9371a64443544a46affdade359485bdd/水闸.dbf
  18. 0 1
      ruoyi-admin/uploads/models/geojson/9371a64443544a46affdade359485bdd/水闸.prj
  19. BIN
      ruoyi-admin/uploads/models/geojson/9371a64443544a46affdade359485bdd/水闸.shp
  20. BIN
      ruoyi-admin/uploads/models/geojson/9371a64443544a46affdade359485bdd/水闸.shx
  21. 0 3
      ruoyi-common/target/maven-archiver/pom.properties
  22. BIN
      ruoyi-common/target/ruoyi-common-3.9.1.jar
  23. 0 3
      ruoyi-framework/target/maven-archiver/pom.properties
  24. BIN
      ruoyi-framework/target/ruoyi-framework-3.9.1.jar
  25. 0 3
      ruoyi-generator/target/maven-archiver/pom.properties
  26. BIN
      ruoyi-generator/target/ruoyi-generator-3.9.1.jar
  27. 0 3
      ruoyi-quartz/target/maven-archiver/pom.properties
  28. BIN
      ruoyi-quartz/target/ruoyi-quartz-3.9.1.jar
  29. 65 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WatershedServiceServiceImpl.java
  30. BIN
      ruoyi-system/target/classes/com/ruoyi/system/service/impl/WatershedServiceServiceImpl.class
  31. 0 3
      ruoyi-system/target/maven-archiver/pom.properties
  32. BIN
      ruoyi-system/target/ruoyi-system-3.9.1.jar

+ 1 - 0
RuoYi-Vue3/src/supermap-cesium-module/components/viewer/viewer.js

@@ -72,6 +72,7 @@ function initViewer(props, callback) {
   }
 
   viewer.scene.debugShowFramesPerSecond = true; //帧率
+  viewer.scene.msaaSamples = 4; // 开启4倍抗锯齿
   viewer.scene.globe.baseColor = Cesium.Color.BLACK; // 没有影像图层时地球的底色
   // viewer.scene.globe.depthTestAgainstTerrain = false; //地形深度
   

+ 23 - 1
RuoYi-Vue3/src/supermap-cesium-module/js/common/layerManagement.js

@@ -261,14 +261,36 @@ function layersDelete(type, id_name, callback) {
             break;
         case "GEOJSON":
         case "SHP":
+            console.log('开始删除GEOJSON/SHP图层, id_name:', id_name);
             if (viewer.dataSources) {
                 const dataSources = viewer.dataSources._dataSources;
+                console.log('当前数据源数量:', dataSources.length);
+                let removed = false;
                 for (let i = dataSources.length - 1; i >= 0; i--) {
                     const ds = dataSources[i];
-                    if (ds.name === id_name || ds._name === id_name) {
+                    console.log('检查数据源:', i, 'name:', ds.name, '_name:', ds._name);
+                    if (ds.name === id_name || ds._name === id_name || 
+                        (ds.name && ds.name.includes(id_name)) || 
+                        (ds._name && ds._name.includes(id_name))) {
+                        console.log('匹配到数据源,删除:', ds.name);
                         viewer.dataSources.remove(ds);
+                        removed = true;
                         break;
                     }
+                    const entities = ds.entities ? ds.entities.values : [];
+                    for (let j = 0; j < entities.length; j++) {
+                        const entity = entities[j];
+                        if (entity.name === id_name || (entity.name && entity.name.includes(id_name))) {
+                            console.log('通过entity匹配到数据源,删除:', ds.name);
+                            viewer.dataSources.remove(ds);
+                            removed = true;
+                            break;
+                        }
+                    }
+                    if (removed) break;
+                }
+                if (!removed) {
+                    console.warn('未找到匹配的数据源:', id_name);
                 }
             }
             actions.setChangeLayers();

+ 20 - 24
RuoYi-Vue3/src/supermap-cesium-module/views/layout/aside.vue

@@ -1393,38 +1393,39 @@ export default {
       const serviceId = service.id || service.serviceId;
       const serviceType = service.type || 'SCENE';
       
+      const finishUnload = () => {
+        const idx = this.loadedCustomServiceIds.indexOf(serviceId);
+        if (idx > -1) {
+          this.loadedCustomServiceIds.splice(idx, 1);
+          console.log('已从loadedCustomServiceIds中移除服务:', serviceId);
+        }
+        window.store.actions.setChangeLayers();
+        this.saveLoadedServices();
+        this.$forceUpdate();
+      };
+      
       if (serviceType === 'SCENE' && service.loadedLayerNames && service.loadedLayerNames.length > 0) {
         console.log('使用loadedLayerNames卸载SCENE图层:', service.loadedLayerNames);
+        let unloadedCount = 0;
         service.loadedLayerNames.forEach((layerName, index) => {
           console.log('卸载图层:', layerName);
-          const isLast = index === service.loadedLayerNames.length - 1;
           layerManagement.layersDelete('S3M', layerName, () => {
             console.log('图层已卸载:', layerName);
-            if (isLast) {
-              const idx = this.loadedCustomServiceIds.indexOf(serviceId);
-              if (idx > -1) {
-                this.loadedCustomServiceIds.splice(idx, 1);
-                console.log('已从loadedCustomServiceIds中移除服务:', serviceId);
-              }
-              window.store.actions.setChangeLayers();
-              this.saveLoadedServices();
+            unloadedCount++;
+            if (unloadedCount === service.loadedLayerNames.length) {
+              finishUnload();
             }
           });
         });
       } else if (service.layers && service.layers.length > 0) {
+        let unloadedCount = 0;
         service.layers.forEach((layer, index) => {
           console.log('卸载图层:', layer.type, layer.layerName);
-          const isLast = index === service.layers.length - 1;
           layerManagement.layersDelete(layer.type, layer.layerName, () => {
             console.log('图层已卸载:', layer.layerName);
-            if (isLast) {
-              const idx = this.loadedCustomServiceIds.indexOf(serviceId);
-              if (idx > -1) {
-                this.loadedCustomServiceIds.splice(idx, 1);
-                console.log('已从loadedCustomServiceIds中移除服务:', serviceId);
-              }
-              window.store.actions.setChangeLayers();
-              this.saveLoadedServices();
+            unloadedCount++;
+            if (unloadedCount === service.layers.length) {
+              finishUnload();
             }
           });
         });
@@ -1434,12 +1435,7 @@ export default {
         console.log('卸载参数 - serviceId:', serviceId, 'type:', type, 'layerName:', layerName);
         layerManagement.layersDelete(type, layerName, () => {
           console.log('服务已卸载:', service.name);
-          const idx = this.loadedCustomServiceIds.indexOf(serviceId);
-          if (idx > -1) {
-            this.loadedCustomServiceIds.splice(idx, 1);
-          }
-          window.store.actions.setChangeLayers();
-          this.saveLoadedServices();
+          finishUnload();
         });
       }
     },

+ 48 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/watershed/WatershedServiceController.java

@@ -1,5 +1,6 @@
 package com.ruoyi.web.controller.watershed;
 
+import java.io.File;
 import java.util.List;
 import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
@@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.enums.BusinessType;
@@ -116,6 +118,52 @@ public class WatershedServiceController extends BaseController
     @DeleteMapping("/{serviceIds}")
     public AjaxResult remove(@PathVariable Long[] serviceIds)
     {
+        System.out.println("========== WatershedServiceController.remove called, serviceIds=" + java.util.Arrays.toString(serviceIds));
+        
+        for (Long serviceId : serviceIds) {
+            WatershedService service = watershedServiceService.selectWatershedServiceByServiceId(serviceId);
+            System.out.println("========== 删除服务: " + service);
+            if (service != null && service.getServiceUrl() != null) {
+                String serviceUrl = service.getServiceUrl();
+                System.out.println("========== 删除服务URL: " + serviceUrl);
+                
+                if (serviceUrl.contains("/profile/geojson/")) {
+                    String basePath = RuoYiConfig.getProfile();
+                    System.out.println("========== basePath: " + basePath);
+                    
+                    String geojsonPath = serviceUrl.replace("/profile/", "");
+                    String geojsonFullPath = basePath + File.separator + geojsonPath.replace("/", File.separator);
+                    System.out.println("========== geojsonFullPath: " + geojsonFullPath);
+                    
+                    File geojsonFile = new File(geojsonFullPath);
+                    if (geojsonFile.exists()) {
+                        boolean deleted = geojsonFile.delete();
+                        System.out.println("========== GeoJSON文件删除" + (deleted ? "成功: " : "失败: ") + geojsonFullPath);
+                    } else {
+                        System.out.println("========== GeoJSON文件不存在: " + geojsonFullPath);
+                    }
+                    
+                    String uuid = geojsonPath.replace("geojson", "").replace(".geojson", "").replace("/", "");
+                    String shpDirPath = basePath + File.separator + "geojson" + File.separator + uuid;
+                    System.out.println("========== shpDirPath: " + shpDirPath);
+                    
+                    File shpDir = new File(shpDirPath);
+                    if (shpDir.exists() && shpDir.isDirectory()) {
+                        File[] files = shpDir.listFiles();
+                        if (files != null) {
+                            for (File file : files) {
+                                file.delete();
+                            }
+                        }
+                        boolean deleted = shpDir.delete();
+                        System.out.println("========== SHP文件夹删除" + (deleted ? "成功: " : "失败: ") + shpDirPath);
+                    } else {
+                        System.out.println("========== SHP文件夹不存在: " + shpDirPath);
+                    }
+                }
+            }
+        }
+        
         return toAjax(watershedServiceService.deleteWatershedServiceByServiceIds(serviceIds));
     }
 }

BIN
ruoyi-admin/target/classes/com/ruoyi/web/controller/watershed/WatershedServiceController.class


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
ruoyi-admin/uploads/models/geojson/28bde72dd24946448f8607da98e9b137.geojson


BIN
ruoyi-admin/uploads/models/geojson/28bde72dd24946448f8607da98e9b137/河道管理范围.dbf


+ 0 - 1
ruoyi-admin/uploads/models/geojson/28bde72dd24946448f8607da98e9b137/河道管理范围.prj

@@ -1 +0,0 @@
-GEOGCS["GCS_China_Geodetic_Coordinate_System_2000",DATUM["D_China_2000",SPHEROID["CGCS2000",6378137.0,298.257222101004]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]

BIN
ruoyi-admin/uploads/models/geojson/28bde72dd24946448f8607da98e9b137/河道管理范围.shp


BIN
ruoyi-admin/uploads/models/geojson/28bde72dd24946448f8607da98e9b137/河道管理范围.shx


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
ruoyi-admin/uploads/models/geojson/2996a06fc50c453aa337961cb3e33e11.geojson


BIN
ruoyi-admin/uploads/models/geojson/2996a06fc50c453aa337961cb3e33e11/水闸.dbf


+ 0 - 1
ruoyi-admin/uploads/models/geojson/2996a06fc50c453aa337961cb3e33e11/水闸.prj

@@ -1 +0,0 @@
-GEOGCS["GCS_China_Geodetic_Coordinate_System_2000",DATUM["D_China_2000",SPHEROID["CGCS2000",6378137.0,298.257222101004]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]

BIN
ruoyi-admin/uploads/models/geojson/2996a06fc50c453aa337961cb3e33e11/水闸.shp


BIN
ruoyi-admin/uploads/models/geojson/2996a06fc50c453aa337961cb3e33e11/水闸.shx


+ 0 - 1
ruoyi-admin/uploads/models/geojson/9371a64443544a46affdade359485bdd.geojson

@@ -1 +0,0 @@
-{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[0.0,0.0]},"properties":{"id":1}}]}

BIN
ruoyi-admin/uploads/models/geojson/9371a64443544a46affdade359485bdd/水闸.dbf


+ 0 - 1
ruoyi-admin/uploads/models/geojson/9371a64443544a46affdade359485bdd/水闸.prj

@@ -1 +0,0 @@
-GEOGCS["GCS_China_Geodetic_Coordinate_System_2000",DATUM["D_China_2000",SPHEROID["CGCS2000",6378137.0,298.257222101004]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]

BIN
ruoyi-admin/uploads/models/geojson/9371a64443544a46affdade359485bdd/水闸.shp


BIN
ruoyi-admin/uploads/models/geojson/9371a64443544a46affdade359485bdd/水闸.shx


+ 0 - 3
ruoyi-common/target/maven-archiver/pom.properties

@@ -1,3 +0,0 @@
-artifactId=ruoyi-common
-groupId=com.ruoyi
-version=3.9.1

BIN
ruoyi-common/target/ruoyi-common-3.9.1.jar


+ 0 - 3
ruoyi-framework/target/maven-archiver/pom.properties

@@ -1,3 +0,0 @@
-artifactId=ruoyi-framework
-groupId=com.ruoyi
-version=3.9.1

BIN
ruoyi-framework/target/ruoyi-framework-3.9.1.jar


+ 0 - 3
ruoyi-generator/target/maven-archiver/pom.properties

@@ -1,3 +0,0 @@
-artifactId=ruoyi-generator
-groupId=com.ruoyi
-version=3.9.1

BIN
ruoyi-generator/target/ruoyi-generator-3.9.1.jar


+ 0 - 3
ruoyi-quartz/target/maven-archiver/pom.properties

@@ -1,3 +0,0 @@
-artifactId=ruoyi-quartz
-groupId=com.ruoyi
-version=3.9.1

BIN
ruoyi-quartz/target/ruoyi-quartz-3.9.1.jar


+ 65 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WatershedServiceServiceImpl.java

@@ -1,6 +1,8 @@
 package com.ruoyi.system.service.impl;
 
+import java.io.File;
 import java.util.List;
+import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -92,6 +94,8 @@ public class WatershedServiceServiceImpl implements IWatershedService
     @Override
     public int deleteWatershedServiceByServiceId(Long serviceId)
     {
+        System.out.println("===== deleteWatershedServiceByServiceId called, serviceId=" + serviceId);
+        deleteServiceFiles(serviceId);
         return watershedServiceMapper.deleteWatershedServiceByServiceId(serviceId);
     }
 
@@ -104,6 +108,67 @@ public class WatershedServiceServiceImpl implements IWatershedService
     @Override
     public int deleteWatershedServiceByServiceIds(Long[] serviceIds)
     {
+        System.out.println("===== deleteWatershedServiceByServiceIds called, serviceIds=" + java.util.Arrays.toString(serviceIds));
+        for (Long serviceId : serviceIds) {
+            deleteServiceFiles(serviceId);
+        }
         return watershedServiceMapper.deleteWatershedServiceByServiceIds(serviceIds);
     }
+    
+    /**
+     * 删除自定义服务对应的本地文件
+     * 
+     * @param serviceId 自定义服务主键
+     */
+    private void deleteServiceFiles(Long serviceId)
+    {
+        System.out.println("========== deleteServiceFiles START, serviceId=" + serviceId);
+        try {
+            WatershedService service = watershedServiceMapper.selectWatershedServiceByServiceId(serviceId);
+            System.out.println("========== deleteServiceFiles, service=" + service);
+            if (service != null && service.getServiceUrl() != null) {
+                String serviceUrl = service.getServiceUrl();
+                System.out.println("========== deleteServiceFiles, serviceUrl=" + serviceUrl);
+                
+                if (serviceUrl.contains("/profile/geojson/")) {
+                    String basePath = RuoYiConfig.getProfile();
+                    System.out.println("========== deleteServiceFiles, basePath=" + basePath);
+                    
+                    String geojsonPath = serviceUrl.replace("/profile/", "");
+                    String geojsonFullPath = basePath + File.separator + geojsonPath;
+                    System.out.println("========== deleteServiceFiles, geojsonFullPath=" + geojsonFullPath);
+                    
+                    File geojsonFile = new File(geojsonFullPath);
+                    if (geojsonFile.exists()) {
+                        boolean deleted = geojsonFile.delete();
+                        System.out.println("========== GeoJSON文件删除" + (deleted ? "成功: " : "失败: ") + geojsonFullPath);
+                    } else {
+                        System.out.println("========== GeoJSON文件不存在: " + geojsonFullPath);
+                    }
+                    
+                    String uuid = geojsonPath.replace("geojson", "").replace(".geojson", "").replace("/", "");
+                    String shpDirPath = basePath + File.separator + "geojson" + File.separator + uuid;
+                    System.out.println("========== deleteServiceFiles, shpDirPath=" + shpDirPath);
+                    
+                    File shpDir = new File(shpDirPath);
+                    if (shpDir.exists() && shpDir.isDirectory()) {
+                        File[] files = shpDir.listFiles();
+                        if (files != null) {
+                            for (File file : files) {
+                                file.delete();
+                            }
+                        }
+                        boolean deleted = shpDir.delete();
+                        System.out.println("========== SHP文件夹删除" + (deleted ? "成功: " : "失败: ") + shpDirPath);
+                    } else {
+                        System.out.println("========== SHP文件夹不存在: " + shpDirPath);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            System.err.println("========== 删除本地文件时出错: " + e.getMessage());
+            e.printStackTrace();
+        }
+        System.out.println("========== deleteServiceFiles END");
+    }
 }

BIN
ruoyi-system/target/classes/com/ruoyi/system/service/impl/WatershedServiceServiceImpl.class


+ 0 - 3
ruoyi-system/target/maven-archiver/pom.properties

@@ -1,3 +0,0 @@
-artifactId=ruoyi-system
-groupId=com.ruoyi
-version=3.9.1

BIN
ruoyi-system/target/ruoyi-system-3.9.1.jar


Неке датотеке нису приказане због велике количине промена