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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package com.dy.pipIrrStatistics.stClient;
 
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.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.voSt.VoStClientAmountDay;
import com.dy.pipIrrGlobal.voSt.VoStClientAmountMonth;
import com.dy.pipIrrGlobal.voSt.VoStClientAmountYear;
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.ArrayList;
import java.util.List;
 
/**
 * @Author: liurunyu
 * @Date: 2024/12/30 15:22
 * @Description
 */
@Slf4j
@RestController
@RequestMapping(path="stClient")
@RequiredArgsConstructor
public class StClientCtrl {
 
    private static final int startYear4YearStatistics = 2024 ;
 
    private StClientSv sv ;
 
    @Autowired
    private void setSv(StClientSv sv){
        this.sv = sv ;
    }
 
    /**
     * 查询指定年月农户各日用水量
     * @param qo
     * @return
     */
    @GetMapping(path = "/amountOfDay")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoStClientAmountDay>>> amountOfDay(StClientQo qo) throws Exception {
        String yearMonth = qo.getYearMonth();
        if(yearMonth == null || yearMonth.trim().equals("")) {
            return BaseResponseUtils.buildErrorMsg("查询条件年月不能为空");
        }
        int[] ymd = DateTime.yyyy_MM_ymdGroup(yearMonth) ;
        qo.year = ymd[0] ;
        qo.month = ymd[1] ;
        return BaseResponseUtils.buildSuccess(this.sv.selectStClientAmountDay(qo));
    }
 
 
    /**
     * 查询指定年农户各月用水量
     * @param qo
     * @return
     */
    @GetMapping(path = "/amountOfMonth")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoStClientAmountMonth>>> amountOfMonth(StClientQo qo) throws Exception {
        if(qo.year == null) {
            return BaseResponseUtils.buildErrorMsg("查询条件年度不能为空");
        }
        return BaseResponseUtils.buildSuccess(this.sv.selectStClientAmountMonth(qo));
    }
 
 
 
    /**
     * 查询指定年农户各年用水量
     * @param qo
     * @return
     */
    @GetMapping(path = "/amountOfYear")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoStClientAmountYear>>> amountOfYear(StClientQo qo) throws Exception {
        List<Integer> yearGrp = new ArrayList<Integer>();
        int nowYear = Integer.parseInt(DateTime.yyyy()) ;
        if(qo.year == null) {
            for(int i = startYear4YearStatistics; i <= nowYear; i++) {
                yearGrp.add(i) ;
            }
        }else{
            if(qo.year > nowYear){
                qo.year = nowYear;
            }
            if(qo.year < startYear4YearStatistics){
                qo.year = startYear4YearStatistics;
            }
            yearGrp.add(qo.year) ;
        }
        return BaseResponseUtils.buildSuccess(this.sv.selectStClientAmountYear(qo, yearGrp));
    }
}