[KC-108] ai api 실행

This commit is contained in:
2026-01-12 18:48:59 +09:00
parent ad0c3bc080
commit 546981076c
3 changed files with 25 additions and 17 deletions

View File

@@ -1,7 +1,6 @@
package com.kamco.cd.kamcoback.inference.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient;
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto;
@@ -34,7 +33,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -53,6 +51,9 @@ public class InferenceResultService {
@Value("${inference.url}")
private String inferenceUrl;
@Value("${spring.profiles.active}")
private String profile;
/**
* 추론관리 목록
*
@@ -205,9 +206,7 @@ public class InferenceResultService {
private void ensureAccepted(InferenceSendDto dto) {
log.info("dto null? {}", dto == null);
ObjectMapper om = new ObjectMapper();
String json = "";
try {
json = om.writeValueAsString(dto);
log.info("dto json={}", om.writeValueAsString(dto));
} catch (Exception e) {
log.error(e.getMessage());
@@ -217,12 +216,17 @@ public class InferenceResultService {
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setAccept(List.of(MediaType.APPLICATION_JSON));
ExternalCallResult result =
externalHttpClient.call(inferenceUrl, HttpMethod.POST, dto, headers);
if (!result.success()) {
throw new CustomApiException("BAD_GATEWAY", HttpStatus.BAD_GATEWAY);
// TODO 추후 삭제
if ("local".equals(profile)) {
dto.getPred_requests_areas().setInput1_scene_path("/kamco-nfs/requests/2023_local.geojson");
dto.getPred_requests_areas().setInput2_scene_path("/kamco-nfs/requests/2024_local.geojson");
}
ExternalCallResult<String> result =
externalHttpClient.call(inferenceUrl, HttpMethod.POST, dto, headers, String.class);
int status = result.statusCode();
String body = result.body();
}
/**