파라미터 yyyy기준으로 변경
This commit is contained in:
@@ -20,22 +20,22 @@ public class LabelAllocateCoreService {
|
||||
|
||||
private final LabelAllocateRepository labelAllocateRepository;
|
||||
|
||||
public List<Long> fetchNextIds(Long lastId, Long batchSize, Long analUid) {
|
||||
return labelAllocateRepository.fetchNextIds(lastId, batchSize, analUid);
|
||||
public List<Long> fetchNextIds(Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
return labelAllocateRepository.fetchNextIds(lastId, batchSize, compareYyyy, targetYyyy, stage);
|
||||
}
|
||||
|
||||
public void assignOwner(List<Long> ids, String userId, Long analUid) {
|
||||
labelAllocateRepository.assignOwner(ids, userId, analUid);
|
||||
public void assignOwner(List<Long> ids, String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
labelAllocateRepository.assignOwner(ids, userId, compareYyyy, targetYyyy, stage);
|
||||
}
|
||||
|
||||
public List<LabelAllocateDto.Basic> findAssignedLabelerList(Long analUid) {
|
||||
return labelAllocateRepository.findAssignedLabelerList(analUid).stream()
|
||||
.map(LabelingAssignmentEntity::toDto)
|
||||
.toList();
|
||||
public List<LabelAllocateDto.Basic> findAssignedLabelerList(Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
return labelAllocateRepository.findAssignedLabelerList(compareYyyy, targetYyyy, stage).stream()
|
||||
.map(LabelingAssignmentEntity::toDto)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public Long findLabelUnAssignedCnt(Long analUid, Integer stage) {
|
||||
return labelAllocateRepository.findLabelUnAssignedCnt(analUid, stage);
|
||||
public Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy) {
|
||||
return labelAllocateRepository.findLabelUnAssignedCnt(stage, compareYyyy, targetYyyy);
|
||||
}
|
||||
|
||||
public void assignInspector(UUID assignmentUid, String inspectorUid) {
|
||||
@@ -47,13 +47,13 @@ public class LabelAllocateCoreService {
|
||||
}
|
||||
|
||||
public List<WorkerStatistics> findWorkerStatistics(
|
||||
Long analUid,
|
||||
String workerType,
|
||||
String searchName,
|
||||
String searchEmployeeNo,
|
||||
String sortType) {
|
||||
Long analUid,
|
||||
String workerType,
|
||||
String searchName,
|
||||
String searchEmployeeNo,
|
||||
String sortType) {
|
||||
return labelAllocateRepository.findWorkerStatistics(
|
||||
analUid, workerType, searchName, searchEmployeeNo, sortType);
|
||||
analUid, workerType, searchName, searchEmployeeNo, sortType);
|
||||
}
|
||||
|
||||
public WorkProgressInfo findWorkProgressInfo(Long analUid) {
|
||||
@@ -61,7 +61,7 @@ public class LabelAllocateCoreService {
|
||||
}
|
||||
|
||||
public Long findDailyProcessedCount(
|
||||
String workerId, String workerType, LocalDate date, Long analUid) {
|
||||
String workerId, String workerType, LocalDate date, Long analUid) {
|
||||
return labelAllocateRepository.findDailyProcessedCount(workerId, workerType, date, analUid);
|
||||
}
|
||||
|
||||
@@ -69,23 +69,23 @@ public class LabelAllocateCoreService {
|
||||
labelAllocateRepository.assignInspectorBulk(assignmentUids, inspectorUid);
|
||||
}
|
||||
|
||||
public InferenceDetail findInferenceDetail(Long analUid) {
|
||||
return labelAllocateRepository.findInferenceDetail(analUid);
|
||||
public InferenceDetail findInferenceDetail(Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
return labelAllocateRepository.findInferenceDetail(compareYyyy, targetYyyy, stage);
|
||||
}
|
||||
|
||||
public Long findLabelUnCompleteCnt(Long analUid) {
|
||||
return labelAllocateRepository.findLabelUnCompleteCnt(analUid);
|
||||
}
|
||||
|
||||
public List<Long> fetchNextMoveIds(Long lastId, Long chargeCnt) {
|
||||
return labelAllocateRepository.fetchNextMoveIds(lastId, chargeCnt);
|
||||
public List<Long> fetchNextMoveIds(Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
return labelAllocateRepository.fetchNextMoveIds(lastId, batchSize, compareYyyy, targetYyyy, stage);
|
||||
}
|
||||
|
||||
public void assignOwnerMove(List<Long> sub, String userId) {
|
||||
labelAllocateRepository.assignOwnerMove(sub, userId);
|
||||
}
|
||||
|
||||
public LabelerDetail findLabelerDetail(String userId, Long analUid) {
|
||||
return labelAllocateRepository.findLabelerDetail(userId, analUid);
|
||||
public LabelerDetail findLabelerDetail(String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
return labelAllocateRepository.findLabelerDetail(userId, compareYyyy, targetYyyy, stage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ import java.util.UUID;
|
||||
|
||||
public interface LabelAllocateRepositoryCustom {
|
||||
|
||||
List<Long> fetchNextIds(Long lastId, Long batchSize, Long analUid);
|
||||
List<Long> fetchNextIds(Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage);
|
||||
|
||||
void assignOwner(List<Long> ids, String userId, Long analUid);
|
||||
void assignOwner(List<Long> ids, String userId, Integer compareYyyy, Integer targetYyyy, Integer stage);
|
||||
|
||||
List<LabelingAssignmentEntity> findAssignedLabelerList(Long analUid);
|
||||
List<LabelingAssignmentEntity> findAssignedLabelerList(Integer compareYyyy, Integer targetYyyy, Integer stage);
|
||||
|
||||
Long findLabelUnAssignedCnt(Long analUid, Integer stage);
|
||||
Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy);
|
||||
|
||||
void assignInspector(UUID assignmentUid, String userId);
|
||||
|
||||
@@ -26,7 +26,7 @@ public interface LabelAllocateRepositoryCustom {
|
||||
|
||||
// 작업자 통계 조회
|
||||
List<WorkerStatistics> findWorkerStatistics(
|
||||
Long analUid, String workerType, String searchName, String searchEmployeeNo, String sortType);
|
||||
Long analUid, String workerType, String searchName, String searchEmployeeNo, String sortType);
|
||||
|
||||
// 작업 진행 현황 조회
|
||||
WorkProgressInfo findWorkProgressInfo(Long analUid);
|
||||
@@ -36,13 +36,13 @@ public interface LabelAllocateRepositoryCustom {
|
||||
|
||||
void assignInspectorBulk(List<UUID> assignmentUids, String inspectorUid);
|
||||
|
||||
InferenceDetail findInferenceDetail(Long analUid);
|
||||
InferenceDetail findInferenceDetail(Integer compareYyyy, Integer targetYyyy, Integer stage);
|
||||
|
||||
List<Long> fetchNextMoveIds(Long lastId, Long batchSize);
|
||||
public List<Long> fetchNextMoveIds(Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage);
|
||||
|
||||
Long findLabelUnCompleteCnt(Long analUid);
|
||||
|
||||
void assignOwnerMove(List<Long> sub, String userId);
|
||||
|
||||
LabelerDetail findLabelerDetail(String userId, Long analUid);
|
||||
LabelerDetail findLabelerDetail(String userId, Integer compareYyyy, Integer targetYyyy, Integer stage);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.label;
|
||||
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QLabelingAssignmentEntity.labelingAssignmentEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceEntity.mapSheetAnalDataInferenceEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalEntity.mapSheetAnalEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMemberEntity.memberEntity;
|
||||
@@ -14,6 +15,7 @@ import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataInferenceEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalEntity;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||
@@ -44,50 +46,58 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
|
||||
@PersistenceContext private EntityManager em;
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
|
||||
@Override
|
||||
public List<Long> fetchNextIds(Long lastId, Long batchSize, Long analUid) {
|
||||
// analUid로 분석 정보 조회
|
||||
MapSheetAnalEntity analEntity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalEntity)
|
||||
.where(mapSheetAnalEntity.id.eq(analUid))
|
||||
.fetchOne();
|
||||
|
||||
if (Objects.isNull(analEntity)) {
|
||||
throw new EntityNotFoundException("MapSheetAnalEntity not found for analUid: " + analUid);
|
||||
}
|
||||
public List<Long> fetchNextIds(Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
|
||||
return queryFactory
|
||||
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
|
||||
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||
.where(
|
||||
lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId),
|
||||
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(analEntity.getCompareYyyy()),
|
||||
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(analEntity.getTargetYyyy()),
|
||||
mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
|
||||
.orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc())
|
||||
.limit(batchSize)
|
||||
.fetch();
|
||||
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
|
||||
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||
.where(
|
||||
lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId),
|
||||
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetAnalDataInferenceGeomEntity.stage.eq(stage),
|
||||
mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
|
||||
.orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc())
|
||||
.limit(batchSize)
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignOwner(List<Long> ids, String userId, Long analUid) {
|
||||
public void assignOwner(List<Long> ids, String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
|
||||
// analUid로 분석 정보 조회
|
||||
MapSheetAnalDataInferenceEntity analEntity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalDataInferenceEntity)
|
||||
.where(mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetAnalDataInferenceEntity.stage.eq(stage)
|
||||
)
|
||||
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
|
||||
.limit(1)
|
||||
.fetchOne();
|
||||
|
||||
if (Objects.isNull(analEntity)) {
|
||||
throw new EntityNotFoundException("MapSheetAnalEntity not found for analUid: ");
|
||||
}
|
||||
|
||||
// data_geom 테이블에 label state 를 ASSIGNED 로 update
|
||||
queryFactory
|
||||
.update(mapSheetAnalDataInferenceGeomEntity)
|
||||
.set(mapSheetAnalDataInferenceGeomEntity.labelState, LabelState.ASSIGNED.getId())
|
||||
.set(mapSheetAnalDataInferenceGeomEntity.labelStateDttm, ZonedDateTime.now())
|
||||
.set(mapSheetAnalDataInferenceGeomEntity.testState, InspectState.UNCONFIRM.getId())
|
||||
.set(mapSheetAnalDataInferenceGeomEntity.testStateDttm, ZonedDateTime.now())
|
||||
.where(mapSheetAnalDataInferenceGeomEntity.geoUid.in(ids))
|
||||
.execute();
|
||||
.update(mapSheetAnalDataInferenceGeomEntity)
|
||||
.set(mapSheetAnalDataInferenceGeomEntity.labelState, LabelState.ASSIGNED.getId())
|
||||
.set(mapSheetAnalDataInferenceGeomEntity.labelStateDttm, ZonedDateTime.now())
|
||||
.set(mapSheetAnalDataInferenceGeomEntity.testState, InspectState.UNCONFIRM.getId())
|
||||
.set(mapSheetAnalDataInferenceGeomEntity.testStateDttm, ZonedDateTime.now())
|
||||
.where(mapSheetAnalDataInferenceGeomEntity.geoUid.in(ids))
|
||||
.execute();
|
||||
|
||||
// 라벨러 할당 테이블에 insert
|
||||
String sql =
|
||||
"""
|
||||
"""
|
||||
insert into tb_labeling_assignment
|
||||
(assignment_uid, inference_geom_uid, worker_uid,
|
||||
work_state, assign_group_id, anal_uid)
|
||||
@@ -96,13 +106,13 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
|
||||
for (Long geoUid : ids) {
|
||||
em.createNativeQuery(sql)
|
||||
.setParameter(1, UUID.randomUUID())
|
||||
.setParameter(2, geoUid)
|
||||
.setParameter(3, userId)
|
||||
.setParameter(4, LabelState.ASSIGNED.getId())
|
||||
.setParameter(5, "")
|
||||
.setParameter(6, analUid)
|
||||
.executeUpdate();
|
||||
.setParameter(1, UUID.randomUUID())
|
||||
.setParameter(2, geoUid)
|
||||
.setParameter(3, userId)
|
||||
.setParameter(4, LabelState.ASSIGNED.getId())
|
||||
.setParameter(5, "")
|
||||
.setParameter(6, analEntity.getAnalUid())
|
||||
.executeUpdate();
|
||||
}
|
||||
|
||||
em.flush();
|
||||
@@ -110,84 +120,91 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LabelingAssignmentEntity> findAssignedLabelerList(Long analUid) {
|
||||
return queryFactory
|
||||
.selectFrom(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()),
|
||||
labelingAssignmentEntity.inspectorUid.isNull())
|
||||
.orderBy(labelingAssignmentEntity.workerUid.asc())
|
||||
.fetch();
|
||||
}
|
||||
public List<LabelingAssignmentEntity> findAssignedLabelerList(Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
// analUid로 분석 정보 조회
|
||||
MapSheetAnalDataInferenceEntity analEntity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalDataInferenceEntity)
|
||||
.where(mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetAnalDataInferenceEntity.stage.eq(stage)
|
||||
)
|
||||
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
|
||||
.limit(1)
|
||||
.fetchOne();
|
||||
|
||||
@Override
|
||||
public Long findLabelUnAssignedCnt(Long analUid, Integer stage) {
|
||||
MapSheetAnalEntity entity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalEntity)
|
||||
.where(mapSheetAnalEntity.id.eq(analUid))
|
||||
.fetchOne();
|
||||
|
||||
if (Objects.isNull(entity)) {
|
||||
throw new EntityNotFoundException("MapSheetAnalEntity not found for analUid: " + analUid);
|
||||
if (Objects.isNull(analEntity)) {
|
||||
throw new EntityNotFoundException("MapSheetAnalEntity not found for analUid: ");
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(mapSheetAnalDataInferenceGeomEntity.geoUid.count())
|
||||
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||
.where(
|
||||
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(entity.getCompareYyyy()),
|
||||
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(entity.getTargetYyyy()),
|
||||
mapSheetAnalDataInferenceGeomEntity.stage.eq(stage),
|
||||
mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
|
||||
.fetchOne();
|
||||
.selectFrom(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analEntity.getAnalUid()),
|
||||
labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()),
|
||||
labelingAssignmentEntity.inspectorUid.isNull())
|
||||
.orderBy(labelingAssignmentEntity.workerUid.asc())
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy) {
|
||||
|
||||
return queryFactory
|
||||
.select(mapSheetAnalDataInferenceGeomEntity.geoUid.count())
|
||||
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||
.where(
|
||||
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetAnalDataInferenceGeomEntity.stage.eq(stage),
|
||||
mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignInspector(UUID assignmentUid, String inspectorUid) {
|
||||
queryFactory
|
||||
.update(labelingAssignmentEntity)
|
||||
.set(labelingAssignmentEntity.inspectorUid, inspectorUid)
|
||||
.where(labelingAssignmentEntity.assignmentUid.eq(assignmentUid))
|
||||
.execute();
|
||||
.update(labelingAssignmentEntity)
|
||||
.set(labelingAssignmentEntity.inspectorUid, inspectorUid)
|
||||
.where(labelingAssignmentEntity.assignmentUid.eq(assignmentUid))
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserList> availUserList(String role) {
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LabelAllocateDto.UserList.class,
|
||||
memberEntity.userRole,
|
||||
memberEntity.employeeNo,
|
||||
memberEntity.name))
|
||||
.from(memberEntity)
|
||||
.where(
|
||||
memberEntity.userRole.eq(role),
|
||||
memberEntity.status.eq(com.kamco.cd.kamcoback.common.enums.StatusType.ACTIVE.getId()))
|
||||
.orderBy(memberEntity.name.asc())
|
||||
.fetch();
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LabelAllocateDto.UserList.class,
|
||||
memberEntity.userRole,
|
||||
memberEntity.employeeNo,
|
||||
memberEntity.name))
|
||||
.from(memberEntity)
|
||||
.where(
|
||||
memberEntity.userRole.eq(role),
|
||||
memberEntity.status.eq(com.kamco.cd.kamcoback.common.enums.StatusType.ACTIVE.getId()))
|
||||
.orderBy(memberEntity.name.asc())
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WorkerStatistics> findWorkerStatistics(
|
||||
Long analUid,
|
||||
String workerType,
|
||||
String searchName,
|
||||
String searchEmployeeNo,
|
||||
String sortType) {
|
||||
Long analUid,
|
||||
String workerType,
|
||||
String searchName,
|
||||
String searchEmployeeNo,
|
||||
String sortType) {
|
||||
|
||||
// 작업자 유형에 따른 필드 선택
|
||||
StringExpression workerIdField =
|
||||
"REVIEWER".equals(workerType)
|
||||
? labelingAssignmentEntity.inspectorUid
|
||||
: labelingAssignmentEntity.workerUid;
|
||||
"REVIEWER".equals(workerType)
|
||||
? labelingAssignmentEntity.inspectorUid
|
||||
: labelingAssignmentEntity.workerUid;
|
||||
|
||||
BooleanExpression workerCondition =
|
||||
"REVIEWER".equals(workerType)
|
||||
? labelingAssignmentEntity.inspectorUid.isNotNull()
|
||||
: labelingAssignmentEntity.workerUid.isNotNull();
|
||||
"REVIEWER".equals(workerType)
|
||||
? labelingAssignmentEntity.inspectorUid.isNotNull()
|
||||
: labelingAssignmentEntity.workerUid.isNotNull();
|
||||
|
||||
// 검색 조건
|
||||
BooleanExpression searchCondition = null;
|
||||
@@ -201,49 +218,49 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
|
||||
// 완료, 스킵, 남은 작업 계산
|
||||
NumberExpression<Long> completedSum =
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq("DONE"))
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum();
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq("DONE"))
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum();
|
||||
|
||||
NumberExpression<Long> skippedSum =
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq("SKIP"))
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum();
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq("SKIP"))
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum();
|
||||
|
||||
NumberExpression<Long> remainingSum =
|
||||
new CaseBuilder()
|
||||
.when(
|
||||
labelingAssignmentEntity
|
||||
.workState
|
||||
.notIn("DONE", "SKIP")
|
||||
.and(labelingAssignmentEntity.workState.isNotNull()))
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum();
|
||||
new CaseBuilder()
|
||||
.when(
|
||||
labelingAssignmentEntity
|
||||
.workState
|
||||
.notIn("DONE", "SKIP")
|
||||
.and(labelingAssignmentEntity.workState.isNotNull()))
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum();
|
||||
|
||||
// 기본 통계 조회 쿼리
|
||||
var baseQuery =
|
||||
queryFactory
|
||||
.select(
|
||||
workerIdField,
|
||||
memberEntity.name,
|
||||
workerIdField.count(),
|
||||
completedSum,
|
||||
skippedSum,
|
||||
remainingSum,
|
||||
labelingAssignmentEntity.stagnationYn.max())
|
||||
.from(labelingAssignmentEntity)
|
||||
.leftJoin(memberEntity)
|
||||
.on(
|
||||
"REVIEWER".equals(workerType)
|
||||
? memberEntity.employeeNo.eq(labelingAssignmentEntity.inspectorUid)
|
||||
: memberEntity.employeeNo.eq(labelingAssignmentEntity.workerUid))
|
||||
.where(labelingAssignmentEntity.analUid.eq(analUid), workerCondition, searchCondition)
|
||||
.groupBy(workerIdField, memberEntity.name);
|
||||
queryFactory
|
||||
.select(
|
||||
workerIdField,
|
||||
memberEntity.name,
|
||||
workerIdField.count(),
|
||||
completedSum,
|
||||
skippedSum,
|
||||
remainingSum,
|
||||
labelingAssignmentEntity.stagnationYn.max())
|
||||
.from(labelingAssignmentEntity)
|
||||
.leftJoin(memberEntity)
|
||||
.on(
|
||||
"REVIEWER".equals(workerType)
|
||||
? memberEntity.employeeNo.eq(labelingAssignmentEntity.inspectorUid)
|
||||
: memberEntity.employeeNo.eq(labelingAssignmentEntity.workerUid))
|
||||
.where(labelingAssignmentEntity.analUid.eq(analUid), workerCondition, searchCondition)
|
||||
.groupBy(workerIdField, memberEntity.name);
|
||||
|
||||
// 정렬 조건 적용
|
||||
if (sortType != null) {
|
||||
@@ -269,132 +286,132 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
|
||||
// 결과를 DTO로 변환
|
||||
return baseQuery.fetch().stream()
|
||||
.map(
|
||||
tuple -> {
|
||||
Character maxStagnationYn = tuple.get(labelingAssignmentEntity.stagnationYn.max());
|
||||
return WorkerStatistics.builder()
|
||||
.workerId(tuple.get(workerIdField))
|
||||
.workerName(tuple.get(memberEntity.name))
|
||||
.workerType(workerType)
|
||||
.totalAssigned(tuple.get(workerIdField.count()))
|
||||
.completed(tuple.get(completedSum))
|
||||
.skipped(tuple.get(skippedSum))
|
||||
.remaining(tuple.get(remainingSum))
|
||||
.history(null) // 3일 이력은 Service에서 채움
|
||||
.isStagnated(maxStagnationYn != null && maxStagnationYn == 'Y')
|
||||
.build();
|
||||
})
|
||||
.toList();
|
||||
.map(
|
||||
tuple -> {
|
||||
Character maxStagnationYn = tuple.get(labelingAssignmentEntity.stagnationYn.max());
|
||||
return WorkerStatistics.builder()
|
||||
.workerId(tuple.get(workerIdField))
|
||||
.workerName(tuple.get(memberEntity.name))
|
||||
.workerType(workerType)
|
||||
.totalAssigned(tuple.get(workerIdField.count()))
|
||||
.completed(tuple.get(completedSum))
|
||||
.skipped(tuple.get(skippedSum))
|
||||
.remaining(tuple.get(remainingSum))
|
||||
.history(null) // 3일 이력은 Service에서 채움
|
||||
.isStagnated(maxStagnationYn != null && maxStagnationYn == 'Y')
|
||||
.build();
|
||||
})
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkProgressInfo findWorkProgressInfo(Long analUid) {
|
||||
// 전체 배정 건수
|
||||
Long totalAssigned =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(labelingAssignmentEntity.analUid.eq(analUid))
|
||||
.fetchOne();
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(labelingAssignmentEntity.analUid.eq(analUid))
|
||||
.fetchOne();
|
||||
|
||||
// 완료 + 스킵 건수
|
||||
Long completedCount =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.workState.in("DONE", "SKIP"))
|
||||
.fetchOne();
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.workState.in("DONE", "SKIP"))
|
||||
.fetchOne();
|
||||
|
||||
// 투입된 라벨러 수 (고유한 worker_uid 수)
|
||||
Long labelerCount =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.workerUid.countDistinct())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.workerUid.isNotNull())
|
||||
.fetchOne();
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.workerUid.countDistinct())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.workerUid.isNotNull())
|
||||
.fetchOne();
|
||||
|
||||
// 남은 라벨링 작업 데이터 수
|
||||
Long remainingLabelCount =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.workerUid.isNotNull(),
|
||||
labelingAssignmentEntity.workState.notIn("DONE", "SKIP"))
|
||||
.fetchOne();
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.workerUid.isNotNull(),
|
||||
labelingAssignmentEntity.workState.notIn("DONE", "SKIP"))
|
||||
.fetchOne();
|
||||
|
||||
// 투입된 검수자 수 (고유한 inspector_uid 수)
|
||||
Long inspectorCount =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.inspectorUid.countDistinct())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.inspectorUid.isNotNull())
|
||||
.fetchOne();
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.inspectorUid.countDistinct())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.inspectorUid.isNotNull())
|
||||
.fetchOne();
|
||||
|
||||
// 남은 검수 작업 데이터 수
|
||||
Long remainingInspectCount =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.inspectorUid.isNotNull(),
|
||||
labelingAssignmentEntity.workState.notIn("DONE"))
|
||||
.fetchOne();
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.inspectorUid.isNotNull(),
|
||||
labelingAssignmentEntity.workState.notIn("DONE"))
|
||||
.fetchOne();
|
||||
|
||||
// 진행률 계산
|
||||
double progressRate = 0.0;
|
||||
if (totalAssigned != null && totalAssigned > 0) {
|
||||
progressRate =
|
||||
(completedCount != null ? completedCount.doubleValue() : 0.0) / totalAssigned * 100;
|
||||
(completedCount != null ? completedCount.doubleValue() : 0.0) / totalAssigned * 100;
|
||||
}
|
||||
|
||||
// 작업 상태 판단 (간단하게 진행률 100%면 종료, 아니면 진행중)
|
||||
String workStatus = (progressRate >= 100.0) ? "종료" : "진행중";
|
||||
|
||||
return WorkProgressInfo.builder()
|
||||
.labelingProgressRate(progressRate)
|
||||
.workStatus(workStatus)
|
||||
.completedCount(completedCount != null ? completedCount : 0L)
|
||||
.totalAssignedCount(totalAssigned != null ? totalAssigned : 0L)
|
||||
.labelerCount(labelerCount != null ? labelerCount : 0L)
|
||||
.remainingLabelCount(remainingLabelCount != null ? remainingLabelCount : 0L)
|
||||
.inspectorCount(inspectorCount != null ? inspectorCount : 0L)
|
||||
.remainingInspectCount(remainingInspectCount != null ? remainingInspectCount : 0L)
|
||||
.build();
|
||||
.labelingProgressRate(progressRate)
|
||||
.workStatus(workStatus)
|
||||
.completedCount(completedCount != null ? completedCount : 0L)
|
||||
.totalAssignedCount(totalAssigned != null ? totalAssigned : 0L)
|
||||
.labelerCount(labelerCount != null ? labelerCount : 0L)
|
||||
.remainingLabelCount(remainingLabelCount != null ? remainingLabelCount : 0L)
|
||||
.inspectorCount(inspectorCount != null ? inspectorCount : 0L)
|
||||
.remainingInspectCount(remainingInspectCount != null ? remainingInspectCount : 0L)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long findDailyProcessedCount(
|
||||
String workerId, String workerType, LocalDate date, Long analUid) {
|
||||
String workerId, String workerType, LocalDate date, Long analUid) {
|
||||
|
||||
// 해당 날짜의 시작과 끝 시간
|
||||
ZonedDateTime startOfDay = date.atStartOfDay(ZoneId.systemDefault());
|
||||
ZonedDateTime endOfDay = date.atTime(LocalTime.MAX).atZone(ZoneId.systemDefault());
|
||||
|
||||
BooleanExpression workerCondition =
|
||||
"REVIEWER".equals(workerType)
|
||||
? labelingAssignmentEntity.inspectorUid.eq(workerId)
|
||||
: labelingAssignmentEntity.workerUid.eq(workerId);
|
||||
"REVIEWER".equals(workerType)
|
||||
? labelingAssignmentEntity.inspectorUid.eq(workerId)
|
||||
: labelingAssignmentEntity.workerUid.eq(workerId);
|
||||
|
||||
Long count =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
workerCondition,
|
||||
labelingAssignmentEntity.workState.in(
|
||||
LabelState.DONE.getId(), LabelState.SKIP.getId()),
|
||||
labelingAssignmentEntity.modifiedDate.between(startOfDay, endOfDay))
|
||||
.fetchOne();
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
workerCondition,
|
||||
labelingAssignmentEntity.workState.in(
|
||||
LabelState.DONE.getId(), LabelState.SKIP.getId()),
|
||||
labelingAssignmentEntity.modifiedDate.between(startOfDay, endOfDay))
|
||||
.fetchOne();
|
||||
|
||||
return count != null ? count : 0L;
|
||||
}
|
||||
@@ -402,152 +419,172 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
@Override
|
||||
public void assignInspectorBulk(List<UUID> assignmentUids, String inspectorUid) {
|
||||
queryFactory
|
||||
.update(labelingAssignmentEntity)
|
||||
.set(labelingAssignmentEntity.inspectorUid, inspectorUid)
|
||||
.where(labelingAssignmentEntity.assignmentUid.in(assignmentUids))
|
||||
.execute();
|
||||
.update(labelingAssignmentEntity)
|
||||
.set(labelingAssignmentEntity.inspectorUid, inspectorUid)
|
||||
.where(labelingAssignmentEntity.assignmentUid.in(assignmentUids))
|
||||
.execute();
|
||||
|
||||
em.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InferenceDetail findInferenceDetail(Long analUid) {
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
InferenceDetail.class,
|
||||
mapSheetAnalEntity.analTitle,
|
||||
Expressions.numberTemplate(Integer.class, "{0}", 4),
|
||||
mapSheetAnalEntity.gukyuinApplyDttm,
|
||||
mapSheetAnalEntity.detectingCnt,
|
||||
labelingAssignmentEntity.workerUid.countDistinct(),
|
||||
labelingAssignmentEntity.inspectorUid.countDistinct()))
|
||||
.from(mapSheetAnalEntity)
|
||||
.innerJoin(labelingAssignmentEntity)
|
||||
.on(mapSheetAnalEntity.id.eq(labelingAssignmentEntity.analUid))
|
||||
.where(mapSheetAnalEntity.id.eq(analUid))
|
||||
.groupBy(
|
||||
mapSheetAnalEntity.analTitle,
|
||||
mapSheetAnalEntity.gukyuinApplyDttm,
|
||||
mapSheetAnalEntity.detectingCnt)
|
||||
public InferenceDetail findInferenceDetail(Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
// analUid로 분석 정보 조회
|
||||
MapSheetAnalDataInferenceEntity analEntity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalDataInferenceEntity)
|
||||
.where(mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetAnalDataInferenceEntity.stage.eq(stage)
|
||||
)
|
||||
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
|
||||
.limit(1)
|
||||
.fetchOne();
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
InferenceDetail.class,
|
||||
mapSheetAnalEntity.analTitle,
|
||||
Expressions.numberTemplate(Integer.class, "{0}", 4),
|
||||
mapSheetAnalEntity.gukyuinApplyDttm,
|
||||
mapSheetAnalEntity.detectingCnt,
|
||||
labelingAssignmentEntity.workerUid.countDistinct(),
|
||||
labelingAssignmentEntity.inspectorUid.countDistinct()))
|
||||
.from(mapSheetAnalEntity)
|
||||
.innerJoin(labelingAssignmentEntity)
|
||||
.on(mapSheetAnalEntity.id.eq(labelingAssignmentEntity.analUid))
|
||||
.where(mapSheetAnalEntity.id.eq(analEntity.getAnalUid()))
|
||||
.groupBy(
|
||||
mapSheetAnalEntity.analTitle,
|
||||
mapSheetAnalEntity.gukyuinApplyDttm,
|
||||
mapSheetAnalEntity.detectingCnt)
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> fetchNextMoveIds(Long lastId, Long batchSize) {
|
||||
MapSheetAnalEntity entity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalEntity)
|
||||
.where(mapSheetAnalEntity.id.eq(3L)) // TODO
|
||||
.fetchOne();
|
||||
|
||||
if (Objects.isNull(entity)) {
|
||||
throw new EntityNotFoundException();
|
||||
}
|
||||
public List<Long> fetchNextMoveIds(Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
|
||||
return queryFactory
|
||||
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
|
||||
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||
.where(
|
||||
// mapSheetAnalDataGeomEntity.pnu.isNotNull(), //TODO: Mockup 진행 이후 확인하기
|
||||
lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId),
|
||||
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(entity.getCompareYyyy()),
|
||||
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(entity.getTargetYyyy()),
|
||||
mapSheetAnalDataInferenceGeomEntity.labelState.in(
|
||||
LabelState.ASSIGNED.getId(), LabelState.SKIP.getId()))
|
||||
.orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc())
|
||||
.limit(batchSize)
|
||||
.fetch();
|
||||
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
|
||||
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||
.where(
|
||||
// mapSheetAnalDataGeomEntity.pnu.isNotNull(), //TODO: Mockup 진행 이후 확인하기
|
||||
lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId),
|
||||
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetAnalDataInferenceGeomEntity.stage.eq(stage),
|
||||
mapSheetAnalDataInferenceGeomEntity.labelState.in(
|
||||
LabelState.ASSIGNED.getId(), LabelState.SKIP.getId()))
|
||||
.orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc())
|
||||
.limit(batchSize)
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long findLabelUnCompleteCnt(Long analUid) {
|
||||
MapSheetAnalEntity entity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalEntity)
|
||||
.where(mapSheetAnalEntity.id.eq(analUid))
|
||||
.fetchOne();
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalEntity)
|
||||
.where(mapSheetAnalEntity.id.eq(analUid))
|
||||
.fetchOne();
|
||||
|
||||
if (Objects.isNull(entity)) {
|
||||
throw new EntityNotFoundException();
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(mapSheetAnalDataInferenceGeomEntity.geoUid.count())
|
||||
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||
.where(
|
||||
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(entity.getCompareYyyy()),
|
||||
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(entity.getTargetYyyy()),
|
||||
mapSheetAnalDataInferenceGeomEntity.stage.eq(4), // TODO: 회차 컬럼을 가져와야 할 듯?
|
||||
mapSheetAnalDataInferenceGeomEntity.labelState.in(
|
||||
LabelState.ASSIGNED.getId(), LabelState.SKIP.getId()))
|
||||
.fetchOne();
|
||||
.select(mapSheetAnalDataInferenceGeomEntity.geoUid.count())
|
||||
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||
.where(
|
||||
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(entity.getCompareYyyy()),
|
||||
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(entity.getTargetYyyy()),
|
||||
mapSheetAnalDataInferenceGeomEntity.stage.eq(4), // TODO: 회차 컬럼을 가져와야 할 듯?
|
||||
mapSheetAnalDataInferenceGeomEntity.labelState.in(
|
||||
LabelState.ASSIGNED.getId(), LabelState.SKIP.getId()))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void assignOwnerMove(List<Long> sub, String userId) {
|
||||
queryFactory
|
||||
.update(labelingAssignmentEntity)
|
||||
.set(labelingAssignmentEntity.workerUid, userId)
|
||||
.where(labelingAssignmentEntity.inferenceGeomUid.in(sub))
|
||||
.execute();
|
||||
.update(labelingAssignmentEntity)
|
||||
.set(labelingAssignmentEntity.workerUid, userId)
|
||||
.where(labelingAssignmentEntity.inferenceGeomUid.in(sub))
|
||||
.execute();
|
||||
|
||||
em.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LabelerDetail findLabelerDetail(String userId, Long analUid) {
|
||||
public LabelerDetail findLabelerDetail(String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
NumberExpression<Long> assignedCnt =
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()))
|
||||
.then(1L)
|
||||
.otherwise((Long) null)
|
||||
.count();
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()))
|
||||
.then(1L)
|
||||
.otherwise((Long) null)
|
||||
.count();
|
||||
|
||||
NumberExpression<Long> skipCnt =
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq(LabelState.SKIP.getId()))
|
||||
.then(1L)
|
||||
.otherwise((Long) null)
|
||||
.count();
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq(LabelState.SKIP.getId()))
|
||||
.then(1L)
|
||||
.otherwise((Long) null)
|
||||
.count();
|
||||
|
||||
NumberExpression<Long> completeCnt =
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq(LabelState.COMPLETE.getId()))
|
||||
.then(1L)
|
||||
.otherwise((Long) null)
|
||||
.count();
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq(LabelState.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로 분석 정보 조회
|
||||
MapSheetAnalDataInferenceEntity analEntity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalDataInferenceEntity)
|
||||
.where(mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetAnalDataInferenceEntity.stage.eq(stage)
|
||||
)
|
||||
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
|
||||
.limit(1)
|
||||
.fetchOne();
|
||||
|
||||
if (Objects.isNull(analEntity)) {
|
||||
throw new EntityNotFoundException("MapSheetAnalEntity not found for analUid: ");
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LabelerDetail.class,
|
||||
memberEntity.userRole,
|
||||
memberEntity.name,
|
||||
memberEntity.employeeNo,
|
||||
assignedCnt,
|
||||
skipCnt,
|
||||
completeCnt,
|
||||
percent))
|
||||
.from(memberEntity)
|
||||
.innerJoin(labelingAssignmentEntity)
|
||||
.on(
|
||||
memberEntity.employeeNo.eq(labelingAssignmentEntity.workerUid),
|
||||
labelingAssignmentEntity.analUid.eq(analUid))
|
||||
.where(memberEntity.employeeNo.eq(userId))
|
||||
.groupBy(memberEntity.userRole, memberEntity.name, memberEntity.employeeNo)
|
||||
.fetchOne();
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LabelerDetail.class,
|
||||
memberEntity.userRole,
|
||||
memberEntity.name,
|
||||
memberEntity.employeeNo,
|
||||
assignedCnt,
|
||||
skipCnt,
|
||||
completeCnt,
|
||||
percent))
|
||||
.from(memberEntity)
|
||||
.innerJoin(labelingAssignmentEntity)
|
||||
.on(
|
||||
memberEntity.employeeNo.eq(labelingAssignmentEntity.workerUid),
|
||||
labelingAssignmentEntity.analUid.eq(analEntity.getAnalUid()))
|
||||
.where(memberEntity.employeeNo.eq(userId))
|
||||
.groupBy(memberEntity.userRole, memberEntity.name, memberEntity.employeeNo)
|
||||
.fetchOne();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user