package com.malk.huagao.schedule;

import com.malk.huagao.service.KdHuaGaoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * @EnableScheduling 开启定时任务 [配置参考McScheduleTask]
 */
@Slf4j
@Configuration
@EnableScheduling
@ConditionalOnProperty(name = {"enable.scheduling"})
public class KdScheduleTask {
    @Autowired
    private KdHuaGaoService kdHuaGaoService;

    //每周六 17:00定时同步序列号主档
    @Scheduled(cron = "0 0 17 * * 6")
    public void syncBDSerialMainFile(){
        kdHuaGaoService.syncBDSerialMainFile(null);
    }

    //每周六 16:00定时同步即时库存明细
    @Scheduled(cron = "0 0 16 * * 6")
    public void syncSTKInventory(){
        kdHuaGaoService.syncSTKInventory(null);
    }

    //每周六 18:00定时处理待处理品数据
    @Scheduled(cron = "0 0 18 * * 6")
    public void syncPendingProducts(){
        kdHuaGaoService.syncPendingProducts();
    }

    //每天00：00定时同步生产退料明细
    @Scheduled(cron = "0 0 0 * * ?")
    public void syncPRDReturnMtrl(){
        kdHuaGaoService.syncPRDReturnMtrl(null);
    }

    //每天00：01定时同步发货通知单
    @Scheduled(cron = "0 1 0 * * ?")
    public void syncDLVNotice(){
        kdHuaGaoService.syncDLVNotice(null);
    }

    //每天00：02定时同步采购订单
    @Scheduled(cron = "0 2 0 * * ?")
    public void syncPUROrder(){
        kdHuaGaoService.syncPUROrder(null);
    }
}
