package com.malk.jinlun.schedule;

import com.malk.jinlun.service.JinlunTaskService;
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 JinlunTask {

    @Autowired
    private JinlunTaskService jinlunTaskService;

    //定时同步物料
    @Scheduled(cron = "0 0 0 * * ?")
    public void syncMaterial(){
        jinlunTaskService.syncMaterial();
    }

    //定时同步销售出库单
    @Scheduled(cron = "0 1 0 * * ?")
    public void syncSaleOut(){
        jinlunTaskService.syncSaleOut();
    }

    //定时同步收款单
    @Scheduled(cron = "0 2 0 * * ?")
    public void syncReceipt(){
        jinlunTaskService.syncReceipt();
    }

    //定时同步应收单
    @Scheduled(cron = "0 3 0 * * ?")
    public void syncReceivable(){
        jinlunTaskService.syncReceivable();
    }

    //定时同步销售退货单
    @Scheduled(cron = "0 4 0 * * ?")
    public void syncSaleReturn(){
        jinlunTaskService.syncSaleReturn();
    }

    //定时同步性能
    @Scheduled(cron = "0 5 0 * * ?")
    public void syncXingneng(){
        jinlunTaskService.syncXingneng();
    }

    //定时同步销售订单
    @Scheduled(cron = "0 6 0 * * ?")
    public void syncSaleOrder(){
        jinlunTaskService.syncSaleOrder();
    }

    //定时同步应收收款核销记录
    @Scheduled(cron = "0 7 0 * * ?")
    public void syncReceiptVerification(){
        jinlunTaskService.syncReceiptVerification();
    }



}
