Merge remote-tracking branch 'origin/feat/infer_dev_260107' into feat/infer_dev_260107

This commit is contained in:
Moon
2026-01-09 12:04:08 +09:00
24 changed files with 845 additions and 129 deletions

View File

@@ -1,5 +1,6 @@
package com.kamco.cd.kamcoback.postgres.core;
import com.kamco.cd.kamcoback.common.utils.UserUtil;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.Dashboard;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.MapSheet;
@@ -8,13 +9,18 @@ import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.ResultList;
import com.kamco.cd.kamcoback.postgres.entity.MapInkx5kEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataInferenceEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataInferenceGeomEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearn5kEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnEntity;
import com.kamco.cd.kamcoback.postgres.repository.Inference.MapSheetAnalDataInferenceRepository;
import com.kamco.cd.kamcoback.postgres.repository.Inference.MapSheetLearn5kRepository;
import com.kamco.cd.kamcoback.postgres.repository.Inference.MapSheetLearnRepository;
import com.kamco.cd.kamcoback.postgres.repository.scene.MapInkx5kRepository;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityNotFoundException;
import jakarta.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
@@ -27,6 +33,10 @@ public class InferenceResultCoreService {
private final MapSheetAnalDataInferenceRepository mapSheetAnalDataRepository;
private final MapSheetLearnRepository mapSheetLearnRepository;
private final MapInkx5kRepository mapInkx5kRepository;
private final MapSheetLearn5kRepository mapSheetLearn5kRepository;
private final EntityManager entityManager;
private final UserUtil userUtil;
/**
* 추론관리 목록
@@ -39,6 +49,55 @@ public class InferenceResultCoreService {
return list.map(MapSheetLearnEntity::toDto);
}
/**
* 변화탐지 실행 정보 생성
*
* @param req
*/
public UUID saveInferenceInfo(InferenceResultDto.RegReq req) {
MapSheetLearnEntity mapSheetLearnEntity = new MapSheetLearnEntity();
mapSheetLearnEntity.setTitle(req.getTitle());
mapSheetLearnEntity.setM1ModelUid(req.getModel1Uid());
mapSheetLearnEntity.setM2ModelUid(req.getModel2Uid());
mapSheetLearnEntity.setM3ModelUid(req.getModel3Uid());
mapSheetLearnEntity.setCompareYyyy(req.getCompareYyyy());
mapSheetLearnEntity.setTargetYyyy(req.getTargetYyyy());
mapSheetLearnEntity.setMapSheetScope(req.getMapSheetScope());
mapSheetLearnEntity.setDetectOption(req.getDetectOption());
mapSheetLearnEntity.setCreatedUid(userUtil.getId());
// learn 테이블 저장
MapSheetLearnEntity savedLearn = mapSheetLearnRepository.save(mapSheetLearnEntity);
final int CHUNK = 1000;
List<MapSheetLearn5kEntity> buffer = new ArrayList<>(CHUNK);
List<String> mapSheetNumList = req.getMapSheetNum();
// learn 도엽 저장
for (String mapSheetNum : mapSheetNumList) {
MapSheetLearn5kEntity e = new MapSheetLearn5kEntity();
e.setLearn(savedLearn);
e.setMapSheetNum(Long.parseLong(mapSheetNum));
e.setCreatedUid(userUtil.getId());
buffer.add(e);
if (buffer.size() == CHUNK) {
mapSheetLearn5kRepository.saveAll(buffer);
mapSheetLearn5kRepository.flush();
entityManager.clear();
buffer.clear();
}
}
if (!buffer.isEmpty()) {
mapSheetLearn5kRepository.saveAll(buffer);
mapSheetLearn5kRepository.flush();
entityManager.clear();
}
return savedLearn.getUuid();
}
/****/
/**

View File

@@ -61,6 +61,10 @@ public class LabelAllocateCoreService {
return labelAllocateRepository.findLatestProjectInfo();
}
public ProjectInfo findProjectInfoByUuid(String uuid) {
return labelAllocateRepository.findProjectInfoByUuid(uuid);
}
public UUID findLastLabelWorkState() {
return labelAllocateRepository.findLastLabelWorkState();
}
@@ -74,6 +78,10 @@ public class LabelAllocateCoreService {
return labelAllocateRepository.findWorkProgressInfo(analUid);
}
public WorkProgressInfo findWorkProgressInfoByUuid(String uuid) {
return labelAllocateRepository.findWorkProgressInfoByUuid(uuid);
}
public Long findDailyProcessedCount(
String workerId, String workerType, LocalDate date, Long analUid) {
return labelAllocateRepository.findDailyProcessedCount(workerId, workerType, date, analUid);
@@ -133,4 +141,8 @@ 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

@@ -0,0 +1,51 @@
package com.kamco.cd.kamcoback.postgres.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import java.time.ZonedDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
@Getter
@Setter
@Entity
@Table(name = "tb_map_sheet_learn_5k")
public class MapSheetLearn5kEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "tb_map_sheet_learn_5k_id_gen")
@SequenceGenerator(
name = "tb_map_sheet_learn_5k_id_gen",
sequenceName = "tb_map_sheet_learn_5k_seq",
allocationSize = 1)
@Column(name = "id", nullable = false)
private Long id;
@NotNull
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@OnDelete(action = OnDeleteAction.CASCADE)
@JoinColumn(name = "learn_id", nullable = false, referencedColumnName = "id")
private MapSheetLearnEntity learn;
@NotNull
@Column(name = "map_sheet_num", nullable = false)
private Long mapSheetNum;
@org.hibernate.annotations.CreationTimestamp
@Column(name = "created_dttm")
private ZonedDateTime createdDttm;
@Column(name = "created_uid")
private Long createdUid;
}

View File

@@ -33,7 +33,7 @@ public class MapSheetLearnEntity {
@ColumnDefault("gen_random_uuid()")
@Column(name = "uuid")
private UUID uuid;
private UUID uuid = UUID.randomUUID();
@Size(max = 200)
@NotNull
@@ -89,7 +89,7 @@ public class MapSheetLearnEntity {
@Column(name = "apply_dttm")
private ZonedDateTime applyDttm;
@ColumnDefault("now()")
@org.hibernate.annotations.CreationTimestamp
@Column(name = "created_dttm")
private ZonedDateTime createdDttm;

View File

@@ -0,0 +1,7 @@
package com.kamco.cd.kamcoback.postgres.repository.Inference;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearn5kEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface MapSheetLearn5kRepository
extends JpaRepository<MapSheetLearn5kEntity, Long>, MapSheetLearn5kRepositoryCustom {}

View File

@@ -0,0 +1,3 @@
package com.kamco.cd.kamcoback.postgres.repository.Inference;
public interface MapSheetLearn5kRepositoryCustom {}

View File

@@ -0,0 +1,6 @@
package com.kamco.cd.kamcoback.postgres.repository.Inference;
import org.springframework.stereotype.Repository;
@Repository
public class MapSheetLearn5kRepositoryImpl implements MapSheetLearn5kRepositoryCustom {}

View File

@@ -37,6 +37,9 @@ public interface LabelAllocateRepositoryCustom {
// 최신 프로젝트 정보 조회 (analUid 없이)
ProjectInfo findLatestProjectInfo();
// UUID로 프로젝트 정보 조회
ProjectInfo findProjectInfoByUuid(String uuid);
// 최신 작업 상태의 UUID 조회
UUID findLastLabelWorkState();
@@ -47,6 +50,9 @@ public interface LabelAllocateRepositoryCustom {
// 작업 진행 현황 조회
WorkProgressInfo findWorkProgressInfo(Long analUid);
// UUID로 작업 진행 현황 조회
WorkProgressInfo findWorkProgressInfoByUuid(String uuid);
// 작업자별 일일 처리량 조회
Long findDailyProcessedCount(String workerId, String workerType, LocalDate date, Long analUid);
@@ -77,4 +83,7 @@ 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,217 @@ 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)
.build();
}
@Override
public WorkProgressInfo findWorkProgressInfoByUuid(String uuid) {
if (uuid == null || uuid.isBlank()) {
return findWorkProgressInfo(null);
}
UUID targetUuid = UUID.fromString(uuid);
// UUID로 analUid 조회
Long effectiveAnalUid =
queryFactory
.select(mapSheetAnalInferenceEntity.id)
.from(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.uuid.eq(targetUuid))
.fetchOne();
if (effectiveAnalUid == null) {
return null;
}
BooleanExpression analUidCondition = labelingAssignmentEntity.analUid.eq(effectiveAnalUid);
// analUid로 분석 정보(compareYyyy, targetYyyy, stage) 조회
MapSheetAnalInferenceEntity 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())
.from(labelingAssignmentEntity)
.where(analUidCondition)
.fetchOne();
// === 라벨링 통계 ===
Long labelingCompleted =
queryFactory
.select(labelingAssignmentEntity.count())
.from(labelingAssignmentEntity)
.where(
analUidCondition,
labelingAssignmentEntity.workState.in("LABEL_FIN", "TEST_ING", "DONE"))
.fetchOne();
Long skipCount =
queryFactory
.select(labelingAssignmentEntity.count())
.from(labelingAssignmentEntity)
.where(analUidCondition, labelingAssignmentEntity.workState.eq("SKIP"))
.fetchOne();
Long labelerCount =
queryFactory
.select(labelingAssignmentEntity.workerUid.countDistinct())
.from(labelingAssignmentEntity)
.where(analUidCondition, labelingAssignmentEntity.workerUid.isNotNull())
.fetchOne();
// === 검수 통계 ===
Long inspectionCompleted =
queryFactory
.select(labelingAssignmentEntity.count())
.from(labelingAssignmentEntity)
.where(analUidCondition, labelingAssignmentEntity.workState.eq("DONE"))
.fetchOne();
Long inspectorCount =
queryFactory
.select(labelingAssignmentEntity.inspectorUid.countDistinct())
.from(labelingAssignmentEntity)
.where(analUidCondition, labelingAssignmentEntity.inspectorUid.isNotNull())
.fetchOne();
// 계산
long labelingTotal = labelingTargetCount != null ? labelingTargetCount : 0L;
long labelCompleted = labelingCompleted != null ? labelingCompleted : 0L;
long inspectCompleted = inspectionCompleted != null ? inspectionCompleted : 0L;
long skipped = skipCount != null ? skipCount : 0L;
long labelingRemaining = labelingTotal - labelCompleted - skipped;
if (labelingRemaining < 0) labelingRemaining = 0;
long inspectionTotal = labelingTotal;
long inspectionRemaining = inspectionTotal - inspectCompleted - skipped;
if (inspectionRemaining < 0) inspectionRemaining = 0;
double labelingRate = labelingTotal > 0 ? (double) labelCompleted / labelingTotal * 100 : 0.0;
double inspectionRate =
inspectionTotal > 0 ? (double) inspectCompleted / inspectionTotal * 100 : 0.0;
// 상태 판단
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()
.labelingProgressRate(labelingRate)
.labelingStatus(labelingStatus)
.labelingTotalCount(labelingTotal)
.labelingCompletedCount(labelCompleted)
.labelingSkipCount(skipped)
.labelingRemainingCount(labelingRemaining)
.labelerCount(labelerCount != null ? labelerCount : 0L)
.inspectionProgressRate(inspectionRate)
.inspectionStatus(inspectionStatus)
.inspectionTotalCount(inspectionTotal)
.inspectionCompletedCount(inspectCompleted)
.inspectionSkipCount(skipped)
.inspectionRemainingCount(inspectionRemaining)
.inspectorCount(inspectorCount != null ? inspectorCount : 0L)
.progressRate(labelingRate)
.totalAssignedCount(labelingTotal)
.completedCount(labelCompleted)
.remainingLabelCount(labelingRemaining)
.remainingInspectCount(inspectionRemaining)
.workStatus(labelingStatus)
.build();
}
@@ -677,7 +887,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 +904,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 +920,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
.gukyuinApplyDttm(gukyuinApplyDttm)
.startDttm(createdDttm)
.uuid(uuid != null ? uuid.toString() : null)
.labelingClosedYn(labelingClosedYn)
.inspectionClosedYn(inspectionClosedYn)
.build();
}
@@ -727,7 +943,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 +959,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 +975,58 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
.gukyuinApplyDttm(gukyuinApplyDttm)
.startDttm(createdDttm)
.uuid(uuid.toString())
.labelingClosedYn(labelingClosedYn)
.inspectionClosedYn(inspectionClosedYn)
.build();
}
@Override
public ProjectInfo findProjectInfoByUuid(String uuid) {
if (uuid == null || uuid.isBlank()) {
return null;
}
UUID targetUuid = UUID.fromString(uuid);
var result =
queryFactory
.select(
mapSheetAnalInferenceEntity.compareYyyy,
mapSheetAnalInferenceEntity.targetYyyy,
mapSheetAnalInferenceEntity.stage,
mapSheetAnalInferenceEntity.gukyuinApplyDttm,
mapSheetAnalInferenceEntity.createdDttm,
mapSheetAnalInferenceEntity.uuid,
mapSheetAnalInferenceEntity.labelingClosedYn,
mapSheetAnalInferenceEntity.inspectionClosedYn)
.from(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.uuid.eq(targetUuid))
.fetchOne();
if (result == null) {
return null;
}
Integer compareYyyy = result.get(mapSheetAnalInferenceEntity.compareYyyy);
Integer targetYyyy = result.get(mapSheetAnalInferenceEntity.targetYyyy);
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 =
(compareYyyy != null && targetYyyy != null) ? compareYyyy + "-" + targetYyyy : null;
String round = stage != null ? String.valueOf(stage) : null;
return ProjectInfo.builder()
.detectionYear(detectionYear)
.stage(round)
.gukyuinApplyDttm(gukyuinApplyDttm)
.startDttm(createdDttm)
.uuid(uuid)
.labelingClosedYn(labelingClosedYn)
.inspectionClosedYn(inspectionClosedYn)
.build();
}
@@ -1160,4 +1432,23 @@ 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

@@ -57,7 +57,6 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
QLabelingAssignmentEntity.labelingAssignmentEntity;
private final QMemberEntity memberEntity = QMemberEntity.memberEntity;
/**
* 변화탐지 년도 셀렉트박스 조회
*
@@ -81,8 +80,7 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
}
/**
* 라벨링 작업관리 목록 조회
* (복잡한 집계 쿼리로 인해 DTO 직접 반환)
* 라벨링 작업관리 목록 조회 (복잡한 집계 쿼리로 인해 DTO 직접 반환)
*
* @param searchReq 검색 조건
* @return 라벨링 작업관리 목록 페이지
@@ -171,38 +169,42 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
mapSheetAnalInferenceEntity.compareYyyy,
mapSheetAnalInferenceEntity.targetYyyy,
mapSheetAnalInferenceEntity.stage,
// createdDttm: tb_map_sheet_anal_inference.created_dttm 사용
mapSheetAnalInferenceEntity.createdDttm,
// 국유인 반영 컬럼 gukyuinApplyDttm
mapSheetAnalInferenceEntity.gukyuinApplyDttm,
mapSheetAnalDataInferenceGeomEntity.dataUid.count(),
// labelTotCnt: pnu 있고 pass_yn = false인 건수
labelTotCntExpr,
new CaseBuilder()
.when(mapSheetAnalDataInferenceGeomEntity.labelState.eq("ASSIGNED"))
.when(
mapSheetAnalDataInferenceGeomEntity.labelState.eq(
LabelState.ASSIGNED.getId()))
.then(1L)
.otherwise(0L)
.sum(),
new CaseBuilder()
.when(mapSheetAnalDataInferenceGeomEntity.labelState.eq("STOP"))
.when(
mapSheetAnalDataInferenceGeomEntity.labelState.eq(
LabelState.SKIP.getId())) // "STOP"?
.then(1L)
.otherwise(0L)
.sum(),
new CaseBuilder()
.when(mapSheetAnalDataInferenceGeomEntity.labelState.eq("LABEL_ING"))
.then(1L)
.otherwise(0L)
.sum(),
new CaseBuilder()
.when(mapSheetAnalDataInferenceGeomEntity.labelState.eq("LABEL_COMPLETE"))
.when(
mapSheetAnalDataInferenceGeomEntity.labelState.eq(
LabelState.DONE.getId())) // "LABEL_COMPLETE"?
.then(1L)
.otherwise(0L)
.sum(),
mapSheetAnalDataInferenceGeomEntity.labelStateDttm.min(),
// analState: tb_map_sheet_anal_inference.anal_state
mapSheetAnalInferenceEntity.analState,
// analState: tb_map_sheet_anal_inference.anal_state -> 우선은 미사용, java 단에서 로직화 해서
// 내려줌
// mapSheetAnalInferenceEntity.analState,
// normalProgressCnt: stagnation_yn = 'N'인 건수 (서브쿼리)
normalProgressCntSubQuery,
// totalAssignmentCnt: 총 배정 건수 (서브쿼리)
totalAssignmentCntSubQuery))
totalAssignmentCntSubQuery,
mapSheetAnalInferenceEntity.labelingClosedYn,
mapSheetAnalInferenceEntity.inspectionClosedYn))
.from(mapSheetAnalInferenceEntity)
.innerJoin(mapSheetAnalDataInferenceEntity)
.on(whereSubDataBuilder)
@@ -267,32 +269,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);
@@ -345,7 +344,9 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
mapSheetAnalInferenceEntity
.uuid
.eq(uuid)
.and(labelingAssignmentEntity.analUid.eq(mapSheetAnalInferenceEntity.id)))
.and(
labelingAssignmentEntity.analUid.eq(
mapSheetAnalInferenceEntity.id)))
.innerJoin(memberEntity)
.on(whereSubBuilder)
.where(whereBuilder)
@@ -390,8 +391,7 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
}
/**
* 작업배정 상세조회
* (복잡한 집계 쿼리로 인해 DTO 직접 반환)
* 작업배정 상세조회 (복잡한 집계 쿼리로 인해 DTO 직접 반환)
*
* @param uuid 작업배정 UUID
* @return 작업배정 상세 정보