This commit is contained in:
2026-01-02 22:18:09 +09:00
parent a7b04d0be8
commit dc2b9286f4
7 changed files with 595 additions and 581 deletions

View File

@@ -34,24 +34,24 @@ public class LabelAllocateService {
/**
* 도엽 기준 asc sorting 해서 할당 수만큼 배정하는 로직
*
* @param autoType 자동/수동 배정 타입
* @param stage 회차
* @param targetUsers 라벨러 목록
* @param autoType 자동/수동 배정 타입
* @param stage 회차
* @param targetUsers 라벨러 목록
* @param targetInspectors 검수자 목록
*/
@Transactional
public void allocateAsc(
String autoType,
Integer stage,
List<TargetUser> targetUsers,
List<TargetInspector> targetInspectors,
Integer compareYyyy,
Integer targetYyyy
) {
String autoType,
Integer stage,
List<TargetUser> targetUsers,
List<TargetInspector> targetInspectors,
Integer compareYyyy,
Integer targetYyyy) {
Long lastId = null;
// geom 잔여건수 조회
Long chargeCnt = labelAllocateCoreService.findLabelUnAssignedCnt(stage, compareYyyy, targetYyyy);
Long chargeCnt =
labelAllocateCoreService.findLabelUnAssignedCnt(stage, compareYyyy, targetYyyy);
// Long totalDemand = targetUsers.stream().mapToLong(TargetUser::getDemand).sum();
// if (!Objects.equals(chargeCnt, totalDemand)) {
// log.info("chargeCnt != totalDemand");
@@ -62,7 +62,8 @@ public class LabelAllocateService {
return;
}
List<Long> allIds = labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage);
List<Long> allIds =
labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage);
int index = 0;
for (TargetUser target : targetUsers) {
int end = index + target.getDemand();
@@ -73,7 +74,8 @@ public class LabelAllocateService {
}
// 검수자에게 userCount명 만큼 할당
List<LabelAllocateDto.Basic> list = labelAllocateCoreService.findAssignedLabelerList(compareYyyy, targetYyyy, stage);
List<LabelAllocateDto.Basic> list =
labelAllocateCoreService.findAssignedLabelerList(compareYyyy, targetYyyy, stage);
int from = 0;
for (TargetInspector inspector : targetInspectors) {
@@ -84,7 +86,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());
@@ -99,50 +101,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);
@@ -155,12 +157,17 @@ public class LabelAllocateService {
return WorkerListResponse.builder().progressInfo(progressInfo).workers(workers).build();
}
public InferenceDetail findInferenceDetail(Integer compareYyyy, Integer targetYyyy, Integer stage) {
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, Integer compareYyyy,
Integer targetYyyy) {
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();
@@ -169,7 +176,9 @@ public class LabelAllocateService {
return;
}
List<Long> allIds = labelAllocateCoreService.fetchNextMoveIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage);
List<Long> allIds =
labelAllocateCoreService.fetchNextMoveIds(
lastId, chargeCnt, compareYyyy, targetYyyy, stage);
int index = 0;
for (TargetUser target : targetUsers) {
int end = index + target.getDemand();
@@ -180,7 +189,8 @@ public class LabelAllocateService {
}
}
public LabelerDetail findLabelerDetail(String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) {
public LabelerDetail findLabelerDetail(
String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateCoreService.findLabelerDetail(userId, compareYyyy, targetYyyy, stage);
}
}