package cokr.xit.ens.batch.sched;

import cokr.xit.ens.core.aop.EnsResponseVO;
import cokr.xit.ens.modules.kkoalimtalk.service.KkoAlimtalkService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@Profile("!local & !local-maria & !local-oracle & !local-test")
@RequiredArgsConstructor
public class EnsKkoAlimtalkScheduler {

    private final KkoAlimtalkService kkoAlimtalkService;


    /**
     * 알림톡 전송 처리
     * -. "제작성공(makeok)" 상태의 자료 중 발송일시(sendDt)가 경과한 자료에 대해 전송을 수행 한다.
     */
    @Scheduled(cron = "0 */1 9-18 * * *")
    public void sended() {
        EnsResponseVO responseVO = kkoAlimtalkService.sendBulkAll();
        StringBuffer sb = new StringBuffer();
        sb.append("\n=======================================================")
                .append("\n[ENS] 카카오 알림톡 전송처리")
                .append("\n결과: {}")
                .append("\n=======================================================");
        log.info(sb.toString(), responseVO.toString());
    }

}
