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

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.jiayue.insu.inclientqn.entity.Station;
import com.jiayue.insu.inclientqn.permisson.com.ComPermisson;
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.time.LocalDateTime;
import java.util.List;

@Component
public class InitRunner implements CommandLineRunner {
    @Autowired
    private ComPermisson comPermisson;
    @Autowired
    private StationService stationService;
    @Autowired
    private BackDataAnalysisService backDataAnalysisService;
    @Override
    public void run(String... args) throws Exception {
        List<Station> stationList = stationService.findAll();
        for(Station station :stationList){
            comPermisson.generateKey(station);
        }

        long time = DateTimeUtils.get15min(DateUtil.date().getTime());
        backDataAnalysisService.watchFile(time);
    }
}
