|  |  | 
 |  |  | import org.springframework.format.annotation.DateTimeFormat; | 
 |  |  |  | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.List; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * @ClassName MonitorPointDataDisplayForm | 
 |  |  | 
 |  |  |  | 
 |  |  |     /* | 
 |  |  |      * 站点id | 
 |  |  |      * */ | 
 |  |  |     private Integer monitorPointId; | 
 |  |  |      */ | 
 |  |  | //    private Integer monitorPointId; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * mac号 | 
 |  |  |      */ | 
 |  |  |     private List<String>  macs; | 
 |  |  |  | 
 |  |  |     /* | 
 |  |  |      * 开始时间 | 
 |  |  |      * */ | 
 |  |  |     @DateTimeFormat(pattern = "yyyy-MM-dd") | 
 |  |  |     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | 
 |  |  |     @DateTimeFormat(pattern = "yyyy-MM-dd HH") | 
 |  |  |     @JsonFormat(pattern = "yyyy-MM-dd HH", timezone = "GMT+8") | 
 |  |  |     private Date startTime; | 
 |  |  |  | 
 |  |  |     /* | 
 |  |  |      * 结束时间 | 
 |  |  |      * */ | 
 |  |  |     @DateTimeFormat(pattern = "yyyy-MM-dd") | 
 |  |  |     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | 
 |  |  |     @DateTimeFormat(pattern = "yyyy-MM-dd HH") | 
 |  |  |     @JsonFormat(pattern = "yyyy-MM-dd HH", timezone = "GMT+8") | 
 |  |  |     private Date endTime; | 
 |  |  |  | 
 |  |  |     /* | 
 |  |  | 
 |  |  |     /* | 
 |  |  |      * 检测数据是否有效 | 
 |  |  |      * */ | 
 |  |  |     public boolean valid() { | 
 |  |  |         if (monitorPointId == null) | 
 |  |  |             return false; | 
 |  |  |         if (reportType == null) { | 
 |  |  |             if (startTime == null || endTime == null) | 
 |  |  |                 return false; | 
 |  |  |             reportType = Constants.DAILYREPORT; | 
 |  |  |             //结束时间获取当天最后一个小时 | 
 |  |  |             String endTimeStr = DateUtils.dateToDateString(endTime,"yyyy-MM-dd"); | 
 |  |  |             endTimeStr+=" 23:59:59"; | 
 |  |  |             endTime = DateUtils.getDate(endTimeStr,"yyyy-MM-dd HH:mm:ss"); | 
 |  |  |         } else { | 
 |  |  |             if(startTime!=null&&endTime!=null) | 
 |  |  |                 return false; | 
 |  |  |             if (reportType.equals(Constants.HOURYLYREPORT)) { | 
 |  |  |                 //时报选项默认为上个小时的数据 | 
 |  |  |                 Date previousHour = DateUtils.getDateOfMin(new Date(), -60); | 
 |  |  |                 startTime = DateUtils.getHourlyStartTime(previousHour); | 
 |  |  |             } else if (reportType.equals(Constants.DAILYREPORT)) { | 
 |  |  |                 //日报选项默认为昨天的数据 | 
 |  |  |                 Date yesterday = DateUtils.getDateOfDay(new Date(),-1); | 
 |  |  |                 startTime = DateUtils.getDailyStartTime(yesterday); | 
 |  |  |             } else if (reportType.equals(Constants.WEEKLYREPORT)) { | 
 |  |  |                 //周报选项默认为上周的数据 | 
 |  |  |                 Date previous = DateUtils.getDateOfDay(new Date(),-7); | 
 |  |  |                 startTime = DateUtils.getWeeklyStartTime(previous); | 
 |  |  |             } else if (reportType.equals(Constants.MONTHLYREPORT)) { | 
 |  |  |                 //月报选项默认为上月的数据 | 
 |  |  |                 Date lastMonthFirstDay = DateUtils.getFirstDayOfLastMonth(); | 
 |  |  |                 startTime = DateUtils.getMonthlyStartTime(lastMonthFirstDay); | 
 |  |  |             } else | 
 |  |  |                 return false; | 
 |  |  |         } | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  | //    public boolean valid() { | 
 |  |  | //        if (monitorPointId == null) | 
 |  |  | //           return false; | 
 |  |  | //        if (reportType == null) { | 
 |  |  | //            if (startTime == null || endTime == null) | 
 |  |  | //                return false; | 
 |  |  | //            //结束时间获取当天最后一个小时 | 
 |  |  | //            String endTimeStr = DateUtils.dateToDateString(endTime,"yyyy-MM-dd"); | 
 |  |  | //            endTimeStr+=" 23:59:59"; | 
 |  |  | //            endTime = DateUtils.getDate(endTimeStr,"yyyy-MM-dd HH:mm:ss"); | 
 |  |  | //        } else { | 
 |  |  | //            if(startTime!=null&&endTime!=null) | 
 |  |  | //                return false; | 
 |  |  | //            if (reportType.equals(Constants.HOURLY_REPORT)) { | 
 |  |  | //                //时报选项默认为上个小时的数据 | 
 |  |  | //                Date previousHour = DateUtils.getDateOfMin(new Date(), -60); | 
 |  |  | //                startTime = DateUtils.getHourlyStartTime(previousHour); | 
 |  |  | //            } else if (reportType.equals(Constants.DAILY_REPORT)) { | 
 |  |  | //                //日报选项默认为昨天的数据 | 
 |  |  | //                Date yesterday = DateUtils.getDateOfDay(new Date(),-1); | 
 |  |  | //                startTime = DateUtils.getDailyStartTime(yesterday); | 
 |  |  | //            } else if (reportType.equals(Constants.WEEKLY_REPORT)) { | 
 |  |  | //                //周报选项默认为上周的数据 | 
 |  |  | //                Date previous = DateUtils.getDateOfDay(new Date(),-7); | 
 |  |  | //                startTime = DateUtils.getWeeklyStartTime(previous); | 
 |  |  | //                endTime = DateUtils.getWeeklyEndTime(previous); | 
 |  |  | //            } else if (reportType.equals(Constants.MONTHLY_REPORT)) { | 
 |  |  | //                //月报选项默认为上月的数据 | 
 |  |  | //                Date lastMonthFirstDay = DateUtils.getFirstDayOfLastMonth(); | 
 |  |  | //                startTime = DateUtils.getMonthlyStartTime(lastMonthFirstDay); | 
 |  |  | //                endTime = DateUtils.getMonthlyEndTime(lastMonthFirstDay); | 
 |  |  | //            } else | 
 |  |  | //                return false; | 
 |  |  | //        } | 
 |  |  | //        return true; | 
 |  |  | //    } | 
 |  |  |  | 
 |  |  | } |