package com.qmth.themis.task.quartz;

import com.qmth.themis.task.quartz.service.QuartzLogicService;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @Description: examActivity job,一次性延时任务
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/7/27
 */
@Component
public class ExamActivityJob extends QuartzJobBean {
    private final static Logger log = LoggerFactory.getLogger(ExamActivityJob.class);

    @Resource
    QuartzLogicService quartzLogicService;

    /**
     * 考试场次mq延时任务
     *
     * @param context
     * @throws JobExecutionException
     */
    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        log.info("exam_acvitity_job进来了,context:{}", context);
        JobDetail jobDetail = context.getJobDetail();
        String key = String.valueOf(jobDetail.getKey());
        if (Objects.nonNull(key)) {
            quartzLogicService.execExamActivityJobLogic(key);
        }
    }
}
