package com.sw.mes.scheduled;

import com.sw.mes.core.utils.DateUtil;
import com.sw.mes.plan.service.FbProductionScheduleService;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Slf4j
@Component(value = "FbAutoScheduling")
public class FbAutoScheduling {
    @Autowired
    private FbProductionScheduleService fbProductionScheduleService;

    @XxlJob("consumptionCutData")
    public void consumptionCutData() {
        String dateStr = DateUtil.formatDate(new Date(), "yyyyMMddHHmmss");
        log.info("【开始方棒自动排程】QF" + dateStr + " * * * * * * * * * * *");
        Long start = System.currentTimeMillis();
        fbProductionScheduleService.autoScheduling();
        Long end = System.currentTimeMillis();
        log.info("【本次方棒自动排程耗时（" + (end - start) + "）毫秒】QF" + dateStr + " * * * * * * * * * * *");
    }


    @XxlJob("autoCloseSchedule")
    public void consumptionCloseCutData() {
        String dateStr = DateUtil.formatDate(new Date(), "yyyyMMddHHmmss");
        log.info("【开始方棒自动关闭排程】QF" + dateStr + " * * * * * * * * * * *");
        Long start = System.currentTimeMillis();
        fbProductionScheduleService.autoCloseScheduling();
        Long end = System.currentTimeMillis();
        log.info("【本次方棒自动关闭排程耗时（" + (end - start) + "）毫秒】QF" + dateStr + " * * * * * * * * * * *");
    }
}
