라벨링 작업관리 목록조회 수정
This commit is contained in:
@@ -14,6 +14,7 @@ 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.querydsl.core.BooleanBuilder;
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.OrderSpecifier;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||
@@ -24,8 +25,6 @@ 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 jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
@@ -33,29 +32,23 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Slf4j
|
||||
@Repository
|
||||
public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
|
||||
implements LabelWorkRepositoryCustom {
|
||||
@RequiredArgsConstructor
|
||||
public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
private final StringExpression NULL_STRING = Expressions.stringTemplate("cast(null as text)");
|
||||
|
||||
@PersistenceContext private EntityManager em;
|
||||
|
||||
public LabelWorkRepositoryImpl(JPAQueryFactory queryFactory) {
|
||||
super(MapSheetAnalDataInferenceGeomEntity.class);
|
||||
this.queryFactory = queryFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 변화탐지 년도 셀렉트박스 조회
|
||||
@@ -129,6 +122,34 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
|
||||
.and(mapSheetAnalDataInferenceGeomEntity.labelStateDttm.lt(end)));
|
||||
}
|
||||
|
||||
// labelTotCnt: pnu가 있고 pass_yn = false (부적합)인 건수만 라벨링 대상
|
||||
NumberExpression<Long> labelTotCntExpr = new CaseBuilder()
|
||||
.when(
|
||||
mapSheetAnalDataInferenceGeomEntity.pnu.isNotNull()
|
||||
.and(mapSheetAnalDataInferenceGeomEntity.pnu.ne(0L))
|
||||
.and(mapSheetAnalDataInferenceGeomEntity.passYn.eq(Boolean.FALSE)))
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum();
|
||||
|
||||
// stagnation_yn = 'N'인 정상 진행 건수 (서브쿼리로 별도 집계)
|
||||
Expression<Long> normalProgressCntSubQuery =
|
||||
JPAExpressions.select(
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.stagnationYn.eq('N'))
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum()
|
||||
.coalesce(0L))
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(labelingAssignmentEntity.analUid.eq(mapSheetAnalInferenceEntity.id));
|
||||
|
||||
// 총 배정 건수 (서브쿼리로 별도 집계)
|
||||
Expression<Long> totalAssignmentCntSubQuery =
|
||||
JPAExpressions.select(labelingAssignmentEntity.count().coalesce(0L))
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(labelingAssignmentEntity.analUid.eq(mapSheetAnalInferenceEntity.id));
|
||||
|
||||
List<LabelWorkMng> foundContent =
|
||||
queryFactory
|
||||
.select(
|
||||
@@ -138,17 +159,11 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
|
||||
mapSheetAnalInferenceEntity.compareYyyy,
|
||||
mapSheetAnalInferenceEntity.targetYyyy,
|
||||
mapSheetAnalInferenceEntity.stage,
|
||||
mapSheetAnalDataInferenceEntity.createdDttm.min(),
|
||||
// createdDttm: tb_map_sheet_anal_inference.created_dttm 사용
|
||||
mapSheetAnalInferenceEntity.createdDttm,
|
||||
mapSheetAnalDataInferenceGeomEntity.dataUid.count(),
|
||||
new CaseBuilder()
|
||||
.when(
|
||||
mapSheetAnalDataInferenceGeomEntity
|
||||
.pnu
|
||||
.isNotNull()
|
||||
.and(mapSheetAnalDataInferenceGeomEntity.pnu.ne(0L)))
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum(),
|
||||
// labelTotCnt: pnu 있고 pass_yn = false인 건수
|
||||
labelTotCntExpr,
|
||||
new CaseBuilder()
|
||||
.when(mapSheetAnalDataInferenceGeomEntity.labelState.eq("ASSIGNED"))
|
||||
.then(1L)
|
||||
@@ -169,7 +184,13 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum(),
|
||||
mapSheetAnalDataInferenceGeomEntity.labelStateDttm.min()))
|
||||
mapSheetAnalDataInferenceGeomEntity.labelStateDttm.min(),
|
||||
// analState: tb_map_sheet_anal_inference.anal_state
|
||||
mapSheetAnalInferenceEntity.analState,
|
||||
// normalProgressCnt: stagnation_yn = 'N'인 건수 (서브쿼리)
|
||||
normalProgressCntSubQuery,
|
||||
// totalAssignmentCnt: 총 배정 건수 (서브쿼리)
|
||||
totalAssignmentCntSubQuery))
|
||||
.from(mapSheetAnalInferenceEntity)
|
||||
.innerJoin(mapSheetAnalDataInferenceEntity)
|
||||
.on(whereSubDataBuilder)
|
||||
@@ -180,7 +201,10 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
|
||||
mapSheetAnalInferenceEntity.uuid,
|
||||
mapSheetAnalInferenceEntity.compareYyyy,
|
||||
mapSheetAnalInferenceEntity.targetYyyy,
|
||||
mapSheetAnalInferenceEntity.stage)
|
||||
mapSheetAnalInferenceEntity.stage,
|
||||
mapSheetAnalInferenceEntity.createdDttm,
|
||||
mapSheetAnalInferenceEntity.analState,
|
||||
mapSheetAnalInferenceEntity.id)
|
||||
.orderBy(
|
||||
mapSheetAnalInferenceEntity.targetYyyy.desc(),
|
||||
mapSheetAnalInferenceEntity.compareYyyy.desc(),
|
||||
|
||||
Reference in New Issue
Block a user