diff --git a/src/main/java/com/kamco/cd/kamcoback/label/LabelAllocateApiController.java b/src/main/java/com/kamco/cd/kamcoback/label/LabelAllocateApiController.java index 040c0e96..ffdca9fd 100644 --- a/src/main/java/com/kamco/cd/kamcoback/label/LabelAllocateApiController.java +++ b/src/main/java/com/kamco/cd/kamcoback/label/LabelAllocateApiController.java @@ -123,7 +123,7 @@ public class LabelAllocateApiController { int targetYyyy = Integer.parseInt(dto.getYyyy().split("-")[1]); return ApiResponseDto.okObject( labelAllocateService.allocateAsc( - dto.getStage(), dto.getLabelers(), dto.getInspectors(), compareYyyy, targetYyyy)); + dto.getUuid(), dto.getLabelers(), dto.getInspectors(), compareYyyy, targetYyyy)); } @Operation(summary = "작업현황 관리 > 변화탐지 회차 정보", description = "작업현황 관리 > 변화탐지 회차 정보") diff --git a/src/main/java/com/kamco/cd/kamcoback/label/dto/LabelAllocateDto.java b/src/main/java/com/kamco/cd/kamcoback/label/dto/LabelAllocateDto.java index fef1c33e..f07f34ca 100644 --- a/src/main/java/com/kamco/cd/kamcoback/label/dto/LabelAllocateDto.java +++ b/src/main/java/com/kamco/cd/kamcoback/label/dto/LabelAllocateDto.java @@ -86,6 +86,12 @@ public class LabelAllocateDto { @AllArgsConstructor public static class AllocateDto { + @Schema( + description = "회차 마스터 key", + example = "f97dc186-e6d3-4645-9737-3173dde8dc64", + required = true) + private UUID uuid; + @Schema(description = "비교년도-기준년도", example = "2022-2024", required = true) private String yyyy; @@ -95,7 +101,7 @@ public class LabelAllocateDto { // @Schema(description = "기준년도", example = "2024", required = true) // private Integer targetYyyy; - @Schema(description = "회차", example = "4", required = true) + @Schema(description = "회차", example = "4") private Integer stage; @Schema( diff --git a/src/main/java/com/kamco/cd/kamcoback/label/service/LabelAllocateService.java b/src/main/java/com/kamco/cd/kamcoback/label/service/LabelAllocateService.java index 3b070eb6..594972fe 100644 --- a/src/main/java/com/kamco/cd/kamcoback/label/service/LabelAllocateService.java +++ b/src/main/java/com/kamco/cd/kamcoback/label/service/LabelAllocateService.java @@ -18,6 +18,7 @@ import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerListResponse; import com.kamco.cd.kamcoback.postgres.core.LabelAllocateCoreService; import java.util.List; import java.util.Objects; +import java.util.UUID; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; import org.springframework.stereotype.Service; @@ -37,13 +38,13 @@ public class LabelAllocateService { /** * 도엽 기준 asc sorting 해서 할당 수만큼 배정하는 로직 * - * @param stage 회차 + * @param uuid 회차 key * @param targetUsers 라벨러 목록 * @param targetInspectors 검수자 목록 */ @Transactional public ApiResponseDto.ResponseObj allocateAsc( - Integer stage, + UUID uuid, List targetUsers, List targetInspectors, Integer compareYyyy, @@ -51,8 +52,7 @@ public class LabelAllocateService { Long lastId = null; // geom 잔여건수 조회 - Long chargeCnt = - labelAllocateCoreService.findLabelUnAssignedCnt(stage, compareYyyy, targetYyyy); + Long chargeCnt = labelAllocateCoreService.findLabelUnAssignedCnt(uuid); if (chargeCnt <= 0) { return new ApiResponseDto.ResponseObj(ApiResponseCode.DUPLICATE_DATA, "이미 배정완료된 회차 입니다."); } @@ -63,12 +63,10 @@ public class LabelAllocateService { ApiResponseCode.BAD_REQUEST, "총 잔여건수와 요청 값의 합계가 맞지 않습니다."); } - List allIds = - labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage); + List allIds = labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, uuid); // MapSheetAnalInferenceEntity analUid 가져오기 - Long analUid = - labelAllocateCoreService.findMapSheetAnalInferenceUid(compareYyyy, targetYyyy, stage); + Long analUid = labelAllocateCoreService.findMapSheetAnalInferenceUid(uuid); int index = 0; for (TargetUser target : targetUsers) { 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 a5cd7f07..02073b62 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 @@ -27,9 +27,8 @@ public class LabelAllocateCoreService { private final LabelAllocateRepository labelAllocateRepository; - public List fetchNextIds( - Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) { - return labelAllocateRepository.fetchNextIds(lastId, batchSize, compareYyyy, targetYyyy, stage); + public List fetchNextIds(Long lastId, Long batchSize, UUID uuid) { + return labelAllocateRepository.fetchNextIds(lastId, batchSize, uuid); } public void assignOwner(List ids, String userId, Long analUid) { @@ -42,8 +41,8 @@ public class LabelAllocateCoreService { .toList(); } - public Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy) { - return labelAllocateRepository.findLabelUnAssignedCnt(stage, compareYyyy, targetYyyy); + public Long findLabelUnAssignedCnt(UUID uuid) { + return labelAllocateRepository.findLabelUnAssignedCnt(uuid); } public void assignInspector(UUID assignmentUid, String inspectorUid) { @@ -144,8 +143,8 @@ public class LabelAllocateCoreService { return detail; } - public Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage) { - return labelAllocateRepository.findMapSheetAnalInferenceUid(compareYyyy, targetYyyy, stage); + public Long findMapSheetAnalInferenceUid(UUID uuid) { + return labelAllocateRepository.findMapSheetAnalInferenceUid(uuid); } public void insertInspector(Long analUid, String inspector) { 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 bc05fe58..478c1613 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 @@ -20,14 +20,13 @@ import org.springframework.data.domain.Page; public interface LabelAllocateRepositoryCustom { - List fetchNextIds( - Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage); + List fetchNextIds(Long lastId, Long batchSize, UUID uuid); void assignOwner(List ids, String userId, Long analUid); List findAssignedLabelerList(Long analUid); - Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy); + Long findLabelUnAssignedCnt(UUID uuid); void assignInspector(UUID assignmentUid, String userId); @@ -74,7 +73,7 @@ public interface LabelAllocateRepositoryCustom { /** UUID로 analUid 조회 */ Long findAnalUidByUuid(String uuid); - Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage); + Long findMapSheetAnalInferenceUid(UUID uuid); void insertInspector(Long analUid, String inspector); 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 c340eb55..040dfcf7 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 @@ -66,8 +66,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto @PersistenceContext private EntityManager em; @Override - public List fetchNextIds( - Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) { + public List fetchNextIds(Long lastId, Long batchSize, UUID uuid) { return queryFactory .select( @@ -76,14 +75,17 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto mapSheetAnalDataInferenceGeomEntity.geoUid, mapSheetAnalDataInferenceGeomEntity.mapSheetNum, mapSheetAnalDataInferenceGeomEntity.pnu)) - .from(mapSheetAnalDataInferenceGeomEntity) - .where( - lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId), + .from(mapSheetAnalInferenceEntity) + .innerJoin(mapSheetAnalDataInferenceEntity) + .on(mapSheetAnalInferenceEntity.id.eq(mapSheetAnalDataInferenceEntity.analUid)) + .innerJoin(mapSheetAnalDataInferenceGeomEntity) + .on( + mapSheetAnalDataInferenceEntity.id.eq(mapSheetAnalDataInferenceGeomEntity.dataUid), mapSheetAnalDataInferenceGeomEntity.pnu.isNotNull(), - mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy), - mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy), - mapSheetAnalDataInferenceGeomEntity.stage.eq(stage), mapSheetAnalDataInferenceGeomEntity.labelState.isNull()) + .where( + mapSheetAnalInferenceEntity.uuid.eq(uuid), + lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId)) .orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc()) .limit(batchSize) .fetch(); @@ -177,17 +179,19 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto } @Override - public Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy) { + public Long findLabelUnAssignedCnt(UUID uuid) { return queryFactory .select(mapSheetAnalDataInferenceGeomEntity.geoUid.count()) - .from(mapSheetAnalDataInferenceGeomEntity) - .where( + .from(mapSheetAnalInferenceEntity) + .innerJoin(mapSheetAnalDataInferenceEntity) + .on(mapSheetAnalInferenceEntity.id.eq(mapSheetAnalDataInferenceEntity.analUid)) + .innerJoin(mapSheetAnalDataInferenceGeomEntity) + .on( + mapSheetAnalDataInferenceEntity.id.eq(mapSheetAnalDataInferenceGeomEntity.dataUid), mapSheetAnalDataInferenceGeomEntity.pnu.isNotNull(), - mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy), - mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy), - mapSheetAnalDataInferenceGeomEntity.stage.eq(stage), mapSheetAnalDataInferenceGeomEntity.labelState.isNull()) + .where(mapSheetAnalInferenceEntity.uuid.eq(uuid)) .fetchOne(); } @@ -912,14 +916,11 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto } @Override - public Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage) { + public Long findMapSheetAnalInferenceUid(UUID uuid) { return queryFactory .select(mapSheetAnalInferenceEntity.id) .from(mapSheetAnalInferenceEntity) - .where( - mapSheetAnalInferenceEntity.compareYyyy.eq(compareYyyy), - mapSheetAnalInferenceEntity.targetYyyy.eq(targetYyyy), - mapSheetAnalInferenceEntity.stage.eq(stage)) + .where(mapSheetAnalInferenceEntity.uuid.eq(uuid)) .fetchOne(); } diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelWorkRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelWorkRepositoryImpl.java index 99bcb8ae..03aacd43 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelWorkRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelWorkRepositoryImpl.java @@ -138,7 +138,9 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom { mapSheetAnalDataInferenceGeomEntity .pnu .isNotNull() - .and(mapSheetAnalDataInferenceGeomEntity.pnu.ne(0L)) + .and( + mapSheetAnalDataInferenceGeomEntity.pnu + .isNotNull()) // TODO: 이노팸 연동 후 0 이상이라고 해야할 듯 .and(mapSheetAnalDataInferenceGeomEntity.passYn.eq(Boolean.FALSE))) .then(1L) .otherwise(0L)