package com.huatek.busi.task.base;

import java.text.ParseException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

import com.huatek.busi.common.util.DateUtil;

/**
 * 定时任务接口抽象实现
 * 
 * @author anker_cheng
 * @date 2019/09/26
 */
public abstract class AbstractBusiTaskExecutor implements BusiTaskExecutor {
    public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE);

    @Override
    public void execute() throws Exception {
        LocalDate yesterday = LocalDate.now().minusDays(1);
        execute(yesterday);
    }

    @Override
    public void execute(String params) throws Exception {
        LocalDate day = toLocalDate(params);
        execute(day);
    }

    protected LocalDate toLocalDate(String date) {
        return LocalDate.parse(date, FORMATTER);
    }

    public void execute(LocalDate day) throws Exception {

    }
}
