From 366262099cf0fd388e20f0ac3350d301bb9a4e6f Mon Sep 17 00:00:00 2001 From: DanielLee <198891672+sanghyeonhd@users.noreply.github.com> Date: Mon, 5 Jan 2026 17:28:19 +0900 Subject: [PATCH] =?UTF-8?q?UUID=20=EC=B5=9C=EC=8B=A0=EC=88=9C=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=A0=84=EC=B2=B4=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/LabelAllocateCoreService.java | 4 ++ .../label/LabelAllocateRepositoryCustom.java | 3 ++ .../label/LabelAllocateRepositoryImpl.java | 54 ++++++++++++++++--- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/core/LabelAllocateCoreService.java b/src/main/java/com/kamco/cd/kamcoback/postgres/core/LabelAllocateCoreService.java index ca31c812..d7e68d77 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/core/LabelAllocateCoreService.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/core/LabelAllocateCoreService.java @@ -60,6 +60,10 @@ public class LabelAllocateCoreService { return labelAllocateRepository.findLatestProjectInfo(); } + public UUID findLastLabelWorkState() { + return labelAllocateRepository.findLastLabelWorkState(); + } + public List findWorkerStatistics( Long analUid, String workerType, String search, String sortType) { return labelAllocateRepository.findWorkerStatistics(analUid, workerType, search, sortType); diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelAllocateRepositoryCustom.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelAllocateRepositoryCustom.java index 187ded4d..4f296843 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelAllocateRepositoryCustom.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelAllocateRepositoryCustom.java @@ -36,6 +36,9 @@ public interface LabelAllocateRepositoryCustom { // 최신 프로젝트 정보 조회 (analUid 없이) ProjectInfo findLatestProjectInfo(); + // 최신 작업 상태의 UUID 조회 + UUID findLastLabelWorkState(); + // 작업자 통계 조회 List findWorkerStatistics( Long analUid, String workerType, String search, String sortType); diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelAllocateRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelAllocateRepositoryImpl.java index 03dd8859..05b09d26 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelAllocateRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelAllocateRepositoryImpl.java @@ -21,6 +21,7 @@ import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics; import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity; import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalInferenceEntity; import com.kamco.cd.kamcoback.postgres.entity.QMemberEntity; +import com.querydsl.core.BooleanBuilder; import com.querydsl.core.types.Expression; import com.querydsl.core.types.Projections; import com.querydsl.core.types.dsl.BooleanExpression; @@ -690,7 +691,14 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto @Override public ProjectInfo findLatestProjectInfo() { - // 최신 target_yyyy를 기준으로 프로젝트 정보 조회 + // 최근 집계용 UUID 조회 - 작업이 할당된 최신 프로젝트 우선 + UUID uuid = findLastLabelWorkState(); + + if (uuid == null) { + return null; + } + + // UUID로 프로젝트 정보 조회 var result = queryFactory .select( @@ -701,11 +709,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto mapSheetAnalInferenceEntity.createdDttm, mapSheetAnalInferenceEntity.uuid) .from(mapSheetAnalInferenceEntity) - .orderBy( - mapSheetAnalInferenceEntity.targetYyyy.desc(), - mapSheetAnalInferenceEntity.compareYyyy.desc(), - mapSheetAnalInferenceEntity.createdDttm.desc()) - .limit(1) + .where(mapSheetAnalInferenceEntity.uuid.eq(uuid)) .fetchOne(); if (result == null) { @@ -717,7 +721,6 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto Integer stage = result.get(mapSheetAnalInferenceEntity.stage); ZonedDateTime gukyuinApplyDttm = result.get(mapSheetAnalInferenceEntity.gukyuinApplyDttm); ZonedDateTime createdDttm = result.get(mapSheetAnalInferenceEntity.createdDttm); - UUID uuid = result.get(mapSheetAnalInferenceEntity.uuid); // 변화탐지년도 생성 String detectionYear = @@ -731,10 +734,45 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto .stage(round) .gukyuinApplyDttm(gukyuinApplyDttm) .startDttm(createdDttm) - .uuid(uuid != null ? uuid.toString() : null) + .uuid(uuid.toString()) .build(); } + @Override + public UUID findLastLabelWorkState() { + BooleanBuilder whereBuilder = new BooleanBuilder(); + + // 1. 작업이 할당된 프로젝트 중 최신 UUID 조회 + UUID uuid = + queryFactory + .select(mapSheetAnalInferenceEntity.uuid) + .from(mapSheetAnalInferenceEntity) + .innerJoin(labelingAssignmentEntity) + .on(mapSheetAnalInferenceEntity.id.eq(labelingAssignmentEntity.analUid)) + .where(whereBuilder) + .orderBy( + mapSheetAnalInferenceEntity.compareYyyy.desc(), + mapSheetAnalInferenceEntity.targetYyyy.desc(), + mapSheetAnalInferenceEntity.stage.desc()) + .fetchFirst(); + + // 2. 작업이 할당된 프로젝트가 없으면 전체 프로젝트 중 최신 UUID 조회 + if (uuid == null) { + uuid = + queryFactory + .select(mapSheetAnalInferenceEntity.uuid) + .from(mapSheetAnalInferenceEntity) + .where(whereBuilder) + .orderBy( + mapSheetAnalInferenceEntity.compareYyyy.desc(), + mapSheetAnalInferenceEntity.targetYyyy.desc(), + mapSheetAnalInferenceEntity.stage.desc()) + .fetchFirst(); + } + + return uuid; + } + @Override public Page findLabelerDailyStat( LabelAllocateDto.searchReq searchReq, String uuid, String userId) {