package com.gyee.wisdom;


import com.gyee.wisdom.backwork.ReadAndWrite;
import com.gyee.wisdom.dao.timeseries.ILatestDao;
import com.gyee.wisdom.domain.timeseries.TsPointService;
import com.gyee.wisdom.taos.WriteRealValue;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ApplicationReadyEventListener implements
        ApplicationListener<ApplicationReadyEvent> {

     @Autowired
     private TsPointService tsPointService;
     @Autowired
     private ILatestDao latestDao;
     @Autowired
     private WriteRealValue writeRealValue;

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        log.info("ApplicationReadyEvent  rised!");
        log.info("listener: " + event.toString());
        ReadAndWrite readAndWrite = new ReadAndWrite();
        readAndWrite.setLatestDao(latestDao);
        readAndWrite.setTsPointService(tsPointService);
        readAndWrite.setWriteHistoryValue(writeRealValue);
        //执行线程
        readAndWrite.start();
    }

}