package com.dy.pipIrrRemote.mqttSd1.soil; import com.dy.common.aop.SsoAop; import com.dy.common.util.NumUtil; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.voRm.VoSoil; import com.dy.pipIrrGlobal.voRm.VoSoilDay; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; /** * @Author: liurunyu * @Date: 2025/6/26 09:31 * @Description */ @Slf4j @Tag(name = "墒情数据查询", description = "墒情数据查询") @RestController("rmSoilCtrl") @RequestMapping(path = "soil") @RequiredArgsConstructor public class SoilCtrl { private SoilSv sv; @Autowired public void setSv(SoilSv sv){ this.sv = sv ; } /** * 根据指定条件查询某气象站某一日记录 * @param soilId * @param yyyy_MM_dd * @return */ @GetMapping(path = "oneDay") @SsoAop() public BaseResponse oneDay(Long soilId, String yyyy_MM_dd){ try { if(soilId == null){ return BaseResponseUtils.buildFail("墒情站id不能为空") ; } if(yyyy_MM_dd == null || yyyy_MM_dd.trim().equals("")){ return BaseResponseUtils.buildFail("查询日期不能为空") ; } String ymdStr = yyyy_MM_dd.replaceAll("-", "") ; if(!NumUtil.isPlusIntNumber(ymdStr)){ return BaseResponseUtils.buildFail("查询日期格式不正确,格式规定为yyyy-MM-dd") ; } return BaseResponseUtils.buildSuccess(sv.oneDay(soilId, Integer.parseInt(ymdStr))); } catch (Exception e) { return BaseResponseUtils.buildException(e.getMessage()) ; } } /** * 根据指定条件查询某气象站某一日记录 * @param soilId * @param yyyy_MM * @return */ @GetMapping(path = "oneDayByMonth") @SsoAop() public BaseResponse> oneDayByMonth(Long soilId, String yyyy_MM){ try { if(soilId == null){ return BaseResponseUtils.buildFail("墒情站id不能为空") ; } if(yyyy_MM == null || yyyy_MM.trim().equals("")){ return BaseResponseUtils.buildFail("查询月份不能为空") ; } String ymdStr = yyyy_MM.replaceAll("-", "") ; if(!NumUtil.isPlusIntNumber(ymdStr)){ return BaseResponseUtils.buildFail("查询日期格式不正确,格式规定为yyyy-MM-dd") ; } Integer ymStart = Integer.parseInt(ymdStr) * 100; Integer ymEnd = Integer.parseInt(ymdStr) * 100 + 31; return BaseResponseUtils.buildSuccess(sv.oneDayByMonth(soilId, ymStart, ymEnd)); } catch (Exception e) { return BaseResponseUtils.buildException(e.getMessage()) ; } } /** * 根据指定条件查询某气象站一些日记录 * @param qo * @return */ @GetMapping(path = "oneSomeDay") @SsoAop() public BaseResponse>> oneSomeDay(SoilQo qo){ try { if(qo.soilId == null){ return BaseResponseUtils.buildFail("墒情站id不能为空") ; } qo.completionTime(); return BaseResponseUtils.buildSuccess(sv.someDay(qo)); } catch (Exception e) { return BaseResponseUtils.buildException(e.getMessage()) ; } } /** * 根据指定条件查询一些气象站日记录 * @param qo * @return */ @GetMapping(path = "someDay") @SsoAop() public BaseResponse>> someDay(SoilQo qo){ try { return BaseResponseUtils.buildSuccess(sv.someDay(qo)); } catch (Exception e) { return BaseResponseUtils.buildException(e.getMessage()) ; } } /** * 根据指定条件查询最新记录 * @param soilId * @return */ @GetMapping(path = "oneLast") @SsoAop() public BaseResponse oneLast(Long soilId){ try { return BaseResponseUtils.buildSuccess(sv.oneLast(soilId)); } catch (Exception e) { return BaseResponseUtils.buildException(e.getMessage()) ; } } /** * 根据指定条件查询历史记录 * @param qo * @return */ @GetMapping(path = "oneHistory") @SsoAop() public BaseResponse>> oneHistory(SoilQo qo){ try { if(qo.soilId == null){ return BaseResponseUtils.buildFail("墒情站id不能为空") ; } qo.completionTime(); return BaseResponseUtils.buildSuccess(sv.oneHistory(qo)); } catch (Exception e) { return BaseResponseUtils.buildException(e.getMessage()) ; } } /** * 根据指定条件查询最新记录 * @param qo * @return */ @GetMapping(path = "someLast") @SsoAop() public BaseResponse>> someLast(SoilQo qo){ try { qo.completionTime(); return BaseResponseUtils.buildSuccess(sv.someLast(qo)); } catch (Exception e) { return BaseResponseUtils.buildException(e.getMessage()) ; } } /** * 根据指定条件查询历史记录 * @param qo * @return */ @GetMapping(path = "someHistory") @SsoAop() public BaseResponse>> someHistory(SoilQo qo){ try { qo.completionTime(); return BaseResponseUtils.buildSuccess(sv.someHistory(qo)); } catch (Exception e) { return BaseResponseUtils.buildException(e.getMessage()) ; } } }