package com.its.op.scheduler; import com.its.op.config.JobConfig; import com.its.op.scheduler.job.*; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import javax.annotation.PreDestroy; @Slf4j @AllArgsConstructor @EnableScheduling @Component public class ItsApiScheduler { private final JobConfig jobConfig; private final CctvPsetCtrlScnrJobThread cctvPsetScnrThread; private final FcltSttsJobThread fcltSttsJobThread; private final UnitSttsJobThread unitSttsJobThread; private final BaseDbmsJobThread baseDbmsJobThread; private final DbSvrSttsJobThread dbSvrSttsJobThread; @PreDestroy public void onShutDown() { } /** * CCTV Preset 제어 스케줄러 */ @Async @Scheduled(cron = "0 * * * * *") // 1분 주기 작업 실행 public void jobCctvPsetScnr() { if (this.jobConfig.isCctvPreset()) { this.cctvPsetScnrThread.run(); } } /** * 기초데이터 메모리 로딩 */ @Async @Scheduled(cron = "5 * * * * *") // 60초 주기 작업 실행 public void pollingBaseDbms() { if (this.jobConfig.isBaseDbms()) { this.baseDbmsJobThread.run(); } } /** * 프로세스 상태정보 조회 및 전송 */ @Async @Scheduled(cron = "20 * * * * *") // 60초 주기 작업 실행 public void pollingUnitStts() { if (this.jobConfig.isUnitStts()) { this.unitSttsJobThread.run(); } } /** * 시설물 상태정보 조회 및 전송 */ @Async @Scheduled(cron = "25 * * * * *") // 60초 주기 작업 실행 public void pollingFcltStts() { if (this.jobConfig.isFcltStts()) { this.fcltSttsJobThread.run(); } } /** * DB Server Stts Update */ @Async @Scheduled(cron = "40 0/10 * * * *") // 5분 주기 작업 실행 public void jobDbSvrStts() { if (this.jobConfig.isDbSvrStts()) { this.dbSvrSttsJobThread.run(); } } /*@Async @Scheduled(cron = "0/2 * * * * *") // 2초 주기 작업 실행 public void checkKafkaServerAlive() { }*/ }