From d428f0b5044f8e652b9abfd5241a9a7fbb8b96c6 Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Fri, 6 Sep 2024 13:45:37 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20batch=20scheduler=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ens/batch/sched/EnsIntgrnScheduler.java | 70 ---------------- .../batch/sched/EnsKkoAlimtalkScheduler.java | 35 -------- .../ens/batch/sched/EnsKkoMydocScheduler.java | 68 --------------- .../ens/batch/sched/EnsKtGibisScheduler.java | 82 ------------------- .../batch/sched/EnsKtSigntalkScheduler.java | 63 -------------- .../batch/sched/EnsNvSigntalkScheduler.java | 70 ---------------- .../xit/ens/batch/sched/EnsScheduler.java | 48 ----------- 7 files changed, 436 deletions(-) delete mode 100644 src/main/java/cokr/xit/ens/batch/sched/EnsIntgrnScheduler.java delete mode 100644 src/main/java/cokr/xit/ens/batch/sched/EnsKkoAlimtalkScheduler.java delete mode 100644 src/main/java/cokr/xit/ens/batch/sched/EnsKkoMydocScheduler.java delete mode 100644 src/main/java/cokr/xit/ens/batch/sched/EnsKtGibisScheduler.java delete mode 100644 src/main/java/cokr/xit/ens/batch/sched/EnsKtSigntalkScheduler.java delete mode 100644 src/main/java/cokr/xit/ens/batch/sched/EnsNvSigntalkScheduler.java delete mode 100644 src/main/java/cokr/xit/ens/batch/sched/EnsScheduler.java diff --git a/src/main/java/cokr/xit/ens/batch/sched/EnsIntgrnScheduler.java b/src/main/java/cokr/xit/ens/batch/sched/EnsIntgrnScheduler.java deleted file mode 100644 index 3c72578..0000000 --- a/src/main/java/cokr/xit/ens/batch/sched/EnsIntgrnScheduler.java +++ /dev/null @@ -1,70 +0,0 @@ -package cokr.xit.ens.batch.sched; - -import cokr.xit.ens.core.aop.EnsResponseVO; -import cokr.xit.ens.modules.common.ctgy.intgrnnoti.service.IntgrnNotiService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Profile; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.util.List; - -@Slf4j -@Component -@Profile("!local & !local-maria & !local-oracle & !local-test") -@RequiredArgsConstructor -public class EnsIntgrnScheduler { - - private final IntgrnNotiService intgrnNotiService; - - /** - * 통합고지 재전송 처리 - * -. 전송회차가 완료되지 않은 모든 자료에 대해 전송을 수행 한다. - */ - @Scheduled(cron = "0 */10 9-18 * * *") - public void resended() { - EnsResponseVO responseVO = intgrnNotiService.sendBulkAll(); - StringBuffer sb = new StringBuffer(); - sb.append("\n=======================================================") - .append("\n[ENS INTGRN] 통합고지 재전송처리") - .append("\n결과: {}") - .append("\n======================================================="); - log.info(sb.toString(), responseVO.toString()); - } - - - /** - * 통합고지 상태갱신 처리 - * -. "실패(~fail) 또는 만료(close) 외" 상태의 자료에 대해 문서상태를 갱신 한다. - * -. 문서상태는 현재 상태에 따라 "전송완료(sendcmplt) 또는 열람중(open)"으로 갱신 된다. - */ - @Scheduled(cron = "0 0 23 * * *") - public void fetched() { - EnsResponseVO responseVO = intgrnNotiService.statBulkAll(); - StringBuffer sb = new StringBuffer(); - sb.append("\n=======================================================") - .append("\n[ENS INTGRN] 통합고지 문서상태갱신 처리") - .append("\n결과: {}") - .append("\n======================================================="); - log.info(sb.toString(), responseVO.toString()); - } - - - /** - * 마감처리 - * -. "열람(open)" 상태의 자료 중 마감기한이 경과한 자료의 상태정보를 "마감(close)" 으로 변경 한다. - */ - @Scheduled(cron = "30 0 9-18 * * *") - public void closed() { - EnsResponseVO> responseVO = intgrnNotiService.closed(); - StringBuffer sb = new StringBuffer(); - sb.append("\n=======================================================") - .append("\n[ENS INTGRN] 통합고지 마감처리 - 총 {}건") - .append("\nIntSendMastId {}") - .append("\n======================================================="); - log.info(sb.toString(), responseVO.getResultInfo().size(), responseVO.getResultInfo().toString()); - } - - -} diff --git a/src/main/java/cokr/xit/ens/batch/sched/EnsKkoAlimtalkScheduler.java b/src/main/java/cokr/xit/ens/batch/sched/EnsKkoAlimtalkScheduler.java deleted file mode 100644 index bf059a8..0000000 --- a/src/main/java/cokr/xit/ens/batch/sched/EnsKkoAlimtalkScheduler.java +++ /dev/null @@ -1,35 +0,0 @@ -package cokr.xit.ens.batch.sched; - -import cokr.xit.ens.core.aop.EnsResponseVO; -import cokr.xit.ens.modules.kkoalimtalk.service.KkoAlimtalkService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Profile; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -@Slf4j -@Component -@Profile("!local & !local-maria & !local-oracle & !local-test") -@RequiredArgsConstructor -public class EnsKkoAlimtalkScheduler { - - private final KkoAlimtalkService kkoAlimtalkService; - - - /** - * 알림톡 전송 처리 - * -. "제작성공(makeok)" 상태의 자료 중 발송일시(sendDt)가 경과한 자료에 대해 전송을 수행 한다. - */ - @Scheduled(cron = "0 */1 9-18 * * *") - public void sended() { - EnsResponseVO responseVO = kkoAlimtalkService.sendBulkAll(); - StringBuffer sb = new StringBuffer(); - sb.append("\n=======================================================") - .append("\n[ENS] 카카오 알림톡 전송처리") - .append("\n결과: {}") - .append("\n======================================================="); - log.info(sb.toString(), responseVO.toString()); - } - -} diff --git a/src/main/java/cokr/xit/ens/batch/sched/EnsKkoMydocScheduler.java b/src/main/java/cokr/xit/ens/batch/sched/EnsKkoMydocScheduler.java deleted file mode 100644 index 9a4fd85..0000000 --- a/src/main/java/cokr/xit/ens/batch/sched/EnsKkoMydocScheduler.java +++ /dev/null @@ -1,68 +0,0 @@ -package cokr.xit.ens.batch.sched; - -import cokr.xit.ens.core.aop.EnsResponseVO; -import cokr.xit.ens.modules.kkomydoc.service.KkoMydocHisService; -import cokr.xit.ens.modules.kkomydoc.service.KkoMydocService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Profile; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -@Slf4j -@Component -@Profile("!local & !local-maria & !local-oracle & !local-test") -@RequiredArgsConstructor -public class EnsKkoMydocScheduler { - - private final KkoMydocService kkoMydocService; - private final KkoMydocHisService kkoMydocHisService; - - /** - * 카카오 내문서함(인증톡) 전송 처리 - * -. "제작성공(makeok)" 상태의 모든 자료에 대해 전송을 수행 한다. - */ - @Scheduled(cron = "0 */1 9-18 * * *") - public void sended() { - EnsResponseVO responseVO = kkoMydocService.sendBulkAll(); - StringBuffer sb = new StringBuffer(); - sb.append("\n=======================================================") - .append("\n[ENS] 카카오 내문서함(인증톡) 전송처리") - .append("\n결과: {}") - .append("\n======================================================="); - log.info(sb.toString(), responseVO.toString()); - } - - /** - * 카카오 내문서함(인증톡) 상태갱신 처리 - * -. "발송성공/발송완료/열람중(sendok/sendcmplt/open)" 상태의 자료에 대해 문서상태를 갱신 한다. - * -. 문서상태는 현재 상태에 따라 "전송완료(sendcmplt) 또는 열람중(open)"으로 갱신 된다. - */ -// @Scheduled(cron = "0 */5 9-18 * * *") - @Scheduled(cron = "0 */30 9-18 * * *") - public void fetched() { - EnsResponseVO responseVO = kkoMydocService.statBulkAll(); - StringBuffer sb = new StringBuffer(); - sb.append("\n=======================================================") - .append("\n[ENS] 카카오 내문서함(인증톡) 문서상태갱신 처리") - .append("\n결과: {}") - .append("\n======================================================="); - log.info(sb.toString(), responseVO.toString()); - } - - /** - * 카카오 내문서함(인증톡) 상태갱신요청이력 영구 삭제 - */ - @Scheduled(cron = "4 4 4 * * *") - public void deleteStateHis() { - Long totCnt = kkoMydocHisService.truncateStatHist(); - StringBuffer sb = new StringBuffer(); - sb.append("\n=======================================================") - .append("\n[ENS] 카카오 내문서함(인증톡) 상태변경요청이력 영구 삭제") - .append("\n결과: {} 건 삭제") - .append("\n======================================================="); - log.info(sb.toString(), totCnt); - } - - -} diff --git a/src/main/java/cokr/xit/ens/batch/sched/EnsKtGibisScheduler.java b/src/main/java/cokr/xit/ens/batch/sched/EnsKtGibisScheduler.java deleted file mode 100644 index 5438752..0000000 --- a/src/main/java/cokr/xit/ens/batch/sched/EnsKtGibisScheduler.java +++ /dev/null @@ -1,82 +0,0 @@ -package cokr.xit.ens.batch.sched; - -import cokr.xit.ens.core.aop.EnsResponseVO; -import cokr.xit.ens.core.exception.code.EnsErrCd; -import cokr.xit.ens.modules.ktsigntalk.gibis.service.KtGibisHisService; -import cokr.xit.ens.modules.ktsigntalk.gibis.service.KtGibisService; -import com.querydsl.core.Tuple; -import com.querydsl.jpa.impl.JPAQueryFactory; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Profile; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.util.List; - -import static cokr.xit.ens.modules.common.ctgy.sys.mng.domain.QOrgMng.orgMng; - -@Slf4j -@Component -@Profile("!local & !local-maria & !local-oracle & !local-test") -@RequiredArgsConstructor -public class EnsKtGibisScheduler { - - private final KtGibisService ktGibisService; - private final KtGibisHisService ktGibisHisService; - private final JPAQueryFactory query; - - - /** - * KT 인증톡(지비스) 전송 처리 - * -. "제작성공(makeok)" 상태의 모든 자료에 대해 전송을 수행 한다. - */ - @Scheduled(cron = "0 */1 9-18 * * *") - public void sended() { - EnsResponseVO responseVO = ktGibisService.sendBulkAll(); - log.info("======================================================="); - log.info("[ENS] KT 인증톡(지비스) 전송처리"); - log.info("결과: {}", responseVO.toString()); - log.info("======================================================="); - } - - - /** - * KT 인증톡(지비스) 인증토큰 갱신 - */ - @Scheduled(cron = "0 0 0 1 */4 *") - public void refreshAuthToken() { - List list = query.select(orgMng.orgCd, orgMng.ktStClientId, orgMng.ktStClientSecret) - .from(orgMng) - .where(orgMng.ktStAccessToken.isNotNull()) - .fetch(); - - int cntRefresh = list.stream() - .map(tuple -> { - EnsResponseVO ensResponseVO = ktGibisService.refreshAuthToken(tuple.get(orgMng.orgCd), tuple.get(orgMng.ktStClientId), tuple.get(orgMng.ktStClientSecret)); - return EnsErrCd.OK.equals(ensResponseVO.getErrCode()) ? 1 : 0; - }) - .reduce(Integer::sum) - .orElse(0); - - log.info("======================================================="); - log.info("[ENS] KT 인증톡(지비스) accessToken 갱신"); - log.info("결과: {} 건 갱신({}/{})", cntRefresh, cntRefresh, list.size()); - log.info("======================================================="); - } - - -// /** -// * KT 인증톡(지비스) 상태갱신요청이력 영구 삭제 -// */ -// @Scheduled(cron = "4 4 4 * * *") -// public void deleteStateHis() { -// EnsResponseVO ensResponseVO = ktGibisHisService.truncateStatHist(); -// log.info("======================================================="); -// log.info("[ENS] KT 인증톡(지비스) 상태변경요청이력 영구 삭제"); -// log.info("결과: {} 건 삭제", ensResponseVO.getResultInfo()); -// log.info("======================================================="); -// } - - -} diff --git a/src/main/java/cokr/xit/ens/batch/sched/EnsKtSigntalkScheduler.java b/src/main/java/cokr/xit/ens/batch/sched/EnsKtSigntalkScheduler.java deleted file mode 100644 index 7086ba2..0000000 --- a/src/main/java/cokr/xit/ens/batch/sched/EnsKtSigntalkScheduler.java +++ /dev/null @@ -1,63 +0,0 @@ -package cokr.xit.ens.batch.sched; - -import cokr.xit.ens.core.aop.EnsResponseVO; -import cokr.xit.ens.modules.ktsigntalk.direct.service.KtSigntalkHisService; -import cokr.xit.ens.modules.ktsigntalk.direct.service.KtSigntalkService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Profile; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -@Slf4j -@Component -@Profile("!local & !local-maria & !local-oracle & !local-test") -@RequiredArgsConstructor -public class EnsKtSigntalkScheduler { - - private final KtSigntalkService ktSigntalkService; - private final KtSigntalkHisService ktSigntalkHisService; - - - /** - * KT 인증톡 전송 처리 - * -. "제작성공(makeok)" 상태의 모든 자료에 대해 전송을 수행 한다. - */ - @Scheduled(cron = "0 */1 9-18 * * *") - public void sended() { - EnsResponseVO responseVO = ktSigntalkService.sendBulkAll(); - log.info("======================================================="); - log.info("[ENS] KT 인증톡 전송처리"); - log.info("결과: {}", responseVO.toString()); - log.info("======================================================="); - } - - /** - * KT 인증톡 상태갱신 처리 - * -. "발송성공/발송완료/열람중(sendok/sendcmplt/open)" 상태의 자료에 대해 문서상태를 갱신 한다. - * -. 문서상태는 현재 상태에 따라 "전송완료(sendcmplt) 또는 열람중(open)"으로 갱신 된다. - */ -// @Scheduled(cron = "0 */5 9-18 * * *") - @Scheduled(cron = "0 */30 9-18 * * *") - public void fetched() { - EnsResponseVO responseVO = ktSigntalkService.statBulkAll(); - log.info("======================================================="); - log.info("[ENS] KT 인증톡 문서상태갱신 처리"); - log.info("결과: {}", responseVO.toString()); - log.info("======================================================="); - } - - /** - * KT 인증톡 상태갱신요청이력 영구 삭제 - */ - @Scheduled(cron = "4 4 4 * * *") - public void deleteStateHis() { - EnsResponseVO ensResponseVO = ktSigntalkHisService.truncateStatHist(); - log.info("======================================================="); - log.info("[ENS] KT 인증톡 상태변경요청이력 영구 삭제"); - log.info("결과: {} 건 삭제", ensResponseVO.getResultInfo()); - log.info("======================================================="); - } - - -} diff --git a/src/main/java/cokr/xit/ens/batch/sched/EnsNvSigntalkScheduler.java b/src/main/java/cokr/xit/ens/batch/sched/EnsNvSigntalkScheduler.java deleted file mode 100644 index 180beb3..0000000 --- a/src/main/java/cokr/xit/ens/batch/sched/EnsNvSigntalkScheduler.java +++ /dev/null @@ -1,70 +0,0 @@ -package cokr.xit.ens.batch.sched; - -import cokr.xit.ens.core.aop.EnsResponseVO; -import cokr.xit.ens.modules.nvsigntalk.service.NvSigntalkHisService; -import cokr.xit.ens.modules.nvsigntalk.service.NvSigntalkService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Profile; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -@Slf4j -@Component -@Profile("!local & !local-maria & !local-oracle & !local-test") -@RequiredArgsConstructor -public class EnsNvSigntalkScheduler { - - private final NvSigntalkService nvSigntalkService; - private final NvSigntalkHisService nvSigntalkHisService; - - - /** - * 네이버 고지서(인증톡) 전송 처리 - * -. "제작성공(makeok)" 상태의 모든 자료에 대해 전송을 수행 한다. - */ - @Scheduled(cron = "0 */1 9-18 * * *") - public void sended() { - EnsResponseVO responseVO = nvSigntalkService.sendBulkAll(); - StringBuffer sb = new StringBuffer(); - sb.append("\n=======================================================") - .append("\n[ENS] 네이버 고지서(인증톡) 전송처리") - .append("\n결과: {}") - .append("\n======================================================="); - log.info(sb.toString(), responseVO.toString()); - } - - /** - * 네이버 고지서(인증톡) 상태갱신 처리 - * -. "발송성공/발송완료/열람중(sendok/sendcmplt/open)" 상태의 자료에 대해 문서상태를 갱신 한다. - * -. 문서상태는 현재 상태에 따라 "전송완료(sendcmplt) 또는 열람중(open)"으로 갱신 된다. - */ -// @Scheduled(cron = "0 */5 9-18 * * *") - @Scheduled(cron = "0 */30 9-18 * * *") - public void fetched() { - EnsResponseVO responseVO = nvSigntalkService.statBulkAll(); - StringBuffer sb = new StringBuffer(); - sb.append("\n=======================================================") - .append("\n[ENS] 네이버 고지서(인증톡) 문서상태갱신 처리") - .append("\n결과: {}") - .append("\n======================================================="); - log.info(sb.toString(), responseVO.toString()); - } - - - /** - * 네이버 고지서(인증톡) 상태갱신요청이력 영구 삭제 - */ - @Scheduled(cron = "4 4 4 * * *") - public void deleteStateHis() { - Long totCnt = nvSigntalkHisService.truncateStatHist(); - StringBuffer sb = new StringBuffer(); - sb.append("\n=======================================================") - .append("\n[ENS] 네이버 고지서(인증톡) 상태변경요청이력 영구 삭제") - .append("\n결과: {} 건 삭제") - .append("\n======================================================="); - log.info(sb.toString(), totCnt); - } - - -} diff --git a/src/main/java/cokr/xit/ens/batch/sched/EnsScheduler.java b/src/main/java/cokr/xit/ens/batch/sched/EnsScheduler.java deleted file mode 100644 index dbf698f..0000000 --- a/src/main/java/cokr/xit/ens/batch/sched/EnsScheduler.java +++ /dev/null @@ -1,48 +0,0 @@ -package cokr.xit.ens.batch.sched; - -import cokr.xit.ens.modules.common.code.StatCd; -import cokr.xit.ens.modules.common.domain.SendMast; -import cokr.xit.ens.modules.common.domain.repository.SendMastRepository; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Profile; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -@Slf4j -@Component -@Profile("!local & !local-maria & !local-oracle & !local-test") -//@Profile({"prod-traffic", "prod-iup"}) -@RequiredArgsConstructor -public class EnsScheduler { - - private final SendMastRepository sendMastRepository; - - - /** - * 마감처리 - * -. "열람(open)" 상태의 자료 중 마감기한이 경과한 자료의 상태정보를 "마감(close)" 으로 변경 한다. - */ - @Scheduled(cron = "0 */5 9-18 * * *") - @Transactional - public void closed() { - log.info("======================================================="); - List sendMastList = sendMastRepository.findAllByStatCdInAndCloseDtBefore(Arrays.asList(StatCd.sendcmplt, StatCd.open), LocalDateTime.now()); - log.info("[ENS] 마감처리 - 총 {}건", sendMastList.size()); - log.info("SendMastId {}", sendMastList.stream() - .map(row -> { - row.setStatCd(StatCd.close); - return row.getSendMastId(); - }) - .collect(Collectors.toList()) - .toString()); - log.info("======================================================="); - } - -}