[KC-151] 재할당 이전 로직으로 수정

This commit is contained in:
2026-01-08 18:08:09 +09:00
parent be69fe274d
commit 8e8c09f2f6
5 changed files with 48 additions and 53 deletions

View File

@@ -12,9 +12,7 @@ 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;
@@ -123,7 +121,6 @@ public class LabelAllocateService {
public ApiResponseDto.ResponseObj allocateMove(
Integer totalCnt, String uuid, List<String> targetUsers, String userId) {
Map<String, Integer> result = new LinkedHashMap<>();
int userCount = targetUsers.size();
if (userCount <= 0) {
return new ApiResponseDto.ResponseObj(ApiResponseCode.BAD_REQUEST, "재할당할 라벨러를 선택해주세요.");
@@ -132,6 +129,11 @@ public class LabelAllocateService {
int base = totalCnt / userCount;
int remainder = totalCnt % userCount;
Long lastId = null;
List<Long> allIds =
labelAllocateCoreService.fetchNextMoveIds(lastId, totalCnt.longValue(), uuid, userId);
int index = 0;
for (int i = 0; i < userCount; i++) {
int assignCount = base;
@@ -140,11 +142,15 @@ public class LabelAllocateService {
assignCount += remainder;
}
result.put(targetUsers.get(i), assignCount);
// TODO: 재할당 테이블에 update 까지만 하고 나머지는 배치에서 처리하기?
labelAllocateCoreService.assignOwnerReAllocate(
uuid, userId, targetUsers.get(i), (long) assignCount);
// labelAllocateCoreService.assignOwnerReAllocate(
// uuid, userId, targetUsers.get(i), (long) assignCount);
int end = index + assignCount;
List<Long> sub = allIds.subList(index, end);
labelAllocateCoreService.assignOwnerMove(sub, targetUsers.get(i));
index = end;
}
// Long lastId = null;