package com.wms_main.service.quartz_job.job_executor;

import com.wms_main.repository.utils.StringUtils;
import com.wms_main.service.quartz_job.IDataSolverService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.quartz.*;

/**
 * 数据处理定时器
 */
@Slf4j
@PersistJobDataAfterExecution
@DisallowConcurrentExecution
@RequiredArgsConstructor
public class DataSolver implements Job {
    private final IDataSolverService dataSolverService;// 数据处理服务

    /**
     * 运行定时任务
     *
     * @param jobExecutionContext 定时任务执行的环境（上下文）
     */
    @Override
    public void execute(JobExecutionContext jobExecutionContext) {
        try {
            dataSolverService.clearLogData();
        } catch (Exception e) {
            log.error("清除日志数据失败{}", StringUtils.objectToString(e));
        }
        try {
            dataSolverService.clearNormalRecord();
        } catch (Exception e) {
            log.error("清除普通记录失败{}", StringUtils.objectToString(e));
        }
        try {
            dataSolverService.clearImportantRecord();
        } catch (Exception e) {
            log.error("清除重要记录失败{}", StringUtils.objectToString(e));
        }
    }
}
