추론결과 저장 result 조회 조건 변경

This commit is contained in:
2026-03-06 11:09:34 +09:00
parent a3b2fd0c73
commit 15d082af0e
5 changed files with 45 additions and 4 deletions

View File

@@ -18,6 +18,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.ToString;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@@ -240,6 +241,7 @@ public class InferenceResultDto {
@Setter @Setter
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ToString
public static class RegReq { public static class RegReq {
@Schema(description = "제목", example = "2023-2024 변화탐지 테스트") @Schema(description = "제목", example = "2023-2024 변화탐지 테스트")

View File

@@ -128,6 +128,7 @@ public class InferenceResultService {
*/ */
@Transactional @Transactional
public UUID run(InferenceResultDto.RegReq req) { public UUID run(InferenceResultDto.RegReq req) {
log.info("inference start request = {}", req);
if (req.getDetectOption().equals(DetectOption.EXCL.getId())) { if (req.getDetectOption().equals(DetectOption.EXCL.getId())) {
// 추론 제외 일때 EXCL // 추론 제외 일때 EXCL
return runExcl(req); return runExcl(req);

View File

@@ -502,9 +502,13 @@ public class InferenceResultCoreService {
*/ */
@Transactional @Transactional
public void upsertGeomData(Long id) { public void upsertGeomData(Long id) {
// 추론 결과 목록 저장
Long analId = inferenceResultRepository.upsertGroupsFromMapSheetAnal(id); Long analId = inferenceResultRepository.upsertGroupsFromMapSheetAnal(id);
// 추론 결과 상세 저장
inferenceResultRepository.upsertGroupsFromInferenceResults(analId); inferenceResultRepository.upsertGroupsFromInferenceResults(analId);
// geom 목록 추론 결과 저장
inferenceResultRepository.upsertGeomsFromInferenceResults(analId); inferenceResultRepository.upsertGeomsFromInferenceResults(analId);
// 집계 추론 결과 저장
inferenceResultRepository.upsertSttcFromInferenceResults(analId); inferenceResultRepository.upsertSttcFromInferenceResults(analId);
} }

View File

@@ -6,14 +6,44 @@ import java.util.UUID;
public interface InferenceResultRepositoryCustom { public interface InferenceResultRepositoryCustom {
/**
* tb_map_sheet_anal_inference 추론 결과 목록 저장
*
* @param id learn 테이블 id
* @return
*/
Long upsertGroupsFromMapSheetAnal(Long id); Long upsertGroupsFromMapSheetAnal(Long id);
/**
* tb_map_sheet_anal_data_inference 추론 결과 상세 저장
*
* @param analId
* @return
*/
int upsertGroupsFromInferenceResults(Long analId); int upsertGroupsFromInferenceResults(Long analId);
/**
* tb_map_sheet_anal_data_inference_geom geom 목록 추론 결과 저장
*
* @param analId
* @return
*/
int upsertGeomsFromInferenceResults(Long analId); int upsertGeomsFromInferenceResults(Long analId);
/**
* tb_map_sheet_anal_sttc 집계 추론 결과 저장
*
* @param analId
* @return
*/
int upsertSttcFromInferenceResults(Long analId); int upsertSttcFromInferenceResults(Long analId);
/**
* 추론실행 목록 uuid 조회
*
* @param uuid 추론 uuid
* @return 추론 실행 정보
*/
Long getInferenceLearnIdByUuid(UUID uuid); Long getInferenceLearnIdByUuid(UUID uuid);
/** /**

View File

@@ -24,6 +24,7 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
@Override @Override
public Long upsertGroupsFromMapSheetAnal(Long id) { public Long upsertGroupsFromMapSheetAnal(Long id) {
// id = learn 테이블 id
String sql = String sql =
""" """
INSERT INTO tb_map_sheet_anal_inference ( INSERT INTO tb_map_sheet_anal_inference (
@@ -53,12 +54,12 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
:pendingStateId :pendingStateId
FROM tb_map_sheet_learn r FROM tb_map_sheet_learn r
WHERE r.id = :id WHERE r.id = :id
ON CONFLICT (stage, compare_yyyy, target_yyyy) ON CONFLICT (learn_id, compare_yyyy, target_yyyy)
DO UPDATE SET DO UPDATE SET
detecting_cnt = EXCLUDED.detecting_cnt, detecting_cnt = EXCLUDED.detecting_cnt,
anal_title = EXCLUDED.anal_title, anal_title = EXCLUDED.anal_title,
updated_dttm = now(), stage = EXCLUDED.stage,
learn_id = EXCLUDED.learn_id updated_dttm = now()
RETURNING anal_uid RETURNING anal_uid
"""; """;
@@ -117,7 +118,7 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
msl.target_yyyy, msl.target_yyyy,
r.map_id, r.map_id,
msl.stage msl.stage
ON CONFLICT (stage, compare_yyyy, target_yyyy, map_sheet_num) ON CONFLICT (anal_uid, compare_yyyy, target_yyyy, map_sheet_num)
DO UPDATE SET DO UPDATE SET
anal_uid = EXCLUDED.anal_uid, anal_uid = EXCLUDED.anal_uid,
ref_map_sheet_num = EXCLUDED.ref_map_sheet_num, ref_map_sheet_num = EXCLUDED.ref_map_sheet_num,
@@ -212,6 +213,9 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
AND r.map_id ~ '^[0-9]+$' AND r.map_id ~ '^[0-9]+$'
AND r.map_id::bigint = msadi.map_sheet_num AND r.map_id::bigint = msadi.map_sheet_num
WHERE msl.anal_uid = :analUid WHERE msl.anal_uid = :analUid
AND r.probability is not null
AND r.before_c is not null
AND r.before_p is not null
AND r.after_c is not null AND r.after_c is not null
AND r.after_p is not null AND r.after_p is not null
ORDER BY r.uid, r.created_date DESC NULLS LAST ORDER BY r.uid, r.created_date DESC NULLS LAST