From d950bfac44ca8dcdfe91de52fde0fe86e0829753 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期日, 03 九月 2023 12:03:02 +0800
Subject: [PATCH] 发布表添加新的字段

---
 src/main/java/com/moon/server/controller/data/PublishController.java |  210 +++++++++++++++++-----------------------------------
 1 files changed, 68 insertions(+), 142 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..b88a93a 100644
--- a/src/main/java/com/moon/server/controller/data/PublishController.java
+++ b/src/main/java/com/moon/server/controller/data/PublishController.java
@@ -8,9 +8,9 @@
 import com.moon.server.entity.data.PublishEntity;
 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.data.ShuJianService;
 import com.moon.server.service.sys.TokenService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -20,7 +20,7 @@
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
-import java.util.Arrays;
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 /**
@@ -39,6 +39,9 @@
 
     @Resource
     PermsService permsService;
+
+    @Resource
+    ShuJianService shuJianService;
 
     @SysLog()
     @ApiOperation(value = "鍒嗛〉鏌ヨ鍏冩暟鎹�")
@@ -61,7 +64,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 +81,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 +129,7 @@
     /**
      * 鑾峰彇鍙戝竷绫诲瀷
      */
-    private String getPubType(String type) {
+    private String getPubType(String type) throws Exception {
         if (StringHelper.isEmpty(type)) {
             return null;
         }
@@ -172,20 +139,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("鏁版嵁绫诲瀷涓嶅尮閰�");
         }
     }
 
@@ -206,128 +165,95 @@
     }
 
     @SysLog()
-    @ApiOperation(value = "鏌ヨLas鏂囦欢鍧愭爣绯籌D")
+    @ApiOperation(value = "鍒嗛〉鏌ヨ鏁扮畝鐨勯鑹茶〃")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "ids", value = "鍏冩暟鎹甀D闆嗗悎", dataType = "Integer[]", paramType = "query", example = "10483,10481,10456,10285")
+            @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "int", paramType = "query", example = "10"),
+            @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", dataType = "int", paramType = "query", example = "1")
     })
-    @GetMapping(value = "/selectLasCs")
-    public ResponseMsg<Object> selectLasCs(Integer[] ids, HttpServletRequest req) {
-        try {
-            if (null == ids || ids.length == 0) {
-                return fail("鍏冩暟鎹甀D闆嗗悎涓嶈兘涓虹┖");
-            }
+    @GetMapping(value = "/selectSjColorTables")
+    public void selectSjColorTables(int pageSize, int pageIndex, HttpServletRequest req, HttpServletResponse res) {
+        pageIndex = Math.max(pageIndex, 1);
+        pageSize = Math.max(pageSize, 5);
 
-            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);
-        }
+        shuJianService.selectSjColorTables(pageSize, pageIndex, req, res);
     }
 
     @SysLog()
-    @ApiOperation(value = "鎻掑叆鍙戝竷鏁版嵁")
+    @ApiOperation(value = "鎻掑叆鏁扮畝鏈嶅姟")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "entity", value = "瀹炰綋绫�", dataType = "PubEntity", paramType = "body")
     })
-    @PostMapping(value = "/insertForPub", produces = "application/json; charset=UTF-8")
-    public ResponseMsg<Object> insertForPub(@RequestBody PubEntity entity, HttpServletRequest req) {
+    @ResponseBody
+    @PostMapping(value = "/insertSjService", produces = "application/json; charset=UTF-8")
+    public ResponseMsg<Object> insertSjService(@RequestBody PubEntity entity, HttpServletRequest req, HttpServletResponse res) {
         try {
             if (null == entity || null == entity.getIds() || entity.getIds().isEmpty()) {
                 return fail("瀹炰綋绫讳负绌烘垨鎵句笉鍒板厓鏁版嵁ID", 0);
             }
             if (StringHelper.isEmpty(entity.getType())) {
-                return fail("鏁版嵁绫诲埆涓虹┖", null);
+                return fail("鍙戝竷绫诲埆涓虹┖", null);
             }
 
             UserEntity ue = tokenService.getCurrentUser(req);
-            if (ue != null) {
+            if (null != ue) {
                 entity.setUserId(ue.getId());
-                entity.setToken(WebHelper.getToken(req));
+                entity.setDepcode(ue.getDepcode());
             }
 
             permsService.clearPermsCache();
-            String method = getConvertMethod(entity.getType());
-            long count = publishService.postForPub(entity, method, req);
+            Integer rows = shuJianService.insertSjService(entity);
 
-            return success(count);
+            return success(rows);
         } 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("鏁版嵁绫诲瀷涓嶅尮閰�");
+    @SysLog()
+    @ApiOperation(value = "鏇存柊鏁扮畝鏈嶅姟")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "entity", value = "瀹炰綋绫�", dataType = "PubEntity", paramType = "body")
+    })
+    @ResponseBody
+    @PostMapping(value = "/updateSjService", produces = "application/json; charset=UTF-8")
+    public ResponseMsg<Object> updateSjService(@RequestBody PubEntity entity, HttpServletRequest req, HttpServletResponse res) {
+        try {
+            if (null == entity || null == entity.getPubid()) {
+                return fail("瀹炰綋绫讳负绌烘垨鍙戝竷ID涓虹┖", 0);
+            }
+            if (StringHelper.isEmpty(entity.getType())) {
+                return fail("鍙戝竷绫诲埆涓虹┖", null);
+            }
+
+            UserEntity ue = tokenService.getCurrentUser(req);
+            if (null != ue) {
+                entity.setUserId(ue.getId());
+                entity.setDepcode(ue.getDepcode());
+            }
+
+            permsService.clearPermsCache();
+            Integer rows = shuJianService.updateSjService(entity, req, res);
+
+            return success(rows);
+        } catch (Exception ex) {
+            return fail(ex.getMessage(), -1);
         }
     }
 
     @SysLog()
-    @ApiOperation(value = "鍒犻櫎澶氭潯")
+    @ApiOperation(value = "鍒犻櫎鏁扮畝鏈嶅姟")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "ids", value = "ID鏁扮粍", dataType = "Integer", paramType = "query", allowMultiple = true, example = "1")
     })
     @GetMapping(value = "/deletes")
-    public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids, HttpServletRequest req) {
+    public ResponseMsg<Integer> deletesSjServices(@RequestParam List<Integer> ids) {
         try {
-            if (ids == null || ids.isEmpty()) {
+            if (null == ids || 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);
-            }
-
             permsService.clearPermsCache();
-            int count = publishService.deletes(ids, req);
-
-            return success(count);
-        } catch (Exception ex) {
-            return fail(ex.getMessage(), -1);
-        }
-    }
-
-    @SysLog()
-    @ApiOperation(value = "鏇存柊涓�鏉�")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "entity", value = "瀹炰綋绫�", dataType = "PublishEntity", paramType = "body")
-    })
-    @ResponseBody
-    @PostMapping(value = "/update", produces = "application/json; charset=UTF-8")
-    public ResponseMsg<Integer> update(@RequestBody PublishEntity entity, HttpServletRequest req) {
-        try {
-            UserEntity ue = tokenService.getCurrentUser(req);
-            if (ue != null) {
-                entity.setUpdateUser(ue.getId());
-            }
-
-            permsService.clearPermsCache();
-            int count = publishService.update(entity);
+            int count = shuJianService.deletesSjServices(ids);
 
             return success(count);
         } catch (Exception ex) {

--
Gitblit v1.9.3