Merge remote-tracking branch 'origin/feat/dev_251201' 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
This commit is contained in:
@@ -92,13 +92,20 @@ public class LabelAllocateApiController {
|
||||
},
|
||||
defaultValue = "NAME_ASC"))
|
||||
@RequestParam(required = false)
|
||||
String sort) {
|
||||
String sort,
|
||||
@Parameter(description = "페이지 번호 (0부터 시작)", example = "0")
|
||||
@RequestParam(defaultValue = "0")
|
||||
Integer page,
|
||||
@Parameter(description = "페이지 크기", example = "20")
|
||||
@RequestParam(defaultValue = "20")
|
||||
Integer size) {
|
||||
|
||||
// type이 null이면 기본값으로 LABELER 설정
|
||||
String workerType = (type == null || type.isEmpty()) ? RoleType.LABELER.name() : type;
|
||||
|
||||
return ApiResponseDto.ok(
|
||||
labelAllocateService.getWorkerStatistics(null, workerType, search, sort));
|
||||
labelAllocateService.getWorkerStatistics(
|
||||
null, workerType, search, sort, page, size));
|
||||
}
|
||||
|
||||
@Operation(summary = "라벨링작업 관리 > 작업 배정", description = "라벨링작업 관리 > 작업 배정")
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.kamco.cd.kamcoback.label;
|
||||
|
||||
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.ChangeDetectYear;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMng;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMngDetail;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMngSearchReq;
|
||||
import com.kamco.cd.kamcoback.label.service.LabelWorkService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -13,10 +14,13 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -30,6 +34,24 @@ public class LabelWorkerApiController {
|
||||
|
||||
private final LabelWorkService labelWorkService;
|
||||
|
||||
@Operation(summary = "변화탐지 년도 셀렉트박스 조회", description = "라벨링작업 관리 > 목록 조회 변화탐지 년도 셀렉트박스 조회")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "조회 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ChangeDetectYear.class))),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping("/change-detect-year")
|
||||
public ApiResponseDto<List<ChangeDetectYear>> getChangeDetectYear() {
|
||||
return ApiResponseDto.ok(labelWorkService.getChangeDetectYear());
|
||||
}
|
||||
|
||||
@Operation(summary = "라벨링작업 관리 > 목록 조회", description = "라벨링작업 관리 > 목록 조회")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@@ -39,26 +61,45 @@ public class LabelWorkerApiController {
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = CommonCodeDto.Basic.class))),
|
||||
schema = @Schema(implementation = Page.class))),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping("/label-work-mng-list")
|
||||
public ApiResponseDto<Page<LabelWorkMng>> labelWorkMngList(
|
||||
@Parameter(description = "변화탐지년도", example = "2024") @RequestParam(required = false)
|
||||
Integer detectYyyy,
|
||||
@Parameter(description = "시작일", example = "20260101") @RequestParam String strtDttm,
|
||||
@Parameter(description = "변화탐지년도", example = "2022-2024") @RequestParam(required = false)
|
||||
String detectYear,
|
||||
@Parameter(description = "시작일", example = "20220101") @RequestParam String strtDttm,
|
||||
@Parameter(description = "종료일", example = "20261201") @RequestParam String endDttm,
|
||||
@Parameter(description = "페이지 번호 (0부터 시작)", example = "0") @RequestParam(defaultValue = "0")
|
||||
int page,
|
||||
@Parameter(description = "페이지 크기", example = "20") @RequestParam(defaultValue = "20")
|
||||
int size) {
|
||||
LabelWorkDto.LabelWorkMngSearchReq searchReq = new LabelWorkMngSearchReq();
|
||||
searchReq.setDetectYyyy(detectYyyy);
|
||||
searchReq.setDetectYear(detectYear);
|
||||
searchReq.setStrtDttm(strtDttm);
|
||||
searchReq.setEndDttm(endDttm);
|
||||
searchReq.setPage(page);
|
||||
searchReq.setSize(size);
|
||||
return ApiResponseDto.ok(labelWorkService.labelWorkMngList(searchReq));
|
||||
}
|
||||
|
||||
@Operation(summary = "라벨링작업 관리 > 작업 배정 정보조회", description = "작업 배정 정보조회")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "조회 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = LabelWorkMngDetail.class))),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping("/label-work-mng-detail/{uuid}")
|
||||
public ApiResponseDto<LabelWorkMngDetail> labelWorkMngDetail(
|
||||
@Parameter(description = "uuid") @PathVariable UUID uuid) {
|
||||
return ApiResponseDto.ok(labelWorkService.findLabelWorkMngDetail(uuid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,11 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
public class LabelAllocateDto {
|
||||
|
||||
@@ -171,6 +175,9 @@ public class LabelAllocateDto {
|
||||
private Long analUid;
|
||||
private ZonedDateTime createdDttm;
|
||||
private ZonedDateTime updatedDttm;
|
||||
private String inspectState;
|
||||
private ZonedDateTime workStatDttm;
|
||||
private ZonedDateTime inspectStatDttm;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@@ -210,7 +217,7 @@ public class LabelAllocateDto {
|
||||
private Double percent;
|
||||
private Integer ranking;
|
||||
private ZonedDateTime createdDttm;
|
||||
private String inspectorName;
|
||||
private String ownerName;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@@ -256,4 +263,42 @@ public class LabelAllocateDto {
|
||||
private Long geoUid;
|
||||
private Long mapSheetNum;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public static class LabelingStatDto {
|
||||
|
||||
private String workDate;
|
||||
private Long dailyTotalCnt;
|
||||
private Long totalCnt;
|
||||
private Long assignedCnt;
|
||||
private Long skipCnt;
|
||||
private Long completeCnt;
|
||||
private Long remainCnt;
|
||||
}
|
||||
|
||||
@Schema(name = "searchReq", description = "일자별 작업 목록 요청")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class searchReq {
|
||||
|
||||
// 페이징 파라미터
|
||||
private int page = 0;
|
||||
private int size = 20;
|
||||
private String sort;
|
||||
|
||||
public Pageable toPageable() {
|
||||
if (sort != null && !sort.isEmpty()) {
|
||||
String[] sortParams = sort.split(",");
|
||||
String property = sortParams[0];
|
||||
Sort.Direction direction =
|
||||
sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC;
|
||||
return PageRequest.of(page, size, Sort.by(direction, property));
|
||||
}
|
||||
return PageRequest.of(page, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.kamco.cd.kamcoback.label.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.kamco.cd.kamcoback.common.utils.enums.Enums;
|
||||
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelMngState;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.UUID;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -14,6 +16,15 @@ import org.springframework.data.domain.Pageable;
|
||||
|
||||
public class LabelWorkDto {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public static class ChangeDetectYear {
|
||||
|
||||
private String code;
|
||||
private String name;
|
||||
}
|
||||
|
||||
@Schema(name = "LabelWorkMng", description = "라벨작업관리")
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -21,8 +32,9 @@ public class LabelWorkDto {
|
||||
@AllArgsConstructor
|
||||
public static class LabelWorkMng {
|
||||
|
||||
private int compareYyyy;
|
||||
private int targetYyyy;
|
||||
private UUID uuid;
|
||||
private Integer compareYyyy;
|
||||
private Integer targetYyyy;
|
||||
private int stage;
|
||||
@JsonFormatDttm private ZonedDateTime createdDttm;
|
||||
private Long detectionTotCnt;
|
||||
@@ -32,6 +44,14 @@ public class LabelWorkDto {
|
||||
private Long labelCompleteTotCnt;
|
||||
@JsonFormatDttm private ZonedDateTime labelStartDttm;
|
||||
|
||||
@JsonProperty("detectYear")
|
||||
public String getDetectYear() {
|
||||
if (compareYyyy == null || targetYyyy == null) {
|
||||
return null;
|
||||
}
|
||||
return compareYyyy + "-" + targetYyyy;
|
||||
}
|
||||
|
||||
public String getLabelState() {
|
||||
|
||||
String mngState = "PENDING";
|
||||
@@ -65,6 +85,20 @@ public class LabelWorkDto {
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class LabelWorkMngDetail {
|
||||
|
||||
private String detectionYear;
|
||||
private Integer stage;
|
||||
@JsonFormatDttm private ZonedDateTime createdDttm;
|
||||
private Long labelTotCnt;
|
||||
private Long labeler;
|
||||
private Long reviewer;
|
||||
}
|
||||
|
||||
@Schema(name = "LabelWorkMngSearchReq", description = "라벨작업관리 검색 요청")
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -80,7 +114,7 @@ public class LabelWorkDto {
|
||||
private int size = 20;
|
||||
|
||||
@Schema(description = "변화탐지년도", example = "2024")
|
||||
private Integer detectYyyy;
|
||||
private String detectYear;
|
||||
|
||||
@Schema(description = "시작일", example = "20260101")
|
||||
private String strtDttm;
|
||||
|
||||
@@ -67,23 +67,17 @@ public class WorkerStatsDto {
|
||||
private Boolean isStagnated;
|
||||
|
||||
// 레거시 필드 (기존 호환성 유지)
|
||||
@Deprecated
|
||||
private Long doneCnt; // completed로 대체
|
||||
@Deprecated private Long doneCnt; // completed로 대체
|
||||
|
||||
@Deprecated
|
||||
private Long skipCnt; // skipped로 대체
|
||||
@Deprecated private Long skipCnt; // skipped로 대체
|
||||
|
||||
@Deprecated
|
||||
private Long remainingCnt; // remaining으로 대체
|
||||
@Deprecated private Long remainingCnt; // remaining으로 대체
|
||||
|
||||
@Deprecated
|
||||
private Long day3AgoDoneCnt; // history.day3Ago로 대체
|
||||
@Deprecated private Long day3AgoDoneCnt; // history.day3Ago로 대체
|
||||
|
||||
@Deprecated
|
||||
private Long day2AgoDoneCnt; // history.day2Ago로 대체
|
||||
@Deprecated private Long day2AgoDoneCnt; // history.day2Ago로 대체
|
||||
|
||||
@Deprecated
|
||||
private Long day1AgoDoneCnt; // history.day1Ago로 대체
|
||||
@Deprecated private Long day1AgoDoneCnt; // history.day1Ago로 대체
|
||||
}
|
||||
|
||||
@Getter
|
||||
@@ -107,7 +101,6 @@ public class WorkerStatsDto {
|
||||
private Long average;
|
||||
}
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
|
||||
@@ -8,8 +8,11 @@ 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.TargetUser;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.DailyHistory;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerListResponse;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
|
||||
import com.kamco.cd.kamcoback.postgres.core.LabelAllocateCoreService;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -21,6 +24,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Transactional
|
||||
public class LabelAllocateService {
|
||||
|
||||
private static final int STAGNATION_THRESHOLD = 10; // 정체 판단 기준 (3일 평균 처리량)
|
||||
private static final int BATCH_SIZE = 100; // 배정 배치 크기
|
||||
|
||||
private final LabelAllocateCoreService labelAllocateCoreService;
|
||||
|
||||
@@ -112,13 +117,17 @@ public class LabelAllocateService {
|
||||
* @param workerType 작업자 유형 (LABELER/INSPECTOR)
|
||||
* @param search 검색어 (이름 또는 사번)
|
||||
* @param sortType 정렬 조건
|
||||
* @param page 페이지 번호 (0부터 시작)
|
||||
* @param size 페이지 크기
|
||||
* @return 작업자 목록 및 통계
|
||||
*/
|
||||
public WorkerListResponse getWorkerStatistics(
|
||||
Long analUid,
|
||||
String workerType,
|
||||
String search,
|
||||
String sortType) {
|
||||
String sortType,
|
||||
Integer page,
|
||||
Integer size) {
|
||||
|
||||
// 프로젝트 정보 조회 (analUid가 있을 때만)
|
||||
var projectInfo = labelAllocateCoreService.findProjectInfo(analUid);
|
||||
@@ -126,9 +135,59 @@ public class LabelAllocateService {
|
||||
// 작업 진행 현황 조회
|
||||
var progressInfo = labelAllocateCoreService.findWorkProgressInfo(analUid);
|
||||
|
||||
// 작업자 통계 조회
|
||||
List<WorkerStatistics> workers =
|
||||
labelAllocateCoreService.findWorkerStatistics(
|
||||
analUid, workerType, search, sortType);
|
||||
|
||||
// 각 작업자별 3일치 처리량 조회
|
||||
LocalDate today = LocalDate.now();
|
||||
for (WorkerStatistics worker : workers) {
|
||||
Long day1Count =
|
||||
labelAllocateCoreService.findDailyProcessedCount(
|
||||
worker.getWorkerId(), workerType, today.minusDays(1), analUid);
|
||||
Long day2Count =
|
||||
labelAllocateCoreService.findDailyProcessedCount(
|
||||
worker.getWorkerId(), workerType, today.minusDays(2), analUid);
|
||||
Long day3Count =
|
||||
labelAllocateCoreService.findDailyProcessedCount(
|
||||
worker.getWorkerId(), workerType, today.minusDays(3), analUid);
|
||||
|
||||
long average = (day1Count + day2Count + day3Count) / 3;
|
||||
|
||||
DailyHistory history =
|
||||
DailyHistory.builder()
|
||||
.day1Ago(day1Count)
|
||||
.day2Ago(day2Count)
|
||||
.day3Ago(day3Count)
|
||||
.average(average)
|
||||
.build();
|
||||
|
||||
worker.setHistory(history);
|
||||
|
||||
// 정체 여부 판단 (3일 평균이 STAGNATION_THRESHOLD 미만일 때)
|
||||
if (average < STAGNATION_THRESHOLD) {
|
||||
worker.setIsStagnated(true);
|
||||
}
|
||||
}
|
||||
|
||||
// 페이징 처리
|
||||
long totalElements = workers.size();
|
||||
int totalPages = (int) Math.ceil((double) totalElements / size);
|
||||
int fromIndex = page * size;
|
||||
int toIndex = Math.min(fromIndex + size, workers.size());
|
||||
|
||||
List<WorkerStatistics> pagedWorkers =
|
||||
(fromIndex < workers.size()) ? workers.subList(fromIndex, toIndex) : List.of();
|
||||
|
||||
return WorkerListResponse.builder()
|
||||
.projectInfo(projectInfo)
|
||||
.progressInfo(progressInfo)
|
||||
.workers(pagedWorkers)
|
||||
.currentPage(page)
|
||||
.pageSize(size)
|
||||
.totalElements(totalElements)
|
||||
.totalPages(totalPages)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,52 @@
|
||||
package com.kamco.cd.kamcoback.label.service;
|
||||
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.ChangeDetectYear;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMng;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMngDetail;
|
||||
import com.kamco.cd.kamcoback.postgres.core.LabelWorkCoreService;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class LabelWorkService {
|
||||
|
||||
private final LabelWorkCoreService labelWorkCoreService;
|
||||
|
||||
public LabelWorkService(LabelWorkCoreService labelWorkCoreService) {
|
||||
this.labelWorkCoreService = labelWorkCoreService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 라벨링작업 관리 목록조회
|
||||
*
|
||||
* @param searchReq
|
||||
* @return
|
||||
*/
|
||||
public Page<LabelWorkMng> labelWorkMngList(LabelWorkDto.LabelWorkMngSearchReq searchReq) {
|
||||
|
||||
return labelWorkCoreService.labelWorkMngList(searchReq);
|
||||
}
|
||||
|
||||
/**
|
||||
* 작업배정 정보 조회
|
||||
*
|
||||
* @param uuid
|
||||
* @return
|
||||
*/
|
||||
public LabelWorkMngDetail findLabelWorkMngDetail(UUID uuid) {
|
||||
return labelWorkCoreService.findLabelWorkMngDetail(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 변화탐지 셀렉트박스 조회
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<ChangeDetectYear> getChangeDetectYear() {
|
||||
return labelWorkCoreService.getChangeDetectYear();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user