package cn.estsh.i3plus.ext.mes.pcn.apiservice.schedulejob.ep;

import cn.estsh.i3plus.ext.mes.pcn.api.job.ep.IEpProductDataRfidMatchService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jboss.logging.Logger;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;

/**
 * @Description : EP_Pcn生产数据RFID匹配定时任务
 * @Reference :
 * @Author : wangjie
 * @CreateDate : 2020-10-23 17:30
 **/
@Slf4j
@ApiOperation("EP_Pcn生产数据RFID匹配定时任务")
@DisallowConcurrentExecution
public class EpProductDataRfidMatchJob implements Job {

    private static final Logger LOGGER = Logger.getLogger(EpProductDataRfidMatchJob.class);

    @Autowired
    private IEpProductDataRfidMatchService productDataRfidMatchService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) {
        LOGGER.info(this.getClass().getSimpleName() + " :Pcn生产数据RFID匹配JOB开始执行...");

        Object param = jobExecutionContext.getJobDetail().getJobDataMap().get(MesPcnExtConstWords.PARAM);
        if (StringUtils.isEmpty(param)) {
            LOGGER.error("Pcn生产数据RFID匹配JOB,未配置工厂代码参数");
            return;
        }

        long startTime = System.currentTimeMillis();

        productDataRfidMatchService.doProductDataRfidMatch(param.toString());

        long endTime = System.currentTimeMillis();
        LOGGER.info(this.getClass().getSimpleName() + " :ALL:耗时: " + (endTime - startTime) + "ms");

    }
}