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 | 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