package com.its.op.scheduler; import com.its.op.config.JobConfig; import com.its.op.config.ApplicationConfig; 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 ApplicationConfig applicationConfig; private final JobConfig jobConfig; private final FcltSttsJobThread fcltSttsJobThread; private final UnitSttsJobThread unitSttsJobThread; private final BaseDbmsJobThread baseDbmsJobThread; private final DbmsSttsJobThread dbmsSttsJobThread; @PreDestroy public void onShutDown() { } /** * CCTV Preset 제어 스케줄러 */ @Async @Scheduled(cron = "0 * * * * *") // 1분 주기 작업 실행 public void jobCctvPsetScnr() { if (!this.applicationConfig.isStartSchedule()) { return; } } /** * 기초데이터 메모리 로딩 */ @Async @Scheduled(cron = "5 * * * * *") // 60초 주기 작업 실행 public void pollingBaseDbms() { if (!this.applicationConfig.isStartSchedule()) { return; } if (this.jobConfig.isBaseDbms()) { this.baseDbmsJobThread.run(); } } /** * 프로세스 상태정보 조회 및 전송 */ @Async @Scheduled(cron = "20 * * * * *") // 60초 주기 작업 실행 public void pollingUnitStts() { if (!this.applicationConfig.isStartSchedule()) { return; } if (this.jobConfig.isUnitStts()) { this.unitSttsJobThread.run(); } } /** * 시설물 상태정보 조회 및 전송 */ @Async @Scheduled(cron = "25 * * * * *") // 60초 주기 작업 실행 public void pollingFcltStts() { if (!this.applicationConfig.isStartSchedule()) { return; } if (this.jobConfig.isFcltStts()) { this.fcltSttsJobThread.run(); } } /** * DB Server Stts Update */ @Async @Scheduled(cron = "40 0/10 * * * *") // 10분 주기 작업 실행 //@Scheduled(cron = "40 * * * * *") // 10분 주기 작업 실행 public void jobDbSvrStts() { if (!this.applicationConfig.isStartSchedule()) { return; } this.dbmsSttsJobThread.run(); // if (this.jobConfig.isDbSvrStts()) { // this.dbSvrSttsJobThread.run(); // } } /*@Async @Scheduled(cron = "0/2 * * * * *") // 2초 주기 작업 실행 public void checkKafkaServerAlive() { }*/ }