package com.usky.iot.controller.web;

import com.usky.iot.service.BaseAlarmService;
import com.usky.iot.service.CrmCustomInfoService;
import com.usky.iot.service.DmpDeviceStatusService;
import com.usky.iot.service.job.DmpDataOverviewJob;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.beans.Beans;

/**
 * @author zyj
 * @since 2023-06-05
 */
@EnableScheduling
@Component
public class TaskController implements ApplicationContextAware {
    @Autowired
    private DmpDataOverviewJob dmpDataOverviewJob;

    @Autowired
    private BaseAlarmService baseAlarmService;

    @Autowired
    private CrmCustomInfoService crmCustomInfoService;

    private static ApplicationContext context;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException{
        context = applicationContext;
    }

//    @Scheduled(cron = "0 30 23 * * ? ") //每天23点30分执行
//    public void task() {
//        System.out.println(Thread.currentThread().getName() + "定时任务执行中");
//        dmpDataOverviewJob.execute();
//    }
//    @Scheduled(cron = "0 0 23 * * ? ") //每天23点执行
//    public void task1() {
//        System.out.println(Thread.currentThread().getName() + "定时任务执行中");
//        baseAlarmService.status();
//    }
//
//    @Scheduled(cron = "0 30 * * * ? ") //每天凌晨0点30分执行
//    public void task2() {
//        System.out.println(Thread.currentThread().getName() + "定时任务执行中");
//        crmCustomInfoService.updateStatus();
//    }

}
