파라미터 yyyy기준으로 변경

This commit is contained in:
2026-01-02 22:17:42 +09:00
parent c85dc1a070
commit a7b04d0be8
6 changed files with 608 additions and 551 deletions

View File

@@ -36,208 +36,214 @@ public class LabelAllocateApiController {
@Operation(summary = "배정 가능한 사용자 목록 조회", description = "라벨링 작업 배정을 위한 활성 상태의 사용자 목록을 조회합니다.")
@ApiResponses(
value = {
@ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음"),
@ApiResponse(responseCode = "500", description = "서버 오류")
})
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) {
@Parameter(
description = "사용자 역할",
example = "LABELER",
schema = @Schema(allowableValues = {"LABELER", "REVIEWER"}))
@RequestParam
String role) {
return ApiResponseDto.ok(labelAllocateService.availUserList(role));
}
@Operation(summary = "작업현황관리(작업자 목록 및 3일치 통계 조회)", description = "학습데이터 제작 현황 조회 API입니다.")
@ApiResponses(
value = {
@ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "404", description = "데이터를 찾을 수 없음"),
@ApiResponse(responseCode = "500", description = "서버 오류")
})
value = {
@ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "404", description = "데이터를 찾을 수 없음"),
@ApiResponse(responseCode = "500", description = "서버 오류")
})
@GetMapping("/admin/workers")
public ApiResponseDto<WorkerListResponse> getWorkerStatistics(
@Parameter(description = "분석 ID (필수)", required = true, example = "3") @RequestParam
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 searchName,
@Parameter(description = "작업자 사번 검색 (부분 일치)", example = "1234567")
@RequestParam(required = false)
String searchEmployeeNo,
@Parameter(
description = "정렬 조건 (선택) - 미입력 시 이름 오름차순",
example = "REMAINING_DESC",
schema =
@Schema(
allowableValues = {
"REMAINING_DESC",
"REMAINING_ASC",
"NAME_ASC",
"NAME_DESC"
},
defaultValue = "NAME_ASC"))
@RequestParam(required = false)
String sort) {
@Parameter(description = "분석 ID (필수)", required = true, example = "3") @RequestParam
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 searchName,
@Parameter(description = "작업자 사번 검색 (부분 일치)", example = "1234567")
@RequestParam(required = false)
String searchEmployeeNo,
@Parameter(
description = "정렬 조건 (선택) - 미입력 시 이름 오름차순",
example = "REMAINING_DESC",
schema =
@Schema(
allowableValues = {
"REMAINING_DESC",
"REMAINING_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(
analUid, workerType, searchName, searchEmployeeNo, sort));
labelAllocateService.getWorkerStatistics(
analUid, workerType, searchName, searchEmployeeNo, sort));
}
@Operation(summary = "작업 배정", description = "작업 배정")
@ApiResponses(
value = {
@ApiResponse(
responseCode = "201",
description = "등록 성공",
content =
@Content(
mediaType = "application/json",
schema = @Schema(implementation = Long.class),
examples = {
@ExampleObject(
name = "라벨러 할당 예시",
description = "라벨러 할당 예시",
value =
"""
{
"autoType": "AUTO",
"stage": 4,
"labelers": [
{
"userId": "123456",
"demand": 1000
},
{
"userId": "010222297501",
"demand": 400
},
{
"userId": "01022223333",
"demand": 440
}
],
"inspectors": [
{
"inspectorUid": "K20251216001",
"userCount": 1000
},
{
"inspectorUid": "01022225555",
"userCount": 340
},
{
"inspectorUid": "K20251212001",
"userCount": 500
}
value = {
@ApiResponse(
responseCode = "201",
description = "등록 성공",
content =
@Content(
mediaType = "application/json",
schema = @Schema(implementation = Long.class),
examples = {
@ExampleObject(
name = "라벨러 할당 예시",
description = "라벨러 할당 예시",
value =
"""
{
"autoType": "AUTO",
"stage": 4,
"labelers": [
{
"userId": "123456",
"demand": 1000
},
{
"userId": "010222297501",
"demand": 400
},
{
"userId": "01022223333",
"demand": 440
}
],
"inspectors": [
{
"inspectorUid": "K20251216001",
"userCount": 1000
},
{
"inspectorUid": "01022225555",
"userCount": 340
},
{
"inspectorUid": "K20251212001",
"userCount": 500
}
]
}
""")
})),
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
})
]
}
""")
})),
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
})
@PostMapping("/allocate")
public ApiResponseDto<Void> labelAllocate(@RequestBody LabelAllocateDto.AllocateDto dto) {
labelAllocateService.allocateAsc(
dto.getAutoType(),
dto.getStage(),
dto.getLabelers(),
dto.getInspectors(),
dto.getAnalUid());
dto.getAutoType(),
dto.getStage(),
dto.getLabelers(),
dto.getInspectors(),
dto.getCompareYyyy(),
dto.getTargetYyyy()
);
return ApiResponseDto.ok(null);
}
@Operation(summary = "추론 상세 조회", description = "분석 ID에 해당하는 추론 상세 정보를 조회합니다.")
@ApiResponses(
value = {
@ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "404", description = "데이터를 찾을 수 없음"),
@ApiResponse(responseCode = "500", description = "서버 오류")
})
value = {
@ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "404", description = "데이터를 찾을 수 없음"),
@ApiResponse(responseCode = "500", description = "서버 오류")
})
@GetMapping("/stage-detail")
public ApiResponseDto<InferenceDetail> findInferenceDetail(
@Parameter(description = "분석 ID", required = true, example = "3") @RequestParam
Long analUid) {
return ApiResponseDto.ok(labelAllocateService.findInferenceDetail(analUid));
@Parameter(description = "비교년도", required = true, example = "2022") @RequestParam Integer compareYyyy,
@Parameter(description = "기준년도", required = true, example = "2024") @RequestParam Integer targetYyyy,
@Parameter(description = "회차", required = true, example = "4") @RequestParam Integer stage
) {
return ApiResponseDto.ok(labelAllocateService.findInferenceDetail(compareYyyy, targetYyyy, stage));
}
@Operation(summary = "작업이관 > 라벨러 상세 정보", description = "작업이관 > 라벨러 상세 정보")
@GetMapping("/labeler-detail")
public ApiResponseDto<LabelerDetail> findLabelerDetail(
@RequestParam(defaultValue = "01022223333") String userId,
@RequestParam(defaultValue = "3") Long analUid) {
return ApiResponseDto.ok(labelAllocateService.findLabelerDetail(userId, analUid));
@RequestParam(defaultValue = "01022223333") String userId,
@Parameter(description = "비교년도", required = true, example = "2022") @RequestParam Integer compareYyyy,
@Parameter(description = "기준년도", required = true, example = "2024") @RequestParam Integer targetYyyy,
@Parameter(description = "회차", required = true, example = "4") @RequestParam Integer stage) {
return ApiResponseDto.ok(labelAllocateService.findLabelerDetail(userId, compareYyyy, targetYyyy, stage));
}
@Operation(summary = "작업 이관", description = "작업 이관")
@ApiResponses(
value = {
@ApiResponse(
responseCode = "201",
description = "등록 성공",
content =
@Content(
mediaType = "application/json",
schema = @Schema(implementation = Long.class),
examples = {
@ExampleObject(
name = "라벨러 할당 예시",
description = "라벨러 할당 예시",
value =
"""
{
"autoType": "AUTO",
"stage": 4,
"labelers": [
{
"userId": "123456",
"demand": 10
},
{
"userId": "010222297501",
"demand": 5
}
]
}
""")
})),
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
})
value = {
@ApiResponse(
responseCode = "201",
description = "등록 성공",
content =
@Content(
mediaType = "application/json",
schema = @Schema(implementation = Long.class),
examples = {
@ExampleObject(
name = "라벨러 할당 예시",
description = "라벨러 할당 예시",
value =
"""
{
"autoType": "AUTO",
"stage": 4,
"labelers": [
{
"userId": "123456",
"demand": 10
},
{
"userId": "010222297501",
"demand": 5
}
]
}
""")
})),
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
})
@PostMapping("/allocate-move")
public ApiResponseDto<Void> 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) {
@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) {
labelAllocateService.allocateMove(dto.getAutoType(), dto.getStage(), dto.getLabelers());
labelAllocateService.allocateMove(dto.getAutoType(), dto.getStage(), dto.getLabelers(), dto.getCompareYyyy(), dto.getTargetYyyy());
return ApiResponseDto.ok(null);
}

View File

@@ -87,9 +87,15 @@ public class LabelAllocateDto {
@AllArgsConstructor
public static class AllocateDto {
@Schema(description = "분석 ID", example = "3", required = true)
@Schema(description = "분석 ID", example = "3")
private Long analUid;
@Schema(description = "비교년도", example = "2022", required = true)
private Integer compareYyyy;
@Schema(description = "기준년도", example = "2024", required = true)
private Integer targetYyyy;
@Schema(description = "자동/수동여부(AUTO/MANUAL)", example = "AUTO")
private String autoType;
@@ -197,5 +203,11 @@ public class LabelAllocateDto {
@Schema(description = "라벨러 할당 목록")
private List<TargetUser> labelers;
@Schema(description = "비교년도", example = "2022")
private Integer compareYyyy;
@Schema(description = "기준년도", example = "2024")
private Integer targetYyyy;
}
}

View File

@@ -34,23 +34,24 @@ public class LabelAllocateService {
/**
* 도엽 기준 asc sorting 해서 할당 수만큼 배정하는 로직
*
* @param autoType 자동/수동 배정 타입
* @param stage 회차
* @param targetUsers 라벨러 목록
* @param autoType 자동/수동 배정 타입
* @param stage 회차
* @param targetUsers 라벨러 목록
* @param targetInspectors 검수자 목록
* @param analUid 분석 ID
*/
@Transactional
public void allocateAsc(
String autoType,
Integer stage,
List<TargetUser> targetUsers,
List<TargetInspector> targetInspectors,
Long analUid) {
String autoType,
Integer stage,
List<TargetUser> targetUsers,
List<TargetInspector> targetInspectors,
Integer compareYyyy,
Integer targetYyyy
) {
Long lastId = null;
// geom 잔여건수 조회
Long chargeCnt = labelAllocateCoreService.findLabelUnAssignedCnt(analUid, stage);
Long chargeCnt = labelAllocateCoreService.findLabelUnAssignedCnt(stage, compareYyyy, targetYyyy);
// Long totalDemand = targetUsers.stream().mapToLong(TargetUser::getDemand).sum();
// if (!Objects.equals(chargeCnt, totalDemand)) {
// log.info("chargeCnt != totalDemand");
@@ -61,18 +62,18 @@ public class LabelAllocateService {
return;
}
List<Long> allIds = labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, analUid);
List<Long> allIds = labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage);
int index = 0;
for (TargetUser target : targetUsers) {
int end = index + target.getDemand();
List<Long> sub = allIds.subList(index, end);
labelAllocateCoreService.assignOwner(sub, target.getUserId(), analUid);
labelAllocateCoreService.assignOwner(sub, target.getUserId(), compareYyyy, targetYyyy, stage);
index = end;
}
// 검수자에게 userCount명 만큼 할당
List<LabelAllocateDto.Basic> list = labelAllocateCoreService.findAssignedLabelerList(analUid);
List<LabelAllocateDto.Basic> list = labelAllocateCoreService.findAssignedLabelerList(compareYyyy, targetYyyy, stage);
int from = 0;
for (TargetInspector inspector : targetInspectors) {
@@ -83,7 +84,7 @@ public class LabelAllocateService {
}
List<UUID> assignmentUids =
list.subList(from, to).stream().map(LabelAllocateDto.Basic::getAssignmentUid).toList();
list.subList(from, to).stream().map(LabelAllocateDto.Basic::getAssignmentUid).toList();
labelAllocateCoreService.assignInspectorBulk(assignmentUids, inspector.getInspectorUid());
@@ -98,50 +99,50 @@ public class LabelAllocateService {
/**
* 작업자 목록 및 3일치 통계 조회
*
* @param analUid 분석 ID
* @param workerType 작업자 유형 (LABELER/INSPECTOR)
* @param searchName 이름 검색
* @param analUid 분석 ID
* @param workerType 작업자 유형 (LABELER/INSPECTOR)
* @param searchName 이름 검색
* @param searchEmployeeNo 사번 검색
* @param sortType 정렬 조건
* @param sortType 정렬 조건
* @return 작업자 목록 및 통계
*/
public WorkerListResponse getWorkerStatistics(
Long analUid,
String workerType,
String searchName,
String searchEmployeeNo,
String sortType) {
Long analUid,
String workerType,
String searchName,
String searchEmployeeNo,
String sortType) {
// 작업 진행 현황 조회
var progressInfo = labelAllocateCoreService.findWorkProgressInfo(analUid);
// 작업자 통계 조회
List<WorkerStatistics> workers =
labelAllocateCoreService.findWorkerStatistics(
analUid, workerType, searchName, searchEmployeeNo, sortType);
labelAllocateCoreService.findWorkerStatistics(
analUid, workerType, searchName, searchEmployeeNo, sortType);
// 각 작업자별 3일치 처리량 조회
LocalDate today = LocalDate.now();
for (WorkerStatistics worker : workers) {
Long day1Count =
labelAllocateCoreService.findDailyProcessedCount(
worker.getWorkerId(), workerType, today.minusDays(1), analUid);
labelAllocateCoreService.findDailyProcessedCount(
worker.getWorkerId(), workerType, today.minusDays(1), analUid);
Long day2Count =
labelAllocateCoreService.findDailyProcessedCount(
worker.getWorkerId(), workerType, today.minusDays(2), analUid);
labelAllocateCoreService.findDailyProcessedCount(
worker.getWorkerId(), workerType, today.minusDays(2), analUid);
Long day3Count =
labelAllocateCoreService.findDailyProcessedCount(
worker.getWorkerId(), workerType, today.minusDays(3), analUid);
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();
DailyHistory.builder()
.day1Ago(day1Count)
.day2Ago(day2Count)
.day3Ago(day3Count)
.average(average)
.build();
worker.setHistory(history);
@@ -154,11 +155,12 @@ public class LabelAllocateService {
return WorkerListResponse.builder().progressInfo(progressInfo).workers(workers).build();
}
public InferenceDetail findInferenceDetail(Long analUid) {
return labelAllocateCoreService.findInferenceDetail(analUid);
public InferenceDetail findInferenceDetail(Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateCoreService.findInferenceDetail(compareYyyy, targetYyyy, stage);
}
public void allocateMove(String autoType, Integer stage, List<TargetUser> targetUsers) {
public void allocateMove(String autoType, Integer stage, List<TargetUser> targetUsers, Integer compareYyyy,
Integer targetYyyy) {
Long lastId = null;
Long chargeCnt = targetUsers.stream().mapToLong(TargetUser::getDemand).sum();
@@ -167,7 +169,7 @@ public class LabelAllocateService {
return;
}
List<Long> allIds = labelAllocateCoreService.fetchNextMoveIds(lastId, chargeCnt);
List<Long> allIds = labelAllocateCoreService.fetchNextMoveIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage);
int index = 0;
for (TargetUser target : targetUsers) {
int end = index + target.getDemand();
@@ -178,7 +180,7 @@ public class LabelAllocateService {
}
}
public LabelerDetail findLabelerDetail(String userId, Long analUid) {
return labelAllocateCoreService.findLabelerDetail(userId, analUid);
public LabelerDetail findLabelerDetail(String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateCoreService.findLabelerDetail(userId, compareYyyy, targetYyyy, stage);
}
}