라벨러 목록조회 임시커밋
This commit is contained in:
@@ -4,15 +4,20 @@ import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto;
|
||||
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;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerListResponse;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
|
||||
import com.kamco.cd.kamcoback.postgres.core.LabelAllocateCoreService;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
public class LabelAllocateService {
|
||||
|
||||
private final LabelAllocateCoreService labelAllocateCoreService;
|
||||
@@ -24,7 +29,8 @@ public class LabelAllocateService {
|
||||
/**
|
||||
* 도엽 기준 asc sorting 해서 할당 수만큼 배정하는 로직
|
||||
*
|
||||
* @param targetUsers
|
||||
* @param targetUsers 라벨러 타겟 목록
|
||||
* @param targetInspectors 검수자 타겟 목록
|
||||
*/
|
||||
@Transactional
|
||||
public void allocateAsc(List<TargetUser> targetUsers, List<TargetInspector> targetInspectors) {
|
||||
@@ -80,4 +86,63 @@ public class LabelAllocateService {
|
||||
public List<UserList> availUserList(String role) {
|
||||
return labelAllocateCoreService.availUserList(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 작업자 목록 및 3일치 통계 조회
|
||||
*
|
||||
* @param analUid 분석 ID
|
||||
* @param workerType 작업자 유형 (LABELER/INSPECTOR)
|
||||
* @param searchName 이름 검색
|
||||
* @param searchEmployeeNo 사번 검색
|
||||
* @param sortType 정렬 조건
|
||||
* @return 작업자 목록 및 통계
|
||||
*/
|
||||
public WorkerListResponse getWorkerStatistics(
|
||||
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);
|
||||
|
||||
// 각 작업자별 3일치 처리량 조회
|
||||
LocalDate today = LocalDate.now();
|
||||
for (WorkerStatistics worker : workers) {
|
||||
Long day1Count =
|
||||
labelAllocateCoreService.findDailyProcessedCount(
|
||||
worker.getWorkerId(), workerType, today.minusDays(1), analUid);
|
||||
Long day2Count =
|
||||
labelAllocateCoreService.findDailyProcessedCount(
|
||||
worker.getWorkerId(), workerType, today.minusDays(2), analUid);
|
||||
Long day3Count =
|
||||
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();
|
||||
|
||||
worker.setHistory(history);
|
||||
|
||||
// 정체 여부 판단 (3일 평균이 특정 기준 미만일 때 - 예: 10건 미만)
|
||||
if (average < 10) {
|
||||
worker.setIsStagnated(true);
|
||||
}
|
||||
}
|
||||
|
||||
return WorkerListResponse.builder().progressInfo(progressInfo).workers(workers).build();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user