ensureAccepted 함수 InferenceCommonService 생성후 공통으로 생성

This commit is contained in:
2026-02-26 16:30:52 +09:00
parent cea1f01ed9
commit ea7e98d28e
7 changed files with 155 additions and 245 deletions

View File

@@ -79,12 +79,13 @@ public class InferenceResultCoreService {
}
/**
* 변화탐지 실행 정보 생성
* 변화탐지 실행 정보 생성 - 추론 실행 목록 테이블 저장, 도엽목록별 상태 체크 테이블 저장
*
* @param req
* @param req 추론 실행 목록 uuid
*/
public UUID saveInferenceInfo(InferenceResultDto.RegReq req, List<MngListDto> targetList) {
// 대표 도엽명 외 N 건 실행 문구 만들기 위해 Null, 중복 제거
List<MngListDto> distinctList =
targetList.stream()
.filter(dto -> dto.getMapSheetName() != null && !dto.getMapSheetName().isBlank())
@@ -124,17 +125,13 @@ public class InferenceResultCoreService {
mapSheetLearnEntity.setDetectingCnt(0L);
mapSheetLearnEntity.setTotalJobs((long) targetList.size());
// 회차는 국유인 반영할때 update로 변경됨
// mapSheetLearnEntity.setStage(
// mapSheetLearnRepository.getLearnStage(req.getCompareYyyy(), req.getTargetYyyy()));
// learn 테이블 저장
MapSheetLearnEntity savedLearn = mapSheetLearnRepository.save(mapSheetLearnEntity);
final int CHUNK = 1000;
List<MapSheetLearn5kEntity> buffer = new ArrayList<>(CHUNK);
// learn 도엽별 저장
// learn 도엽별 저장, 도엽수가 많으므로 1000개 씩 저장함
for (MngListDto mngDto : targetList) {
MapSheetLearn5kEntity entity = new MapSheetLearn5kEntity();
entity.setLearn(savedLearn);
@@ -145,12 +142,15 @@ public class InferenceResultCoreService {
buffer.add(entity);
if (buffer.size() == CHUNK) {
// 도엽별 저장 learn 5k 테이블
flushChunk(buffer);
buffer.clear();
}
}
// chunk 남은거 처리
if (!buffer.isEmpty()) {
// 도엽별 저장 learn 5k 테이블
flushChunk(buffer);
buffer.clear();
}
@@ -159,9 +159,9 @@ public class InferenceResultCoreService {
}
/**
* 도엽별 저장
* 도엽별 저장 learn 5k 테이블
*
* @param buffer
* @param buffer 저장 정보
*/
private void flushChunk(List<MapSheetLearn5kEntity> buffer) {
@@ -422,7 +422,7 @@ public class InferenceResultCoreService {
/**
* 추론 진행중인지 확인
*
* @return
* @return 추론 실행중인 추론 uuid, batch id
*/
public SaveInferenceAiDto getProcessing() {
MapSheetLearnEntity entity = mapSheetLearnRepository.getProcessing();

View File

@@ -431,6 +431,12 @@ public class MapSheetMngCoreService {
return mapSheetMngYearRepository.findByHstMapSheetCompareList(mngYyyy, mapId);
}
/**
* 연도 조건으로 실행 가능 도엽번호 조회
*
* @param year 연도
* @return 추론 가능한 도엽 정보
*/
public List<String> getMapSheetNumByHst(Integer year) {
List<MapSheetMngHstEntity> entity = mapSheetMngRepository.getMapSheetMngHst(year);
return entity.stream().map(MapSheetMngHstEntity::getMapSheetNum).toList();

View File

@@ -65,10 +65,10 @@ public interface MapSheetMngRepositoryCustom {
List<MapSheetMngDto.MngFilesDto> findByHstUidMapSheetFileList(Long hstUid);
/**
* 변화탐지 실행 가능 기준 연도 조회
* 기준년도 추론 실행 가능 도 조회
*
* @param req 조회 연도, 도엽번호 목록,
* @return
* @return 실행 가능한 도엽번호
*/
List<MngListDto> findByHstMapSheetTargetList(InferenceResultDto.RegReq req);
@@ -88,6 +88,12 @@ public interface MapSheetMngRepositoryCustom {
void insertMapSheetMngTile(@Valid AddReq addReq);
/**
* 연도 조건으로 도엽번호 조회
*
* @param year 연도
* @return 추론 가능한 도엽 정보
*/
List<MapSheetMngHstEntity> getMapSheetMngHst(Integer year);
List<MapSheetFallbackYearDto> findFallbackCompareYearByMapSheets(

View File

@@ -572,12 +572,6 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
return foundContent;
}
/**
* 기준년도 추론 실행 가능 도엽 조회
*
* @param req
* @return
*/
@Override
public List<MngListDto> findByHstMapSheetTargetList(InferenceResultDto.RegReq req) {
BooleanBuilder whereBuilder = new BooleanBuilder();
@@ -594,6 +588,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
BooleanBuilder likeBuilder = new BooleanBuilder();
// 부분 선택 실행이면 도엽번호 검색조건 추가
if (MapSheetScope.PART.getId().equals(req.getMapSheetScope())) {
List<String> list = req.getMapSheetNum();
if (list == null || list.isEmpty()) {
@@ -604,6 +599,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
if (prefix == null || prefix.isBlank()) {
continue;
}
// 50k 도엽번호로 Like 하여 5k 도엽번호 검색
likeBuilder.or(mapSheetMngHstEntity.mapSheetNum.like(prefix.trim() + "%"));
}
}