package com.zhongshu.card.server.core.init;

import com.zhongshu.card.server.core.service.devices.DeviceInfoServiceImpl;
import com.zhongshu.card.server.core.service.openAPI.OpenAPIRegisterService;
import com.zhongshu.card.server.core.service.paySetting.ProjectChannelConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

/**
 * 初始、检查数据
 *
 * @author TRX
 * @date 2024/6/3
 */
@Component
@Slf4j
public class DataiInit implements CommandLineRunner {

    @Autowired
    private ProjectChannelConfigService projectChannelConfigService;

    @Autowired
    private DeviceInfoServiceImpl deviceInfoService;

    @Override
    public void run(String... args) throws Exception {
        CompletableFuture.runAsync(() -> {
            try {
                TimeUnit.SECONDS.sleep(20);
                // 初始平台的支付产品
                projectChannelConfigService.initAllChannel();

                // 检查设备的在线状态
                deviceInfoService.initCheckDeviceOnLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
    }
}
