[KC-99] 추론관리 등록 수정, 모델 조회 추가
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
|
||||
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;
|
||||
@@ -20,6 +21,7 @@ import jakarta.persistence.EntityNotFoundException;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -69,6 +71,14 @@ public class InferenceResultCoreService {
|
||||
// learn 테이블 저장
|
||||
MapSheetLearnEntity savedLearn = mapSheetLearnRepository.save(mapSheetLearnEntity);
|
||||
|
||||
// if (req.getMapSheetScope().equals(MapSheetScope.ALL)) {
|
||||
// List<String> mapSheetIds = new ArrayList<>();
|
||||
// mapInkx5kRepository.findAll().forEach(mapInkx5kEntity -> {
|
||||
// mapSheetIds.add(mapInkx5kEntity.getMapidcdNo());
|
||||
// });
|
||||
// req.setMapSheetNum(mapSheetIds);
|
||||
// }
|
||||
|
||||
final int CHUNK = 1000;
|
||||
List<MapSheetLearn5kEntity> buffer = new ArrayList<>(CHUNK);
|
||||
List<String> mapSheetNumList = req.getMapSheetNum();
|
||||
@@ -82,22 +92,48 @@ public class InferenceResultCoreService {
|
||||
buffer.add(e);
|
||||
|
||||
if (buffer.size() == CHUNK) {
|
||||
mapSheetLearn5kRepository.saveAll(buffer);
|
||||
mapSheetLearn5kRepository.flush();
|
||||
entityManager.clear();
|
||||
this.flushChunk(buffer);
|
||||
buffer.clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (!buffer.isEmpty()) {
|
||||
mapSheetLearn5kRepository.saveAll(buffer);
|
||||
mapSheetLearn5kRepository.flush();
|
||||
entityManager.clear();
|
||||
this.flushChunk(buffer);
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
return savedLearn.getUuid();
|
||||
}
|
||||
|
||||
private void flushChunk(List<MapSheetLearn5kEntity> buffer) {
|
||||
|
||||
// 청크 번호 추출 in 조건 만들기
|
||||
List<String> chunkNums =
|
||||
buffer.stream().map(e -> String.valueOf(e.getMapSheetNum())).distinct().toList();
|
||||
|
||||
// 추론 제외
|
||||
List<MapInkx5kEntity> usedEntities =
|
||||
mapInkx5kRepository.findByMapSheetNumInAndUseInference(chunkNums, CommonUseStatus.USE);
|
||||
|
||||
// TODO 추론 제외 했으면 파일 있는지도 확인 해야함
|
||||
// 조회 결과에서 번호만 Set으로
|
||||
Set<String> usedSet =
|
||||
usedEntities.stream()
|
||||
.map(MapInkx5kEntity::getMapidcdNo)
|
||||
.collect(java.util.stream.Collectors.toSet());
|
||||
|
||||
// 필터 후 저장
|
||||
List<MapSheetLearn5kEntity> toSave =
|
||||
buffer.stream().filter(e -> usedSet.contains(String.valueOf(e.getMapSheetNum()))).toList();
|
||||
|
||||
if (!toSave.isEmpty()) {
|
||||
mapSheetLearn5kRepository.saveAll(toSave);
|
||||
mapSheetLearn5kRepository.flush();
|
||||
}
|
||||
|
||||
entityManager.clear();
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,4 +22,9 @@ public interface MapInkx5kRepositoryCustom {
|
||||
|
||||
Page<MapInkx5kEntity> getSceneListByPage(
|
||||
CommonUseStatus useInference, String searchVal, searchReq searchReq);
|
||||
|
||||
List<MapInkx5kEntity> findByMapSheetNumInAndUseInference(
|
||||
List<String> mapSheetNums, CommonUseStatus use);
|
||||
|
||||
Optional<MapInkx5kEntity> findByMapidList();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,9 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class MapInkx5kRepositoryImpl extends QuerydslRepositorySupport
|
||||
implements MapInkx5kRepositoryCustom {
|
||||
|
||||
@@ -127,6 +129,24 @@ public class MapInkx5kRepositoryImpl extends QuerydslRepositorySupport
|
||||
return new PageImpl<>(content, pageable, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MapInkx5kEntity> findByMapSheetNumInAndUseInference(
|
||||
List<String> mapSheetNums, CommonUseStatus use) {
|
||||
if (mapSheetNums == null || mapSheetNums.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.selectFrom(mapInkx5kEntity)
|
||||
.where(mapInkx5kEntity.mapidcdNo.in(mapSheetNums), mapInkx5kEntity.useInference.eq(use))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<MapInkx5kEntity> findByMapidList() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private BooleanExpression searchUseInference(CommonUseStatus useInference) {
|
||||
if (Objects.isNull(useInference)) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user