라벨할당 검수자 insert 로직 수정
This commit is contained in:
@@ -6,7 +6,6 @@ import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto;
|
||||
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.TargetInspector;
|
||||
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.DailyHistory;
|
||||
@@ -16,7 +15,6 @@ 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;
|
||||
@@ -38,19 +36,15 @@ public class LabelAllocateService {
|
||||
/**
|
||||
* 도엽 기준 asc sorting 해서 할당 수만큼 배정하는 로직
|
||||
*
|
||||
* @param labelerAutoType 라벨러 자동/수동 배정 타입
|
||||
* @param inspectorAutoType 검수자 자동/수동 배정 타입
|
||||
* @param stage 회차
|
||||
* @param targetUsers 라벨러 목록
|
||||
* @param targetInspectors 검수자 목록
|
||||
*/
|
||||
@Transactional
|
||||
public ApiResponseDto.ResponseObj allocateAsc(
|
||||
String labelerAutoType,
|
||||
String inspectorAutoType,
|
||||
Integer stage,
|
||||
List<TargetUser> targetUsers,
|
||||
List<TargetInspector> targetInspectors,
|
||||
List<String> targetInspectors,
|
||||
Integer compareYyyy,
|
||||
Integer targetYyyy) {
|
||||
Long lastId = null;
|
||||
@@ -70,35 +64,45 @@ public class LabelAllocateService {
|
||||
|
||||
List<AllocateInfoDto> allIds =
|
||||
labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage);
|
||||
|
||||
// MapSheetAnalInferenceEntity analUid 가져오기
|
||||
Long analUid =
|
||||
labelAllocateCoreService.findMapSheetAnalInferenceUid(compareYyyy, targetYyyy, stage);
|
||||
|
||||
int index = 0;
|
||||
for (TargetUser target : targetUsers) {
|
||||
int end = index + target.getDemand();
|
||||
List<AllocateInfoDto> sub = allIds.subList(index, end);
|
||||
|
||||
labelAllocateCoreService.assignOwner(sub, target.getUserId(), compareYyyy, targetYyyy, stage);
|
||||
labelAllocateCoreService.assignOwner(sub, target.getUserId(), analUid);
|
||||
index = end;
|
||||
}
|
||||
|
||||
// 검수자에게 userCount명 만큼 할당
|
||||
List<LabelAllocateDto.Basic> list =
|
||||
labelAllocateCoreService.findAssignedLabelerList(compareYyyy, targetYyyy, stage);
|
||||
int from = 0;
|
||||
List<LabelAllocateDto.Basic> list = labelAllocateCoreService.findAssignedLabelerList(analUid);
|
||||
|
||||
for (TargetInspector inspector : targetInspectors) {
|
||||
int to = Math.min(from + inspector.getUserCount(), list.size());
|
||||
|
||||
if (from >= to) {
|
||||
break;
|
||||
}
|
||||
|
||||
List<UUID> assignmentUids =
|
||||
list.subList(from, to).stream().map(LabelAllocateDto.Basic::getAssignmentUid).toList();
|
||||
|
||||
labelAllocateCoreService.assignInspectorBulk(assignmentUids, inspector.getInspectorUid());
|
||||
|
||||
from = to;
|
||||
for (String inspector : targetInspectors) {
|
||||
labelAllocateCoreService.insertInspector(analUid, inspector);
|
||||
}
|
||||
|
||||
// int from = 0;
|
||||
// for (TargetInspector inspector : targetInspectors) {
|
||||
// int to = Math.min(from + inspector.getUserCount(), list.size());
|
||||
//
|
||||
// if (from >= to) {
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// List<UUID> assignmentUids =
|
||||
// list.subList(from,
|
||||
// to).stream().map(LabelAllocateDto.Basic::getAssignmentUid).toList();
|
||||
//
|
||||
// labelAllocateCoreService.assignInspectorBulk(assignmentUids,
|
||||
// inspector.getInspectorUid());
|
||||
//
|
||||
// from = to;
|
||||
// }
|
||||
|
||||
return new ApiResponseDto.ResponseObj(ApiResponseCode.OK, "배정이 완료되었습니다.");
|
||||
}
|
||||
|
||||
@@ -165,9 +169,8 @@ public class LabelAllocateService {
|
||||
return WorkerListResponse.builder().progressInfo(progressInfo).workers(workers).build();
|
||||
}
|
||||
|
||||
public InferenceDetail findInferenceDetail(
|
||||
Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
return labelAllocateCoreService.findInferenceDetail(compareYyyy, targetYyyy, stage);
|
||||
public InferenceDetail findInferenceDetail(String uuid) {
|
||||
return labelAllocateCoreService.findInferenceDetail(uuid);
|
||||
}
|
||||
|
||||
public ApiResponseDto.ResponseObj allocateMove(
|
||||
@@ -199,8 +202,7 @@ public class LabelAllocateService {
|
||||
return new ApiResponseDto.ResponseObj(ApiResponseCode.OK, "이관을 완료하였습니다.");
|
||||
}
|
||||
|
||||
public LabelerDetail findLabelerDetail(
|
||||
String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
return labelAllocateCoreService.findLabelerDetail(userId, compareYyyy, targetYyyy, stage);
|
||||
public LabelerDetail findLabelerDetail(String userId, String uuid) {
|
||||
return labelAllocateCoreService.findLabelerDetail(userId, uuid);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user