package com.usky.alarm.controller.web;

import com.usky.alarm.service.BaseAlarmStatisticService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author han
 * @since 2023-12-04
 */
@EnableScheduling
@Component
public class TaskController {
    @Autowired
    private BaseAlarmStatisticService baseAlarmStatisticService;

    @Scheduled(cron = "0 2 0 * * ? ") //每天凌晨2点执行
    public void task() {
        System.out.println(Thread.currentThread().getName() + "告警及隐患日统计定时任务执行中");
        baseAlarmStatisticService.baseAlarmStatisticTask(1);
    }

    @Scheduled(cron = "0 0 1 1 * ?")//每月1号凌晨1点
    public void task1() {
        System.out.println(Thread.currentThread().getName() + "告警及隐患月统计定时任务执行中");
        baseAlarmStatisticService.baseAlarmStatisticTask(2);
    }
}
