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