국유인 연동 API 응답 로직 수정
This commit is contained in:
@@ -216,4 +216,16 @@ public class ChngDetectMastDto {
|
|||||||
private ZonedDateTime reviewerWorkDttm;
|
private ZonedDateTime reviewerWorkDttm;
|
||||||
private ZonedDateTime labelSendDttm;
|
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;
|
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.NetUtils;
|
||||||
import com.kamco.cd.kamcoback.common.utils.UserUtil;
|
import com.kamco.cd.kamcoback.common.utils.UserUtil;
|
||||||
import com.kamco.cd.kamcoback.config.api.ApiLogFunction;
|
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.ChngDetectContDto.ResultPnuDto;
|
||||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto;
|
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.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.LabelSendDto;
|
||||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResReturn;
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResReturn;
|
||||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResultDto;
|
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResultDto;
|
||||||
@@ -51,6 +54,7 @@ public class GukYuinApiService {
|
|||||||
|
|
||||||
private final UserUtil userUtil;
|
private final UserUtil userUtil;
|
||||||
private final AuditLogRepository auditLogRepository;
|
private final AuditLogRepository auditLogRepository;
|
||||||
|
private final ObjectMapper objectMapper;
|
||||||
|
|
||||||
@Value("${spring.profiles.active:local}")
|
@Value("${spring.profiles.active:local}")
|
||||||
private String profile;
|
private String profile;
|
||||||
@@ -80,15 +84,30 @@ public class GukYuinApiService {
|
|||||||
ChngDetectMastDto.RegistResDto.class);
|
ChngDetectMastDto.RegistResDto.class);
|
||||||
|
|
||||||
ChngDetectMastDto.RegistResDto resultBody = result.body();
|
ChngDetectMastDto.RegistResDto resultBody = result.body();
|
||||||
Boolean success = false;
|
boolean success = false;
|
||||||
if (resultBody != null) {
|
if (resultBody != null && resultBody.getSuccess() != null) {
|
||||||
ChngDetectMastDto.Basic registRes = resultBody.getResult();
|
ChngDetectMastDto.Basic registRes = resultBody.getResult();
|
||||||
|
|
||||||
|
success = resultBody.getSuccess();
|
||||||
// 추론 회차에 applyStatus, applyStatusDttm 업데이트
|
// 추론 회차에 applyStatus, applyStatusDttm 업데이트
|
||||||
gukyuinCoreService.updateGukYuinMastRegResult(registRes);
|
gukyuinCoreService.updateGukYuinMastRegResult(registRes);
|
||||||
|
|
||||||
// anal_inference 에도 국유인 반영여부, applyDttm 업데이트
|
// anal_inference 에도 국유인 반영여부, applyDttm 업데이트
|
||||||
gukyuinCoreService.updateAnalInferenceApplyDttm(registRes);
|
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(
|
this.insertGukyuinAuditLog(
|
||||||
@@ -98,6 +117,7 @@ public class GukYuinApiService {
|
|||||||
url.replace(gukyuinUrl, ""),
|
url.replace(gukyuinUrl, ""),
|
||||||
chnDetectMastReq,
|
chnDetectMastReq,
|
||||||
success);
|
success);
|
||||||
|
|
||||||
return resultBody;
|
return resultBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,9 +418,12 @@ public class GukYuinApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 국유인 /chn/mast/regist 전송
|
// 국유인 /chn/mast/regist 전송
|
||||||
this.regist(reqDto);
|
ChngDetectMastDto.RegistResDto result = this.regist(reqDto);
|
||||||
|
if (result.getSuccess()) {
|
||||||
return new ResponseObj(ApiResponseCode.OK, "");
|
return new ResponseObj(ApiResponseCode.OK, "연동되었습니다.");
|
||||||
|
} else {
|
||||||
|
return new ResponseObj(ApiResponseCode.INTERNAL_SERVER_ERROR, result.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LabelSendDto> findLabelingCompleteSendList(LocalDate yesterday) {
|
public List<LabelSendDto> findLabelingCompleteSendList(LocalDate yesterday) {
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ public class GukYuinRepositoryImpl implements GukYuinRepositoryCustom {
|
|||||||
Expressions.numberTemplate(Integer.class, "coalesce({0}, 0)", mapSheetLearnEntity.stage);
|
Expressions.numberTemplate(Integer.class, "coalesce({0}, 0)", mapSheetLearnEntity.stage);
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(stageExpr.max())
|
.select(stageExpr.max().coalesce(0))
|
||||||
.from(mapSheetLearnEntity)
|
.from(mapSheetLearnEntity)
|
||||||
.where(
|
.where(
|
||||||
mapSheetLearnEntity.compareYyyy.eq(compareYyyy),
|
mapSheetLearnEntity.compareYyyy.eq(compareYyyy),
|
||||||
|
|||||||
Reference in New Issue
Block a user