This commit is contained in:
2026-01-05 13:36:15 +09:00
parent d86e70e27e
commit 8c149605e5
8 changed files with 295 additions and 371 deletions

View File

@@ -5,6 +5,7 @@ import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
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.LabelerDetail;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelingStatDto;
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerListResponse;
import com.kamco.cd.kamcoback.label.service.LabelAllocateService;
import io.swagger.v3.oas.annotations.Operation;
@@ -18,6 +19,7 @@ import jakarta.validation.Valid;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -93,19 +95,16 @@ public class LabelAllocateApiController {
defaultValue = "NAME_ASC"))
@RequestParam(required = false)
String sort,
@Parameter(description = "페이지 번호 (0부터 시작)", example = "0")
@RequestParam(defaultValue = "0")
@Parameter(description = "페이지 번호 (0부터 시작)", example = "0") @RequestParam(defaultValue = "0")
Integer page,
@Parameter(description = "페이지 크기", example = "20")
@RequestParam(defaultValue = "20")
@Parameter(description = "페이지 크기", example = "20") @RequestParam(defaultValue = "20")
Integer size) {
// type이 null이면 기본값으로 LABELER 설정
String workerType = (type == null || type.isEmpty()) ? RoleType.LABELER.name() : type;
return ApiResponseDto.ok(
labelAllocateService.getWorkerStatistics(
null, workerType, search, sort, page, size));
labelAllocateService.getWorkerStatistics(null, workerType, search, sort, page, size));
}
@Operation(summary = "라벨링작업 관리 > 작업 배정", description = "라벨링작업 관리 > 작업 배정")
@@ -154,24 +153,23 @@ public class LabelAllocateApiController {
}
@Operation(
summary = "작업현황 관리 > 라벨러/검수자 상세 정보, 작업이관 팝업 내 라벨러 상세 정보 동일",
description = "작업현황 관리 > 라벨러/검수자 상세 정보, 작업이관 팝업 내 라벨러 상세 정보 동일")
summary = "작업현황 관리 > 라벨러/검수자 상세 정보, 작업이관 팝업 내 라벨러 상세 정보 동일",
description = "작업현황 관리 > 라벨러/검수자 상세 정보, 작업이관 팝업 내 라벨러 상세 정보 동일")
@GetMapping("/user-detail")
public ApiResponseDto<LabelerDetail> findUserDetail(
@RequestParam(defaultValue = "01022223333", required = true) String userId,
@Parameter(
description = "회차 마스터 key",
required = true,
example = "8584e8d4-53b3-4582-bde2-28a81495a626")
@RequestParam
String uuid,
@Schema(
allowableValues = {"LABELER", "REVIEWER"},
defaultValue = "LABELER")
@Parameter(
description = "라벨러/검수자(LABELER/REVIEWER)",
required = true) @RequestParam String type
) {
@RequestParam(defaultValue = "01022223333", required = true) String userId,
@Parameter(
description = "회차 마스터 key",
required = true,
example = "8584e8d4-53b3-4582-bde2-28a81495a626")
@RequestParam
String uuid,
@Schema(
allowableValues = {"LABELER", "REVIEWER"},
defaultValue = "LABELER")
@Parameter(description = "라벨러/검수자(LABELER/REVIEWER)", required = true)
@RequestParam
String type) {
return ApiResponseDto.ok(labelAllocateService.findUserDetail(userId, uuid, type));
}
@@ -211,30 +209,26 @@ public class LabelAllocateApiController {
}
@Operation(
summary = "라벨링작업 관리 > 상세 > 라벨러/검수자 일별 작업량 목록",
description = "라벨링작업 관리 > 상세 > 라벨러/검수자 일별 작업량 목록")
summary = "라벨링작업 관리 > 상세 > 라벨러/검수자 일별 작업량 목록",
description = "라벨링작업 관리 > 상세 > 라벨러/검수자 일별 작업량 목록")
@GetMapping("/daily-list")
public ApiResponseDto<Page<LabelingStatDto>> findDaliyList(
@RequestParam(defaultValue = "0", required = true) int page,
@RequestParam(defaultValue = "20", required = true) int size,
@Parameter(
description = "회차 마스터 key",
required = true,
example = "8584e8d4-53b3-4582-bde2-28a81495a626")
@RequestParam
String uuid,
@Parameter(
description = "사번",
required = true,
example = "123456")
@RequestParam String userId,
@Schema(
allowableValues = {"LABELER", "REVIEWER"},
defaultValue = "LABELER")
@Parameter(
description = "라벨러/검수자(LABELER/REVIEWER)",
required = true) @RequestParam String type
) {
@RequestParam(defaultValue = "0", required = true) int page,
@RequestParam(defaultValue = "20", required = true) int size,
@Parameter(
description = "회차 마스터 key",
required = true,
example = "8584e8d4-53b3-4582-bde2-28a81495a626")
@RequestParam
String uuid,
@Parameter(description = "사번", required = true, example = "123456") @RequestParam
String userId,
@Schema(
allowableValues = {"LABELER", "REVIEWER"},
defaultValue = "LABELER")
@Parameter(description = "라벨러/검수자(LABELER/REVIEWER)", required = true)
@RequestParam
String type) {
LabelAllocateDto.searchReq searchReq = new LabelAllocateDto.searchReq(page, size, "");
return ApiResponseDto.ok(labelAllocateService.findDaliyList(searchReq, uuid, userId, type));
}

View File

@@ -101,9 +101,9 @@ public class LabelAllocateDto {
private Integer stage;
@Schema(
description = "라벨러 할당 목록",
example =
"""
description = "라벨러 할당 목록",
example =
"""
[
{
"userId": "123456",
@@ -122,9 +122,9 @@ public class LabelAllocateDto {
private List<TargetUser> labelers;
@Schema(
description = "검수자 할당 목록",
example =
"""
description = "검수자 할당 목록",
example =
"""
["K20251216001",
"01022225555",
"K20251212001"
@@ -232,9 +232,9 @@ public class LabelAllocateDto {
private Integer stage;
@Schema(
description = "라벨러 할당 목록",
example =
"""
description = "라벨러 할당 목록",
example =
"""
[
{
"userId": "123456",
@@ -295,11 +295,10 @@ public class LabelAllocateDto {
String[] sortParams = sort.split(",");
String property = sortParams[0];
Sort.Direction direction =
sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC;
sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC;
return PageRequest.of(page, size, Sort.by(direction, property));
}
return PageRequest.of(page, size);
}
}
}

View File

@@ -67,23 +67,17 @@ public class WorkerStatsDto {
private Boolean isStagnated;
// 레거시 필드 (기존 호환성 유지)
@Deprecated
private Long doneCnt; // completed로 대체
@Deprecated private Long doneCnt; // completed로 대체
@Deprecated
private Long skipCnt; // skipped로 대체
@Deprecated private Long skipCnt; // skipped로 대체
@Deprecated
private Long remainingCnt; // remaining으로 대체
@Deprecated private Long remainingCnt; // remaining으로 대체
@Deprecated
private Long day3AgoDoneCnt; // history.day3Ago로 대체
@Deprecated private Long day3AgoDoneCnt; // history.day3Ago로 대체
@Deprecated
private Long day2AgoDoneCnt; // history.day2Ago로 대체
@Deprecated private Long day2AgoDoneCnt; // history.day2Ago로 대체
@Deprecated
private Long day1AgoDoneCnt; // history.day1Ago로 대체
@Deprecated private Long day1AgoDoneCnt; // history.day1Ago로 대체
}
@Getter
@@ -107,7 +101,6 @@ public class WorkerStatsDto {
private Long average;
}
@Getter
@Setter
@Builder

View File

@@ -124,12 +124,7 @@ public class LabelAllocateService {
* @return 작업자 목록 및 통계
*/
public WorkerListResponse getWorkerStatistics(
Long analUid,
String workerType,
String search,
String sortType,
Integer page,
Integer size) {
Long analUid, String workerType, String search, String sortType, Integer page, Integer size) {
// 프로젝트 정보 조회 (analUid가 있을 때만)
var projectInfo = labelAllocateCoreService.findProjectInfo(analUid);
@@ -139,8 +134,7 @@ public class LabelAllocateService {
// 작업자 통계 조회
List<WorkerStatistics> workers =
labelAllocateCoreService.findWorkerStatistics(
analUid, workerType, search, sortType);
labelAllocateCoreService.findWorkerStatistics(analUid, workerType, search, sortType);
// 각 작업자별 3일치 처리량 조회
LocalDate today = LocalDate.now();
@@ -234,7 +228,8 @@ public class LabelAllocateService {
}
}
public Page<LabelingStatDto> findDaliyList(LabelAllocateDto.searchReq searchReq, String uuid, String userId, String type) {
public Page<LabelingStatDto> findDaliyList(
LabelAllocateDto.searchReq searchReq, String uuid, String userId, String type) {
if (type.equals("LABELER")) {
return labelAllocateCoreService.findLabelerDailyStat(searchReq, uuid, userId);
} else {

View File

@@ -57,12 +57,8 @@ public class LabelAllocateCoreService {
}
public List<WorkerStatistics> findWorkerStatistics(
Long analUid,
String workerType,
String search,
String sortType) {
return labelAllocateRepository.findWorkerStatistics(
analUid, workerType, search, sortType);
Long analUid, String workerType, String search, String sortType) {
return labelAllocateRepository.findWorkerStatistics(analUid, workerType, search, sortType);
}
public WorkProgressInfo findWorkProgressInfo(Long analUid) {
@@ -104,11 +100,13 @@ public class LabelAllocateCoreService {
labelAllocateRepository.insertInspector(analUid, inspector);
}
public Page<LabelingStatDto> findLabelerDailyStat(searchReq searchReq, String uuid, String userId) {
public Page<LabelingStatDto> findLabelerDailyStat(
searchReq searchReq, String uuid, String userId) {
return labelAllocateRepository.findLabelerDailyStat(searchReq, uuid, userId);
}
public Page<LabelingStatDto> findInspectorDailyStat(searchReq searchReq, String uuid, String userId) {
public Page<LabelingStatDto> findInspectorDailyStat(
searchReq searchReq, String uuid, String userId) {
return labelAllocateRepository.findInspectorDailyStat(searchReq, uuid, userId);
}

View File

@@ -52,20 +52,19 @@ public class LabelingAssignmentEntity extends CommonDateEntity {
public LabelAllocateDto.Basic toDto() {
return new LabelAllocateDto.Basic(
this.assignmentUid,
this.inferenceGeomUid,
this.workerUid,
this.inspectorUid,
this.workState,
this.stagnationYn,
this.assignGroupId,
this.learnGeomUid,
this.analUid,
super.getCreatedDate(),
super.getModifiedDate(),
this.inspectState,
this.workStatDttm,
this.inspectStatDttm
);
this.assignmentUid,
this.inferenceGeomUid,
this.workerUid,
this.inspectorUid,
this.workState,
this.stagnationYn,
this.assignGroupId,
this.learnGeomUid,
this.analUid,
super.getCreatedDate(),
super.getModifiedDate(),
this.inspectState,
this.workStatDttm,
this.inspectStatDttm);
}
}

View File

@@ -18,7 +18,7 @@ import org.springframework.data.domain.Page;
public interface LabelAllocateRepositoryCustom {
List<AllocateInfoDto> fetchNextIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage);
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage);
void assignOwner(List<AllocateInfoDto> ids, String userId, Long analUid);
@@ -35,7 +35,7 @@ public interface LabelAllocateRepositoryCustom {
// 작업자 통계 조회
List<WorkerStatistics> findWorkerStatistics(
Long analUid, String workerType, String search, String sortType);
Long analUid, String workerType, String search, String sortType);
// 작업 진행 현황 조회
WorkProgressInfo findWorkProgressInfo(Long analUid);
@@ -48,7 +48,7 @@ public interface LabelAllocateRepositoryCustom {
InferenceDetail findInferenceDetail(String uuid);
List<Long> fetchNextMoveIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage);
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage);
void assignOwnerMove(List<Long> sub, String userId);
@@ -58,9 +58,11 @@ public interface LabelAllocateRepositoryCustom {
void insertInspector(Long analUid, String inspector);
Page<LabelingStatDto> findLabelerDailyStat(LabelAllocateDto.searchReq searchReq, String uuid, String userId);
Page<LabelingStatDto> findLabelerDailyStat(
LabelAllocateDto.searchReq searchReq, String uuid, String userId);
Page<LabelingStatDto> findInspectorDailyStat(LabelAllocateDto.searchReq searchReq, String uuid, String userId);
Page<LabelingStatDto> findInspectorDailyStat(
LabelAllocateDto.searchReq searchReq, String uuid, String userId);
LabelerDetail findInspectorDetail(String userId, String uuid);
}

View File

@@ -197,10 +197,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
@Override
public List<WorkerStatistics> findWorkerStatistics(
Long analUid,
String workerType,
String search,
String sortType) {
Long analUid, String workerType, String search, String sortType) {
// 작업자 유형에 따른 필드 선택
StringExpression workerIdField =
@@ -216,8 +213,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
// 검색 조건 (이름 또는 사번으로 검색)
BooleanExpression searchCondition = null;
if (search != null && !search.isEmpty()) {
searchCondition = memberEntity.name.contains(search)
.or(memberEntity.employeeNo.contains(search));
searchCondition =
memberEntity.name.contains(search).or(memberEntity.employeeNo.contains(search));
}
// 완료, 스킵, 남은 작업 계산
@@ -247,7 +244,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
.sum();
// 기본 통계 조회 쿼리
BooleanExpression analUidCondition = analUid != null ? labelingAssignmentEntity.analUid.eq(analUid) : null;
BooleanExpression analUidCondition =
analUid != null ? labelingAssignmentEntity.analUid.eq(analUid) : null;
var baseQuery =
queryFactory
@@ -318,7 +316,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
@Override
public WorkProgressInfo findWorkProgressInfo(Long analUid) {
BooleanExpression analUidCondition = analUid != null ? labelingAssignmentEntity.analUid.eq(analUid) : null;
BooleanExpression analUidCondition =
analUid != null ? labelingAssignmentEntity.analUid.eq(analUid) : null;
// 전체 배정 건수
Long totalAssigned =
@@ -344,9 +343,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
queryFactory
.select(labelingAssignmentEntity.count())
.from(labelingAssignmentEntity)
.where(
analUidCondition,
labelingAssignmentEntity.workState.eq("SKIP"))
.where(analUidCondition, labelingAssignmentEntity.workState.eq("SKIP"))
.fetchOne();
// 투입된 라벨러 수
@@ -354,9 +351,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
queryFactory
.select(labelingAssignmentEntity.workerUid.countDistinct())
.from(labelingAssignmentEntity)
.where(
analUidCondition,
labelingAssignmentEntity.workerUid.isNotNull())
.where(analUidCondition, labelingAssignmentEntity.workerUid.isNotNull())
.fetchOne();
// === 검수 통계 ===
@@ -365,9 +360,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
queryFactory
.select(labelingAssignmentEntity.count())
.from(labelingAssignmentEntity)
.where(
analUidCondition,
labelingAssignmentEntity.workState.eq("DONE"))
.where(analUidCondition, labelingAssignmentEntity.workState.eq("DONE"))
.fetchOne();
// 투입된 검수자 수
@@ -375,9 +368,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
queryFactory
.select(labelingAssignmentEntity.inspectorUid.countDistinct())
.from(labelingAssignmentEntity)
.where(
analUidCondition,
labelingAssignmentEntity.inspectorUid.isNotNull())
.where(analUidCondition, labelingAssignmentEntity.inspectorUid.isNotNull())
.fetchOne();
// 남은 작업 건수 계산
@@ -437,7 +428,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
? labelingAssignmentEntity.inspectorUid.eq(workerId)
: labelingAssignmentEntity.workerUid.eq(workerId);
BooleanExpression analUidCondition = analUid != null ? labelingAssignmentEntity.analUid.eq(analUid) : null;
BooleanExpression analUidCondition =
analUid != null ? labelingAssignmentEntity.analUid.eq(analUid) : null;
Long count =
queryFactory
@@ -580,29 +572,29 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
QMemberEntity inspector = new QMemberEntity("inspector");
return queryFactory
.select(
Projections.constructor(
LabelerDetail.class,
worker.userRole,
worker.name,
worker.employeeNo,
assignedCnt,
skipCnt,
completeCnt,
percent,
Expressions.constant(0), // TODO: 순위, 꼭 해야할지?
labelingAssignmentEntity.workStatDttm.min(),
inspector.name.min()))
.from(worker)
.innerJoin(labelingAssignmentEntity)
.on(
worker.employeeNo.eq(labelingAssignmentEntity.workerUid),
labelingAssignmentEntity.analUid.eq(analEntity.getId()))
.leftJoin(inspector)
.on(labelingAssignmentEntity.inspectorUid.eq(inspector.employeeNo))
.where(worker.employeeNo.eq(userId))
.groupBy(worker.userRole, worker.name, worker.employeeNo)
.fetchOne();
.select(
Projections.constructor(
LabelerDetail.class,
worker.userRole,
worker.name,
worker.employeeNo,
assignedCnt,
skipCnt,
completeCnt,
percent,
Expressions.constant(0), // TODO: 순위, 꼭 해야할지?
labelingAssignmentEntity.workStatDttm.min(),
inspector.name.min()))
.from(worker)
.innerJoin(labelingAssignmentEntity)
.on(
worker.employeeNo.eq(labelingAssignmentEntity.workerUid),
labelingAssignmentEntity.analUid.eq(analEntity.getId()))
.leftJoin(inspector)
.on(labelingAssignmentEntity.inspectorUid.eq(inspector.employeeNo))
.where(worker.employeeNo.eq(userId))
.groupBy(worker.userRole, worker.name, worker.employeeNo)
.fetchOne();
}
@Override
@@ -638,17 +630,17 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
return null;
}
var result = queryFactory
.select(
mapSheetAnalEntity.compareYyyy,
mapSheetAnalEntity.targetYyyy,
mapSheetAnalEntity.analTitle,
mapSheetAnalEntity.gukyuinApplyDttm,
mapSheetAnalEntity.analStrtDttm
)
.from(mapSheetAnalEntity)
.where(mapSheetAnalEntity.id.eq(analUid))
.fetchOne();
var result =
queryFactory
.select(
mapSheetAnalEntity.compareYyyy,
mapSheetAnalEntity.targetYyyy,
mapSheetAnalEntity.analTitle,
mapSheetAnalEntity.gukyuinApplyDttm,
mapSheetAnalEntity.analStrtDttm)
.from(mapSheetAnalEntity)
.where(mapSheetAnalEntity.id.eq(analUid))
.fetchOne();
if (result == null) {
return null;
@@ -661,9 +653,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
ZonedDateTime analStrtDttm = result.get(mapSheetAnalEntity.analStrtDttm);
// 변화탐지년도 생성
String detectionYear = (compareYyyy != null && targetYyyy != null)
? compareYyyy + "-" + targetYyyy
: null;
String detectionYear =
(compareYyyy != null && targetYyyy != null) ? compareYyyy + "-" + targetYyyy : null;
// 회차 추출 (예: "8회차" → "8")
String round = extractRoundFromTitle(analTitle);
@@ -676,10 +667,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
.build();
}
/**
* 제목에서 회차 숫자 추출
* 예: "8회차", "제8회차" → "8"
*/
/** 제목에서 회차 숫자 추출 예: "8회차", "제8회차" → "8" */
private String extractRoundFromTitle(String title) {
if (title == null || title.isEmpty()) {
return null;
@@ -691,9 +679,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
return matcher.find() ? matcher.group(1) : null;
}
/**
* ZonedDateTime을 "yyyy-MM-dd" 형식으로 변환
*/
/** ZonedDateTime을 "yyyy-MM-dd" 형식으로 변환 */
private String formatDate(ZonedDateTime dateTime) {
if (dateTime == null) {
return null;
@@ -702,211 +688,169 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
}
@Override
public Page<LabelingStatDto> findLabelerDailyStat(LabelAllocateDto.searchReq searchReq, String uuid, String userId) {
public Page<LabelingStatDto> findLabelerDailyStat(
LabelAllocateDto.searchReq searchReq, String uuid, String userId) {
// 날짜 포맷
Expression<String> workDate =
Expressions.stringTemplate(
"TO_CHAR({0}, 'YYYY-MM-DD')",
labelingAssignmentEntity.workStatDttm
);
Expressions.stringTemplate(
"TO_CHAR({0}, 'YYYY-MM-DD')", labelingAssignmentEntity.workStatDttm);
// 날짜별 전체 건수
Expression<Long> dailyTotalCnt =
Expressions.numberTemplate(
Long.class,
"COUNT(*)"
);
Expression<Long> dailyTotalCnt = Expressions.numberTemplate(Long.class, "COUNT(*)");
// ⭐ 전체 기간 총 건수 (윈도우 함수)
Expression<Long> totalCnt =
Expressions.numberTemplate(
Long.class,
"SUM(COUNT(*)) OVER ()"
);
Expression<Long> totalCnt = Expressions.numberTemplate(Long.class, "SUM(COUNT(*)) OVER ()");
// 상태별 카운트 (Postgres FILTER 사용)
Expression<Long> assignedCnt =
Expressions.numberTemplate(
Long.class,
"COUNT(*) FILTER (WHERE {0} = 'ASSIGNED')",
labelingAssignmentEntity.workState
);
Expressions.numberTemplate(
Long.class,
"COUNT(*) FILTER (WHERE {0} = 'ASSIGNED')",
labelingAssignmentEntity.workState);
Expression<Long> skipCnt =
Expressions.numberTemplate(
Long.class,
"COUNT(*) FILTER (WHERE {0} = 'SKIP')",
labelingAssignmentEntity.workState
);
Expressions.numberTemplate(
Long.class, "COUNT(*) FILTER (WHERE {0} = 'SKIP')", labelingAssignmentEntity.workState);
Expression<Long> completeCnt =
Expressions.numberTemplate(
Long.class,
"COUNT(*) FILTER (WHERE {0} = 'COMPLETE')",
labelingAssignmentEntity.workState
);
Expressions.numberTemplate(
Long.class,
"COUNT(*) FILTER (WHERE {0} = 'COMPLETE')",
labelingAssignmentEntity.workState);
Expression<Long> remainCnt =
Expressions.numberTemplate(
Long.class,
"({0} - {1} - {2})",
totalCnt,
skipCnt,
completeCnt
);
Expressions.numberTemplate(Long.class, "({0} - {1} - {2})", totalCnt, skipCnt, completeCnt);
// analUid로 분석 정보 조회
MapSheetAnalInferenceEntity analEntity =
queryFactory
.selectFrom(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
.fetchOne();
queryFactory
.selectFrom(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
.fetchOne();
if (Objects.isNull(analEntity)) {
throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: ");
}
Pageable pageable = searchReq.toPageable();
List<LabelingStatDto> foundContent = queryFactory
.select(
Projections.constructor(
LabelingStatDto.class,
workDate,
dailyTotalCnt,
totalCnt, // ⭐ 전체 일자 배정 건수
assignedCnt,
skipCnt,
completeCnt,
remainCnt
)
)
.from(labelingAssignmentEntity)
.where(
labelingAssignmentEntity.workerUid.eq(userId),
labelingAssignmentEntity.analUid.eq(analEntity.getId())
)
.groupBy(workDate)
.orderBy(labelingAssignmentEntity.workStatDttm.min().asc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();
List<LabelingStatDto> foundContent =
queryFactory
.select(
Projections.constructor(
LabelingStatDto.class,
workDate,
dailyTotalCnt,
totalCnt, // ⭐ 전체 일자 배정 건수
assignedCnt,
skipCnt,
completeCnt,
remainCnt))
.from(labelingAssignmentEntity)
.where(
labelingAssignmentEntity.workerUid.eq(userId),
labelingAssignmentEntity.analUid.eq(analEntity.getId()))
.groupBy(workDate)
.orderBy(labelingAssignmentEntity.workStatDttm.min().asc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();
Long countQuery = queryFactory
.select(workDate)
.from(labelingAssignmentEntity)
.where(
labelingAssignmentEntity.workerUid.eq(userId),
labelingAssignmentEntity.analUid.eq(analEntity.getId())
)
.distinct()
.fetch()
.stream()
.count();
Long countQuery =
queryFactory
.select(workDate)
.from(labelingAssignmentEntity)
.where(
labelingAssignmentEntity.workerUid.eq(userId),
labelingAssignmentEntity.analUid.eq(analEntity.getId()))
.distinct()
.fetch()
.stream()
.count();
return new PageImpl<>(foundContent, pageable, countQuery);
}
@Override
public Page<LabelingStatDto> findInspectorDailyStat(searchReq searchReq, String uuid, String userId) {
public Page<LabelingStatDto> findInspectorDailyStat(
searchReq searchReq, String uuid, String userId) {
// 날짜 포맷
Expression<String> workDate =
Expressions.stringTemplate(
"TO_CHAR({0}, 'YYYY-MM-DD')",
labelingAssignmentEntity.inspectStatDttm
);
Expressions.stringTemplate(
"TO_CHAR({0}, 'YYYY-MM-DD')", labelingAssignmentEntity.inspectStatDttm);
// 날짜별 전체 건수
Expression<Long> dailyTotalCnt =
Expressions.numberTemplate(
Long.class,
"COUNT(*)"
);
Expression<Long> dailyTotalCnt = Expressions.numberTemplate(Long.class, "COUNT(*)");
// ⭐ 전체 기간 총 건수 (윈도우 함수)
Expression<Long> totalCnt =
Expressions.numberTemplate(
Long.class,
"SUM(COUNT(*)) OVER ()"
);
Expression<Long> totalCnt = Expressions.numberTemplate(Long.class, "SUM(COUNT(*)) OVER ()");
// 상태별 카운트 (Postgres FILTER 사용)
Expression<Long> assignedCnt =
Expressions.numberTemplate(
Long.class,
"COUNT(*) FILTER (WHERE {0} = 'UNCONFIRM')",
labelingAssignmentEntity.inspectState
);
Expressions.numberTemplate(
Long.class,
"COUNT(*) FILTER (WHERE {0} = 'UNCONFIRM')",
labelingAssignmentEntity.inspectState);
Expression<Long> skipCnt =
Expressions.numberTemplate(
Long.class,
"COUNT(*) FILTER (WHERE {0} = 'EXCEPT')",
labelingAssignmentEntity.inspectState
);
Expressions.numberTemplate(
Long.class,
"COUNT(*) FILTER (WHERE {0} = 'EXCEPT')",
labelingAssignmentEntity.inspectState);
Expression<Long> completeCnt =
Expressions.numberTemplate(
Long.class,
"COUNT(*) FILTER (WHERE {0} = 'COMPLETE')",
labelingAssignmentEntity.inspectState
);
Expressions.numberTemplate(
Long.class,
"COUNT(*) FILTER (WHERE {0} = 'COMPLETE')",
labelingAssignmentEntity.inspectState);
Expression<Long> remainCnt =
Expressions.numberTemplate(
Long.class,
"({0} - {1} - {2})",
totalCnt,
skipCnt,
completeCnt
);
Expressions.numberTemplate(Long.class, "({0} - {1} - {2})", totalCnt, skipCnt, completeCnt);
// analUid로 분석 정보 조회
MapSheetAnalInferenceEntity analEntity =
queryFactory
.selectFrom(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
.fetchOne();
queryFactory
.selectFrom(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
.fetchOne();
if (Objects.isNull(analEntity)) {
throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: ");
}
Pageable pageable = searchReq.toPageable();
List<LabelingStatDto> foundContent = queryFactory
.select(
Projections.constructor(
LabelingStatDto.class,
workDate,
dailyTotalCnt,
totalCnt, // ⭐ 전체 일자 배정 건수
assignedCnt,
skipCnt,
completeCnt,
remainCnt
)
)
.from(labelingAssignmentEntity)
.where(
labelingAssignmentEntity.inspectorUid.eq(userId),
labelingAssignmentEntity.analUid.eq(analEntity.getId())
)
.groupBy(workDate)
.orderBy(labelingAssignmentEntity.inspectStatDttm.min().asc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();
List<LabelingStatDto> foundContent =
queryFactory
.select(
Projections.constructor(
LabelingStatDto.class,
workDate,
dailyTotalCnt,
totalCnt, // ⭐ 전체 일자 배정 건수
assignedCnt,
skipCnt,
completeCnt,
remainCnt))
.from(labelingAssignmentEntity)
.where(
labelingAssignmentEntity.inspectorUid.eq(userId),
labelingAssignmentEntity.analUid.eq(analEntity.getId()))
.groupBy(workDate)
.orderBy(labelingAssignmentEntity.inspectStatDttm.min().asc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();
Long countQuery = queryFactory
.select(workDate)
.from(labelingAssignmentEntity)
.where(
labelingAssignmentEntity.inspectorUid.eq(userId),
labelingAssignmentEntity.analUid.eq(analEntity.getId())
)
.distinct()
.fetch()
.stream()
.count();
Long countQuery =
queryFactory
.select(workDate)
.from(labelingAssignmentEntity)
.where(
labelingAssignmentEntity.inspectorUid.eq(userId),
labelingAssignmentEntity.analUid.eq(analEntity.getId()))
.distinct()
.fetch()
.stream()
.count();
return new PageImpl<>(foundContent, pageable, countQuery);
}
@@ -914,43 +858,43 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
@Override
public LabelerDetail findInspectorDetail(String userId, String uuid) {
NumberExpression<Long> assignedCnt =
new CaseBuilder()
.when(labelingAssignmentEntity.inspectState.eq(InspectState.UNCONFIRM.getId()))
.then(1L)
.otherwise((Long) null)
.count();
new CaseBuilder()
.when(labelingAssignmentEntity.inspectState.eq(InspectState.UNCONFIRM.getId()))
.then(1L)
.otherwise((Long) null)
.count();
NumberExpression<Long> skipCnt =
new CaseBuilder()
.when(labelingAssignmentEntity.inspectState.eq(InspectState.EXCEPT.getId()))
.then(1L)
.otherwise((Long) null)
.count();
new CaseBuilder()
.when(labelingAssignmentEntity.inspectState.eq(InspectState.EXCEPT.getId()))
.then(1L)
.otherwise((Long) null)
.count();
NumberExpression<Long> completeCnt =
new CaseBuilder()
.when(labelingAssignmentEntity.inspectState.eq(InspectState.COMPLETE.getId()))
.then(1L)
.otherwise((Long) null)
.count();
new CaseBuilder()
.when(labelingAssignmentEntity.inspectState.eq(InspectState.COMPLETE.getId()))
.then(1L)
.otherwise((Long) null)
.count();
NumberExpression<Double> percent =
new CaseBuilder()
.when(completeCnt.eq(0L))
.then(0.0)
.otherwise(
Expressions.numberTemplate(
Double.class,
"round({0} / {1}, 2)",
labelingAssignmentEntity.count(),
completeCnt));
new CaseBuilder()
.when(completeCnt.eq(0L))
.then(0.0)
.otherwise(
Expressions.numberTemplate(
Double.class,
"round({0} / {1}, 2)",
labelingAssignmentEntity.count(),
completeCnt));
// analUid로 분석 정보 조회
MapSheetAnalInferenceEntity analEntity =
queryFactory
.selectFrom(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
.fetchOne();
queryFactory
.selectFrom(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
.fetchOne();
if (Objects.isNull(analEntity)) {
throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: ");
@@ -960,28 +904,28 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
QMemberEntity worker = new QMemberEntity("worker");
return queryFactory
.select(
Projections.constructor(
LabelerDetail.class,
inspector.userRole,
inspector.name,
inspector.employeeNo,
assignedCnt,
skipCnt,
completeCnt,
percent,
Expressions.constant(0), // TODO: 순위, 꼭 해야할지?
labelingAssignmentEntity.inspectStatDttm.min(),
worker.name.min()))
.from(inspector)
.innerJoin(labelingAssignmentEntity)
.on(
inspector.employeeNo.eq(labelingAssignmentEntity.inspectorUid),
labelingAssignmentEntity.analUid.eq(analEntity.getId()))
.leftJoin(worker)
.on(labelingAssignmentEntity.workerUid.eq(worker.employeeNo))
.where(inspector.employeeNo.eq(userId))
.groupBy(inspector.userRole, inspector.name, inspector.employeeNo)
.fetchOne();
.select(
Projections.constructor(
LabelerDetail.class,
inspector.userRole,
inspector.name,
inspector.employeeNo,
assignedCnt,
skipCnt,
completeCnt,
percent,
Expressions.constant(0), // TODO: 순위, 꼭 해야할지?
labelingAssignmentEntity.inspectStatDttm.min(),
worker.name.min()))
.from(inspector)
.innerJoin(labelingAssignmentEntity)
.on(
inspector.employeeNo.eq(labelingAssignmentEntity.inspectorUid),
labelingAssignmentEntity.analUid.eq(analEntity.getId()))
.leftJoin(worker)
.on(labelingAssignmentEntity.workerUid.eq(worker.employeeNo))
.where(inspector.employeeNo.eq(userId))
.groupBy(inspector.userRole, inspector.name, inspector.employeeNo)
.fetchOne();
}
}