package cn.com.ctop.job.bytedance.handler;

import cn.com.ctop.check.component.execute.GroovyScriptExecutor;
import cn.com.ctop.check.entity.CtopCheckTaskList;
import cn.com.ctop.check.service.ICtopCheckTaskListService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class CheckDataStateJob {

    @Autowired
    private GroovyScriptExecutor groovyScriptExecutor;

    @Autowired
    private ICtopCheckTaskListService checkTaskListService;

    private final String jobName="checkDataStateJob";

    /**
     * 检查任务执行结果
     * 检查数据结果
     */
    @XxlJob(jobName)
    public void execute() throws Exception {
        //查询需要检查的任务列表
        List<CtopCheckTaskList> ctopCheckTaskList= checkTaskListService.queryExecuteList(jobName);
        if(ctopCheckTaskList!=null){
            ctopCheckTaskList.forEach(it-> groovyScriptExecutor.execute(it));
        }
    }
}
