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; 
 | 
    } 
 | 
} 
 |