작업현황관리 리스트 API분리
This commit is contained in:
@@ -2,6 +2,8 @@ package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
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.WorkerState;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.label.LabelWorkRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -16,4 +18,9 @@ public class LabelWorkCoreService {
|
||||
public Page<LabelWorkMng> labelWorkMngList(LabelWorkDto.LabelWorkMngSearchReq searchReq) {
|
||||
return labelWorkRepository.labelWorkMngList(searchReq);
|
||||
}
|
||||
|
||||
public Page<WorkerState> findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq)
|
||||
{
|
||||
return labelWorkRepository.findlabelWorkStateList(searchReq);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,9 +2,14 @@ package com.kamco.cd.kamcoback.postgres.repository.label;
|
||||
|
||||
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.WorkerState;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
public interface LabelWorkRepositoryCustom {
|
||||
|
||||
public Page<LabelWorkMng> labelWorkMngList(LabelWorkDto.LabelWorkMngSearchReq searchReq);
|
||||
|
||||
Page<WorkerState> findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
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.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.LabelWorkDto;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMng;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.WorkerState;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataGeomEntity;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
import com.querydsl.core.types.Projections;
|
||||
@@ -14,6 +22,7 @@ import com.querydsl.core.types.dsl.StringExpression;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -135,4 +144,120 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
|
||||
|
||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Page<WorkerState> findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq){
|
||||
Pageable pageable = PageRequest.of(searchReq.getPage(), searchReq.getSize());
|
||||
BooleanBuilder whereBuilder = new BooleanBuilder();
|
||||
BooleanBuilder whereSubBuilder = new BooleanBuilder();
|
||||
|
||||
LocalDate threeDaysAgo = LocalDate.now().minusDays(3);
|
||||
String s3 = threeDaysAgo.format(DateTimeFormatter.ofPattern("YYYY-MM-DD"));
|
||||
|
||||
LocalDate twoDaysAgo = LocalDate.now().minusDays(2);
|
||||
String s2 = twoDaysAgo.format(DateTimeFormatter.ofPattern("YYYY-MM-DD"));
|
||||
|
||||
LocalDate oneDaysAgo = LocalDate.now().minusDays(1);
|
||||
String s1 = oneDaysAgo.format(DateTimeFormatter.ofPattern("YYYY-MM-DD"));
|
||||
|
||||
if (searchReq.getUserRole() != null && ! searchReq.getUserRole().isEmpty()) {
|
||||
whereSubBuilder.and(memberEntity.userRole.eq(searchReq.getUserRole()));
|
||||
}
|
||||
|
||||
if (searchReq.getSearchVal() != null && ! searchReq.getSearchVal().isEmpty()) {
|
||||
whereSubBuilder.and(
|
||||
Expressions.stringTemplate(
|
||||
"{0}",memberEntity.userId)
|
||||
.likeIgnoreCase("%" + searchReq.getSearchVal() + "%")
|
||||
.or(
|
||||
Expressions.stringTemplate(
|
||||
"{0}",memberEntity.name)
|
||||
.likeIgnoreCase("%" + searchReq.getSearchVal() + "%")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
whereSubBuilder.and(
|
||||
labelingAssignmentEntity.workerUid.eq(memberEntity.userId));
|
||||
|
||||
List<WorkerState> foundContent =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
WorkerState.class,
|
||||
memberEntity.userRole,
|
||||
memberEntity.name,
|
||||
memberEntity.userId,
|
||||
labelingAssignmentEntity.workerUid.count().as("assignedCnt"),
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq("DONE"))
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum()
|
||||
.as("doneCnt"),
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq("SKIP"))
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum()
|
||||
.as("skipCnt"),
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq("DONE")
|
||||
.and(
|
||||
Expressions.stringTemplate(
|
||||
"to_char({0}, 'YYYY-MM-DD')", labelingAssignmentEntity.modifiedDate).eq(s3) )
|
||||
)
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum()
|
||||
.as("day3AgoDoneCnt"),
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq("DONE")
|
||||
.and(
|
||||
Expressions.stringTemplate(
|
||||
"to_char({0}, 'YYYY-MM-DD')", labelingAssignmentEntity.modifiedDate).eq(s2) )
|
||||
)
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum()
|
||||
.as("day2AgoDoneCnt"),
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq("DONE")
|
||||
.and(
|
||||
Expressions.stringTemplate(
|
||||
"to_char({0}, 'YYYY-MM-DD')", labelingAssignmentEntity.modifiedDate).eq(s1) )
|
||||
)
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum()
|
||||
.as("day1AgoDoneCnt")
|
||||
))
|
||||
.from(labelingAssignmentEntity)
|
||||
.innerJoin(memberEntity)
|
||||
.on(whereSubBuilder)
|
||||
.where(whereBuilder)
|
||||
.groupBy(
|
||||
memberEntity.userRole,
|
||||
memberEntity.name,
|
||||
memberEntity.userId)
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
.fetch();
|
||||
|
||||
/*
|
||||
Long countQuery =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.workerUid.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(whereBuilder)
|
||||
.fetchOne();
|
||||
*/
|
||||
|
||||
Long countQuery = foundContent.stream().count();
|
||||
|
||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user