From c6f05c53f1ccdef583017cce94759e2f0462646c Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期五, 07 四月 2023 17:58:12 +0800 Subject: [PATCH] 1 --- src/main/java/com/terra/coal/controller/MainController.java | 64 ++++++++++++++++++++++++++++++++ 1 files changed, 64 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/terra/coal/controller/MainController.java b/src/main/java/com/terra/coal/controller/MainController.java index e58fffa..921c294 100644 --- a/src/main/java/com/terra/coal/controller/MainController.java +++ b/src/main/java/com/terra/coal/controller/MainController.java @@ -1,14 +1,24 @@ 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; +import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.ModelAndView; +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 @@ -18,6 +28,9 @@ @RestController @RequestMapping("/main") public class MainController extends BaseController { + @Autowired + MainService mainService; + @ApiOperation(value = "璺宠浆棣栭〉") @GetMapping({"/", "/toIndex"}) public ModelAndView toIndex(ModelAndView mv, HttpServletRequest req) { @@ -34,4 +47,55 @@ return mv; } + + @ApiOperation(value = "鍔犺浇54鏁版嵁(鍏ュ簱)") + @ApiImplicitParams({ + @ApiImplicitParam(name = "txtPath", value = "鍧椾綋鏁版嵁鏂囦欢璺緞", dataType = "String", paramType = "query", example = "D:\\鍧椾綋鏁版嵁.txt") + }) + @GetMapping(value = "/load54Data") + public ResponseMsg<Integer> load54Data(String txtPath) { + try { + if (StringHelper.isEmpty(txtPath)) { + return fail("璇烽�夋嫨鈥樺潡浣撴暟鎹�.txt鈥�", null); + } + + File f = new File(txtPath); + if (!f.exists() || f.isDirectory()) { + return fail("鏂囦欢涓嶅瓨鍦�", null); + } + + Integer rows = mainService.load54Data(f); + + return success("鎴愬姛", rows); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + return fail(ex.getMessage(), null); + } + } + + @ApiOperation(value = "鏍规嵁鑼冨洿缁熻") + @ApiImplicitParams({ + @ApiImplicitParam(name = "txtPath", value = "鍧椾綋鏁版嵁鏂囦欢璺緞", dataType = "String", paramType = "query", example = "D:\\鍧椾綋鏁版嵁.txt") + }) + @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(wkt, z, deep); + + return success("鎴愬姛", rs); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + return fail(ex.getMessage(), null); + } + } } -- Gitblit v1.9.3