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


import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.base.MesMaximoServiceImpl;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.impp.framework.boot.init.ApplicationProperties;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author castle,暂时没有客供品移库
 * @version 1.0
 * @date 2021/2/2 16:44
 **/
@Slf4j
@DisallowConcurrentExecution
@Component
@ApiOperation("仪表读数job")
public class MesMeterReadingJob extends BaseMesScheduleJob {

    @Autowired
    private MesMaximoServiceImpl maximoService;

    public MesMeterReadingJob() {
        super(MesMeterReadingJob.class, "仪表读数job");
    }
    @Override
    public void executeMesJob(JobExecutionContext context, ApplicationProperties applicationProperties) {
        String jobParam = this.getJobParam();
        JSONObject jsonObject= JSONUtil.parseObj(jobParam);
        String organizeCode = jsonObject.getStr("organizeCode");
        String url = jsonObject.getStr("url");
        if (null == organizeCode){
            log.error("请添加需要报工的工厂代码!");
            return;
        }
        maximoService.doMeterReading(organizeCode,url);
    }
}
