From f7c642eed8ae076553f95a1f0ac5fd2e7c31b6a1 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期四, 31 十月 2024 18:00:37 +0800
Subject: [PATCH] 修改返回值

---
 src/main/java/com/se/simu/controller/WaterController.java |    9 +++++----
 src/main/java/com/se/simu/service/WaterService.java       |    9 +++------
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/se/simu/controller/WaterController.java b/src/main/java/com/se/simu/controller/WaterController.java
index 68e77d5..d0f2df3 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.R;
 import com.se.simu.helper.WebHelper;
 import com.se.simu.service.SimuService;
 import com.se.simu.service.WaterService;
@@ -28,7 +29,7 @@
 @Slf4j
 @RestController
 @RequestMapping("/waterlogging")
-public class WaterController {
+public class WaterController extends BaseController {
     @Resource
     SimuService simuService;
 
@@ -134,7 +135,7 @@
             @ApiImplicitParam(name = "y", value = "Y", dataType = "double", paramType = "query", example = "39.8868915"),
             @ApiImplicitParam(name = "timestamp", value = "鏃堕棿鎴�", dataType = "long", paramType = "query", example = "1730217660000")
     })
-    public Double getWaterHeight(@PathVariable String serviceName, double x, double y, long timestamp, HttpServletResponse res) {
+    public R<Double> getWaterHeight(@PathVariable String serviceName, double x, double y, long timestamp, HttpServletResponse res) {
         try {
             SimuPo simu = simuService.getSimuByServiceName(serviceName);
             if (null == simu) {
@@ -142,10 +143,10 @@
             }
 
             // 鏍规嵁鏈嶅姟鍚�+鏃堕棿鎴�+鍧愭爣锛屾煡璇㈠搴旂殑绉按娣卞害
-            return waterService.getWaterHeight(simu, x, y, timestamp);
+            return success(waterService.getWaterHeight(simu, x, y, timestamp));
         } catch (Exception ex) {
             log.error(ex.getMessage(), ex);
-            return null;
+            return fail(ex);
         }
     }
 
diff --git a/src/main/java/com/se/simu/service/WaterService.java b/src/main/java/com/se/simu/service/WaterService.java
index 19a4736..07beea4 100644
--- a/src/main/java/com/se/simu/service/WaterService.java
+++ b/src/main/java/com/se/simu/service/WaterService.java
@@ -152,11 +152,10 @@
                 return null;
             }
 
-            double[] values = new double[1];
-            ds.GetRasterBand(1).ReadRaster(XY[0], XY[1], 1, 1, values);
-            double val = values[0];
+            double[] vals = new double[1];
+            ds.GetRasterBand(1).ReadRaster(XY[0], XY[1], 1, 1, vals);
 
-            return isValid(val) ? val : null;
+            return isValid(vals[0]) ? vals[0] : null;
         } catch (Exception ex) {
             log.error(ex.getMessage(), ex);
             return null;
@@ -184,8 +183,6 @@
      * @return 鍍忕礌鍧愭爣
      */
     public int[] coordinates2ColRow(double[] gt, double x, double y) {
-        int[] ints = new int[2];
-
         // 鍚戜笅鍙栨暣,濡傛灉鍚戜笂鍙栨暣浼氬鑷磋绠楃粨鏋滃亸澶э紝浠庤�屽湪鍚庨潰璇诲彇鍒伴偦杩戝儚鍏冪殑鏁版嵁
         //Double col = Math.floor(((y - gt[3]) * gt[1] - (x - gt[0]) * gt[4]) / (gt[5] * gt[1] - gt[2] * gt[4]));
         Double col = Math.floor((y * gt[1] - x * gt[4] + gt[0] * gt[4] - gt[3] * gt[1]) / (gt[5] * gt[1] - gt[2] * gt[4]));

--
Gitblit v1.9.3