| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- package com.its.vms.scheduler;
- import com.its.app.AppUtils;
- import com.its.app.utils.Elapsed;
- import com.its.vms.config.ApplicationConfig;
- import com.its.vms.config.DebugConfig;
- import com.its.vms.service.*;
- import lombok.AllArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- 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 SchedulerTask {
- private final ApplicationConfig config;
- private final UnitSystService unitSystService;
- private final VmsCtlrService vmsCtlrService;
- private final VmsManageService vmsManageService;
- private final VmsDisplayOnOffService displayOnOffService;
- private final VmsSymbService symbService;
- // private final EsbVmsTcpService esbVmsTcpService;
- private final AppRepositoryService repoService;
- @PreDestroy
- public void onShutDown() {
- this.unitSystService.updateUnitSystStts(false);
- DebugConfig debug = (DebugConfig) AppUtils.getBean(DebugConfig.class);
- debug.saveDebugInfo();
- }
- /**
- * 프로세스와 제어기 상태정보를 업데이트 한다.
- */
- @Scheduled(cron = "5 * * * * *") // 1분주기 작업 실행
- public void scheduleUnitSystStts() {
- if (!this.config.isStartSchedule()) {
- return;
- }
- Elapsed elapsed = new Elapsed();
- log.info("scheduleUnitSystStts: start. {}", Thread.currentThread().getName());
- // 1. 프로세스 상태정보 업데이트
- this.unitSystService.updateUnitSystStts(true);
- // 2. 제어기 상태정보 업데이트
- this.vmsCtlrService.updateCtlrStts(true, null);
- log.info("scheduleUnitSystStts: ..end. {} ms. {}", elapsed.milliSeconds(), Thread.currentThread().getName());
- }
- /**
- * 제어기의 상태정보 제어기로 전송한다.
- */
- @Scheduled(cron = "8 * * * * *") // 1분주기 작업 실행
- public void scheduleVmsStatusRequest() {
- if (!this.config.isStartSchedule()) {
- return;
- }
- Elapsed elapsed = new Elapsed();
- log.info("scheduleVmsStatusRequest: start. {}", Thread.currentThread().getName());
- this.vmsManageService.requestStatus();
- log.info("scheduleVmsStatusRequest: ..end. {} ms. {}", elapsed.milliSeconds(), Thread.currentThread().getName());
- }
- /**
- * 제어기 전광판 On/Off 시각에 명령을 전송한다.
- */
- //@Scheduled(cron = "${application.atmp.crontab:40 0/30 * * * *}")
- @Scheduled(cron = "15 * * * * *") // 1분주기 작업 실행
- public void scheduleVmsOnOffControl() {
- if (!this.config.isStartSchedule()) {
- return;
- }
- Elapsed elapsed = new Elapsed();
- log.info("scheduleVmsOnOffControl: start. {}", Thread.currentThread().getName());
- this.displayOnOffService.loadVmsOnOffTime();
- log.info("scheduleVmsOnOffControl: ..end. {} ms. {}", elapsed.milliSeconds(), Thread.currentThread().getName());
- }
- /**
- * 정주기 VMS 다운로드 메시지를 생성하고 제어기로 다운로드 한다.
- */
- @Scheduled(cron = "30 0/5 * * * *") // 정주기 5분 30초에 스케쥴 실행
- public void scheduleVmsFormDownload() {
- if (!this.config.isStartSchedule()) {
- return;
- }
- Elapsed elapsed = new Elapsed();
- log.info("scheduleVmsFormDownload..: start. {}", Thread.currentThread().getName());
- this.repoService.setStaticCycle(true);
- this.vmsManageService.jobMakeDownloadVmsForm();
- log.info("scheduleVmsFormDownload..: ..end. {} ms. {}", elapsed.milliSeconds(), Thread.currentThread().getName());
- }
- /**
- * VMS 심벌 다운로드 정보를 조회하여 제어기로 다운로드 한다.
- */
- @Scheduled(cron = "10 3,8,13,18,23,28,33,38,43,48,53,58 * * * *") // 5분주기 작업 실행
- public void scheduleVmsDnldSymb() {
- if (!this.config.isStartSchedule()) {
- return;
- }
- Elapsed elapsed = new Elapsed();
- log.info("scheduleVmsDnldSymb: start. {}", Thread.currentThread().getName());
- this.symbService.loadVmsScheSymbLib();
- log.info("scheduleVmsDnldSymb: ..end. {} ms. {}", elapsed.milliSeconds(), Thread.currentThread().getName());
- }
- /**
- * ESB VMS 연계 서버에 전송할 단문 메시지가 존재하는 지 1분 주기로 체크하여 데이터를 전송한다.
- */
- // @Scheduled(cron = "15 * * * * *") // 1분주기 작업 실행
- // public void scheduleEsbVmsShortMsg() {
- // if (!this.config.isStartSchedule()) {
- // return;
- // }
- // Elapsed elapsed = new Elapsed();
- // log.info("scheduleEsbVmsShortMsg: start. {}", Thread.currentThread().getName());
- // this.esbVmsTcpService.loadVmsShorMsg();
- // log.info("scheduleEsbVmsShortMsg: ..end. {} ms. {}", elapsed.milliSeconds(), Thread.currentThread().getName());
- // }
- }
|