123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- package com.its.vds.scheduler;
- import com.its.app.AppUtils;
- import com.its.app.utils.Elapsed;
- import com.its.vds.config.ProcessConfig;
- import com.its.vds.service.StatisticsServices;
- import com.its.vds.service.UnitSystService;
- import com.its.vds.service.VdsCtlrService;
- 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 ProcessConfig processConfig;
- private final UnitSystService unitSystService;
- private final VdsCtlrService vdsCtlrService;
- private final StatisticsServices statisticsServices;
- @Scheduled(cron = "5 * * * * *") // 1분주기 작업 실행
- public void UnitSystSchedule() {
- if (!this.processConfig.isStartSchedule()) {
- return;
- }
- Elapsed elapsed = new Elapsed();
- log.info(" UnitSystSchedule: start. {}", Thread.currentThread().getName());
- // 프로세스 상태정보 업데이트
- this.unitSystService.updateUnitSystStts(true);
- // 제어기 상태정보 업데이트(제어기/프로세스 상태정보 UDP 전송)
- this.vdsCtlrService.updateCtlrStts(true);
- log.info(" UnitSystSchedule: ..end. {} ms. {}", elapsed.milliSeconds(), Thread.currentThread().getName());
- /*
- TcpServerDataProcess tcpServerDataProcess = (TcpServerDataProcess) AppUtils.getBean(TcpServerDataProcess.class);
- for (int ii = 0; ii < 100; ii++) {
- String id = Integer.toString(ii);
- tcpServerDataProcess.add(new TcpServerData(id, null, null));
- }*/
- }
- // @Scheduled(cron = "10/30 * * * * *") // 30초마다 요청(10초, 40초)
- // public void VdsTrafficRequestSchedule() {
- // if (!this.processConfig.isStartSchedule()) {
- // return;
- // }
- // Elapsed elapsed = new Elapsed();
- // log.info("VdsTrafficRequestSchedule: start. {}", Thread.currentThread().getName());
- // // 제어기 동기화 요청
- // // 교통데이터 요청
- // this.vdsCtlrService.requestTraffic();
- // log.info("VdsTrafficRequestSchedule: ..end. {} ms. {}", elapsed.milliSeconds(), Thread.currentThread().getName());
- // }
- // @Scheduled(cron = "15/30 * * * * *") // 30초마다 요청(15초, 45초)
- // public void VdsVehicleRequestSchedule() {
- // if (!this.processConfig.isStartSchedule()) {
- // return;
- // }
- // Elapsed elapsed = new Elapsed();
- // // VDS 교통 데이터를 요청한 다음에 차량 정보를 요청한다.
- // // 제어기에서 동기화가 안되기 때문에 교통 데이터를 요청한 다음에 5초 후에 요청한다.
- // log.info("VdsVehicleRequestSchedule: start. {}", Thread.currentThread().getName());
- // this.vdsCtlrService.requestVehicle();
- // log.info("VdsVehicleRequestSchedule: ..end. {} ms. {}", elapsed.milliSeconds(), Thread.currentThread().getName());
- // }
- @Scheduled(cron = "40 0/5 * * * *") // 정주기 5분 40초에 스케쥴 실행
- public void StatisticsSchedule() {
- if (!this.processConfig.isStartSchedule()) {
- return;
- }
- Elapsed elapsed = new Elapsed();
- log.info(" StatisticsSchedule: start. {}", Thread.currentThread().getName());
- ProcessConfig processConfig = (ProcessConfig) AppUtils.getBean(ProcessConfig.class);
- // if (applicationConfig.getTaskStatistics().equals("true")) {
- // StatisticsTime its = new StatisticsTime();
- // its.init();
- // its.setProcessing(true);
- //
- // if (true) {
- // // VDS 검지기 5분 가공
- // this.statisticsServices.CRT_TB_VDS_DTCT_HS(its.getPrcsFiveMin(), its.getPrcsFiveMinFrom(), its.getPrcsFiveMinTo());
- // }
- //
- // if (its.isStat15Min()) {
- // // 5분 정주기 가공이 끝나고 15분 주기일 경우(00, 15, 30, 45 분 일경우 15분 통계 정보를 생성한다)
- // this.statisticsServices.CRT_TB_VDS_DTCT_15M_STAT(its.getStat15MinFrom(), its.getStat15MinFrom(), its.getStat15MinTo());
- // }
- //
- // if (its.isStatHour()) {
- // // 매시 5분 가공완료후 1시간 통계
- // this.statisticsServices.CRT_TB_VDS_DTCT_HH_STAT(its.getStatHourTime(), its.getStatHourTime(), its.getStatHourTo());
- // }
- //
- // if (its.isStatDay()) {
- // // 00시 10분 가공이 끝나면 이전일의 통계 정보를 가공.
- // this.statisticsServices.CRT_TB_VDS_DTCT_DD_STAT(its.getStatDayFrom(), its.getStatDayFrom(), its.getStatDayTo());
- // }
- //
- // if (its.isStatMon()) {
- // // 02시 10분 가공이 끝나면 이전일의 월통계 정보를 누적 가공.
- // String STAT_DT = its.getStatMonFrom().substring(0, 6) + "00000000";
- // this.statisticsServices.CRT_TB_VDS_DTCT_MN_STAT(STAT_DT, its.getStatMonFrom(), its.getStatMonTo());
- // }
- // if (its.isStatYear()) {
- // // 02시 35분 가공이 끝나면 이전일의 연통계 정보를 누적 가공.
- // String STAT_DT = its.getStatYearFrom().substring(0, 4) + "0000000000";
- // this.statisticsServices.CRT_TB_VDS_DTCT_YY_STAT(STAT_DT, its.getStatYearFrom(), its.getStatYearTo());
- // }
- // its.setProcessing(false);
- // }
- log.info(" StatisticsSchedule: ..end. {} ms. {}", elapsed.milliSeconds(), Thread.currentThread().getName());
- }
- @PreDestroy
- public void onShutDown() {
- this.unitSystService.updateUnitSystStts(false);
- }
- }
|