ItsApiScheduler.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package com.its.op.scheduler;
  2. import com.its.op.config.JobConfig;
  3. import com.its.op.config.ApplicationConfig;
  4. import com.its.op.scheduler.job.*;
  5. import lombok.AllArgsConstructor;
  6. import lombok.extern.slf4j.Slf4j;
  7. import org.springframework.scheduling.annotation.Async;
  8. import org.springframework.scheduling.annotation.EnableScheduling;
  9. import org.springframework.scheduling.annotation.Scheduled;
  10. import org.springframework.stereotype.Component;
  11. import javax.annotation.PreDestroy;
  12. @Slf4j
  13. @AllArgsConstructor
  14. @EnableScheduling
  15. @Component
  16. public class ItsApiScheduler {
  17. private final ApplicationConfig applicationConfig;
  18. private final JobConfig jobConfig;
  19. private final FcltSttsJobThread fcltSttsJobThread;
  20. private final UnitSttsJobThread unitSttsJobThread;
  21. private final BaseDbmsJobThread baseDbmsJobThread;
  22. private final DbmsSttsJobThread dbmsSttsJobThread;
  23. @PreDestroy
  24. public void onShutDown() {
  25. }
  26. /**
  27. * CCTV Preset 제어 스케줄러
  28. */
  29. @Async
  30. @Scheduled(cron = "0 * * * * *") // 1분 주기 작업 실행
  31. public void jobCctvPsetScnr() {
  32. if (!this.applicationConfig.isStartSchedule()) {
  33. return;
  34. }
  35. }
  36. /**
  37. * 기초데이터 메모리 로딩
  38. */
  39. @Async
  40. @Scheduled(cron = "5 * * * * *") // 60초 주기 작업 실행
  41. public void pollingBaseDbms() {
  42. if (!this.applicationConfig.isStartSchedule()) {
  43. return;
  44. }
  45. if (this.jobConfig.isBaseDbms()) {
  46. this.baseDbmsJobThread.run();
  47. }
  48. }
  49. /**
  50. * 프로세스 상태정보 조회 및 전송
  51. */
  52. @Async
  53. @Scheduled(cron = "20 * * * * *") // 60초 주기 작업 실행
  54. public void pollingUnitStts() {
  55. if (!this.applicationConfig.isStartSchedule()) {
  56. return;
  57. }
  58. if (this.jobConfig.isUnitStts()) {
  59. this.unitSttsJobThread.run();
  60. }
  61. }
  62. /**
  63. * 시설물 상태정보 조회 및 전송
  64. */
  65. @Async
  66. @Scheduled(cron = "25 * * * * *") // 60초 주기 작업 실행
  67. public void pollingFcltStts() {
  68. if (!this.applicationConfig.isStartSchedule()) {
  69. return;
  70. }
  71. if (this.jobConfig.isFcltStts()) {
  72. this.fcltSttsJobThread.run();
  73. }
  74. }
  75. /**
  76. * DB Server Stts Update
  77. */
  78. @Async
  79. @Scheduled(cron = "40 0/10 * * * *") // 10분 주기 작업 실행
  80. //@Scheduled(cron = "40 * * * * *") // 10분 주기 작업 실행
  81. public void jobDbSvrStts() {
  82. if (!this.applicationConfig.isStartSchedule()) {
  83. return;
  84. }
  85. this.dbmsSttsJobThread.run();
  86. // if (this.jobConfig.isDbSvrStts()) {
  87. // this.dbSvrSttsJobThread.run();
  88. // }
  89. }
  90. /*@Async
  91. @Scheduled(cron = "0/2 * * * * *") // 2초 주기 작업 실행
  92. public void checkKafkaServerAlive() {
  93. }*/
  94. }