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

View File

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

View File

@@ -20,15 +20,18 @@ public class LabelAllocateCoreService {
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);
}
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);
}
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()
.map(LabelingAssignmentEntity::toDto)
.toList();
@@ -69,7 +72,8 @@ public class LabelAllocateCoreService {
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);
}
@@ -77,15 +81,18 @@ public class LabelAllocateCoreService {
return labelAllocateRepository.findLabelUnCompleteCnt(analUid);
}
public List<Long> fetchNextMoveIds(Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateRepository.fetchNextMoveIds(lastId, batchSize, compareYyyy, targetYyyy, stage);
public List<Long> fetchNextMoveIds(
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) {
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);
}
}

View File

@@ -12,11 +12,14 @@ import java.util.UUID;
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);
@@ -38,11 +41,13 @@ public interface LabelAllocateRepositoryCustom {
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);
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;
@PersistenceContext
private EntityManager em;
@PersistenceContext private EntityManager em;
@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
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
@@ -67,16 +67,17 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
}
@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로 분석 정보 조회
MapSheetAnalDataInferenceEntity analEntity =
queryFactory
.selectFrom(mapSheetAnalDataInferenceEntity)
.where(mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
.where(
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceEntity.stage.eq(stage)
)
mapSheetAnalDataInferenceEntity.stage.eq(stage))
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
.limit(1)
.fetchOne();
@@ -120,15 +121,16 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
}
@Override
public List<LabelingAssignmentEntity> findAssignedLabelerList(Integer compareYyyy, Integer targetYyyy, Integer stage) {
public List<LabelingAssignmentEntity> findAssignedLabelerList(
Integer compareYyyy, Integer targetYyyy, Integer stage) {
// analUid로 분석 정보 조회
MapSheetAnalDataInferenceEntity analEntity =
queryFactory
.selectFrom(mapSheetAnalDataInferenceEntity)
.where(mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
.where(
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceEntity.stage.eq(stage)
)
mapSheetAnalDataInferenceEntity.stage.eq(stage))
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
.limit(1)
.fetchOne();
@@ -428,15 +430,16 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
}
@Override
public InferenceDetail findInferenceDetail(Integer compareYyyy, Integer targetYyyy, Integer stage) {
public InferenceDetail findInferenceDetail(
Integer compareYyyy, Integer targetYyyy, Integer stage) {
// analUid로 분석 정보 조회
MapSheetAnalDataInferenceEntity analEntity =
queryFactory
.selectFrom(mapSheetAnalDataInferenceEntity)
.where(mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
.where(
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceEntity.stage.eq(stage)
)
mapSheetAnalDataInferenceEntity.stage.eq(stage))
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
.limit(1)
.fetchOne();
@@ -463,7 +466,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
}
@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
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
@@ -518,7 +522,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
}
@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 =
new CaseBuilder()
.when(labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()))
@@ -555,10 +560,10 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
MapSheetAnalDataInferenceEntity analEntity =
queryFactory
.selectFrom(mapSheetAnalDataInferenceEntity)
.where(mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
.where(
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceEntity.stage.eq(stage)
)
mapSheetAnalDataInferenceEntity.stage.eq(stage))
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
.limit(1)
.fetchOne();

View File

@@ -1,23 +1,11 @@
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;
@@ -25,16 +13,9 @@ 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;
@@ -58,7 +39,6 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
this.queryFactory = queryFactory;
}
@Override
public Page<LabelWorkMng> labelWorkMngList(LabelWorkDto.LabelWorkMngSearchReq searchReq) {
@@ -74,23 +54,24 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
// mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id)
whereSubBuilder.and(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()) {
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())
);
Expressions.stringTemplate(
"to_char({0}, 'YYYYMMDD')", mapSheetAnalDataInferenceGeomEntity.labelStateDttm)
.between(searchReq.getStrtDttm(), searchReq.getEndDttm()));
// whereBuilder.and(mapSheetAnalDataInferenceGeomEntity.labelStateDttm.min().isNotNull());
}
List<LabelWorkMng> foundContent =
queryFactory
.select(
@@ -102,7 +83,6 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
mapSheetAnalDataInferenceEntity.createdDttm.min(),
mapSheetAnalDataInferenceGeomEntity.dataUid.count(),
mapSheetAnalDataInferenceGeomEntity.dataUid.count(),
new CaseBuilder()
.when(mapSheetAnalDataInferenceGeomEntity.labelState.eq("STOP"))
.then(1L)
@@ -118,9 +98,7 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
.then(1L)
.otherwise(0L)
.sum(),
mapSheetAnalDataInferenceGeomEntity.labelStateDttm.min()
))
mapSheetAnalDataInferenceGeomEntity.labelStateDttm.min()))
.from(mapSheetAnalDataInferenceEntity)
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
.on(whereSubBuilder)
@@ -128,10 +106,10 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
.groupBy(
mapSheetAnalDataInferenceEntity.compareYyyy,
mapSheetAnalDataInferenceEntity.targetYyyy,
mapSheetAnalDataInferenceEntity.stage
)
.orderBy(mapSheetAnalDataInferenceEntity.targetYyyy.desc()
,mapSheetAnalDataInferenceEntity.stage.desc())
mapSheetAnalDataInferenceEntity.stage)
.orderBy(
mapSheetAnalDataInferenceEntity.targetYyyy.desc(),
mapSheetAnalDataInferenceEntity.stage.desc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();