package com.hotwj.platform.workbench.task;

import com.hotwj.platform.workbench.service.IHotHiddenDangerDailyStatsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 日统计定时任务（隐患、培训）
 *
 * @author shihongwei
 * @date 2026-02-25
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class GovHiddenDangerDailyStatsTask {

    private final IHotHiddenDangerDailyStatsService dailyStatsService;

    /**
     * 每天凌晨1点执行统计
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void generateDailyStats() {
        log.info("开始执行日统计定时任务（隐患、培训）");
        try {
            dailyStatsService.generateDailyStats();
        } catch (Exception e) {
            log.error("日统计定时任务（隐患、培训）执行失败", e);
        }
        log.info("日统计定时任务（隐患、培训）执行结束");
    }
}
