inference_results 결과 저장 중복방지 #136
@@ -1,9 +1,12 @@
|
||||
package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultShpDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalInferenceEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.Inference.InferenceResultRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -24,6 +27,12 @@ public class InferenceResultShpCoreService {
|
||||
@Transactional
|
||||
public InferenceResultShpDto.InferenceCntDto buildInferenceData(Long id) {
|
||||
|
||||
MapSheetAnalInferenceEntity analInferenceEntity =
|
||||
repo.getAnalInferenceDataByLearnId(id).orElse(null);
|
||||
if (analInferenceEntity != null) {
|
||||
throw new CustomApiException("CONFLICT", HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
Long analId = repo.upsertGroupsFromMapSheetAnal(id);
|
||||
int analDataCnt = repo.upsertGroupsFromInferenceResults(analId);
|
||||
int geomCnt = repo.upsertGeomsFromInferenceResults(analId);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.Inference;
|
||||
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalInferenceEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnEntity;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
@@ -53,4 +54,12 @@ public interface InferenceResultRepositoryCustom {
|
||||
* @return 추론 정보
|
||||
*/
|
||||
Optional<MapSheetLearnEntity> getInferenceUid(UUID uuid);
|
||||
|
||||
/**
|
||||
* learn id 로 analInference 값 조회
|
||||
*
|
||||
* @param id 추론 id
|
||||
* @return
|
||||
*/
|
||||
Optional<MapSheetAnalInferenceEntity> getAnalInferenceDataByLearnId(Long id);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.Inference;
|
||||
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnEntity.mapSheetLearnEntity;
|
||||
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelMngState;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalInferenceEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnEntity;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import jakarta.persistence.EntityManager;
|
||||
@@ -334,4 +336,14 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
|
||||
.where(mapSheetLearnEntity.uuid.eq(uuid))
|
||||
.fetchOne());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<MapSheetAnalInferenceEntity> getAnalInferenceDataByLearnId(Long id) {
|
||||
return Optional.ofNullable(
|
||||
queryFactory
|
||||
.select(mapSheetAnalInferenceEntity)
|
||||
.from(mapSheetAnalInferenceEntity)
|
||||
.where(mapSheetAnalInferenceEntity.learnId.eq(id))
|
||||
.fetchOne());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user