국유인in 연동 가능여부 api 수정

This commit is contained in:
2026-01-22 21:00:12 +09:00
parent f0eb5b839a
commit 97010c6a1f
6 changed files with 101 additions and 58 deletions

View File

@@ -1,6 +1,6 @@
package com.kamco.cd.kamcoback.postgres.core;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GukYuinLinkFacts;
import com.kamco.cd.kamcoback.postgres.repository.Inference.MapSheetLearnRepository;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
@@ -18,7 +18,7 @@ public class GukYuinCoreService {
* @param uuid uuid
* @return
*/
public GukYuinDto.isLinkDto getIsLinkGukYuin(UUID uuid) {
return mapSheetLearnRepository.getIsLinkGukYuin(uuid);
public GukYuinLinkFacts findLinkFacts(UUID uuid) {
return mapSheetLearnRepository.findLinkFacts(uuid);
}
}

View File

@@ -1,6 +1,6 @@
package com.kamco.cd.kamcoback.postgres.repository.Inference;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GukYuinLinkFacts;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.AnalResultInfo;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.BboxPointDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.Dashboard;
@@ -42,5 +42,5 @@ public interface MapSheetLearnRepositoryCustom {
Page<Geom> getInferenceGeomList(UUID uuid, SearchGeoReq searchGeoReq);
GukYuinDto.isLinkDto getIsLinkGukYuin(UUID uuid);
GukYuinLinkFacts findLinkFacts(UUID uuid);
}

View File

@@ -12,7 +12,7 @@ import static com.kamco.cd.kamcoback.postgres.entity.QSystemMetricEntity.systemM
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
import com.kamco.cd.kamcoback.common.utils.DateRange;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GukYuinLinkFacts;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.AnalResultInfo;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.BboxPointDto;
@@ -26,6 +26,8 @@ import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceStatusDe
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetScope;
import com.kamco.cd.kamcoback.model.service.ModelMngService;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnEntity;
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity;
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnEntity;
import com.kamco.cd.kamcoback.postgres.entity.QModelMngEntity;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Expression;
@@ -513,67 +515,49 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
* @return
*/
@Override
public GukYuinDto.isLinkDto getIsLinkGukYuin(UUID uuid) {
GukYuinDto.isLinkDto dto = new GukYuinDto.isLinkDto();
public GukYuinLinkFacts findLinkFacts(UUID uuid) {
MapSheetLearnEntity learn =
queryFactory
.selectFrom(mapSheetLearnEntity)
.where(mapSheetLearnEntity.uuid.eq(uuid))
.selectFrom(QMapSheetLearnEntity.mapSheetLearnEntity)
.where(QMapSheetLearnEntity.mapSheetLearnEntity.uuid.eq(uuid))
.fetchOne();
if (learn == null) {
dto.setIsLinkable(false);
dto.setMessage("데이터가 없습니다.");
return dto;
return new GukYuinLinkFacts(false, false, false, false);
}
if (MapSheetScope.PART.getId().equals(learn.getMapSheetScope())) {
dto.setIsLinkable(false);
dto.setMessage("분석도엽 전체만 국유in 연동이 가능합니다.");
return dto;
}
boolean isPartScope = MapSheetScope.PART.getId().equals(learn.getMapSheetScope());
// 같은 연도에 ASSIGNED/ING inference 존재 여부
Boolean hasRunningInference =
QMapSheetAnalInferenceEntity inf = QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
QMapSheetLearnEntity learn2 = new QMapSheetLearnEntity("learn2");
QMapSheetLearnEntity learnQ = QMapSheetLearnEntity.mapSheetLearnEntity;
boolean hasRunningInference =
queryFactory
.selectOne()
.from(mapSheetAnalInferenceEntity)
.join(mapSheetLearnEntity)
.on(mapSheetAnalInferenceEntity.learnId.eq(mapSheetLearnEntity.id))
.from(inf)
.join(learn2)
.on(inf.learnId.eq(learn2.id))
.where(
mapSheetLearnEntity.compareYyyy.eq(learn.getCompareYyyy()),
mapSheetLearnEntity.targetYyyy.eq(learn.getTargetYyyy()),
mapSheetAnalInferenceEntity.analState.in("ASSIGNED", "ING"))
learn2.compareYyyy.eq(learn.getCompareYyyy()),
learn2.targetYyyy.eq(learn.getTargetYyyy()),
inf.analState.in("ASSIGNED", "ING"))
.fetchFirst()
!= null;
if (hasRunningInference) {
dto.setIsLinkable(false);
dto.setMessage("라벨링 중인 회차가 있습니다.");
return dto;
}
// 같은 연도에 아직 국유인 종료 안 된 다른 learn 존재 여부
Boolean hasOtherUnfinishedGukYuin =
boolean hasOtherUnfinishedGukYuin =
queryFactory
.selectOne()
.from(mapSheetLearnEntity)
.from(learnQ)
.where(
mapSheetLearnEntity.compareYyyy.eq(learn.getCompareYyyy()),
mapSheetLearnEntity.targetYyyy.eq(learn.getTargetYyyy()),
mapSheetLearnEntity.applyStatus.eq(GukYuinStatus.IN_PROGRESS.getId()),
mapSheetLearnEntity.uuid.ne(learn.getUuid()))
learnQ.compareYyyy.eq(learn.getCompareYyyy()),
learnQ.targetYyyy.eq(learn.getTargetYyyy()),
learnQ.applyStatus.eq(GukYuinStatus.IN_PROGRESS.getId()),
learnQ.uuid.ne(learn.getUuid()))
.fetchFirst()
!= null;
if (hasOtherUnfinishedGukYuin) {
dto.setIsLinkable(false);
dto.setMessage("국유in 연동중인 회차가 있습니다.");
return dto;
}
dto.setIsLinkable(true);
return dto;
return new GukYuinLinkFacts(true, isPartScope, hasRunningInference, hasOtherUnfinishedGukYuin);
}
}