From 2fcbeffa30bc674cffdd0147da271754468073a3 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期六, 02 九月 2023 10:58:06 +0800
Subject: [PATCH] 修改发布服务控制器-1

---
 src/main/java/com/moon/server/service/data/PublishService.java       |   55 +------------
 src/main/java/com/moon/server/service/data/ShuJianService.java       |   51 ++++++++++--
 src/main/java/com/moon/server/controller/data/PublishController.java |  125 ++++---------------------------
 src/main/resources/application.yml                                   |    9 +-
 4 files changed, 69 insertions(+), 171 deletions(-)

diff --git a/src/main/java/com/moon/server/controller/data/PublishController.java b/src/main/java/com/moon/server/controller/data/PublishController.java
index e0d15fe..9bc4efc 100644
--- a/src/main/java/com/moon/server/controller/data/PublishController.java
+++ b/src/main/java/com/moon/server/controller/data/PublishController.java
@@ -61,7 +61,7 @@
                 return fail("鏁版嵁绫诲埆涓虹┖", null);
             }
 
-            String types = getType(dircode, type);
+            String types = getType(type);
             int count = publishService.selectMetasByCount(depcode, dircode, verid, types, name);
             if (count == 0) {
                 return success(0, null);
@@ -78,55 +78,19 @@
     /**
      * 鑾峰彇绫诲瀷
      */
-    private String getType(String dircode, String type) throws Exception {
+    private String getType(String type) throws Exception {
         switch (type) {
             case "DOM":
-                return "type in ('tif', 'tiff', 'img')" + getFilter(dircode, type);
+                return "type in ('tif', 'tiff', 'img', 'jp2', 'jpg') and mata_type in (1, 3, 4, 5)";
             case "DEM":
-                return "type in ('tif', 'tiff')" + getFilter(dircode, type);
-            case "MPT":
-                return "type = 'mpt'";
-            case "3DML":
-                return "type = '3dml'";
-            case "CPT":
-                return "type = 'cpt'";
-            case "BIM":
-                return "type in ('ifc', 'fbx', 'rvt')";
-            case "LAS":
-                return "type in ('las', 'laz')";
-            case "OSGB":
-                return "type = 'osgb'";
+                return "type in ('tif', 'tiff', 'dem') and mata_type = 2";
+            case "Vector":
+                return "type in ('shp', 'gdb') and mata_type = 6";
+            case "Model":
+                return "type in ('ifc', 'gdb') and mata_type = 7";
             default:
                 throw new Exception("鏁版嵁绫诲瀷涓嶅尮閰�");
         }
-    }
-
-    /**
-     * 鑾峰彇杩囨护鏉′欢
-     */
-    private String getFilter(String dircode, String type) {
-        dircode = StringHelper.isEmpty(dircode) ? "" : StringHelper.getRightLike(dircode);
-
-        List<String> list = null;
-        switch (type) {
-            case "DOM":
-                list = publishService.selectCodesForDir(dircode, 0);
-                break;
-            case "DEM":
-                list = publishService.selectCodesForDir(dircode, 1);
-                break;
-            default:
-                break;
-        }
-        if (null == list || list.isEmpty()) {
-            return "";
-        }
-
-        for (int i = 0, c = list.size(); i < c; i++) {
-            list.set(i, "'" + list.get(i) + "'");
-        }
-
-        return " and dircode not in (" + StringHelper.join(list, ",") + ")";
     }
 
     @SysLog()
@@ -162,7 +126,7 @@
     /**
      * 鑾峰彇鍙戝竷绫诲瀷
      */
-    private String getPubType(String type) {
+    private String getPubType(String type) throws Exception {
         if (StringHelper.isEmpty(type)) {
             return null;
         }
@@ -172,20 +136,12 @@
                 return "type = 'DOM'";
             case "DEM":
                 return "type = 'DEM'";
-            case "MPT":
-                return "type = 'mpt'";
-            case "3DML":
-                return "type = '3dml'";
-            case "CPT":
-                return "type = 'cpt'";
-            case "BIM":
-                return "type in ('ifc', 'fbx', 'rvt')";
-            case "LAS":
-                return "type in ('las', 'laz')";
-            case "OSGB":
-                return "type = 'osgb'";
+            case "Vector":
+                return "type = 'Vector'";
+            case "Model":
+                return "type = 'Model'";
             default:
-                return null;
+                throw new Exception("鏁版嵁绫诲瀷涓嶅尮閰�");
         }
     }
 
@@ -200,31 +156,6 @@
             PublishEntity entity = publishService.selectById(id);
 
             return success(entity);
-        } catch (Exception ex) {
-            return fail(ex.getMessage(), null);
-        }
-    }
-
-    @SysLog()
-    @ApiOperation(value = "鏌ヨLas鏂囦欢鍧愭爣绯籌D")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "ids", value = "鍏冩暟鎹甀D闆嗗悎", dataType = "Integer[]", paramType = "query", example = "10483,10481,10456,10285")
-    })
-    @GetMapping(value = "/selectLasCs")
-    public ResponseMsg<Object> selectLasCs(Integer[] ids, HttpServletRequest req) {
-        try {
-            if (null == ids || ids.length == 0) {
-                return fail("鍏冩暟鎹甀D闆嗗悎涓嶈兘涓虹┖");
-            }
-
-            PubEntity entity = new PubEntity();
-            entity.setIds(Arrays.asList(ids));
-            entity.setDircode("00");
-            entity.setToken(WebHelper.getToken(req));
-
-            List<Integer> list = publishService.selectLasCs(entity, "/Convert/ReadLasCs", req);
-
-            return success(list);
         } catch (Exception ex) {
             return fail(ex.getMessage(), null);
         }
@@ -252,36 +183,12 @@
             }
 
             permsService.clearPermsCache();
-            String method = getConvertMethod(entity.getType());
-            long count = publishService.postForPub(entity, method, req);
+            // String method = getConvertMethod(entity.getType())
+            long count = publishService.postForPub(entity, "", req);
 
             return success(count);
         } catch (Exception ex) {
             return fail(ex.getMessage(), -1);
-        }
-    }
-
-    /**
-     * 鑾峰彇杞崲鏂规硶
-     */
-    private String getConvertMethod(String type) throws Exception {
-        switch (type) {
-            case "DOM":
-                return "/Convert/ToTiles";
-            case "DEM":
-                return "/Convert/ToTerra";
-            case "MPT":
-            case "3DML":
-            case "CPT":
-                return "/Convert/ToSG";
-            case "BIM":
-                return "/Convert/ToTileset";
-            case "LAS":
-                return "/Convert/ToLasByPy";
-            case "OSGB":
-                return "/Convert/ToOsgb";
-            default:
-                throw new Exception("鏁版嵁绫诲瀷涓嶅尮閰�");
         }
     }
 
diff --git a/src/main/java/com/moon/server/service/data/PublishService.java b/src/main/java/com/moon/server/service/data/PublishService.java
index 7b6bed4..8c49fef 100644
--- a/src/main/java/com/moon/server/service/data/PublishService.java
+++ b/src/main/java/com/moon/server/service/data/PublishService.java
@@ -9,9 +9,7 @@
 import com.moon.server.helper.PathHelper;
 import com.moon.server.helper.RestHelper;
 import com.moon.server.helper.StringHelper;
-import com.moon.server.helper.WebHelper;
 import com.moon.server.mapper.data.PublishMapper;
-import com.moon.server.service.sys.TokenService;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.beans.factory.annotation.Value;
@@ -19,7 +17,6 @@
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
-import java.io.File;
 import java.lang.reflect.Field;
 import java.util.HashMap;
 import java.util.List;
@@ -34,14 +31,11 @@
     @Value("${sys.exportServer}")
     private String exportServer;
 
-    @Value("${sys.iisHost}")
-    private String iisHost;
-
     @Resource
     PublishMapper publishMapper;
 
     @Resource
-    PathHelper pathHelper;
+    ShuJianService shuJianService;
 
     private final static Log log = LogFactory.getLog(PublishService.class);
 
@@ -134,27 +128,6 @@
         return publishMapper.selectMetasByPage(depcode, dircode, verid, types, name, limit, offset);
     }
 
-    public List<Integer> selectLasCs(PubEntity entity, String method, HttpServletRequest req) {
-        Map<String, Object> map = getMapData(entity);
-
-        String str = RestHelper.postForRest(exportServer + method, map);
-        if (StringHelper.isEmpty(str)) {
-            return null;
-        }
-
-        ResponseMsg<String> msg = JSON.parseObject(str, ResponseMsg.class);
-        if (msg == null || msg.getCode() != StaticData.TWO_HUNDRED) {
-            return null;
-        }
-
-        String rs = msg.getResult();
-        if (StringHelper.isEmpty(rs)) {
-            return null;
-        }
-
-        return StringHelper.strToIntegers(rs);
-    }
-
     /**
      * 鍙戦�佸彂甯冭姹�
      */
@@ -225,28 +198,12 @@
     public Integer deletes(List<Integer> idList, HttpServletRequest req) {
         String ids = StringHelper.join(idList, ",");
 
-        return deletes(ids);
-    }
-
-    /**
-     * 鍒犻櫎鍙戝竷鏂囦欢
-     */
-    public void deleteFiles(List<PublishEntity> list) {
-        String lfData = pathHelper.getConfig().getLfData();
-        for (PublishEntity pub : list) {
-            if (null != pub.getUrl() && pub.getUrl().contains("/SG/")) {
-                continue;
-            }
-
-            String path = lfData + pub.getPath().replace("\\tileset.json", "");
-            File file = new File(path);
-            if (!file.exists() || !file.isDirectory()) {
-                continue;
-            }
-
-            String cmd = String.format("cmd /c rd \"%s\" /s /q", path);
-            WebHelper.exec(cmd);
+        List<PublishEntity> list = selectByIds(ids);
+        for (PublishEntity entity : list) {
+            shuJianService.deleteServe(entity);
         }
+
+        return deletes(ids);
     }
 
     /**
diff --git a/src/main/java/com/moon/server/service/data/ShuJianService.java b/src/main/java/com/moon/server/service/data/ShuJianService.java
index 5de9931..eb71087 100644
--- a/src/main/java/com/moon/server/service/data/ShuJianService.java
+++ b/src/main/java/com/moon/server/service/data/ShuJianService.java
@@ -1,9 +1,13 @@
 package com.moon.server.service.data;
 
 import com.moon.server.entity.all.StaticData;
+import com.moon.server.entity.data.PublishEntity;
 import com.moon.server.entity.shujian.CreateLayerEntity;
 import com.moon.server.entity.shujian.CreateServiceEntity;
+import com.moon.server.entity.shujian.DeleteEntity;
 import com.moon.server.helper.StringHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -14,6 +18,8 @@
  */
 @Service
 public class ShuJianService {
+    private final static Log log = LogFactory.getLog(ShuJianService.class);
+
     /**
      * 鍒涘缓鏁扮畝鍥惧眰
      */
@@ -42,13 +48,6 @@
     }
 
     /**
-     * 鍒犻櫎鏁扮畝鍥惧眰
-     */
-    public void deleteShuJianLayer() {
-        //
-    }
-
-    /**
      * 鍒涘缓鏁扮畝鏈嶅姟
      */
     public void createShuJianService() {
@@ -70,9 +69,43 @@
     }
 
     /**
+     * 鍒犻櫎鏁扮畝鏈嶅姟
+     */
+    public void deleteServe(PublishEntity entity) {
+        if (null != entity.getLayerid()) {
+            deleteLayer(entity.getLayerid());
+        }
+        if (null != entity.getServiceid()) {
+            deleteService(entity.getServiceid());
+        }
+    }
+
+
+    /**
      * 鍒犻櫎鏁扮畝鍥惧眰
      */
-    public void deleteShuJianService() {
-        //
+    public void deleteLayer(Integer id) {
+        try {
+            DeleteEntity entity = new DeleteEntity();
+            entity.getId_list().add(id);
+
+            //
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+        }
+    }
+
+    /**
+     * 鍒犻櫎鏁扮畝鍥惧眰
+     */
+    public void deleteService(Integer id) {
+        try {
+            DeleteEntity entity = new DeleteEntity();
+            entity.getId_list().add(id);
+
+            //
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+        }
     }
 }
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index a5e509c..87d3695 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -15,7 +15,8 @@
   # redis
   redis:
     database: 0
-    host: 192.168.20.83
+    #host: 192.168.20.83
+    host: 127.0.0.1
     port: 6369
     password: rediS_5L#F4_Server
     timeout: 10000  # 杩炴帴瓒呮椂鏃堕暱锛堟绉掞級
@@ -45,8 +46,8 @@
   datasource:
     name: prod
     # JDBC 鍩烘湰閰嶇疆 &currentSchema=public
-    url: jdbc:postgresql://192.168.20.83:5433/moon?useAffectedRows=true
-    #url: jdbc:postgresql://127.0.0.1:5433/moon?useAffectedRows=true
+    #url: jdbc:postgresql://192.168.20.83:5433/moon?useAffectedRows=true
+    url: jdbc:postgresql://103.85.165.99:25432/moon?useAffectedRows=true
     username: postgres
     password: Postgres!_14_moon
     #password: postgres
@@ -130,7 +131,7 @@
   # IIS鐨勪富鏈哄湴鍧�
   iisHost: 127.0.0.1
   # FME鏈嶅姟鍦板潃
-  fmeUrl: http://192.168.20.205:88/
+  fmeUrl: http://127.0.0.1:88/
   # 鍑哄浘鏈嶅姟
   exportServer: http://127.0.0.1/ExportMap
   #exportServer: http://192.168.20.83:80/ExportMap

--
Gitblit v1.9.3