Merge remote-tracking branch 'origin/feat/infer_dev_260107' into feat/infer_dev_260107

This commit is contained in:
Moon
2026-01-15 12:37:51 +09:00
7 changed files with 88 additions and 54 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.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@@ -36,9 +37,10 @@ public class InferenceResultShpApiController {
@ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content), @ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
}) })
@PostMapping("/save") @PostMapping("/save/{id}")
public ApiResponseDto<InferenceResultShpDto.InferenceCntDto> saveInferenceData() { public ApiResponseDto<InferenceResultShpDto.InferenceCntDto> saveInferenceData(
return ApiResponseDto.createOK(inferenceResultShpService.saveInferenceResultData()); @PathVariable Long id) {
return ApiResponseDto.createOK(inferenceResultShpService.saveInferenceResultData(id));
} }
@Operation(summary = "shp 파일 생성", description = "shp 파일 생성") @Operation(summary = "shp 파일 생성", description = "shp 파일 생성")

View File

@@ -200,7 +200,7 @@ public class InferenceResultDto {
long m = (s % 3600) / 60; long m = (s % 3600) / 60;
long sec = s % 60; long sec = s % 60;
return String.format("%dH %dM %dS", h, m, sec); return String.format("%d시간 %d %d", h, m, sec);
} }
} }
@@ -462,9 +462,45 @@ public class InferenceResultDto {
@Schema(description = "분석도엽 명") @Schema(description = "분석도엽 명")
@JsonProperty("mapSheetScopeName") @JsonProperty("mapSheetScopeName")
private String getMapSheetScope() { private String getMapSheetScopeName() {
return MapSheetScope.getDescByCode(this.mapSheetScope); return MapSheetScope.getDescByCode(this.mapSheetScope);
} }
@Schema(description = "M1 사용시간")
@JsonProperty("m1ElapsedTim")
public String getM1ElapsedTime() {
return formatElapsedTime(this.m1ModelStartDttm, this.m1ModelEndDttm);
}
@Schema(description = "M2 사용시간")
@JsonProperty("m2ElapsedTim")
public String getM2ElapsedTime() {
return formatElapsedTime(this.m2ModelStartDttm, this.m2ModelEndDttm);
}
@Schema(description = "M3 사용시간")
@JsonProperty("m3ElapsedTim")
public String getM3ElapsedTime() {
return formatElapsedTime(this.m3ModelStartDttm, this.m3ModelEndDttm);
}
private String formatElapsedTime(ZonedDateTime start, ZonedDateTime end) {
if (start == null || end == null) {
return null;
}
Duration d = Duration.between(start, end);
if (d.isNegative()) {
d = d.negated();
}
long s = d.getSeconds();
long h = s / 3600;
long m = (s % 3600) / 60;
long sec = s % 60;
return String.format("%d시간 %d분 %d초", h, m, sec);
}
} }
@Getter @Getter

View File

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

View File

@@ -414,8 +414,4 @@ public class InferenceResultCoreService {
public Page<Geom> getInferenceGeomList(String uuid, SearchGeoReq searchGeoReq) { public Page<Geom> getInferenceGeomList(String uuid, SearchGeoReq searchGeoReq) {
return mapSheetLearnRepository.getInferenceGeomList(uuid, 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 테이블을 최신 상태로 구성한다. * tb_map_sheet_anal_data_inference_geom 테이블을 최신 상태로 구성한다.
*/ */
@Transactional @Transactional
public InferenceResultShpDto.InferenceCntDto buildInferenceData() { public InferenceResultShpDto.InferenceCntDto buildInferenceData(Long id) {
int sheetAnalDataCnt = repo.upsertGroupsFromMapSheetAnal(); // int sheetAnalDataCnt = repo.upsertGroupsFromMapSheetAnal();
int inferenceCnt = repo.upsertGroupsFromInferenceResults(); // int inferenceCnt = repo.upsertGroupsFromInferenceResults();
int inferenceGeomCnt = repo.upsertGeomsFromInferenceResults(); int inferenceGeomCnt = repo.upsertGeomsFromInferenceResults(id);
InferenceResultShpDto.InferenceCntDto cntDto = new InferenceResultShpDto.InferenceCntDto(); InferenceResultShpDto.InferenceCntDto cntDto = new InferenceResultShpDto.InferenceCntDto();
cntDto.setSheetAnalDataCnt(sheetAnalDataCnt); // cntDto.setSheetAnalDataCnt(sheetAnalDataCnt);
cntDto.setInferenceCnt(inferenceCnt); // cntDto.setInferenceCnt(inferenceCnt);
cntDto.setInferenceGeomCnt(inferenceGeomCnt); cntDto.setInferenceGeomCnt(inferenceGeomCnt);
return cntDto; return cntDto;

View File

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

View File

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