package com.jay.monitor.data.server.job.impl;

import com.jay.monitor.data.server.job.ScheduleJobServiceAdaptor;
import com.jay.monitor.data.server.report.DayAlertProcess;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Module TODO
 * @Description TODO
 * @Author liukaixiong
 * @Date 2020/12/16 19:41
 */
@Component
public class AlertDayJobService extends ScheduleJobServiceAdaptor {

    private SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");

    @Autowired
    private DayAlertProcess dayAlertProcess;

    @Override
    public boolean isDayInvoke() {
        return true;
    }

    @Override
    public void processDayJob() throws Exception {
        Date date = DateUtils.addDays(new Date(), -1);
        dayAlertProcess.alert(sdf.format(date));
    }
}
