From 4aaa82f73fc81761380b1d6ac8e512b69285ca2d Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期日, 23 四月 2023 10:43:09 +0800
Subject: [PATCH] 1

---
 src/main/java/com/terra/coal/controller/MainController.java |   35 +++++++++++++++++++++++++++++++++--
 1 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/terra/coal/controller/MainController.java b/src/main/java/com/terra/coal/controller/MainController.java
index 0c52b85..5ccb600 100644
--- a/src/main/java/com/terra/coal/controller/MainController.java
+++ b/src/main/java/com/terra/coal/controller/MainController.java
@@ -1,6 +1,8 @@
 package com.terra.coal.controller;
 
+import com.terra.coal.entity.CountEntity;
 import com.terra.coal.entity.ResponseMsg;
+import com.terra.coal.entity.StaticData;
 import com.terra.coal.helper.StringHelper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -11,11 +13,12 @@
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.servlet.ModelAndView;
-import service.MainService;
+import com.terra.coal.service.MainService;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
+import java.util.List;
 
 /**
  * CoalController
@@ -45,7 +48,7 @@
         return mv;
     }
 
-    @ApiOperation(value = "鍔犺浇54鏁版嵁鍏ュ簱")
+    @ApiOperation(value = "鍔犺浇54鏁版嵁(鍏ュ簱)")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "txtPath", value = "鍧椾綋鏁版嵁鏂囦欢璺緞", dataType = "String", paramType = "query", example = "D:\\鍧椾綋鏁版嵁.txt")
     })
@@ -69,4 +72,32 @@
             return fail(ex.getMessage(), null);
         }
     }
+
+    @ApiOperation(value = "鏍规嵁鑼冨洿缁熻")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "z", value = "楂樺害", dataType = "double", paramType = "query", example = "750"),
+            @ApiImplicitParam(name = "deep", value = "娣卞害", dataType = "double", paramType = "query", example = "150"),
+            @ApiImplicitParam(name = "wkt", value = "WKT鏂囨湰", dataType = "String", paramType = "query", example = "POLYGON ((113.5807 45.4897,113.5898 45.4893,113.5857 45.4837,113.5807 45.4897))")
+    })
+    @GetMapping(value = "/countByRange")
+    public ResponseMsg<Object> countByRange(String wkt, double z, double deep) {
+        try {
+            if (StringHelper.isEmpty(wkt)) {
+                return fail("璇疯緭鍏ユ煡璇㈣寖鍥�(WKT瀛楃涓�)", null);
+            }
+            if (z < StaticData.MINUS_ONE_THOUSAND || z > StaticData.NINE_THOUSAND) {
+                return fail("楂樺害鍊艰秴鍑鸿寖鍥�(-1000~9000)", null);
+            }
+            if (deep < 1) {
+                return fail("寮�鎸栨繁搴﹁繃灏�", null);
+            }
+
+            List<CountEntity> rs = mainService.countByRange(z, z - deep, wkt);
+
+            return success("鎴愬姛", null == rs ? 0 : rs.size(), rs);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            return fail(ex.getMessage(), null);
+        }
+    }
 }

--
Gitblit v1.9.3