package io.renren.modules.aspen.controller;

import io.renren.modules.aspen.entity.TElecdashboardRealtimeEntity;
import io.renren.modules.aspen.entity.base.TElecdashboard;
import io.renren.modules.aspen.service.TElecdashboardRealtimeService;
import io.renren.modules.aspen.utils.DashboardDataPullUtils;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 电厂大屏实时数据
 *
 * @author Wang Zi Wen
 * @email wangggziwen@163.com
 * @date 2022/09/01 10:58:53
 */
@Component
@Configuration
@EnableScheduling
public class TElecdashboardRealtimeController {

    @Resource
    private TElecdashboardRealtimeService tElecdashboardRealtimeService;

    /**
     * 每5秒抓取实时数据，存入数据库
     */
//    @Scheduled(cron = "*/5 * * * * ?" )
    public void getExcelDataEvery5Seconds(){
        DashboardDataPullUtils dashboardDataPullUtils = new DashboardDataPullUtils();
        TElecdashboard tElecdashboard = dashboardDataPullUtils.getExcelData(new TElecdashboardRealtimeEntity());
        TElecdashboardRealtimeEntity tElecdashboardRealtimeEntity = (TElecdashboardRealtimeEntity) tElecdashboard;
        tElecdashboardRealtimeService.insertTElecdashboardRealtime(tElecdashboardRealtimeEntity);

    }

}
