From a8271d6ce5b34e0a1d4993f58828e398c9da18d8 Mon Sep 17 00:00:00 2001 From: hqx <3376194473@qq.com> Date: Thu, 1 Feb 2024 17:25:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=A6=96=E9=A1=B5=E6=B0=B4?= =?UTF-8?q?=E5=BA=93=E6=B0=B4=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xyt/controller/HomePageController.java | 58 ++++++++++++ .../xyt/mapper/StResStcdRefMapper.java | 13 +++ .../xyt/service/ReservoirLevelService.java | 94 +++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100644 src/main/java/com/gunshi/project/xyt/controller/HomePageController.java create mode 100644 src/main/java/com/gunshi/project/xyt/service/ReservoirLevelService.java diff --git a/src/main/java/com/gunshi/project/xyt/controller/HomePageController.java b/src/main/java/com/gunshi/project/xyt/controller/HomePageController.java new file mode 100644 index 0000000..220507d --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/controller/HomePageController.java @@ -0,0 +1,58 @@ +package com.gunshi.project.xyt.controller; + +import com.gunshi.core.annotation.Get; +import com.gunshi.core.result.R; +import com.gunshi.project.xyt.service.ReservoirLevelService; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.math.BigDecimal; + +/** + * TODO + * + * @ClassName HomePageController + * @Author Huang Qianxiang + * @Date 2024/2/1 15:34 + */ + +@Slf4j +@Tag(name = "首页接口") +@RestController +@RequestMapping("/homePage") +public class HomePageController { + + @Resource + private ReservoirLevelService reservoirLevelService; + + @Get(path = "/reservoirLevel/queryChfllv",summary = "根据水库ID查询校核洪水位") + public R queryChfllvByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){ + return R.ok(reservoirLevelService.queryChfllvByResId(resId)); + } + + @Get(path = "/reservoirLevel/queryFlLowLimLev",summary = "根据水库ID查询汛限水位") + public R queryFlLowLimLevByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){ + return R.ok(reservoirLevelService.queryFlLowLimLevByResId(resId)); + } + + @Get(path = "/reservoirLevel/queryTotCap",summary = "根据水库ID查询总库容") + public R queryTotCapByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){ + return R.ok(reservoirLevelService.queryTotCapByResId(resId)); + } + + @Get(path = "/reservoirLevel/queryDeadLev",summary = "根据水库ID查询死水位") + public R queryDeadLevByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){ + return R.ok(reservoirLevelService.queryDeadLevByResId(resId)); + } + + @Get(path = "/reservoirLevel/queryRz",summary = "根据水库ID查询实时水位") + public R queryRzByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){ + return R.ok(reservoirLevelService.queryRzByResId(resId)); + } + +} diff --git a/src/main/java/com/gunshi/project/xyt/mapper/StResStcdRefMapper.java b/src/main/java/com/gunshi/project/xyt/mapper/StResStcdRefMapper.java index 2f8a521..50c67c5 100644 --- a/src/main/java/com/gunshi/project/xyt/mapper/StResStcdRefMapper.java +++ b/src/main/java/com/gunshi/project/xyt/mapper/StResStcdRefMapper.java @@ -2,11 +2,24 @@ package com.gunshi.project.xyt.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.gunshi.project.xyt.model.StResStcdRef; + +import java.math.BigDecimal; import java.util.List; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; @Mapper public interface StResStcdRefMapper extends BaseMapper { int batchInsert(@Param("list") List list); + + @Select(""" + + """) + BigDecimal queryRzByResId(@Param("resId") String resId); } \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/service/ReservoirLevelService.java b/src/main/java/com/gunshi/project/xyt/service/ReservoirLevelService.java new file mode 100644 index 0000000..8d89357 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/service/ReservoirLevelService.java @@ -0,0 +1,94 @@ +package com.gunshi.project.xyt.service; + +import com.gunshi.project.xyt.mapper.StResStcdRefMapper; +import com.gunshi.project.xyt.model.StResB; +import com.gunshi.project.xyt.model.StResBAutoDao; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; + +/** + * TODO + * + * @ClassName ReservoirLevelService + * @Author Huang Qianxiang + * @Date 2024/2/1 15:37 + */ +@Service +@Slf4j +@Transactional(rollbackFor = Exception.class) +public class ReservoirLevelService { + + @Resource + private StResBAutoDao stResBAutoDao; + @Resource + private StResStcdRefMapper stResStcdRefMapper; + + /** + * 根据水库ID查询校核洪水位 + * @param resId 水库ID + * @return 校核洪水位 + */ + public BigDecimal queryChfllvByResId(String resId){ + StResB stResB = stResBAutoDao.getById(resId); + if (stResB == null){ + throw new IllegalArgumentException("该水库ID不存在"); + } + return stResB.getChfllv(); + } + + /** + * 根据水库ID查询汛限水位 + * @param resId 水库ID + * @return 汛限水位 + */ + public BigDecimal queryFlLowLimLevByResId(String resId){ + StResB stResB = stResBAutoDao.getById(resId); + if (stResB == null){ + throw new IllegalArgumentException("该水库ID不存在"); + } + return stResB.getFlLowLimLev(); + } + + /** + * 根据水库ID查询总库容 + * @param resId 水库ID + * @return 总库容 + */ + public BigDecimal queryTotCapByResId(String resId){ + StResB stResB = stResBAutoDao.getById(resId); + if (stResB == null){ + throw new IllegalArgumentException("该水库ID不存在"); + } + return stResB.getTotCap(); + } + + /** + * 根据水库ID查询死水位 + * @param resId 水库ID + * @return 死水位 + */ + public BigDecimal queryDeadLevByResId(String resId){ + StResB stResB = stResBAutoDao.getById(resId); + if (stResB == null){ + throw new IllegalArgumentException("该水库ID不存在"); + } + return stResB.getDeadLev(); + } + + /** + * 根据水库ID查询实时水位 + * @param resId 水库ID + * @return 实时水位 + */ + public BigDecimal queryRzByResId(String resId){ + StResB stResB = stResBAutoDao.getById(resId); + if (stResB == null){ + throw new IllegalArgumentException("该水库ID不存在"); + } + return stResStcdRefMapper.queryRzByResId(resId); + } +}