Compare commits
17 Commits
feat/dean/
...
a4b1db462b
| Author | SHA1 | Date | |
|---|---|---|---|
| a4b1db462b | |||
| 2bf7c42a3f | |||
| a1be4e9faf | |||
| 8904de0e3d | |||
| a21df9d018 | |||
| 85cad2dd28 | |||
| 7b8bf8726b | |||
| c841d460aa | |||
| 3a8ac3a24f | |||
| 046f4f06d3 | |||
| 5c9f33d210 | |||
| ea7e98d28e | |||
| 3e78f744a4 | |||
| cea1f01ed9 | |||
| d7f2d22b93 | |||
| eccdfb17e6 | |||
| d2fa86a89f |
@@ -5,7 +5,9 @@ import com.kamco.cd.kamcoback.common.download.dto.DownloadAuditEvent;
|
|||||||
import com.kamco.cd.kamcoback.menu.dto.MenuDto;
|
import com.kamco.cd.kamcoback.menu.dto.MenuDto;
|
||||||
import com.kamco.cd.kamcoback.menu.service.MenuService;
|
import com.kamco.cd.kamcoback.menu.service.MenuService;
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.AuditLogEntity;
|
import com.kamco.cd.kamcoback.postgres.entity.AuditLogEntity;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.MemberEntity;
|
||||||
import com.kamco.cd.kamcoback.postgres.repository.log.AuditLogRepository;
|
import com.kamco.cd.kamcoback.postgres.repository.log.AuditLogRepository;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.repository.members.MembersRepository;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -24,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
public class DownloadAuditEventListener {
|
public class DownloadAuditEventListener {
|
||||||
|
|
||||||
private final AuditLogRepository auditLogRepository;
|
private final AuditLogRepository auditLogRepository;
|
||||||
|
private final MembersRepository membersRepository;
|
||||||
private final MenuService menuService;
|
private final MenuService menuService;
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
|
|
||||||
@@ -42,9 +45,23 @@ public class DownloadAuditEventListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Long userId = ev.userId();
|
||||||
|
|
||||||
|
if (userId == null) {
|
||||||
|
// a 링크로 들어온 download는 사번으로 파라미터가 전달 되므로 사번으로 user id 조회 하기
|
||||||
|
MemberEntity memberEntity =
|
||||||
|
membersRepository.findByEmployeeNo(ev.employeeNo()).orElse(null);
|
||||||
|
|
||||||
|
if (memberEntity == null) {
|
||||||
|
return; // 매핑 실패 시 로그 저장 안 함
|
||||||
|
}
|
||||||
|
|
||||||
|
userId = memberEntity.getId();
|
||||||
|
}
|
||||||
|
|
||||||
AuditLogEntity logEntity =
|
AuditLogEntity logEntity =
|
||||||
AuditLogEntity.forFileDownload(
|
AuditLogEntity.forFileDownload(
|
||||||
ev.userId(), ev.requestUri(), menuUid, ev.ip(), ev.status(), ev.downloadUuid());
|
userId, ev.requestUri(), menuUid, ev.ip(), ev.status(), ev.downloadUuid());
|
||||||
|
|
||||||
auditLogRepository.save(logEntity);
|
auditLogRepository.save(logEntity);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public record DownloadAuditEvent(
|
public record DownloadAuditEvent(
|
||||||
Long userId,
|
Long userId,
|
||||||
|
String employeeNo,
|
||||||
String requestUri,
|
String requestUri,
|
||||||
String normalizedUri,
|
String normalizedUri,
|
||||||
String ip,
|
String ip,
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
package com.kamco.cd.kamcoback.common.inference.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
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.InferenceSendDto;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Log4j2
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class InferenceCommonService {
|
||||||
|
|
||||||
|
@Value("${spring.profiles.active}")
|
||||||
|
private String profile;
|
||||||
|
|
||||||
|
@Value("${inference.url}")
|
||||||
|
private String inferenceUrl;
|
||||||
|
|
||||||
|
private final ObjectMapper objectMapper;
|
||||||
|
private final ExternalHttpClient externalHttpClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 추론 AI API 호출 batch id를 리턴
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Long ensureAccepted(InferenceSendDto dto) {
|
||||||
|
|
||||||
|
if (dto == null) {
|
||||||
|
log.warn("not InferenceSendDto dto");
|
||||||
|
throw new CustomApiException("BAD_REQUEST", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("");
|
||||||
|
log.info("========================================================");
|
||||||
|
log.info("[SEND INFERENCE] Inference request dto= {}", dto);
|
||||||
|
log.info("========================================================");
|
||||||
|
log.info("");
|
||||||
|
|
||||||
|
// 1) 요청 로그
|
||||||
|
try {
|
||||||
|
log.debug("Inference request dto={}", objectMapper.writeValueAsString(dto));
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
log.warn("Failed to serialize inference dto", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) local 환경 임시 처리
|
||||||
|
// if ("local".equals(profile)) {
|
||||||
|
// if (dto.getPred_requests_areas() == null) {
|
||||||
|
// throw new IllegalStateException("pred_requests_areas is null");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// 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");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 3) HTTP 호출
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
headers.setAccept(List.of(MediaType.APPLICATION_JSON));
|
||||||
|
|
||||||
|
// 4) 추론 실행 API 호출
|
||||||
|
ExternalCallResult<String> result =
|
||||||
|
externalHttpClient.call(inferenceUrl, HttpMethod.POST, dto, headers, String.class);
|
||||||
|
|
||||||
|
if (result.statusCode() < 200 || result.statusCode() >= 300) {
|
||||||
|
log.error("Inference API failed. status={}, body={}", result.statusCode(), result.body());
|
||||||
|
throw new CustomApiException("BAD_GATEWAY", HttpStatus.BAD_GATEWAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5) 응답 파싱
|
||||||
|
try {
|
||||||
|
List<Map<String, Object>> list =
|
||||||
|
objectMapper.readValue(result.body(), new TypeReference<>() {});
|
||||||
|
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
throw new CustomApiException(
|
||||||
|
"NOT_FOUND", HttpStatus.NOT_FOUND, "Inference response is empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
Object batchIdObj = list.get(0).get("batch_id");
|
||||||
|
if (batchIdObj == null) {
|
||||||
|
throw new CustomApiException(
|
||||||
|
"NOT_FOUND", HttpStatus.NOT_FOUND, "batch_id not found in response");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Long.valueOf(batchIdObj.toString());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Failed to parse inference response. body={}", result.body(), e);
|
||||||
|
throw new CustomApiException("INVALID_INFERENCE_RESPONSE", HttpStatus.BAD_GATEWAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
package com.kamco.cd.kamcoback.common.inference.utils;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
|
|
||||||
|
public class GeoJsonValidator {
|
||||||
|
|
||||||
|
private static final ObjectMapper om = new ObjectMapper();
|
||||||
|
private static final Logger log = LogManager.getLogger(GeoJsonValidator.class);
|
||||||
|
|
||||||
|
public static void validateWithRequested(String geojsonPath, List<String> requestedMapSheetNums) {
|
||||||
|
|
||||||
|
Path path = Path.of(geojsonPath);
|
||||||
|
|
||||||
|
// 1) 파일 기본 검증
|
||||||
|
try {
|
||||||
|
if (!Files.exists(path)) {
|
||||||
|
throw new ResponseStatusException(
|
||||||
|
HttpStatus.NOT_FOUND, "GeoJSON 파일이 존재하지 않습니다: " + geojsonPath);
|
||||||
|
}
|
||||||
|
if (Files.size(path) == 0) {
|
||||||
|
throw new ResponseStatusException(
|
||||||
|
HttpStatus.BAD_REQUEST, "GeoJSON 파일이 비어있습니다: " + geojsonPath);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("GeoJSON 파일 상태 확인 실패: path={}", path, e);
|
||||||
|
throw new ResponseStatusException(
|
||||||
|
HttpStatus.INTERNAL_SERVER_ERROR, "GeoJSON 파일 상태 확인 실패: " + geojsonPath, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestedMapSheetNums == null || requestedMapSheetNums.isEmpty()) {
|
||||||
|
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "requestedMapSheetNums 가 비어있습니다.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) 요청 도엽 Set (중복/공백 제거)
|
||||||
|
Set<String> requested =
|
||||||
|
requestedMapSheetNums.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.map(String::trim)
|
||||||
|
.filter(s -> !s.isEmpty())
|
||||||
|
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||||
|
|
||||||
|
if (requested.isEmpty()) {
|
||||||
|
throw new ResponseStatusException(
|
||||||
|
HttpStatus.BAD_REQUEST, "requestedMapSheetNums 가 공백/NULL만 포함합니다.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3) GeoJSON 파싱
|
||||||
|
final JsonNode features;
|
||||||
|
try {
|
||||||
|
JsonNode root = om.readTree(path.toFile());
|
||||||
|
features = root.get("features");
|
||||||
|
|
||||||
|
if (features == null || !features.isArray()) {
|
||||||
|
throw new ResponseStatusException(
|
||||||
|
HttpStatus.BAD_REQUEST, "유효하지 않은 GeoJSON: features가 없거나 배열이 아닙니다.");
|
||||||
|
}
|
||||||
|
} catch (ResponseStatusException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("GeoJSON 파일 읽기/파싱 실패: path={}", path, e);
|
||||||
|
throw new ResponseStatusException(
|
||||||
|
HttpStatus.INTERNAL_SERVER_ERROR, "GeoJSON 파일 읽기/파싱 실패: " + geojsonPath, e);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("GeoJSON 파싱 오류(비정상 JSON): path={}", path, e);
|
||||||
|
throw new ResponseStatusException(
|
||||||
|
HttpStatus.BAD_REQUEST, "GeoJSON 파싱 오류(비정상 JSON): " + geojsonPath, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4) 검증 로직
|
||||||
|
int featureCount = features.size();
|
||||||
|
|
||||||
|
Set<String> foundUnique = new HashSet<>();
|
||||||
|
Set<String> duplicates = new LinkedHashSet<>();
|
||||||
|
int nullIdCount = 0;
|
||||||
|
|
||||||
|
for (JsonNode feature : features) {
|
||||||
|
JsonNode props = feature.get("properties");
|
||||||
|
String sceneId =
|
||||||
|
(props != null && props.hasNonNull("scene_id")) ? props.get("scene_id").asText() : null;
|
||||||
|
|
||||||
|
if (sceneId == null || sceneId.isBlank()) {
|
||||||
|
nullIdCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!foundUnique.add(sceneId)) {
|
||||||
|
duplicates.add(sceneId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// foundUnique에 있는 것들을 missing에서 제거
|
||||||
|
Set<String> missing = new LinkedHashSet<>(requested);
|
||||||
|
missing.removeAll(foundUnique);
|
||||||
|
|
||||||
|
// requested에 있는 것들을 extra에서 제거
|
||||||
|
Set<String> extra = new LinkedHashSet<>(foundUnique);
|
||||||
|
extra.removeAll(requested);
|
||||||
|
|
||||||
|
// ================================================
|
||||||
|
// GeoJSON Validation
|
||||||
|
//
|
||||||
|
// 요청한 도엽번호(requested)와
|
||||||
|
// 실제 생성된 GeoJSON 파일의 scene_id를 비교하여
|
||||||
|
// 정합성(데이터 일치 여부)을 검증한다.
|
||||||
|
//
|
||||||
|
// 검증 항목:
|
||||||
|
// 1. features(total) : GeoJSON 전체 feature 개수 (중복 포함)
|
||||||
|
// 2. requested(unique) : 요청한 도엽번호 개수
|
||||||
|
// 3. found(unique scene_id) : GeoJSON에서 실제 발견된 유니크 도엽 개수
|
||||||
|
// 4. scene_id null/blank : scene_id가 없는 feature 개수 (데이터 이상)
|
||||||
|
// 5. duplicates(scene_id) : 동일 도엽이 중복 생성된 개수
|
||||||
|
// 6. missing(requested - found) : 요청했지만 파일에 없는 도엽 개수
|
||||||
|
// 7. extra(found - requested) : 요청하지 않았는데 파일에 포함된 도엽 개수
|
||||||
|
//
|
||||||
|
// 정상 기준:
|
||||||
|
// - missing = 0
|
||||||
|
// - extra = 0
|
||||||
|
// - duplicates = 0
|
||||||
|
// - nullId = 0
|
||||||
|
// - requested(unique) == found(unique scene_id)
|
||||||
|
//
|
||||||
|
// 위 조건을 만족하지 않으면 GeoJSON 생성 오류로 판단한다.
|
||||||
|
// ================================================
|
||||||
|
|
||||||
|
// 5) 로그
|
||||||
|
log.info(
|
||||||
|
"""
|
||||||
|
===== GeoJSON Validation =====
|
||||||
|
file: {}
|
||||||
|
features(total): {}
|
||||||
|
requested(unique): {}
|
||||||
|
found(unique scene_id): {}
|
||||||
|
scene_id null/blank: {}
|
||||||
|
duplicates(scene_id): {}
|
||||||
|
missing(requested - found): {}
|
||||||
|
extra(found - requested): {}
|
||||||
|
==============================
|
||||||
|
""",
|
||||||
|
geojsonPath,
|
||||||
|
featureCount,
|
||||||
|
requested.size(),
|
||||||
|
foundUnique.size(),
|
||||||
|
nullIdCount,
|
||||||
|
duplicates.size(),
|
||||||
|
missing.size(),
|
||||||
|
extra.size());
|
||||||
|
|
||||||
|
if (!duplicates.isEmpty())
|
||||||
|
log.warn("duplicates sample: {}", duplicates.stream().limit(20).toList());
|
||||||
|
if (!missing.isEmpty()) log.warn("missing sample: {}", missing.stream().limit(50).toList());
|
||||||
|
if (!extra.isEmpty()) log.warn("extra sample: {}", extra.stream().limit(50).toList());
|
||||||
|
|
||||||
|
// 6) 실패면 422
|
||||||
|
if (!missing.isEmpty() || !extra.isEmpty() || !duplicates.isEmpty() || nullIdCount > 0) {
|
||||||
|
throw new ResponseStatusException(
|
||||||
|
HttpStatus.UNPROCESSABLE_ENTITY,
|
||||||
|
String.format(
|
||||||
|
"GeoJSON validation failed: missing=%d, extra=%d, duplicates=%d, nullId=%d",
|
||||||
|
missing.size(), extra.size(), duplicates.size(), nullIdCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("GeoJSON validation OK");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import org.springframework.context.ApplicationEventPublisher;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
|
/** 파일 다운로드 log 저장 */
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -30,9 +31,17 @@ public class FileDownloadInteceptor implements HandlerInterceptor {
|
|||||||
if (request.getDispatcherType() != DispatcherType.REQUEST) return;
|
if (request.getDispatcherType() != DispatcherType.REQUEST) return;
|
||||||
|
|
||||||
Long userId;
|
Long userId;
|
||||||
|
String employeeNo = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// a 링크 다운로드일경우 userId가 없으므로 전달받은 사번을 넣는다
|
||||||
userId = userUtil.getId();
|
userId = userUtil.getId();
|
||||||
if (userId == null) return; // userId null 불가면 스킵
|
if (userId == null) {
|
||||||
|
employeeNo = request.getParameter("employeeNo");
|
||||||
|
if (employeeNo == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Download audit userId resolve failed. uri={}, err={}", uri, e.toString());
|
log.warn("Download audit userId resolve failed. uri={}, err={}", uri, e.toString());
|
||||||
return;
|
return;
|
||||||
@@ -48,8 +57,9 @@ public class FileDownloadInteceptor implements HandlerInterceptor {
|
|||||||
return; // downloadUuid null 불가 -> 스킵
|
return; // downloadUuid null 불가 -> 스킵
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// log저장 DownloadAuditEventListener 클래스 호출
|
||||||
publisher.publishEvent(
|
publisher.publishEvent(
|
||||||
new DownloadAuditEvent(userId, uri, normalizedUri, ip, status, downloadUuid));
|
new DownloadAuditEvent(userId, employeeNo, uri, normalizedUri, ip, status, downloadUuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
private UUID extractUuidFromUri(String uri) {
|
private UUID extractUuidFromUri(String uri) {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class SecurityConfig {
|
|||||||
|
|
||||||
// 다운로드는 인증 필요
|
// 다운로드는 인증 필요
|
||||||
.requestMatchers(HttpMethod.GET, DownloadPaths.PATTERNS)
|
.requestMatchers(HttpMethod.GET, DownloadPaths.PATTERNS)
|
||||||
.authenticated()
|
.permitAll()
|
||||||
|
|
||||||
// 메뉴 등록 ADMIN만 가능
|
// 메뉴 등록 ADMIN만 가능
|
||||||
.requestMatchers(HttpMethod.POST, "/api/menu/auth")
|
.requestMatchers(HttpMethod.POST, "/api/menu/auth")
|
||||||
@@ -105,8 +105,7 @@ public class SecurityConfig {
|
|||||||
"/api/layer/map/**",
|
"/api/layer/map/**",
|
||||||
"/api/layer/tile-url",
|
"/api/layer/tile-url",
|
||||||
"/api/layer/tile-url-year",
|
"/api/layer/tile-url-year",
|
||||||
"/api/common-code/clazz",
|
"/api/common-code/clazz")
|
||||||
"/api/inference/download/**")
|
|
||||||
.permitAll()
|
.permitAll()
|
||||||
// 로그인한 사용자만 가능 IAM
|
// 로그인한 사용자만 가능 IAM
|
||||||
.requestMatchers(
|
.requestMatchers(
|
||||||
|
|||||||
@@ -173,8 +173,9 @@ public class ApiResponseDto<T> {
|
|||||||
+ "To reset your password again, please submit a new request through \"Forgot"
|
+ "To reset your password again, please submit a new request through \"Forgot"
|
||||||
+ " Password.\""),
|
+ " Password.\""),
|
||||||
PAYLOAD_TOO_LARGE("업로드 용량 제한을 초과했습니다."),
|
PAYLOAD_TOO_LARGE("업로드 용량 제한을 초과했습니다."),
|
||||||
NOT_FOUND_TARGET_YEAR("기준년도 도엽을 찾을 수 없습니다."),
|
NOT_FOUND_TARGET_YEAR("기준연도 도엽을 찾을 수 없습니다."),
|
||||||
NOT_FOUND_COMPARE_YEAR("비교년도 도엽을 찾을 수 없습니다."),
|
NOT_FOUND_COMPARE_YEAR("비교연도 도엽을 찾을 수 없습니다."),
|
||||||
|
NOT_FOUND_MAP_SHEET_NUM("추론 가능한 도엽이 없습니다."),
|
||||||
FAIL_SAVE_MAP_SHEET("도엽 저장 중 오류가 발생했습니다."),
|
FAIL_SAVE_MAP_SHEET("도엽 저장 중 오류가 발생했습니다."),
|
||||||
FAIL_CREATE_MAP_SHEET_FILE("도엽 설정파일 생성 중 오류가 발생했습니다."),
|
FAIL_CREATE_MAP_SHEET_FILE("도엽 설정파일 생성 중 오류가 발생했습니다."),
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.kamco.cd.kamcoback.inference.service;
|
package com.kamco.cd.kamcoback.inference;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@@ -18,7 +18,6 @@ import com.kamco.cd.kamcoback.model.dto.ModelMngDto;
|
|||||||
import com.kamco.cd.kamcoback.model.service.ModelMngService;
|
import com.kamco.cd.kamcoback.model.service.ModelMngService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
||||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||||
import io.swagger.v3.oas.annotations.media.Content;
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
@@ -58,7 +57,8 @@ public class InferenceResultApiController {
|
|||||||
private final ModelMngService modelMngService;
|
private final ModelMngService modelMngService;
|
||||||
private final RangeDownloadResponder rangeDownloadResponder;
|
private final RangeDownloadResponder rangeDownloadResponder;
|
||||||
|
|
||||||
@Operation(summary = "추론관리 목록", description = "어드민 홈 > 추론관리 > 추론관리 > 추론관리 목록")
|
/** 추론관리 목록 화면에서 호출 */
|
||||||
|
@Operation(summary = "추론관리 목록", description = "추론관리 > 추론관리 목록 ")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
@@ -90,7 +90,8 @@ public class InferenceResultApiController {
|
|||||||
return ApiResponseDto.ok(analResList);
|
return ApiResponseDto.ok(analResList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "추론 진행 여부 확인", description = "어드민 홈 > 추론관리 > 추론관리 > 추론관리 목록")
|
/** 추론관리 목록 화면에서 호출 */
|
||||||
|
@Operation(summary = "추론 진행 여부 확인", description = "추론관리 > 추론관리 목록")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
@@ -112,7 +113,8 @@ public class InferenceResultApiController {
|
|||||||
return ApiResponseDto.ok(inferenceResultService.getProcessing());
|
return ApiResponseDto.ok(inferenceResultService.getProcessing());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "년도 목록 조회", description = "어드민 홈 > 추론관리 > 추론목록 > 변화탐지 실행 정보 입력 > 년도 목록 조회")
|
/** 추론관리 목록 화면에서 호출 */
|
||||||
|
@Operation(summary = "년도 목록 조회", description = "추론관리 > 추론목록 > 변화탐지 실행 정보 입력 > 년도 목록 조회")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
@@ -130,7 +132,8 @@ public class InferenceResultApiController {
|
|||||||
return ApiResponseDto.ok(mapSheetMngService.findMapSheetMngDoneYyyyList());
|
return ApiResponseDto.ok(mapSheetMngService.findMapSheetMngDoneYyyyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "변화탐지 실행 정보 입력", description = "어드민 홈 > 추론관리 > 추론목록 > 변화탐지 실행 정보 입력")
|
/** 변화탐지 실행 정보 입력화면에서 호출 */
|
||||||
|
@Operation(summary = "변화탐지 실행 정보 입력, 추론실행", description = "추론관리 > 추론목록 > 변화탐지 실행 정보 입력")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
@@ -155,7 +158,8 @@ public class InferenceResultApiController {
|
|||||||
return ApiResponseDto.ok(uuid);
|
return ApiResponseDto.ok(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "추론 종료", description = "추론 종료")
|
/** 추론진행 현황 화면에서 호출 */
|
||||||
|
@Operation(summary = "추론 종료", description = "추론관리 > 추론목록 > 추론진행 현황")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
@@ -174,7 +178,8 @@ public class InferenceResultApiController {
|
|||||||
return ApiResponseDto.ok(uuid);
|
return ApiResponseDto.ok(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "분석 모델 선택 조회", description = "변화탐지 실행 정보 입력 모델선택 팝업 ")
|
/** 변화탐지 실행 정보 입력화면에서 호출 */
|
||||||
|
@Operation(summary = "분석 모델 선택 조회", description = "추론관리 > 추론목록 > 변화탐지 실행 정보 입력 > 모델선택 팝업 ")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
@@ -205,7 +210,8 @@ public class InferenceResultApiController {
|
|||||||
return ApiResponseDto.ok(result);
|
return ApiResponseDto.ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "추론관리 추론진행 서버 현황", description = "추론관리 추론진행 서버 현황")
|
/** 추론진행 현황 화면에서 호출 */
|
||||||
|
@Operation(summary = "추론관리 추론진행 서버 현황", description = "추론관리 > 추론목록 > 추론진행 현황")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
@@ -224,7 +230,8 @@ public class InferenceResultApiController {
|
|||||||
return ApiResponseDto.ok(inferenceResultService.getInferenceServerStatusList());
|
return ApiResponseDto.ok(inferenceResultService.getInferenceServerStatusList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "추론관리 진행현황 상세", description = "어드민 홈 > 추론관리 > 추론관리 > 진행현황 상세")
|
/** 추론진행 현황 화면에서 호출 */
|
||||||
|
@Operation(summary = "추론관리 진행현황 상세", description = "추론관리 > 추론진행 현황")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
@@ -248,7 +255,8 @@ public class InferenceResultApiController {
|
|||||||
return ApiResponseDto.ok(inferenceResultService.getInferenceStatus(uuid));
|
return ApiResponseDto.ok(inferenceResultService.getInferenceStatus(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "추론결과 기본정보", description = "추론결과 기본정보")
|
/** 추론결과 화면에서 호출 */
|
||||||
|
@Operation(summary = "추론결과 기본정보", description = "추론관리 > 추론결과")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
@@ -269,7 +277,8 @@ public class InferenceResultApiController {
|
|||||||
return ApiResponseDto.ok(inferenceResultService.getInferenceResultInfo(uuid));
|
return ApiResponseDto.ok(inferenceResultService.getInferenceResultInfo(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "추론결과 분류별 탐지 건수", description = "추론결과 분류별 탐지 건수")
|
/** 추론결과 화면에서 호출 */
|
||||||
|
@Operation(summary = "추론결과 분류별 탐지 건수", description = "추론관리 > 추론결과")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
@@ -290,6 +299,7 @@ public class InferenceResultApiController {
|
|||||||
return ApiResponseDto.ok(inferenceResultService.getInferenceClassCountList(uuid));
|
return ApiResponseDto.ok(inferenceResultService.getInferenceClassCountList(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 추론결과 화면에서 호출 */
|
||||||
@Operation(summary = "추론관리 분석결과 상세 목록", description = "추론관리 분석결과 상세 목록 geojson 데이터 조회")
|
@Operation(summary = "추론관리 분석결과 상세 목록", description = "추론관리 분석결과 상세 목록 geojson 데이터 조회")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@@ -329,26 +339,13 @@ public class InferenceResultApiController {
|
|||||||
return ApiResponseDto.ok(geomList);
|
return ApiResponseDto.ok(geomList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(
|
/** 추론결과 화면에서 호출 */
|
||||||
summary = "shp 파일 다운로드",
|
@Operation(summary = "shp 파일 다운로드", description = "추론관리 분석결과 shp 파일 다운로드")
|
||||||
description = "추론관리 분석결과 shp 파일 다운로드",
|
|
||||||
parameters = {
|
|
||||||
@Parameter(
|
|
||||||
name = "kamco-download-uuid",
|
|
||||||
in = ParameterIn.HEADER,
|
|
||||||
required = true,
|
|
||||||
description = "다운로드 요청 UUID",
|
|
||||||
schema =
|
|
||||||
@Schema(
|
|
||||||
type = "string",
|
|
||||||
format = "uuid",
|
|
||||||
example = "69c4e56c-e0bf-4742-9225-bba9aae39052"))
|
|
||||||
})
|
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
responseCode = "200",
|
responseCode = "200",
|
||||||
description = "shp zip파일 다운로드",
|
description = "shp 파일 다운로드",
|
||||||
content =
|
content =
|
||||||
@Content(
|
@Content(
|
||||||
mediaType = "application/octet-stream",
|
mediaType = "application/octet-stream",
|
||||||
@@ -357,13 +354,16 @@ public class InferenceResultApiController {
|
|||||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||||
})
|
})
|
||||||
@GetMapping("/download/{uuid}")
|
@GetMapping("/download/{uuid}")
|
||||||
public ResponseEntity<?> download(@PathVariable UUID uuid, HttpServletRequest request)
|
public ResponseEntity<?> download(
|
||||||
|
@PathVariable UUID uuid,
|
||||||
|
@Parameter(description = "사번", example = "123456") @RequestParam String employeeNo,
|
||||||
|
HttpServletRequest request)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
String path;
|
String path;
|
||||||
String uid;
|
String uid;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// 추론결과 shp zip 파일 확인하여 다운로드 경로 생성
|
||||||
Map<String, Object> map = inferenceResultService.shpDownloadPath(uuid);
|
Map<String, Object> map = inferenceResultService.shpDownloadPath(uuid);
|
||||||
path = String.valueOf(map.get("path"));
|
path = String.valueOf(map.get("path"));
|
||||||
uid = String.valueOf(map.get("uid"));
|
uid = String.valueOf(map.get("uid"));
|
||||||
@@ -377,6 +377,7 @@ public class InferenceResultApiController {
|
|||||||
return rangeDownloadResponder.buildZipResponse(zipPath, uid + ".zip", request);
|
return rangeDownloadResponder.buildZipResponse(zipPath, uid + ".zip", request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 추론결과 화면에서 호출 */
|
||||||
@Operation(summary = "shp 파일 다운로드 이력 조회", description = "추론관리 분석결과 shp 파일 다운로드 이력 조회")
|
@Operation(summary = "shp 파일 다운로드 이력 조회", description = "추론관리 분석결과 shp 파일 다운로드 이력 조회")
|
||||||
@GetMapping(value = "/download-audit/{uuid}")
|
@GetMapping(value = "/download-audit/{uuid}")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
@@ -419,7 +420,8 @@ public class InferenceResultApiController {
|
|||||||
return ApiResponseDto.ok(inferenceResultService.getDownloadAudit(searchReq, downloadReq));
|
return ApiResponseDto.ok(inferenceResultService.getDownloadAudit(searchReq, downloadReq));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "추론 실행중인 도엽 목록", description = "추론관리 실행중인 도엽명 5k 목록")
|
/** 추론진행 현황 화면에서 호출, 분석도엽 부분 옵션일때 분석중인 도엽 확인용 */
|
||||||
|
@Operation(summary = "추론관리 분석중인 도엽명 5k 목록", description = "추론관리 분석중인 도엽명 50k 목록")
|
||||||
@ApiResponses({
|
@ApiResponses({
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
responseCode = "200",
|
responseCode = "200",
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.kamco.cd.kamcoback.inference;
|
package com.kamco.cd.kamcoback.inference;
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
|
|
||||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.Scene;
|
|
||||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultShpDto;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultShpDto;
|
||||||
import com.kamco.cd.kamcoback.inference.service.InferenceResultShpService;
|
import com.kamco.cd.kamcoback.inference.service.InferenceResultShpService;
|
||||||
@@ -12,15 +10,11 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@@ -62,29 +56,4 @@ public class InferenceResultShpApiController {
|
|||||||
inferenceResultShpService.createShp(uuid);
|
inferenceResultShpService.createShp(uuid);
|
||||||
return ApiResponseDto.createOK(null);
|
return ApiResponseDto.createOK(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "추론실행에 필요한 geojson 파일 생성", description = "추론실행에 필요한 geojson 파일 생성")
|
|
||||||
@PostMapping("/geojson/{yyyy}/{mapSheetScope}/{detectOption}")
|
|
||||||
public ApiResponseDto<Scene> createGeojson(
|
|
||||||
@Schema(description = "년도") @PathVariable String yyyy,
|
|
||||||
@Schema(description = "전체(ALL),부분(PART)", example = "PART") @PathVariable
|
|
||||||
String mapSheetScope,
|
|
||||||
@Schema(description = "추론제외(EXCL),이전 년도 도엽 사용(PREV)", example = "EXCL") @PathVariable
|
|
||||||
String detectOption,
|
|
||||||
@Schema(description = "5k도엽번호", example = MAP_ID) @RequestBody Map<String, Object> body) {
|
|
||||||
|
|
||||||
Object raw = body.get("mapIds");
|
|
||||||
|
|
||||||
if (raw == null) {
|
|
||||||
throw new CustomApiException("BAD_REQUEST", HttpStatus.BAD_REQUEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<String> mapIds = (List<String>) raw;
|
|
||||||
|
|
||||||
Scene scene =
|
|
||||||
inferenceResultShpService.createGeojson(yyyy, mapSheetScope, detectOption, mapIds);
|
|
||||||
|
|
||||||
return ApiResponseDto.createOK(scene);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.kamco.cd.kamcoback.inference.service;
|
package com.kamco.cd.kamcoback.inference.service;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
|
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
|
||||||
|
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter;
|
||||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.ImageFeature;
|
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.ImageFeature;
|
||||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.Scene;
|
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.Scene;
|
||||||
|
import com.kamco.cd.kamcoback.common.inference.service.InferenceCommonService;
|
||||||
|
import com.kamco.cd.kamcoback.common.inference.utils.GeoJsonValidator;
|
||||||
import com.kamco.cd.kamcoback.common.utils.UserUtil;
|
import com.kamco.cd.kamcoback.common.utils.UserUtil;
|
||||||
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient;
|
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient;
|
||||||
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult;
|
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult;
|
||||||
@@ -21,8 +21,7 @@ import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.DetectOption;
|
|||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceLearnDto;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceLearnDto;
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceServerStatusDto;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceServerStatusDto;
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceStatusDetailDto;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceStatusDetailDto;
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetFallbackYearDto;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetScope;
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetNumDto;
|
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.ResultList;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.ResultList;
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.SaveInferenceAiDto;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.SaveInferenceAiDto;
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.Status;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.Status;
|
||||||
@@ -40,6 +39,8 @@ import com.kamco.cd.kamcoback.postgres.core.InferenceResultCoreService;
|
|||||||
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngCoreService;
|
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngCoreService;
|
||||||
import com.kamco.cd.kamcoback.postgres.core.ModelMngCoreService;
|
import com.kamco.cd.kamcoback.postgres.core.ModelMngCoreService;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
@@ -76,14 +77,11 @@ public class InferenceResultService {
|
|||||||
private final MapSheetMngCoreService mapSheetMngCoreService;
|
private final MapSheetMngCoreService mapSheetMngCoreService;
|
||||||
private final ModelMngCoreService modelMngCoreService;
|
private final ModelMngCoreService modelMngCoreService;
|
||||||
private final AuditLogCoreService auditLogCoreService;
|
private final AuditLogCoreService auditLogCoreService;
|
||||||
|
private final InferenceCommonService inferenceCommonService;
|
||||||
|
|
||||||
private final ExternalHttpClient externalHttpClient;
|
private final ExternalHttpClient externalHttpClient;
|
||||||
private final ObjectMapper objectMapper;
|
|
||||||
private final UserUtil userUtil;
|
private final UserUtil userUtil;
|
||||||
|
|
||||||
@Value("${inference.url}")
|
|
||||||
private String inferenceUrl;
|
|
||||||
|
|
||||||
@Value("${inference.batch-url}")
|
@Value("${inference.batch-url}")
|
||||||
private String batchUrl;
|
private String batchUrl;
|
||||||
|
|
||||||
@@ -94,7 +92,10 @@ public class InferenceResultService {
|
|||||||
private String datasetDir;
|
private String datasetDir;
|
||||||
|
|
||||||
@Value("${spring.profiles.active}")
|
@Value("${spring.profiles.active}")
|
||||||
private String profile;
|
private String activeEnv;
|
||||||
|
|
||||||
|
@Value("${inference.geojson-dir}")
|
||||||
|
private String inferenceDir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 추론관리 목록
|
* 추론관리 목록
|
||||||
@@ -107,7 +108,7 @@ public class InferenceResultService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 추론 진행중인지 확인
|
* 추론 진행중인지 확인, 변화탐지 설정 등록 버튼 활성화 여부에 필요함
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -120,7 +121,7 @@ public class InferenceResultService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 추론 실행 - 추론제외, 이전년도 도엽 사용 분기
|
* 추론 실행 - 추론제외, 이전연도 도엽 사용 분기
|
||||||
*
|
*
|
||||||
* @param req
|
* @param req
|
||||||
* @return
|
* @return
|
||||||
@@ -128,8 +129,11 @@ public class InferenceResultService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public UUID run(InferenceResultDto.RegReq req) {
|
public UUID run(InferenceResultDto.RegReq req) {
|
||||||
if (req.getDetectOption().equals(DetectOption.EXCL.getId())) {
|
if (req.getDetectOption().equals(DetectOption.EXCL.getId())) {
|
||||||
|
// 추론 제외 일때 EXCL
|
||||||
return runExcl(req);
|
return runExcl(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 이전연도 도엽 사용 일때 PREV
|
||||||
return runPrev(req);
|
return runPrev(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,38 +144,70 @@ public class InferenceResultService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public UUID runExcl(InferenceResultDto.RegReq req) {
|
public UUID runExcl(InferenceResultDto.RegReq req) {
|
||||||
// target 도엽 조회
|
// 기준연도 실행가능 도엽 조회
|
||||||
List<MngListDto> targetDtoList = mapSheetMngCoreService.getHstMapSheetList(req);
|
List<MngListDto> mngList =
|
||||||
|
mapSheetMngCoreService.findExecutableSheets(
|
||||||
|
req.getCompareYyyy(),
|
||||||
|
req.getTargetYyyy(),
|
||||||
|
req.getMapSheetScope(),
|
||||||
|
req.getMapSheetNum());
|
||||||
|
|
||||||
// target 리스트 추출 (null 제거 + 중복 제거)
|
if (mngList == null || mngList.isEmpty()) {
|
||||||
List<String> targetList =
|
throw new CustomApiException("NOT_FOUND_MAP_SHEET_NUM", HttpStatus.NOT_FOUND);
|
||||||
targetDtoList.stream()
|
}
|
||||||
|
|
||||||
|
// 비교 연도 도엽번호를 꺼내와서 최종 추론 대상 도엽번호를 담기
|
||||||
|
List<String> mapSheetNums =
|
||||||
|
mngList.stream()
|
||||||
.map(MngListDto::getMapSheetNum)
|
.map(MngListDto::getMapSheetNum)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.distinct()
|
.distinct()
|
||||||
.toList();
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// compare 도엽번호 리스트 조회 (null 제거 + 중복 제거)
|
// 기준연도 추론 실행가능 도엽 count
|
||||||
List<String> compareList =
|
int targetTotal =
|
||||||
mapSheetMngCoreService.getMapSheetNumByHst(req.getCompareYyyy()).stream()
|
mapSheetMngCoreService.countExecutableSheetsDistinct(
|
||||||
.filter(Objects::nonNull)
|
req.getTargetYyyy(), req.getMapSheetScope(), mapSheetNums);
|
||||||
.distinct()
|
// 비교연도 추론 실행가능 도엽 count
|
||||||
.toList();
|
int compareTotal =
|
||||||
|
mapSheetMngCoreService.countExecutableSheetsDistinct(
|
||||||
|
req.getCompareYyyy(), req.getMapSheetScope(), mapSheetNums);
|
||||||
|
int intersection = mapSheetNums.size();
|
||||||
|
|
||||||
// compare 기준
|
// ===== MapSheet Year Comparison =====
|
||||||
Set<String> compareSet = new HashSet<>(compareList);
|
// target Total : 기준연도 실행가능 전체 도엽 수
|
||||||
|
// compare Total : 비교연도 실행가능 전체 도엽 수
|
||||||
|
// Intersection : 양 연도에 모두 존재하는 도엽 수 (최종 추론 대상)
|
||||||
|
// target Only (Excluded) : 기준연도에만 존재하고 비교연도에는 없는 도엽 수
|
||||||
|
// compare Only : 비교연도에만 존재하고 기준연도에는 없는 도엽 수
|
||||||
|
// ====================================
|
||||||
|
|
||||||
// target 기준으로 compare에 존재하는 도엽만 필터링
|
log.info(
|
||||||
List<String> filteredTargetList = targetList.stream().filter(compareSet::contains).toList();
|
"""
|
||||||
|
===== MapSheet Year Comparison =====
|
||||||
|
target Total: {}
|
||||||
|
compare Total: {}
|
||||||
|
Intersection: {}
|
||||||
|
target Only (Excluded): {}
|
||||||
|
compare Only: {}
|
||||||
|
====================================
|
||||||
|
""",
|
||||||
|
targetTotal,
|
||||||
|
compareTotal,
|
||||||
|
intersection,
|
||||||
|
targetTotal - intersection,
|
||||||
|
compareTotal - intersection);
|
||||||
|
|
||||||
// 도엽 비교 로그 출력
|
if (mapSheetNums.isEmpty()) {
|
||||||
logYearComparison(targetList, compareList, filteredTargetList);
|
// 추론 가능한 도엽이 없습니다.
|
||||||
|
throw new CustomApiException("NOT_FOUND_MAP_SHEET_NUM", HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
// compare geojson 파일 생성
|
// compare geojson 파일 생성
|
||||||
Scene compareScene =
|
Scene compareScene =
|
||||||
getSceneInference(
|
getSceneInference(
|
||||||
req.getCompareYyyy().toString(), // 기준년도
|
req.getCompareYyyy().toString(), // 기준년도
|
||||||
filteredTargetList, // 교집합 도엽
|
mapSheetNums, // 최종 추론 대상
|
||||||
req.getMapSheetScope(), // ALL / 부분
|
req.getMapSheetScope(), // ALL / 부분
|
||||||
req.getDetectOption()); // EXCL / PREV
|
req.getDetectOption()); // EXCL / PREV
|
||||||
|
|
||||||
@@ -179,15 +215,20 @@ public class InferenceResultService {
|
|||||||
Scene targetScene =
|
Scene targetScene =
|
||||||
getSceneInference(
|
getSceneInference(
|
||||||
req.getTargetYyyy().toString(), // 대상년도
|
req.getTargetYyyy().toString(), // 대상년도
|
||||||
filteredTargetList, // 교집합 도엽
|
mapSheetNums, // 최종 추론 대상
|
||||||
req.getMapSheetScope(),
|
req.getMapSheetScope(),
|
||||||
req.getDetectOption());
|
req.getDetectOption());
|
||||||
|
|
||||||
|
log.info("비교년도 geojson 파일 validation ===== {}", compareScene.getFilePath());
|
||||||
|
GeoJsonValidator.validateWithRequested(compareScene.getFilePath(), mapSheetNums);
|
||||||
|
log.info("기준년도 geojson 파일 validation ===== {}", targetScene.getFilePath());
|
||||||
|
GeoJsonValidator.validateWithRequested(targetScene.getFilePath(), mapSheetNums);
|
||||||
|
|
||||||
// 추론 실행
|
// 추론 실행
|
||||||
return executeInference(
|
return executeInference(
|
||||||
req,
|
req,
|
||||||
targetDtoList, // 전체 target 목록
|
mngList, // 전체 target 목록
|
||||||
filteredTargetList, // 최종 추론 대상
|
mapSheetNums, // 최종 추론 대상
|
||||||
compareScene, // compare geojson
|
compareScene, // compare geojson
|
||||||
targetScene // target geojson
|
targetScene // target geojson
|
||||||
);
|
);
|
||||||
@@ -201,91 +242,102 @@ public class InferenceResultService {
|
|||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public UUID runPrev(InferenceResultDto.RegReq req) {
|
public UUID runPrev(InferenceResultDto.RegReq req) {
|
||||||
// target 목록 조회
|
|
||||||
List<MngListDto> targetDtoList = mapSheetMngCoreService.getHstMapSheetList(req);
|
|
||||||
|
|
||||||
// target 도엽번호 리스트 추출 중복 제거
|
// 기준연도 실행가능 도엽 조회
|
||||||
List<String> targetList =
|
List<MngListDto> targetMngList =
|
||||||
targetDtoList.stream()
|
mapSheetMngCoreService.getMapSheetMngHst(
|
||||||
|
req.getTargetYyyy(), req.getMapSheetScope(), req.getMapSheetNum());
|
||||||
|
|
||||||
|
if (targetMngList == null || targetMngList.isEmpty()) {
|
||||||
|
throw new CustomApiException("NOT_FOUND_TARGET_YEAR", HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 비교연도 실행가능 도엽 조회
|
||||||
|
List<MngListDto> compareMngList =
|
||||||
|
mapSheetMngCoreService.getMapSheetMngHst(
|
||||||
|
req.getCompareYyyy(), req.getMapSheetScope(), req.getMapSheetNum());
|
||||||
|
|
||||||
|
if (compareMngList == null || compareMngList.isEmpty()) {
|
||||||
|
throw new CustomApiException("NOT_FOUND_COMPARE_YEAR", HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("Difference in count = {}", targetMngList.size() - compareMngList.size());
|
||||||
|
|
||||||
|
// 로그용 원본 카운트 (fallback 추가 전)
|
||||||
|
int targetTotal = targetMngList.size();
|
||||||
|
int compareTotalBeforeFallback = compareMngList.size();
|
||||||
|
|
||||||
|
// target - compare 구해서 이전년도로 compare 보완
|
||||||
|
List<String> compareNums0 =
|
||||||
|
compareMngList.stream().map(MngListDto::getMapSheetNum).filter(Objects::nonNull).toList();
|
||||||
|
|
||||||
|
// 기준연도에 없는 도엽을 비교년도 이전 도엽에서 찾아서 추가하기
|
||||||
|
List<String> targetOnlyMapSheetNums =
|
||||||
|
targetMngList.stream()
|
||||||
.map(MngListDto::getMapSheetNum)
|
.map(MngListDto::getMapSheetNum)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.distinct()
|
.filter(num -> !compareNums0.contains(num))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
// compare 목록 조회
|
// 이전년도(fallback) 추가
|
||||||
List<MapSheetFallbackYearDto> compareDtoList =
|
compareMngList.addAll(
|
||||||
new ArrayList<>(mapSheetMngCoreService.getMapSheetNumDtoByHst(req.getCompareYyyy()));
|
|
||||||
|
|
||||||
// compare 도엽번호 Set 구성
|
|
||||||
Set<String> compareSet =
|
|
||||||
compareDtoList.stream()
|
|
||||||
.map(MapSheetFallbackYearDto::getMapSheetNum)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
|
|
||||||
// target에는 있으나 compare에는 없는 도엽 추출
|
|
||||||
List<String> remainingTargetList =
|
|
||||||
targetList.stream().filter(s -> !compareSet.contains(s)).toList();
|
|
||||||
|
|
||||||
// compare에 없을때 이전 년도 사용 가능여부 조회
|
|
||||||
List<MapSheetFallbackYearDto> fallbackYearDtoList =
|
|
||||||
mapSheetMngCoreService.findFallbackCompareYearByMapSheets(
|
mapSheetMngCoreService.findFallbackCompareYearByMapSheets(
|
||||||
req.getTargetYyyy(), // 대상년도 기준
|
req.getCompareYyyy(), targetOnlyMapSheetNums));
|
||||||
remainingTargetList // compare에 없는 도엽들
|
|
||||||
);
|
|
||||||
|
|
||||||
// 기존 compare , 사용가능 이전년도 정보 합치기
|
// 이전연도 추가 후 compare 총 개수
|
||||||
compareDtoList.addAll(fallbackYearDtoList);
|
int compareTotalAfterFallback = compareMngList.size();
|
||||||
|
|
||||||
// 중복제거하여 사용할 compare 도엽 목록
|
// 교집합 도엽번호(mapSheetNums) 교집합 생성
|
||||||
Set<String> availableCompareSheets =
|
List<String> compareNums1 =
|
||||||
compareDtoList.stream()
|
compareMngList.stream().map(MngListDto::getMapSheetNum).filter(Objects::nonNull).toList();
|
||||||
.map(MapSheetFallbackYearDto::getMapSheetNum)
|
|
||||||
|
// 기준연도 교집합
|
||||||
|
List<String> mapSheetNums =
|
||||||
|
targetMngList.stream()
|
||||||
|
.map(MngListDto::getMapSheetNum)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toSet());
|
.filter(compareNums1::contains)
|
||||||
|
|
||||||
// 최종 추론 대상 도엽
|
|
||||||
// target 기준으로 compare 에 존재하는 도엽만 추출
|
|
||||||
List<String> filteredTargetList =
|
|
||||||
targetList.stream().filter(availableCompareSheets::contains).toList();
|
|
||||||
|
|
||||||
// compareDtoList도 최종 기준으로 필터
|
|
||||||
Set<String> filteredTargetSet = new HashSet<>(filteredTargetList);
|
|
||||||
|
|
||||||
List<MapSheetFallbackYearDto> filteredCompareDtoList =
|
|
||||||
compareDtoList.stream()
|
|
||||||
.filter(d -> d.getMapSheetNum() != null)
|
|
||||||
.filter(d -> filteredTargetSet.contains(d.getMapSheetNum()))
|
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
// compare only 계산 (target에는 없는 compare 도엽 수) log 용
|
int intersection = mapSheetNums.size();
|
||||||
long compareOnlyCount =
|
|
||||||
compareDtoList.stream()
|
// 서로 같은 것만 남기기: compare 모두 교집합
|
||||||
.map(MapSheetFallbackYearDto::getMapSheetNum)
|
compareMngList =
|
||||||
.filter(s -> s != null && !targetList.contains(s))
|
compareMngList.stream()
|
||||||
.count();
|
.filter(c -> c.getMapSheetNum() != null)
|
||||||
|
.filter(c -> mapSheetNums.contains(c.getMapSheetNum()))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// 로그
|
||||||
|
int targetOnlyExcluded = targetTotal - intersection;
|
||||||
|
int compareOnly = compareTotalAfterFallback - intersection;
|
||||||
|
|
||||||
// 연도별 도엽 비교 로그 출력
|
|
||||||
log.info(
|
log.info(
|
||||||
"""
|
"""
|
||||||
===== MapSheet Year Comparison =====
|
===== MapSheet Year Comparison =====
|
||||||
target Total: {}
|
target Total: {}
|
||||||
compare Total: {}
|
compare Total(before fallback): {}
|
||||||
|
compare Total(after fallback): {}
|
||||||
Intersection: {}
|
Intersection: {}
|
||||||
target Only (Excluded): {}
|
target Only (Excluded): {}
|
||||||
compare Only: {}
|
compare Only: {}
|
||||||
====================================
|
====================================
|
||||||
""",
|
""",
|
||||||
targetList.size(), // target count
|
targetTotal,
|
||||||
compareDtoList.size(), // compare count
|
compareTotalBeforeFallback,
|
||||||
filteredTargetList.size(), // target 기준으로 compare 비교하여 최종 추론할 도엽 count
|
compareTotalAfterFallback,
|
||||||
targetList.size() - filteredTargetList.size(), // compare에 존재하지 않는 target 도엽 수
|
intersection,
|
||||||
compareOnlyCount); // target 에 존재하지 않는 compare 도엽수
|
targetOnlyExcluded,
|
||||||
|
compareOnly);
|
||||||
|
|
||||||
// compare 기준 geojson 생성 (년도 fallback 반영)
|
if (mapSheetNums.isEmpty()) {
|
||||||
|
throw new CustomApiException("NOT_FOUND_MAP_SHEET_NUM", HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
// compare 기준 geojson 생성
|
||||||
Scene compareScene =
|
Scene compareScene =
|
||||||
getSceneInference(
|
getSceneInference(
|
||||||
filteredCompareDtoList,
|
compareMngList,
|
||||||
req.getCompareYyyy().toString(),
|
req.getCompareYyyy().toString(),
|
||||||
req.getMapSheetScope(),
|
req.getMapSheetScope(),
|
||||||
req.getDetectOption());
|
req.getDetectOption());
|
||||||
@@ -294,12 +346,18 @@ public class InferenceResultService {
|
|||||||
Scene targetScene =
|
Scene targetScene =
|
||||||
getSceneInference(
|
getSceneInference(
|
||||||
req.getTargetYyyy().toString(),
|
req.getTargetYyyy().toString(),
|
||||||
filteredTargetList,
|
mapSheetNums,
|
||||||
req.getMapSheetScope(),
|
req.getMapSheetScope(),
|
||||||
req.getDetectOption());
|
req.getDetectOption());
|
||||||
|
|
||||||
// AI 추론 실행
|
log.info("비교년도 geojson 파일 validation ===== {}", compareScene.getFilePath());
|
||||||
return executeInference(req, targetDtoList, filteredTargetList, compareScene, targetScene);
|
GeoJsonValidator.validateWithRequested(compareScene.getFilePath(), mapSheetNums);
|
||||||
|
|
||||||
|
log.info("기준년도 geojson 파일 validation ===== {}", targetScene.getFilePath());
|
||||||
|
GeoJsonValidator.validateWithRequested(targetScene.getFilePath(), mapSheetNums);
|
||||||
|
|
||||||
|
// 추론 실행
|
||||||
|
return executeInference(req, targetMngList, mapSheetNums, compareScene, targetScene);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -326,20 +384,24 @@ public class InferenceResultService {
|
|||||||
.filter(m -> filteredSet.contains(m.getMapSheetNum()))
|
.filter(m -> filteredSet.contains(m.getMapSheetNum()))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
|
// 추론 실행 목록 테이블 저장, 도엽목록별 상태 체크 테이블 저장
|
||||||
UUID uuid = inferenceResultCoreService.saveInferenceInfo(req, newTargetList);
|
UUID uuid = inferenceResultCoreService.saveInferenceInfo(req, newTargetList);
|
||||||
|
|
||||||
|
// 추론 AI 전달 파라미터 생성
|
||||||
pred_requests_areas predRequestsAreas = new pred_requests_areas();
|
pred_requests_areas predRequestsAreas = new pred_requests_areas();
|
||||||
predRequestsAreas.setInput1_year(req.getCompareYyyy());
|
predRequestsAreas.setInput1_year(req.getCompareYyyy());
|
||||||
predRequestsAreas.setInput2_year(req.getTargetYyyy());
|
predRequestsAreas.setInput2_year(req.getTargetYyyy());
|
||||||
predRequestsAreas.setInput1_scene_path(modelComparePath.getFilePath());
|
predRequestsAreas.setInput1_scene_path(modelComparePath.getFilePath());
|
||||||
predRequestsAreas.setInput2_scene_path(modelTargetPath.getFilePath());
|
predRequestsAreas.setInput2_scene_path(modelTargetPath.getFilePath());
|
||||||
|
|
||||||
|
// 모델정보 조회 dto 생성 후 반환
|
||||||
InferenceSendDto m1 = this.getModelInfo(req.getModel1Uuid());
|
InferenceSendDto m1 = this.getModelInfo(req.getModel1Uuid());
|
||||||
m1.setPred_requests_areas(predRequestsAreas);
|
m1.setPred_requests_areas(predRequestsAreas);
|
||||||
|
|
||||||
log.info("[INFERENCE] Start m1 = {}", m1);
|
log.info("[INFERENCE] Start m1 = {}", m1);
|
||||||
|
|
||||||
Long batchId = ensureAccepted(m1);
|
// AI 호출
|
||||||
|
Long batchId = inferenceCommonService.ensureAccepted(m1);
|
||||||
|
|
||||||
SaveInferenceAiDto saveInferenceAiDto = new SaveInferenceAiDto();
|
SaveInferenceAiDto saveInferenceAiDto = new SaveInferenceAiDto();
|
||||||
saveInferenceAiDto.setUuid(uuid);
|
saveInferenceAiDto.setUuid(uuid);
|
||||||
@@ -351,43 +413,14 @@ public class InferenceResultService {
|
|||||||
saveInferenceAiDto.setModelTargetPath(modelTargetPath.getFilePath());
|
saveInferenceAiDto.setModelTargetPath(modelTargetPath.getFilePath());
|
||||||
saveInferenceAiDto.setModelStartDttm(ZonedDateTime.now());
|
saveInferenceAiDto.setModelStartDttm(ZonedDateTime.now());
|
||||||
|
|
||||||
|
// AI 호출 하고 리턴 받은 정보 추론 실행 목록 테이블에 업데이트
|
||||||
inferenceResultCoreService.update(saveInferenceAiDto);
|
inferenceResultCoreService.update(saveInferenceAiDto);
|
||||||
|
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EXCL 로그
|
* 변화탐지 실행 정보 생성 TODO 미사용, 새로운 추론실행 로직 테스트후 삭제 해야합니다.
|
||||||
*
|
|
||||||
* @param targetList
|
|
||||||
* @param compareList
|
|
||||||
* @param filteredTargetList
|
|
||||||
*/
|
|
||||||
private void logYearComparison(
|
|
||||||
List<String> targetList, List<String> compareList, List<String> filteredTargetList) {
|
|
||||||
Set<String> targetSet = new HashSet<>(targetList);
|
|
||||||
|
|
||||||
long compareOnlyCount = compareList.stream().filter(s -> !targetSet.contains(s)).count();
|
|
||||||
|
|
||||||
log.info(
|
|
||||||
"""
|
|
||||||
===== MapSheet Year Comparison =====
|
|
||||||
target Total: {}
|
|
||||||
compare Total: {}
|
|
||||||
Intersection: {}
|
|
||||||
target Only (Excluded): {}
|
|
||||||
compare Only: {}
|
|
||||||
====================================
|
|
||||||
""",
|
|
||||||
targetList.size(), // target count
|
|
||||||
compareList.size(), // compare count
|
|
||||||
filteredTargetList.size(), // target 기준으로 compare 비교하여 최종 추론할 도엽 count
|
|
||||||
targetList.size() - filteredTargetList.size(), // compare에 존재하지 않는 target 도엽 수
|
|
||||||
compareOnlyCount); // target 에 존재하지 않는 compare 도엽수
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 변화탐지 실행 정보 생성
|
|
||||||
*
|
*
|
||||||
* @param req
|
* @param req
|
||||||
*/
|
*/
|
||||||
@@ -395,7 +428,7 @@ public class InferenceResultService {
|
|||||||
public UUID saveInferenceInfo(InferenceResultDto.RegReq req) {
|
public UUID saveInferenceInfo(InferenceResultDto.RegReq req) {
|
||||||
|
|
||||||
// 변화탐지 실행 가능 기준 년도 조회
|
// 변화탐지 실행 가능 기준 년도 조회
|
||||||
List<MngListDto> targetList = mapSheetMngCoreService.getHstMapSheetList(req);
|
List<MngListDto> targetList = null; // mapSheetMngCoreService.getHstMapSheetList(req);
|
||||||
|
|
||||||
if (targetList.isEmpty()) {
|
if (targetList.isEmpty()) {
|
||||||
throw new CustomApiException("NOT_FOUND_TARGET_YEAR", HttpStatus.NOT_FOUND);
|
throw new CustomApiException("NOT_FOUND_TARGET_YEAR", HttpStatus.NOT_FOUND);
|
||||||
@@ -513,7 +546,7 @@ public class InferenceResultService {
|
|||||||
m1.setPred_requests_areas(predRequestsAreas);
|
m1.setPred_requests_areas(predRequestsAreas);
|
||||||
|
|
||||||
// ai 추론 실행 api 호출
|
// ai 추론 실행 api 호출
|
||||||
Long batchId = ensureAccepted(m1);
|
Long batchId = inferenceCommonService.ensureAccepted(m1);
|
||||||
|
|
||||||
// ai 추론 실행후 응답값 update
|
// ai 추론 실행후 응답값 update
|
||||||
SaveInferenceAiDto saveInferenceAiDto = new SaveInferenceAiDto();
|
SaveInferenceAiDto saveInferenceAiDto = new SaveInferenceAiDto();
|
||||||
@@ -530,145 +563,6 @@ public class InferenceResultService {
|
|||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 비교년도 탐지 제이터 옵션 별로 조회하여 req에 적용
|
|
||||||
private List<MapSheetNumDto> createdMngDto(
|
|
||||||
InferenceResultDto.RegReq req, List<MngListDto> targetList) {
|
|
||||||
List<String> mapTargetIds = new ArrayList<>();
|
|
||||||
|
|
||||||
targetList.forEach(
|
|
||||||
hstMapSheet -> {
|
|
||||||
// 비교년도는 target 년도 기준으로 가져옴 파라미터 만들기
|
|
||||||
mapTargetIds.add(hstMapSheet.getMapSheetNum());
|
|
||||||
});
|
|
||||||
|
|
||||||
// 비교년도 조회
|
|
||||||
List<String> mapCompareIds = new ArrayList<>();
|
|
||||||
List<MngListCompareDto> compareList =
|
|
||||||
mapSheetMngCoreService.getByHstMapSheetCompareList(req.getCompareYyyy(), mapTargetIds);
|
|
||||||
|
|
||||||
for (MngListCompareDto dto : compareList) {
|
|
||||||
// 추론 제외일때 이전년도 파일이 없으면 제외
|
|
||||||
if (req.getDetectOption().equals(DetectOption.EXCL.getId())) {
|
|
||||||
int targetYear = req.getTargetYyyy() - 1;
|
|
||||||
if (dto.getBeforeYear() != targetYear) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 비교년도는 target 년도 기준으로 가져옴
|
|
||||||
mapCompareIds.add(dto.getMapSheetNum());
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<String> compareSet =
|
|
||||||
mapCompareIds.stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.map(String::trim) // 공백/개행 방지
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
|
|
||||||
// target 기준 compare 비교하여 서로 있는것만 저장
|
|
||||||
List<String> commonIds =
|
|
||||||
mapTargetIds.stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.map(String::trim)
|
|
||||||
.filter(compareSet::contains)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
Set<String> commonIdSet =
|
|
||||||
commonIds.stream().filter(Objects::nonNull).map(String::trim).collect(Collectors.toSet());
|
|
||||||
|
|
||||||
// 저장하기위해 파라미터 다시 구성
|
|
||||||
List<MapSheetNumDto> mapSheetNum =
|
|
||||||
targetList.stream()
|
|
||||||
.filter(dto -> dto.getMapSheetNum() != null)
|
|
||||||
.filter(dto -> commonIdSet.contains(dto.getMapSheetNum().trim()))
|
|
||||||
.map(
|
|
||||||
dto -> {
|
|
||||||
MapSheetNumDto mapSheetNumDto = new MapSheetNumDto();
|
|
||||||
mapSheetNumDto.setMapSheetNum(dto.getMapSheetNum());
|
|
||||||
mapSheetNumDto.setMapSheetName(dto.getMapSheetName());
|
|
||||||
return mapSheetNumDto;
|
|
||||||
})
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
return mapSheetNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 추론 AI API 호출 batch id를 리턴
|
|
||||||
*
|
|
||||||
* @param dto
|
|
||||||
*/
|
|
||||||
// 같은함수가 왜 두개지
|
|
||||||
private Long ensureAccepted(InferenceSendDto dto) {
|
|
||||||
|
|
||||||
if (dto == null) {
|
|
||||||
log.warn("not InferenceSendDto dto");
|
|
||||||
throw new CustomApiException("BAD_REQUEST", HttpStatus.BAD_REQUEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
// [중복]운영환경일때 경로수정 dean 260226
|
|
||||||
if (profile != null && profile.equals("prod")) {
|
|
||||||
log.info("========================================================");
|
|
||||||
log.info("[CHANGE INFERENCE] profile = {} Inforence req", profile);
|
|
||||||
log.info("========================================================");
|
|
||||||
log.info("");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1) 요청 로그
|
|
||||||
try {
|
|
||||||
log.debug("Inference request dto={}", objectMapper.writeValueAsString(dto));
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
log.warn("Failed to serialize inference dto", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2) local 환경 임시 처리
|
|
||||||
// if ("local".equals(profile)) {
|
|
||||||
// if (dto.getPred_requests_areas() == null) {
|
|
||||||
// throw new IllegalStateException("pred_requests_areas is null");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// 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");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 3) HTTP 호출
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
headers.setAccept(List.of(MediaType.APPLICATION_JSON));
|
|
||||||
|
|
||||||
// 추론 실행 API 호출
|
|
||||||
ExternalCallResult<String> result =
|
|
||||||
externalHttpClient.call(inferenceUrl, HttpMethod.POST, dto, headers, String.class);
|
|
||||||
|
|
||||||
if (result.statusCode() < 200 || result.statusCode() >= 300) {
|
|
||||||
log.error("Inference API failed. status={}, body={}", result.statusCode(), result.body());
|
|
||||||
throw new CustomApiException("BAD_GATEWAY", HttpStatus.BAD_GATEWAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4) 응답 파싱
|
|
||||||
try {
|
|
||||||
List<Map<String, Object>> list =
|
|
||||||
objectMapper.readValue(result.body(), new TypeReference<>() {});
|
|
||||||
|
|
||||||
if (list.isEmpty()) {
|
|
||||||
throw new CustomApiException(
|
|
||||||
"NOT_FOUND", HttpStatus.NOT_FOUND, "Inference response is empty");
|
|
||||||
}
|
|
||||||
|
|
||||||
Object batchIdObj = list.get(0).get("batch_id");
|
|
||||||
if (batchIdObj == null) {
|
|
||||||
throw new CustomApiException(
|
|
||||||
"NOT_FOUND", HttpStatus.NOT_FOUND, "batch_id not found in response");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Long.valueOf(batchIdObj.toString());
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Failed to parse inference response. body={}", result.body(), e);
|
|
||||||
throw new CustomApiException("INVALID_INFERENCE_RESPONSE", HttpStatus.BAD_GATEWAY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 모델정보 조회 dto 생성 후 반환
|
* 모델정보 조회 dto 생성 후 반환
|
||||||
*
|
*
|
||||||
@@ -731,25 +625,36 @@ public class InferenceResultService {
|
|||||||
*/
|
*/
|
||||||
private Scene getSceneInference(
|
private Scene getSceneInference(
|
||||||
String yyyy, List<String> mapSheetNums, String mapSheetScope, String detectOption) {
|
String yyyy, List<String> mapSheetNums, String mapSheetScope, String detectOption) {
|
||||||
return mapSheetMngCoreService.getSceneInference(
|
|
||||||
yyyy, mapSheetNums, mapSheetScope, detectOption);
|
// geojson 생성시 필요한 영상파일 정보 조회
|
||||||
|
List<ImageFeature> features =
|
||||||
|
mapSheetMngCoreService.loadSceneInferenceBySheets(yyyy, mapSheetNums);
|
||||||
|
|
||||||
|
if (features == null || features.isEmpty()) {
|
||||||
|
log.warn(
|
||||||
|
"NOT_FOUND_MAP_SHEET_NUM : yyyy={}, scenesSize={}",
|
||||||
|
yyyy,
|
||||||
|
mapSheetNums == null ? 0 : mapSheetNums.size());
|
||||||
|
throw new CustomApiException("NOT_FOUND_MAP_SHEET_NUM", HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
return writeSceneGeoJson(yyyy, mapSheetScope, detectOption, features);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 년도 별로 조회하여 geojson 파일 생성
|
* 년도 별로 조회하여 geojson 파일 생성
|
||||||
*
|
*
|
||||||
* @param yearDtos
|
* @param yearDtos
|
||||||
* @param year
|
* @param yyyy
|
||||||
* @param mapSheetScope
|
* @param mapSheetScope
|
||||||
* @param detectOption
|
* @param detectOption
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Scene getSceneInference(
|
private Scene getSceneInference(
|
||||||
List<MapSheetFallbackYearDto> yearDtos,
|
List<MngListDto> yearDtos, String yyyy, String mapSheetScope, String detectOption) {
|
||||||
String year,
|
|
||||||
String mapSheetScope,
|
List<ImageFeature> features =
|
||||||
String detectOption) {
|
mapSheetMngCoreService.loadSceneInferenceByFallbackYears(yearDtos);
|
||||||
return mapSheetMngCoreService.getSceneInference(yearDtos, year, mapSheetScope, detectOption);
|
return writeSceneGeoJson(yyyy, mapSheetScope, detectOption, features);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -952,10 +857,10 @@ public class InferenceResultService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 추론결과 shp zip 파일 다운로드 경로 생성
|
* 추론결과 shp zip 파일 확인하여 다운로드 경로 생성
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid 추론 uuid
|
||||||
* @return
|
* @return 32자 추론 uid, shp 파일 경로
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> shpDownloadPath(UUID uuid) {
|
public Map<String, Object> shpDownloadPath(UUID uuid) {
|
||||||
InferenceLearnDto dto = inferenceResultCoreService.getInferenceUid(uuid);
|
InferenceLearnDto dto = inferenceResultCoreService.getInferenceUid(uuid);
|
||||||
@@ -981,7 +886,7 @@ public class InferenceResultService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 실행중인 추론 도엽명 목록
|
* 분석중인 추론 도엽명 목록
|
||||||
*
|
*
|
||||||
* @param uuid uuid
|
* @param uuid uuid
|
||||||
* @return
|
* @return
|
||||||
@@ -989,4 +894,69 @@ public class InferenceResultService {
|
|||||||
public List<String> getInferenceRunMapId(UUID uuid) {
|
public List<String> getInferenceRunMapId(UUID uuid) {
|
||||||
return inferenceResultCoreService.getInferenceRunMapId(uuid);
|
return inferenceResultCoreService.getInferenceRunMapId(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 파일 경로/이름 , 파일 생성 , 도엽번호 반환
|
||||||
|
*
|
||||||
|
* @param yyyy
|
||||||
|
* @param mapSheetScope
|
||||||
|
* @param detectOption
|
||||||
|
* @param sceneInference
|
||||||
|
* @return Scene
|
||||||
|
*/
|
||||||
|
private Scene writeSceneGeoJson(
|
||||||
|
String yyyy, String mapSheetScope, String detectOption, List<ImageFeature> sceneInference) {
|
||||||
|
|
||||||
|
boolean isAll = MapSheetScope.ALL.getId().equals(mapSheetScope);
|
||||||
|
String optionSuffix = buildOptionSuffix(detectOption);
|
||||||
|
|
||||||
|
String targetDir =
|
||||||
|
"local".equals(activeEnv) ? System.getProperty("user.home") + "/geojson" : inferenceDir;
|
||||||
|
|
||||||
|
// 파일명 생성
|
||||||
|
String filename =
|
||||||
|
isAll
|
||||||
|
? String.format("%s_%s_ALL%s.geojson", yyyy, activeEnv, optionSuffix)
|
||||||
|
: String.format("%s_%s%s.geojson", yyyy, activeEnv, optionSuffix);
|
||||||
|
|
||||||
|
Path outputPath = Paths.get(targetDir, filename);
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.info("create Directories outputPath: {}", outputPath);
|
||||||
|
log.info(
|
||||||
|
"activeEnv={}, inferenceDir={}, targetDir={}, filename={}",
|
||||||
|
activeEnv,
|
||||||
|
inferenceDir,
|
||||||
|
targetDir,
|
||||||
|
filename);
|
||||||
|
log.info("outputPath={}, parent={}", outputPath.toAbsolutePath(), outputPath.getParent());
|
||||||
|
|
||||||
|
Files.createDirectories(outputPath.getParent());
|
||||||
|
|
||||||
|
new GeoJsonFileWriter()
|
||||||
|
.exportToFile(sceneInference, "scene_inference_" + yyyy, 5186, outputPath.toString());
|
||||||
|
|
||||||
|
Scene scene = new Scene();
|
||||||
|
scene.setFeatures(sceneInference);
|
||||||
|
scene.setFilePath(outputPath.toString());
|
||||||
|
return scene;
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(
|
||||||
|
"FAIL_CREATE_MAP_SHEET_FILE: yyyy={}, isAll={}, path={}", yyyy, isAll, outputPath, e);
|
||||||
|
throw new CustomApiException("INTERNAL_SERVER_ERROR", HttpStatus.INTERNAL_SERVER_ERROR, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* geojson 파일명 Suffix
|
||||||
|
*
|
||||||
|
* @param detectOption
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String buildOptionSuffix(String detectOption) {
|
||||||
|
if (DetectOption.EXCL.getId().equals(detectOption)) return "_EXCL";
|
||||||
|
if (DetectOption.PREV.getId().equals(detectOption)) return "_PREV";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package com.kamco.cd.kamcoback.inference.service;
|
package com.kamco.cd.kamcoback.inference.service;
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.Scene;
|
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceLearnDto;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceLearnDto;
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultShpDto;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultShpDto;
|
||||||
import com.kamco.cd.kamcoback.postgres.core.InferenceResultCoreService;
|
import com.kamco.cd.kamcoback.postgres.core.InferenceResultCoreService;
|
||||||
import com.kamco.cd.kamcoback.postgres.core.InferenceResultShpCoreService;
|
import com.kamco.cd.kamcoback.postgres.core.InferenceResultShpCoreService;
|
||||||
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngCoreService;
|
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngCoreService;
|
||||||
import com.kamco.cd.kamcoback.scheduler.service.ShpPipelineService;
|
import com.kamco.cd.kamcoback.scheduler.service.ShpPipelineService;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -66,21 +64,4 @@ public class InferenceResultShpService {
|
|||||||
// shp 파일 비동기 생성
|
// shp 파일 비동기 생성
|
||||||
shpPipelineService.runPipeline(jarPath, datasetDir, batchId, dto.getUid());
|
shpPipelineService.runPipeline(jarPath, datasetDir, batchId, dto.getUid());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 추론 실행전 geojson 파일 생성
|
|
||||||
*
|
|
||||||
* @param yyyy
|
|
||||||
* @param mapSheetScope
|
|
||||||
* @param detectOption
|
|
||||||
* @param mapIds
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Scene createGeojson(
|
|
||||||
String yyyy, String mapSheetScope, String detectOption, List<String> mapIds) {
|
|
||||||
Scene getSceneInference =
|
|
||||||
mapSheetMngCoreService.getSceneInference(yyyy, mapIds, mapSheetScope, detectOption);
|
|
||||||
log.info("getSceneInference: {}", getSceneInference);
|
|
||||||
return getSceneInference;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,7 +339,12 @@ public class MapSheetMngService {
|
|||||||
|
|
||||||
public FoldersDto getFolderAll(SrchFoldersDto srchDto) {
|
public FoldersDto getFolderAll(SrchFoldersDto srchDto) {
|
||||||
|
|
||||||
String dirPath = syncRootDir + srchDto.getDirPath();
|
// "경로중복"
|
||||||
|
String dirPath =
|
||||||
|
(srchDto.getDirPath() == null || srchDto.getDirPath().isEmpty())
|
||||||
|
? syncRootDir
|
||||||
|
: srchDto.getDirPath();
|
||||||
|
// String dirPath = syncRootDir + srchDto.getDirPath();
|
||||||
|
|
||||||
log.info("[FIND_FOLDER] DIR : {}", dirPath);
|
log.info("[FIND_FOLDER] DIR : {}", dirPath);
|
||||||
List<FIleChecker.Folder> folderList =
|
List<FIleChecker.Folder> folderList =
|
||||||
@@ -381,6 +386,9 @@ public class MapSheetMngService {
|
|||||||
mapSheetMngCoreService.getSceneInference(yyyy);
|
mapSheetMngCoreService.getSceneInference(yyyy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public List<MngYyyyDto> findMapSheetMngDoneYyyyList() {
|
public List<MngYyyyDto> findMapSheetMngDoneYyyyList() {
|
||||||
|
|
||||||
List<MngDto> mngList = mapSheetMngCoreService.findMapSheetMngList();
|
List<MngDto> mngList = mapSheetMngCoreService.findMapSheetMngList();
|
||||||
|
|||||||
@@ -46,6 +46,13 @@ public class AuditLogCoreService
|
|||||||
return auditLogRepository.findLogByAccount(searchRange, searchValue);
|
return auditLogRepository.findLogByAccount(searchRange, searchValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 다운로드 이력 조회
|
||||||
|
*
|
||||||
|
* @param searchReq 페이징 파라미터
|
||||||
|
* @param downloadReq 다운로드 이력 팝업 검색 조건
|
||||||
|
* @return 다운로드 이력 정보 목록
|
||||||
|
*/
|
||||||
public Page<AuditLogDto.DownloadRes> findLogByAccount(
|
public Page<AuditLogDto.DownloadRes> findLogByAccount(
|
||||||
AuditLogDto.searchReq searchReq, DownloadReq downloadReq) {
|
AuditLogDto.searchReq searchReq, DownloadReq downloadReq) {
|
||||||
return auditLogRepository.findDownloadLog(searchReq, downloadReq);
|
return auditLogRepository.findDownloadLog(searchReq, downloadReq);
|
||||||
|
|||||||
@@ -79,12 +79,13 @@ public class InferenceResultCoreService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 변화탐지 실행 정보 생성
|
* 변화탐지 실행 정보 생성 - 추론 실행 목록 테이블 저장, 도엽목록별 상태 체크 테이블 저장
|
||||||
*
|
*
|
||||||
* @param req
|
* @param req 추론 실행 목록 uuid
|
||||||
*/
|
*/
|
||||||
public UUID saveInferenceInfo(InferenceResultDto.RegReq req, List<MngListDto> targetList) {
|
public UUID saveInferenceInfo(InferenceResultDto.RegReq req, List<MngListDto> targetList) {
|
||||||
|
|
||||||
|
// 대표 도엽명 외 N 건 실행 문구 만들기 위해 Null, 중복 제거
|
||||||
List<MngListDto> distinctList =
|
List<MngListDto> distinctList =
|
||||||
targetList.stream()
|
targetList.stream()
|
||||||
.filter(dto -> dto.getMapSheetName() != null && !dto.getMapSheetName().isBlank())
|
.filter(dto -> dto.getMapSheetName() != null && !dto.getMapSheetName().isBlank())
|
||||||
@@ -124,17 +125,13 @@ public class InferenceResultCoreService {
|
|||||||
mapSheetLearnEntity.setDetectingCnt(0L);
|
mapSheetLearnEntity.setDetectingCnt(0L);
|
||||||
mapSheetLearnEntity.setTotalJobs((long) targetList.size());
|
mapSheetLearnEntity.setTotalJobs((long) targetList.size());
|
||||||
|
|
||||||
// 회차는 국유인 반영할때 update로 변경됨
|
|
||||||
// mapSheetLearnEntity.setStage(
|
|
||||||
// mapSheetLearnRepository.getLearnStage(req.getCompareYyyy(), req.getTargetYyyy()));
|
|
||||||
|
|
||||||
// learn 테이블 저장
|
// learn 테이블 저장
|
||||||
MapSheetLearnEntity savedLearn = mapSheetLearnRepository.save(mapSheetLearnEntity);
|
MapSheetLearnEntity savedLearn = mapSheetLearnRepository.save(mapSheetLearnEntity);
|
||||||
|
|
||||||
final int CHUNK = 1000;
|
final int CHUNK = 1000;
|
||||||
List<MapSheetLearn5kEntity> buffer = new ArrayList<>(CHUNK);
|
List<MapSheetLearn5kEntity> buffer = new ArrayList<>(CHUNK);
|
||||||
|
|
||||||
// learn 도엽별 저장
|
// learn 도엽별 저장, 도엽수가 많으므로 1000개 씩 저장함
|
||||||
for (MngListDto mngDto : targetList) {
|
for (MngListDto mngDto : targetList) {
|
||||||
MapSheetLearn5kEntity entity = new MapSheetLearn5kEntity();
|
MapSheetLearn5kEntity entity = new MapSheetLearn5kEntity();
|
||||||
entity.setLearn(savedLearn);
|
entity.setLearn(savedLearn);
|
||||||
@@ -145,12 +142,15 @@ public class InferenceResultCoreService {
|
|||||||
|
|
||||||
buffer.add(entity);
|
buffer.add(entity);
|
||||||
if (buffer.size() == CHUNK) {
|
if (buffer.size() == CHUNK) {
|
||||||
|
// 도엽별 저장 learn 5k 테이블
|
||||||
flushChunk(buffer);
|
flushChunk(buffer);
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// chunk 남은거 처리
|
||||||
if (!buffer.isEmpty()) {
|
if (!buffer.isEmpty()) {
|
||||||
|
// 도엽별 저장 learn 5k 테이블
|
||||||
flushChunk(buffer);
|
flushChunk(buffer);
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
}
|
}
|
||||||
@@ -159,9 +159,9 @@ public class InferenceResultCoreService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 도엽별 저장
|
* 도엽별 저장 learn 5k 테이블
|
||||||
*
|
*
|
||||||
* @param buffer
|
* @param buffer 저장 정보
|
||||||
*/
|
*/
|
||||||
private void flushChunk(List<MapSheetLearn5kEntity> buffer) {
|
private void flushChunk(List<MapSheetLearn5kEntity> buffer) {
|
||||||
|
|
||||||
@@ -422,7 +422,7 @@ public class InferenceResultCoreService {
|
|||||||
/**
|
/**
|
||||||
* 추론 진행중인지 확인
|
* 추론 진행중인지 확인
|
||||||
*
|
*
|
||||||
* @return
|
* @return 추론 실행중인 추론 uuid, batch id
|
||||||
*/
|
*/
|
||||||
public SaveInferenceAiDto getProcessing() {
|
public SaveInferenceAiDto getProcessing() {
|
||||||
MapSheetLearnEntity entity = mapSheetLearnRepository.getProcessing();
|
MapSheetLearnEntity entity = mapSheetLearnRepository.getProcessing();
|
||||||
@@ -527,10 +527,10 @@ public class InferenceResultCoreService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* uid 조회
|
* 추론 정보 조회 하여 batch id, 32자 uid 리턴
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid 추론 uuid
|
||||||
* @return
|
* @return 추론정보
|
||||||
*/
|
*/
|
||||||
public InferenceLearnDto getInferenceUid(UUID uuid) {
|
public InferenceLearnDto getInferenceUid(UUID uuid) {
|
||||||
MapSheetLearnEntity entity = inferenceResultRepository.getInferenceUid(uuid).orElse(null);
|
MapSheetLearnEntity entity = inferenceResultRepository.getInferenceUid(uuid).orElse(null);
|
||||||
@@ -547,7 +547,7 @@ public class InferenceResultCoreService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 실행중인 추론 도엽명 목록
|
* 분석중인 추론 도엽명 목록
|
||||||
*
|
*
|
||||||
* @param uuid 추론 실행중인 uuid
|
* @param uuid 추론 실행중인 uuid
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
@@ -1,14 +1,8 @@
|
|||||||
package com.kamco.cd.kamcoback.postgres.core;
|
package com.kamco.cd.kamcoback.postgres.core;
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.common.enums.MngStateType;
|
import com.kamco.cd.kamcoback.common.enums.MngStateType;
|
||||||
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
|
|
||||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter;
|
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter;
|
||||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.ImageFeature;
|
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.ImageFeature;
|
||||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.Scene;
|
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.DetectOption;
|
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetFallbackYearDto;
|
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetScope;
|
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListCompareDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListCompareDto;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListDto;
|
||||||
@@ -22,11 +16,11 @@ import jakarta.persistence.EntityNotFoundException;
|
|||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -37,7 +31,6 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -55,9 +48,6 @@ public class MapSheetMngCoreService {
|
|||||||
@Value("${file.sync-root-dir}")
|
@Value("${file.sync-root-dir}")
|
||||||
private String syncRootDir;
|
private String syncRootDir;
|
||||||
|
|
||||||
@Value("${inference.geojson-dir}")
|
|
||||||
private String inferenceDir;
|
|
||||||
|
|
||||||
public List<MapSheetMngDto.MngDto> findMapSheetMngList() {
|
public List<MapSheetMngDto.MngDto> findMapSheetMngList() {
|
||||||
return mapSheetMngRepository.findMapSheetMngList();
|
return mapSheetMngRepository.findMapSheetMngList();
|
||||||
}
|
}
|
||||||
@@ -235,124 +225,29 @@ public class MapSheetMngCoreService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* geojson 생성
|
* geojson 생성시 필요한 영상파일 정보 조회
|
||||||
*
|
*
|
||||||
* @param yyyy
|
* @param yyyy
|
||||||
* @param scenes
|
* @param mapSheetNums
|
||||||
* @param mapSheetScope
|
|
||||||
* @param detectOption
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Scene getSceneInference(
|
|
||||||
String yyyy, List<String> scenes, String mapSheetScope, String detectOption) {
|
|
||||||
List<ImageFeature> features = loadSceneInferenceBySheets(yyyy, scenes);
|
|
||||||
return writeSceneGeoJson(yyyy, mapSheetScope, detectOption, features);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* geojson 생성
|
|
||||||
*
|
|
||||||
* @param yearDtos
|
|
||||||
* @param yyyy
|
|
||||||
* @param mapSheetScope
|
|
||||||
* @param detectOption
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Scene getSceneInference(
|
|
||||||
List<MapSheetFallbackYearDto> yearDtos,
|
|
||||||
String yyyy,
|
|
||||||
String mapSheetScope,
|
|
||||||
String detectOption) {
|
|
||||||
List<ImageFeature> features = loadSceneInferenceByFallbackYears(yearDtos);
|
|
||||||
return writeSceneGeoJson(yyyy, mapSheetScope, detectOption, features);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 파일 경로/이름 , 파일 생성 , 도엽번호 반환
|
|
||||||
*
|
|
||||||
* @param yyyy
|
|
||||||
* @param mapSheetScope
|
|
||||||
* @param detectOption
|
|
||||||
* @param sceneInference
|
|
||||||
* @return Scene
|
|
||||||
*/
|
|
||||||
private Scene writeSceneGeoJson(
|
|
||||||
String yyyy, String mapSheetScope, String detectOption, List<ImageFeature> sceneInference) {
|
|
||||||
boolean isAll = MapSheetScope.ALL.getId().equals(mapSheetScope);
|
|
||||||
String optionSuffix = buildOptionSuffix(detectOption);
|
|
||||||
|
|
||||||
String targetDir =
|
|
||||||
"local".equals(activeEnv) ? System.getProperty("user.home") + "/geojson" : inferenceDir;
|
|
||||||
|
|
||||||
String filename =
|
|
||||||
isAll
|
|
||||||
? String.format("%s_%s_ALL%s.geojson", yyyy, activeEnv, optionSuffix)
|
|
||||||
: String.format("%s_%s%s.geojson", yyyy, activeEnv, optionSuffix);
|
|
||||||
|
|
||||||
Path outputPath = Paths.get(targetDir, filename);
|
|
||||||
|
|
||||||
if (sceneInference == null || sceneInference.isEmpty()) {
|
|
||||||
log.warn("NOT_FOUND_TARGET_YEAR: yyyy={}, isAll={}, featuresSize={}", yyyy, isAll, 0);
|
|
||||||
throw new CustomApiException("NOT_FOUND_TARGET_YEAR", HttpStatus.NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
log.info("create Directories outputPath: {}", outputPath);
|
|
||||||
log.info(
|
|
||||||
"activeEnv={}, inferenceDir={}, targetDir={}, filename={}",
|
|
||||||
activeEnv,
|
|
||||||
inferenceDir,
|
|
||||||
targetDir,
|
|
||||||
filename);
|
|
||||||
log.info("outputPath={}, parent={}", outputPath.toAbsolutePath(), outputPath.getParent());
|
|
||||||
|
|
||||||
Files.createDirectories(outputPath.getParent());
|
|
||||||
|
|
||||||
new GeoJsonFileWriter()
|
|
||||||
.exportToFile(sceneInference, "scene_inference_" + yyyy, 5186, outputPath.toString());
|
|
||||||
|
|
||||||
Scene scene = new Scene();
|
|
||||||
scene.setFeatures(sceneInference);
|
|
||||||
scene.setFilePath(outputPath.toString());
|
|
||||||
return scene;
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(
|
|
||||||
"FAIL_CREATE_MAP_SHEET_FILE: yyyy={}, isAll={}, path={}", yyyy, isAll, outputPath, e);
|
|
||||||
throw new CustomApiException("INTERNAL_SERVER_ERROR", HttpStatus.INTERNAL_SERVER_ERROR, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* geojson 파일명 Suffix
|
|
||||||
*
|
|
||||||
* @param detectOption
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String buildOptionSuffix(String detectOption) {
|
|
||||||
if (DetectOption.EXCL.getId().equals(detectOption)) return "_EXCL";
|
|
||||||
if (DetectOption.PREV.getId().equals(detectOption)) return "_PREV";
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 년도, 도엽번호로 조회
|
|
||||||
*
|
|
||||||
* @param yyyy
|
|
||||||
* @param scenes
|
|
||||||
* @return ImageFeature
|
* @return ImageFeature
|
||||||
*/
|
*/
|
||||||
private List<ImageFeature> loadSceneInferenceBySheets(String yyyy, List<String> scenes) {
|
public List<ImageFeature> loadSceneInferenceBySheets(String yyyy, List<String> mapSheetNums) {
|
||||||
List<ImageFeature> sceneInference = mapSheetMngRepository.getSceneInference(yyyy, scenes);
|
|
||||||
|
|
||||||
if (sceneInference == null || sceneInference.isEmpty()) {
|
if (mapSheetNums == null || mapSheetNums.isEmpty()) {
|
||||||
log.warn(
|
return List.of();
|
||||||
"NOT_FOUND_TARGET_YEAR: yyyy={}, scenesSize={}",
|
|
||||||
yyyy,
|
|
||||||
scenes == null ? 0 : scenes.size());
|
|
||||||
throw new CustomApiException("NOT_FOUND_TARGET_YEAR", HttpStatus.NOT_FOUND);
|
|
||||||
}
|
}
|
||||||
return sceneInference;
|
|
||||||
|
// CHUNK_SIZE 단위로 나누어 여러 번 조회한다.
|
||||||
|
final int CHUNK_SIZE = 1000;
|
||||||
|
List<ImageFeature> features = new ArrayList<>();
|
||||||
|
|
||||||
|
// i부터 CHUNK_SIZE만큼 잘라서 조회
|
||||||
|
// 마지막 구간은 남은 개수만큼만 처리하기 위해 Math.min 사용
|
||||||
|
for (int i = 0; i < mapSheetNums.size(); i += CHUNK_SIZE) {
|
||||||
|
List<String> chunk = mapSheetNums.subList(i, Math.min(i + CHUNK_SIZE, mapSheetNums.size()));
|
||||||
|
features.addAll(mapSheetMngRepository.getSceneInference(yyyy, chunk));
|
||||||
|
}
|
||||||
|
return features;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -361,33 +256,32 @@ public class MapSheetMngCoreService {
|
|||||||
* @param yearDtos
|
* @param yearDtos
|
||||||
* @return ImageFeature
|
* @return ImageFeature
|
||||||
*/
|
*/
|
||||||
private List<ImageFeature> loadSceneInferenceByFallbackYears(
|
public List<ImageFeature> loadSceneInferenceByFallbackYears(List<MngListDto> yearDtos) {
|
||||||
List<MapSheetFallbackYearDto> yearDtos) {
|
|
||||||
if (yearDtos == null || yearDtos.isEmpty()) {
|
if (yearDtos == null || yearDtos.isEmpty()) {
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 년도 별로 루프를 돌리기위해 년도별 정리
|
// 년도 별로 루프를 돌리기위해 년도별 정리
|
||||||
Map<Integer, List<MapSheetFallbackYearDto>> groupedByYear =
|
Map<Integer, List<MngListDto>> groupedByYear =
|
||||||
yearDtos.stream()
|
yearDtos.stream()
|
||||||
.filter(d -> d.getMngYyyy() != null && d.getMapSheetNum() != null)
|
.filter(d -> d.getMngYyyy() != 0 && d.getMapSheetNum() != null)
|
||||||
.collect(Collectors.groupingBy(MapSheetFallbackYearDto::getMngYyyy));
|
.collect(Collectors.groupingBy(MngListDto::getMngYyyy));
|
||||||
|
|
||||||
List<ImageFeature> sceneInference = new ArrayList<>();
|
List<ImageFeature> sceneInference = new ArrayList<>();
|
||||||
|
|
||||||
for (Map.Entry<Integer, List<MapSheetFallbackYearDto>> entry : groupedByYear.entrySet()) {
|
for (Map.Entry<Integer, List<MngListDto>> entry : groupedByYear.entrySet()) {
|
||||||
Integer year = entry.getKey();
|
Integer year = entry.getKey();
|
||||||
|
|
||||||
// 년도별 mapSheetNum 만들기
|
// 년도별 mapSheetNum 만들기
|
||||||
List<String> sheetNums =
|
List<String> sheetNums =
|
||||||
entry.getValue().stream()
|
entry.getValue().stream()
|
||||||
.map(MapSheetFallbackYearDto::getMapSheetNum)
|
.map(MngListDto::getMapSheetNum)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.distinct()
|
.distinct()
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
// tif파일 정보 조회
|
// tif파일 정보 조회
|
||||||
List<ImageFeature> temp = mapSheetMngRepository.getSceneInference(year.toString(), sheetNums);
|
List<ImageFeature> temp = loadSceneInferenceBySheets(year.toString(), sheetNums);
|
||||||
|
|
||||||
if (temp != null && !temp.isEmpty()) {
|
if (temp != null && !temp.isEmpty()) {
|
||||||
sceneInference.addAll(temp);
|
sceneInference.addAll(temp);
|
||||||
@@ -400,15 +294,35 @@ public class MapSheetMngCoreService {
|
|||||||
/**
|
/**
|
||||||
* 변화탐지 실행 가능 기준 년도 조회
|
* 변화탐지 실행 가능 기준 년도 조회
|
||||||
*
|
*
|
||||||
* @param req
|
* @param compareYear 비교 연도
|
||||||
* @return
|
* @param targetYear 기준 연도
|
||||||
|
* @param mapSheetScope 부분실행, 전체실행
|
||||||
|
* @param mapSheetNums 도엽번호 목록
|
||||||
|
* @return 실행가능한 도엽번호 목록
|
||||||
*/
|
*/
|
||||||
public List<MngListDto> getHstMapSheetList(InferenceResultDto.RegReq req) {
|
public List<MngListDto> findExecutableSheets(
|
||||||
return mapSheetMngRepository.findByHstMapSheetTargetList(req);
|
Integer compareYear, Integer targetYear, String mapSheetScope, List<String> mapSheetNums) {
|
||||||
|
return mapSheetMngRepository.findExecutableSheets(
|
||||||
|
compareYear, targetYear, mapSheetScope, mapSheetNums);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MngListDto> getHstMapSheetList(int mngYyyy, List<String> mapIds) {
|
public List<MngListDto> fetchBaseWithCompare(
|
||||||
return mapSheetMngRepository.findByHstMapSheetTargetList(mngYyyy, mapIds);
|
Integer compareYear, Integer targetYear, String mapSheetScope, List<String> mapSheetNums) {
|
||||||
|
return mapSheetMngRepository.fetchBaseWithCompare(
|
||||||
|
compareYear, targetYear, mapSheetScope, mapSheetNums);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 실행가능 도엽 count
|
||||||
|
*
|
||||||
|
* @param year 연도
|
||||||
|
* @param mapSheetScope 부분, 전체 구분
|
||||||
|
* @param mapSheetNums 도엽 목록
|
||||||
|
* @return count
|
||||||
|
*/
|
||||||
|
public int countExecutableSheetsDistinct(
|
||||||
|
Integer year, String mapSheetScope, List<String> mapSheetNums) {
|
||||||
|
return mapSheetMngRepository.countExecutableSheetsDistinct(year, mapSheetScope, mapSheetNums);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMapSheetMngHstUploadId(Long hstUid, UUID uuid, String uploadId) {
|
public void updateMapSheetMngHstUploadId(Long hstUid, UUID uuid, String uploadId) {
|
||||||
@@ -431,30 +345,32 @@ public class MapSheetMngCoreService {
|
|||||||
return mapSheetMngYearRepository.findByHstMapSheetCompareList(mngYyyy, mapId);
|
return mapSheetMngYearRepository.findByHstMapSheetCompareList(mngYyyy, mapId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getMapSheetNumByHst(Integer year) {
|
public List<MngListDto> getMapSheetMngHst(
|
||||||
List<MapSheetMngHstEntity> entity = mapSheetMngRepository.getMapSheetMngHst(year);
|
Integer year, String mapSheetScope, List<String> mapSheetNum) {
|
||||||
return entity.stream().map(MapSheetMngHstEntity::getMapSheetNum).toList();
|
return mapSheetMngRepository.getMapSheetMngHst(year, mapSheetScope, mapSheetNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 특정 연도의 도엽 이력 데이터를 조회
|
* 이전 년도 도엽 조회
|
||||||
*
|
*
|
||||||
* @param year
|
* @param year
|
||||||
|
* @param mapIds
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<MapSheetFallbackYearDto> getMapSheetNumDtoByHst(Integer year) {
|
public List<MngListDto> findFallbackCompareYearByMapSheets(Integer year, List<String> mapIds) {
|
||||||
List<MapSheetMngHstEntity> entity = mapSheetMngRepository.getMapSheetMngHst(year);
|
if (mapIds == null || mapIds.isEmpty()) {
|
||||||
return entity.stream()
|
return Collections.emptyList();
|
||||||
.map(
|
|
||||||
e ->
|
|
||||||
new MapSheetFallbackYearDto(
|
|
||||||
e.getMapSheetNum(), e.getMngYyyy() // 조회 기준 연도
|
|
||||||
))
|
|
||||||
.toList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MapSheetFallbackYearDto> findFallbackCompareYearByMapSheets(
|
int chunkSize = 1000;
|
||||||
Integer year, List<String> mapIds) {
|
List<MngListDto> result = new ArrayList<>();
|
||||||
return mapSheetMngRepository.findFallbackCompareYearByMapSheets(year, mapIds);
|
|
||||||
|
for (int i = 0; i < mapIds.size(); i += chunkSize) {
|
||||||
|
List<String> chunk = mapIds.subList(i, Math.min(i + chunkSize, mapIds.size()));
|
||||||
|
|
||||||
|
result.addAll(mapSheetMngRepository.findFallbackCompareYearByMapSheets(year, chunk));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,5 +16,11 @@ public interface InferenceResultRepositoryCustom {
|
|||||||
|
|
||||||
Long getInferenceLearnIdByUuid(UUID uuid);
|
Long getInferenceLearnIdByUuid(UUID uuid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 추론 정보 조회
|
||||||
|
*
|
||||||
|
* @param uuid 추론 uuid
|
||||||
|
* @return 추론 정보
|
||||||
|
*/
|
||||||
Optional<MapSheetLearnEntity> getInferenceUid(UUID uuid);
|
Optional<MapSheetLearnEntity> getInferenceUid(UUID uuid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,5 +14,11 @@ public interface MapSheetLearn5kRepositoryCustom {
|
|||||||
|
|
||||||
List<Long> findCompleted5kList(UUID uuid, List<Long> completedIds, String type);
|
List<Long> findCompleted5kList(UUID uuid, List<Long> completedIds, String type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 추론 실행중일때 분석중인 도엽명 목록 조회
|
||||||
|
*
|
||||||
|
* @param uuid 추론 uuid
|
||||||
|
* @return 도엽명+50K 도엽번호
|
||||||
|
*/
|
||||||
List<String> getInferenceRunMapId(UUID uuid);
|
List<String> getInferenceRunMapId(UUID uuid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
|
package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.ImageFeature;
|
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.ImageFeature;
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetFallbackYearDto;
|
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.AddReq;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.AddReq;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListDto;
|
||||||
@@ -65,14 +63,38 @@ public interface MapSheetMngRepositoryCustom {
|
|||||||
List<MapSheetMngDto.MngFilesDto> findByHstUidMapSheetFileList(Long hstUid);
|
List<MapSheetMngDto.MngFilesDto> findByHstUidMapSheetFileList(Long hstUid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 변화탐지 실행 가능 기준 연도 조회
|
* 추론 실행 가능 도엽 조회 (추론 제외)
|
||||||
*
|
*
|
||||||
* @param req 조회 연도, 도엽번호 목록,
|
* @param compareYear 비교 연도
|
||||||
|
* @param targetYear 기준 연도
|
||||||
|
* @param mapSheetScope 부분실행, 전체실행
|
||||||
|
* @param mapSheetNums 도엽번호 목록
|
||||||
|
* @return 실행가능한 도엽번호 목록
|
||||||
|
*/
|
||||||
|
List<MngListDto> findExecutableSheets(
|
||||||
|
Integer compareYear, Integer targetYear, String mapSheetScope, List<String> mapSheetNums);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 추론 실행 가능 도엽 조회 (이전년도 사용가능)
|
||||||
|
*
|
||||||
|
* @param targetYear
|
||||||
|
* @param compareYear
|
||||||
|
* @param mapSheetScope
|
||||||
|
* @param mapSheetNums
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<MngListDto> findByHstMapSheetTargetList(InferenceResultDto.RegReq req);
|
List<MngListDto> fetchBaseWithCompare(
|
||||||
|
Integer targetYear, Integer compareYear, String mapSheetScope, List<String> mapSheetNums);
|
||||||
|
|
||||||
List<MngListDto> findByHstMapSheetTargetList(int mngYyyy, List<String> mapIds);
|
/**
|
||||||
|
* 실행가능 도엽 count
|
||||||
|
*
|
||||||
|
* @param year 연도
|
||||||
|
* @param mapSheetScope 부분, 전체 구분
|
||||||
|
* @param mapSheetNums 도엽 목록
|
||||||
|
* @return count
|
||||||
|
*/
|
||||||
|
int countExecutableSheetsDistinct(Integer year, String mapSheetScope, List<String> mapSheetNums);
|
||||||
|
|
||||||
MapSheetMngDto.MngFilesDto findByFileUidMapSheetFile(Long fileUid);
|
MapSheetMngDto.MngFilesDto findByFileUidMapSheetFile(Long fileUid);
|
||||||
|
|
||||||
@@ -82,14 +104,26 @@ public interface MapSheetMngRepositoryCustom {
|
|||||||
|
|
||||||
Page<YearEntity> getYears(YearSearchReq req);
|
Page<YearEntity> getYears(YearSearchReq req);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 도엽 영상파일 정보 조회
|
||||||
|
*
|
||||||
|
* @param yyyy 연도
|
||||||
|
* @param mapSheetNums 도엽목록
|
||||||
|
* @return 도엽 영상파일 정보
|
||||||
|
*/
|
||||||
List<ImageFeature> getSceneInference(String yyyy, List<String> mapSheetNums);
|
List<ImageFeature> getSceneInference(String yyyy, List<String> mapSheetNums);
|
||||||
|
|
||||||
void updateMapSheetMngHstUploadId(Long hstUid, UUID uuid, String uploadId);
|
void updateMapSheetMngHstUploadId(Long hstUid, UUID uuid, String uploadId);
|
||||||
|
|
||||||
void insertMapSheetMngTile(@Valid AddReq addReq);
|
void insertMapSheetMngTile(@Valid AddReq addReq);
|
||||||
|
|
||||||
List<MapSheetMngHstEntity> getMapSheetMngHst(Integer year);
|
/**
|
||||||
|
* 연도 조건으로 도엽번호 조회
|
||||||
|
*
|
||||||
|
* @param year 연도
|
||||||
|
* @return 추론 가능한 도엽 정보
|
||||||
|
*/
|
||||||
|
List<MngListDto> getMapSheetMngHst(Integer year, String mapSheetScope, List<String> mapSheetNum);
|
||||||
|
|
||||||
List<MapSheetFallbackYearDto> findFallbackCompareYearByMapSheets(
|
List<MngListDto> findFallbackCompareYearByMapSheets(Integer year, List<String> mapIds);
|
||||||
Integer year, List<String> mapIds);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,36 +5,41 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngEntity.mapSheet
|
|||||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngFileEntity.mapSheetMngFileEntity;
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngFileEntity.mapSheetMngFileEntity;
|
||||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngHstEntity.mapSheetMngHstEntity;
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngHstEntity.mapSheetMngHstEntity;
|
||||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngTileEntity.mapSheetMngTileEntity;
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngTileEntity.mapSheetMngTileEntity;
|
||||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngYearYnEntity.mapSheetMngYearYnEntity;
|
|
||||||
import static com.kamco.cd.kamcoback.postgres.entity.QYearEntity.yearEntity;
|
import static com.kamco.cd.kamcoback.postgres.entity.QYearEntity.yearEntity;
|
||||||
import static com.querydsl.core.types.dsl.Expressions.nullExpression;
|
import static com.querydsl.core.types.dsl.Expressions.nullExpression;
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
|
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
|
||||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.ImageFeature;
|
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.ImageFeature;
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetFallbackYearDto;
|
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetScope;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetScope;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.AddReq;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.AddReq;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListDto;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.YearSearchReq;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.YearSearchReq;
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.QMapInkx5kEntity;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngFileEntity;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngHstEntity;
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.QYearEntity;
|
import com.kamco.cd.kamcoback.postgres.entity.QYearEntity;
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.YearEntity;
|
import com.kamco.cd.kamcoback.postgres.entity.YearEntity;
|
||||||
import com.querydsl.core.BooleanBuilder;
|
import com.querydsl.core.BooleanBuilder;
|
||||||
|
import com.querydsl.core.Tuple;
|
||||||
import com.querydsl.core.types.Projections;
|
import com.querydsl.core.types.Projections;
|
||||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||||
import com.querydsl.core.types.dsl.CaseBuilder;
|
import com.querydsl.core.types.dsl.CaseBuilder;
|
||||||
import com.querydsl.core.types.dsl.Expressions;
|
import com.querydsl.core.types.dsl.Expressions;
|
||||||
import com.querydsl.core.types.dsl.NumberExpression;
|
import com.querydsl.core.types.dsl.NumberExpression;
|
||||||
import com.querydsl.core.types.dsl.StringExpression;
|
import com.querydsl.core.types.dsl.StringExpression;
|
||||||
|
import com.querydsl.jpa.JPAExpressions;
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.persistence.PersistenceContext;
|
import jakarta.persistence.PersistenceContext;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -572,85 +577,202 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
return foundContent;
|
return foundContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 기준년도 추론 실행 가능 도엽 조회
|
|
||||||
*
|
|
||||||
* @param req
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<MngListDto> findByHstMapSheetTargetList(InferenceResultDto.RegReq req) {
|
public List<MngListDto> findExecutableSheets(
|
||||||
BooleanBuilder whereBuilder = new BooleanBuilder();
|
Integer compareYear, Integer targetYear, String mapSheetScope, List<String> mapSheetNums) {
|
||||||
|
|
||||||
whereBuilder.and(mapSheetMngHstEntity.dataState.eq("DONE"));
|
QMapSheetMngHstEntity t = new QMapSheetMngHstEntity("t");
|
||||||
whereBuilder.and(
|
QMapSheetMngHstEntity c = new QMapSheetMngHstEntity("c");
|
||||||
mapSheetMngHstEntity
|
|
||||||
.syncState
|
|
||||||
.eq("DONE")
|
|
||||||
.or(mapSheetMngHstEntity.syncCheckState.eq("DONE")));
|
|
||||||
whereBuilder.and(mapSheetMngHstEntity.useInference.eq("USE"));
|
|
||||||
|
|
||||||
whereBuilder.and(mapSheetMngHstEntity.mngYyyy.eq(req.getTargetYyyy()));
|
QMapInkx5kEntity ti = new QMapInkx5kEntity("ti");
|
||||||
|
QMapInkx5kEntity ci = new QMapInkx5kEntity("ci");
|
||||||
|
|
||||||
|
QMapSheetMngFileEntity tf = new QMapSheetMngFileEntity("tf");
|
||||||
|
QMapSheetMngFileEntity cf = new QMapSheetMngFileEntity("cf");
|
||||||
|
|
||||||
|
BooleanBuilder whereBuilderere = new BooleanBuilder();
|
||||||
|
whereBuilderere.and(t.dataState.eq("DONE"));
|
||||||
|
whereBuilderere.and(t.syncState.eq("DONE").or(t.syncCheckState.eq("DONE")));
|
||||||
|
whereBuilderere.and(t.useInference.eq("USE"));
|
||||||
|
whereBuilderere.and(t.mngYyyy.eq(targetYear));
|
||||||
|
|
||||||
|
// target: tif + DONE 파일 존재
|
||||||
|
whereBuilderere.and(
|
||||||
|
JPAExpressions.selectOne()
|
||||||
|
.from(tf)
|
||||||
|
.where(tf.hstUid.eq(t.hstUid).and(tf.fileExt.eq("tif")).and(tf.fileState.eq("DONE")))
|
||||||
|
.exists());
|
||||||
|
|
||||||
|
// PART scope면 prefix like 조건 추가
|
||||||
BooleanBuilder likeBuilder = new BooleanBuilder();
|
BooleanBuilder likeBuilder = new BooleanBuilder();
|
||||||
|
|
||||||
if (MapSheetScope.PART.getId().equals(req.getMapSheetScope())) {
|
if (MapSheetScope.PART.getId().equals(mapSheetScope)) {
|
||||||
List<String> list = req.getMapSheetNum();
|
if (mapSheetNums == null || mapSheetNums.isEmpty()) {
|
||||||
if (list == null || list.isEmpty()) {
|
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
for (String prefix : mapSheetNums) {
|
||||||
for (String prefix : list) {
|
if (prefix == null || prefix.isBlank()) continue;
|
||||||
if (prefix == null || prefix.isBlank()) {
|
likeBuilder.or(t.mapSheetNum.like(prefix.trim() + "%"));
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
likeBuilder.or(mapSheetMngHstEntity.mapSheetNum.like(prefix.trim() + "%"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (likeBuilder.hasValue()) {
|
if (likeBuilder.hasValue()) {
|
||||||
whereBuilder.and(likeBuilder);
|
whereBuilderere.and(likeBuilder);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// compare 조건은 EXISTS 서브쿼리 안에서 체크
|
||||||
|
BooleanExpression compareExists =
|
||||||
|
JPAExpressions.selectOne()
|
||||||
|
.from(c)
|
||||||
|
.join(ci)
|
||||||
|
.on(ci.mapidcdNo.eq(c.mapSheetNum).and(ci.useInference.eq(CommonUseStatus.USE)))
|
||||||
|
.where(
|
||||||
|
c.mapSheetNum
|
||||||
|
.eq(t.mapSheetNum) // 핵심: 같은 도엽번호
|
||||||
|
.and(c.dataState.eq("DONE"))
|
||||||
|
.and(c.syncState.eq("DONE").or(c.syncCheckState.eq("DONE")))
|
||||||
|
.and(c.useInference.eq("USE"))
|
||||||
|
.and(c.mngYyyy.eq(compareYear))
|
||||||
|
.and(
|
||||||
|
JPAExpressions.selectOne()
|
||||||
|
.from(cf)
|
||||||
|
.where(
|
||||||
|
cf.hstUid
|
||||||
|
.eq(c.hstUid)
|
||||||
|
.and(cf.fileExt.eq("tif"))
|
||||||
|
.and(cf.fileState.eq("DONE")))
|
||||||
|
.exists()))
|
||||||
|
.exists();
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(
|
.select(
|
||||||
Projections.constructor(
|
Projections.constructor(
|
||||||
MngListDto.class,
|
MngListDto.class,
|
||||||
mapSheetMngHstEntity.mngYyyy,
|
t.mngYyyy, // int mngYyyy
|
||||||
mapSheetMngHstEntity.mapSheetNum,
|
t.mapSheetNum, // String mapSheetNum
|
||||||
mapSheetMngHstEntity.mapSheetName,
|
t.mapSheetName, // String mapSheetName
|
||||||
nullExpression(Integer.class),
|
Expressions.nullExpression(Integer.class),
|
||||||
nullExpression(Boolean.class)))
|
Expressions.nullExpression(Boolean.class)))
|
||||||
.from(mapSheetMngHstEntity)
|
.from(t)
|
||||||
.innerJoin(mapInkx5kEntity)
|
.join(ti)
|
||||||
.on(
|
.on(ti.mapidcdNo.eq(t.mapSheetNum).and(ti.useInference.eq(CommonUseStatus.USE)))
|
||||||
mapInkx5kEntity
|
.where(whereBuilderere.and(compareExists))
|
||||||
.mapidcdNo
|
.distinct()
|
||||||
.eq(mapSheetMngHstEntity.mapSheetNum)
|
|
||||||
.and(mapInkx5kEntity.useInference.eq(CommonUseStatus.USE)))
|
|
||||||
.where(whereBuilder)
|
|
||||||
.fetch();
|
.fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MngListDto> findByHstMapSheetTargetList(int mngYyyy, List<String> mapIds) {
|
public List<MngListDto> fetchBaseWithCompare(
|
||||||
BooleanBuilder whereBuilder = new BooleanBuilder();
|
Integer compareYear, // 예: 2024 (비교 상한)
|
||||||
whereBuilder.and(mapSheetMngHstEntity.mngYyyy.eq(mngYyyy));
|
Integer targetYear, // 예: 2026 (기준 고정)
|
||||||
whereBuilder.and(mapSheetMngHstEntity.mapSheetNum.in(mapIds));
|
String mapSheetScope,
|
||||||
whereBuilder.and(mapSheetMngHstEntity.dataState.eq("DONE"));
|
List<String> mapSheetNums) {
|
||||||
whereBuilder.and(mapSheetMngHstEntity.syncState.eq("DONE")); // TODO 싱크체크 or조건 추가
|
|
||||||
whereBuilder.and(mapSheetMngHstEntity.useInference.eq("USE"));
|
|
||||||
|
|
||||||
return queryFactory
|
QMapSheetMngHstEntity h = QMapSheetMngHstEntity.mapSheetMngHstEntity; // base
|
||||||
.select(
|
QMapSheetMngHstEntity h2 = new QMapSheetMngHstEntity("h2"); // cmp
|
||||||
Projections.constructor(
|
QMapInkx5kEntity i = QMapInkx5kEntity.mapInkx5kEntity;
|
||||||
MngListDto.class,
|
QMapSheetMngFileEntity f = QMapSheetMngFileEntity.mapSheetMngFileEntity;
|
||||||
mapSheetMngHstEntity.mngYyyy,
|
QMapSheetMngFileEntity f2 = new QMapSheetMngFileEntity("f2");
|
||||||
mapSheetMngHstEntity.mapSheetNum,
|
|
||||||
mapSheetMngHstEntity.mapSheetName))
|
// -----------------------
|
||||||
.from(mapSheetMngHstEntity)
|
// 공통: tif DONE exists
|
||||||
.where(whereBuilder)
|
// -----------------------
|
||||||
|
BooleanExpression baseTifExists =
|
||||||
|
JPAExpressions.selectOne()
|
||||||
|
.from(f)
|
||||||
|
.where(f.hstUid.eq(h.hstUid), f.fileExt.eq("tif"), f.fileState.eq("DONE"))
|
||||||
|
.exists();
|
||||||
|
|
||||||
|
BooleanExpression cmpTifExists =
|
||||||
|
JPAExpressions.selectOne()
|
||||||
|
.from(f2)
|
||||||
|
.where(f2.hstUid.eq(h2.hstUid), f2.fileExt.eq("tif"), f2.fileState.eq("DONE"))
|
||||||
|
.exists();
|
||||||
|
|
||||||
|
// -----------------------
|
||||||
|
// 1) base 조회 (CTE base)
|
||||||
|
// -----------------------
|
||||||
|
BooleanBuilder baseWhere =
|
||||||
|
new BooleanBuilder()
|
||||||
|
.and(h.mngYyyy.eq(targetYear))
|
||||||
|
.and(h.dataState.eq("DONE"))
|
||||||
|
.and(h.useInference.eq("USE"))
|
||||||
|
.and(h.syncState.eq("DONE").or(h.syncCheckState.eq("DONE")))
|
||||||
|
.and(baseTifExists);
|
||||||
|
|
||||||
|
// PART 조건
|
||||||
|
if (MapSheetScope.PART.getId().equals(mapSheetScope)) {
|
||||||
|
if (mapSheetNums == null || mapSheetNums.isEmpty()) return List.of();
|
||||||
|
|
||||||
|
BooleanBuilder like = new BooleanBuilder();
|
||||||
|
for (String prefix : mapSheetNums) {
|
||||||
|
if (prefix == null || prefix.isBlank()) continue;
|
||||||
|
like.or(h.mapSheetNum.like(prefix.trim() + "%"));
|
||||||
|
}
|
||||||
|
if (!like.hasValue()) return List.of();
|
||||||
|
baseWhere.and(like);
|
||||||
|
}
|
||||||
|
|
||||||
|
// base: distinct map_sheet_num, mng_yyyy, map_sheet_name
|
||||||
|
List<Tuple> baseTuples =
|
||||||
|
queryFactory
|
||||||
|
.select(h.mapSheetNum, h.mngYyyy, h.mapSheetName)
|
||||||
|
.distinct()
|
||||||
|
.from(h)
|
||||||
|
.join(i)
|
||||||
|
.on(i.mapidcdNo.eq(h.mapSheetNum), i.useInference.eq(CommonUseStatus.USE))
|
||||||
|
.where(baseWhere)
|
||||||
.fetch();
|
.fetch();
|
||||||
|
|
||||||
|
if (baseTuples.isEmpty()) return List.of();
|
||||||
|
|
||||||
|
List<String> baseNums = baseTuples.stream().map(t -> t.get(h.mapSheetNum)).toList();
|
||||||
|
|
||||||
|
// -----------------------
|
||||||
|
// 2) cmp 집계 (CTE cmp)
|
||||||
|
// map_sheet_num별 max(mng_yyyy <= 2024)
|
||||||
|
// -----------------------
|
||||||
|
List<Tuple> cmpTuples =
|
||||||
|
queryFactory
|
||||||
|
.select(h2.mapSheetNum, h2.mngYyyy.max())
|
||||||
|
.from(h2)
|
||||||
|
.where(
|
||||||
|
h2.mapSheetNum.in(baseNums),
|
||||||
|
h2.mngYyyy.loe(compareYear),
|
||||||
|
h2.dataState.eq("DONE"),
|
||||||
|
h2.useInference.eq("USE"),
|
||||||
|
h2.syncState.eq("DONE").or(h2.syncCheckState.eq("DONE")),
|
||||||
|
cmpTifExists)
|
||||||
|
.groupBy(h2.mapSheetNum)
|
||||||
|
.fetch();
|
||||||
|
|
||||||
|
Map<String, Integer> beforeYearMap = new HashMap<>(cmpTuples.size());
|
||||||
|
for (Tuple t : cmpTuples) {
|
||||||
|
String num = t.get(h2.mapSheetNum);
|
||||||
|
Integer beforeYear = t.get(h2.mngYyyy.max());
|
||||||
|
beforeYearMap.put(num, beforeYear);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------
|
||||||
|
// 3) base JOIN cmp (메모리)
|
||||||
|
// - SQL에서 join cmp c on c.map_sheet_num = b.map_sheet_num 동일
|
||||||
|
// -----------------------
|
||||||
|
List<MngListDto> result = new ArrayList<>();
|
||||||
|
for (Tuple bt : baseTuples) {
|
||||||
|
String num = bt.get(h.mapSheetNum);
|
||||||
|
Integer beforeYear = beforeYearMap.get(num);
|
||||||
|
if (beforeYear == null) continue; // SQL의 inner join cmp 효과
|
||||||
|
|
||||||
|
result.add(
|
||||||
|
new MngListDto(
|
||||||
|
bt.get(h.mngYyyy), // 2026
|
||||||
|
num,
|
||||||
|
bt.get(h.mapSheetName),
|
||||||
|
beforeYear, // <=2024 max
|
||||||
|
null // isSuccess
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1103,42 +1225,161 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MapSheetMngHstEntity> getMapSheetMngHst(Integer year) {
|
public List<MngListDto> getMapSheetMngHst(
|
||||||
return queryFactory
|
Integer year, String mapSheetScope, List<String> mapSheetNum) {
|
||||||
.select(mapSheetMngHstEntity)
|
BooleanBuilder whereBuilder = new BooleanBuilder();
|
||||||
.from(mapSheetMngHstEntity)
|
|
||||||
.innerJoin(mapSheetMngFileEntity)
|
whereBuilder.and(mapSheetMngHstEntity.dataState.eq("DONE"));
|
||||||
.on(mapSheetMngFileEntity.hstUid.eq(mapSheetMngHstEntity.hstUid))
|
whereBuilder.and(
|
||||||
.where(
|
|
||||||
mapSheetMngHstEntity
|
|
||||||
.mngYyyy
|
|
||||||
.eq(year)
|
|
||||||
.and(
|
|
||||||
mapSheetMngHstEntity
|
mapSheetMngHstEntity
|
||||||
.syncState
|
.syncState
|
||||||
.eq("DONE")
|
.eq("DONE")
|
||||||
.or(mapSheetMngHstEntity.syncCheckState.eq("DONE")))
|
.or(mapSheetMngHstEntity.syncCheckState.eq("DONE")));
|
||||||
.and(mapSheetMngFileEntity.fileExt.eq("tif")))
|
whereBuilder.and(mapSheetMngHstEntity.useInference.eq("USE"));
|
||||||
.fetch();
|
|
||||||
|
whereBuilder.and(mapSheetMngHstEntity.mngYyyy.eq(year));
|
||||||
|
|
||||||
|
BooleanBuilder likeBuilder = new BooleanBuilder();
|
||||||
|
|
||||||
|
if (MapSheetScope.PART.getId().equals(mapSheetScope)) {
|
||||||
|
List<String> list = mapSheetNum;
|
||||||
|
if (list == null || list.isEmpty()) {
|
||||||
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
for (String prefix : list) {
|
||||||
public List<MapSheetFallbackYearDto> findFallbackCompareYearByMapSheets(
|
if (prefix == null || prefix.isBlank()) {
|
||||||
Integer year, List<String> mapIds) {
|
continue;
|
||||||
BooleanBuilder builder = new BooleanBuilder();
|
}
|
||||||
builder.and(mapSheetMngYearYnEntity.id.mapSheetNum.in(mapIds));
|
likeBuilder.or(mapSheetMngHstEntity.mapSheetNum.like(prefix.trim() + "%"));
|
||||||
builder.and(mapSheetMngYearYnEntity.id.mngYyyy.lt(year));
|
}
|
||||||
builder.and(mapSheetMngYearYnEntity.yn.eq("Y"));
|
}
|
||||||
|
|
||||||
|
if (likeBuilder.hasValue()) {
|
||||||
|
whereBuilder.and(likeBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(
|
.select(
|
||||||
Projections.constructor(
|
Projections.constructor(
|
||||||
MapSheetFallbackYearDto.class,
|
MngListDto.class,
|
||||||
mapSheetMngYearYnEntity.id.mapSheetNum,
|
mapSheetMngHstEntity.mngYyyy,
|
||||||
mapSheetMngYearYnEntity.id.mngYyyy.max()))
|
mapSheetMngHstEntity.mapSheetNum,
|
||||||
.from(mapSheetMngYearYnEntity)
|
mapSheetMngHstEntity.mapSheetName,
|
||||||
.where(builder)
|
nullExpression(Integer.class),
|
||||||
.groupBy(mapSheetMngYearYnEntity.id.mapSheetNum)
|
nullExpression(Boolean.class)))
|
||||||
|
.from(mapSheetMngHstEntity)
|
||||||
|
.innerJoin(mapInkx5kEntity)
|
||||||
|
.on(
|
||||||
|
mapInkx5kEntity
|
||||||
|
.mapidcdNo
|
||||||
|
.eq(mapSheetMngHstEntity.mapSheetNum)
|
||||||
|
.and(mapInkx5kEntity.useInference.eq(CommonUseStatus.USE)))
|
||||||
|
.where(whereBuilder)
|
||||||
.fetch();
|
.fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MngListDto> findFallbackCompareYearByMapSheets(Integer year, List<String> mapIds) {
|
||||||
|
QMapSheetMngHstEntity h = QMapSheetMngHstEntity.mapSheetMngHstEntity;
|
||||||
|
QMapSheetMngHstEntity h2 = new QMapSheetMngHstEntity("h2");
|
||||||
|
QMapSheetMngFileEntity f = QMapSheetMngFileEntity.mapSheetMngFileEntity;
|
||||||
|
QMapSheetMngFileEntity f2 = new QMapSheetMngFileEntity("f2");
|
||||||
|
QMapInkx5kEntity inkk = QMapInkx5kEntity.mapInkx5kEntity;
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
MngListDto.class,
|
||||||
|
h.mngYyyy,
|
||||||
|
h.mapSheetNum,
|
||||||
|
h.mapSheetName,
|
||||||
|
nullExpression(Integer.class),
|
||||||
|
nullExpression(Boolean.class)))
|
||||||
|
.from(h)
|
||||||
|
.innerJoin(inkk)
|
||||||
|
.on(inkk.mapidcdNo.eq(h.mapSheetNum).and(inkk.useInference.eq(CommonUseStatus.USE)))
|
||||||
|
.where(
|
||||||
|
h.mapSheetNum.in(mapIds),
|
||||||
|
h.mngYyyy.lt(year),
|
||||||
|
h.dataState.eq("DONE"),
|
||||||
|
h.useInference.eq("USE"),
|
||||||
|
h.syncState.eq("DONE").or(h.syncCheckState.eq("DONE")),
|
||||||
|
JPAExpressions.selectOne()
|
||||||
|
.from(f)
|
||||||
|
.where(f.hstUid.eq(h.hstUid), f.fileExt.eq("tif"), f.fileState.eq("DONE"))
|
||||||
|
.exists(),
|
||||||
|
|
||||||
|
// mapSheetNum별 최대 mngYyyy인 행만 남김
|
||||||
|
h.mngYyyy.eq(
|
||||||
|
JPAExpressions.select(h2.mngYyyy.max())
|
||||||
|
.from(h2)
|
||||||
|
.where(
|
||||||
|
h2.mapSheetNum.eq(h.mapSheetNum),
|
||||||
|
h2.mngYyyy.lt(year),
|
||||||
|
h2.dataState.eq("DONE"),
|
||||||
|
h2.useInference.eq("USE"),
|
||||||
|
h2.syncState.eq("DONE").or(h2.syncCheckState.eq("DONE")),
|
||||||
|
JPAExpressions.selectOne()
|
||||||
|
.from(f2)
|
||||||
|
.where(
|
||||||
|
f2.hstUid.eq(h2.hstUid),
|
||||||
|
f2.fileExt.eq("tif"),
|
||||||
|
f2.fileState.eq("DONE"))
|
||||||
|
.exists())))
|
||||||
|
.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countExecutableSheetsDistinct(
|
||||||
|
Integer year, String mapSheetScope, List<String> mapSheetNum) {
|
||||||
|
|
||||||
|
QMapSheetMngHstEntity h = QMapSheetMngHstEntity.mapSheetMngHstEntity;
|
||||||
|
QMapInkx5kEntity i = QMapInkx5kEntity.mapInkx5kEntity;
|
||||||
|
QMapSheetMngFileEntity f = QMapSheetMngFileEntity.mapSheetMngFileEntity;
|
||||||
|
|
||||||
|
BooleanBuilder where = new BooleanBuilder();
|
||||||
|
|
||||||
|
// 실행가능 조건
|
||||||
|
where.and(h.dataState.eq("DONE"));
|
||||||
|
where.and(h.syncState.eq("DONE").or(h.syncCheckState.eq("DONE")));
|
||||||
|
where.and(h.useInference.eq("USE"));
|
||||||
|
where.and(h.mngYyyy.eq(year));
|
||||||
|
|
||||||
|
// tif + DONE 파일 존재 조건 AND EXISTS
|
||||||
|
where.and(
|
||||||
|
JPAExpressions.selectOne()
|
||||||
|
.from(f)
|
||||||
|
.where(f.hstUid.eq(h.hstUid).and(f.fileExt.eq("tif")).and(f.fileState.eq("DONE")))
|
||||||
|
.exists());
|
||||||
|
|
||||||
|
// PART scope prefix 조건
|
||||||
|
if (MapSheetScope.PART.getId().equals(mapSheetScope)) {
|
||||||
|
if (mapSheetNum == null || mapSheetNum.isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BooleanBuilder likeBuilder = new BooleanBuilder();
|
||||||
|
for (String prefix : mapSheetNum) {
|
||||||
|
if (prefix == null || prefix.isBlank()) continue;
|
||||||
|
likeBuilder.or(h.mapSheetNum.like(prefix.trim() + "%"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (likeBuilder.hasValue()) {
|
||||||
|
where.and(likeBuilder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DISTINCT mapSheetNum 기준 카운트
|
||||||
|
Long count =
|
||||||
|
queryFactory
|
||||||
|
.select(h.mapSheetNum.countDistinct())
|
||||||
|
.from(h)
|
||||||
|
.join(i)
|
||||||
|
.on(i.mapidcdNo.eq(h.mapSheetNum).and(i.useInference.eq(CommonUseStatus.USE)))
|
||||||
|
.where(where)
|
||||||
|
.fetchOne();
|
||||||
|
|
||||||
|
return count != null ? count.intValue() : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,12 @@ public interface MembersRepositoryCustom {
|
|||||||
|
|
||||||
boolean existsByEmployeeNo(String employeeNo);
|
boolean existsByEmployeeNo(String employeeNo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 사번으로 사용자 조회
|
||||||
|
*
|
||||||
|
* @param employeeNo 사번
|
||||||
|
* @return 사용자 정보 조회
|
||||||
|
*/
|
||||||
Optional<MemberEntity> findByEmployeeNo(String employeeNo);
|
Optional<MemberEntity> findByEmployeeNo(String employeeNo);
|
||||||
|
|
||||||
Optional<MemberEntity> findByUserId(String userId);
|
Optional<MemberEntity> findByUserId(String userId);
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package com.kamco.cd.kamcoback.scheduler.service;
|
package com.kamco.cd.kamcoback.scheduler.service;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
|
import com.kamco.cd.kamcoback.common.inference.service.InferenceCommonService;
|
||||||
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient;
|
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient;
|
||||||
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult;
|
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult;
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.InferenceBatchSheet;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.InferenceBatchSheet;
|
||||||
@@ -19,7 +18,6 @@ import java.nio.file.Paths;
|
|||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import lombok.extern.log4j.Log4j2;
|
|||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -43,6 +40,7 @@ public class MapSheetInferenceJobService {
|
|||||||
|
|
||||||
private final InferenceResultCoreService inferenceResultCoreService;
|
private final InferenceResultCoreService inferenceResultCoreService;
|
||||||
private final ShpPipelineService shpPipelineService;
|
private final ShpPipelineService shpPipelineService;
|
||||||
|
private final InferenceCommonService inferenceCommonService;
|
||||||
|
|
||||||
private final ExternalHttpClient externalHttpClient;
|
private final ExternalHttpClient externalHttpClient;
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
@@ -357,7 +355,7 @@ public class MapSheetInferenceJobService {
|
|||||||
m.setPriority(5d);
|
m.setPriority(5d);
|
||||||
log.info("[BEFORE INFERENCE] BEFORE SendDto={}", m);
|
log.info("[BEFORE INFERENCE] BEFORE SendDto={}", m);
|
||||||
// 추론 실행 api 호출
|
// 추론 실행 api 호출
|
||||||
Long batchId = ensureAccepted(m);
|
Long batchId = inferenceCommonService.ensureAccepted(m);
|
||||||
|
|
||||||
SaveInferenceAiDto saveInferenceAiDto = new SaveInferenceAiDto();
|
SaveInferenceAiDto saveInferenceAiDto = new SaveInferenceAiDto();
|
||||||
saveInferenceAiDto.setUuid(uuid);
|
saveInferenceAiDto.setUuid(uuid);
|
||||||
@@ -369,73 +367,6 @@ public class MapSheetInferenceJobService {
|
|||||||
inferenceResultCoreService.update(saveInferenceAiDto);
|
inferenceResultCoreService.update(saveInferenceAiDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* api 호출
|
|
||||||
*
|
|
||||||
* @param dto
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
// 같은함수가 왜 두개지
|
|
||||||
private Long ensureAccepted(InferenceSendDto dto) {
|
|
||||||
if (dto == null) {
|
|
||||||
log.warn("not InferenceSendDto dto");
|
|
||||||
throw new CustomApiException("BAD_REQUEST", HttpStatus.BAD_REQUEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1) 요청 로그
|
|
||||||
log.info("");
|
|
||||||
log.info("========================================================");
|
|
||||||
log.info("[SEND INFERENCE] Inference request dto= {}", dto);
|
|
||||||
log.info("========================================================");
|
|
||||||
log.info("");
|
|
||||||
// 2) local 환경 임시 처리
|
|
||||||
// if ("local".equals(profile)) {
|
|
||||||
// if (dto.getPred_requests_areas() == null) {
|
|
||||||
// throw new IllegalStateException("pred_requests_areas is null");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// 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");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 3) HTTP 호출
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
headers.setAccept(List.of(MediaType.APPLICATION_JSON));
|
|
||||||
|
|
||||||
// TODO 어떤 URL로 어떤파리티러로 요청한 로딩해야지
|
|
||||||
ExternalCallResult<String> result =
|
|
||||||
externalHttpClient.call(inferenceUrl, HttpMethod.POST, dto, headers, String.class);
|
|
||||||
|
|
||||||
if (result.statusCode() < 200 || result.statusCode() >= 300) {
|
|
||||||
log.error("Inference API failed. status={}, body={}", result.statusCode(), result.body());
|
|
||||||
throw new CustomApiException("BAD_GATEWAY", HttpStatus.BAD_GATEWAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4) 응답 파싱
|
|
||||||
try {
|
|
||||||
List<Map<String, Object>> list =
|
|
||||||
objectMapper.readValue(result.body(), new TypeReference<>() {});
|
|
||||||
|
|
||||||
if (list.isEmpty()) {
|
|
||||||
// 어떤 URL로 어떤파리티러로 요청한 정보를 봐야 재현을 할듯하지요
|
|
||||||
throw new IllegalStateException("Inference response is empty");
|
|
||||||
}
|
|
||||||
|
|
||||||
Object batchIdObj = list.get(0).get("batch_id");
|
|
||||||
if (batchIdObj == null) {
|
|
||||||
throw new IllegalStateException("batch_id not found in response");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Long.valueOf(batchIdObj.toString());
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Failed to parse inference response. body={}", result.body(), e);
|
|
||||||
throw new CustomApiException("INVALID_INFERENCE_RESPONSE", HttpStatus.BAD_GATEWAY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 실행중인 profile
|
* 실행중인 profile
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user