package com.zcxk.quartz.job;

import com.zcxk.quartz.service.DataAlarmDayJobService;
import com.zcxk.service.MonitorDataService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.Serializable;

/**
 * @author Administrator
 * @create 2020-05-18 14:07
 */
@Slf4j
@Component
public  class MonitorDataReportByMonthJob implements Job, Serializable {

    private static final long serialVersionUID = 3336891083300321324L;

    @Autowired
    private MonitorDataService monitorDataService;

    @Resource
    private DataAlarmDayJobService dataAlarmDayJobService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        try{
            log.info("月报报任务开始执行");
            monitorDataService.getMonitorDataByDay();
            dataAlarmDayJobService.execute();
            log.info("月报任务执行结束");
        }catch (Exception e){
            e.printStackTrace();
            log.info("月报任务执行异常，{}", e.getMessage());
        }
    }

}