국유인in 연동 가능여부 api

This commit is contained in:
2026-01-22 20:40:58 +09:00
parent cf93244969
commit f0eb5b839a
8 changed files with 182 additions and 7 deletions

View File

@@ -1,8 +1,24 @@
package com.kamco.cd.kamcoback.postgres.core;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto;
import com.kamco.cd.kamcoback.postgres.repository.Inference.MapSheetLearnRepository;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class GukYuinCoreService {}
public class GukYuinCoreService {
private final MapSheetLearnRepository mapSheetLearnRepository;
/**
* 국유in연동 가능여부 확인
*
* @param uuid uuid
* @return
*/
public GukYuinDto.isLinkDto getIsLinkGukYuin(UUID uuid) {
return mapSheetLearnRepository.getIsLinkGukYuin(uuid);
}
}

View File

@@ -1,5 +1,6 @@
package com.kamco.cd.kamcoback.postgres.entity;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
@@ -186,6 +187,12 @@ public class MapSheetLearnEntity {
@Column(name = "m3_failed_jobs", nullable = false)
private int m3FailedJobs = 0;
@Column(name = "apply_status")
private String applyStatus = GukYuinStatus.PENDING.getId();
@Column(name = "apply_status_dttm")
private ZonedDateTime applyStatusDttm;
@Column(name = "uid", nullable = false)
private String uid = UUID.randomUUID().toString().replace("-", "").toUpperCase();

View File

@@ -1,5 +1,6 @@
package com.kamco.cd.kamcoback.postgres.repository.Inference;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto;
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;
@@ -40,4 +41,6 @@ public interface MapSheetLearnRepositoryCustom {
List<Dashboard> getInferenceClassCountList(UUID uuid);
Page<Geom> getInferenceGeomList(UUID uuid, SearchGeoReq searchGeoReq);
GukYuinDto.isLinkDto getIsLinkGukYuin(UUID uuid);
}

View File

@@ -12,6 +12,8 @@ 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.GukYuinStatus;
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;
@@ -21,6 +23,7 @@ import com.kamco.cd.kamcoback.inference.dto.InferenceProgressDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceServerStatusDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceStatusDetailDto;
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.QModelMngEntity;
@@ -502,4 +505,75 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
return new PageImpl<>(content, pageable, total == null ? 0L : total);
}
/**
* 국유in연동 가능여부 확인
*
* @param uuid uuid
* @return
*/
@Override
public GukYuinDto.isLinkDto getIsLinkGukYuin(UUID uuid) {
GukYuinDto.isLinkDto dto = new GukYuinDto.isLinkDto();
MapSheetLearnEntity learn =
queryFactory
.selectFrom(mapSheetLearnEntity)
.where(mapSheetLearnEntity.uuid.eq(uuid))
.fetchOne();
if (learn == null) {
dto.setIsLinkable(false);
dto.setMessage("데이터가 없습니다.");
return dto;
}
if (MapSheetScope.PART.getId().equals(learn.getMapSheetScope())) {
dto.setIsLinkable(false);
dto.setMessage("분석도엽 전체만 국유in 연동이 가능합니다.");
return dto;
}
// 같은 연도에 ASSIGNED/ING inference 존재 여부
Boolean hasRunningInference =
queryFactory
.selectOne()
.from(mapSheetAnalInferenceEntity)
.join(mapSheetLearnEntity)
.on(mapSheetAnalInferenceEntity.learnId.eq(mapSheetLearnEntity.id))
.where(
mapSheetLearnEntity.compareYyyy.eq(learn.getCompareYyyy()),
mapSheetLearnEntity.targetYyyy.eq(learn.getTargetYyyy()),
mapSheetAnalInferenceEntity.analState.in("ASSIGNED", "ING"))
.fetchFirst()
!= null;
if (hasRunningInference) {
dto.setIsLinkable(false);
dto.setMessage("라벨링 중인 회차가 있습니다.");
return dto;
}
// 같은 연도에 아직 국유인 종료 안 된 다른 learn 존재 여부
Boolean hasOtherUnfinishedGukYuin =
queryFactory
.selectOne()
.from(mapSheetLearnEntity)
.where(
mapSheetLearnEntity.compareYyyy.eq(learn.getCompareYyyy()),
mapSheetLearnEntity.targetYyyy.eq(learn.getTargetYyyy()),
mapSheetLearnEntity.applyStatus.eq(GukYuinStatus.IN_PROGRESS.getId()),
mapSheetLearnEntity.uuid.ne(learn.getUuid()))
.fetchFirst()
!= null;
if (hasOtherUnfinishedGukYuin) {
dto.setIsLinkable(false);
dto.setMessage("국유in 연동중인 회차가 있습니다.");
return dto;
}
dto.setIsLinkable(true);
return dto;
}
}