package com.wms_main.service.quartz_job.job_executor;

import com.wms_main.repository.utils.StringUtils;
import com.wms_main.service.quartz_job.IOutsExecutorService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.PersistJobDataAfterExecution;

/**
 * 定时任务定义类---出库单修复类
 */
@Slf4j
@PersistJobDataAfterExecution
// 以下注解用于实现fixed_delay
@DisallowConcurrentExecution
@RequiredArgsConstructor
public class
OutsRepair implements Job {
    private final IOutsExecutorService outsExecutorService;// 出库单解析服务

    /**
     * 运行定时任务
     *
     * @param jobExecutionContext 定时任务执行的环境（上下文）
     */
    @Override
    public void execute(JobExecutionContext jobExecutionContext) {
        // 修复出库单
        try {
            outsExecutorService.repairOuts();
        } catch (Exception e) {
            log.error("修复出库单失败{}", StringUtils.objectToString(e));
        }
        // 修复站台工作StandWork
        try {
            outsExecutorService.repairStandWorks();
        } catch (Exception e) {
            log.error("修复站台工作StandWork失败{}", StringUtils.objectToString(e));
        }
        // 自修复（配料）
        try {
            outsExecutorService.repairKateWorks();
        } catch (Exception e) {
            log.error("自修复（配料）失败{}", StringUtils.objectToString(e));
        }
    }
}
