라벨할당 검수자 insert 로직 수정

This commit is contained in:
2026-01-05 11:46:21 +09:00
parent 88cf9a4487
commit b4ae6e148d
8 changed files with 190 additions and 184 deletions

View File

@@ -122,8 +122,6 @@ public class LabelAllocateApiController {
return ApiResponseDto.okObject( return ApiResponseDto.okObject(
labelAllocateService.allocateAsc( labelAllocateService.allocateAsc(
dto.getLabelerAutoType(),
dto.getInspectorAutoType(),
dto.getStage(), dto.getStage(),
dto.getLabelers(), dto.getLabelers(),
dto.getInspectors(), dto.getInspectors(),
@@ -140,13 +138,13 @@ public class LabelAllocateApiController {
}) })
@GetMapping("/stage-detail") @GetMapping("/stage-detail")
public ApiResponseDto<InferenceDetail> findInferenceDetail( public ApiResponseDto<InferenceDetail> findInferenceDetail(
@Parameter(description = "비교년도", required = true, example = "2022") @RequestParam @Parameter(
Integer compareYyyy, description = "회차 마스터 key",
@Parameter(description = "기준년도", required = true, example = "2024") @RequestParam required = true,
Integer targetYyyy, example = "8584e8d4-53b3-4582-bde2-28a81495a626")
@Parameter(description = "회차", required = true, example = "4") @RequestParam Integer stage) { @RequestParam
return ApiResponseDto.ok( String uuid) {
labelAllocateService.findInferenceDetail(compareYyyy, targetYyyy, stage)); return ApiResponseDto.ok(labelAllocateService.findInferenceDetail(uuid));
} }
@Operation( @Operation(
@@ -154,14 +152,14 @@ public class LabelAllocateApiController {
description = "작업현황 관리 > 라벨러 상세 정보, 작업이관 팝업 내 라벨러 상세 정보 동일") description = "작업현황 관리 > 라벨러 상세 정보, 작업이관 팝업 내 라벨러 상세 정보 동일")
@GetMapping("/labeler-detail") @GetMapping("/labeler-detail")
public ApiResponseDto<LabelerDetail> findLabelerDetail( public ApiResponseDto<LabelerDetail> findLabelerDetail(
@RequestParam(defaultValue = "01022223333") String userId, @RequestParam(defaultValue = "01022223333", required = true) String userId,
@Parameter(description = "비교년도", required = true, example = "2022") @RequestParam @Parameter(
Integer compareYyyy, description = "회차 마스터 key",
@Parameter(description = "기준년도", required = true, example = "2024") @RequestParam required = true,
Integer targetYyyy, example = "8584e8d4-53b3-4582-bde2-28a81495a626")
@Parameter(description = "회차", required = true, example = "4") @RequestParam Integer stage) { @RequestParam
return ApiResponseDto.ok( String uuid) {
labelAllocateService.findLabelerDetail(userId, compareYyyy, targetYyyy, stage)); return ApiResponseDto.ok(labelAllocateService.findLabelerDetail(userId, uuid));
} }
@Operation(summary = "작업현황 관리 > 상세 > 작업 이관", description = "작업현황 관리 > 상세 > 작업 이관") @Operation(summary = "작업현황 관리 > 상세 > 작업 이관", description = "작업현황 관리 > 상세 > 작업 이관")

View File

@@ -87,22 +87,13 @@ public class LabelAllocateDto {
@AllArgsConstructor @AllArgsConstructor
public static class AllocateDto { public static class AllocateDto {
// @Schema(description = "분석 ID", example = "3")
// private Long analUid;
@Schema(description = "비교년도", example = "2022", required = true) @Schema(description = "비교년도", example = "2022", required = true)
private Integer compareYyyy; private Integer compareYyyy;
@Schema(description = "기준년도", example = "2024", required = true) @Schema(description = "기준년도", example = "2024", required = true)
private Integer targetYyyy; private Integer targetYyyy;
@Schema(description = "라벨러 자동/수동여부(AUTO/MANUAL)", example = "AUTO") @Schema(description = "회차", example = "4", required = true)
private String labelerAutoType;
@Schema(description = "검수자 자동/수동여부(AUTO/MANUAL)", example = "AUTO")
private String inspectorAutoType;
@Schema(description = "회차", example = "4")
private Integer stage; private Integer stage;
@Schema( @Schema(
@@ -130,22 +121,12 @@ public class LabelAllocateDto {
description = "검수자 할당 목록", description = "검수자 할당 목록",
example = example =
""" """
[ ["K20251216001",
{ "01022225555",
"inspectorUid": "K20251216001", "K20251212001"
"userCount": 1000
},
{
"inspectorUid": "01022225555",
"userCount": 340
},
{
"inspectorUid": "K20251212001",
"userCount": 500
}
] ]
""") """)
private List<TargetInspector> inspectors; private List<String> inspectors;
} }
@Getter @Getter
@@ -273,6 +254,6 @@ public class LabelAllocateDto {
public static class AllocateInfoDto { public static class AllocateInfoDto {
private Long geoUid; private Long geoUid;
private String mapSheetNum; private Long mapSheetNum;
} }
} }

View File

@@ -0,0 +1,22 @@
package com.kamco.cd.kamcoback.label.dto;
import java.time.ZonedDateTime;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
public class LabelInspectorDto {
@Getter
@Setter
@AllArgsConstructor
public static class Basic {
private UUID operatorUid;
private Long analUid;
private String inspectorUid;
private ZonedDateTime createdDttm;
private ZonedDateTime updatedDttm;
}
}

View File

@@ -6,7 +6,6 @@ import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.AllocateInfoDto; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.AllocateInfoDto;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InferenceDetail; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InferenceDetail;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelerDetail; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelerDetail;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.TargetInspector;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.TargetUser; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.TargetUser;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.DailyHistory; import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.DailyHistory;
@@ -16,7 +15,6 @@ import com.kamco.cd.kamcoback.postgres.core.LabelAllocateCoreService;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -38,19 +36,15 @@ public class LabelAllocateService {
/** /**
* 도엽 기준 asc sorting 해서 할당 수만큼 배정하는 로직 * 도엽 기준 asc sorting 해서 할당 수만큼 배정하는 로직
* *
* @param labelerAutoType 라벨러 자동/수동 배정 타입
* @param inspectorAutoType 검수자 자동/수동 배정 타입
* @param stage 회차 * @param stage 회차
* @param targetUsers 라벨러 목록 * @param targetUsers 라벨러 목록
* @param targetInspectors 검수자 목록 * @param targetInspectors 검수자 목록
*/ */
@Transactional @Transactional
public ApiResponseDto.ResponseObj allocateAsc( public ApiResponseDto.ResponseObj allocateAsc(
String labelerAutoType,
String inspectorAutoType,
Integer stage, Integer stage,
List<TargetUser> targetUsers, List<TargetUser> targetUsers,
List<TargetInspector> targetInspectors, List<String> targetInspectors,
Integer compareYyyy, Integer compareYyyy,
Integer targetYyyy) { Integer targetYyyy) {
Long lastId = null; Long lastId = null;
@@ -70,34 +64,44 @@ public class LabelAllocateService {
List<AllocateInfoDto> allIds = List<AllocateInfoDto> allIds =
labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage); labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage);
// MapSheetAnalInferenceEntity analUid 가져오기
Long analUid =
labelAllocateCoreService.findMapSheetAnalInferenceUid(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();
List<AllocateInfoDto> sub = allIds.subList(index, end); List<AllocateInfoDto> sub = allIds.subList(index, end);
labelAllocateCoreService.assignOwner(sub, target.getUserId(), compareYyyy, targetYyyy, stage); labelAllocateCoreService.assignOwner(sub, target.getUserId(), analUid);
index = end; index = end;
} }
// 검수자에게 userCount명 만큼 할당 // 검수자에게 userCount명 만큼 할당
List<LabelAllocateDto.Basic> list = List<LabelAllocateDto.Basic> list = labelAllocateCoreService.findAssignedLabelerList(analUid);
labelAllocateCoreService.findAssignedLabelerList(compareYyyy, targetYyyy, stage);
int from = 0;
for (TargetInspector inspector : targetInspectors) { for (String inspector : targetInspectors) {
int to = Math.min(from + inspector.getUserCount(), list.size()); labelAllocateCoreService.insertInspector(analUid, inspector);
if (from >= to) {
break;
} }
List<UUID> assignmentUids = // int from = 0;
list.subList(from, to).stream().map(LabelAllocateDto.Basic::getAssignmentUid).toList(); // for (TargetInspector inspector : targetInspectors) {
// int to = Math.min(from + inspector.getUserCount(), list.size());
labelAllocateCoreService.assignInspectorBulk(assignmentUids, inspector.getInspectorUid()); //
// if (from >= to) {
from = to; // break;
} // }
//
// List<UUID> assignmentUids =
// list.subList(from,
// to).stream().map(LabelAllocateDto.Basic::getAssignmentUid).toList();
//
// labelAllocateCoreService.assignInspectorBulk(assignmentUids,
// inspector.getInspectorUid());
//
// from = to;
// }
return new ApiResponseDto.ResponseObj(ApiResponseCode.OK, "배정이 완료되었습니다."); return new ApiResponseDto.ResponseObj(ApiResponseCode.OK, "배정이 완료되었습니다.");
} }
@@ -165,9 +169,8 @@ public class LabelAllocateService {
return WorkerListResponse.builder().progressInfo(progressInfo).workers(workers).build(); return WorkerListResponse.builder().progressInfo(progressInfo).workers(workers).build();
} }
public InferenceDetail findInferenceDetail( public InferenceDetail findInferenceDetail(String uuid) {
Integer compareYyyy, Integer targetYyyy, Integer stage) { return labelAllocateCoreService.findInferenceDetail(uuid);
return labelAllocateCoreService.findInferenceDetail(compareYyyy, targetYyyy, stage);
} }
public ApiResponseDto.ResponseObj allocateMove( public ApiResponseDto.ResponseObj allocateMove(
@@ -199,8 +202,7 @@ public class LabelAllocateService {
return new ApiResponseDto.ResponseObj(ApiResponseCode.OK, "이관을 완료하였습니다."); return new ApiResponseDto.ResponseObj(ApiResponseCode.OK, "이관을 완료하였습니다.");
} }
public LabelerDetail findLabelerDetail( public LabelerDetail findLabelerDetail(String userId, String uuid) {
String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) { return labelAllocateCoreService.findLabelerDetail(userId, uuid);
return labelAllocateCoreService.findLabelerDetail(userId, compareYyyy, targetYyyy, stage);
} }
} }

View File

@@ -26,18 +26,12 @@ public class LabelAllocateCoreService {
return labelAllocateRepository.fetchNextIds(lastId, batchSize, compareYyyy, targetYyyy, stage); return labelAllocateRepository.fetchNextIds(lastId, batchSize, compareYyyy, targetYyyy, stage);
} }
public void assignOwner( public void assignOwner(List<AllocateInfoDto> ids, String userId, Long analUid) {
List<AllocateInfoDto> ids, labelAllocateRepository.assignOwner(ids, userId, analUid);
String userId,
Integer compareYyyy,
Integer targetYyyy,
Integer stage) {
labelAllocateRepository.assignOwner(ids, userId, compareYyyy, targetYyyy, stage);
} }
public List<LabelAllocateDto.Basic> findAssignedLabelerList( public List<LabelAllocateDto.Basic> findAssignedLabelerList(Long analUid) {
Integer compareYyyy, Integer targetYyyy, Integer stage) { return labelAllocateRepository.findAssignedLabelerList(analUid).stream()
return labelAllocateRepository.findAssignedLabelerList(compareYyyy, targetYyyy, stage).stream()
.map(LabelingAssignmentEntity::toDto) .map(LabelingAssignmentEntity::toDto)
.toList(); .toList();
} }
@@ -77,13 +71,8 @@ public class LabelAllocateCoreService {
labelAllocateRepository.assignInspectorBulk(assignmentUids, inspectorUid); labelAllocateRepository.assignInspectorBulk(assignmentUids, inspectorUid);
} }
public InferenceDetail findInferenceDetail( public InferenceDetail findInferenceDetail(String uuid) {
Integer compareYyyy, Integer targetYyyy, Integer stage) { return labelAllocateRepository.findInferenceDetail(uuid);
return labelAllocateRepository.findInferenceDetail(compareYyyy, targetYyyy, stage);
}
public Long findLabelUnCompleteCnt(Long analUid) {
return labelAllocateRepository.findLabelUnCompleteCnt(analUid);
} }
public List<Long> fetchNextMoveIds( public List<Long> fetchNextMoveIds(
@@ -96,8 +85,15 @@ public class LabelAllocateCoreService {
labelAllocateRepository.assignOwnerMove(sub, userId); labelAllocateRepository.assignOwnerMove(sub, userId);
} }
public LabelerDetail findLabelerDetail( public LabelerDetail findLabelerDetail(String userId, String uuid) {
String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) { return labelAllocateRepository.findLabelerDetail(userId, uuid);
return labelAllocateRepository.findLabelerDetail(userId, compareYyyy, targetYyyy, stage); }
public Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateRepository.findMapSheetAnalInferenceUid(compareYyyy, targetYyyy, stage);
}
public void insertInspector(Long analUid, String inspector) {
labelAllocateRepository.insertInspector(analUid, inspector);
} }
} }

View File

@@ -0,0 +1,33 @@
package com.kamco.cd.kamcoback.postgres.entity;
import com.kamco.cd.kamcoback.label.dto.LabelInspectorDto;
import com.kamco.cd.kamcoback.postgres.CommonDateEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.util.UUID;
@Entity
@Table(name = "tb_labeling_inspector")
public class LabelingInspectorEntity extends CommonDateEntity {
@Id
@Column(name = "operator_uid")
private UUID operatorUid;
@Column(name = "anal_uid")
private Long analUid;
@Column(name = "inspector_uid")
private String inspectorUid;
public LabelInspectorDto.Basic toDto() {
return new LabelInspectorDto.Basic(
this.operatorUid,
this.analUid,
this.inspectorUid,
super.getCreatedDate(),
super.getModifiedDate());
}
}

View File

@@ -16,15 +16,9 @@ public interface LabelAllocateRepositoryCustom {
List<AllocateInfoDto> fetchNextIds( List<AllocateInfoDto> fetchNextIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage); Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage);
void assignOwner( void assignOwner(List<AllocateInfoDto> ids, String userId, Long analUid);
List<AllocateInfoDto> ids,
String userId,
Integer compareYyyy,
Integer targetYyyy,
Integer stage);
List<LabelingAssignmentEntity> findAssignedLabelerList( List<LabelingAssignmentEntity> findAssignedLabelerList(Long analUid);
Integer compareYyyy, Integer targetYyyy, Integer stage);
Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy); Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy);
@@ -44,15 +38,16 @@ public interface LabelAllocateRepositoryCustom {
void assignInspectorBulk(List<UUID> assignmentUids, String inspectorUid); void assignInspectorBulk(List<UUID> assignmentUids, String inspectorUid);
InferenceDetail findInferenceDetail(Integer compareYyyy, Integer targetYyyy, Integer stage); InferenceDetail findInferenceDetail(String uuid);
public List<Long> fetchNextMoveIds( List<Long> fetchNextMoveIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage); Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage);
Long findLabelUnCompleteCnt(Long analUid);
void assignOwnerMove(List<Long> sub, String userId); void assignOwnerMove(List<Long> sub, String userId);
LabelerDetail findLabelerDetail( LabelerDetail findLabelerDetail(String userId, String uuid);
String userId, Integer compareYyyy, Integer targetYyyy, Integer stage);
Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage);
void insertInspector(Long analUid, String inspector);
} }

View File

@@ -1,9 +1,10 @@
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.QLabelingAssignmentEntity.labelingAssignmentEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceEntity.mapSheetAnalDataInferenceEntity; import static com.kamco.cd.kamcoback.postgres.entity.QLabelingInspectorEntity.labelingInspectorEntity;
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.QMapSheetAnalEntity.mapSheetAnalEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMemberEntity.memberEntity; import static com.kamco.cd.kamcoback.postgres.entity.QMemberEntity.memberEntity;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto;
@@ -16,8 +17,7 @@ import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo; import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo;
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics; import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity; import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataInferenceEntity; import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalInferenceEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalEntity;
import com.kamco.cd.kamcoback.postgres.entity.QMemberEntity; import com.kamco.cd.kamcoback.postgres.entity.QMemberEntity;
import com.querydsl.core.types.Projections; import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.BooleanExpression;
@@ -73,27 +73,17 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
} }
@Override @Override
public void assignOwner( public void assignOwner(List<AllocateInfoDto> ids, String userId, Long analUid) {
List<AllocateInfoDto> ids,
String userId,
Integer compareYyyy,
Integer targetYyyy,
Integer stage) {
// analUid로 분석 정보 조회 // analUid로 분석 정보 조회
MapSheetAnalDataInferenceEntity analEntity = MapSheetAnalInferenceEntity analEntity =
queryFactory queryFactory
.selectFrom(mapSheetAnalDataInferenceEntity) .selectFrom(mapSheetAnalInferenceEntity)
.where( .where(mapSheetAnalInferenceEntity.id.eq(analUid))
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceEntity.stage.eq(stage))
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
.limit(1)
.fetchOne(); .fetchOne();
if (Objects.isNull(analEntity)) { if (Objects.isNull(analEntity)) {
throw new EntityNotFoundException("MapSheetAnalEntity not found for analUid: "); throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: ");
} }
// data_geom 테이블에 label state 를 ASSIGNED 로 update // data_geom 테이블에 label state 를 ASSIGNED 로 update
@@ -125,7 +115,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
.setParameter(3, userId) .setParameter(3, userId)
.setParameter(4, LabelState.ASSIGNED.getId()) .setParameter(4, LabelState.ASSIGNED.getId())
.setParameter(5, info.getMapSheetNum()) .setParameter(5, info.getMapSheetNum())
.setParameter(6, analEntity.getAnalUid()) .setParameter(6, analEntity.getId())
.executeUpdate(); .executeUpdate();
} }
@@ -134,28 +124,22 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
} }
@Override @Override
public List<LabelingAssignmentEntity> findAssignedLabelerList( public List<LabelingAssignmentEntity> findAssignedLabelerList(Long analUid) {
Integer compareYyyy, Integer targetYyyy, Integer stage) {
// analUid로 분석 정보 조회 // analUid로 분석 정보 조회
MapSheetAnalDataInferenceEntity analEntity = MapSheetAnalInferenceEntity analEntity =
queryFactory queryFactory
.selectFrom(mapSheetAnalDataInferenceEntity) .selectFrom(mapSheetAnalInferenceEntity)
.where( .where(mapSheetAnalInferenceEntity.id.eq(analUid))
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceEntity.stage.eq(stage))
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
.limit(1)
.fetchOne(); .fetchOne();
if (Objects.isNull(analEntity)) { if (Objects.isNull(analEntity)) {
throw new EntityNotFoundException("MapSheetAnalEntity not found for analUid: "); throw new EntityNotFoundException("mapSheetAnalInferenceEntity not found for analUid: ");
} }
return queryFactory return queryFactory
.selectFrom(labelingAssignmentEntity) .selectFrom(labelingAssignmentEntity)
.where( .where(
labelingAssignmentEntity.analUid.eq(analEntity.getAnalUid()), labelingAssignmentEntity.analUid.eq(analEntity.getId()),
labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()), labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()),
labelingAssignmentEntity.inspectorUid.isNull()) labelingAssignmentEntity.inspectorUid.isNull())
.orderBy(labelingAssignmentEntity.workerUid.asc()) .orderBy(labelingAssignmentEntity.workerUid.asc())
@@ -443,20 +427,18 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
} }
@Override @Override
public InferenceDetail findInferenceDetail( public InferenceDetail findInferenceDetail(String uuid) {
Integer compareYyyy, Integer targetYyyy, Integer stage) {
// analUid로 분석 정보 조회 // analUid로 분석 정보 조회
MapSheetAnalDataInferenceEntity analEntity = MapSheetAnalInferenceEntity analEntity =
queryFactory queryFactory
.selectFrom(mapSheetAnalDataInferenceEntity) .selectFrom(mapSheetAnalInferenceEntity)
.where( .where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceEntity.stage.eq(stage))
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
.limit(1)
.fetchOne(); .fetchOne();
if (Objects.isNull(analEntity)) {
throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: ");
}
return queryFactory return queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
@@ -470,7 +452,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
.from(mapSheetAnalEntity) .from(mapSheetAnalEntity)
.innerJoin(labelingAssignmentEntity) .innerJoin(labelingAssignmentEntity)
.on(mapSheetAnalEntity.id.eq(labelingAssignmentEntity.analUid)) .on(mapSheetAnalEntity.id.eq(labelingAssignmentEntity.analUid))
.where(mapSheetAnalEntity.id.eq(analEntity.getAnalUid())) .where(mapSheetAnalEntity.id.eq(analEntity.getId()))
.groupBy( .groupBy(
mapSheetAnalEntity.analTitle, mapSheetAnalEntity.analTitle,
mapSheetAnalEntity.gukyuinApplyDttm, mapSheetAnalEntity.gukyuinApplyDttm,
@@ -498,30 +480,6 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
.fetch(); .fetch();
} }
@Override
public Long findLabelUnCompleteCnt(Long analUid) {
MapSheetAnalEntity entity =
queryFactory
.selectFrom(mapSheetAnalEntity)
.where(mapSheetAnalEntity.id.eq(analUid))
.fetchOne();
if (Objects.isNull(entity)) {
throw new EntityNotFoundException();
}
return queryFactory
.select(mapSheetAnalDataInferenceGeomEntity.geoUid.count())
.from(mapSheetAnalDataInferenceGeomEntity)
.where(
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(entity.getCompareYyyy()),
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(entity.getTargetYyyy()),
mapSheetAnalDataInferenceGeomEntity.stage.eq(4), // TODO: 회차 컬럼을 가져와야 할 듯?
mapSheetAnalDataInferenceGeomEntity.labelState.in(
LabelState.ASSIGNED.getId(), LabelState.SKIP.getId()))
.fetchOne();
}
@Transactional @Transactional
@Override @Override
public void assignOwnerMove(List<Long> sub, String userId) { public void assignOwnerMove(List<Long> sub, String userId) {
@@ -535,8 +493,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
} }
@Override @Override
public LabelerDetail findLabelerDetail( public LabelerDetail findLabelerDetail(String userId, String uuid) {
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()))
@@ -570,19 +527,14 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
completeCnt)); completeCnt));
// analUid로 분석 정보 조회 // analUid로 분석 정보 조회
MapSheetAnalDataInferenceEntity analEntity = MapSheetAnalInferenceEntity analEntity =
queryFactory queryFactory
.selectFrom(mapSheetAnalDataInferenceEntity) .selectFrom(mapSheetAnalInferenceEntity)
.where( .where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceEntity.stage.eq(stage))
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
.limit(1)
.fetchOne(); .fetchOne();
if (Objects.isNull(analEntity)) { if (Objects.isNull(analEntity)) {
throw new EntityNotFoundException("MapSheetAnalEntity not found for analUid: "); throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: ");
} }
QMemberEntity worker = QMemberEntity.memberEntity; QMemberEntity worker = QMemberEntity.memberEntity;
@@ -606,11 +558,38 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
.innerJoin(labelingAssignmentEntity) .innerJoin(labelingAssignmentEntity)
.on( .on(
worker.employeeNo.eq(labelingAssignmentEntity.workerUid), worker.employeeNo.eq(labelingAssignmentEntity.workerUid),
labelingAssignmentEntity.analUid.eq(analEntity.getAnalUid())) labelingAssignmentEntity.analUid.eq(analEntity.getId()))
.leftJoin(inspector) .leftJoin(inspector)
.on(labelingAssignmentEntity.inspectorUid.eq(inspector.employeeNo)) .on(labelingAssignmentEntity.inspectorUid.eq(inspector.employeeNo))
.where(worker.employeeNo.eq(userId)) .where(worker.employeeNo.eq(userId))
.groupBy(worker.userRole, worker.name, worker.employeeNo) .groupBy(worker.userRole, worker.name, worker.employeeNo)
.fetchOne(); .fetchOne();
} }
@Override
public Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage) {
return queryFactory
.select(mapSheetAnalInferenceEntity.id)
.from(mapSheetAnalInferenceEntity)
.where(
mapSheetAnalInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalInferenceEntity.stage.eq(stage))
.fetchOne();
}
@Override
public void insertInspector(Long analUid, String inspector) {
queryFactory
.insert(labelingInspectorEntity)
.columns(
labelingInspectorEntity.operatorUid,
labelingInspectorEntity.analUid,
labelingInspectorEntity.inspectorUid)
.values(UUID.randomUUID(), analUid, inspector)
.execute();
em.flush();
em.clear();
}
} }