라벨링 목록조회 수정

This commit is contained in:
DanielLee
2026-01-08 18:45:46 +09:00
parent 1e505e2ece
commit 3cdfe2d42c
2 changed files with 61 additions and 51 deletions

View File

@@ -196,14 +196,14 @@ public class LabelWorkDto {
@Schema(description = "1일전처리개수") @Schema(description = "1일전처리개수")
private Long day1AgoDoneCnt; private Long day1AgoDoneCnt;
public Long getremindCnt() { public Long getRemainCnt() {
return this.assignedCnt - this.doneCnt; return this.assignedCnt - this.doneCnt;
} }
public double getDoneRate() { 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 0.0;
} }
return (double) dayDoneCnt / 3; return (double) dayDoneCnt / 3;

View File

@@ -1,18 +1,16 @@
package com.kamco.cd.kamcoback.postgres.repository.label; 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.LabelAllocateDto.LabelState;
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto; 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.LabelWorkMng;
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMngDetail; import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMngDetail;
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.WorkerState; 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.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.BooleanBuilder;
import com.querydsl.core.types.Expression; import com.querydsl.core.types.Expression;
import com.querydsl.core.types.OrderSpecifier; 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.DateTimePath;
import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.NumberExpression; import com.querydsl.core.types.dsl.NumberExpression;
import com.querydsl.core.types.dsl.StringExpression;
import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.impl.JPAQueryFactory; import com.querydsl.jpa.impl.JPAQueryFactory;
import java.time.LocalDate; import java.time.LocalDate;
@@ -31,6 +28,7 @@ import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -47,13 +45,24 @@ import org.springframework.stereotype.Repository;
public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom { public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
private final JPAQueryFactory queryFactory; 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 @Override
public List<MapSheetAnalInferenceEntity> findChangeDetectYearList() { public List<MapSheetAnalInferenceEntity> findChangeDetectYearList() {
@@ -74,9 +83,10 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
/** /**
* 라벨링 작업관리 목록 조회 * 라벨링 작업관리 목록 조회
* (복잡한 집계 쿼리로 인해 DTO 직접 반환)
* *
* @param searchReq * @param searchReq 검색 조건
* @return * @return 라벨링 작업관리 목록 페이지
*/ */
@Override @Override
public Page<LabelWorkMng> labelWorkMngList(LabelWorkDto.LabelWorkMngSearchReq searchReq) { public Page<LabelWorkMng> labelWorkMngList(LabelWorkDto.LabelWorkMngSearchReq searchReq) {
@@ -213,7 +223,9 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
.limit(pageable.getPageSize()) .limit(pageable.getPageSize())
.fetch(); .fetch();
Long total = // Count 쿼리 별도 실행 (null safe handling)
long total =
Optional.ofNullable(
queryFactory queryFactory
.select(mapSheetAnalInferenceEntity.uuid.countDistinct()) .select(mapSheetAnalInferenceEntity.uuid.countDistinct())
.from(mapSheetAnalInferenceEntity) .from(mapSheetAnalInferenceEntity)
@@ -222,7 +234,8 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
.innerJoin(mapSheetAnalDataInferenceGeomEntity) .innerJoin(mapSheetAnalDataInferenceGeomEntity)
.on(whereSubBuilder) .on(whereSubBuilder)
.where(whereBuilder) .where(whereBuilder)
.fetchOne(); .fetchOne())
.orElse(0L);
return new PageImpl<>(foundContent, pageable, total); return new PageImpl<>(foundContent, pageable, total);
} }
@@ -319,7 +332,9 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
.limit(pageable.getPageSize()) .limit(pageable.getPageSize())
.fetch(); .fetch();
Long countQuery = // Count 쿼리 별도 실행 (null safe handling)
long countQuery =
Optional.ofNullable(
queryFactory queryFactory
.select(labelingAssignmentEntity.workerUid.countDistinct()) .select(labelingAssignmentEntity.workerUid.countDistinct())
.from(labelingAssignmentEntity) .from(labelingAssignmentEntity)
@@ -332,8 +347,8 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
.innerJoin(memberEntity) .innerJoin(memberEntity)
.on(whereSubBuilder) .on(whereSubBuilder)
.where(whereBuilder) .where(whereBuilder)
// .groupBy(memberEntity.userRole, memberEntity.name, memberEntity.userId) .fetchOne())
.fetchOne(); .orElse(0L);
return new PageImpl<>(foundContent, pageable, countQuery); return new PageImpl<>(foundContent, pageable, countQuery);
} }
@@ -374,9 +389,10 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
/** /**
* 작업배정 상세조회 * 작업배정 상세조회
* (복잡한 집계 쿼리로 인해 DTO 직접 반환)
* *
* @param uuid * @param uuid 작업배정 UUID
* @return * @return 작업배정 상세 정보
*/ */
@Override @Override
public LabelWorkMngDetail findLabelWorkMngDetail(UUID uuid) { public LabelWorkMngDetail findLabelWorkMngDetail(UUID uuid) {
@@ -418,19 +434,13 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
} }
public NumberExpression<Long> caseSumExpression(BooleanExpression condition) { public NumberExpression<Long> caseSumExpression(BooleanExpression condition) {
NumberExpression<Long> sumExp = new CaseBuilder().when(condition).then(1L).otherwise(0L).sum(); return new CaseBuilder().when(condition).then(1L).otherwise(0L).sum();
return sumExp;
} }
public BooleanExpression fromDateEqExpression(DateTimePath<ZonedDateTime> path, int addDayCnt) { public BooleanExpression fromDateEqExpression(DateTimePath<ZonedDateTime> path, int addDayCnt) {
LocalDate threeDaysAgo = LocalDate.now().plusDays(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 = return Expressions.stringTemplate("to_char({0}, 'yyyy-MM-dd')", path).eq(toDate);
Expressions.stringTemplate("to_char({0}, 'YYYY-MM-DD')", path).eq(toDate);
return condition;
} }
} }