국유인 연동 API 응답 로직 수정
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<LabelSendDto> findLabelingCompleteSendList(LocalDate yesterday) {
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user