라벨 재할당 로직 수정, 배치로 재배치는 나중에
This commit is contained in:
@@ -191,12 +191,9 @@ public class LabelAllocateApiController {
|
||||
@RequestBody
|
||||
LabelAllocateDto.AllocateMoveDto dto) {
|
||||
|
||||
int compareYyyy = Integer.parseInt(dto.getYyyy().split("-")[0]);
|
||||
int targetYyyy = Integer.parseInt(dto.getYyyy().split("-")[1]);
|
||||
|
||||
return ApiResponseDto.okObject(
|
||||
labelAllocateService.allocateMove(
|
||||
dto.getStage(), dto.getLabelers(), compareYyyy, targetYyyy, dto.getUserId()));
|
||||
dto.getTotalCnt(), dto.getUuid(), dto.getLabelers(), dto.getUserId()));
|
||||
}
|
||||
|
||||
@Operation(
|
||||
@@ -232,7 +229,7 @@ public class LabelAllocateApiController {
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류")
|
||||
})
|
||||
@GetMapping("/move-user")
|
||||
public ApiResponseDto<List<LabelAllocateDto.MoveUserList>> availMoveUserList(
|
||||
public ApiResponseDto<LabelAllocateDto.MoveInfo> availMoveUserList(
|
||||
@Parameter(description = "해당 사용자 사번", example = "01022223333") @RequestParam String userId,
|
||||
@Parameter(description = "회차 마스터 key", example = "f97dc186-e6d3-4645-9737-3173dde8dc64")
|
||||
@RequestParam
|
||||
|
||||
@@ -229,34 +229,20 @@ public class LabelAllocateDto {
|
||||
@AllArgsConstructor
|
||||
public static class AllocateMoveDto {
|
||||
|
||||
@Schema(description = "회차", example = "4")
|
||||
private Integer stage;
|
||||
@Schema(description = "총 잔여 건수", example = "5061")
|
||||
private Integer totalCnt;
|
||||
|
||||
@Schema(
|
||||
description = "이관할 라벨러 할당량",
|
||||
example =
|
||||
"""
|
||||
description = "이관할 라벨러",
|
||||
example = """
|
||||
[
|
||||
{
|
||||
"userId": "123456",
|
||||
"demand": 10
|
||||
},
|
||||
{
|
||||
"userId": "010222297501",
|
||||
"demand": 5
|
||||
}
|
||||
"87654321"
|
||||
]
|
||||
""")
|
||||
private List<TargetUser> labelers;
|
||||
private List<String> labelers;
|
||||
|
||||
@Schema(description = "비교년도-기준년도", example = "2022-2024")
|
||||
private String yyyy;
|
||||
|
||||
// @Schema(description = "비교년도", example = "2022")
|
||||
// private Integer compareYyyy;
|
||||
//
|
||||
// @Schema(description = "기준년도", example = "2024")
|
||||
// private Integer targetYyyy;
|
||||
@Schema(description = "회차 마스터 key", example = "f97dc186-e6d3-4645-9737-3173dde8dc64")
|
||||
private String uuid;
|
||||
|
||||
@Schema(description = "대상 사번", example = "01022223333")
|
||||
private String userId;
|
||||
@@ -269,6 +255,7 @@ public class LabelAllocateDto {
|
||||
|
||||
private Long geoUid;
|
||||
private Long mapSheetNum;
|
||||
private Long pnu;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@@ -320,4 +307,13 @@ public class LabelAllocateDto {
|
||||
private Long remainCnt;
|
||||
private Double percent;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public static class MoveInfo {
|
||||
|
||||
private Long totalCnt;
|
||||
private List<MoveUserList> moveUserList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.kamco.cd.kamcoback.label.dto;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.UUID;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class LabelLabelerDto {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public static class Basic {
|
||||
|
||||
private UUID lbUsrUid;
|
||||
private Long analUid;
|
||||
private String workerUid;
|
||||
private Long allocateCnt;
|
||||
private Boolean deleted;
|
||||
private Boolean reAllocateYn;
|
||||
private Long reAllocateCnt;
|
||||
private String reAllocateWorkerUid;
|
||||
private ZonedDateTime createdDttm;
|
||||
private ZonedDateTime updatedDttm;
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,14 @@ import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.AllocateInfoDto;
|
||||
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.LabelAllocateDto.MoveUserList;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.MoveInfo;
|
||||
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.WorkerListResponse;
|
||||
import com.kamco.cd.kamcoback.postgres.core.LabelAllocateCoreService;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -73,6 +75,9 @@ public class LabelAllocateService {
|
||||
|
||||
labelAllocateCoreService.assignOwner(sub, target.getUserId(), analUid);
|
||||
index = end;
|
||||
|
||||
// 라벨러 유저 테이블에 insert
|
||||
labelAllocateCoreService.insertLabelerUser(analUid, target.getUserId(), target.getDemand());
|
||||
}
|
||||
|
||||
// 검수자 할당 테이블에 insert. TODO: 익일 배치로 라벨링 완료된 내역을 검수자에게 할당해야 함
|
||||
@@ -116,31 +121,51 @@ public class LabelAllocateService {
|
||||
}
|
||||
|
||||
public ApiResponseDto.ResponseObj allocateMove(
|
||||
Integer stage,
|
||||
List<TargetUser> targetUsers,
|
||||
Integer compareYyyy,
|
||||
Integer targetYyyy,
|
||||
String userId) {
|
||||
Long lastId = null;
|
||||
Integer totalCnt, String uuid, List<String> targetUsers, String userId) {
|
||||
|
||||
Long chargeCnt = targetUsers.stream().mapToLong(TargetUser::getDemand).sum();
|
||||
|
||||
if (chargeCnt <= 0) {
|
||||
return new ApiResponseDto.ResponseObj(ApiResponseCode.BAD_REQUEST, "이관할 데이터를 입력해주세요.");
|
||||
Map<String, Integer> result = new LinkedHashMap<>();
|
||||
int userCount = targetUsers.size();
|
||||
if (userCount <= 0) {
|
||||
return new ApiResponseDto.ResponseObj(ApiResponseCode.BAD_REQUEST, "재할당할 라벨러를 선택해주세요.");
|
||||
}
|
||||
|
||||
List<Long> allIds =
|
||||
labelAllocateCoreService.fetchNextMoveIds(
|
||||
lastId, chargeCnt, compareYyyy, targetYyyy, stage, userId);
|
||||
int index = 0;
|
||||
for (TargetUser target : targetUsers) {
|
||||
int end = index + target.getDemand();
|
||||
List<Long> sub = allIds.subList(index, end);
|
||||
int base = totalCnt / userCount;
|
||||
int remainder = totalCnt % userCount;
|
||||
|
||||
labelAllocateCoreService.assignOwnerMove(sub, target.getUserId());
|
||||
index = end;
|
||||
for (int i = 0; i < userCount; i++) {
|
||||
int assignCount = base;
|
||||
|
||||
// 마지막 사람에게 나머지 몰아주기
|
||||
if (i == userCount - 1) {
|
||||
assignCount += remainder;
|
||||
}
|
||||
|
||||
result.put(targetUsers.get(i), assignCount);
|
||||
|
||||
// TODO: 재할당 테이블에 update 까지만 하고 나머지는 배치에서 처리하기?
|
||||
labelAllocateCoreService.assignOwnerReAllocate(
|
||||
uuid, userId, targetUsers.get(i), (long) assignCount);
|
||||
}
|
||||
|
||||
// Long lastId = null;
|
||||
// Long chargeCnt = targetUsers.stream().mapToLong(TargetUser::getDemand).sum();
|
||||
//
|
||||
// if (chargeCnt <= 0) {
|
||||
// return new ApiResponseDto.ResponseObj(ApiResponseCode.BAD_REQUEST, "이관할 데이터를 입력해주세요.");
|
||||
// }
|
||||
//
|
||||
// List<Long> allIds =
|
||||
// labelAllocateCoreService.fetchNextMoveIds(
|
||||
// lastId, chargeCnt, compareYyyy, targetYyyy, stage, userId);
|
||||
// int index = 0;
|
||||
// for (TargetUser target : targetUsers) {
|
||||
// int end = index + target.getDemand();
|
||||
// List<Long> sub = allIds.subList(index, end);
|
||||
//
|
||||
// labelAllocateCoreService.assignOwnerMove(sub, target.getUserId());
|
||||
// index = end;
|
||||
// }
|
||||
|
||||
return new ApiResponseDto.ResponseObj(ApiResponseCode.OK, "이관을 완료하였습니다.");
|
||||
}
|
||||
|
||||
@@ -161,7 +186,7 @@ public class LabelAllocateService {
|
||||
}
|
||||
}
|
||||
|
||||
public List<MoveUserList> moveAvailUserList(String userId, String uuid) {
|
||||
public MoveInfo moveAvailUserList(String userId, String uuid) {
|
||||
return labelAllocateCoreService.moveAvailUserList(userId, uuid);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user