package com.gyee.alarm.task.thread;

import com.gyee.alarm.feigns.IAlarmService;
import com.gyee.alarm.init.CacheContext;
import com.gyee.alarm.model.vo.*;
import com.gyee.alarm.rule.AlarmFunction;
import com.gyee.alarm.rule.expression.AlarmExpression;
import com.gyee.alarm.rule.expression.Analyzer;
import com.gyee.alarm.service.AlarmCtService;
import com.gyee.alarm.service.auto.IAlarmTsService;
import com.gyee.alarm.service.auto.IProEconAlarmRuleService;
import com.gyee.common.model.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class ScheduledTasks {


    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Resource
    private AlarmCtService alarmCtService;
    @Resource
    private IProEconAlarmRuleService proEconAlarmRuleService;
    // 每15分钟执行一次
    @Scheduled(fixedRate = 1000*60*15)
    public void reportCurrentTime() throws Exception {

        proEconAlarmRuleService.inital();
        CacheContext.alarmTags = alarmCtService.findTags(AlarmSuperTalbeType.CT.getCode());
        logger.info("当前时间: " + System.currentTimeMillis() / 1000);
    }

//    // 初始延迟1秒，之后每10秒执行一次
//    @Scheduled(fixedDelay = 10000, initialDelay = 1000)
//    public void fixedDelayTask() {
//        System.out.println("固定延迟任务执行: " + System.currentTimeMillis() / 1000);
//    }
//
//    // 初始延迟1秒，之后在上一次执行结束后再等待10秒执行
//    @Scheduled(fixedDelayString = "10000", initialDelay = 1000)
//    public void fixedDelayStringTask() {
//        System.out.println("固定延迟字符串任务执行: " + System.currentTimeMillis() / 1000);
//    }
//
//    // 初始延迟1秒，之后在上一次执行结束后再等待10秒执行，使用cron表达式
//    @Scheduled(cron = "*/10 * * * * ?")
//    public void executeTaskWithCron() {
//        System.out.println("Cron表达式任务执行: " + System.currentTimeMillis() / 1000);
//    }
}