From 3417cf014a65765e02696c1d121ce58b2b4a8aed Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期二, 08 四月 2025 15:55:36 +0800
Subject: [PATCH] 修改pom.xml

---
 src/main/java/com/se/simu/controller/WaterController.java |  202 +++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 148 insertions(+), 54 deletions(-)

diff --git a/src/main/java/com/se/simu/controller/WaterController.java b/src/main/java/com/se/simu/controller/WaterController.java
index 21959c2..8141dbc 100644
--- a/src/main/java/com/se/simu/controller/WaterController.java
+++ b/src/main/java/com/se/simu/controller/WaterController.java
@@ -1,8 +1,16 @@
 package com.se.simu.controller;
 
-import com.se.simu.domain.Layer;
+import com.se.simu.domain.po.SimuPo;
+import com.se.simu.domain.vo.PondingVo;
+import com.se.simu.domain.vo.R;
+import com.se.simu.helper.StringHelper;
 import com.se.simu.helper.WebHelper;
+import com.se.simu.service.SimuService;
 import com.se.simu.service.WaterService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -14,16 +22,15 @@
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 
-/**
- * 鍐呮稘鎺у埗鍣�
- *
- * @author WWW
- * @date   2024-07-16
- */
+@Api(tags = "鍐呮稘绠$悊")
 @Slf4j
 @RestController
+@SuppressWarnings("ALL")
 @RequestMapping("/waterlogging")
-public class WaterController {
+public class WaterController extends BaseController {
+    @Resource
+    SimuService simuService;
+
     @Resource
     WaterService waterService;
 
@@ -33,36 +40,75 @@
 
     private final static long Y2000 = 949334400000L;
 
-    /**
-     * 鑾峰彇褰撳墠鏃堕棿
-     */
-    @GetMapping("/getTime")
-    public Object getTime() {
-        return System.currentTimeMillis();
-    }
-
-    /**
-     * 鑾峰彇鍏冩暟鎹俊鎭�
-     */
+    @ApiOperation(value = "鑾峰彇鍏冩暟鎹甁SON")
     @GetMapping("/{serviceName}/layer.json")
-    public void getLayer(@PathVariable String serviceName, HttpServletResponse res) {
+    public void getLayerJson(@PathVariable String serviceName, HttpServletResponse res) {
         try {
             if (!validate(serviceName, res)) {
                 return;
             }
 
-            Layer layer = waterService.getLayer(serviceName);
+            byte[] bytes = waterService.getson(serviceName, "layer.json");
 
-            WebHelper.writeJson2Page(res, HttpStatus.OK, layer);
+            WebHelper.writeBytes(bytes, res);
         } catch (Exception ex) {
             log.error(ex.getMessage(), ex);
             WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
         }
     }
 
-    /**
-     * 鑾峰彇鍦板舰楂樺害鍥�
-     */
+    @ApiOperation(value = "鑾峰彇闄嶆按鏇茬嚎JSON")
+    @GetMapping("/{serviceName}/rainfall.json")
+    public void getRainfallJson(@PathVariable String serviceName, HttpServletResponse res) {
+        try {
+            if (!validate(serviceName, res)) {
+                return;
+            }
+
+            byte[] bytes = waterService.getson(serviceName, "rainfall.json");
+
+            WebHelper.writeBytes(bytes, res);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
+        }
+    }
+
+    @ApiOperation(value = "鑾峰彇寤虹瓚鐗╂秹姘碕SON")
+    @GetMapping("/{serviceName}/building.json")
+    public void getBuildingJson(@PathVariable String serviceName, HttpServletResponse res) {
+        try {
+            if (!validate(serviceName, res)) {
+                return;
+            }
+
+            byte[] bytes = waterService.getson(serviceName, "building.json");
+
+            WebHelper.writeBytes(bytes, res);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
+        }
+    }
+
+    @ApiOperation(value = "鑾峰彇绉按JSON")
+    @GetMapping("/{serviceName}/{timestamp}/water.json")
+    public void getWaterJson(@PathVariable String serviceName, @PathVariable String timestamp, HttpServletResponse res) {
+        try {
+            if (!validate(serviceName, res)) {
+                return;
+            }
+
+            byte[] bytes = waterService.getson(serviceName, "waters" + File.separator + timestamp + File.separator + "water.json");
+
+            WebHelper.writeBytes(bytes, res);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
+        }
+    }
+
+    @ApiOperation(value = "鑾峰彇鍦板舰楂樺害鍥�")
     @GetMapping("/{serviceName}/terrain")
     public void getTerraMap(@PathVariable String serviceName, Integer width, Integer height, HttpServletResponse res) {
         try {
@@ -71,16 +117,15 @@
             }
 
             String file = waterService.getTerraMap(serviceName, width, height);
-            writeFile(file, res);
+
+            WebHelper.writePng(file, res);
         } catch (Exception ex) {
             log.error(ex.getMessage(), ex);
             WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
         }
     }
 
-    /**
-     * 鑾峰彇姘撮潰楂樺害鍥�
-     */
+    @ApiOperation(value = "鑾峰彇姘撮潰楂樺害鍥�")
     @GetMapping("/{serviceName}/waterMap")
     public void getWaterMap(@PathVariable String serviceName, Integer width, Integer height, Long timestamp, HttpServletResponse res) {
         try {
@@ -88,17 +133,16 @@
                 return;
             }
 
-            String file = waterService.getWaterMap(serviceName, width, height);
-            writeFile(file, res);
+            String file = waterService.getWaterMap(serviceName, width, height, timestamp);
+
+            WebHelper.writePng(file, res);
         } catch (Exception ex) {
             log.error(ex.getMessage(), ex);
             WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
         }
     }
 
-    /**
-     * 鑾峰彇姘存祦鍚戞祦閫熷浘
-     */
+    @ApiOperation(value = "鑾峰彇姘存祦鍚戞祦閫熷浘")
     @GetMapping("/{serviceName}/flowMap")
     public void getFlowMap(@PathVariable String serviceName, Integer width, Integer height, Long timestamp, HttpServletResponse res) {
         try {
@@ -107,10 +151,77 @@
             }
 
             String file = waterService.getFlowMap(serviceName, width, height, timestamp);
-            writeFile(file, res);
+
+            WebHelper.writePng(file, res);
         } catch (Exception ex) {
             log.error(ex.getMessage(), ex);
             WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
+        }
+    }
+
+    @ApiOperation(value = "鏍规嵁鍧愭爣鏌ヨ绉按娣卞害")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "serviceName", value = "鏈嶅姟鍚�", dataType = "String", paramType = "path", example = "20241010095328"),
+            @ApiImplicitParam(name = "x", value = "X", dataType = "double", paramType = "query", example = "116.6447998"),
+            @ApiImplicitParam(name = "y", value = "Y", dataType = "double", paramType = "query", example = "39.8868915"),
+            @ApiImplicitParam(name = "timestamp", value = "鏃堕棿鎴�", dataType = "long", paramType = "query", example = "1730217660000")
+    })
+    @GetMapping("/{serviceName}/getWaterHeight")
+    public R<Object> getWaterHeight(@PathVariable String serviceName, double x, double y, long timestamp, HttpServletResponse res) {
+        try {
+            SimuPo simu = simuService.getSimuByServiceName(serviceName);
+            if (null == simu) {
+                return null;
+            }
+
+            Double depth = waterService.getWaterHeight(simu, x, y, timestamp);
+            Double area = waterService.getWaterArea(simu, x, y, timestamp);
+
+            return success(new PondingVo(depth, area));
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            return fail(ex);
+        }
+    }
+
+    @ApiOperation(value = "鏍规嵁seid鏌ヨ寤虹瓚鐗╂秹姘存繁搴�")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "serviceName", value = "鏈嶅姟鍚�", dataType = "String", paramType = "path", example = "20241010095328"),
+            @ApiImplicitParam(name = "seid", value = "X", dataType = "String", paramType = "query", example = "5_f128d8b1aba6455c88d2f42334ca62bb")
+    })
+    @GetMapping("/{serviceName}/getBuildingDepthBySeid")
+    public R<Object> getBuildingDepthBySeid(@PathVariable String serviceName, String seid) {
+        try {
+            if (StringHelper.isEmpty(serviceName) || StringHelper.isEmpty(seid)) {
+                return null;
+            }
+
+            // 鏍规嵁鏈嶅姟鍚�+鏃堕棿鎴�+鍧愭爣锛屾煡璇㈠搴旂殑绉按娣卞害
+            return success(waterService.getBuildingDepthBySeid(serviceName, seid));
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            return fail(ex);
+        }
+    }
+
+
+    @ApiOperation(value = "鏍规嵁timestamp鏌ヨ寤虹瓚鐗╂秹姘存繁搴�")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "serviceName", value = "鏈嶅姟鍚�", dataType = "String", paramType = "path", example = "20241010095328"),
+            @ApiImplicitParam(name = "timestamp", value = "鏃堕棿鎴�", dataType = "Long", paramType = "query", example = "1730217660000")
+    })
+    @GetMapping("/{serviceName}/getBuildingDepthByTime")
+    public R<Object> getBuildingDepthByTime(@PathVariable String serviceName, Long timestamp) {
+        try {
+            if (StringHelper.isEmpty(serviceName) || null == timestamp) {
+                return null;
+            }
+
+            // 鏍规嵁鏈嶅姟鍚�+鏃堕棿鎴�+鍧愭爣锛屾煡璇㈠搴旂殑绉按娣卞害
+            return success(waterService.getBuildingDepthByTime(serviceName, timestamp));
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            return fail(ex);
         }
     }
 
@@ -139,26 +250,9 @@
         if (null == height || height < MIN_SIZE || height > MAX_SIZE) {
             return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "鍥惧儚楂樺害涓嶈兘涓虹┖涓斿彇鍊艰寖鍥翠负" + MIN_SIZE + "~" + MAX_SIZE + "涔嬮棿");
         }
-        if (null == timestamp || timestamp < Y2000) {
-            return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "鏃堕棿涓嶈兘涓虹┖涓斿ぇ浜�2000骞�");
+        if (null == timestamp || timestamp < 0) {
+            return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "鏃堕棿涓嶈兘涓虹┖涓斿ぇ浜�0");
         }
-
-        return true;
-    }
-
-    /**
-     * 鍐欐枃浠�
-     */
-    private boolean writeFile(String path, HttpServletResponse res) throws Exception {
-        if (WebHelper.isEmpty(path)) {
-            return WebHelper.writeJson2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, "鐢熸垚PNG澶辫触");
-        }
-        File file = new File(path);
-        if (!file.exists() || file.isDirectory()) {
-            return WebHelper.writeJson2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, "PNG鏂囦欢鎵句笉鍒�");
-        }
-
-        WebHelper.download(path, file.getName(), res);
 
         return true;
     }

--
Gitblit v1.9.3