cjl
2023-11-08 0e4aa8d08a3bf8e8683d05081baefdbf96ce080f
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
package com.moral.api.pojo.form.aqi;
 
import com.fasterxml.jackson.annotation.JsonFormat;
import com.moral.util.DateUtils;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
 
import java.util.Date;
 
/**
 * @ClassName QueryPollutionLevelsForPieChartFrom
 * @Description TODO
 * @Author 陈凯裕
 * @Date 2021/11/11 8:37
 * @Version TODO
 **/
@Data
public class ChartOfPollutionLevelForm {
 
    /*
     * 地区码 必传
     * */
    Integer regionCode;
 
    /*
     * 查询年份数据的时候需要传递,非必传
     * */
    @DateTimeFormat(pattern = "yyyy")
    @JsonFormat(pattern = "yyyy", timezone = "GMT+8")
    Date year;
 
    /*
     * 自定义开始时间,非必传
     * */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    Date startDate;
 
    /*
     * 自定义结束时间,非必传
     * */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    Date endDate;
 
    public boolean valid() {
        if (regionCode == null)
            return false;
        //如果没有自定义时间,则为查询年份数据
        if (startDate == null || endDate == null) {
            if (year == null)
                return false;
            //判断是否为今年
            if (DateUtils.isCurrentYear(year)) {
                startDate = DateUtils.getFirstDayOfCurrYear();
                endDate = DateUtils.getYesterdayDate();
                return true;
            }else{
                startDate = DateUtils.getFirstDayOfYear(year);
                endDate = DateUtils.getLastDayOfYear(year);
                return true;
            }
        }
        return true;
    }
}