Merge remote-tracking branch 'origin/feat/dev_251201' into feat/dev_251201
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.kamco.cd.kamcoback.label.service;
|
||||
|
||||
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.TargetInspector;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.TargetUser;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
|
||||
@@ -10,7 +11,7 @@ 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 java.util.UUID;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -29,57 +30,56 @@ public class LabelAllocateService {
|
||||
/**
|
||||
* 도엽 기준 asc sorting 해서 할당 수만큼 배정하는 로직
|
||||
*
|
||||
* @param targetUsers 라벨러 타겟 목록
|
||||
* @param targetInspectors 검수자 타겟 목록
|
||||
* @param targetUsers
|
||||
*/
|
||||
@Transactional
|
||||
public void allocateAsc(List<TargetUser> targetUsers, List<TargetInspector> targetInspectors) {
|
||||
public void allocateAsc(
|
||||
String autoType,
|
||||
Integer stage,
|
||||
List<TargetUser> targetUsers,
|
||||
List<TargetInspector> targetInspectors)
|
||||
throws Exception {
|
||||
Long lastId = null;
|
||||
|
||||
// geom 잔여건수 != 프론트에서 넘어 온 총 건수 -> return
|
||||
Long chargeCnt = labelAllocateCoreService.findLabelUnAssignedCnt(3L); // TODO
|
||||
Long totalDemand = targetUsers.stream().mapToLong(TargetUser::getDemand).sum();
|
||||
if (!Objects.equals(chargeCnt, totalDemand)) {
|
||||
log.info("chargeCnt != totalDemand");
|
||||
// Long totalDemand = targetUsers.stream().mapToLong(TargetUser::getDemand).sum();
|
||||
// if (!Objects.equals(chargeCnt, totalDemand)) {
|
||||
// log.info("chargeCnt != totalDemand");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (chargeCnt <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 라벨러에게 건수만큼 할당
|
||||
List<Long> allIds = labelAllocateCoreService.fetchNextIds(lastId, chargeCnt);
|
||||
int index = 0;
|
||||
for (TargetUser target : targetUsers) {
|
||||
int remaining = target.getDemand();
|
||||
int end = index + target.getDemand();
|
||||
List<Long> sub = allIds.subList(index, end);
|
||||
|
||||
while (remaining > 0) {
|
||||
|
||||
int batchSize = Math.min(remaining, 100);
|
||||
List<Long> ids = labelAllocateCoreService.fetchNextIds(lastId, batchSize);
|
||||
|
||||
if (ids.isEmpty()) {
|
||||
return; // 더이상 할당할 데이터가 없으면 return
|
||||
}
|
||||
|
||||
labelAllocateCoreService.assignOwner(ids, target.getUserId());
|
||||
|
||||
remaining -= ids.size();
|
||||
lastId = ids.get(ids.size() - 1);
|
||||
}
|
||||
labelAllocateCoreService.assignOwner(sub, target.getUserId());
|
||||
index = end;
|
||||
}
|
||||
|
||||
// 검수자에게 userCount명 만큼 할당
|
||||
List<LabelAllocateDto.Basic> list = labelAllocateCoreService.findAssignedLabelerList(3L);
|
||||
int reviewerIndex = 0;
|
||||
int count = 0;
|
||||
log.info("list : " + list.size());
|
||||
int from = 0;
|
||||
|
||||
for (LabelAllocateDto.Basic labeler : list) {
|
||||
TargetInspector inspector = targetInspectors.get(reviewerIndex);
|
||||
labelAllocateCoreService.assignInspector(
|
||||
labeler.getAssignmentUid(), inspector.getInspectorUid());
|
||||
count++;
|
||||
for (TargetInspector inspector : targetInspectors) {
|
||||
int to = Math.min(from + inspector.getUserCount(), list.size());
|
||||
|
||||
if (count == inspector.getUserCount()) {
|
||||
reviewerIndex++;
|
||||
count = 0;
|
||||
if (from >= to) {
|
||||
break;
|
||||
}
|
||||
|
||||
List<UUID> assignmentUids =
|
||||
list.subList(from, to).stream().map(LabelAllocateDto.Basic::getAssignmentUid).toList();
|
||||
|
||||
labelAllocateCoreService.assignInspectorBulk(assignmentUids, inspector.getInspectorUid());
|
||||
|
||||
from = to;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,4 +145,8 @@ public class LabelAllocateService {
|
||||
|
||||
return WorkerListResponse.builder().progressInfo(progressInfo).workers(workers).build();
|
||||
}
|
||||
|
||||
public InferenceDetail findInferenceDetail(Long analUid) {
|
||||
return labelAllocateCoreService.findInferenceDetail(analUid);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user