package com.qmth.teachcloud.task.quartz;

import com.qmth.teachcloud.task.job.service.JobService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Description: 定时任务
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2021/9/1
 */
@Component
public class ScheduledTask implements InitializingBean {
    private final static Logger log = LoggerFactory.getLogger(ScheduledTask.class);

    @Resource
    JobService jobService;

    /**
     * 机器心跳
     */
    @Scheduled(cron = "0/15 * * * * ?")
    public void machineHeart() {
        log.info("machineHeart is come in");
        jobService.machineHeart();
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        this.machineHeart();
    }
}
