Selaa lähdekoodia

Merge branch 'dev' of liuwenbin/patient-co-management into dev

chenweida 7 vuotta sitten
vanhempi
commit
65a362da69

+ 17 - 1
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/MysqlToEsQuotaJob.java

@ -63,6 +63,7 @@ public class MysqlToEsQuotaJob implements Job {
    private String year;//要统计的年份
    private Date quotaDate;//统计的时间
    private String timeLevel;//1 日 2年
    private Integer incrementInterval;//增量的时间间隔(天)
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
@ -107,6 +108,7 @@ public class MysqlToEsQuotaJob implements Job {
        this.timeLevel = map.getString("timeLevel");
        this.endTime = map.getString("endTime");
        this.startTime = map.getString("startTime");
        this.incrementInterval = (Integer) map.get("incrementInterval");
        //为空默认是统计昨天的数据  统计昨天的数据是从 前天的下午17:00:00 到昨天的下午17:00:00
        //初始化结束时间
        if (StringUtils.isEmpty(endTime)) {
@ -123,7 +125,8 @@ public class MysqlToEsQuotaJob implements Job {
        } else {
            //增量
            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 {
                startTime = startTime + " 17:00:00";
            }
@ -326,4 +329,17 @@ public class MysqlToEsQuotaJob implements Job {
            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";
        }
    }
}