From 670f36af44911c51eb2e57b230c67b585b696896 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期四, 30 三月 2023 09:15:28 +0800
Subject: [PATCH] 1

---
 src/main/java/com/lf/server/controller/all/BaseQueryController.java |  160 +++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 129 insertions(+), 31 deletions(-)

diff --git a/src/main/java/com/lf/server/controller/all/BaseQueryController.java b/src/main/java/com/lf/server/controller/all/BaseQueryController.java
index 42f5448..1277d32 100644
--- a/src/main/java/com/lf/server/controller/all/BaseQueryController.java
+++ b/src/main/java/com/lf/server/controller/all/BaseQueryController.java
@@ -6,6 +6,7 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.lf.server.annotation.SysLog;
 import com.lf.server.entity.all.ResponseMsg;
+import com.lf.server.entity.all.StaticData;
 import com.lf.server.entity.ctrl.DownloadReqEntity;
 import com.lf.server.entity.ctrl.IdNameEntity;
 import com.lf.server.entity.ctrl.KeyValueEntity;
@@ -131,7 +132,7 @@
             }
 
             Page<Object> page = new Page<>(pageIndex, pageSize);
-            page.addOrder(OrderItem.asc("gid"));
+            page.addOrder(OrderItem.desc("gid"));
             IPage<Object> paged = baseMapper.selectPage(page, wrapper);
 
             return success(paged.getTotal(), paged.getRecords());
@@ -145,13 +146,35 @@
     @ApiImplicitParams({
             @ApiImplicitParam(name = "name", value = "鏄犲皠鍚嶇О", dataType = "String", paramType = "query", example = "dlgagnp"),
             @ApiImplicitParam(name = "wkt", value = "WKT锛堣憲鍚嶆枃鏈級", dataType = "String", paramType = "query", example = ""),
+            @ApiImplicitParam(name = "buffer", value = "缂撳啿鍖哄ぇ灏�", dataType = "Double", paramType = "query", example = "10"),
             @ApiImplicitParam(name = "limit", value = "闄愬埗鏉℃暟", dataType = "Integer", paramType = "query", example = "20")
     })
     @GetMapping(value = "/selectByBuffer")
-    public ResponseMsg<List<Object>> selectByBuffer(String name, String wkt, Integer limit) {
+    public ResponseMsg<List<?>> selectByBuffer(String name, String wkt, Double buffer, Integer limit) {
         try {
+            if (StringHelper.isEmpty(wkt)) {
+                return fail("WKT涓嶈兘涓虹┖", null);
+            }
+            if (null == limit || limit < 1 || limit > StaticData.ONE_HUNDRED) {
+                limit = 20;
+            }
+            if (null == buffer || buffer < 0 || buffer > StaticData.ONE_HUNDRED_THOUSAND) {
+                buffer = 10.0;
+            }
 
-            return success(0, null);
+            GeomBaseMapper baseMapper = ClassHelper.getGeoBaseMapper(name);
+            if (baseMapper == null) {
+                return fail("鏌ヨ瀵硅薄涓嶅瓨鍦�", null);
+            }
+
+            QueryWrapper wrapper = new QueryWrapper();
+            wrapper.select("ST_AsText(geom) as geom, *");
+            baseQueryService.addBufferWrapper(baseMapper, wrapper, wkt, buffer);
+            wrapper.last("limit " + limit);
+
+            List<?> list = baseMapper.selectList(wrapper);
+
+            return success(null == list ? 0 : list.size(), list);
         } catch (Exception ex) {
             return fail(ex, null);
         }
@@ -219,6 +242,53 @@
     }
 
     @SysLog()
+    @ApiOperation(value = "鏍规嵁GID鏌ヨ")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "name", value = "鏄犲皠鍚嶇О", dataType = "String", paramType = "query", example = "dlgagnp"),
+            @ApiImplicitParam(name = "gid", value = "GID", dataType = "int", paramType = "query", example = "1")
+    })
+    @GetMapping(value = "/selectByGid")
+    public ResponseMsg<Object> selectByGid(String name, int gid) {
+        try {
+            GeomBaseMapper baseMapper = ClassHelper.getGeoBaseMapper(name);
+            if (baseMapper == null) {
+                return fail("鏌ヨ瀵硅薄涓嶅瓨鍦�", null);
+            }
+
+            QueryWrapper wrapper = new QueryWrapper();
+            wrapper.select("ST_AsText(geom) as geom, *");
+            wrapper.eq("gid", gid);
+
+            Object obj = baseMapper.selectOne(wrapper);
+
+            return success(null == obj ? 0 : 1, obj);
+        } catch (Exception ex) {
+            return fail(ex, null);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "鏍规嵁瀹炰綋鍚嶆煡璇㈣〃鍚�")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "name", value = "鏄犲皠鍚嶇О", dataType = "String", paramType = "query", example = "dlgagnp")
+    })
+    @GetMapping(value = "/selectTabByEntity")
+    public ResponseMsg<Object> selectTabByEntity(String name) {
+        try {
+            BasicMapper baseMapper = ClassHelper.getBasicMapper(name);
+            if (baseMapper == null) {
+                return fail("鏌ヨ瀵硅薄涓嶅瓨鍦�", null);
+            }
+
+            String tab = BaseQueryService.getTabName(baseMapper);
+
+            return success(tab);
+        } catch (Exception ex) {
+            return fail(ex, null);
+        }
+    }
+
+    @SysLog()
     @ApiOperation(value = "妯$硦鎼滅储瀛楁")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "name", value = "鏄犲皠鍚嶇О", dataType = "String", paramType = "query", example = "dlgagnp"),
@@ -240,11 +310,8 @@
             if (StringHelper.isEmpty(field) || StringHelper.isSqlInjection(field)) {
                 return fail("鏌ヨ瀛楁涓嶆纭�", null);
             }
-            if (!StringHelper.isEmpty(value)) {
-                value = value.trim().replace("'", "");
-            }
 
-            value = StringHelper.getLikeStr2(value);
+            value = StringHelper.isEmpty(value) ? "%" : StringHelper.getLikeUpperStr(value);
             List<String> rs = baseMapper.selectFieldFuzzy(tab, field, value);
 
             return success(rs);
@@ -328,7 +395,7 @@
             }
             dirs = DataLibService.copeCodes(dirs, "dirid");
             if (dirs != null) {
-                filters += String.format(" and (%s)", dirs);
+                filters += String.format(" and %s", dirs);
             }
 
             String field = null == hasGeom || !hasGeom ? "gid" : "geom";
@@ -468,18 +535,17 @@
     })
     @ResponseBody
     @PostMapping(value = "/selectDbOverflowDep")
-    public ResponseMsg<Object> selectDbOverflowDep(@RequestBody DownloadReqEntity reqEntity, HttpServletRequest req, HttpServletResponse res) {
+    public ResponseMsg<Object> selectDbOverflowDep(@RequestBody DownloadReqEntity dr, HttpServletRequest req, HttpServletResponse res) {
         try {
-            if (null == reqEntity || null == reqEntity.getEntities() || reqEntity.getEntities().isEmpty()) {
+            if (null == dr || null == dr.getEntities() || dr.getEntities().isEmpty()) {
                 return fail("璇烽�夋嫨瑕佷笅杞界殑瀹炰綋鍚�");
             }
-            reqEntity.setWkt(AesHelper.decrypt(reqEntity.getWkt()));
-            if (StringHelper.isEmpty(reqEntity.getWkt())) {
-                return fail("璇烽�夋嫨瑕佷笅杞界殑WKT鑼冨洿");
+            if (!StringHelper.isEmpty(dr.getWkt())) {
+                dr.setWkt(AesHelper.decrypt(dr.getWkt()));
             }
 
             UserEntity ue = tokenService.getCurrentUser(req);
-            List<String> list = dataLibService.selectDbOverflowDep(ue, reqEntity.getEntities(), reqEntity.getWkt());
+            List<String> list = dataLibService.selectDbOverflowDep(ue, dr);
 
             return success(list);
         } catch (Exception ex) {
@@ -510,32 +576,65 @@
     @SysLog()
     @ApiOperation(value = "璇锋眰DB鏁版嵁涓嬭浇")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "dre", value = "璇锋眰涓嬭浇瀹炰綋", dataType = "DownloadReqEntity", paramType = "body")
+            @ApiImplicitParam(name = "dr", value = "璇锋眰涓嬭浇瀹炰綋", dataType = "DownloadReqEntity", paramType = "body")
+    })
+    @ResponseBody
+    @PostMapping(value = "/downloadDbData")
+    public ResponseMsg<Object> downloadDbData(@RequestBody DownloadReqEntity dr, HttpServletRequest req) {
+        try {
+            if (null == dr || null == dr.getEntities() || dr.getEntities().isEmpty()) {
+                return fail("璇烽�夋嫨瑕佷笅杞界殑瀹炰綋鍚�");
+            }
+            if (StringHelper.isEmpty(dr.getPwd())) {
+                return fail("瀵嗙爜涓嶈兘涓虹┖");
+            }
+            if (!DownloadService.decryptPwd(dr)) {
+                return fail("瀵嗙爜瑙e瘑澶辫触", null);
+            }
+            if (StringHelper.isPwdInvalid(dr.getPwd())) {
+                return fail("瀵嗙爜涓嶇鍚堣姹�");
+            }
+            if (!StringHelper.isEmpty(dr.getWkt())) {
+                dr.setWkt(AesHelper.decrypt(dr.getWkt()));
+            }
+
+            UserEntity ue = tokenService.getCurrentUser(req);
+            String guid = dataLibService.downloadDbReq(ue, dr);
+
+            return success(guid);
+        } catch (Exception ex) {
+            return fail(ex, null);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "璇锋眰DB鏁版嵁涓嬭浇")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "dr", value = "璇锋眰涓嬭浇瀹炰綋", dataType = "DownloadReqEntity", paramType = "body")
     })
     @ResponseBody
     @PostMapping(value = "/downloadDbReq")
-    public ResponseMsg<Object> downloadDbReq(@RequestBody DownloadReqEntity dre, HttpServletRequest req, HttpServletResponse res) {
+    public ResponseMsg<Object> downloadDbReq(@RequestBody DownloadReqEntity dr, HttpServletRequest req, HttpServletResponse res) {
         try {
-            if (null == dre || StringHelper.isEmpty(dre.getPwd())) {
+            if (null == dr || StringHelper.isEmpty(dr.getPwd())) {
                 return fail("瀵嗙爜涓嶈兘涓虹┖");
             }
-            if (null == dre.getEntities() || dre.getEntities().isEmpty()) {
+            if (null == dr.getEntities() || dr.getEntities().isEmpty()) {
                 return fail("璇烽�夋嫨瑕佷笅杞界殑瀹炰綋鍚�");
             }
-            dre.setWkt(AesHelper.decrypt(dre.getWkt()));
-            if (StringHelper.isEmpty(dre.getWkt())) {
+            dr.setWkt(AesHelper.decrypt(dr.getWkt()));
+            if (StringHelper.isEmpty(dr.getWkt())) {
                 return fail("璇烽�夋嫨瑕佷笅杞界殑WKT鑼冨洿");
             }
-            if (!DownloadService.decryptPwd(dre)) {
+            if (!DownloadService.decryptPwd(dr)) {
                 return fail("瀵嗙爜瑙e瘑澶辫触", null);
             }
-            if (StringHelper.isPwdInvalid(dre.getPwd())) {
+            if (StringHelper.isPwdInvalid(dr.getPwd())) {
                 return fail("瀵嗙爜涓嶇鍚堣姹�");
             }
 
             UserEntity ue = tokenService.getCurrentUser(req);
-            String depcode = null == dre.getDepcodes() || dre.getDepcodes().isEmpty() ? null : dre.getDepcodes().get(0);
-            String guid = dataLibService.createZipFile(ue, dre.getEntities(), depcode, dre.getDirs(), dre.getWkt(), dre.getPwd());
+            String guid = dataLibService.downloadDbReq4Wkt(ue, dr);
 
             return success(guid);
         } catch (Exception ex) {
@@ -550,24 +649,23 @@
     })
     @ResponseBody
     @PostMapping(value = "/downloadEntityReq")
-    public ResponseMsg<Object> downloadEntityReq(@RequestBody DownloadReqEntity dre, HttpServletRequest req, HttpServletResponse res) {
+    public ResponseMsg<Object> downloadEntityReq(@RequestBody DownloadReqEntity dr, HttpServletRequest req, HttpServletResponse res) {
         try {
-            if (null == dre || StringHelper.isEmpty(dre.getPwd())) {
+            if (null == dr || StringHelper.isEmpty(dr.getPwd())) {
                 return fail("瀵嗙爜涓嶈兘涓虹┖");
             }
-            if (null == dre.getEntities() || dre.getEntities().isEmpty()) {
+            if (null == dr.getEntities() || dr.getEntities().isEmpty()) {
                 return fail("璇烽�夋嫨瑕佷笅杞界殑瀹炰綋鍚�");
             }
-            if (!DownloadService.decryptPwd(dre)) {
+            if (!DownloadService.decryptPwd(dr)) {
                 return fail("瀵嗙爜瑙e瘑澶辫触", null);
             }
-            if (StringHelper.isPwdInvalid(dre.getPwd())) {
+            if (StringHelper.isPwdInvalid(dr.getPwd())) {
                 return fail("瀵嗙爜涓嶇鍚堣姹�");
             }
 
             UserEntity ue = tokenService.getCurrentUser(req);
-            String depcode = null == dre.getDepcodes() || dre.getDepcodes().isEmpty() ? null : dre.getDepcodes().get(0);
-            String guid = dataLibService.zipDbData(ue, dre.getEntities().get(0), depcode, dre.getDirs(), dre.getFilter(), dre.getPwd());
+            String guid = dataLibService.downloadDbReq4Prop(ue, dr);
 
             return success(guid);
         } catch (Exception ex) {

--
Gitblit v1.9.3