From 8612e42fb5612e6c9db4cc019964574d82839721 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 22 八月 2025 10:53:04 +0800
Subject: [PATCH] 为前端提供蒸腾量测试计算逻辑功能

---
 pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestInitVo.java |   16 +++++
 pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestQo.java     |   21 +++++++
 pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestCtrl.java   |   80 ++++++++++++++++++++++++++
 pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestSv.java     |   40 +++++++++++++
 4 files changed, 157 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestCtrl.java
new file mode 100644
index 0000000..d018757
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestCtrl.java
@@ -0,0 +1,80 @@
+package com.dy.pipIrrModel.vapor;
+
+import com.dy.common.aop.SsoAop;
+import com.dy.common.util.DateTime;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.pipIrrModel.modelCalculate.Hargreaves;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2025/8/22 10:20
+ * @Description 涓嶈鍒犻櫎锛侊紒锛� 涓哄墠绔捀鑵鹃噺璁$畻鎻愪緵鐨勬湇鍔�
+ */
+
+@Slf4j
+@Tag(name = "浣滅墿鏃ヨ捀鑵鹃噺璁$畻娴嬭瘯", description = "浣滅墿鏃ヨ捀鑵鹃噺璁$畻娴嬭瘯")
+@RestController
+@RequestMapping(path = "mdTest")
+public class TestCtrl {
+
+    private TestSv sv;
+
+    @Autowired
+    private void setSv(TestSv sv) { this.sv = sv; }
+
+    /**
+     * 寰楀埌鍒濆鍖栨暟鎹�
+     */
+    @GetMapping(path = "initData")
+    @SsoAop()
+    public BaseResponse<TestInitVo> initData(){
+        try {
+            TestInitVo vo = new TestInitVo();
+            String yesterday_ymd = DateTime.lastXDay_yyyy_MM_dd(1) ;
+            Long days = DateTime.daysBetweenyyyy_MM_dd(yesterday_ymd, DateTime.yyyy() + "-01-01");
+            vo.dateIndex = days.intValue() + 1 ;
+            vo.ymd = yesterday_ymd ;
+
+            Object[] objs = this.sv.getOneWeatherNameAndLat() ;
+            if(objs != null){
+                vo.weatherName = objs[0].toString() ;
+                vo.lat = Double.parseDouble(objs[1].toString()) ;
+            }else{
+                vo.weatherName = "" ;
+                vo.lat = 0.0 ;
+            }
+            return BaseResponseUtils.buildSuccess(vo);
+        } catch (Exception e) {
+            log.error("鏌ヨ鎵�鏈変綔鐗╃殑鏄ㄦ棩钂歌吘閲忓紓甯�", e);
+            return BaseResponseUtils.buildException(e.getMessage()) ;
+        }
+    }
+
+    @PostMapping(path = "calculate", consumes = MediaType.APPLICATION_JSON_VALUE)
+    @SsoAop()
+    public BaseResponse<Double> calculate(@RequestBody TestQo qo){
+        try {
+            Double fai = Hargreaves.rad(qo.lat);
+
+            Double sunMagnetismAngular = Hargreaves.sunMagnetismAngular(qo.dateIndex);
+
+            Double sunEarthDistance = Hargreaves.sunEarthDistance(qo.dateIndex);
+
+            Double sunTimeAngular = Hargreaves.sunTimeAngular(fai, sunMagnetismAngular);
+
+            Double zenithRadiation = Hargreaves.zenithRadiation(sunEarthDistance, sunTimeAngular, fai, sunMagnetismAngular);
+
+            Double et0 = Hargreaves.ET0(qo.kc, qo.maxTmp, qo.minTmp, zenithRadiation);
+            return BaseResponseUtils.buildSuccess(et0);
+        } catch (Exception e) {
+            log.error("鏌ヨ鎵�鏈変綔鐗╃殑鏄ㄦ棩钂歌吘閲忓紓甯�", e);
+            return BaseResponseUtils.buildException(e.getMessage()) ;
+        }
+    }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestInitVo.java b/pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestInitVo.java
new file mode 100644
index 0000000..5db9e03
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestInitVo.java
@@ -0,0 +1,16 @@
+package com.dy.pipIrrModel.vapor;
+
+import lombok.Data;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2025/8/22 10:23
+ * @Description
+ */
+@Data
+public class TestInitVo {
+    public Double lat ;
+    public String weatherName ;
+    public Integer dateIndex ;
+    public String ymd ;
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestQo.java b/pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestQo.java
new file mode 100644
index 0000000..e1bcefa
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestQo.java
@@ -0,0 +1,21 @@
+package com.dy.pipIrrModel.vapor;
+
+import lombok.*;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2025/8/22 10:47
+ * @Description
+ */
+@Data
+@Builder
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class TestQo {
+    public Double lat ;
+    public Integer dateIndex ;
+    public Double kc ;
+    public Double maxTmp ;
+    public Double minTmp ;
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestSv.java
new file mode 100644
index 0000000..0cfc98d
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-model/src/main/java/com/dy/pipIrrModel/vapor/TestSv.java
@@ -0,0 +1,40 @@
+package com.dy.pipIrrModel.vapor;
+
+import com.dy.pipIrrGlobal.daoMd.MdCropsMapper;
+import com.dy.pipIrrGlobal.daoPr.PrStWeatherMapper;
+import com.dy.pipIrrGlobal.voPr.VoMqttSimple;
+import com.dy.pipIrrGlobal.voPr.VoWeather;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2025/8/22 10:21
+ * @Description
+ */
+@Slf4j
+@Service
+public class TestSv {
+
+    private PrStWeatherMapper prStWeatherDao;
+
+    @Autowired
+    private void setDao(PrStWeatherMapper prStWeatherDao) {
+        this.prStWeatherDao = prStWeatherDao;
+    }
+
+    public Object[] getOneWeatherNameAndLat(){
+        List<VoMqttSimple> list = this.prStWeatherDao.selectAllSimple() ;
+        if(list != null && list.size() > 0){
+            VoMqttSimple vos = list.get(0) ;
+            if(vos != null && vos.id != null){
+                VoWeather wvo = this.prStWeatherDao.selectOne(vos.id) ;
+                return new Object[]{wvo.name, wvo.lat} ;
+            }
+        }
+        return null ;
+    }
+}

--
Gitblit v1.8.0