추론 실행 수정 및 추석 추가 작업중
This commit is contained in:
@@ -246,15 +246,15 @@ public class InferenceResultDto {
|
||||
@NotBlank
|
||||
private String title;
|
||||
|
||||
@Schema(description = "G1", example = "b40e0f68-c1d8-49fc-93f9-a36270093861")
|
||||
@Schema(description = "G1", example = "643adead-f3d2-4f10-9037-862bee919399")
|
||||
@NotNull
|
||||
private UUID model1Uuid;
|
||||
|
||||
@Schema(description = "G2", example = "ec92b7d2-b5a3-4915-9bdf-35fb3ca8ad27")
|
||||
@Schema(description = "G2", example = "dd86b4ef-28e3-4e3d-9ee4-f60d9cb54e13")
|
||||
@NotNull
|
||||
private UUID model2Uuid;
|
||||
|
||||
@Schema(description = "G3", example = "37f45782-8ccf-4cf6-911c-a055a1510d39")
|
||||
@Schema(description = "G3", example = "58c1153e-dec6-4424-82a1-189083a9d9dc")
|
||||
@NotNull
|
||||
private UUID model3Uuid;
|
||||
|
||||
|
||||
@@ -47,14 +47,12 @@ import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
@@ -67,6 +65,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/** 추론 관리 */
|
||||
@Service
|
||||
@Log4j2
|
||||
@RequiredArgsConstructor
|
||||
@@ -199,7 +198,7 @@ public class InferenceResultService {
|
||||
// target 목록 조회
|
||||
List<MngListDto> targetDtoList = mapSheetMngCoreService.getHstMapSheetList(req);
|
||||
|
||||
// target 도엽번호 리스트 추출
|
||||
// target 도엽번호 리스트 추출 중복 제거
|
||||
List<String> targetList =
|
||||
targetDtoList.stream()
|
||||
.map(MngListDto::getMapSheetNum)
|
||||
@@ -207,9 +206,6 @@ public class InferenceResultService {
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
// target 포함 여부 판단
|
||||
Set<String> targetSet = new HashSet<>(targetList);
|
||||
|
||||
// compare 목록 조회
|
||||
List<MapSheetFallbackYearDto> compareDtoList =
|
||||
new ArrayList<>(mapSheetMngCoreService.getMapSheetNumDtoByHst(req.getCompareYyyy()));
|
||||
@@ -221,34 +217,21 @@ public class InferenceResultService {
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// arget에는 있으나 compare에는 없는 도엽 추출
|
||||
// target에는 있으나 compare에는 없는 도엽 추출
|
||||
List<String> remainingTargetList =
|
||||
targetList.stream().filter(s -> !compareSet.contains(s)).toList();
|
||||
|
||||
// fallback년도 도엽 조회
|
||||
// compare에 없을때 이전 년도 사용 가능여부 조회
|
||||
List<MapSheetFallbackYearDto> fallbackYearDtoList =
|
||||
mapSheetMngCoreService.findFallbackCompareYearByMapSheets(
|
||||
req.getTargetYyyy(), // 대상년도 기준
|
||||
remainingTargetList // compare에 없는 도엽들
|
||||
);
|
||||
|
||||
// 기존 compare , fallback 합치기
|
||||
// 기존 compare , 사용가능 이전년도 정보 합치기
|
||||
compareDtoList.addAll(fallbackYearDtoList);
|
||||
|
||||
// mapSheetNum 기준 중복 제거 (기존 compare 우선 유지)
|
||||
compareDtoList =
|
||||
new ArrayList<>(
|
||||
compareDtoList.stream()
|
||||
.filter(d -> d.getMapSheetNum() != null)
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
MapSheetFallbackYearDto::getMapSheetNum,
|
||||
Function.identity(),
|
||||
(existing, replacement) -> existing, // 기존 우선
|
||||
LinkedHashMap::new))
|
||||
.values());
|
||||
|
||||
// 최종 compare 도엽 Set 구성
|
||||
// 중복제거하여 사용할 compare 도엽 목록
|
||||
Set<String> availableCompareSheets =
|
||||
compareDtoList.stream()
|
||||
.map(MapSheetFallbackYearDto::getMapSheetNum)
|
||||
@@ -256,35 +239,11 @@ public class InferenceResultService {
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 최종 추론 대상 도엽
|
||||
// target 중 compare(fallback)에 존재하는 도엽만 추출
|
||||
// target 기준으로 compare 에 존재하는 도엽만 추출
|
||||
List<String> filteredTargetList =
|
||||
targetList.stream().filter(availableCompareSheets::contains).toList();
|
||||
|
||||
// compare only 계산 (target에는 없는 compare 도엽 수)
|
||||
long compareOnlyCount =
|
||||
compareDtoList.stream()
|
||||
.map(MapSheetFallbackYearDto::getMapSheetNum)
|
||||
.filter(s -> s != null && !targetSet.contains(s))
|
||||
.count();
|
||||
|
||||
// 연도별 도엽 비교 로그 출력
|
||||
log.info(
|
||||
"""
|
||||
===== MapSheet Year Comparison =====
|
||||
target Total: {}
|
||||
compare Total: {}
|
||||
Intersection: {}
|
||||
target Only (Excluded): {}
|
||||
compare Only: {}
|
||||
====================================
|
||||
""",
|
||||
targetList.size(), // target count
|
||||
compareDtoList.size(), // compare count
|
||||
filteredTargetList.size(), // target 기준으로 compare 비교하여 최종 추론할 도엽 count
|
||||
targetList.size() - filteredTargetList.size(), // compare에 존재하지 않는 target 도엽 수
|
||||
compareOnlyCount); // target 에 존재하지 않는 compare 도엽수
|
||||
|
||||
// compareDtoList도 최종 교집합 기준으로 필터
|
||||
// compareDtoList도 최종 기준으로 필터
|
||||
Set<String> filteredTargetSet = new HashSet<>(filteredTargetList);
|
||||
|
||||
List<MapSheetFallbackYearDto> filteredCompareDtoList =
|
||||
@@ -293,6 +252,30 @@ public class InferenceResultService {
|
||||
.filter(d -> filteredTargetSet.contains(d.getMapSheetNum()))
|
||||
.toList();
|
||||
|
||||
// compare only 계산 (target에는 없는 compare 도엽 수) log 용
|
||||
long compareOnlyCount =
|
||||
compareDtoList.stream()
|
||||
.map(MapSheetFallbackYearDto::getMapSheetNum)
|
||||
.filter(s -> s != null && !targetList.contains(s))
|
||||
.count();
|
||||
|
||||
// 연도별 도엽 비교 로그 출력
|
||||
log.info(
|
||||
"""
|
||||
===== MapSheet Year Comparison =====
|
||||
target Total: {}
|
||||
compare Total: {}
|
||||
Intersection: {}
|
||||
target Only (Excluded): {}
|
||||
compare Only: {}
|
||||
====================================
|
||||
""",
|
||||
targetList.size(), // target count
|
||||
compareDtoList.size(), // compare count
|
||||
filteredTargetList.size(), // target 기준으로 compare 비교하여 최종 추론할 도엽 count
|
||||
targetList.size() - filteredTargetList.size(), // compare에 존재하지 않는 target 도엽 수
|
||||
compareOnlyCount); // target 에 존재하지 않는 compare 도엽수
|
||||
|
||||
// compare 기준 geojson 생성 (년도 fallback 반영)
|
||||
Scene compareScene =
|
||||
getSceneInference(
|
||||
@@ -604,7 +587,7 @@ public class InferenceResultService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 추론 AI API 호출
|
||||
* 추론 AI API 호출 batch id를 리턴
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
@@ -636,6 +619,7 @@ public class InferenceResultService {
|
||||
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);
|
||||
|
||||
@@ -650,12 +634,14 @@ public class InferenceResultService {
|
||||
objectMapper.readValue(result.body(), new TypeReference<>() {});
|
||||
|
||||
if (list.isEmpty()) {
|
||||
throw new IllegalStateException("Inference response is empty");
|
||||
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 IllegalStateException("batch_id not found in response");
|
||||
throw new CustomApiException(
|
||||
"NOT_FOUND", HttpStatus.NOT_FOUND, "batch_id not found in response");
|
||||
}
|
||||
|
||||
return Long.valueOf(batchIdObj.toString());
|
||||
@@ -674,6 +660,7 @@ public class InferenceResultService {
|
||||
*/
|
||||
private InferenceSendDto getModelInfo(UUID uuid) {
|
||||
|
||||
// 모델정보 조회
|
||||
Basic modelInfo = modelMngCoreService.findByModelUuid(uuid);
|
||||
|
||||
String cdModelPath = "";
|
||||
|
||||
@@ -369,6 +369,12 @@ public class InferenceResultCoreService {
|
||||
return mapSheetLearnRepository.getInferenceServerStatusList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 진행중 배치 조회
|
||||
*
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
public InferenceBatchSheet getInferenceResultByStatus(String status) {
|
||||
MapSheetLearnEntity entity =
|
||||
mapSheetLearnRepository.getInferenceResultByStatus(status).orElse(null);
|
||||
@@ -403,6 +409,12 @@ public class InferenceResultCoreService {
|
||||
return mapSheetLearnRepository.getInferenceAiResultById(id, modelUuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 추론 진행 현황 상세
|
||||
*
|
||||
* @param uuid
|
||||
* @return
|
||||
*/
|
||||
public InferenceStatusDetailDto getInferenceStatus(UUID uuid) {
|
||||
return mapSheetLearnRepository.getInferenceStatus(uuid);
|
||||
}
|
||||
|
||||
@@ -367,6 +367,7 @@ public class MapSheetMngCoreService {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
// 년도 별로 루프를 돌리기위해 년도별 정리
|
||||
Map<Integer, List<MapSheetFallbackYearDto>> groupedByYear =
|
||||
yearDtos.stream()
|
||||
.filter(d -> d.getMngYyyy() != null && d.getMapSheetNum() != null)
|
||||
@@ -377,6 +378,7 @@ public class MapSheetMngCoreService {
|
||||
for (Map.Entry<Integer, List<MapSheetFallbackYearDto>> entry : groupedByYear.entrySet()) {
|
||||
Integer year = entry.getKey();
|
||||
|
||||
// 년도별 mapSheetNum 만들기
|
||||
List<String> sheetNums =
|
||||
entry.getValue().stream()
|
||||
.map(MapSheetFallbackYearDto::getMapSheetNum)
|
||||
@@ -384,6 +386,7 @@ public class MapSheetMngCoreService {
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
// tif파일 정보 조회
|
||||
List<ImageFeature> temp = mapSheetMngRepository.getSceneInference(year.toString(), sheetNums);
|
||||
|
||||
if (temp != null && !temp.isEmpty()) {
|
||||
@@ -433,6 +436,12 @@ public class MapSheetMngCoreService {
|
||||
return entity.stream().map(MapSheetMngHstEntity::getMapSheetNum).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 연도의 도엽 이력 데이터를 조회
|
||||
*
|
||||
* @param year
|
||||
* @return
|
||||
*/
|
||||
public List<MapSheetFallbackYearDto> getMapSheetNumDtoByHst(Integer year) {
|
||||
List<MapSheetMngHstEntity> entity = mapSheetMngRepository.getMapSheetMngHst(year);
|
||||
return entity.stream()
|
||||
|
||||
@@ -18,29 +18,101 @@ import org.springframework.data.domain.Page;
|
||||
|
||||
public interface MapSheetLearnRepositoryCustom {
|
||||
|
||||
/**
|
||||
* 추론 관리 목록 조회
|
||||
*
|
||||
* @param req 추론관리 목록 화면 조회 조건
|
||||
* @return 추론 관리 목록
|
||||
*/
|
||||
Page<MapSheetLearnEntity> getInferenceMgnResultList(InferenceResultDto.SearchListReq req);
|
||||
|
||||
/**
|
||||
* uuid 조건으로 추론 실행 정보 조회
|
||||
*
|
||||
* @param uuid uuid
|
||||
* @return 추론 실행 정보
|
||||
*/
|
||||
Optional<MapSheetLearnEntity> getInferenceResultByUuid(UUID uuid);
|
||||
|
||||
/**
|
||||
* 추론 실행중 서버정보 조회 cpu, gpu
|
||||
*
|
||||
* @return cpu, gpu 정보
|
||||
*/
|
||||
List<InferenceServerStatusDto> getInferenceServerStatusList();
|
||||
|
||||
/**
|
||||
* 추론 실행 목록 진행 상태별 조회
|
||||
*
|
||||
* @param status 추론 진행 상태
|
||||
* @return 추론 실행 정보
|
||||
*/
|
||||
Optional<MapSheetLearnEntity> getInferenceResultByStatus(String status);
|
||||
|
||||
/**
|
||||
* 등록된 추론 실행목록 및 등록된 모델 정보 조회
|
||||
*
|
||||
* @param id 추론 실행 테이블 id
|
||||
* @param modelUuid 모델 uuid
|
||||
* @return 모델 정보
|
||||
*/
|
||||
InferenceProgressDto getInferenceAiResultById(Long id, UUID modelUuid);
|
||||
|
||||
/**
|
||||
* 진행중인 추론 정보 상세 조회
|
||||
*
|
||||
* @param uuid 추론진행 uuid
|
||||
* @return 진행중인 추론정보 상세 정보
|
||||
*/
|
||||
InferenceStatusDetailDto getInferenceStatus(UUID uuid);
|
||||
|
||||
/**
|
||||
* 진행중인 추론이 있는지 조회
|
||||
*
|
||||
* @return 진행중인 추론 정보
|
||||
*/
|
||||
MapSheetLearnEntity getProcessing();
|
||||
|
||||
Integer getLearnStage(Integer compareYear, Integer targetYear);
|
||||
|
||||
/**
|
||||
* 추론 결과 정보 조회
|
||||
*
|
||||
* @param uuid 추론 uuid
|
||||
* @return 추론 결과 및 사용 모델 정보
|
||||
*/
|
||||
AnalResultInfo getInferenceResultInfo(UUID uuid);
|
||||
|
||||
/**
|
||||
* 추론 결과 bbox, point 조회
|
||||
*
|
||||
* @param uuid 추론 uuid
|
||||
* @return bbox, pont 정보
|
||||
*/
|
||||
BboxPointDto getBboxPoint(UUID uuid);
|
||||
|
||||
/**
|
||||
* 분류별 탐지건수 조회
|
||||
*
|
||||
* @param uuid 추론 uuid
|
||||
* @return 분류별 탐지건수 정보
|
||||
*/
|
||||
List<Dashboard> getInferenceClassCountList(UUID uuid);
|
||||
|
||||
/**
|
||||
* 추론 결과 상세 geom 목록 조회
|
||||
*
|
||||
* @param uuid 추론 uuid
|
||||
* @param searchGeoReq 추론 결과 상세화면 geom 조회 조건
|
||||
* @return geom 목록 정보
|
||||
*/
|
||||
Page<Geom> getInferenceGeomList(UUID uuid, SearchGeoReq searchGeoReq);
|
||||
|
||||
/**
|
||||
* 국유in연동 가능여부 확인 조회
|
||||
*
|
||||
* @param uuid 추론 uuid
|
||||
* @return 추론 존재여부, 부분도엽 여부, 추론 진행중 여부, 국유인 작업 진행중 여부
|
||||
*/
|
||||
GukYuinLinkFacts findLinkFacts(UUID uuid);
|
||||
}
|
||||
|
||||
@@ -528,6 +528,7 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
|
||||
@Override
|
||||
public GukYuinLinkFacts findLinkFacts(UUID uuid) {
|
||||
|
||||
// 해당 추론 있는지 확인
|
||||
MapSheetLearnEntity learn =
|
||||
queryFactory
|
||||
.selectFrom(QMapSheetLearnEntity.mapSheetLearnEntity)
|
||||
@@ -538,12 +539,14 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
|
||||
return new GukYuinLinkFacts(false, false, false, false);
|
||||
}
|
||||
|
||||
// 부분 도엽 실행인지 확인
|
||||
boolean isPartScope = MapSheetScope.PART.getId().equals(learn.getMapSheetScope());
|
||||
|
||||
QMapSheetAnalInferenceEntity inf = QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
|
||||
QMapSheetLearnEntity learn2 = new QMapSheetLearnEntity("learn2");
|
||||
QMapSheetLearnEntity learnQ = QMapSheetLearnEntity.mapSheetLearnEntity;
|
||||
|
||||
// 실행중인 추론 있는지 확인
|
||||
boolean hasRunningInference =
|
||||
queryFactory
|
||||
.selectOne()
|
||||
@@ -557,6 +560,7 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
|
||||
.fetchFirst()
|
||||
!= null;
|
||||
|
||||
// 국유인 작업 진행중 있는지 확인
|
||||
boolean hasOtherUnfinishedGukYuin =
|
||||
queryFactory
|
||||
.selectOne()
|
||||
|
||||
Reference in New Issue
Block a user