Merge pull request '[KC-103] 결과 테이블 적용' (#238) from feat/infer_dev_260107 into develop

Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/238
This commit is contained in:
2026-01-15 09:58:03 +09:00
6 changed files with 50 additions and 52 deletions

View File

@@ -10,6 +10,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -36,9 +37,10 @@ public class InferenceResultShpApiController {
@ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
})
@PostMapping("/save")
public ApiResponseDto<InferenceResultShpDto.InferenceCntDto> saveInferenceData() {
return ApiResponseDto.createOK(inferenceResultShpService.saveInferenceResultData());
@PostMapping("/save/{id}")
public ApiResponseDto<InferenceResultShpDto.InferenceCntDto> saveInferenceData(
@PathVariable Long id) {
return ApiResponseDto.createOK(inferenceResultShpService.saveInferenceResultData(id));
}
@Operation(summary = "shp 파일 생성", description = "shp 파일 생성")

View File

@@ -22,8 +22,8 @@ public class InferenceResultShpService {
/** inference_results 테이블을 기준으로 분석 결과 테이블과 도형 테이블을 최신 상태로 반영한다. */
@Transactional
public InferenceResultShpDto.InferenceCntDto saveInferenceResultData() {
return coreService.buildInferenceData();
public InferenceResultShpDto.InferenceCntDto saveInferenceResultData(Long id) {
return coreService.buildInferenceData(id);
}
/**

View File

@@ -414,8 +414,4 @@ public class InferenceResultCoreService {
public Page<Geom> getInferenceGeomList(String uuid, SearchGeoReq searchGeoReq) {
return mapSheetLearnRepository.getInferenceGeomList(uuid, searchGeoReq);
}
public void upsertGeomsFromInferenceResults(Long id) {
int inferenceGeomCnt = inferenceResultRepository.upsertGeomsFromInferenceResults();
}
}

View File

@@ -19,14 +19,14 @@ public class InferenceResultShpCoreService {
* tb_map_sheet_anal_data_inference_geom 테이블을 최신 상태로 구성한다.
*/
@Transactional
public InferenceResultShpDto.InferenceCntDto buildInferenceData() {
int sheetAnalDataCnt = repo.upsertGroupsFromMapSheetAnal();
int inferenceCnt = repo.upsertGroupsFromInferenceResults();
int inferenceGeomCnt = repo.upsertGeomsFromInferenceResults();
public InferenceResultShpDto.InferenceCntDto buildInferenceData(Long id) {
// int sheetAnalDataCnt = repo.upsertGroupsFromMapSheetAnal();
// int inferenceCnt = repo.upsertGroupsFromInferenceResults();
int inferenceGeomCnt = repo.upsertGeomsFromInferenceResults(id);
InferenceResultShpDto.InferenceCntDto cntDto = new InferenceResultShpDto.InferenceCntDto();
cntDto.setSheetAnalDataCnt(sheetAnalDataCnt);
cntDto.setInferenceCnt(inferenceCnt);
// cntDto.setSheetAnalDataCnt(sheetAnalDataCnt);
// cntDto.setInferenceCnt(inferenceCnt);
cntDto.setInferenceGeomCnt(inferenceGeomCnt);
return cntDto;

View File

@@ -9,7 +9,7 @@ public interface InferenceResultRepositoryCustom {
int upsertGroupsFromInferenceResults();
int upsertGeomsFromInferenceResults();
int upsertGeomsFromInferenceResults(Long id);
List<Long> findPendingDataUids(int limit);

View File

@@ -126,7 +126,7 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
* @return 반영된 행 수
*/
@Override
public int upsertGeomsFromInferenceResults() {
public int upsertGeomsFromInferenceResults(Long id) {
String sql =
"""
@@ -145,9 +145,7 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
geom_center,
area,
data_uid,
file_created_yn,
created_dttm,
updated_dttm
created_dttm
)
SELECT
x.uuid,
@@ -164,38 +162,40 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
ST_Centroid(x.geom),
x.area,
x.data_uid,
false,
x.created_dttm,
x.updated_dttm
x.created_dttm
FROM (
SELECT DISTINCT ON (r.uuid)
r.uuid,
r.stage,
SELECT DISTINCT ON (r.uid)
r.uid AS uuid,
di.stage AS stage,
r.cd_prob,
r.input1 AS compare_yyyy,
r.input2 AS target_yyyy,
r.map_id AS map_sheet_num,
r.before_class AS class_before_cd,
r.before_probability AS class_before_prob,
r.after_class AS class_after_cd,
r.after_probability AS class_after_prob,
CASE
WHEN r.map_id ~ '^[0-9]+$' THEN r.map_id::bigint
ELSE NULL
END AS map_sheet_num,
r.before_c AS class_before_cd,
r.before_p AS class_before_prob,
r.after_c AS class_after_cd,
r.after_p AS class_after_prob,
CASE
WHEN r.geometry IS NULL THEN NULL
WHEN LEFT(r.geometry, 2) = '01'
THEN ST_SetSRID(ST_GeomFromWKB(decode(r.geometry, 'hex')), 5186)
ELSE ST_GeomFromText(r.geometry, 5186)
ELSE ST_SetSRID(ST_GeomFromText(r.geometry), 5186)
END AS geom,
r.area,
di.data_uid,
r.created_dttm,
r.updated_dttm
FROM inference_results r
JOIN tb_map_sheet_anal_data_inference di
ON di.stage = r.stage
AND di.compare_yyyy = r.input1
AND di.target_yyyy = r.input2
AND di.map_sheet_num = r.map_id
ORDER BY r.uuid, r.updated_dttm DESC NULLS LAST, r.uid DESC
di.id AS data_uid,
r.created_date AS created_dttm
FROM inference_results_testing r
JOIN tb_map_sheet_learn di
ON r.batch_id IN (
di.m1_model_batch_id,
di.m2_model_batch_id,
di.m3_model_batch_id
)
where di.id = :id
ORDER BY r.uid, r.created_date DESC NULLS LAST
) x
ON CONFLICT (uuid)
DO UPDATE SET
@@ -214,7 +214,7 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
updated_dttm = now()
""";
return em.createNativeQuery(sql).executeUpdate();
return em.createNativeQuery(sql).setParameter("id", id).executeUpdate();
}
// ===============================