From 31ddf6cd524464ed8f18d3866fbe563f4a6e71c3 Mon Sep 17 00:00:00 2001 From: teddy Date: Mon, 26 Jan 2026 13:55:29 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=EC=9D=98=20?= =?UTF-8?q?=ED=83=90=EC=A7=80=EA=B1=B4=EC=88=98=EC=99=80=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=EC=9D=98=20=ED=83=90=EC=A7=80=EA=B1=B4=EC=88=98=20?= =?UTF-8?q?=EB=B6=88=EC=9D=BC=EC=B9=98=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/InferenceResultCoreService.java | 12 +++++--- .../ChangeDetectionRepositoryImpl.java | 28 +++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/core/InferenceResultCoreService.java b/src/main/java/com/kamco/cd/kamcoback/postgres/core/InferenceResultCoreService.java index 1f0202c8..ac81238e 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/core/InferenceResultCoreService.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/core/InferenceResultCoreService.java @@ -506,10 +506,14 @@ public class InferenceResultCoreService { * @return */ public InferenceLearnDto getInferenceUid(UUID uuid) { - MapSheetLearnEntity entity = - inferenceResultRepository - .getInferenceUid(uuid) - .orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND)); + MapSheetLearnEntity entity = inferenceResultRepository.getInferenceUid(uuid).orElse(null); + if (entity == null) { + throw new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND); + } + // inferenceResultRepository + // .getInferenceUid(uuid) + // .orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", + // HttpStatus.NOT_FOUND)); InferenceLearnDto dto = new InferenceLearnDto(); dto.setUid(entity.getUid()); dto.setM1ModelBatchId(entity.getM1ModelBatchId()); diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/changedetection/ChangeDetectionRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/changedetection/ChangeDetectionRepositoryImpl.java index ed634a0c..0cb431fe 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/changedetection/ChangeDetectionRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/changedetection/ChangeDetectionRepositoryImpl.java @@ -7,6 +7,7 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceE import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity; import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity; import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalSttcEntity.mapSheetAnalSttcEntity; +import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnEntity.mapSheetLearnEntity; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; @@ -15,7 +16,9 @@ import com.kamco.cd.kamcoback.changedetection.dto.ChangeDetectionDto; import com.kamco.cd.kamcoback.changedetection.dto.ChangeDetectionDto.DetectSearchType; import com.kamco.cd.kamcoback.changedetection.dto.ChangeDetectionDto.MapScaleType; import com.kamco.cd.kamcoback.changedetection.dto.ChangeDetectionDto.MapSheetList; +import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.Status; import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataInferenceGeomEntity; +import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceEntity; import com.querydsl.core.types.Projections; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.CaseBuilder; @@ -171,18 +174,27 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport @Override public List getChangeDetectionYearList() { + QMapSheetAnalDataInferenceEntity d = new QMapSheetAnalDataInferenceEntity("d2"); + return queryFactory .select( Projections.constructor( ChangeDetectionDto.AnalYearList.class, - mapSheetAnalInferenceEntity.uuid, - mapSheetAnalInferenceEntity.id, - mapSheetAnalInferenceEntity.analTitle, - mapSheetAnalInferenceEntity.compareYyyy.as("beforeYear"), - mapSheetAnalInferenceEntity.targetYyyy.as("afterYear"), - mapSheetAnalInferenceEntity.baseMapSheetNum)) - .from(mapSheetAnalInferenceEntity) - .orderBy(mapSheetAnalInferenceEntity.id.asc()) + mapSheetLearnEntity.uuid, + mapSheetLearnEntity.id, + mapSheetLearnEntity.title, + mapSheetLearnEntity.compareYyyy.as("beforeYear"), + mapSheetLearnEntity.targetYyyy.as("afterYear"), + Expressions.stringTemplate( + "cast({0} as string)", + JPAExpressions.select(d.mapSheetNum.max()) + .from(d) + .where(d.analUid.eq(mapSheetAnalInferenceEntity.id))))) + .from(mapSheetLearnEntity) + .leftJoin(mapSheetAnalInferenceEntity) + .on(mapSheetAnalInferenceEntity.learnId.eq(mapSheetLearnEntity.id)) + .where(mapSheetLearnEntity.status.eq(Status.END.getId())) + .orderBy(mapSheetLearnEntity.id.asc()) .fetch(); }