From 74b244981b7c4cc0e0cf88cb94f9f30e9a4149a2 Mon Sep 17 00:00:00 2001 From: "gayoun.park" Date: Mon, 2 Feb 2026 12:17:18 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B5=AD=EC=9C=A0=EC=9D=B8=20=EC=97=B0?= =?UTF-8?q?=EB=8F=99=20API=20=EC=9D=91=EB=8B=B5=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gukyuin/dto/ChngDetectMastDto.java | 12 +++++++ .../gukyuin/service/GukYuinApiService.java | 35 +++++++++++++++---- .../gukyuin/GukYuinRepositoryImpl.java | 2 +- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/kamco/cd/kamcoback/gukyuin/dto/ChngDetectMastDto.java b/src/main/java/com/kamco/cd/kamcoback/gukyuin/dto/ChngDetectMastDto.java index a124ac66..caacc7c6 100644 --- a/src/main/java/com/kamco/cd/kamcoback/gukyuin/dto/ChngDetectMastDto.java +++ b/src/main/java/com/kamco/cd/kamcoback/gukyuin/dto/ChngDetectMastDto.java @@ -216,4 +216,16 @@ public class ChngDetectMastDto { private ZonedDateTime reviewerWorkDttm; private ZonedDateTime labelSendDttm; } + + @Getter + @Setter + @NoArgsConstructor + @AllArgsConstructor + public static class ErrorResDto { + + private String timestamp; + private Integer status; + private String error; + private String path; + } } diff --git a/src/main/java/com/kamco/cd/kamcoback/gukyuin/service/GukYuinApiService.java b/src/main/java/com/kamco/cd/kamcoback/gukyuin/service/GukYuinApiService.java index 46ace37b..9d1a42e5 100644 --- a/src/main/java/com/kamco/cd/kamcoback/gukyuin/service/GukYuinApiService.java +++ b/src/main/java/com/kamco/cd/kamcoback/gukyuin/service/GukYuinApiService.java @@ -1,5 +1,7 @@ package com.kamco.cd.kamcoback.gukyuin.service; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.kamco.cd.kamcoback.common.utils.NetUtils; import com.kamco.cd.kamcoback.common.utils.UserUtil; import com.kamco.cd.kamcoback.config.api.ApiLogFunction; @@ -13,6 +15,7 @@ import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto.ResultContDto; import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto.ResultPnuDto; import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto; import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ChnDetectMastReqDto; +import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ErrorResDto; import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LabelSendDto; import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResReturn; import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResultDto; @@ -51,6 +54,7 @@ public class GukYuinApiService { private final UserUtil userUtil; private final AuditLogRepository auditLogRepository; + private final ObjectMapper objectMapper; @Value("${spring.profiles.active:local}") private String profile; @@ -80,15 +84,30 @@ public class GukYuinApiService { ChngDetectMastDto.RegistResDto.class); ChngDetectMastDto.RegistResDto resultBody = result.body(); - Boolean success = false; - if (resultBody != null) { + boolean success = false; + if (resultBody != null && resultBody.getSuccess() != null) { ChngDetectMastDto.Basic registRes = resultBody.getResult(); + + success = resultBody.getSuccess(); // 추론 회차에 applyStatus, applyStatusDttm 업데이트 gukyuinCoreService.updateGukYuinMastRegResult(registRes); // anal_inference 에도 국유인 반영여부, applyDttm 업데이트 gukyuinCoreService.updateAnalInferenceApplyDttm(registRes); - success = resultBody.getSuccess(); + } else { + String errBody = result.errBody(); + ErrorResDto error = null; + try { + error = objectMapper.readValue(errBody, ErrorResDto.class); + return new ChngDetectMastDto.RegistResDto(error.getStatus(), error.getError(), null, false); + } catch (JsonProcessingException e) { + log.error("에러 응답 파싱 실패. rawBody={}", errBody, e); + return new ChngDetectMastDto.RegistResDto( + result.statusCode(), // HTTP status + errBody, // 원문 그대로 + null, + false); + } } this.insertGukyuinAuditLog( @@ -98,6 +117,7 @@ public class GukYuinApiService { url.replace(gukyuinUrl, ""), chnDetectMastReq, success); + return resultBody; } @@ -398,9 +418,12 @@ public class GukYuinApiService { } // 국유인 /chn/mast/regist 전송 - this.regist(reqDto); - - return new ResponseObj(ApiResponseCode.OK, ""); + ChngDetectMastDto.RegistResDto result = this.regist(reqDto); + if (result.getSuccess()) { + return new ResponseObj(ApiResponseCode.OK, "연동되었습니다."); + } else { + return new ResponseObj(ApiResponseCode.INTERNAL_SERVER_ERROR, result.getMessage()); + } } public List findLabelingCompleteSendList(LocalDate yesterday) { diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/gukyuin/GukYuinRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/gukyuin/GukYuinRepositoryImpl.java index 51503a7a..9235addb 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/gukyuin/GukYuinRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/gukyuin/GukYuinRepositoryImpl.java @@ -164,7 +164,7 @@ public class GukYuinRepositoryImpl implements GukYuinRepositoryCustom { Expressions.numberTemplate(Integer.class, "coalesce({0}, 0)", mapSheetLearnEntity.stage); return queryFactory - .select(stageExpr.max()) + .select(stageExpr.max().coalesce(0)) .from(mapSheetLearnEntity) .where( mapSheetLearnEntity.compareYyyy.eq(compareYyyy),