|  |  | 
 |  |  |     Integer regionCode; | 
 |  |  |  | 
 |  |  |     /* | 
 |  |  |     * 地区类型 0为市内城市,1为省内城市,2为28城市 | 
 |  |  |     * 地区类型 city为市内城市,province为省内城市,28为28城市 | 
 |  |  |     * */ | 
 |  |  |     String regionType; | 
 |  |  |  | 
 |  |  |     /* | 
 |  |  |     * 对比类型,0为同比 1为环比 | 
 |  |  |     * 对比类型,yoy为同比 mom为环比 | 
 |  |  |     * */ | 
 |  |  |     String comparisonType; | 
 |  |  |  | 
 |  |  |     /* | 
 |  |  |      * 查询年份数据的时候需要传递,非必传 | 
 |  |  |      * */ | 
 |  |  |     @DateTimeFormat(pattern = "yyyy") | 
 |  |  |     @JsonFormat(pattern = "yyyy", timezone = "GMT+8") | 
 |  |  |     Date year; | 
 |  |  |     String dateType; | 
 |  |  |  | 
 |  |  |     /* | 
 |  |  |      * 查询年份数据的时候需要传递,非必传 | 
 |  |  |      * */ | 
 |  |  |     @DateTimeFormat(pattern = "yyyy-MM") | 
 |  |  |     @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") | 
 |  |  |     Date month; | 
 |  |  |     String time; | 
 |  |  |  | 
 |  |  |     /* | 
 |  |  |      * 自定义开始时间,非必传 | 
 |  |  | 
 |  |  |     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | 
 |  |  |     Date endDate; | 
 |  |  |  | 
 |  |  |     /* | 
 |  |  |     * 对比开始时间 | 
 |  |  |     * */ | 
 |  |  |     Date comparisonStartDate; | 
 |  |  |  | 
 |  |  |     /* | 
 |  |  |     * 对比结束时间 | 
 |  |  |     * */ | 
 |  |  |     Date comparisonEndDate; | 
 |  |  |  | 
 |  |  |     public boolean valid() { | 
 |  |  |         //校验地区类型对应的地区码 | 
 |  |  |         if(regionType==null||comparisonType==null) | 
 |  |  | 
 |  |  |         } | 
 |  |  |         if (regionType.equals(Constants.PROVINCE_TYPE)) { | 
 |  |  |             String regionCodeStr = regionCode.toString(); | 
 |  |  |             if (!regionCodeStr.substring(regionCodeStr.length() - 4, regionCodeStr.length()).equals("0000")) | 
 |  |  |                 return false; | 
 |  |  |             regionCode = Integer.parseInt(regionCodeStr.substring(0,regionCodeStr.length()-4)+"0000"); | 
 |  |  |         } | 
 |  |  |         //时间转换 | 
 |  |  |         if (year != null) { | 
 |  |  |             if(month!=null) | 
 |  |  |                 return false; | 
 |  |  |             startDate = DateUtils.getFirstDayOfYear(year); | 
 |  |  |             endDate = DateUtils.getLastDayOfYear(year); | 
 |  |  |             return true; | 
 |  |  |         if(dateType.equals(Constants.MONTH)){ | 
 |  |  |             Date date = DateUtils.getDate(time, "yyyy-MM"); | 
 |  |  |             startDate = DateUtils.getFirstDayOfMonth(date); | 
 |  |  |             endDate = DateUtils.getLastDayOfMonth(date); | 
 |  |  |         } | 
 |  |  |         if (month != null) { | 
 |  |  |             if(year!=null) | 
 |  |  |                 return false; | 
 |  |  |             startDate = DateUtils.getFirstDayOfMonth(month); | 
 |  |  |             endDate = DateUtils.getLastDayOfMonth(month); | 
 |  |  |             return true; | 
 |  |  |         } | 
 |  |  |         if(startDate!=null&&endDate!=null) | 
 |  |  |             return true; | 
 |  |  |  | 
 |  |  |         return false; | 
 |  |  |         if(dateType.equals(Constants.YEAR)){ | 
 |  |  |             Date date = DateUtils.getDate(time, "yyyy"); | 
 |  |  |             startDate = DateUtils.getFirstDayOfYear(date); | 
 |  |  |             endDate = DateUtils.getLastDayOfYear(date); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if(startDate==null||endDate==null) | 
 |  |  |             return false; | 
 |  |  |  | 
 |  |  |         calculateComparisonDate(); | 
 |  |  |  | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |     * @Description: 计算对比时间 | 
 |  |  |             * @Param: [startDate, endDate] | 
 |  |  |             * @return: void | 
 |  |  |             * @Author: 陈凯裕 | 
 |  |  |             * @Date: 2022/1/14 | 
 |  |  |             */ | 
 |  |  |     private void calculateComparisonDate(){ | 
 |  |  |         if(comparisonType.equals(Constants.MOM)){ | 
 |  |  |             comparisonStartDate = DateUtils.addMonths(startDate,-1); | 
 |  |  |             comparisonEndDate = DateUtils.addMonths(endDate,-1); | 
 |  |  |         }else{ | 
 |  |  |             comparisonStartDate = DateUtils.addMonths(startDate,-12); | 
 |  |  |             comparisonEndDate = DateUtils.addMonths(endDate,-12); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | } |