完成首页水库水位
parent
eceb1a00d8
commit
a8271d6ce5
|
|
@ -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<BigDecimal> queryChfllvByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){
|
||||
return R.ok(reservoirLevelService.queryChfllvByResId(resId));
|
||||
}
|
||||
|
||||
@Get(path = "/reservoirLevel/queryFlLowLimLev",summary = "根据水库ID查询汛限水位")
|
||||
public R<BigDecimal> queryFlLowLimLevByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){
|
||||
return R.ok(reservoirLevelService.queryFlLowLimLevByResId(resId));
|
||||
}
|
||||
|
||||
@Get(path = "/reservoirLevel/queryTotCap",summary = "根据水库ID查询总库容")
|
||||
public R<BigDecimal> queryTotCapByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){
|
||||
return R.ok(reservoirLevelService.queryTotCapByResId(resId));
|
||||
}
|
||||
|
||||
@Get(path = "/reservoirLevel/queryDeadLev",summary = "根据水库ID查询死水位")
|
||||
public R<BigDecimal> queryDeadLevByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){
|
||||
return R.ok(reservoirLevelService.queryDeadLevByResId(resId));
|
||||
}
|
||||
|
||||
@Get(path = "/reservoirLevel/queryRz",summary = "根据水库ID查询实时水位")
|
||||
public R<BigDecimal> queryRzByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){
|
||||
return R.ok(reservoirLevelService.queryRzByResId(resId));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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<StResStcdRef> {
|
||||
int batchInsert(@Param("list") List<StResStcdRef> list);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
select top 1 RZ from ST_RES_STCD_REF,ST_RSVR_R
|
||||
where ST_RES_STCD_REF.STCD = ST_RSVR_R.STCD and
|
||||
ST_RES_STCD_REF.RES_ID = #{resId}
|
||||
order by ST_RSVR_R.TM Desc;
|
||||
</script>
|
||||
""")
|
||||
BigDecimal queryRzByResId(@Param("resId") String resId);
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue