package com.jiayue.insu.inclientqn.service.client;

import cn.hutool.core.date.DateUtil;
import com.jiayue.insu.inclientqn.entity.Station;
import com.jiayue.insu.inclientqn.permisson.com.BJZYYJYSDComPermisson;
import com.jiayue.insu.inclientqn.permisson.com.ComPermisson;
import com.jiayue.insu.inclientqn.permisson.com.SHComPermisson;
import com.jiayue.insu.inclientqn.permisson.com.WXComPermisson;
import com.jiayue.insu.inclientqn.service.StationService;
import com.jiayue.insu.inclientqn.util.DateTimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class InitRunner implements CommandLineRunner {
    @Autowired
    private ComPermisson comPermisson;
    @Autowired
    private BJZYYJYSDComPermisson bjzyyjysdComPermisson;
    @Autowired
    private StationService stationService;
    @Autowired
    private WXComPermisson wxComPermisson;
    @Autowired
    private SHComPermisson shComPermisson;
    @Autowired
    private BackDataAnalysisService backDataAnalysisService;

    /**
     * 打包的时候 用哪个站放开哪个站 其他站注释掉 todo
     *
     * @param args
     * @throws Exception
     */
    @Override
    public void run(String... args) throws Exception {
        List<Station> stationList = stationService.findAll();
        for (Station station : stationList) {
            // 清能token
            comPermisson.generateKey(station);
//            // 山东国家研究院token
//            bjzyyjysdComPermisson.generateKey(station);
            // 武穴一体化请求token
//            wxComPermisson.generateKey(station);
            // 飔合科技token from一体化云
//            shComPermisson.generateKey(station);
        }
        // 有内网回传放开，没有不用管
        long time = DateTimeUtils.get15min(DateUtil.date().getTime());
        backDataAnalysisService.watchFile(time);
    }
}
