Merge branch 'feat/dev_251201' of https://10.100.0.10:3210/dabeeo/kamco-dabeeo-backoffice into feat/dev_251201

# Conflicts:
#	src/main/java/com/kamco/cd/kamcoback/label/LabelAllocateApiController.java
#	src/main/java/com/kamco/cd/kamcoback/label/service/LabelAllocateService.java
#	src/main/java/com/kamco/cd/kamcoback/postgres/core/LabelAllocateCoreService.java
#	src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelAllocateRepositoryImpl.java
This commit is contained in:
2026-01-05 13:34:21 +09:00
6 changed files with 688 additions and 487 deletions

View File

@@ -5,7 +5,6 @@ import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InferenceDetail; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InferenceDetail;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelerDetail; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelerDetail;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelingStatDto;
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerListResponse; import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerListResponse;
import com.kamco.cd.kamcoback.label.service.LabelAllocateService; import com.kamco.cd.kamcoback.label.service.LabelAllocateService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@@ -19,7 +18,6 @@ import jakarta.validation.Valid;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@@ -38,118 +36,120 @@ public class LabelAllocateApiController {
@Operation(summary = "배정 가능한 사용자 목록 조회", description = "라벨링 작업 배정을 위한 활성 상태의 사용자 목록을 조회합니다.") @Operation(summary = "배정 가능한 사용자 목록 조회", description = "라벨링 작업 배정을 위한 활성 상태의 사용자 목록을 조회합니다.")
@ApiResponses( @ApiResponses(
value = { value = {
@ApiResponse(responseCode = "200", description = "조회 성공"), @ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음"), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음"),
@ApiResponse(responseCode = "500", description = "서버 오류") @ApiResponse(responseCode = "500", description = "서버 오류")
}) })
@GetMapping("/avail-user") @GetMapping("/avail-user")
public ApiResponseDto<List<LabelAllocateDto.UserList>> availUserList( public ApiResponseDto<List<LabelAllocateDto.UserList>> availUserList(
@Parameter( @Parameter(
description = "사용자 역할", description = "사용자 역할",
example = "LABELER", example = "LABELER",
schema = @Schema(allowableValues = {"LABELER", "REVIEWER"})) schema = @Schema(allowableValues = {"LABELER", "REVIEWER"}))
@RequestParam @RequestParam
String role) { String role) {
return ApiResponseDto.ok(labelAllocateService.availUserList(role)); return ApiResponseDto.ok(labelAllocateService.availUserList(role));
} }
@Operation( @Operation(
summary = "작업현황 관리 (라벨링, 검수 진행률 요약정보, 작업자 목록)", summary = "작업현황 관리 (라벨링, 검수 진행률 요약정보, 작업자 목록)",
description = "작업현황 관리 (라벨링, 검수 진행률 요약정보, 작업자 목록)") description = "작업현황 관리 (라벨링, 검수 진행률 요약정보, 작업자 목록)")
@ApiResponses( @ApiResponses(
value = { value = {
@ApiResponse(responseCode = "200", description = "조회 성공"), @ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "404", description = "데이터를 찾을 수 없음"), @ApiResponse(responseCode = "404", description = "데이터를 찾을 수 없음"),
@ApiResponse(responseCode = "500", description = "서버 오류") @ApiResponse(responseCode = "500", description = "서버 오류")
}) })
@GetMapping("/admin/workers") @GetMapping("/admin/workers")
public ApiResponseDto<WorkerListResponse> getWorkerStatistics( public ApiResponseDto<WorkerListResponse> getWorkerStatistics(
@Parameter(description = "분석 ID (선택)", example = "3") @RequestParam(required = false) // @Parameter(description = "분석 ID (선택)", example = "3") @RequestParam(required = false)
Long analUid, // Long analUid,
@Parameter( @Parameter(
description = "작업자 유형 (선택) - 미입력 시 LABELER로 조회", description = "작업자 유형 (선택) - 미입력 시 LABELER로 조회",
example = "LABELER", example = "LABELER",
schema = schema =
@Schema( @Schema(
allowableValues = {"LABELER", "REVIEWER"}, allowableValues = {"LABELER", "REVIEWER"},
defaultValue = "LABELER")) defaultValue = "LABELER"))
@RequestParam(required = false) @RequestParam(required = false)
String type, String type,
@Parameter(description = "검색어 (작업자 이름 또는 사번으로 검색, 부분 일치)", example = "김라벨") @Parameter(description = "검색어 (작업자 이름 또는 사번으로 검색, 부분 일치)", example = "김라벨")
@RequestParam(required = false) @RequestParam(required = false)
String search, String search,
@Parameter( @Parameter(
description = "정렬 조건 (선택) - 미입력 시 이름 오름차순", description = "정렬 조건 (선택) - 미입력 시 이름 오름차순",
example = "REMAINING_DESC", example = "REMAINING_DESC",
schema = schema =
@Schema( @Schema(
allowableValues = { allowableValues = {
"REMAINING_DESC", "REMAINING_DESC",
"REMAINING_ASC", "REMAINING_ASC",
"NAME_ASC", "COMPLETED_DESC",
"NAME_DESC" "COMPLETED_ASC",
}, "NAME_ASC",
defaultValue = "NAME_ASC")) "NAME_DESC"
@RequestParam(required = false) },
String sort, defaultValue = "NAME_ASC"))
@Parameter(description = "페이지 번호 (0부터 시작)", example = "0") @RequestParam(required = false)
@RequestParam(defaultValue = "0") String sort,
Integer page, @Parameter(description = "페이지 번호 (0부터 시작)", example = "0")
@Parameter(description = "페이지 크기", example = "20") @RequestParam(defaultValue = "0")
@RequestParam(defaultValue = "20") Integer page,
Integer size) { @Parameter(description = "페이지 크기", example = "20")
@RequestParam(defaultValue = "20")
Integer size) {
// type이 null이면 기본값으로 LABELER 설정 // type이 null이면 기본값으로 LABELER 설정
String workerType = (type == null || type.isEmpty()) ? RoleType.LABELER.name() : type; String workerType = (type == null || type.isEmpty()) ? RoleType.LABELER.name() : type;
return ApiResponseDto.ok( return ApiResponseDto.ok(
labelAllocateService.getWorkerStatistics( labelAllocateService.getWorkerStatistics(
analUid, workerType, search, sort, page, size)); null, workerType, search, sort, page, size));
} }
@Operation(summary = "라벨링작업 관리 > 작업 배정", description = "라벨링작업 관리 > 작업 배정") @Operation(summary = "라벨링작업 관리 > 작업 배정", description = "라벨링작업 관리 > 작업 배정")
@ApiResponses( @ApiResponses(
value = { value = {
@ApiResponse( @ApiResponse(
responseCode = "201", responseCode = "201",
description = "등록 성공", description = "등록 성공",
content = content =
@Content( @Content(
mediaType = "application/json", mediaType = "application/json",
schema = @Schema(implementation = Long.class))), schema = @Schema(implementation = Long.class))),
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content), @ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
}) })
@PostMapping("/allocate") @PostMapping("/allocate")
public ApiResponseDto<ApiResponseDto.ResponseObj> labelAllocate( public ApiResponseDto<ApiResponseDto.ResponseObj> labelAllocate(
@RequestBody @Valid LabelAllocateDto.AllocateDto dto) { @RequestBody @Valid LabelAllocateDto.AllocateDto dto) {
return ApiResponseDto.okObject( return ApiResponseDto.okObject(
labelAllocateService.allocateAsc( labelAllocateService.allocateAsc(
dto.getStage(), dto.getStage(),
dto.getLabelers(), dto.getLabelers(),
dto.getInspectors(), dto.getInspectors(),
dto.getCompareYyyy(), dto.getCompareYyyy(),
dto.getTargetYyyy())); dto.getTargetYyyy()));
} }
@Operation(summary = "작업현황 관리 > 변화탐지 회차 정보", description = "작업현황 관리 > 변화탐지 회차 정보") @Operation(summary = "작업현황 관리 > 변화탐지 회차 정보", description = "작업현황 관리 > 변화탐지 회차 정보")
@ApiResponses( @ApiResponses(
value = { value = {
@ApiResponse(responseCode = "200", description = "조회 성공"), @ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "404", description = "데이터를 찾을 수 없음"), @ApiResponse(responseCode = "404", description = "데이터를 찾을 수 없음"),
@ApiResponse(responseCode = "500", description = "서버 오류") @ApiResponse(responseCode = "500", description = "서버 오류")
}) })
@GetMapping("/stage-detail") @GetMapping("/stage-detail")
public ApiResponseDto<InferenceDetail> findInferenceDetail( public ApiResponseDto<InferenceDetail> findInferenceDetail(
@Parameter( @Parameter(
description = "회차 마스터 key", description = "회차 마스터 key",
required = true, required = true,
example = "8584e8d4-53b3-4582-bde2-28a81495a626") example = "8584e8d4-53b3-4582-bde2-28a81495a626")
@RequestParam @RequestParam
String uuid) { String uuid) {
return ApiResponseDto.ok(labelAllocateService.findInferenceDetail(uuid)); return ApiResponseDto.ok(labelAllocateService.findInferenceDetail(uuid));
} }
@@ -177,37 +177,37 @@ public class LabelAllocateApiController {
@Operation(summary = "작업현황 관리 > 상세 > 작업 이관", description = "작업현황 관리 > 상세 > 작업 이관") @Operation(summary = "작업현황 관리 > 상세 > 작업 이관", description = "작업현황 관리 > 상세 > 작업 이관")
@ApiResponses( @ApiResponses(
value = { value = {
@ApiResponse( @ApiResponse(
responseCode = "201", responseCode = "201",
description = "등록 성공", description = "등록 성공",
content = content =
@Content( @Content(
mediaType = "application/json", mediaType = "application/json",
schema = @Schema(implementation = Long.class))), schema = @Schema(implementation = Long.class))),
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content), @ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
}) })
@PostMapping("/allocate-move") @PostMapping("/allocate-move")
public ApiResponseDto<ApiResponseDto.ResponseObj> labelAllocateMove( public ApiResponseDto<ApiResponseDto.ResponseObj> labelAllocateMove(
@io.swagger.v3.oas.annotations.parameters.RequestBody( @io.swagger.v3.oas.annotations.parameters.RequestBody(
description = "라벨링 이관", description = "라벨링 이관",
required = true, required = true,
content = content =
@Content( @Content(
mediaType = "application/json", mediaType = "application/json",
schema = @Schema(implementation = LabelAllocateDto.AllocateMoveDto.class))) schema = @Schema(implementation = LabelAllocateDto.AllocateMoveDto.class)))
@RequestBody @RequestBody
LabelAllocateDto.AllocateMoveDto dto) { LabelAllocateDto.AllocateMoveDto dto) {
return ApiResponseDto.okObject( return ApiResponseDto.okObject(
labelAllocateService.allocateMove( labelAllocateService.allocateMove(
dto.getAutoType(), dto.getAutoType(),
dto.getStage(), dto.getStage(),
dto.getLabelers(), dto.getLabelers(),
dto.getCompareYyyy(), dto.getCompareYyyy(),
dto.getTargetYyyy())); dto.getTargetYyyy()));
} }
@Operation( @Operation(

View File

@@ -10,6 +10,27 @@ import lombok.Setter;
public class WorkerStatsDto { public class WorkerStatsDto {
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "프로젝트 기본 정보 (상단 표시용)")
public static class ProjectInfo {
@Schema(description = "변화탐지년도 (예: 2026-2025)")
private String detectionYear;
@Schema(description = "회차 (예: 8)")
private String round;
@Schema(description = "국유인 반영일 (예: 2026-03-31)")
private String reflectionDate;
@Schema(description = "작업 시작일 (예: 2026-04-06)")
private String startDate;
}
@Getter @Getter
@Setter @Setter
@Builder @Builder
@@ -44,6 +65,25 @@ public class WorkerStatsDto {
@Schema(description = "작업 정체 여부 (3일간 실적이 저조하면 true)") @Schema(description = "작업 정체 여부 (3일간 실적이 저조하면 true)")
private Boolean isStagnated; private Boolean isStagnated;
// 레거시 필드 (기존 호환성 유지)
@Deprecated
private Long doneCnt; // completed로 대체
@Deprecated
private Long skipCnt; // skipped로 대체
@Deprecated
private Long remainingCnt; // remaining으로 대체
@Deprecated
private Long day3AgoDoneCnt; // history.day3Ago로 대체
@Deprecated
private Long day2AgoDoneCnt; // history.day2Ago로 대체
@Deprecated
private Long day1AgoDoneCnt; // history.day1Ago로 대체
} }
@Getter @Getter
@@ -67,6 +107,7 @@ public class WorkerStatsDto {
private Long average; private Long average;
} }
@Getter @Getter
@Setter @Setter
@Builder @Builder
@@ -75,29 +116,74 @@ public class WorkerStatsDto {
@Schema(description = "작업 진행 현황 정보") @Schema(description = "작업 진행 현황 정보")
public static class WorkProgressInfo { public static class WorkProgressInfo {
// === 라벨링 관련 ===
@Schema(description = "라벨링 진행률 (완료건+스킵건)/배정건") @Schema(description = "라벨링 진행률 (완료건+스킵건)/배정건")
private Double labelingProgressRate; private Double labelingProgressRate;
@Schema(description = "작업 상태 (진행중/료)") @Schema(description = "라벨링 작업 상태 (진행중/료)")
private String workStatus; private String labelingStatus;
@Schema(description = "진행률 수치 (완료+스킵)") @Schema(description = "라벨링 전체 배정 건수")
private Long completedCount; private Long labelingTotalCount;
@Schema(description = "전체 배정 건수") @Schema(description = "라벨링 완료 건수 (LABEL_FIN + TEST_ING + DONE)")
private Long totalAssignedCount; private Long labelingCompletedCount;
@Schema(description = "라벨링 스킵 건수 (SKIP)")
private Long labelingSkipCount;
@Schema(description = "라벨링 남은 작업 건수")
private Long labelingRemainingCount;
@Schema(description = "투입된 라벨러 수") @Schema(description = "투입된 라벨러 수")
private Long labelerCount; private Long labelerCount;
@Schema(description = "남은 라벨링 작업 데이터 수") // === 검수(Inspection) 관련 (신규 추가) ===
private Long remainingLabelCount; @Schema(description = "검수 진행률 (완료건/대상건)")
private Double inspectionProgressRate;
@Schema(description = "검수 작업 상태 (진행중/완료)")
private String inspectionStatus;
@Schema(description = "검수 전체 대상 건수")
private Long inspectionTotalCount;
@Schema(description = "검수 완료 건수 (DONE)")
private Long inspectionCompletedCount;
@Schema(description = "검수 제외 건수 (라벨링 스킵과 동일)")
private Long inspectionSkipCount;
@Schema(description = "검수 남은 작업 건수")
private Long inspectionRemainingCount;
@Schema(description = "투입된 검수자 수") @Schema(description = "투입된 검수자 수")
private Long inspectorCount; private Long inspectorCount;
@Schema(description = "남은 검수 작업 데이터 수") // === 레거시 호환 필드 (Deprecated) ===
@Deprecated
@Schema(description = "[Deprecated] labelingProgressRate 사용 권장")
private Double progressRate;
@Deprecated
@Schema(description = "[Deprecated] labelingTotalCount 사용 권장")
private Long totalAssignedCount;
@Deprecated
@Schema(description = "[Deprecated] labelingCompletedCount 사용 권장")
private Long completedCount;
@Deprecated
@Schema(description = "[Deprecated] labelingRemainingCount 사용 권장")
private Long remainingLabelCount;
@Deprecated
@Schema(description = "[Deprecated] inspectionRemainingCount 사용 권장")
private Long remainingInspectCount; private Long remainingInspectCount;
@Deprecated
@Schema(description = "[Deprecated] labelingStatus/inspectionStatus 사용 권장")
private String workStatus;
} }
@Getter @Getter
@@ -108,6 +194,9 @@ public class WorkerStatsDto {
@Schema(description = "작업자 목록 응답 (작업 정보 포함)") @Schema(description = "작업자 목록 응답 (작업 정보 포함)")
public static class WorkerListResponse { public static class WorkerListResponse {
@Schema(description = "프로젝트 기본 정보 (상단 표시용)")
private ProjectInfo projectInfo;
@Schema(description = "작업 진행 현황 정보") @Schema(description = "작업 진행 현황 정보")
private WorkProgressInfo progressInfo; private WorkProgressInfo progressInfo;

View File

@@ -38,22 +38,22 @@ public class LabelAllocateService {
/** /**
* 도엽 기준 asc sorting 해서 할당 수만큼 배정하는 로직 * 도엽 기준 asc sorting 해서 할당 수만큼 배정하는 로직
* *
* @param stage 회차 * @param stage 회차
* @param targetUsers 라벨러 목록 * @param targetUsers 라벨러 목록
* @param targetInspectors 검수자 목록 * @param targetInspectors 검수자 목록
*/ */
@Transactional @Transactional
public ApiResponseDto.ResponseObj allocateAsc( public ApiResponseDto.ResponseObj allocateAsc(
Integer stage, Integer stage,
List<TargetUser> targetUsers, List<TargetUser> targetUsers,
List<String> targetInspectors, List<String> targetInspectors,
Integer compareYyyy, Integer compareYyyy,
Integer targetYyyy) { Integer targetYyyy) {
Long lastId = null; Long lastId = null;
// geom 잔여건수 조회 // geom 잔여건수 조회
Long chargeCnt = Long chargeCnt =
labelAllocateCoreService.findLabelUnAssignedCnt(stage, compareYyyy, targetYyyy); 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, "이미 배정완료된 회차 입니다.");
} }
@@ -61,15 +61,15 @@ public class LabelAllocateService {
Long totalDemand = targetUsers.stream().mapToLong(TargetUser::getDemand).sum(); Long totalDemand = targetUsers.stream().mapToLong(TargetUser::getDemand).sum();
if (!Objects.equals(chargeCnt, totalDemand)) { if (!Objects.equals(chargeCnt, totalDemand)) {
return new ApiResponseDto.ResponseObj( return new ApiResponseDto.ResponseObj(
ApiResponseCode.BAD_REQUEST, "총 잔여건수와 요청 값의 합계가 맞지 않습니다."); ApiResponseCode.BAD_REQUEST, "총 잔여건수와 요청 값의 합계가 맞지 않습니다.");
} }
List<AllocateInfoDto> allIds = List<AllocateInfoDto> allIds =
labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage); labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage);
// MapSheetAnalInferenceEntity analUid 가져오기 // MapSheetAnalInferenceEntity analUid 가져오기
Long analUid = Long analUid =
labelAllocateCoreService.findMapSheetAnalInferenceUid(compareYyyy, targetYyyy, stage); labelAllocateCoreService.findMapSheetAnalInferenceUid(compareYyyy, targetYyyy, stage);
int index = 0; int index = 0;
for (TargetUser target : targetUsers) { for (TargetUser target : targetUsers) {
@@ -115,52 +115,55 @@ public class LabelAllocateService {
/** /**
* 작업자 통계 조회 * 작업자 통계 조회
* *
* @param analUid 분석 ID * @param analUid 분석 ID
* @param workerType 작업자 유형 (LABELER/INSPECTOR) * @param workerType 작업자 유형 (LABELER/INSPECTOR)
* @param search 검색어 (이름 또는 사번) * @param search 검색어 (이름 또는 사번)
* @param sortType 정렬 조건 * @param sortType 정렬 조건
* @param page 페이지 번호 (0부터 시작) * @param page 페이지 번호 (0부터 시작)
* @param size 페이지 크기 * @param size 페이지 크기
* @return 작업자 목록 및 통계 * @return 작업자 목록 및 통계
*/ */
public WorkerListResponse getWorkerStatistics( public WorkerListResponse getWorkerStatistics(
Long analUid, Long analUid,
String workerType, String workerType,
String search, String search,
String sortType, String sortType,
Integer page, Integer page,
Integer size) { Integer size) {
// 프로젝트 정보 조회 (analUid가 있을 때만)
var projectInfo = labelAllocateCoreService.findProjectInfo(analUid);
// 작업 진행 현황 조회 // 작업 진행 현황 조회
var progressInfo = labelAllocateCoreService.findWorkProgressInfo(analUid); var progressInfo = labelAllocateCoreService.findWorkProgressInfo(analUid);
// 작업자 통계 조회 // 작업자 통계 조회
List<WorkerStatistics> workers = List<WorkerStatistics> workers =
labelAllocateCoreService.findWorkerStatistics( labelAllocateCoreService.findWorkerStatistics(
analUid, workerType, search, sortType); analUid, workerType, search, sortType);
// 각 작업자별 3일치 처리량 조회 // 각 작업자별 3일치 처리량 조회
LocalDate today = LocalDate.now(); LocalDate today = LocalDate.now();
for (WorkerStatistics worker : workers) { for (WorkerStatistics worker : workers) {
Long day1Count = Long day1Count =
labelAllocateCoreService.findDailyProcessedCount( labelAllocateCoreService.findDailyProcessedCount(
worker.getWorkerId(), workerType, today.minusDays(1), analUid); worker.getWorkerId(), workerType, today.minusDays(1), analUid);
Long day2Count = Long day2Count =
labelAllocateCoreService.findDailyProcessedCount( labelAllocateCoreService.findDailyProcessedCount(
worker.getWorkerId(), workerType, today.minusDays(2), analUid); worker.getWorkerId(), workerType, today.minusDays(2), analUid);
Long day3Count = Long day3Count =
labelAllocateCoreService.findDailyProcessedCount( labelAllocateCoreService.findDailyProcessedCount(
worker.getWorkerId(), workerType, today.minusDays(3), analUid); worker.getWorkerId(), workerType, today.minusDays(3), analUid);
long average = (day1Count + day2Count + day3Count) / 3; long average = (day1Count + day2Count + day3Count) / 3;
DailyHistory history = DailyHistory history =
DailyHistory.builder() DailyHistory.builder()
.day1Ago(day1Count) .day1Ago(day1Count)
.day2Ago(day2Count) .day2Ago(day2Count)
.day3Ago(day3Count) .day3Ago(day3Count)
.average(average) .average(average)
.build(); .build();
worker.setHistory(history); worker.setHistory(history);
@@ -177,16 +180,17 @@ public class LabelAllocateService {
int toIndex = Math.min(fromIndex + size, workers.size()); int toIndex = Math.min(fromIndex + size, workers.size());
List<WorkerStatistics> pagedWorkers = List<WorkerStatistics> pagedWorkers =
(fromIndex < workers.size()) ? workers.subList(fromIndex, toIndex) : List.of(); (fromIndex < workers.size()) ? workers.subList(fromIndex, toIndex) : List.of();
return WorkerListResponse.builder() return WorkerListResponse.builder()
.progressInfo(progressInfo) .projectInfo(projectInfo)
.workers(pagedWorkers) .progressInfo(progressInfo)
.currentPage(page) .workers(pagedWorkers)
.pageSize(size) .currentPage(page)
.totalElements(totalElements) .pageSize(size)
.totalPages(totalPages) .totalElements(totalElements)
.build(); .totalPages(totalPages)
.build();
} }
public InferenceDetail findInferenceDetail(String uuid) { public InferenceDetail findInferenceDetail(String uuid) {
@@ -194,11 +198,11 @@ public class LabelAllocateService {
} }
public ApiResponseDto.ResponseObj allocateMove( public ApiResponseDto.ResponseObj allocateMove(
String autoType, String autoType,
Integer stage, Integer stage,
List<TargetUser> targetUsers, List<TargetUser> targetUsers,
Integer compareYyyy, Integer compareYyyy,
Integer targetYyyy) { Integer targetYyyy) {
Long lastId = null; Long lastId = null;
Long chargeCnt = targetUsers.stream().mapToLong(TargetUser::getDemand).sum(); Long chargeCnt = targetUsers.stream().mapToLong(TargetUser::getDemand).sum();
@@ -208,8 +212,8 @@ public class LabelAllocateService {
} }
List<Long> allIds = List<Long> allIds =
labelAllocateCoreService.fetchNextMoveIds( labelAllocateCoreService.fetchNextMoveIds(
lastId, chargeCnt, compareYyyy, targetYyyy, stage); lastId, chargeCnt, compareYyyy, targetYyyy, stage);
int index = 0; int index = 0;
for (TargetUser target : targetUsers) { for (TargetUser target : targetUsers) {
int end = index + target.getDemand(); int end = index + target.getDemand();

View File

@@ -7,6 +7,7 @@ import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelerDetail;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelingStatDto; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelingStatDto;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.searchReq; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.searchReq;
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.ProjectInfo;
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo; import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo;
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics; import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity; import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
@@ -25,7 +26,7 @@ public class LabelAllocateCoreService {
private final LabelAllocateRepository labelAllocateRepository; private final LabelAllocateRepository labelAllocateRepository;
public List<AllocateInfoDto> fetchNextIds( public List<AllocateInfoDto> fetchNextIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) { Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateRepository.fetchNextIds(lastId, batchSize, compareYyyy, targetYyyy, stage); return labelAllocateRepository.fetchNextIds(lastId, batchSize, compareYyyy, targetYyyy, stage);
} }
@@ -35,8 +36,8 @@ public class LabelAllocateCoreService {
public List<LabelAllocateDto.Basic> findAssignedLabelerList(Long analUid) { public List<LabelAllocateDto.Basic> findAssignedLabelerList(Long analUid) {
return labelAllocateRepository.findAssignedLabelerList(analUid).stream() return labelAllocateRepository.findAssignedLabelerList(analUid).stream()
.map(LabelingAssignmentEntity::toDto) .map(LabelingAssignmentEntity::toDto)
.toList(); .toList();
} }
public Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy) { public Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy) {
@@ -51,13 +52,17 @@ public class LabelAllocateCoreService {
return labelAllocateRepository.availUserList(role); return labelAllocateRepository.availUserList(role);
} }
public ProjectInfo findProjectInfo(Long analUid) {
return labelAllocateRepository.findProjectInfo(analUid);
}
public List<WorkerStatistics> findWorkerStatistics( public List<WorkerStatistics> findWorkerStatistics(
Long analUid, Long analUid,
String workerType, String workerType,
String search, String search,
String sortType) { String sortType) {
return labelAllocateRepository.findWorkerStatistics( return labelAllocateRepository.findWorkerStatistics(
analUid, workerType, search, sortType); analUid, workerType, search, sortType);
} }
public WorkProgressInfo findWorkProgressInfo(Long analUid) { public WorkProgressInfo findWorkProgressInfo(Long analUid) {
@@ -65,7 +70,7 @@ public class LabelAllocateCoreService {
} }
public Long findDailyProcessedCount( public Long findDailyProcessedCount(
String workerId, String workerType, LocalDate date, Long analUid) { String workerId, String workerType, LocalDate date, Long analUid) {
return labelAllocateRepository.findDailyProcessedCount(workerId, workerType, date, analUid); return labelAllocateRepository.findDailyProcessedCount(workerId, workerType, date, analUid);
} }
@@ -78,9 +83,9 @@ public class LabelAllocateCoreService {
} }
public List<Long> fetchNextMoveIds( public List<Long> fetchNextMoveIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) { Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateRepository.fetchNextMoveIds( return labelAllocateRepository.fetchNextMoveIds(
lastId, batchSize, compareYyyy, targetYyyy, stage); lastId, batchSize, compareYyyy, targetYyyy, stage);
} }
public void assignOwnerMove(List<Long> sub, String userId) { public void assignOwnerMove(List<Long> sub, String userId) {

View File

@@ -6,6 +6,7 @@ import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InferenceDetail;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelerDetail; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelerDetail;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelingStatDto; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelingStatDto;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.ProjectInfo;
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo; import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo;
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics; import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity; import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
@@ -29,6 +30,9 @@ public interface LabelAllocateRepositoryCustom {
List<UserList> availUserList(String role); List<UserList> availUserList(String role);
// 프로젝트 정보 조회
ProjectInfo findProjectInfo(Long analUid);
// 작업자 통계 조회 // 작업자 통계 조회
List<WorkerStatistics> findWorkerStatistics( List<WorkerStatistics> findWorkerStatistics(
Long analUid, String workerType, String search, String sortType); Long analUid, String workerType, String search, String sortType);

View File

@@ -15,7 +15,7 @@ import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelState;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelerDetail; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelerDetail;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelingStatDto; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelingStatDto;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.searchReq; import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.ProjectInfo;
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo; import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo;
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics; import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity; import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
@@ -37,9 +37,12 @@ import java.time.LocalDate;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
@@ -54,29 +57,28 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
private final JPAQueryFactory queryFactory; private final JPAQueryFactory queryFactory;
@PersistenceContext @PersistenceContext private EntityManager em;
private EntityManager em;
@Override @Override
public List<AllocateInfoDto> fetchNextIds( public List<AllocateInfoDto> fetchNextIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) { Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
return queryFactory return queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
AllocateInfoDto.class, AllocateInfoDto.class,
mapSheetAnalDataInferenceGeomEntity.geoUid, mapSheetAnalDataInferenceGeomEntity.geoUid,
mapSheetAnalDataInferenceGeomEntity.mapSheetNum)) mapSheetAnalDataInferenceGeomEntity.mapSheetNum))
.from(mapSheetAnalDataInferenceGeomEntity) .from(mapSheetAnalDataInferenceGeomEntity)
.where( .where(
lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId), lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId),
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy), mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy), mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceGeomEntity.stage.eq(stage), mapSheetAnalDataInferenceGeomEntity.stage.eq(stage),
mapSheetAnalDataInferenceGeomEntity.labelState.isNull()) mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
.orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc()) .orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc())
.limit(batchSize) .limit(batchSize)
.fetch(); .fetch();
} }
@Override @Override
@@ -84,10 +86,10 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
// analUid로 분석 정보 조회 // analUid로 분석 정보 조회
MapSheetAnalInferenceEntity analEntity = MapSheetAnalInferenceEntity analEntity =
queryFactory queryFactory
.selectFrom(mapSheetAnalInferenceEntity) .selectFrom(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.id.eq(analUid)) .where(mapSheetAnalInferenceEntity.id.eq(analUid))
.fetchOne(); .fetchOne();
if (Objects.isNull(analEntity)) { if (Objects.isNull(analEntity)) {
throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: "); throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: ");
@@ -95,20 +97,20 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
// data_geom 테이블에 label state 를 ASSIGNED 로 update // data_geom 테이블에 label state 를 ASSIGNED 로 update
List<Long> geoUidList = List<Long> geoUidList =
ids.stream().map(AllocateInfoDto::getGeoUid).filter(Objects::nonNull).toList(); ids.stream().map(AllocateInfoDto::getGeoUid).filter(Objects::nonNull).toList();
queryFactory queryFactory
.update(mapSheetAnalDataInferenceGeomEntity) .update(mapSheetAnalDataInferenceGeomEntity)
.set(mapSheetAnalDataInferenceGeomEntity.labelState, LabelState.ASSIGNED.getId()) .set(mapSheetAnalDataInferenceGeomEntity.labelState, LabelState.ASSIGNED.getId())
.set(mapSheetAnalDataInferenceGeomEntity.labelStateDttm, ZonedDateTime.now()) .set(mapSheetAnalDataInferenceGeomEntity.labelStateDttm, ZonedDateTime.now())
.set(mapSheetAnalDataInferenceGeomEntity.testState, InspectState.UNCONFIRM.getId()) .set(mapSheetAnalDataInferenceGeomEntity.testState, InspectState.UNCONFIRM.getId())
.set(mapSheetAnalDataInferenceGeomEntity.testStateDttm, ZonedDateTime.now()) .set(mapSheetAnalDataInferenceGeomEntity.testStateDttm, ZonedDateTime.now())
.where(mapSheetAnalDataInferenceGeomEntity.geoUid.in(geoUidList)) .where(mapSheetAnalDataInferenceGeomEntity.geoUid.in(geoUidList))
.execute(); .execute();
// 라벨러 할당 테이블에 insert // 라벨러 할당 테이블에 insert
String sql = String sql =
""" """
insert into tb_labeling_assignment insert into tb_labeling_assignment
(assignment_uid, inference_geom_uid, worker_uid, (assignment_uid, inference_geom_uid, worker_uid,
work_state, assign_group_id, anal_uid) work_state, assign_group_id, anal_uid)
@@ -117,13 +119,13 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
for (AllocateInfoDto info : ids) { for (AllocateInfoDto info : ids) {
em.createNativeQuery(sql) em.createNativeQuery(sql)
.setParameter(1, UUID.randomUUID()) .setParameter(1, UUID.randomUUID())
.setParameter(2, info.getGeoUid()) .setParameter(2, info.getGeoUid())
.setParameter(3, userId) .setParameter(3, userId)
.setParameter(4, LabelState.ASSIGNED.getId()) .setParameter(4, LabelState.ASSIGNED.getId())
.setParameter(5, info.getMapSheetNum()) .setParameter(5, info.getMapSheetNum())
.setParameter(6, analEntity.getId()) .setParameter(6, analEntity.getId())
.executeUpdate(); .executeUpdate();
} }
em.flush(); em.flush();
@@ -134,137 +136,137 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
public List<LabelingAssignmentEntity> findAssignedLabelerList(Long analUid) { public List<LabelingAssignmentEntity> findAssignedLabelerList(Long analUid) {
// analUid로 분석 정보 조회 // analUid로 분석 정보 조회
MapSheetAnalInferenceEntity analEntity = MapSheetAnalInferenceEntity analEntity =
queryFactory queryFactory
.selectFrom(mapSheetAnalInferenceEntity) .selectFrom(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.id.eq(analUid)) .where(mapSheetAnalInferenceEntity.id.eq(analUid))
.fetchOne(); .fetchOne();
if (Objects.isNull(analEntity)) { if (Objects.isNull(analEntity)) {
throw new EntityNotFoundException("mapSheetAnalInferenceEntity not found for analUid: "); throw new EntityNotFoundException("mapSheetAnalInferenceEntity not found for analUid: ");
} }
return queryFactory return queryFactory
.selectFrom(labelingAssignmentEntity) .selectFrom(labelingAssignmentEntity)
.where( .where(
labelingAssignmentEntity.analUid.eq(analEntity.getId()), labelingAssignmentEntity.analUid.eq(analEntity.getId()),
labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()), labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()),
labelingAssignmentEntity.inspectorUid.isNull()) labelingAssignmentEntity.inspectorUid.isNull())
.orderBy(labelingAssignmentEntity.workerUid.asc()) .orderBy(labelingAssignmentEntity.workerUid.asc())
.fetch(); .fetch();
} }
@Override @Override
public Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy) { public Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy) {
return queryFactory return queryFactory
.select(mapSheetAnalDataInferenceGeomEntity.geoUid.count()) .select(mapSheetAnalDataInferenceGeomEntity.geoUid.count())
.from(mapSheetAnalDataInferenceGeomEntity) .from(mapSheetAnalDataInferenceGeomEntity)
.where( .where(
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy), mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy), mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceGeomEntity.stage.eq(stage), mapSheetAnalDataInferenceGeomEntity.stage.eq(stage),
mapSheetAnalDataInferenceGeomEntity.labelState.isNull()) mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
.fetchOne(); .fetchOne();
} }
@Override @Override
public void assignInspector(UUID assignmentUid, String inspectorUid) { public void assignInspector(UUID assignmentUid, String inspectorUid) {
queryFactory queryFactory
.update(labelingAssignmentEntity) .update(labelingAssignmentEntity)
.set(labelingAssignmentEntity.inspectorUid, inspectorUid) .set(labelingAssignmentEntity.inspectorUid, inspectorUid)
.where(labelingAssignmentEntity.assignmentUid.eq(assignmentUid)) .where(labelingAssignmentEntity.assignmentUid.eq(assignmentUid))
.execute(); .execute();
} }
@Override @Override
public List<UserList> availUserList(String role) { public List<UserList> availUserList(String role) {
return queryFactory return queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
LabelAllocateDto.UserList.class, LabelAllocateDto.UserList.class,
memberEntity.userRole, memberEntity.userRole,
memberEntity.employeeNo, memberEntity.employeeNo,
memberEntity.name)) memberEntity.name))
.from(memberEntity) .from(memberEntity)
.where( .where(
memberEntity.userRole.eq(role), memberEntity.userRole.eq(role),
memberEntity.status.eq(com.kamco.cd.kamcoback.common.enums.StatusType.ACTIVE.getId())) memberEntity.status.eq(com.kamco.cd.kamcoback.common.enums.StatusType.ACTIVE.getId()))
.orderBy(memberEntity.name.asc()) .orderBy(memberEntity.name.asc())
.fetch(); .fetch();
} }
@Override @Override
public List<WorkerStatistics> findWorkerStatistics( public List<WorkerStatistics> findWorkerStatistics(
Long analUid, Long analUid,
String workerType, String workerType,
String search, String search,
String sortType) { String sortType) {
// 작업자 유형에 따른 필드 선택 // 작업자 유형에 따른 필드 선택
StringExpression workerIdField = StringExpression workerIdField =
"REVIEWER".equals(workerType) "REVIEWER".equals(workerType)
? labelingAssignmentEntity.inspectorUid ? labelingAssignmentEntity.inspectorUid
: labelingAssignmentEntity.workerUid; : labelingAssignmentEntity.workerUid;
BooleanExpression workerCondition = BooleanExpression workerCondition =
"REVIEWER".equals(workerType) "REVIEWER".equals(workerType)
? labelingAssignmentEntity.inspectorUid.isNotNull() ? labelingAssignmentEntity.inspectorUid.isNotNull()
: labelingAssignmentEntity.workerUid.isNotNull(); : labelingAssignmentEntity.workerUid.isNotNull();
// 검색 조건 (이름 또는 사번으로 검색) // 검색 조건 (이름 또는 사번으로 검색)
BooleanExpression searchCondition = null; BooleanExpression searchCondition = null;
if (search != null && !search.isEmpty()) { if (search != null && !search.isEmpty()) {
searchCondition = memberEntity.name.contains(search) searchCondition = memberEntity.name.contains(search)
.or(memberEntity.employeeNo.contains(search)); .or(memberEntity.employeeNo.contains(search));
} }
// 완료, 스킵, 남은 작업 계산 // 완료, 스킵, 남은 작업 계산
NumberExpression<Long> completedSum = NumberExpression<Long> completedSum =
new CaseBuilder() new CaseBuilder()
.when(labelingAssignmentEntity.workState.eq("DONE")) .when(labelingAssignmentEntity.workState.eq("DONE"))
.then(1L) .then(1L)
.otherwise(0L) .otherwise(0L)
.sum(); .sum();
NumberExpression<Long> skippedSum = NumberExpression<Long> skippedSum =
new CaseBuilder() new CaseBuilder()
.when(labelingAssignmentEntity.workState.eq("SKIP")) .when(labelingAssignmentEntity.workState.eq("SKIP"))
.then(1L) .then(1L)
.otherwise(0L) .otherwise(0L)
.sum(); .sum();
NumberExpression<Long> remainingSum = NumberExpression<Long> remainingSum =
new CaseBuilder() new CaseBuilder()
.when( .when(
labelingAssignmentEntity labelingAssignmentEntity
.workState .workState
.notIn("DONE", "SKIP") .notIn("DONE", "SKIP")
.and(labelingAssignmentEntity.workState.isNotNull())) .and(labelingAssignmentEntity.workState.isNotNull()))
.then(1L) .then(1L)
.otherwise(0L) .otherwise(0L)
.sum(); .sum();
// 기본 통계 조회 쿼리 // 기본 통계 조회 쿼리
BooleanExpression analUidCondition = analUid != null ? labelingAssignmentEntity.analUid.eq(analUid) : null; BooleanExpression analUidCondition = analUid != null ? labelingAssignmentEntity.analUid.eq(analUid) : null;
var baseQuery = var baseQuery =
queryFactory queryFactory
.select( .select(
workerIdField, workerIdField,
memberEntity.name, memberEntity.name,
workerIdField.count(), workerIdField.count(),
completedSum, completedSum,
skippedSum, skippedSum,
remainingSum, remainingSum,
labelingAssignmentEntity.stagnationYn.max()) labelingAssignmentEntity.stagnationYn.max())
.from(labelingAssignmentEntity) .from(labelingAssignmentEntity)
.leftJoin(memberEntity) .leftJoin(memberEntity)
.on( .on(
"REVIEWER".equals(workerType) "REVIEWER".equals(workerType)
? memberEntity.employeeNo.eq(labelingAssignmentEntity.inspectorUid) ? memberEntity.employeeNo.eq(labelingAssignmentEntity.inspectorUid)
: memberEntity.employeeNo.eq(labelingAssignmentEntity.workerUid)) : memberEntity.employeeNo.eq(labelingAssignmentEntity.workerUid))
.where(analUidCondition, workerCondition, searchCondition) .where(analUidCondition, workerCondition, searchCondition)
.groupBy(workerIdField, memberEntity.name); .groupBy(workerIdField, memberEntity.name);
// 정렬 조건 적용 // 정렬 조건 적용
if (sortType != null) { if (sortType != null) {
@@ -275,6 +277,12 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
case "REMAINING_ASC": case "REMAINING_ASC":
baseQuery.orderBy(remainingSum.asc()); baseQuery.orderBy(remainingSum.asc());
break; break;
case "COMPLETED_DESC":
baseQuery.orderBy(completedSum.desc());
break;
case "COMPLETED_ASC":
baseQuery.orderBy(completedSum.asc());
break;
case "NAME_ASC": case "NAME_ASC":
baseQuery.orderBy(memberEntity.name.asc()); baseQuery.orderBy(memberEntity.name.asc());
break; break;
@@ -290,22 +298,22 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
// 결과를 DTO로 변환 // 결과를 DTO로 변환
return baseQuery.fetch().stream() return baseQuery.fetch().stream()
.map( .map(
tuple -> { tuple -> {
Character maxStagnationYn = tuple.get(labelingAssignmentEntity.stagnationYn.max()); Character maxStagnationYn = tuple.get(labelingAssignmentEntity.stagnationYn.max());
return WorkerStatistics.builder() return WorkerStatistics.builder()
.workerId(tuple.get(workerIdField)) .workerId(tuple.get(workerIdField))
.workerName(tuple.get(memberEntity.name)) .workerName(tuple.get(memberEntity.name))
.workerType(workerType) .workerType(workerType)
.totalAssigned(tuple.get(workerIdField.count())) .totalAssigned(tuple.get(workerIdField.count()))
.completed(tuple.get(completedSum)) .completed(tuple.get(completedSum))
.skipped(tuple.get(skippedSum)) .skipped(tuple.get(skippedSum))
.remaining(tuple.get(remainingSum)) .remaining(tuple.get(remainingSum))
.history(null) // 3일 이력은 Service에서 채움 .history(null) // 3일 이력은 Service에서 채움
.isStagnated(maxStagnationYn != null && maxStagnationYn == 'Y') .isStagnated(maxStagnationYn != null && maxStagnationYn == 'Y')
.build(); .build();
}) })
.toList(); .toList();
} }
@Override @Override
@@ -314,112 +322,134 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
// 전체 배정 건수 // 전체 배정 건수
Long totalAssigned = Long totalAssigned =
queryFactory queryFactory
.select(labelingAssignmentEntity.count()) .select(labelingAssignmentEntity.count())
.from(labelingAssignmentEntity) .from(labelingAssignmentEntity)
.where(analUidCondition) .where(analUidCondition)
.fetchOne(); .fetchOne();
// 완료 + 스킵 건수 // === 라벨링 통계 ===
Long completedCount = // 라벨링 완료: LABEL_FIN, TEST_ING, DONE (검수 포함)
queryFactory Long labelingCompleted =
.select(labelingAssignmentEntity.count()) queryFactory
.from(labelingAssignmentEntity) .select(labelingAssignmentEntity.count())
.where( .from(labelingAssignmentEntity)
analUidCondition, .where(
labelingAssignmentEntity.workState.in("DONE", "SKIP")) analUidCondition,
.fetchOne(); labelingAssignmentEntity.workState.in("LABEL_FIN", "TEST_ING", "DONE"))
.fetchOne();
// 투입된 라벨러 수 (고유한 worker_uid 수) // 스킵 건수
Long skipCount =
queryFactory
.select(labelingAssignmentEntity.count())
.from(labelingAssignmentEntity)
.where(
analUidCondition,
labelingAssignmentEntity.workState.eq("SKIP"))
.fetchOne();
// 투입된 라벨러 수
Long labelerCount = Long labelerCount =
queryFactory queryFactory
.select(labelingAssignmentEntity.workerUid.countDistinct()) .select(labelingAssignmentEntity.workerUid.countDistinct())
.from(labelingAssignmentEntity) .from(labelingAssignmentEntity)
.where( .where(
analUidCondition, analUidCondition,
labelingAssignmentEntity.workerUid.isNotNull()) labelingAssignmentEntity.workerUid.isNotNull())
.fetchOne(); .fetchOne();
// 남은 라벨링 작업 데이터 수 // === 검수 통계 ===
Long remainingLabelCount = // 검수 완료: DONE만
queryFactory Long inspectionCompleted =
.select(labelingAssignmentEntity.count()) queryFactory
.from(labelingAssignmentEntity) .select(labelingAssignmentEntity.count())
.where( .from(labelingAssignmentEntity)
analUidCondition, .where(
labelingAssignmentEntity.workerUid.isNotNull(), analUidCondition,
labelingAssignmentEntity.workState.notIn("DONE", "SKIP")) labelingAssignmentEntity.workState.eq("DONE"))
.fetchOne(); .fetchOne();
// 투입된 검수자 수 (고유한 inspector_uid 수) // 투입된 검수자 수
Long inspectorCount = Long inspectorCount =
queryFactory queryFactory
.select(labelingAssignmentEntity.inspectorUid.countDistinct()) .select(labelingAssignmentEntity.inspectorUid.countDistinct())
.from(labelingAssignmentEntity) .from(labelingAssignmentEntity)
.where( .where(
analUidCondition, analUidCondition,
labelingAssignmentEntity.inspectorUid.isNotNull()) labelingAssignmentEntity.inspectorUid.isNotNull())
.fetchOne(); .fetchOne();
// 남은 검수 작업 데이터 수 // 남은 작업 건수 계산
Long remainingInspectCount = long total = totalAssigned != null ? totalAssigned : 0L;
queryFactory long labelCompleted = labelingCompleted != null ? labelingCompleted : 0L;
.select(labelingAssignmentEntity.count()) long inspectCompleted = inspectionCompleted != null ? inspectionCompleted : 0L;
.from(labelingAssignmentEntity) long skipped = skipCount != null ? skipCount : 0L;
.where(
analUidCondition, long labelingRemaining = total - labelCompleted - skipped;
labelingAssignmentEntity.inspectorUid.isNotNull(), long inspectionRemaining = total - inspectCompleted - skipped;
labelingAssignmentEntity.workState.notIn("DONE"))
.fetchOne();
// 진행률 계산 // 진행률 계산
double progressRate = 0.0; double labelingRate = total > 0 ? (double) labelCompleted / total * 100 : 0.0;
if (totalAssigned != null && totalAssigned > 0) { double inspectionRate = total > 0 ? (double) inspectCompleted / total * 100 : 0.0;
progressRate =
(completedCount != null ? completedCount.doubleValue() : 0.0) / totalAssigned * 100;
}
// 작업 상태 판단 (간단하게 진행률 100%면 종료, 아니면 진행중) // 상태 판단
String workStatus = (progressRate >= 100.0) ? "종료" : "진행중"; String labelingStatus = labelingRemaining > 0 ? "진행중" : "완료";
String inspectionStatus = inspectionRemaining > 0 ? "진행중" : "완료";
return WorkProgressInfo.builder() return WorkProgressInfo.builder()
.labelingProgressRate(progressRate) // 라벨링
.workStatus(workStatus) .labelingProgressRate(labelingRate)
.completedCount(completedCount != null ? completedCount : 0L) .labelingStatus(labelingStatus)
.totalAssignedCount(totalAssigned != null ? totalAssigned : 0L) .labelingTotalCount(total)
.labelerCount(labelerCount != null ? labelerCount : 0L) .labelingCompletedCount(labelCompleted)
.remainingLabelCount(remainingLabelCount != null ? remainingLabelCount : 0L) .labelingSkipCount(skipped)
.inspectorCount(inspectorCount != null ? inspectorCount : 0L) .labelingRemainingCount(labelingRemaining)
.remainingInspectCount(remainingInspectCount != null ? remainingInspectCount : 0L) .labelerCount(labelerCount != null ? labelerCount : 0L)
.build(); // 검수
.inspectionProgressRate(inspectionRate)
.inspectionStatus(inspectionStatus)
.inspectionTotalCount(total)
.inspectionCompletedCount(inspectCompleted)
.inspectionSkipCount(skipped)
.inspectionRemainingCount(inspectionRemaining)
.inspectorCount(inspectorCount != null ? inspectorCount : 0L)
// 레거시 호환 필드 (Deprecated)
.progressRate(labelingRate)
.totalAssignedCount(total)
.completedCount(labelCompleted)
.remainingLabelCount(labelingRemaining)
.remainingInspectCount(inspectionRemaining)
.workStatus(labelingStatus)
.build();
} }
@Override @Override
public Long findDailyProcessedCount( public Long findDailyProcessedCount(
String workerId, String workerType, LocalDate date, Long analUid) { String workerId, String workerType, LocalDate date, Long analUid) {
// 해당 날짜의 시작과 끝 시간 // 해당 날짜의 시작과 끝 시간
ZonedDateTime startOfDay = date.atStartOfDay(ZoneId.systemDefault()); ZonedDateTime startOfDay = date.atStartOfDay(ZoneId.systemDefault());
ZonedDateTime endOfDay = date.atTime(LocalTime.MAX).atZone(ZoneId.systemDefault()); ZonedDateTime endOfDay = date.atTime(LocalTime.MAX).atZone(ZoneId.systemDefault());
BooleanExpression workerCondition = BooleanExpression workerCondition =
"REVIEWER".equals(workerType) "REVIEWER".equals(workerType)
? labelingAssignmentEntity.inspectorUid.eq(workerId) ? labelingAssignmentEntity.inspectorUid.eq(workerId)
: labelingAssignmentEntity.workerUid.eq(workerId); : labelingAssignmentEntity.workerUid.eq(workerId);
BooleanExpression analUidCondition = analUid != null ? labelingAssignmentEntity.analUid.eq(analUid) : null; BooleanExpression analUidCondition = analUid != null ? labelingAssignmentEntity.analUid.eq(analUid) : null;
Long count = Long count =
queryFactory queryFactory
.select(labelingAssignmentEntity.count()) .select(labelingAssignmentEntity.count())
.from(labelingAssignmentEntity) .from(labelingAssignmentEntity)
.where( .where(
analUidCondition, analUidCondition,
workerCondition, workerCondition,
labelingAssignmentEntity.workState.in( labelingAssignmentEntity.workState.in(
LabelState.DONE.getId(), LabelState.SKIP.getId()), LabelState.DONE.getId(), LabelState.SKIP.getId()),
labelingAssignmentEntity.modifiedDate.between(startOfDay, endOfDay)) labelingAssignmentEntity.modifiedDate.between(startOfDay, endOfDay))
.fetchOne(); .fetchOne();
return count != null ? count : 0L; return count != null ? count : 0L;
} }
@@ -427,10 +457,10 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
@Override @Override
public void assignInspectorBulk(List<UUID> assignmentUids, String inspectorUid) { public void assignInspectorBulk(List<UUID> assignmentUids, String inspectorUid) {
queryFactory queryFactory
.update(labelingAssignmentEntity) .update(labelingAssignmentEntity)
.set(labelingAssignmentEntity.inspectorUid, inspectorUid) .set(labelingAssignmentEntity.inspectorUid, inspectorUid)
.where(labelingAssignmentEntity.assignmentUid.in(assignmentUids)) .where(labelingAssignmentEntity.assignmentUid.in(assignmentUids))
.execute(); .execute();
em.clear(); em.clear();
} }
@@ -439,64 +469,64 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
public InferenceDetail findInferenceDetail(String uuid) { public InferenceDetail findInferenceDetail(String uuid) {
// analUid로 분석 정보 조회 // analUid로 분석 정보 조회
MapSheetAnalInferenceEntity analEntity = MapSheetAnalInferenceEntity analEntity =
queryFactory queryFactory
.selectFrom(mapSheetAnalInferenceEntity) .selectFrom(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid))) .where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
.fetchOne(); .fetchOne();
if (Objects.isNull(analEntity)) { if (Objects.isNull(analEntity)) {
throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: "); throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: ");
} }
return queryFactory return queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
InferenceDetail.class, InferenceDetail.class,
mapSheetAnalEntity.analTitle, mapSheetAnalEntity.analTitle,
Expressions.numberTemplate(Integer.class, "{0}", 4), Expressions.numberTemplate(Integer.class, "{0}", 4),
mapSheetAnalEntity.gukyuinApplyDttm, mapSheetAnalEntity.gukyuinApplyDttm,
mapSheetAnalEntity.detectingCnt, mapSheetAnalEntity.detectingCnt,
labelingAssignmentEntity.workerUid.countDistinct(), labelingAssignmentEntity.workerUid.countDistinct(),
labelingAssignmentEntity.inspectorUid.countDistinct())) labelingAssignmentEntity.inspectorUid.countDistinct()))
.from(mapSheetAnalEntity) .from(mapSheetAnalEntity)
.innerJoin(labelingAssignmentEntity) .innerJoin(labelingAssignmentEntity)
.on(mapSheetAnalEntity.id.eq(labelingAssignmentEntity.analUid)) .on(mapSheetAnalEntity.id.eq(labelingAssignmentEntity.analUid))
.where(mapSheetAnalEntity.id.eq(analEntity.getId())) .where(mapSheetAnalEntity.id.eq(analEntity.getId()))
.groupBy( .groupBy(
mapSheetAnalEntity.analTitle, mapSheetAnalEntity.analTitle,
mapSheetAnalEntity.gukyuinApplyDttm, mapSheetAnalEntity.gukyuinApplyDttm,
mapSheetAnalEntity.detectingCnt) mapSheetAnalEntity.detectingCnt)
.fetchOne(); .fetchOne();
} }
@Override @Override
public List<Long> fetchNextMoveIds( public List<Long> fetchNextMoveIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) { Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
return queryFactory return queryFactory
.select(mapSheetAnalDataInferenceGeomEntity.geoUid) .select(mapSheetAnalDataInferenceGeomEntity.geoUid)
.from(mapSheetAnalDataInferenceGeomEntity) .from(mapSheetAnalDataInferenceGeomEntity)
.where( .where(
// mapSheetAnalDataGeomEntity.pnu.isNotNull(), //TODO: Mockup 진행 이후 확인하기 // mapSheetAnalDataGeomEntity.pnu.isNotNull(), //TODO: Mockup 진행 이후 확인하기
lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId), lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId),
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy), mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy), mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceGeomEntity.stage.eq(stage), mapSheetAnalDataInferenceGeomEntity.stage.eq(stage),
mapSheetAnalDataInferenceGeomEntity.labelState.in( mapSheetAnalDataInferenceGeomEntity.labelState.in(
LabelState.ASSIGNED.getId(), LabelState.SKIP.getId())) LabelState.ASSIGNED.getId(), LabelState.SKIP.getId()))
.orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc()) .orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc())
.limit(batchSize) .limit(batchSize)
.fetch(); .fetch();
} }
@Transactional @Transactional
@Override @Override
public void assignOwnerMove(List<Long> sub, String userId) { public void assignOwnerMove(List<Long> sub, String userId) {
queryFactory queryFactory
.update(labelingAssignmentEntity) .update(labelingAssignmentEntity)
.set(labelingAssignmentEntity.workerUid, userId) .set(labelingAssignmentEntity.workerUid, userId)
.where(labelingAssignmentEntity.inferenceGeomUid.in(sub)) .where(labelingAssignmentEntity.inferenceGeomUid.in(sub))
.execute(); .execute();
em.clear(); em.clear();
} }
@@ -504,43 +534,43 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
@Override @Override
public LabelerDetail findLabelerDetail(String userId, String uuid) { public LabelerDetail findLabelerDetail(String userId, String uuid) {
NumberExpression<Long> assignedCnt = NumberExpression<Long> assignedCnt =
new CaseBuilder() new CaseBuilder()
.when(labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId())) .when(labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()))
.then(1L) .then(1L)
.otherwise((Long) null) .otherwise((Long) null)
.count(); .count();
NumberExpression<Long> skipCnt = NumberExpression<Long> skipCnt =
new CaseBuilder() new CaseBuilder()
.when(labelingAssignmentEntity.workState.eq(LabelState.SKIP.getId())) .when(labelingAssignmentEntity.workState.eq(LabelState.SKIP.getId()))
.then(1L) .then(1L)
.otherwise((Long) null) .otherwise((Long) null)
.count(); .count();
NumberExpression<Long> completeCnt = NumberExpression<Long> completeCnt =
new CaseBuilder() new CaseBuilder()
.when(labelingAssignmentEntity.workState.eq(LabelState.COMPLETE.getId())) .when(labelingAssignmentEntity.workState.eq(LabelState.COMPLETE.getId()))
.then(1L) .then(1L)
.otherwise((Long) null) .otherwise((Long) null)
.count(); .count();
NumberExpression<Double> percent = NumberExpression<Double> percent =
new CaseBuilder() new CaseBuilder()
.when(completeCnt.eq(0L)) .when(completeCnt.eq(0L))
.then(0.0) .then(0.0)
.otherwise( .otherwise(
Expressions.numberTemplate( Expressions.numberTemplate(
Double.class, Double.class,
"round({0} / {1}, 2)", "round({0} / {1}, 2)",
labelingAssignmentEntity.count(), labelingAssignmentEntity.count(),
completeCnt)); completeCnt));
// analUid로 분석 정보 조회 // analUid로 분석 정보 조회
MapSheetAnalInferenceEntity analEntity = MapSheetAnalInferenceEntity analEntity =
queryFactory queryFactory
.selectFrom(mapSheetAnalInferenceEntity) .selectFrom(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid))) .where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
.fetchOne(); .fetchOne();
if (Objects.isNull(analEntity)) { if (Objects.isNull(analEntity)) {
throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: "); throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: ");
@@ -578,30 +608,99 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
@Override @Override
public Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage) { public Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage) {
return queryFactory return queryFactory
.select(mapSheetAnalInferenceEntity.id) .select(mapSheetAnalInferenceEntity.id)
.from(mapSheetAnalInferenceEntity) .from(mapSheetAnalInferenceEntity)
.where( .where(
mapSheetAnalInferenceEntity.compareYyyy.eq(compareYyyy), mapSheetAnalInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalInferenceEntity.targetYyyy.eq(targetYyyy), mapSheetAnalInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalInferenceEntity.stage.eq(stage)) mapSheetAnalInferenceEntity.stage.eq(stage))
.fetchOne(); .fetchOne();
} }
@Override @Override
public void insertInspector(Long analUid, String inspector) { public void insertInspector(Long analUid, String inspector) {
queryFactory queryFactory
.insert(labelingInspectorEntity) .insert(labelingInspectorEntity)
.columns( .columns(
labelingInspectorEntity.operatorUid, labelingInspectorEntity.operatorUid,
labelingInspectorEntity.analUid, labelingInspectorEntity.analUid,
labelingInspectorEntity.inspectorUid) labelingInspectorEntity.inspectorUid)
.values(UUID.randomUUID(), analUid, inspector) .values(UUID.randomUUID(), analUid, inspector)
.execute(); .execute();
em.flush(); em.flush();
em.clear(); em.clear();
} }
@Override
public ProjectInfo findProjectInfo(Long analUid) {
if (analUid == null) {
return null;
}
var result = queryFactory
.select(
mapSheetAnalEntity.compareYyyy,
mapSheetAnalEntity.targetYyyy,
mapSheetAnalEntity.analTitle,
mapSheetAnalEntity.gukyuinApplyDttm,
mapSheetAnalEntity.analStrtDttm
)
.from(mapSheetAnalEntity)
.where(mapSheetAnalEntity.id.eq(analUid))
.fetchOne();
if (result == null) {
return null;
}
Integer compareYyyy = result.get(mapSheetAnalEntity.compareYyyy);
Integer targetYyyy = result.get(mapSheetAnalEntity.targetYyyy);
String analTitle = result.get(mapSheetAnalEntity.analTitle);
ZonedDateTime gukyuinApplyDttm = result.get(mapSheetAnalEntity.gukyuinApplyDttm);
ZonedDateTime analStrtDttm = result.get(mapSheetAnalEntity.analStrtDttm);
// 변화탐지년도 생성
String detectionYear = (compareYyyy != null && targetYyyy != null)
? compareYyyy + "-" + targetYyyy
: null;
// 회차 추출 (예: "8회차" → "8")
String round = extractRoundFromTitle(analTitle);
return ProjectInfo.builder()
.detectionYear(detectionYear)
.round(round)
.reflectionDate(formatDate(gukyuinApplyDttm))
.startDate(formatDate(analStrtDttm))
.build();
}
/**
* 제목에서 회차 숫자 추출
* 예: "8회차", "제8회차" → "8"
*/
private String extractRoundFromTitle(String title) {
if (title == null || title.isEmpty()) {
return null;
}
Pattern pattern = Pattern.compile("(\\d+)회차");
Matcher matcher = pattern.matcher(title);
return matcher.find() ? matcher.group(1) : null;
}
/**
* ZonedDateTime을 "yyyy-MM-dd" 형식으로 변환
*/
private String formatDate(ZonedDateTime dateTime) {
if (dateTime == null) {
return null;
}
return dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
@Override @Override
public Page<LabelingStatDto> findLabelerDailyStat(LabelAllocateDto.searchReq searchReq, String uuid, String userId) { public Page<LabelingStatDto> findLabelerDailyStat(LabelAllocateDto.searchReq searchReq, String uuid, String userId) {
// 날짜 포맷 // 날짜 포맷