From 2303ba3d0bcc38607dd01329a12e4f4b74b444c0 Mon Sep 17 00:00:00 2001
From: xingjinshuang <xingjs@qq.com>
Date: 星期五, 27 十二月 2024 17:49:53 +0800
Subject: [PATCH] @xingjs@20241227@优化解决获取建筑物图层方法

---
 src/main/java/com/se/simu/controller/WaterController.java |   34 +++++++++++++++++++++++++---------
 1 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/se/simu/controller/WaterController.java b/src/main/java/com/se/simu/controller/WaterController.java
index 4befa5a..8141dbc 100644
--- a/src/main/java/com/se/simu/controller/WaterController.java
+++ b/src/main/java/com/se/simu/controller/WaterController.java
@@ -1,6 +1,7 @@
 package com.se.simu.controller;
 
 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;
@@ -19,16 +20,12 @@
 
 import javax.annotation.Resource;
 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 extends BaseController {
     @Resource
@@ -86,6 +83,23 @@
             }
 
             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) {
@@ -153,15 +167,17 @@
             @ApiImplicitParam(name = "timestamp", value = "鏃堕棿鎴�", dataType = "long", paramType = "query", example = "1730217660000")
     })
     @GetMapping("/{serviceName}/getWaterHeight")
-    public R<Double> getWaterHeight(@PathVariable String serviceName, double x, double y, long timestamp, HttpServletResponse res) {
+    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;
             }
 
-            // 鏍规嵁鏈嶅姟鍚�+鏃堕棿鎴�+鍧愭爣锛屾煡璇㈠搴旂殑绉按娣卞害
-            return success(waterService.getWaterHeight(simu, x, y, timestamp));
+            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);

--
Gitblit v1.9.3