라벨링 작업이력 수정
This commit is contained in:
@@ -1466,13 +1466,6 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
|
||||
NumberExpression<Long> totalCnt = labelingAssignmentEntity.assignmentUid.count();
|
||||
|
||||
NumberExpression<Long> assignedCnt =
|
||||
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()))
|
||||
@@ -1487,78 +1480,166 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
.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)",
|
||||
completeCnt,
|
||||
labelingAssignmentEntity.count()));
|
||||
|
||||
Pageable pageable = searchReq.toPageable();
|
||||
List<WorkHistoryDto> list =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
Projections.bean(
|
||||
WorkHistoryDto.class,
|
||||
Expressions.numberTemplate(
|
||||
Integer.class,
|
||||
"row_number() over(order by {0} desc)",
|
||||
labelingAssignmentEntity.analUid),
|
||||
Expressions.stringTemplate(
|
||||
"concat({0}, '-', {1})",
|
||||
mapSheetAnalInferenceEntity.compareYyyy,
|
||||
mapSheetAnalInferenceEntity.targetYyyy),
|
||||
mapSheetAnalInferenceEntity.stage,
|
||||
mapSheetAnalInferenceEntity.gukyuinApplyDttm,
|
||||
assignedCnt,
|
||||
completeCnt,
|
||||
skipCnt,
|
||||
skipCnt,
|
||||
// status,
|
||||
percent,
|
||||
mapSheetAnalInferenceEntity.createdDttm,
|
||||
"concat({0}, '-', {1})",
|
||||
mapSheetAnalInferenceEntity.compareYyyy,
|
||||
mapSheetAnalInferenceEntity.targetYyyy)
|
||||
.as("changeDetectionYear"),
|
||||
mapSheetAnalInferenceEntity.stage.longValue().as("stage"),
|
||||
mapSheetAnalInferenceEntity.gukyuinApplyDttm.as("gukyuinApplyDttm"),
|
||||
totalCnt.as("assignedCnt"),
|
||||
completeCnt.as("completeCnt"),
|
||||
skipCnt.as("skipCnt"),
|
||||
mapSheetAnalInferenceEntity.createdDttm.as("createdDttm"),
|
||||
new CaseBuilder()
|
||||
.when(mapSheetAnalInferenceEntity.inspectionClosedYn.eq("Y"))
|
||||
.then(mapSheetAnalInferenceEntity.updatedDttm)
|
||||
.otherwise((ZonedDateTime) null)))
|
||||
.otherwise((ZonedDateTime) null)
|
||||
.as("projectCloseDttm")))
|
||||
.from(labelingAssignmentEntity)
|
||||
.innerJoin(mapSheetAnalInferenceEntity)
|
||||
.on(labelingAssignmentEntity.analUid.eq(mapSheetAnalInferenceEntity.id))
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.in(
|
||||
JPAExpressions.select(labelingAssignmentEntity.analUid)
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(labelingAssignmentEntity.workerUid.eq(userId))
|
||||
.groupBy(labelingAssignmentEntity.analUid)))
|
||||
.orderBy(percent.desc())
|
||||
.where(labelingAssignmentEntity.workerUid.eq(userId))
|
||||
.groupBy(
|
||||
mapSheetAnalInferenceEntity.id,
|
||||
mapSheetAnalInferenceEntity.compareYyyy,
|
||||
mapSheetAnalInferenceEntity.targetYyyy,
|
||||
mapSheetAnalInferenceEntity.stage,
|
||||
mapSheetAnalInferenceEntity.gukyuinApplyDttm,
|
||||
mapSheetAnalInferenceEntity.createdDttm,
|
||||
mapSheetAnalInferenceEntity.inspectionClosedYn,
|
||||
mapSheetAnalInferenceEntity.updatedDttm)
|
||||
.orderBy(mapSheetAnalInferenceEntity.id.desc())
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
.fetch();
|
||||
|
||||
// rowNum과 remainCnt, percent를 Java에서 계산
|
||||
int startRow = (int) pageable.getOffset() + 1;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
WorkHistoryDto dto = list.get(i);
|
||||
dto.setRowNum(startRow + i);
|
||||
|
||||
// remainCnt 계산
|
||||
Long assigned = dto.getAssignedCnt() != null ? dto.getAssignedCnt() : 0L;
|
||||
Long complete = dto.getCompleteCnt() != null ? dto.getCompleteCnt() : 0L;
|
||||
Long skip = dto.getSkipCnt() != null ? dto.getSkipCnt() : 0L;
|
||||
dto.setRemainCnt(assigned - complete - skip);
|
||||
|
||||
// percent 계산
|
||||
if (assigned > 0) {
|
||||
dto.setPercent(Math.round((double) complete / assigned * 100.0 * 100.0) / 100.0);
|
||||
} else {
|
||||
dto.setPercent(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
Long countQuery =
|
||||
queryFactory
|
||||
.select(mapSheetAnalInferenceEntity.id.count())
|
||||
.select(mapSheetAnalInferenceEntity.id.countDistinct())
|
||||
.from(labelingAssignmentEntity)
|
||||
.innerJoin(mapSheetAnalInferenceEntity)
|
||||
.on(labelingAssignmentEntity.analUid.eq(mapSheetAnalInferenceEntity.id))
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.in(
|
||||
JPAExpressions.select(labelingAssignmentEntity.analUid)
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(labelingAssignmentEntity.workerUid.eq(userId))
|
||||
.groupBy(labelingAssignmentEntity.analUid)))
|
||||
.where(labelingAssignmentEntity.workerUid.eq(userId))
|
||||
.fetchOne();
|
||||
|
||||
return new PageImpl<>(list, pageable, countQuery);
|
||||
return new PageImpl<>(list, pageable, countQuery != null ? countQuery : 0L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<WorkHistoryDto> workReviewerHistoryList(searchReq searchReq, String userId) {
|
||||
|
||||
return null;
|
||||
NumberExpression<Long> totalCnt = labelingAssignmentEntity.assignmentUid.count();
|
||||
|
||||
NumberExpression<Long> skipCnt =
|
||||
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();
|
||||
|
||||
Pageable pageable = searchReq.toPageable();
|
||||
List<WorkHistoryDto> list =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.bean(
|
||||
WorkHistoryDto.class,
|
||||
Expressions.stringTemplate(
|
||||
"concat({0}, '-', {1})",
|
||||
mapSheetAnalInferenceEntity.compareYyyy,
|
||||
mapSheetAnalInferenceEntity.targetYyyy)
|
||||
.as("changeDetectionYear"),
|
||||
mapSheetAnalInferenceEntity.stage.longValue().as("stage"),
|
||||
mapSheetAnalInferenceEntity.gukyuinApplyDttm.as("gukyuinApplyDttm"),
|
||||
totalCnt.as("assignedCnt"),
|
||||
completeCnt.as("completeCnt"),
|
||||
skipCnt.as("skipCnt"),
|
||||
mapSheetAnalInferenceEntity.createdDttm.as("createdDttm"),
|
||||
new CaseBuilder()
|
||||
.when(mapSheetAnalInferenceEntity.inspectionClosedYn.eq("Y"))
|
||||
.then(mapSheetAnalInferenceEntity.updatedDttm)
|
||||
.otherwise((ZonedDateTime) null)
|
||||
.as("projectCloseDttm")))
|
||||
.from(labelingAssignmentEntity)
|
||||
.innerJoin(mapSheetAnalInferenceEntity)
|
||||
.on(labelingAssignmentEntity.analUid.eq(mapSheetAnalInferenceEntity.id))
|
||||
.where(labelingAssignmentEntity.inspectorUid.eq(userId))
|
||||
.groupBy(
|
||||
mapSheetAnalInferenceEntity.id,
|
||||
mapSheetAnalInferenceEntity.compareYyyy,
|
||||
mapSheetAnalInferenceEntity.targetYyyy,
|
||||
mapSheetAnalInferenceEntity.stage,
|
||||
mapSheetAnalInferenceEntity.gukyuinApplyDttm,
|
||||
mapSheetAnalInferenceEntity.createdDttm,
|
||||
mapSheetAnalInferenceEntity.inspectionClosedYn,
|
||||
mapSheetAnalInferenceEntity.updatedDttm)
|
||||
.orderBy(mapSheetAnalInferenceEntity.id.desc())
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
.fetch();
|
||||
|
||||
// rowNum과 remainCnt, percent를 Java에서 계산
|
||||
int startRow = (int) pageable.getOffset() + 1;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
WorkHistoryDto dto = list.get(i);
|
||||
dto.setRowNum(startRow + i);
|
||||
|
||||
// remainCnt 계산
|
||||
Long assigned = dto.getAssignedCnt() != null ? dto.getAssignedCnt() : 0L;
|
||||
Long complete = dto.getCompleteCnt() != null ? dto.getCompleteCnt() : 0L;
|
||||
Long skip = dto.getSkipCnt() != null ? dto.getSkipCnt() : 0L;
|
||||
dto.setRemainCnt(assigned - complete - skip);
|
||||
|
||||
// percent 계산
|
||||
if (assigned > 0) {
|
||||
dto.setPercent(Math.round((double) complete / assigned * 100.0 * 100.0) / 100.0);
|
||||
} else {
|
||||
dto.setPercent(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
Long countQuery =
|
||||
queryFactory
|
||||
.select(mapSheetAnalInferenceEntity.id.countDistinct())
|
||||
.from(labelingAssignmentEntity)
|
||||
.innerJoin(mapSheetAnalInferenceEntity)
|
||||
.on(labelingAssignmentEntity.analUid.eq(mapSheetAnalInferenceEntity.id))
|
||||
.where(labelingAssignmentEntity.inspectorUid.eq(userId))
|
||||
.fetchOne();
|
||||
|
||||
return new PageImpl<>(list, pageable, countQuery != null ? countQuery : 0L);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user