package com.czg.task;

import com.czg.order.service.ShopOrderStatisticService;
import com.czg.order.service.ShopProdStatisticService;
import com.czg.order.service.ShopTableOrderStatisticService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author Administrator
 */
@Component
@Slf4j
public class StatisticTask {
    @Resource
    private ShopTableOrderStatisticService shopTableOrderStatisticService;
    @Resource
    private ShopProdStatisticService shopProdStatisticService;
    @Resource
    private ShopOrderStatisticService shopOrderStatisticService;

//    @Scheduled(cron = "1/6 * * * * ? ")
    @Scheduled(cron = "0 0 8 * * ?")
    public void run() {
        long start = System.currentTimeMillis();
        log.info("定时任务执行，开始统计数据");
        shopOrderStatisticService.statistic();
        shopProdStatisticService.statistic();
        shopTableOrderStatisticService.statistic();
        log.info("定时任务执行完毕，耗时:{}ms", start - System.currentTimeMillis());
    }
}
