kaiyu
2021-12-30 bd9a7f2d97af968d43ccd5516644f6933b42f5b2
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
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 AreaPollutionLevelForm
 * @Description TODO
 * @Author 陈凯裕
 * @Date 2021/12/30 10:37
 * @Version TODO
 **/
@Data
public class AreaPollutionLevelForm {
 
    /*
     * 地区码
     * */
    private Integer regionCode;
 
    /*
     * 如果是查年数据则该参数不能为空
     * */
    @DateTimeFormat(pattern = "yyyy")
    @JsonFormat(pattern = "yyyy", timezone = "GMT+8")
    private Date year;
 
    /*
     * 如果是查月数据则该参数不能为空
     * */
    @DateTimeFormat(pattern = "yyyy-MM")
    @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8")
    private Date month;
 
    /*
     * 用于查询数据的开始时间,由form自行转换
     * */
    private Date startDate;
 
    /*
     * 用于查询数据的结束时间,由form自行转换
     * */
    private Date endDate;
 
    public boolean valid() {
        if (regionCode == null || (year == null && month == null)||(year != null && month != null))
            return false;
        //检查regionCode格式
        String regionCodeStr = regionCode.toString();
        if (!regionCodeStr.substring(regionCodeStr.length() - 2, regionCodeStr.length()).equals("00"))
            return false;
        //时间转换
        if (year != null) {
            startDate = DateUtils.getFirstDayOfYear(year);
            endDate = DateUtils.getLastDayOfYear(year);
            return true;
        }
        startDate = DateUtils.getFirstDayOfMonth(month);
        endDate = DateUtils.getLastDayOfMonth(month);
        return true;
    }
 
 
}