This commit is contained in:
2026-01-02 22:18:09 +09:00
parent a7b04d0be8
commit dc2b9286f4
7 changed files with 595 additions and 581 deletions

View File

@@ -163,8 +163,7 @@ public class LabelAllocateApiController {
dto.getLabelers(), dto.getLabelers(),
dto.getInspectors(), dto.getInspectors(),
dto.getCompareYyyy(), dto.getCompareYyyy(),
dto.getTargetYyyy() dto.getTargetYyyy());
);
return ApiResponseDto.ok(null); return ApiResponseDto.ok(null);
} }
@@ -178,21 +177,26 @@ public class LabelAllocateApiController {
}) })
@GetMapping("/stage-detail") @GetMapping("/stage-detail")
public ApiResponseDto<InferenceDetail> findInferenceDetail( public ApiResponseDto<InferenceDetail> findInferenceDetail(
@Parameter(description = "비교년도", required = true, example = "2022") @RequestParam Integer compareYyyy, @Parameter(description = "비교년도", required = true, example = "2022") @RequestParam
@Parameter(description = "기준년도", required = true, example = "2024") @RequestParam Integer targetYyyy, Integer compareYyyy,
@Parameter(description = "회차", required = true, example = "4") @RequestParam Integer stage @Parameter(description = "기준년도", required = true, example = "2024") @RequestParam
) { Integer targetYyyy,
return ApiResponseDto.ok(labelAllocateService.findInferenceDetail(compareYyyy, targetYyyy, stage)); @Parameter(description = "회차", required = true, example = "4") @RequestParam Integer stage) {
return ApiResponseDto.ok(
labelAllocateService.findInferenceDetail(compareYyyy, targetYyyy, stage));
} }
@Operation(summary = "작업이관 > 라벨러 상세 정보", description = "작업이관 > 라벨러 상세 정보") @Operation(summary = "작업이관 > 라벨러 상세 정보", description = "작업이관 > 라벨러 상세 정보")
@GetMapping("/labeler-detail") @GetMapping("/labeler-detail")
public ApiResponseDto<LabelerDetail> findLabelerDetail( public ApiResponseDto<LabelerDetail> findLabelerDetail(
@RequestParam(defaultValue = "01022223333") String userId, @RequestParam(defaultValue = "01022223333") String userId,
@Parameter(description = "비교년도", required = true, example = "2022") @RequestParam Integer compareYyyy, @Parameter(description = "비교년도", required = true, example = "2022") @RequestParam
@Parameter(description = "기준년도", required = true, example = "2024") @RequestParam Integer targetYyyy, Integer compareYyyy,
@Parameter(description = "기준년도", required = true, example = "2024") @RequestParam
Integer targetYyyy,
@Parameter(description = "회차", required = true, example = "4") @RequestParam Integer stage) { @Parameter(description = "회차", required = true, example = "4") @RequestParam Integer stage) {
return ApiResponseDto.ok(labelAllocateService.findLabelerDetail(userId, compareYyyy, targetYyyy, stage)); return ApiResponseDto.ok(
labelAllocateService.findLabelerDetail(userId, compareYyyy, targetYyyy, stage));
} }
@Operation(summary = "작업 이관", description = "작업 이관") @Operation(summary = "작업 이관", description = "작업 이관")
@@ -243,7 +247,12 @@ public class LabelAllocateApiController {
@RequestBody @RequestBody
LabelAllocateDto.AllocateMoveDto dto) { LabelAllocateDto.AllocateMoveDto dto) {
labelAllocateService.allocateMove(dto.getAutoType(), dto.getStage(), dto.getLabelers(), dto.getCompareYyyy(), dto.getTargetYyyy()); labelAllocateService.allocateMove(
dto.getAutoType(),
dto.getStage(),
dto.getLabelers(),
dto.getCompareYyyy(),
dto.getTargetYyyy());
return ApiResponseDto.ok(null); return ApiResponseDto.ok(null);
} }

View File

@@ -46,12 +46,12 @@ public class LabelAllocateService {
List<TargetUser> targetUsers, List<TargetUser> targetUsers,
List<TargetInspector> targetInspectors, List<TargetInspector> targetInspectors,
Integer compareYyyy, Integer compareYyyy,
Integer targetYyyy Integer targetYyyy) {
) {
Long lastId = null; Long lastId = null;
// geom 잔여건수 조회 // geom 잔여건수 조회
Long chargeCnt = labelAllocateCoreService.findLabelUnAssignedCnt(stage, compareYyyy, targetYyyy); Long chargeCnt =
labelAllocateCoreService.findLabelUnAssignedCnt(stage, compareYyyy, targetYyyy);
// Long totalDemand = targetUsers.stream().mapToLong(TargetUser::getDemand).sum(); // Long totalDemand = targetUsers.stream().mapToLong(TargetUser::getDemand).sum();
// if (!Objects.equals(chargeCnt, totalDemand)) { // if (!Objects.equals(chargeCnt, totalDemand)) {
// log.info("chargeCnt != totalDemand"); // log.info("chargeCnt != totalDemand");
@@ -62,7 +62,8 @@ public class LabelAllocateService {
return; return;
} }
List<Long> allIds = labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage); List<Long> allIds =
labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage);
int index = 0; int index = 0;
for (TargetUser target : targetUsers) { for (TargetUser target : targetUsers) {
int end = index + target.getDemand(); int end = index + target.getDemand();
@@ -73,7 +74,8 @@ public class LabelAllocateService {
} }
// 검수자에게 userCount명 만큼 할당 // 검수자에게 userCount명 만큼 할당
List<LabelAllocateDto.Basic> list = labelAllocateCoreService.findAssignedLabelerList(compareYyyy, targetYyyy, stage); List<LabelAllocateDto.Basic> list =
labelAllocateCoreService.findAssignedLabelerList(compareYyyy, targetYyyy, stage);
int from = 0; int from = 0;
for (TargetInspector inspector : targetInspectors) { for (TargetInspector inspector : targetInspectors) {
@@ -155,11 +157,16 @@ public class LabelAllocateService {
return WorkerListResponse.builder().progressInfo(progressInfo).workers(workers).build(); return WorkerListResponse.builder().progressInfo(progressInfo).workers(workers).build();
} }
public InferenceDetail findInferenceDetail(Integer compareYyyy, Integer targetYyyy, Integer stage) { public InferenceDetail findInferenceDetail(
Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateCoreService.findInferenceDetail(compareYyyy, targetYyyy, stage); return labelAllocateCoreService.findInferenceDetail(compareYyyy, targetYyyy, stage);
} }
public void allocateMove(String autoType, Integer stage, List<TargetUser> targetUsers, Integer compareYyyy, public void allocateMove(
String autoType,
Integer stage,
List<TargetUser> targetUsers,
Integer compareYyyy,
Integer targetYyyy) { Integer targetYyyy) {
Long lastId = null; Long lastId = null;
@@ -169,7 +176,9 @@ public class LabelAllocateService {
return; return;
} }
List<Long> allIds = labelAllocateCoreService.fetchNextMoveIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage); List<Long> allIds =
labelAllocateCoreService.fetchNextMoveIds(
lastId, chargeCnt, compareYyyy, targetYyyy, stage);
int index = 0; int index = 0;
for (TargetUser target : targetUsers) { for (TargetUser target : targetUsers) {
int end = index + target.getDemand(); int end = index + target.getDemand();
@@ -180,7 +189,8 @@ public class LabelAllocateService {
} }
} }
public LabelerDetail findLabelerDetail(String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) { public LabelerDetail findLabelerDetail(
String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateCoreService.findLabelerDetail(userId, compareYyyy, targetYyyy, stage); return labelAllocateCoreService.findLabelerDetail(userId, compareYyyy, targetYyyy, stage);
} }
} }

View File

@@ -20,15 +20,18 @@ public class LabelAllocateCoreService {
private final LabelAllocateRepository labelAllocateRepository; private final LabelAllocateRepository labelAllocateRepository;
public List<Long> fetchNextIds(Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) { public List<Long> fetchNextIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateRepository.fetchNextIds(lastId, batchSize, compareYyyy, targetYyyy, stage); return labelAllocateRepository.fetchNextIds(lastId, batchSize, compareYyyy, targetYyyy, stage);
} }
public void assignOwner(List<Long> ids, String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) { public void assignOwner(
List<Long> ids, String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) {
labelAllocateRepository.assignOwner(ids, userId, compareYyyy, targetYyyy, stage); labelAllocateRepository.assignOwner(ids, userId, compareYyyy, targetYyyy, stage);
} }
public List<LabelAllocateDto.Basic> findAssignedLabelerList(Integer compareYyyy, Integer targetYyyy, Integer stage) { public List<LabelAllocateDto.Basic> findAssignedLabelerList(
Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateRepository.findAssignedLabelerList(compareYyyy, targetYyyy, stage).stream() return labelAllocateRepository.findAssignedLabelerList(compareYyyy, targetYyyy, stage).stream()
.map(LabelingAssignmentEntity::toDto) .map(LabelingAssignmentEntity::toDto)
.toList(); .toList();
@@ -69,7 +72,8 @@ public class LabelAllocateCoreService {
labelAllocateRepository.assignInspectorBulk(assignmentUids, inspectorUid); labelAllocateRepository.assignInspectorBulk(assignmentUids, inspectorUid);
} }
public InferenceDetail findInferenceDetail(Integer compareYyyy, Integer targetYyyy, Integer stage) { public InferenceDetail findInferenceDetail(
Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateRepository.findInferenceDetail(compareYyyy, targetYyyy, stage); return labelAllocateRepository.findInferenceDetail(compareYyyy, targetYyyy, stage);
} }
@@ -77,15 +81,18 @@ public class LabelAllocateCoreService {
return labelAllocateRepository.findLabelUnCompleteCnt(analUid); return labelAllocateRepository.findLabelUnCompleteCnt(analUid);
} }
public List<Long> fetchNextMoveIds(Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) { public List<Long> fetchNextMoveIds(
return labelAllocateRepository.fetchNextMoveIds(lastId, batchSize, compareYyyy, targetYyyy, stage); Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateRepository.fetchNextMoveIds(
lastId, batchSize, compareYyyy, targetYyyy, stage);
} }
public void assignOwnerMove(List<Long> sub, String userId) { public void assignOwnerMove(List<Long> sub, String userId) {
labelAllocateRepository.assignOwnerMove(sub, userId); labelAllocateRepository.assignOwnerMove(sub, userId);
} }
public LabelerDetail findLabelerDetail(String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) { public LabelerDetail findLabelerDetail(
String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateRepository.findLabelerDetail(userId, compareYyyy, targetYyyy, stage); return labelAllocateRepository.findLabelerDetail(userId, compareYyyy, targetYyyy, stage);
} }
} }

View File

@@ -12,11 +12,14 @@ import java.util.UUID;
public interface LabelAllocateRepositoryCustom { public interface LabelAllocateRepositoryCustom {
List<Long> fetchNextIds(Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage); List<Long> fetchNextIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage);
void assignOwner(List<Long> ids, String userId, Integer compareYyyy, Integer targetYyyy, Integer stage); void assignOwner(
List<Long> ids, String userId, Integer compareYyyy, Integer targetYyyy, Integer stage);
List<LabelingAssignmentEntity> findAssignedLabelerList(Integer compareYyyy, Integer targetYyyy, Integer stage); List<LabelingAssignmentEntity> findAssignedLabelerList(
Integer compareYyyy, Integer targetYyyy, Integer stage);
Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy); Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy);
@@ -38,11 +41,13 @@ public interface LabelAllocateRepositoryCustom {
InferenceDetail findInferenceDetail(Integer compareYyyy, Integer targetYyyy, Integer stage); InferenceDetail findInferenceDetail(Integer compareYyyy, Integer targetYyyy, Integer stage);
public List<Long> fetchNextMoveIds(Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage); public List<Long> fetchNextMoveIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage);
Long findLabelUnCompleteCnt(Long analUid); Long findLabelUnCompleteCnt(Long analUid);
void assignOwnerMove(List<Long> sub, String userId); void assignOwnerMove(List<Long> sub, String userId);
LabelerDetail findLabelerDetail(String userId, Integer compareYyyy, Integer targetYyyy, Integer stage); LabelerDetail findLabelerDetail(
String userId, Integer compareYyyy, Integer targetYyyy, Integer stage);
} }

View File

@@ -46,11 +46,11 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
private final JPAQueryFactory queryFactory; private final JPAQueryFactory queryFactory;
@PersistenceContext @PersistenceContext private EntityManager em;
private EntityManager em;
@Override @Override
public List<Long> fetchNextIds(Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) { public List<Long> fetchNextIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
return queryFactory return queryFactory
.select(mapSheetAnalDataInferenceGeomEntity.geoUid) .select(mapSheetAnalDataInferenceGeomEntity.geoUid)
@@ -67,16 +67,17 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
} }
@Override @Override
public void assignOwner(List<Long> ids, String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) { public void assignOwner(
List<Long> ids, String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) {
// analUid로 분석 정보 조회 // analUid로 분석 정보 조회
MapSheetAnalDataInferenceEntity analEntity = MapSheetAnalDataInferenceEntity analEntity =
queryFactory queryFactory
.selectFrom(mapSheetAnalDataInferenceEntity) .selectFrom(mapSheetAnalDataInferenceEntity)
.where(mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy), .where(
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy), mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceEntity.stage.eq(stage) mapSheetAnalDataInferenceEntity.stage.eq(stage))
)
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc()) .orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
.limit(1) .limit(1)
.fetchOne(); .fetchOne();
@@ -120,15 +121,16 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
} }
@Override @Override
public List<LabelingAssignmentEntity> findAssignedLabelerList(Integer compareYyyy, Integer targetYyyy, Integer stage) { public List<LabelingAssignmentEntity> findAssignedLabelerList(
Integer compareYyyy, Integer targetYyyy, Integer stage) {
// analUid로 분석 정보 조회 // analUid로 분석 정보 조회
MapSheetAnalDataInferenceEntity analEntity = MapSheetAnalDataInferenceEntity analEntity =
queryFactory queryFactory
.selectFrom(mapSheetAnalDataInferenceEntity) .selectFrom(mapSheetAnalDataInferenceEntity)
.where(mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy), .where(
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy), mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceEntity.stage.eq(stage) mapSheetAnalDataInferenceEntity.stage.eq(stage))
)
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc()) .orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
.limit(1) .limit(1)
.fetchOne(); .fetchOne();
@@ -428,15 +430,16 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
} }
@Override @Override
public InferenceDetail findInferenceDetail(Integer compareYyyy, Integer targetYyyy, Integer stage) { public InferenceDetail findInferenceDetail(
Integer compareYyyy, Integer targetYyyy, Integer stage) {
// analUid로 분석 정보 조회 // analUid로 분석 정보 조회
MapSheetAnalDataInferenceEntity analEntity = MapSheetAnalDataInferenceEntity analEntity =
queryFactory queryFactory
.selectFrom(mapSheetAnalDataInferenceEntity) .selectFrom(mapSheetAnalDataInferenceEntity)
.where(mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy), .where(
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy), mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceEntity.stage.eq(stage) mapSheetAnalDataInferenceEntity.stage.eq(stage))
)
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc()) .orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
.limit(1) .limit(1)
.fetchOne(); .fetchOne();
@@ -463,7 +466,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
} }
@Override @Override
public List<Long> fetchNextMoveIds(Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) { public List<Long> fetchNextMoveIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
return queryFactory return queryFactory
.select(mapSheetAnalDataInferenceGeomEntity.geoUid) .select(mapSheetAnalDataInferenceGeomEntity.geoUid)
@@ -518,7 +522,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
} }
@Override @Override
public LabelerDetail findLabelerDetail(String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) { public LabelerDetail findLabelerDetail(
String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) {
NumberExpression<Long> assignedCnt = NumberExpression<Long> assignedCnt =
new CaseBuilder() new CaseBuilder()
.when(labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId())) .when(labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()))
@@ -555,10 +560,10 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
MapSheetAnalDataInferenceEntity analEntity = MapSheetAnalDataInferenceEntity analEntity =
queryFactory queryFactory
.selectFrom(mapSheetAnalDataInferenceEntity) .selectFrom(mapSheetAnalDataInferenceEntity)
.where(mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy), .where(
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy), mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceEntity.stage.eq(stage) mapSheetAnalDataInferenceEntity.stage.eq(stage))
)
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc()) .orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
.limit(1) .limit(1)
.fetchOne(); .fetchOne();

View File

@@ -1,23 +1,11 @@
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.QMapInkx5kEntity.mapInkx5kEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceEntity.mapSheetAnalDataInferenceEntity; 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.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;
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMng; 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.MapSheetAnalDataGeomEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalEntity;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Projections; import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.CaseBuilder; import com.querydsl.core.types.dsl.CaseBuilder;
@@ -25,16 +13,9 @@ import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.StringExpression; import com.querydsl.core.types.dsl.StringExpression;
import com.querydsl.jpa.impl.JPAQueryFactory; import com.querydsl.jpa.impl.JPAQueryFactory;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityNotFoundException;
import jakarta.persistence.PersistenceContext; 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.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
@@ -58,7 +39,6 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
} }
@Override @Override
public Page<LabelWorkMng> labelWorkMngList(LabelWorkDto.LabelWorkMngSearchReq searchReq) { public Page<LabelWorkMng> labelWorkMngList(LabelWorkDto.LabelWorkMngSearchReq searchReq) {
@@ -72,25 +52,26 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
whereBuilder.and(mapSheetAnalDataInferenceEntity.targetYyyy.eq(searchReq.getDetectYyyy())); whereBuilder.and(mapSheetAnalDataInferenceEntity.targetYyyy.eq(searchReq.getDetectYyyy()));
} }
//mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id) // mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id)
whereSubBuilder.and(mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id));
if (searchReq.getStrtDttm() != null && ! searchReq.getStrtDttm().isEmpty()
&& searchReq.getEndDttm() != null && ! searchReq.getEndDttm().isEmpty()) {
//whereSubBuilder.and(mapSheetAnalDataInferenceGeomEntity.labelStateDttm.isNotNull());
whereSubBuilder.and( whereSubBuilder.and(
Expressions.stringTemplate("to_char({0}, 'YYYYMMDD')", mapSheetAnalDataInferenceGeomEntity.labelStateDttm) mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id));
.between(searchReq.getStrtDttm(), searchReq.getEndDttm())
);
//whereBuilder.and(mapSheetAnalDataInferenceGeomEntity.labelStateDttm.min().isNotNull()); if (searchReq.getStrtDttm() != null
&& !searchReq.getStrtDttm().isEmpty()
&& searchReq.getEndDttm() != null
&& !searchReq.getEndDttm().isEmpty()) {
// whereSubBuilder.and(mapSheetAnalDataInferenceGeomEntity.labelStateDttm.isNotNull());
whereSubBuilder.and(
Expressions.stringTemplate(
"to_char({0}, 'YYYYMMDD')", mapSheetAnalDataInferenceGeomEntity.labelStateDttm)
.between(searchReq.getStrtDttm(), searchReq.getEndDttm()));
// whereBuilder.and(mapSheetAnalDataInferenceGeomEntity.labelStateDttm.min().isNotNull());
} }
List<LabelWorkMng> foundContent = List<LabelWorkMng> foundContent =
queryFactory queryFactory
.select( .select(
@@ -102,7 +83,6 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
mapSheetAnalDataInferenceEntity.createdDttm.min(), mapSheetAnalDataInferenceEntity.createdDttm.min(),
mapSheetAnalDataInferenceGeomEntity.dataUid.count(), mapSheetAnalDataInferenceGeomEntity.dataUid.count(),
mapSheetAnalDataInferenceGeomEntity.dataUid.count(), mapSheetAnalDataInferenceGeomEntity.dataUid.count(),
new CaseBuilder() new CaseBuilder()
.when(mapSheetAnalDataInferenceGeomEntity.labelState.eq("STOP")) .when(mapSheetAnalDataInferenceGeomEntity.labelState.eq("STOP"))
.then(1L) .then(1L)
@@ -118,9 +98,7 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
.then(1L) .then(1L)
.otherwise(0L) .otherwise(0L)
.sum(), .sum(),
mapSheetAnalDataInferenceGeomEntity.labelStateDttm.min()))
mapSheetAnalDataInferenceGeomEntity.labelStateDttm.min()
))
.from(mapSheetAnalDataInferenceEntity) .from(mapSheetAnalDataInferenceEntity)
.innerJoin(mapSheetAnalDataInferenceGeomEntity) .innerJoin(mapSheetAnalDataInferenceGeomEntity)
.on(whereSubBuilder) .on(whereSubBuilder)
@@ -128,10 +106,10 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
.groupBy( .groupBy(
mapSheetAnalDataInferenceEntity.compareYyyy, mapSheetAnalDataInferenceEntity.compareYyyy,
mapSheetAnalDataInferenceEntity.targetYyyy, mapSheetAnalDataInferenceEntity.targetYyyy,
mapSheetAnalDataInferenceEntity.stage mapSheetAnalDataInferenceEntity.stage)
) .orderBy(
.orderBy(mapSheetAnalDataInferenceEntity.targetYyyy.desc() mapSheetAnalDataInferenceEntity.targetYyyy.desc(),
,mapSheetAnalDataInferenceEntity.stage.desc()) mapSheetAnalDataInferenceEntity.stage.desc())
.offset(pageable.getOffset()) .offset(pageable.getOffset())
.limit(pageable.getPageSize()) .limit(pageable.getPageSize())
.fetch(); .fetch();