package com.hotwj.platform.securityManagement.hiddenDangerPlan.task;

import com.hotwj.platform.securityManagement.hiddenDangerPlan.service.IHotHiddenDangerPlanService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 隐患排查计划定时任务
 *
 * @author shihongwei
 * @date 2025-01-03
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class HazardInspectionPlanTask {

    private final IHotHiddenDangerPlanService hotHiddenDangerPlanService;

    /**
     * 每天0点执行，生成隐患排查计划
     */
    @Scheduled(cron = "0 0 0 * * ?")
    // @Scheduled(cron = "0 0/5 * * * ?")
    public void generatePlans() {
        log.info("开始生成隐患排查计划");
        try {
            hotHiddenDangerPlanService.generatePlans();
            log.info("生成隐患排查计划完成");
        } catch (Exception e) {
            log.error("生成隐患排查计划失败", e);
        }
    }
}
