From e002c67732b571f0b20cca8321ca8ee1ddba2e05 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期一, 14 八月 2023 17:05:23 +0800
Subject: [PATCH] 修改文件上传、GDB/Shp数据读取、数据入库、元数据管理等接口

---
 src/main/java/com/moon/server/controller/data/PublishController.java |  134 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 124 insertions(+), 10 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 0027314..706c24c 100644
--- a/src/main/java/com/moon/server/controller/data/PublishController.java
+++ b/src/main/java/com/moon/server/controller/data/PublishController.java
@@ -9,16 +9,18 @@
 import com.moon.server.entity.sys.UserEntity;
 import com.moon.server.helper.StringHelper;
 import com.moon.server.helper.WebHelper;
+import com.moon.server.service.all.PermsService;
 import com.moon.server.service.data.PublishService;
 import com.moon.server.service.sys.TokenService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -29,11 +31,14 @@
 @RestController
 @RequestMapping("/publish")
 public class PublishController extends BaseController {
-    @Autowired
+    @Resource
     PublishService publishService;
 
-    @Autowired
+    @Resource
     TokenService tokenService;
+
+    @Resource
+    PermsService permsService;
 
     @SysLog()
     @ApiOperation(value = "鍒嗛〉鏌ヨ鍏冩暟鎹�")
@@ -56,7 +61,7 @@
                 return fail("鏁版嵁绫诲埆涓虹┖", null);
             }
 
-            String types = getType(type);
+            String types = getType(dircode, type);
             int count = publishService.selectMetasByCount(depcode, dircode, verid, types, name);
             if (count == 0) {
                 return success(0, null);
@@ -73,47 +78,114 @@
     /**
      * 鑾峰彇绫诲瀷
      */
-    private String getType(String type) throws Exception {
+    private String getType(String dircode, String type) throws Exception {
         switch (type) {
             case "DOM":
-                return "type in ('tif', 'tiff', 'img')";
+                return "type in ('tif', 'tiff', 'img')" + getFilter(dircode, type);
             case "DEM":
-                return "type in ('tif', 'tiff')";
+                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'";
             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()
     @ApiOperation(value = "鍒嗛〉鏌ヨ骞惰繑鍥炶褰曟暟")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "name", value = "鍚嶇О", dataType = "String", paramType = "query", example = ""),
+            @ApiImplicitParam(name = "dircode", value = "鐩綍", dataType = "String", paramType = "query", example = ""),
+            @ApiImplicitParam(name = "type", value = "绫诲埆", dataType = "String", paramType = "query", example = ""),
             @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"),
             @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", dataType = "Integer", paramType = "query", example = "1")
     })
     @GetMapping(value = "/selectByPageAndCount")
-    public ResponseMsg<List<PublishEntity>> selectByPageAndCount(String name, Integer pageSize, Integer pageIndex) {
+    public ResponseMsg<List<PublishEntity>> selectByPageAndCount(String name, String dircode, String type, Integer pageSize, Integer pageIndex) {
         try {
             if (pageSize < 1 || pageIndex < 1) {
                 return fail("姣忛〉椤垫暟鎴栧垎椤垫暟灏忎簬1", null);
             }
+            type = getPubType(type);
 
-            int count = publishService.selectCount(name);
+            int count = publishService.selectCount(name, dircode, type);
             if (count == 0) {
                 return success(0, null);
             }
 
-            List<PublishEntity> rs = publishService.selectByPage(name, pageSize, pageSize * (pageIndex - 1));
+            List<PublishEntity> rs = publishService.selectByPage(name, dircode, type, pageSize, pageSize * (pageIndex - 1));
 
             return success(count, rs);
         } catch (Exception ex) {
             return fail(ex.getMessage(), null);
+        }
+    }
+
+    /**
+     * 鑾峰彇鍙戝竷绫诲瀷
+     */
+    private String getPubType(String type) {
+        if (StringHelper.isEmpty(type)) {
+            return null;
+        }
+
+        switch (type) {
+            case "DOM":
+                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'";
+            default:
+                return null;
         }
     }
 
@@ -128,6 +200,31 @@
             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);
         }
@@ -154,6 +251,7 @@
                 entity.setToken(WebHelper.getToken(req));
             }
 
+            permsService.clearLayerCache();
             String method = getConvertMethod(entity.getType());
             long count = publishService.postForPub(entity, method, req);
 
@@ -174,9 +272,14 @@
                 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("鏁版嵁绫诲瀷涓嶅尮閰�");
         }
@@ -193,6 +296,16 @@
             if (ids == null || ids.isEmpty()) {
                 return fail("id鏁扮粍涓嶈兘涓虹┖", -1);
             }
+
+            String strs = StringHelper.join(ids, ",");
+            List<PublishEntity> list = publishService.selectByIds(strs);
+            if (null == list || list.isEmpty()) {
+                return fail("娌℃湁鎵惧埌瑕佸垹闄ょ殑鏁版嵁", -1);
+            }
+
+            // publishService.deleteFiles(list)
+            permsService.clearLayerCache();
+            publishService.deleteFiles(ids, req);
 
             int count = publishService.deletes(ids, req);
 
@@ -216,6 +329,7 @@
                 entity.setUpdateUser(ue.getId());
             }
 
+            permsService.clearLayerCache();
             int count = publishService.update(entity);
 
             return success(count);

--
Gitblit v1.9.3