瀏覽代碼

11指标执行优化

liuwenbin 7 年之前
父節點
當前提交
95727ef461

+ 30 - 2
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentMysqlToEsQuotaJob.java

@ -62,6 +62,8 @@ public class CurrentMysqlToEsQuotaJob implements Job {
    private String year;//要统计的年份
    private Date quotaDate;//统计的时间
    private String timeLevel;//1 日 2年
    private String wlyyJobCongId;//指标对象
    private QuartzJobConfig quartzJobConfig;//指标对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
@ -80,6 +82,7 @@ public class CurrentMysqlToEsQuotaJob implements Job {
    private StringRedisTemplate redisTemplate;
    @Autowired
    private Data2Save data2Save;
    private String incrementInterval;//增量的时间间隔(天)
    public void execute(JobExecutionContext context)
@ -112,7 +115,8 @@ public class CurrentMysqlToEsQuotaJob implements Job {
        //为空默认是统计昨天的数据  统计昨天的数据是从 前天的下午17:00:00 到昨天的下午17:00:00
        //初始化结束时间
        this.endTime = DateUtil.getStringDate("yyyy-MM-dd HH:mm:ss");
        this.startTime = map.getString("startTime");
        this.incrementInterval = map.get("incrementInterval")!=null?String.valueOf(map.get("incrementInterval")):"1";
        //初始化统计年份
        this.year = getNowYearByDate();
        //初始化开始时间
@ -120,11 +124,20 @@ public class CurrentMysqlToEsQuotaJob implements Job {
            //按年度到达量
            startTime = this.year + "-06-30 17:00:00";
        } else {
//            //增量
//            this.startTime = new LocalDate(new DateTime().minusDays(1)).toString("yyyy-MM-dd") + " 17:00:00"; //2017-06-01 17:00:00
            //增量
            this.startTime = new LocalDate(new DateTime().minusDays(1)).toString("yyyy-MM-dd") + " 17:00:00"; //2017-06-01 17:00:00
            if (StringUtils.isEmpty(startTime)) {
//                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";
            }
        }
        this.quotaDate = DateUtil.strToDate(endTime, "yyyy-MM-dd");
        this.wlyyJobCongId = map.getString("jobConfig");
        this.quartzJobConfig = quartzJobConfigDao.findById(wlyyJobCongId);
    }
@ -407,4 +420,19 @@ public class CurrentMysqlToEsQuotaJob implements Job {
        SimpleDateFormat s=new SimpleDateFormat("");
        System.out.println(s.format(new Date()));
    }
    public void getStartTime() throws Exception{
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
        if("1".equals(this.incrementInterval)){//日
            startTime = new LocalDate(new DateTime().minusDays(2)).toString("yyyy-MM-dd") + " 17:00:00";
        }else if("2".equals(this.incrementInterval)){//周
            Date monday = DateUtil.getMondayOfThisDayToDate(sf.parse(endTime));
//            startTime =sf.format(monday)+ " 17:00:00";
            startTime =DateUtil.getNextDay(monday,-1)+ " 17:00:00";
        }else if("3".equals(this.incrementInterval)){//月
            Date fristDay = DateUtil.getFristDayOfMonthToDate(sf.parse(endTime));
//            startTime = sf.format(fristDay)+ " 17:00:00";
            startTime =DateUtil.getNextDay(fristDay,-1)+ " 17:00:00";
        }
    }
}