package com.its.op.scheduler.job;

import com.its.op.global.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;

import javax.annotation.PostConstruct;

@Slf4j
@AllArgsConstructor
@Service
public class BaseDbmsJobThread {

    private final CodeManager codeManager;
    private final CctvManager cctvManager;
    private final VdsManager vdsManager;
    private final VmsManager vmsManager;
    private final VmsIfscManager vmsIfscManager;

    @PostConstruct
    private void init() {
        log.info("{}", this);
    }

    @Async("schJobExecutor")
    public void run() {

        log.info("START: BaseDbmsJobThread.run: {}", Thread.currentThread().getName());

        StopWatch stopWatch = new StopWatch();
        stopWatch.start();

        codeManager.load();
        cctvManager.load();
        vdsManager.load();
        vmsManager.load();
        vmsIfscManager.load();

        stopWatch.stop();
        log.info("--END: BaseDbmsJobThread.run: {}, {} ms.", Thread.currentThread().getName(), stopWatch.getTotalTimeMillis());
    }
}
