From e29ba6a6573a846c9c0ac594bf5924ea129b2430 Mon Sep 17 00:00:00 2001 From: limju Date: Thu, 26 Oct 2023 16:01:49 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=B9=B4=EC=B9=B4=EC=98=A4=20sendBulks,?= =?UTF-8?q?=20statusBulks=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/cmm/service/CmmEnsFileService.java | 4 +- .../service/AsyncKkopayEltrcDocService.java | 8 +- .../kakao/service/KkopayEltrcDocService.java | 18 ++- .../kakao/web/KkopayEltrcDocController.java | 17 ++- .../xit/biz/ens/service/EnsBatchService.java | 131 ++++++++++-------- .../biz/ens/service/EnsCctvFileService.java | 2 +- .../biz/pni/service/PniCctvFileService.java | 2 +- .../spring/config/cache/CachingConfig.java | 2 +- .../kr/xit/core/support/utils/IpMacUtils.java | 2 +- .../core/support/xlsx/impl/StreamingRow.java | 2 +- .../xlsx/sst/BufferedStringsTable.java | 2 +- .../xit/core/init/custom/AppInitHelper.java | 2 +- 12 files changed, 107 insertions(+), 85 deletions(-) diff --git a/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsFileService.java b/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsFileService.java index fa3d9cd..1310c79 100644 --- a/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsFileService.java +++ b/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsFileService.java @@ -76,11 +76,11 @@ public class CmmEnsFileService extends EgovAbstractServiceImpl implements ICmmEn @Override public String fmcExcelUpload(FmcExcelUpload fileReq) { final Set> errors = validator.validate(fileReq); - if (errors.size() > 0) { + if (!errors.isEmpty()) { throw BizRuntimeException.create(errors.stream() .map(row -> String.format("%s=%s", row.getPropertyPath(), row.getMessageTemplate())) - .collect(Collectors.toList()).toString()); + .toList().toString()); } diff --git a/mens-api/src/main/java/kr/xit/ens/kakao/service/AsyncKkopayEltrcDocService.java b/mens-api/src/main/java/kr/xit/ens/kakao/service/AsyncKkopayEltrcDocService.java index f45c4fc..fe7568c 100644 --- a/mens-api/src/main/java/kr/xit/ens/kakao/service/AsyncKkopayEltrcDocService.java +++ b/mens-api/src/main/java/kr/xit/ens/kakao/service/AsyncKkopayEltrcDocService.java @@ -254,7 +254,7 @@ public class AsyncKkopayEltrcDocService extends EgovAbstractServiceImpl implemen errors.add(String.format("문서 식별 번호는 40자를 넘을 수 없습니다[%d번째]", idx+1)); } } - if(errors.size() > 0) { + if(!errors.isEmpty()) { throw BizRuntimeException.create(errors.toString()); } @@ -272,14 +272,14 @@ public class AsyncKkopayEltrcDocService extends EgovAbstractServiceImpl implemen private static List validate(T t, List errList) { final Set> list = validator.validate(t); - if (list.size() > 0) { + if (!list.isEmpty()) { List errors = list.stream() .map(row -> String.format("%s=%s", row.getPropertyPath(), row.getMessageTemplate())) - .collect(Collectors.toList()); + .toList(); // 추가적인 유효성 검증이 필요 없는 경우 if(errList == null){ - if(errors.size() > 0) throw BizRuntimeException.create(errors.toString()); + if(!errors.isEmpty()) throw BizRuntimeException.create(errors.toString()); return null; } errList.addAll(errors); diff --git a/mens-api/src/main/java/kr/xit/ens/kakao/service/KkopayEltrcDocService.java b/mens-api/src/main/java/kr/xit/ens/kakao/service/KkopayEltrcDocService.java index 5052e99..ab6c9a8 100644 --- a/mens-api/src/main/java/kr/xit/ens/kakao/service/KkopayEltrcDocService.java +++ b/mens-api/src/main/java/kr/xit/ens/kakao/service/KkopayEltrcDocService.java @@ -4,11 +4,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.Set; -import java.util.stream.Collectors; import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; - import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO; import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO; import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO.DocumentBinderUuid; @@ -109,7 +107,7 @@ public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements if(Checks.isEmpty(receiver.getPhone_number())) Objects.requireNonNull(errors).add("receiver.phone_number=받는이 전화번호는 필수입니다."); if(Checks.isEmpty(receiver.getBirthday())) Objects.requireNonNull(errors).add("receiver.birthday=받는이 생년월일은 필수입니다."); } - if(Objects.requireNonNull(errors).size() > 0) throw BizRuntimeException.create(errors.toString()); + if(!Objects.requireNonNull(errors).isEmpty()) throw BizRuntimeException.create(errors.toString()); return webClient.exchangeKko(HOST + API_SEND[0], HttpMethod.valueOf(API_SEND[1]), JsonUtils.toJson(reqDTO), SendResponse.class, getEnsRlaybsnmDTO(reqDTO.getSignguCode(), reqDTO.getFfnlgCode())); } @@ -189,12 +187,12 @@ public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements List dtos = reqDTO.getDocuments(); for(int idx = 0; idx < dtos.size(); idx++) { final Set> list = validator.validate(dtos.get(idx)); - if (list.size() > 0) { + if (!list.isEmpty()) { int finalIdx = idx; errors.addAll(list.stream() .map(row -> String.format("%s[%d]=%s", row.getPropertyPath(), finalIdx +1, row.getMessageTemplate())) - .collect(Collectors.toList()) + .toList() ); } } @@ -223,7 +221,7 @@ public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements } } } - if(errors.size() > 0){ + if(!errors.isEmpty()){ throw BizRuntimeException.create(errors.toString()); } @@ -254,7 +252,7 @@ public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements errors.add(String.format("문서 식별 번호는 40자를 넘을 수 없습니다[%d번째]", idx+1)); } } - if(errors.size() > 0) { + if(!errors.isEmpty()) { throw BizRuntimeException.create(errors.toString()); } return webClient.exchangeKko(HOST + API_BULKSTATUS[0], HttpMethod.valueOf(API_BULKSTATUS[1]), JsonUtils.toJson(reqDTO), BulkStatusResponses.class, getEnsRlaybsnmDTO(reqDTO.getSignguCode(), reqDTO.getFfnlgCode())); @@ -293,14 +291,14 @@ public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements private static List validate(T t, List errList) { final Set> list = validator.validate(t); - if(list.size() > 0) { + if(!list.isEmpty()) { final List errors = list.stream() .map(row -> String.format("%s=%s", row.getPropertyPath(), row.getMessageTemplate())) - .collect(Collectors.toList()); + .toList(); // 추가적인 유효성 검증이 필요 없는 경우 if(errList == null){ - if(errors.size() > 0) throw BizRuntimeException.create(errors.toString()); + if(!errors.isEmpty()) throw BizRuntimeException.create(errors.toString()); return null; } errList.addAll(errors); diff --git a/mens-api/src/main/java/kr/xit/ens/kakao/web/KkopayEltrcDocController.java b/mens-api/src/main/java/kr/xit/ens/kakao/web/KkopayEltrcDocController.java index 2928284..675ad28 100644 --- a/mens-api/src/main/java/kr/xit/ens/kakao/web/KkopayEltrcDocController.java +++ b/mens-api/src/main/java/kr/xit/ens/kakao/web/KkopayEltrcDocController.java @@ -150,9 +150,18 @@ public class KkopayEltrcDocController { * -.이용기관 서버에서 전자문서 서버로 문서발송 처리를 요청합니다. * * @param reqDTO KkopayDocBulkDTO.BulkSendRequests - * @return ApiResponseDTO + * @return BulkStatusResponses.BulkSendResponses */ - @Operation(summary = "대량 문서발송 요청", description = "카카오페이 전자문서 서버로 대량 문서발송 처리를 요청") + /* + @Operation(summary = "대량 문서발송 요청 -> batch sendBulks 에서 호출", description = "카카오페이 전자문서 서버로 대량 문서발송 처리를 요청 -> batch sendBulks 에서 호출") + @PostMapping(value = "/documents/bulk", produces = MediaType.APPLICATION_JSON_VALUE) + public BulkSendResponses requestSendBulk( + @RequestBody final BulkSendRequests reqDTO + ) { + return service.requestSendBulk(reqDTO); + } +*/ + @Operation(summary = "대량 문서발송 요청 -> batch sendBulks 에서 호출", description = "카카오페이 전자문서 서버로 대량 문서발송 처리를 요청 -> batch sendBulks 에서 호출") @PostMapping(value = "/documents/bulk", produces = MediaType.APPLICATION_JSON_VALUE) public IApiResponse requestSendBulk( @RequestBody final BulkSendRequests reqDTO @@ -166,9 +175,9 @@ public class KkopayEltrcDocController { * -.이용기관 서버에서 전자문서 서버로 문서발송 처리를 요청합니다. * * @param reqDTO KkopayDocBulkDTO.BulkStatusRequests - * @return ApiResponseDTO + * @return BulkStatusResponses.BulkStatusResponses */ - @Operation(summary = "대량 문서 상태 조회 요청", description = "카카오페이 전자문서 서버로 대량 문서 상태 조회 요청") + @Operation(summary = "대량 문서 상태 조회 요청 -> batch statusBulks 에서 호출", description = "카카오페이 전자문서 서버로 대량 문서 상태 조회 요청 -> batch statusBulks 에서 호출") @PostMapping(value = "/documents/bulk/status", produces = MediaType.APPLICATION_JSON_VALUE) public IApiResponse findBulkStatus( @RequestBody final BulkStatusRequests reqDTO diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchService.java b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchService.java index e948454..d3ff5f1 100644 --- a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchService.java +++ b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchService.java @@ -9,7 +9,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.stream.Collectors; import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; @@ -36,6 +35,7 @@ import kr.xit.core.model.ApiResponseDTO; import kr.xit.core.spring.util.ApiWebClientUtil; import kr.xit.core.support.utils.Checks; import kr.xit.core.support.utils.DateUtils; +import kr.xit.core.support.utils.JsonUtils; import lombok.RequiredArgsConstructor; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.StringUtils; @@ -348,25 +348,30 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc final List docsBinderUuids = mapper.selectKakaoStatusTgts(reqDTO.getSndngProcessSttus()); List> partitions = ListUtils.partition(docsBinderUuids, bulkKkoMaxCnt); - List> apiResults = partitions.stream() - .map(uuids -> - ApiResponseDTO.success( - apiWebClient.exchange( - url.toString(), - HttpMethod.POST, - BulkStatusRequests.builder() - .signguCode(reqDTO.getSignguCode()) - .ffnlgCode(reqDTO.getFfnlgCode()) - .document_binder_uuids(uuids) - .build(), - BulkStatusResponses.class, - getHeadeMap())) - ).collect(Collectors.toList()); - - - List resList = apiResults.stream() - .map(ApiResponseDTO::getData) - .collect(Collectors.toList()); + List apiResults = partitions.stream() + .map(uuids -> apiWebClient.exchange( + url, + HttpMethod.POST, + BulkStatusRequests.builder() + .signguCode(reqDTO.getSignguCode()) + .ffnlgCode(reqDTO.getFfnlgCode()) + .document_binder_uuids(uuids) + .build(), + ApiResponseDTO.class, + getHeadeMap()) + ).toList(); + + List resList = new ArrayList<>(); + + for(ApiResponseDTO apiResult : apiResults) { + if(apiResult.getData() != null) { + BulkStatusResponses data = JsonUtils.toObjByObj(apiResult.getData(), + BulkStatusResponses.class); + resList.add(data); + }else{ + throw BizRuntimeException.create(apiResult.getMessage()); + } + } // 결과 반영 resList.forEach(o -> @@ -486,12 +491,12 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc for (EnsDTO.sndngVali dto : list) { Set> errList = validator.validate(dto); - if (list.size() > 0) { + if (!list.isEmpty()) { int finalIdx = idx; errors.addAll(errList.stream() .map(row -> String.format("%s[%d]=%s", row.getPropertyPath(), finalIdx + 1, row.getMessageTemplate())) - .collect(Collectors.toList()) + .toList() ); } @@ -571,7 +576,7 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc idx++; } } - if (errors.size() > 0) { + if (!errors.isEmpty()) { throw BizRuntimeException.create(errors.toString()); } } @@ -726,27 +731,33 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc List> partitions = ListUtils.partition(bulkList, bulkKkoMaxCnt); - - List> apiResults = partitions.stream() - .map(bulkSendList -> - ApiResponseDTO.success( - apiWebClient.exchange( - url.toString(), - HttpMethod.POST, - BulkSendRequests.builder() - .signguCode(tgtDTO.getSignguCode()) - .ffnlgCode(tgtDTO.getFfnlgCode()) - .documents(bulkSendList) - .build(), - BulkSendResponses.class, - getHeadeMap())) + List apiResults = partitions.stream() + .map(bulkSendList -> apiWebClient.exchange( + url, + HttpMethod.POST, + BulkSendRequests.builder() + .signguCode(tgtDTO.getSignguCode()) + .ffnlgCode(tgtDTO.getFfnlgCode()) + .documents(bulkSendList) + .build(), + ApiResponseDTO.class, + getHeadeMap()) ) - .collect(Collectors.toList()); + .toList(); + + + List resList = new ArrayList<>(); - // GET 결과 목록 - List resList = apiResults.stream() - .map(ApiResponseDTO::getData) - .collect(Collectors.toList()); + for(ApiResponseDTO apiResult : apiResults) { + if(apiResult.getData() != null) { + BulkSendResponses data = JsonUtils.toObjByObj(apiResult.getData(), + BulkSendResponses.class); + resList.add(data); + }else{ + updateKkoMyDocSndngMstFailStatus(mstIdList, apiResult.getMessage()); + throw BizRuntimeException.create(apiResult.getMessage()); + } + } // 카카오 문서 요청 결과 반영 requireNewService.saveKkoMyDocResult(mstIdList, tgtDTO.getUnitySndngMastrId(), resList); @@ -829,13 +840,13 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc Set> errList = validator.validate( dto); - if (list.size() > 0) { + if (!list.isEmpty()) { int finalIdx = idx; errors.addAll(errList.stream() .map(row -> String.format("%s[%d]=%s", row.getPropertyPath(), finalIdx + 1, row.getMessageTemplate())) - .collect(Collectors.toList()) + .toList() ); } @@ -865,7 +876,7 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc } } - if (errors.size() > 0) { + if (!errors.isEmpty()) { throw BizRuntimeException.create(errors.toString()); } } @@ -942,24 +953,28 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc List> partitions = ListUtils.partition(sendReqs, bulkKtMaxCnt); - List> apiResults = partitions.stream() + List apiResults = partitions.stream() .map(bulkSendList -> { infoDto.setReqs(bulkSendList); - return ApiResponseDTO.success( - apiWebClient.exchange( - url.toString(), - HttpMethod.POST, - infoDto, - KtCommonResponse.class, - getHeadeMap())); + return apiWebClient.exchange( + url, + HttpMethod.POST, + infoDto, + ApiResponseDTO.class, + getHeadeMap()); } ) - .collect(Collectors.toList()); + .toList(); - // GET 결과 목록 - List resList = apiResults.stream() - .map(ApiResponseDTO::getData) - .collect(Collectors.toList()); + List resList = new ArrayList<>(); + for(ApiResponseDTO apiResult : apiResults) { + if(apiResult.getData() != null) { + resList.add(JsonUtils.toObjByObj(apiResult.getData(), KtCommonResponse.class)); + }else{ + //updateKkoMyDocSndngMstFailStatus(mstIdList, apiResult.getMessage()); + throw BizRuntimeException.create(apiResult.getMessage()); + } + } // 카카오 문서 요청 결과 반영 //requireNewService.saveKkoMyDocResult(mstIdList, tgtDTO.getUnitySndngMastrId(), resList); diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsCctvFileService.java b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsCctvFileService.java index 4bb06d4..a6fe63d 100644 --- a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsCctvFileService.java +++ b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsCctvFileService.java @@ -140,7 +140,7 @@ public class EnsCctvFileService extends EgovAbstractServiceImpl implements IEnsC public void acceptEnsNtnccntcSndng() { List tgtList = mapper.selectEnsNtncCntcSndngs(); - if(tgtList.size() == 0) return; + if(tgtList.isEmpty()) return; // search 전자 고지 연계발송 데이타 생성 대상 Optional first = tgtList.stream() diff --git a/mens-batch/src/main/java/kr/xit/biz/pni/service/PniCctvFileService.java b/mens-batch/src/main/java/kr/xit/biz/pni/service/PniCctvFileService.java index a7676e6..551244f 100644 --- a/mens-batch/src/main/java/kr/xit/biz/pni/service/PniCctvFileService.java +++ b/mens-batch/src/main/java/kr/xit/biz/pni/service/PniCctvFileService.java @@ -138,7 +138,7 @@ public class PniCctvFileService extends EgovAbstractServiceImpl implements IPniC public void acceptPniNtnccntcSndng() { List tgtList = mapper.selectPniNtncCntcSndngs(); - if(tgtList.size() == 0) return; + if(tgtList.isEmpty()) return; // search 사전알림 연계발송 SMS 데이타 생성 대상 Optional sms = tgtList.stream() diff --git a/mens-core/src/main/java/kr/xit/core/spring/config/cache/CachingConfig.java b/mens-core/src/main/java/kr/xit/core/spring/config/cache/CachingConfig.java index 59c3026..85fa482 100644 --- a/mens-core/src/main/java/kr/xit/core/spring/config/cache/CachingConfig.java +++ b/mens-core/src/main/java/kr/xit/core/spring/config/cache/CachingConfig.java @@ -68,7 +68,7 @@ public class CachingConfig { log.info("Key {} was evicted ({}): {}", key, cause, value)) .build() )) - .collect(Collectors.toList()); + .toList(); final SimpleCacheManager cacheManager = new SimpleCacheManager(); cacheManager.setCaches(caffeineCaches); diff --git a/mens-core/src/main/java/kr/xit/core/support/utils/IpMacUtils.java b/mens-core/src/main/java/kr/xit/core/support/utils/IpMacUtils.java index e799fb0..1f77286 100644 --- a/mens-core/src/main/java/kr/xit/core/support/utils/IpMacUtils.java +++ b/mens-core/src/main/java/kr/xit/core/support/utils/IpMacUtils.java @@ -117,7 +117,7 @@ public class IpMacUtils { if(inetAddress.getAddress().length == 4) ips.add(inetAddress.getHostAddress().toString()); } } - return ips.stream().distinct().collect(Collectors.toList()); + return ips.stream().distinct().toList(); } catch (SocketException e) { log.error("{}", e.getLocalizedMessage()); throw BizRuntimeException.create(e.getLocalizedMessage()); diff --git a/mens-core/src/main/java/kr/xit/core/support/xlsx/impl/StreamingRow.java b/mens-core/src/main/java/kr/xit/core/support/xlsx/impl/StreamingRow.java index 980b128..e8037e3 100644 --- a/mens-core/src/main/java/kr/xit/core/support/xlsx/impl/StreamingRow.java +++ b/mens-core/src/main/java/kr/xit/core/support/xlsx/impl/StreamingRow.java @@ -114,7 +114,7 @@ public class StreamingRow implements Row { */ @Override public short getFirstCellNum() { - if (cellMap.size() == 0) { + if (cellMap.isEmpty()) { return -1; } return cellMap.firstKey().shortValue(); diff --git a/mens-core/src/main/java/kr/xit/core/support/xlsx/sst/BufferedStringsTable.java b/mens-core/src/main/java/kr/xit/core/support/xlsx/sst/BufferedStringsTable.java index ef9d23b..8f5f7d7 100644 --- a/mens-core/src/main/java/kr/xit/core/support/xlsx/sst/BufferedStringsTable.java +++ b/mens-core/src/main/java/kr/xit/core/support/xlsx/sst/BufferedStringsTable.java @@ -24,7 +24,7 @@ public class BufferedStringsTable extends SharedStringsTable implements AutoClos throws IOException { List parts = pkg.getPartsByContentType( XSSFRelation.SHARED_STRINGS.getContentType()); - return parts.size() == 0 ? null + return parts.isEmpty() ? null : new BufferedStringsTable(parts.get(0), tmp, cacheSizeBytes); } diff --git a/xit-init/src/main/java/xit/core/init/custom/AppInitHelper.java b/xit-init/src/main/java/xit/core/init/custom/AppInitHelper.java index 8ecb021..2bfa4c4 100644 --- a/xit-init/src/main/java/xit/core/init/custom/AppInitHelper.java +++ b/xit-init/src/main/java/xit/core/init/custom/AppInitHelper.java @@ -152,7 +152,7 @@ public class AppInitHelper { if(inetAddress.getAddress().length == 4) ips.add(inetAddress.getHostAddress().toString()); } } - return ips.stream().distinct().collect(Collectors.toList()); + return ips.stream().distinct().toList(); } catch (SocketException e) { throw e; }