|
@ -63,6 +63,7 @@ public class MysqlToEsQuotaJob implements Job {
|
|
private String year;//要统计的年份
|
|
private String year;//要统计的年份
|
|
private Date quotaDate;//统计的时间
|
|
private Date quotaDate;//统计的时间
|
|
private String timeLevel;//1 日 2年
|
|
private String timeLevel;//1 日 2年
|
|
|
|
private Integer incrementInterval;//增量的时间间隔(天)
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
|
|
private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
|
|
@ -107,6 +108,7 @@ public class MysqlToEsQuotaJob implements Job {
|
|
this.timeLevel = map.getString("timeLevel");
|
|
this.timeLevel = map.getString("timeLevel");
|
|
this.endTime = map.getString("endTime");
|
|
this.endTime = map.getString("endTime");
|
|
this.startTime = map.getString("startTime");
|
|
this.startTime = map.getString("startTime");
|
|
|
|
this.incrementInterval = (Integer) map.get("incrementInterval");
|
|
//为空默认是统计昨天的数据 统计昨天的数据是从 前天的下午17:00:00 到昨天的下午17:00:00
|
|
//为空默认是统计昨天的数据 统计昨天的数据是从 前天的下午17:00:00 到昨天的下午17:00:00
|
|
//初始化结束时间
|
|
//初始化结束时间
|
|
if (StringUtils.isEmpty(endTime)) {
|
|
if (StringUtils.isEmpty(endTime)) {
|
|
@ -123,7 +125,8 @@ public class MysqlToEsQuotaJob implements Job {
|
|
} else {
|
|
} else {
|
|
//增量
|
|
//增量
|
|
if (StringUtils.isEmpty(startTime)) {
|
|
if (StringUtils.isEmpty(startTime)) {
|
|
startTime = new LocalDate(new DateTime().minusDays(2)).toString("yyyy-MM-dd") + " 17:00:00"; //2017-06-01 17:00:00
|
|
|
|
|
|
// startTime = new LocalDate(new DateTime().minusDays(2)).toString("yyyy-MM-dd") + " 17:00:00"; //2017-06-01 17:00:00
|
|
|
|
getStartTime();
|
|
} else {
|
|
} else {
|
|
startTime = startTime + " 17:00:00";
|
|
startTime = startTime + " 17:00:00";
|
|
}
|
|
}
|
|
@ -326,4 +329,17 @@ public class MysqlToEsQuotaJob implements Job {
|
|
return (1900 + today.getYear() - 1) + "";
|
|
return (1900 + today.getYear() - 1) + "";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void getStartTime() throws Exception{
|
|
|
|
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
if(this.incrementInterval==1){//日
|
|
|
|
startTime = new LocalDate(new DateTime().minusDays(2)).toString("yyyy-MM-dd") + " 17:00:00";
|
|
|
|
}else if(this.incrementInterval==2){//周
|
|
|
|
Date monday = DateUtil.getMondayOfThisDayToDate(sf.parse(endTime));
|
|
|
|
startTime =sf.format(monday)+ " 17:00:00";
|
|
|
|
}else if(this.incrementInterval==3){//月
|
|
|
|
Date fristDay = DateUtil.getFristDayOfMonthToDate(sf.parse(endTime));
|
|
|
|
startTime = sf.format(fristDay)+ " 17:00:00";
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|