|
|
|
|
@@ -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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|