라벨링 작업할당 stage 조회 제거하기

This commit is contained in:
2026-01-20 10:19:41 +09:00
parent 7471322664
commit 9090c94611
7 changed files with 46 additions and 41 deletions

View File

@@ -123,7 +123,7 @@ public class LabelAllocateApiController {
int targetYyyy = Integer.parseInt(dto.getYyyy().split("-")[1]); int targetYyyy = Integer.parseInt(dto.getYyyy().split("-")[1]);
return ApiResponseDto.okObject( return ApiResponseDto.okObject(
labelAllocateService.allocateAsc( labelAllocateService.allocateAsc(
dto.getStage(), dto.getLabelers(), dto.getInspectors(), compareYyyy, targetYyyy)); dto.getUuid(), dto.getLabelers(), dto.getInspectors(), compareYyyy, targetYyyy));
} }
@Operation(summary = "작업현황 관리 > 변화탐지 회차 정보", description = "작업현황 관리 > 변화탐지 회차 정보") @Operation(summary = "작업현황 관리 > 변화탐지 회차 정보", description = "작업현황 관리 > 변화탐지 회차 정보")

View File

@@ -86,6 +86,12 @@ public class LabelAllocateDto {
@AllArgsConstructor @AllArgsConstructor
public static class AllocateDto { 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) @Schema(description = "비교년도-기준년도", example = "2022-2024", required = true)
private String yyyy; private String yyyy;
@@ -95,7 +101,7 @@ public class LabelAllocateDto {
// @Schema(description = "기준년도", example = "2024", required = true) // @Schema(description = "기준년도", example = "2024", required = true)
// private Integer targetYyyy; // private Integer targetYyyy;
@Schema(description = "회차", example = "4", required = true) @Schema(description = "회차", example = "4")
private Integer stage; private Integer stage;
@Schema( @Schema(

View File

@@ -18,6 +18,7 @@ import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerListResponse;
import com.kamco.cd.kamcoback.postgres.core.LabelAllocateCoreService; import com.kamco.cd.kamcoback.postgres.core.LabelAllocateCoreService;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -37,13 +38,13 @@ public class LabelAllocateService {
/** /**
* 도엽 기준 asc sorting 해서 할당 수만큼 배정하는 로직 * 도엽 기준 asc sorting 해서 할당 수만큼 배정하는 로직
* *
* @param stage 회차 * @param uuid 회차 key
* @param targetUsers 라벨러 목록 * @param targetUsers 라벨러 목록
* @param targetInspectors 검수자 목록 * @param targetInspectors 검수자 목록
*/ */
@Transactional @Transactional
public ApiResponseDto.ResponseObj allocateAsc( public ApiResponseDto.ResponseObj allocateAsc(
Integer stage, UUID uuid,
List<TargetUser> targetUsers, List<TargetUser> targetUsers,
List<String> targetInspectors, List<String> targetInspectors,
Integer compareYyyy, Integer compareYyyy,
@@ -51,8 +52,7 @@ public class LabelAllocateService {
Long lastId = null; Long lastId = null;
// geom 잔여건수 조회 // geom 잔여건수 조회
Long chargeCnt = Long chargeCnt = labelAllocateCoreService.findLabelUnAssignedCnt(uuid);
labelAllocateCoreService.findLabelUnAssignedCnt(stage, compareYyyy, targetYyyy);
if (chargeCnt <= 0) { if (chargeCnt <= 0) {
return new ApiResponseDto.ResponseObj(ApiResponseCode.DUPLICATE_DATA, "이미 배정완료된 회차 입니다."); return new ApiResponseDto.ResponseObj(ApiResponseCode.DUPLICATE_DATA, "이미 배정완료된 회차 입니다.");
} }
@@ -63,12 +63,10 @@ public class LabelAllocateService {
ApiResponseCode.BAD_REQUEST, "총 잔여건수와 요청 값의 합계가 맞지 않습니다."); ApiResponseCode.BAD_REQUEST, "총 잔여건수와 요청 값의 합계가 맞지 않습니다.");
} }
List<AllocateInfoDto> allIds = List<AllocateInfoDto> allIds = labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, uuid);
labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage);
// MapSheetAnalInferenceEntity analUid 가져오기 // MapSheetAnalInferenceEntity analUid 가져오기
Long analUid = Long analUid = labelAllocateCoreService.findMapSheetAnalInferenceUid(uuid);
labelAllocateCoreService.findMapSheetAnalInferenceUid(compareYyyy, targetYyyy, stage);
int index = 0; int index = 0;
for (TargetUser target : targetUsers) { for (TargetUser target : targetUsers) {

View File

@@ -27,9 +27,8 @@ public class LabelAllocateCoreService {
private final LabelAllocateRepository labelAllocateRepository; private final LabelAllocateRepository labelAllocateRepository;
public List<AllocateInfoDto> fetchNextIds( public List<AllocateInfoDto> fetchNextIds(Long lastId, Long batchSize, UUID uuid) {
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) { return labelAllocateRepository.fetchNextIds(lastId, batchSize, uuid);
return labelAllocateRepository.fetchNextIds(lastId, batchSize, compareYyyy, targetYyyy, stage);
} }
public void assignOwner(List<AllocateInfoDto> ids, String userId, Long analUid) { public void assignOwner(List<AllocateInfoDto> ids, String userId, Long analUid) {
@@ -42,8 +41,8 @@ public class LabelAllocateCoreService {
.toList(); .toList();
} }
public Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy) { public Long findLabelUnAssignedCnt(UUID uuid) {
return labelAllocateRepository.findLabelUnAssignedCnt(stage, compareYyyy, targetYyyy); return labelAllocateRepository.findLabelUnAssignedCnt(uuid);
} }
public void assignInspector(UUID assignmentUid, String inspectorUid) { public void assignInspector(UUID assignmentUid, String inspectorUid) {
@@ -144,8 +143,8 @@ public class LabelAllocateCoreService {
return detail; return detail;
} }
public Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage) { public Long findMapSheetAnalInferenceUid(UUID uuid) {
return labelAllocateRepository.findMapSheetAnalInferenceUid(compareYyyy, targetYyyy, stage); return labelAllocateRepository.findMapSheetAnalInferenceUid(uuid);
} }
public void insertInspector(Long analUid, String inspector) { public void insertInspector(Long analUid, String inspector) {

View File

@@ -20,14 +20,13 @@ import org.springframework.data.domain.Page;
public interface LabelAllocateRepositoryCustom { public interface LabelAllocateRepositoryCustom {
List<AllocateInfoDto> fetchNextIds( List<AllocateInfoDto> fetchNextIds(Long lastId, Long batchSize, UUID uuid);
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage);
void assignOwner(List<AllocateInfoDto> ids, String userId, Long analUid); void assignOwner(List<AllocateInfoDto> ids, String userId, Long analUid);
List<LabelingAssignmentEntity> findAssignedLabelerList(Long analUid); List<LabelingAssignmentEntity> findAssignedLabelerList(Long analUid);
Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy); Long findLabelUnAssignedCnt(UUID uuid);
void assignInspector(UUID assignmentUid, String userId); void assignInspector(UUID assignmentUid, String userId);
@@ -74,7 +73,7 @@ public interface LabelAllocateRepositoryCustom {
/** UUID로 analUid 조회 */ /** UUID로 analUid 조회 */
Long findAnalUidByUuid(String uuid); Long findAnalUidByUuid(String uuid);
Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage); Long findMapSheetAnalInferenceUid(UUID uuid);
void insertInspector(Long analUid, String inspector); void insertInspector(Long analUid, String inspector);

View File

@@ -66,8 +66,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
@PersistenceContext private EntityManager em; @PersistenceContext private EntityManager em;
@Override @Override
public List<AllocateInfoDto> fetchNextIds( public List<AllocateInfoDto> fetchNextIds(Long lastId, Long batchSize, UUID uuid) {
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
return queryFactory return queryFactory
.select( .select(
@@ -76,14 +75,17 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
mapSheetAnalDataInferenceGeomEntity.geoUid, mapSheetAnalDataInferenceGeomEntity.geoUid,
mapSheetAnalDataInferenceGeomEntity.mapSheetNum, mapSheetAnalDataInferenceGeomEntity.mapSheetNum,
mapSheetAnalDataInferenceGeomEntity.pnu)) mapSheetAnalDataInferenceGeomEntity.pnu))
.from(mapSheetAnalDataInferenceGeomEntity) .from(mapSheetAnalInferenceEntity)
.where( .innerJoin(mapSheetAnalDataInferenceEntity)
lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId), .on(mapSheetAnalInferenceEntity.id.eq(mapSheetAnalDataInferenceEntity.analUid))
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
.on(
mapSheetAnalDataInferenceEntity.id.eq(mapSheetAnalDataInferenceGeomEntity.dataUid),
mapSheetAnalDataInferenceGeomEntity.pnu.isNotNull(), mapSheetAnalDataInferenceGeomEntity.pnu.isNotNull(),
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceGeomEntity.stage.eq(stage),
mapSheetAnalDataInferenceGeomEntity.labelState.isNull()) mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
.where(
mapSheetAnalInferenceEntity.uuid.eq(uuid),
lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId))
.orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc()) .orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc())
.limit(batchSize) .limit(batchSize)
.fetch(); .fetch();
@@ -177,17 +179,19 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
} }
@Override @Override
public Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy) { public Long findLabelUnAssignedCnt(UUID uuid) {
return queryFactory return queryFactory
.select(mapSheetAnalDataInferenceGeomEntity.geoUid.count()) .select(mapSheetAnalDataInferenceGeomEntity.geoUid.count())
.from(mapSheetAnalDataInferenceGeomEntity) .from(mapSheetAnalInferenceEntity)
.where( .innerJoin(mapSheetAnalDataInferenceEntity)
.on(mapSheetAnalInferenceEntity.id.eq(mapSheetAnalDataInferenceEntity.analUid))
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
.on(
mapSheetAnalDataInferenceEntity.id.eq(mapSheetAnalDataInferenceGeomEntity.dataUid),
mapSheetAnalDataInferenceGeomEntity.pnu.isNotNull(), mapSheetAnalDataInferenceGeomEntity.pnu.isNotNull(),
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceGeomEntity.stage.eq(stage),
mapSheetAnalDataInferenceGeomEntity.labelState.isNull()) mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
.where(mapSheetAnalInferenceEntity.uuid.eq(uuid))
.fetchOne(); .fetchOne();
} }
@@ -912,14 +916,11 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
} }
@Override @Override
public Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage) { public Long findMapSheetAnalInferenceUid(UUID uuid) {
return queryFactory return queryFactory
.select(mapSheetAnalInferenceEntity.id) .select(mapSheetAnalInferenceEntity.id)
.from(mapSheetAnalInferenceEntity) .from(mapSheetAnalInferenceEntity)
.where( .where(mapSheetAnalInferenceEntity.uuid.eq(uuid))
mapSheetAnalInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalInferenceEntity.stage.eq(stage))
.fetchOne(); .fetchOne();
} }

View File

@@ -138,7 +138,9 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
mapSheetAnalDataInferenceGeomEntity mapSheetAnalDataInferenceGeomEntity
.pnu .pnu
.isNotNull() .isNotNull()
.and(mapSheetAnalDataInferenceGeomEntity.pnu.ne(0L)) .and(
mapSheetAnalDataInferenceGeomEntity.pnu
.isNotNull()) // TODO: 이노팸 연동 후 0 이상이라고 해야할 듯
.and(mapSheetAnalDataInferenceGeomEntity.passYn.eq(Boolean.FALSE))) .and(mapSheetAnalDataInferenceGeomEntity.passYn.eq(Boolean.FALSE)))
.then(1L) .then(1L)
.otherwise(0L) .otherwise(0L)