라벨링 목록조회 수정
This commit is contained in:
@@ -196,14 +196,14 @@ public class LabelWorkDto {
|
||||
@Schema(description = "1일전처리개수")
|
||||
private Long day1AgoDoneCnt;
|
||||
|
||||
public Long getremindCnt() {
|
||||
public Long getRemainCnt() {
|
||||
return this.assignedCnt - this.doneCnt;
|
||||
}
|
||||
|
||||
public double getDoneRate() {
|
||||
Long dayDoneCnt = this.day3AgoDoneCnt + this.day2AgoDoneCnt + this.day1AgoDoneCnt;
|
||||
long dayDoneCnt = this.day3AgoDoneCnt + this.day2AgoDoneCnt + this.day1AgoDoneCnt;
|
||||
|
||||
if (dayDoneCnt == null || dayDoneCnt == 0) {
|
||||
if (dayDoneCnt == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
return (double) dayDoneCnt / 3;
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
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.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMemberEntity.memberEntity;
|
||||
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelState;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMng;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMngDetail;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.WorkerState;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataInferenceGeomEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalInferenceEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.QLabelingAssignmentEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.QMemberEntity;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.OrderSpecifier;
|
||||
@@ -22,7 +20,6 @@ import com.querydsl.core.types.dsl.CaseBuilder;
|
||||
import com.querydsl.core.types.dsl.DateTimePath;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.core.types.dsl.NumberExpression;
|
||||
import com.querydsl.core.types.dsl.StringExpression;
|
||||
import com.querydsl.jpa.JPAExpressions;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.time.LocalDate;
|
||||
@@ -31,6 +28,7 @@ import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -47,13 +45,24 @@ import org.springframework.stereotype.Repository;
|
||||
public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
private final StringExpression NULL_STRING = Expressions.stringTemplate("cast(null as text)");
|
||||
|
||||
// Q클래스 필드 선언
|
||||
private final QMapSheetAnalInferenceEntity mapSheetAnalInferenceEntity =
|
||||
QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
|
||||
private final QMapSheetAnalDataInferenceEntity mapSheetAnalDataInferenceEntity =
|
||||
QMapSheetAnalDataInferenceEntity.mapSheetAnalDataInferenceEntity;
|
||||
private final QMapSheetAnalDataInferenceGeomEntity mapSheetAnalDataInferenceGeomEntity =
|
||||
QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity;
|
||||
private final QLabelingAssignmentEntity labelingAssignmentEntity =
|
||||
QLabelingAssignmentEntity.labelingAssignmentEntity;
|
||||
private final QMemberEntity memberEntity = QMemberEntity.memberEntity;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 변화탐지 년도 셀렉트박스 조회
|
||||
*
|
||||
* @return
|
||||
* @return 변화탐지 년도 목록 (Entity 반환)
|
||||
*/
|
||||
@Override
|
||||
public List<MapSheetAnalInferenceEntity> findChangeDetectYearList() {
|
||||
@@ -74,9 +83,10 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
|
||||
|
||||
/**
|
||||
* 라벨링 작업관리 목록 조회
|
||||
* (복잡한 집계 쿼리로 인해 DTO 직접 반환)
|
||||
*
|
||||
* @param searchReq
|
||||
* @return
|
||||
* @param searchReq 검색 조건
|
||||
* @return 라벨링 작업관리 목록 페이지
|
||||
*/
|
||||
@Override
|
||||
public Page<LabelWorkMng> labelWorkMngList(LabelWorkDto.LabelWorkMngSearchReq searchReq) {
|
||||
@@ -213,16 +223,19 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
|
||||
.limit(pageable.getPageSize())
|
||||
.fetch();
|
||||
|
||||
Long total =
|
||||
queryFactory
|
||||
.select(mapSheetAnalInferenceEntity.uuid.countDistinct())
|
||||
.from(mapSheetAnalInferenceEntity)
|
||||
.innerJoin(mapSheetAnalDataInferenceEntity)
|
||||
.on(whereSubDataBuilder)
|
||||
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||
.on(whereSubBuilder)
|
||||
.where(whereBuilder)
|
||||
.fetchOne();
|
||||
// Count 쿼리 별도 실행 (null safe handling)
|
||||
long total =
|
||||
Optional.ofNullable(
|
||||
queryFactory
|
||||
.select(mapSheetAnalInferenceEntity.uuid.countDistinct())
|
||||
.from(mapSheetAnalInferenceEntity)
|
||||
.innerJoin(mapSheetAnalDataInferenceEntity)
|
||||
.on(whereSubDataBuilder)
|
||||
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||
.on(whereSubBuilder)
|
||||
.where(whereBuilder)
|
||||
.fetchOne())
|
||||
.orElse(0L);
|
||||
|
||||
return new PageImpl<>(foundContent, pageable, total);
|
||||
}
|
||||
@@ -319,21 +332,23 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
|
||||
.limit(pageable.getPageSize())
|
||||
.fetch();
|
||||
|
||||
Long countQuery =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.workerUid.countDistinct())
|
||||
.from(labelingAssignmentEntity)
|
||||
.innerJoin(mapSheetAnalInferenceEntity)
|
||||
.on(
|
||||
mapSheetAnalInferenceEntity
|
||||
.uuid
|
||||
.eq(uuid)
|
||||
.and(labelingAssignmentEntity.analUid.eq(mapSheetAnalInferenceEntity.id)))
|
||||
.innerJoin(memberEntity)
|
||||
.on(whereSubBuilder)
|
||||
.where(whereBuilder)
|
||||
// .groupBy(memberEntity.userRole, memberEntity.name, memberEntity.userId)
|
||||
.fetchOne();
|
||||
// Count 쿼리 별도 실행 (null safe handling)
|
||||
long countQuery =
|
||||
Optional.ofNullable(
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.workerUid.countDistinct())
|
||||
.from(labelingAssignmentEntity)
|
||||
.innerJoin(mapSheetAnalInferenceEntity)
|
||||
.on(
|
||||
mapSheetAnalInferenceEntity
|
||||
.uuid
|
||||
.eq(uuid)
|
||||
.and(labelingAssignmentEntity.analUid.eq(mapSheetAnalInferenceEntity.id)))
|
||||
.innerJoin(memberEntity)
|
||||
.on(whereSubBuilder)
|
||||
.where(whereBuilder)
|
||||
.fetchOne())
|
||||
.orElse(0L);
|
||||
|
||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||
}
|
||||
@@ -374,9 +389,10 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
|
||||
|
||||
/**
|
||||
* 작업배정 상세조회
|
||||
* (복잡한 집계 쿼리로 인해 DTO 직접 반환)
|
||||
*
|
||||
* @param uuid
|
||||
* @return
|
||||
* @param uuid 작업배정 UUID
|
||||
* @return 작업배정 상세 정보
|
||||
*/
|
||||
@Override
|
||||
public LabelWorkMngDetail findLabelWorkMngDetail(UUID uuid) {
|
||||
@@ -418,19 +434,13 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
|
||||
}
|
||||
|
||||
public NumberExpression<Long> caseSumExpression(BooleanExpression condition) {
|
||||
NumberExpression<Long> sumExp = new CaseBuilder().when(condition).then(1L).otherwise(0L).sum();
|
||||
|
||||
return sumExp;
|
||||
return new CaseBuilder().when(condition).then(1L).otherwise(0L).sum();
|
||||
}
|
||||
|
||||
public BooleanExpression fromDateEqExpression(DateTimePath<ZonedDateTime> path, int addDayCnt) {
|
||||
|
||||
LocalDate threeDaysAgo = LocalDate.now().plusDays(addDayCnt);
|
||||
String toDate = threeDaysAgo.format(DateTimeFormatter.ofPattern("YYYY-MM-DD"));
|
||||
String toDate = threeDaysAgo.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
|
||||
BooleanExpression condition =
|
||||
Expressions.stringTemplate("to_char({0}, 'YYYY-MM-DD')", path).eq(toDate);
|
||||
|
||||
return condition;
|
||||
return Expressions.stringTemplate("to_char({0}, 'yyyy-MM-dd')", path).eq(toDate);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user