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 javax.annotation.Resource;
import java.util.Objects;

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

    @Resource
    QuartzLogicService quartzLogicService;

    /**
     * 非强制交卷，换算最终交卷时间并生成一次性考生延时任务
     *
     * @param context
     * @throws JobExecutionException
     */
    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        log.info("exam_student_job进来了,context:{}", context);
        JobDetail jobDetail = context.getJobDetail();
        String key = String.valueOf(jobDetail.getKey());
        if (Objects.nonNull(key)) {
            quartzLogicService.execExamStudentJobLogic(key);
        }
    }
}
