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

import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesShippingKanbanCfgService;
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 org.springframework.util.StringUtils;

/**
 * @author 龙兴发运看板抓取客户端库存数据job
 * @version 1.0
 * @date 2025/04/30 16:44
 **/
@Slf4j
@DisallowConcurrentExecution
@Component
@ApiOperation("龙兴发运看板抓取客户端库存数据job")
public class MesCustQtyByTimeJob extends BaseMesScheduleJob {
    @Autowired
    private IMesShippingKanbanCfgService shippingKanbanCfgService;

    public MesCustQtyByTimeJob() {
        super(MesCustQtyByTimeJob.class, "龙兴发运看板抓取客户端库存数据job");
    }

    @Override
    public void executeMesJob(JobExecutionContext context, ApplicationProperties applicationProperties) {
        String jobParam = this.getJobParam();
        JSONObject jsonObject= JSONUtil.parseObj(jobParam);
        String organizeCode = jsonObject.getStr("organizeCode");
        if (StringUtils.isEmpty(organizeCode)){
            log.error("请添加需要抓取的工厂代码!");
            return;
        }
        shippingKanbanCfgService.doCreateCustQtyByTime(organizeCode, "job");
    }
}
