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/TestCtrl.java | 80 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 80 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()) ; + } + } +} -- Gitblit v1.8.0