라벨링 종료여부 추가

This commit is contained in:
DanielLee
2026-01-09 10:10:28 +09:00
parent 980828fbd3
commit 26e58b01d5
8 changed files with 271 additions and 40 deletions

View File

@@ -133,4 +133,9 @@ public class LabelAllocateCoreService {
String uuid, String userId, String paramUserId, Long assignCount) {
labelAllocateRepository.assignOwnerReAllocate(uuid, userId, paramUserId, assignCount);
}
public void updateClosedYnByUuid(String uuid, String closedType, String closedYn) {
labelAllocateRepository.updateClosedYnByUuid(uuid, closedType, closedYn);
}
}

View File

@@ -149,4 +149,14 @@ public class MapSheetAnalInferenceEntity {
@Column(name = "stage")
private Integer stage;
@Size(max = 1)
@ColumnDefault("'N'")
@Column(name = "labeling_closed_yn", length = 1)
private String labelingClosedYn = "N";
@Size(max = 1)
@ColumnDefault("'N'")
@Column(name = "inspection_closed_yn", length = 1)
private String inspectionClosedYn = "N";
}

View File

@@ -77,4 +77,8 @@ public interface LabelAllocateRepositoryCustom {
void insertLabelerUser(Long analUid, String userId, int demand);
void assignOwnerReAllocate(String uuid, String userId, String paramUserId, Long assignCount);
// 프로젝트 종료 여부 업데이트 (uuid 기반)
void updateClosedYnByUuid(String uuid, String closedType, String closedYn);
}

View File

@@ -335,10 +335,50 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
@Override
public WorkProgressInfo findWorkProgressInfo(Long analUid) {
BooleanExpression analUidCondition =
analUid != null ? labelingAssignmentEntity.analUid.eq(analUid) : null;
// analUid가 null이면 최신 프로젝트의 analUid 조회
Long effectiveAnalUid = analUid;
if (effectiveAnalUid == null) {
UUID latestUuid = findLastLabelWorkState();
if (latestUuid != null) {
effectiveAnalUid =
queryFactory
.select(mapSheetAnalInferenceEntity.id)
.from(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.uuid.eq(latestUuid))
.fetchOne();
}
}
// 전체 배정 건수
BooleanExpression analUidCondition =
effectiveAnalUid != null ? labelingAssignmentEntity.analUid.eq(effectiveAnalUid) : null;
// analUid로 분석 정보(compareYyyy, targetYyyy, stage) 조회
MapSheetAnalInferenceEntity analEntity = null;
if (effectiveAnalUid != null) {
analEntity =
queryFactory
.selectFrom(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.id.eq(effectiveAnalUid))
.fetchOne();
}
// 라벨링 대상 건수: tb_map_sheet_anal_data_inference_geom에서 pnu > 0 AND pass_yn = false(부적합)인 건수
Long labelingTargetCount = 0L;
if (analEntity != null) {
labelingTargetCount =
queryFactory
.select(mapSheetAnalDataInferenceGeomEntity.geoUid.count())
.from(mapSheetAnalDataInferenceGeomEntity)
.where(
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(analEntity.getCompareYyyy()),
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(analEntity.getTargetYyyy()),
mapSheetAnalDataInferenceGeomEntity.stage.eq(analEntity.getStage()),
mapSheetAnalDataInferenceGeomEntity.pnu.gt(0L),
mapSheetAnalDataInferenceGeomEntity.passYn.isFalse())
.fetchOne();
}
// 전체 배정 건수 (tb_labeling_assignment 기준)
Long totalAssigned =
queryFactory
.select(labelingAssignmentEntity.count())
@@ -390,47 +430,69 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
.where(analUidCondition, labelingAssignmentEntity.inspectorUid.isNotNull())
.fetchOne();
// 남은 작업 건수 계산
long total = totalAssigned != null ? totalAssigned : 0L;
// 라벨링 대상 건수 (pass_yn = false인 부적합 데이터 기준)
long labelingTotal = labelingTargetCount != null ? labelingTargetCount : 0L;
long assignedTotal = totalAssigned != null ? totalAssigned : 0L;
long labelCompleted = labelingCompleted != null ? labelingCompleted : 0L;
long inspectCompleted = inspectionCompleted != null ? inspectionCompleted : 0L;
long skipped = skipCount != null ? skipCount : 0L;
long labelingRemaining = total - labelCompleted - skipped;
long inspectionRemaining = total - inspectCompleted - skipped;
// 라벨링 남은 건수: 라벨링 대상 건수 - 완료 - 스킵
long labelingRemaining = labelingTotal - labelCompleted - skipped;
if (labelingRemaining < 0) labelingRemaining = 0;
// 진행률 계산
double labelingRate = total > 0 ? (double) labelCompleted / total * 100 : 0.0;
double inspectionRate = total > 0 ? (double) inspectCompleted / total * 100 : 0.0;
// 검수 대상 건수: 라벨링 대상 건수와 동일 (기획서 기준)
long inspectionTotal = labelingTotal;
// 검수 남은 건수: 검수 대상 건수 - 검수완료(DONE) - 스킵
long inspectionRemaining = inspectionTotal - inspectCompleted - skipped;
if (inspectionRemaining < 0) inspectionRemaining = 0;
// 상태 판단
String labelingStatus = labelingRemaining > 0 ? "진행중" : "완료";
String inspectionStatus = inspectionRemaining > 0 ? "진행중" : "완료";
// 진행률 계산 (라벨링 대상 건수 기준)
double labelingRate = labelingTotal > 0 ? (double) labelCompleted / labelingTotal * 100 : 0.0;
double inspectionRate =
inspectionTotal > 0 ? (double) inspectCompleted / inspectionTotal * 100 : 0.0;
// 상태 판단 (각각의 closedYn이 "Y"이면 "종료", 아니면 진행중/완료)
String labelingStatus;
String inspectionStatus;
// 라벨링 상태 판단
if (analEntity != null && "Y".equals(analEntity.getLabelingClosedYn())) {
labelingStatus = "종료";
} else {
labelingStatus = labelingRemaining > 0 ? "진행중" : "완료";
}
// 검수 상태 판단
if (analEntity != null && "Y".equals(analEntity.getInspectionClosedYn())) {
inspectionStatus = "종료";
} else {
inspectionStatus = inspectionRemaining > 0 ? "진행중" : "완료";
}
return WorkProgressInfo.builder()
// 라벨링
// 라벨링 (pass_yn = false인 부적합 데이터 기준)
.labelingProgressRate(labelingRate)
.labelingStatus(labelingStatus)
.labelingTotalCount(total)
.labelingTotalCount(labelingTotal)
.labelingCompletedCount(labelCompleted)
.labelingSkipCount(skipped)
.labelingRemainingCount(labelingRemaining)
.labelerCount(labelerCount != null ? labelerCount : 0L)
// 검수
// 검수 (라벨링 완료 건수 기준)
.inspectionProgressRate(inspectionRate)
.inspectionStatus(inspectionStatus)
.inspectionTotalCount(total)
.inspectionTotalCount(inspectionTotal)
.inspectionCompletedCount(inspectCompleted)
.inspectionSkipCount(skipped)
.inspectionRemainingCount(inspectionRemaining)
.inspectorCount(inspectorCount != null ? inspectorCount : 0L)
// 레거시 호환 필드 (Deprecated)
.progressRate(labelingRate)
.totalAssignedCount(total)
.totalAssignedCount(labelingTotal)
.completedCount(labelCompleted)
.remainingLabelCount(labelingRemaining)
.remainingInspectCount(inspectionRemaining)
.workStatus(labelingStatus)
.build();
}
@@ -677,7 +739,9 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
mapSheetAnalInferenceEntity.stage,
mapSheetAnalInferenceEntity.gukyuinApplyDttm,
mapSheetAnalInferenceEntity.createdDttm,
mapSheetAnalInferenceEntity.uuid)
mapSheetAnalInferenceEntity.uuid,
mapSheetAnalInferenceEntity.labelingClosedYn,
mapSheetAnalInferenceEntity.inspectionClosedYn)
.from(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.id.eq(analUid))
.fetchOne();
@@ -692,6 +756,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
ZonedDateTime gukyuinApplyDttm = result.get(mapSheetAnalInferenceEntity.gukyuinApplyDttm);
ZonedDateTime createdDttm = result.get(mapSheetAnalInferenceEntity.createdDttm);
UUID uuid = result.get(mapSheetAnalInferenceEntity.uuid);
String labelingClosedYn = result.get(mapSheetAnalInferenceEntity.labelingClosedYn);
String inspectionClosedYn = result.get(mapSheetAnalInferenceEntity.inspectionClosedYn);
// 변화탐지년도 생성
String detectionYear =
@@ -706,6 +772,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
.gukyuinApplyDttm(gukyuinApplyDttm)
.startDttm(createdDttm)
.uuid(uuid != null ? uuid.toString() : null)
.labelingClosedYn(labelingClosedYn)
.inspectionClosedYn(inspectionClosedYn)
.build();
}
@@ -727,7 +795,9 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
mapSheetAnalInferenceEntity.stage,
mapSheetAnalInferenceEntity.gukyuinApplyDttm,
mapSheetAnalInferenceEntity.createdDttm,
mapSheetAnalInferenceEntity.uuid)
mapSheetAnalInferenceEntity.uuid,
mapSheetAnalInferenceEntity.labelingClosedYn,
mapSheetAnalInferenceEntity.inspectionClosedYn)
.from(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.uuid.eq(uuid))
.fetchOne();
@@ -741,6 +811,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
Integer stage = result.get(mapSheetAnalInferenceEntity.stage);
ZonedDateTime gukyuinApplyDttm = result.get(mapSheetAnalInferenceEntity.gukyuinApplyDttm);
ZonedDateTime createdDttm = result.get(mapSheetAnalInferenceEntity.createdDttm);
String labelingClosedYn = result.get(mapSheetAnalInferenceEntity.labelingClosedYn);
String inspectionClosedYn = result.get(mapSheetAnalInferenceEntity.inspectionClosedYn);
// 변화탐지년도 생성
String detectionYear =
@@ -755,6 +827,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
.gukyuinApplyDttm(gukyuinApplyDttm)
.startDttm(createdDttm)
.uuid(uuid.toString())
.labelingClosedYn(labelingClosedYn)
.inspectionClosedYn(inspectionClosedYn)
.build();
}
@@ -1160,4 +1234,24 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
labelingLabelerEntity.workerUid.eq(paramUserId))
.execute();
}
@Override
public void updateClosedYnByUuid(String uuid, String closedType, String closedYn) {
var updateQuery = queryFactory.update(mapSheetAnalInferenceEntity);
if ("LABELING".equals(closedType)) {
updateQuery.set(mapSheetAnalInferenceEntity.labelingClosedYn, closedYn);
} else if ("INSPECTION".equals(closedType)) {
updateQuery.set(mapSheetAnalInferenceEntity.inspectionClosedYn, closedYn);
}
updateQuery
.set(mapSheetAnalInferenceEntity.updatedDttm, ZonedDateTime.now())
.where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
.execute();
em.flush();
em.clear();
}
}

View File

@@ -267,32 +267,29 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
whereSubBuilder.and(labelingAssignmentEntity.workerUid.eq(memberEntity.userId));
// 공통 조건 추출
BooleanExpression doneStateCondition =
labelingAssignmentEntity.workState.eq(LabelState.DONE.name());
NumberExpression<Long> assignedCnt = labelingAssignmentEntity.workerUid.count();
NumberExpression<Long> doneCnt =
this.caseSumExpression(labelingAssignmentEntity.workState.eq(LabelState.DONE.name()));
NumberExpression<Long> doneCnt = this.caseSumExpression(doneStateCondition);
NumberExpression<Long> skipCnt =
this.caseSumExpression(labelingAssignmentEntity.workState.eq(LabelState.SKIP.name()));
NumberExpression<Long> day3AgoDoneCnt =
this.caseSumExpression(
labelingAssignmentEntity
.workState
.eq(LabelState.DONE.name())
.and(this.fromDateEqExpression(labelingAssignmentEntity.modifiedDate, -3)));
doneStateCondition.and(
this.fromDateEqExpression(labelingAssignmentEntity.modifiedDate, -3)));
NumberExpression<Long> day2AgoDoneCnt =
this.caseSumExpression(
labelingAssignmentEntity
.workState
.eq(LabelState.DONE.name())
.and(this.fromDateEqExpression(labelingAssignmentEntity.modifiedDate, -2)));
doneStateCondition.and(
this.fromDateEqExpression(labelingAssignmentEntity.modifiedDate, -2)));
NumberExpression<Long> day1AgoDoneCnt =
this.caseSumExpression(
labelingAssignmentEntity
.workState
.eq(LabelState.DONE.name())
.and(this.fromDateEqExpression(labelingAssignmentEntity.modifiedDate, -1)));
doneStateCondition.and(
this.fromDateEqExpression(labelingAssignmentEntity.modifiedDate, -1)));
NumberExpression<Long> remainingCnt = assignedCnt.subtract(doneCnt);