package org.springblade.modules.app.job;

import com.wn.common.exception.BusinessException;
import com.wn.common.perfmonitor.annotation.ServiceTimeLog;
import org.springblade.modules.app.manager.TransportManager;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * 司机自动确认job
 *
 * @author FUXINSHENG
 */
@Component
@Slf4j
public class DriverConfirmJobHandler extends IJobHandler {
    @Autowired
    private TransportManager transportManager;

    @Override
    @ServiceTimeLog
    @XxlJob("driverConfirmJobHandler")
    public void execute() throws Exception {
        log.info("司机自动确认 定时扫描任务处理中...");
        try {
            //司机自动确认
            transportManager.driverConfirmJobHandler();
        } catch (BusinessException be) {
            log.info("司机自动确认 定时调度执行失败，错误原因是：{}", be.getMessage());
            XxlJobHelper.handleFail();
        } catch (Exception e) {
            log.error("司机自动确认 定时调度执行抛异常：", e);
            XxlJobHelper.handleFail();
        }
        log.info("司机自动确认 定时扫描任务处理完成！");
    }
}
