package incheon.ags.dss.weight.init;

import incheon.ags.dss.weight.batch.AnaWeightBatchProcessor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

/**
 * 'data-init-dss' 프로파일로 기동 시,
 * 자동으로 공간 가중치 데이터(Mst/Sum)를 생성하는 초기화 컴포넌트
 */
@Profile("data-init-dss")
@Component
@RequiredArgsConstructor
@Slf4j
public class AnaWeightDataInitializer implements CommandLineRunner {

    // [변경] Service 대신 Processor 주입
    private final AnaWeightBatchProcessor batchProcessor;

    @Override
    public void run(String... args) throws Exception {
        log.info("=================================================");
        log.info(">>> [INIT] 공간 가중치 데이터 자동 생성 (전체 연도)");
        log.info("=================================================");

        try {
            batchProcessor.runBatchJob("SYSTEM");

        } catch (Exception e) {
            log.error(">>> [INIT] 오류 발생", e);
        }
    }
}