From ac20dc99bf1f463365dba071973e08fffbd294b4 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期五, 14 七月 2023 14:12:21 +0800
Subject: [PATCH] 1

---
 src/main/java/com/lf/server/controller/data/PublishController.java |  178 ++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 90 insertions(+), 88 deletions(-)

diff --git a/src/main/java/com/lf/server/controller/data/PublishController.java b/src/main/java/com/lf/server/controller/data/PublishController.java
index dcc2d7b..b28ab65 100644
--- a/src/main/java/com/lf/server/controller/data/PublishController.java
+++ b/src/main/java/com/lf/server/controller/data/PublishController.java
@@ -3,10 +3,12 @@
 import com.lf.server.annotation.SysLog;
 import com.lf.server.controller.all.BaseController;
 import com.lf.server.entity.all.ResponseMsg;
+import com.lf.server.entity.ctrl.PubEntity;
 import com.lf.server.entity.data.MetaEntity;
 import com.lf.server.entity.data.PublishEntity;
 import com.lf.server.entity.sys.UserEntity;
 import com.lf.server.helper.StringHelper;
+import com.lf.server.helper.WebHelper;
 import com.lf.server.service.data.PublishService;
 import com.lf.server.service.sys.TokenService;
 import io.swagger.annotations.Api;
@@ -51,10 +53,10 @@
                 return fail("姣忛〉椤垫暟鎴栧垎椤垫暟灏忎簬1", null);
             }
             if (StringHelper.isEmpty(type)) {
-                return fail("璇疯緭鍏ユ暟鎹被鍒�");
+                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);
@@ -71,19 +73,55 @@
     /**
      * 鑾峰彇绫诲瀷
      */
-    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')" + 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()
@@ -114,19 +152,6 @@
     }
 
     @SysLog()
-    @ApiOperation(value = "鏌ヨ鎵�鏈�")
-    @GetMapping(value = "/selectAll")
-    public ResponseMsg<List<PublishEntity>> selectAll() {
-        try {
-            List<PublishEntity> list = publishService.selectAll();
-
-            return success(list);
-        } catch (Exception ex) {
-            return fail(ex.getMessage(), null);
-        }
-    }
-
-    @SysLog()
     @ApiOperation(value = "鏍规嵁ID鏌ヨ")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "ID", dataType = "int", paramType = "query", example = "1")
@@ -143,19 +168,28 @@
     }
 
     @SysLog()
-    @ApiOperation(value = "鎻掑叆涓�鏉�")
+    @ApiOperation(value = "鎻掑叆鍙戝竷鏁版嵁")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "entity", value = "瀹炰綋绫�", dataType = "PublishEntity", paramType = "body")
+            @ApiImplicitParam(name = "entity", value = "瀹炰綋绫�", dataType = "PubEntity", paramType = "body")
     })
-    @PostMapping(value = "/insert", produces = "application/json; charset=UTF-8")
-    public ResponseMsg<Integer> insert(@RequestBody PublishEntity entity, HttpServletRequest req) {
+    @PostMapping(value = "/insertForPub", produces = "application/json; charset=UTF-8")
+    public ResponseMsg<Object> insertForPub(@RequestBody PubEntity entity, HttpServletRequest req) {
         try {
-            UserEntity ue = tokenService.getCurrentUser(req);
-            if (ue != null) {
-                entity.setCreateUser(ue.getId());
+            if (null == entity || null == entity.getIds() || entity.getIds().isEmpty()) {
+                return fail("瀹炰綋绫讳负绌烘垨鎵句笉鍒板厓鏁版嵁ID", 0);
+            }
+            if (StringHelper.isEmpty(entity.getType())) {
+                return fail("鏁版嵁绫诲埆涓虹┖", null);
             }
 
-            int count = publishService.insert(entity);
+            UserEntity ue = tokenService.getCurrentUser(req);
+            if (ue != null) {
+                entity.setUserId(ue.getId());
+                entity.setToken(WebHelper.getToken(req));
+            }
+
+            String method = getConvertMethod(entity.getType());
+            long count = publishService.postForPub(entity, method, req);
 
             return success(count);
         } catch (Exception ex) {
@@ -163,58 +197,50 @@
         }
     }
 
-    @SysLog()
-    @ApiOperation(value = "鎻掑叆澶氭潯")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "list", value = "瀹炰綋绫婚泦鍚�", dataType = "PublishEntity", paramType = "body")
-    })
-    @PostMapping(value = "/inserts", produces = "application/json; charset=UTF-8")
-    public ResponseMsg<Integer> inserts(@RequestBody List<PublishEntity> list, HttpServletRequest req) {
-        try {
-            UserEntity ue = tokenService.getCurrentUser(req);
-            if (ue != null) {
-                for (PublishEntity entity : list) {
-                    entity.setCreateUser(ue.getId());
-                }
-            }
-
-            int count = publishService.inserts(list);
-
-            return success(count);
-        } catch (Exception ex) {
-            return fail(ex.getMessage(), -1);
-        }
-    }
-
-    @SysLog()
-    @ApiOperation(value = "鍒犻櫎涓�鏉�")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1")
-    })
-    @GetMapping(value = "/delete")
-    public ResponseMsg<Integer> delete(int id) {
-        try {
-            int count = publishService.delete(id);
-
-            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/ToLas";
+            case "OSGB":
+                return "/Convert/ToOsgb";
+            default:
+                throw new Exception("鏁版嵁绫诲瀷涓嶅尮閰�");
         }
     }
 
     @SysLog()
     @ApiOperation(value = "鍒犻櫎澶氭潯")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "ids", value = "ID鏁扮粍", dataType = "Integer", paramType = "query", example = "1,2")
+            @ApiImplicitParam(name = "ids", value = "ID鏁扮粍", dataType = "Integer", paramType = "query", allowMultiple = true, example = "1")
     })
     @GetMapping(value = "/deletes")
-    public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids) {
+    public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids, HttpServletRequest req) {
         try {
             if (ids == null || ids.isEmpty()) {
                 return fail("id鏁扮粍涓嶈兘涓虹┖", -1);
             }
 
-            int count = publishService.deletes(ids);
+            String strs = StringHelper.join(ids, ",");
+            List<PublishEntity> list = publishService.selectByIds(strs);
+            if (null == list || list.isEmpty()) {
+                return fail("娌℃湁鎵惧埌瑕佸垹闄ょ殑鏁版嵁", -1);
+            }
+
+            publishService.deleteFiles(list);
+            int count = publishService.deletes(ids, req);
 
             return success(count);
         } catch (Exception ex) {
@@ -237,30 +263,6 @@
             }
 
             int count = publishService.update(entity);
-
-            return success(count);
-        } catch (Exception ex) {
-            return fail(ex.getMessage(), -1);
-        }
-    }
-
-    @SysLog()
-    @ApiOperation(value = "鏇存柊澶氭潯")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "list", value = "瀹炰綋绫婚泦鍚�", dataType = "PublishEntity", paramType = "body")
-    })
-    @ResponseBody
-    @PostMapping(value = "/updates", produces = "application/json; charset=UTF-8")
-    public ResponseMsg<Integer> updates(@RequestBody List<PublishEntity> list, HttpServletRequest req) {
-        try {
-            UserEntity ue = tokenService.getCurrentUser(req);
-            if (ue != null) {
-                for (PublishEntity entity : list) {
-                    entity.setUpdateUser(ue.getId());
-                }
-            }
-
-            int count = publishService.updates(list);
 
             return success(count);
         } catch (Exception ex) {

--
Gitblit v1.9.3