|
|
|
|
@@ -0,0 +1,157 @@
|
|
|
|
|
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.QMapInkx5kEntity.mapInkx5kEntity;
|
|
|
|
|
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.QMapSheetMngEntity.mapSheetMngEntity;
|
|
|
|
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngHstEntity.mapSheetMngHstEntity;
|
|
|
|
|
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.UserList;
|
|
|
|
|
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto;
|
|
|
|
|
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMng;
|
|
|
|
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
|
|
|
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.ErrorDataDto;
|
|
|
|
|
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
|
|
|
|
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataGeomEntity;
|
|
|
|
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalEntity;
|
|
|
|
|
import com.querydsl.core.BooleanBuilder;
|
|
|
|
|
import com.querydsl.core.types.Projections;
|
|
|
|
|
import com.querydsl.core.types.dsl.CaseBuilder;
|
|
|
|
|
import com.querydsl.core.types.dsl.Expressions;
|
|
|
|
|
import com.querydsl.core.types.dsl.StringExpression;
|
|
|
|
|
import com.querydsl.jpa.impl.JPAQueryFactory;
|
|
|
|
|
import jakarta.persistence.EntityManager;
|
|
|
|
|
import jakarta.persistence.EntityNotFoundException;
|
|
|
|
|
import jakarta.persistence.PersistenceContext;
|
|
|
|
|
import jakarta.validation.Valid;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.ZoneId;
|
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
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 {
|
|
|
|
|
|
|
|
|
|
private final JPAQueryFactory queryFactory;
|
|
|
|
|
private final StringExpression NULL_STRING = Expressions.stringTemplate("cast(null as text)");
|
|
|
|
|
|
|
|
|
|
@PersistenceContext private EntityManager em;
|
|
|
|
|
|
|
|
|
|
public LabelWorkRepositoryImpl(JPAQueryFactory queryFactory) {
|
|
|
|
|
super(MapSheetAnalDataGeomEntity.class);
|
|
|
|
|
this.queryFactory = queryFactory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Page<LabelWorkMng> labelWorkMngList(LabelWorkDto.LabelWorkMngSearchReq searchReq) {
|
|
|
|
|
|
|
|
|
|
Pageable pageable = PageRequest.of(searchReq.getPage(), searchReq.getSize());
|
|
|
|
|
BooleanBuilder whereBuilder = new BooleanBuilder();
|
|
|
|
|
BooleanBuilder whereSubBuilder = new BooleanBuilder();
|
|
|
|
|
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
|
|
|
|
|
|
|
if (searchReq.getDetectYyyy() != null) {
|
|
|
|
|
whereBuilder.and(mapSheetAnalDataInferenceEntity.targetYyyy.eq(searchReq.getDetectYyyy()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id)
|
|
|
|
|
|
|
|
|
|
whereSubBuilder.and(mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id));
|
|
|
|
|
|
|
|
|
|
if (searchReq.getStrtDttm() != null && ! searchReq.getStrtDttm().isEmpty()) {
|
|
|
|
|
|
|
|
|
|
whereSubBuilder.and(mapSheetAnalDataInferenceGeomEntity.labelStateDttm.isNotNull());
|
|
|
|
|
|
|
|
|
|
whereSubBuilder.and(
|
|
|
|
|
Expressions.stringTemplate("to_char({0}, 'YYYY-MM-DD')", mapSheetAnalDataInferenceEntity.labelStateDttm)
|
|
|
|
|
.gt("2024-01-01")
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<LabelWorkMng> foundContent =
|
|
|
|
|
queryFactory
|
|
|
|
|
.select(
|
|
|
|
|
Projections.constructor(
|
|
|
|
|
LabelWorkMng.class,
|
|
|
|
|
mapSheetAnalDataInferenceEntity.compareYyyy,
|
|
|
|
|
mapSheetAnalDataInferenceEntity.targetYyyy,
|
|
|
|
|
mapSheetAnalDataInferenceEntity.stage,
|
|
|
|
|
mapSheetAnalDataInferenceEntity.createdDttm.min(),
|
|
|
|
|
mapSheetAnalDataInferenceEntity.detectingCnt.sum(),
|
|
|
|
|
mapSheetAnalDataInferenceGeomEntity.dataUid.count(),
|
|
|
|
|
|
|
|
|
|
new CaseBuilder()
|
|
|
|
|
.when(mapSheetAnalDataInferenceGeomEntity.labelState.eq("STOP"))
|
|
|
|
|
.then(1L)
|
|
|
|
|
.otherwise(0L)
|
|
|
|
|
.sum(),
|
|
|
|
|
new CaseBuilder()
|
|
|
|
|
.when(mapSheetAnalDataInferenceGeomEntity.labelState.eq("LABEL_ING"))
|
|
|
|
|
.then(1L)
|
|
|
|
|
.otherwise(0L)
|
|
|
|
|
.sum(),
|
|
|
|
|
new CaseBuilder()
|
|
|
|
|
.when(mapSheetAnalDataInferenceGeomEntity.labelState.eq("LABEL_COMPLETE"))
|
|
|
|
|
.then(1L)
|
|
|
|
|
.otherwise(0L)
|
|
|
|
|
.sum(),
|
|
|
|
|
|
|
|
|
|
mapSheetAnalDataInferenceGeomEntity.labelStateDttm.min()
|
|
|
|
|
))
|
|
|
|
|
.from(mapSheetAnalDataInferenceEntity)
|
|
|
|
|
.leftJoin(mapSheetAnalDataInferenceGeomEntity)
|
|
|
|
|
.on(whereSubBuilder)
|
|
|
|
|
.where(whereBuilder)
|
|
|
|
|
.groupBy(
|
|
|
|
|
mapSheetAnalDataInferenceEntity.compareYyyy,
|
|
|
|
|
mapSheetAnalDataInferenceEntity.targetYyyy,
|
|
|
|
|
mapSheetAnalDataInferenceEntity.stage
|
|
|
|
|
)
|
|
|
|
|
.orderBy(mapSheetAnalDataInferenceEntity.targetYyyy.desc()
|
|
|
|
|
,mapSheetAnalDataInferenceEntity.stage.desc())
|
|
|
|
|
.offset(pageable.getOffset())
|
|
|
|
|
.limit(pageable.getPageSize())
|
|
|
|
|
.fetch();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Long countQuery =
|
|
|
|
|
queryFactory
|
|
|
|
|
.select(mapSheetAnalDataInferenceEntity.count())
|
|
|
|
|
.from(mapSheetAnalDataInferenceEntity)
|
|
|
|
|
.leftJoin(mapSheetAnalDataInferenceGeomEntity)
|
|
|
|
|
.on(whereSubBuilder)
|
|
|
|
|
.where(whereBuilder)
|
|
|
|
|
.groupBy(
|
|
|
|
|
mapSheetAnalDataInferenceEntity.compareYyyy,
|
|
|
|
|
mapSheetAnalDataInferenceEntity.targetYyyy,
|
|
|
|
|
mapSheetAnalDataInferenceEntity.stage
|
|
|
|
|
)
|
|
|
|
|
.fetchOne();
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
Long countQuery = foundContent.stream().count();
|
|
|
|
|
|
|
|
|
|
return new PageImpl<>(foundContent, pageable, countQuery);
|
|
|
|
|
}
|
|
|
|
|
}
|