1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.dy.pipIrrWechat.vapor;
 
import com.dy.common.util.DateTime;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pipIrrGlobal.pojoMd.MdEt0;
import io.swagger.v3.oas.annotations.tags.Tag;
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.ArrayList;
import java.util.List;
 
/**
 * @Author: liurunyu
 * @Date: 2025/8/19 16:21
 * @Description
 */
@Slf4j
@Tag(name = "作物日蒸腾量", description = "作物日蒸腾量查询等操作")
@RestController
@RequestMapping(path = "mdVapor")
public class VaporCtrl {
 
    private VaporSv sv;
 
    @Autowired
    private void setSv(VaporSv sv) { this.sv = sv; }
 
 
    /**
     * 客户端请求得到所有作物的昨日蒸腾量
     * @return 所有所有作物的昨日蒸腾量
     */
    @GetMapping(path = "allCropsWithYesterday")
    public BaseResponse<List<MdEt0>> allYesterday(){
        try {
            String ymd = DateTime.yesterday_yyyy_MM_dd(
                    Integer.parseInt(DateTime.yyyy()),
                    Integer.parseInt(DateTime.MM()),
                    Integer.parseInt(DateTime.dd())) ;
            List<MdEt0> res = this.sv.selectEt0(ymd) ;
            return BaseResponseUtils.buildSuccess(res);
        } catch (Exception e) {
            log.error("查询所有作物的昨日蒸腾量异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
 
    /**
     * 根据指定条件作物查询一段时间内的蒸腾量
     * @param qo
     * @return
     */
    @GetMapping(path = "oneCropsSomeEt0")
    public BaseResponse<List<MdEt0>> oneCropsSomeEt0(VaporQo qo){
        try {
            if(qo.cropId == null){
                return BaseResponseUtils.buildFail("作物id不能为空") ;
            }
            if(qo.timeStop == null || qo.timeStop.trim().equals("")){
                qo.timeStop = DateTime.yyyy_MM_dd() ;
            }
            if(qo.timeStart == null || qo.timeStart.trim().equals("")){
                qo.timeStart = DateTime.lastXDay_yyyy_MM_dd(qo.timeStop, 10);
            }
            List<MdEt0> list = sv.oneCropsSomeEt0(qo) ;
            if(list == null){
                list = new ArrayList<>() ;
            }
            return BaseResponseUtils.buildSuccess(list);
        } catch (Exception e) {
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
 
}