shp 파일 생성 추가
This commit is contained in:
@@ -19,8 +19,8 @@ public class InferenceResultShpDto {
|
||||
// ===== 그룹 키 =====
|
||||
private Integer stage;
|
||||
private Long mapId;
|
||||
private Integer input1; // compare_yyyy
|
||||
private Integer input2; // target_yyyy
|
||||
private Integer input1; // compare_yyyy
|
||||
private Integer input2; // target_yyyy
|
||||
|
||||
// ===== 추론 결과 =====
|
||||
private Float cdProb;
|
||||
@@ -35,9 +35,7 @@ public class InferenceResultShpDto {
|
||||
private Geometry geometry;
|
||||
private Float area;
|
||||
|
||||
/**
|
||||
* Entity → DTO 변환
|
||||
*/
|
||||
/** Entity → DTO 변환 */
|
||||
public static Basic from(MapSheetAnalDataInferenceGeomEntity e) {
|
||||
Basic d = new Basic();
|
||||
|
||||
|
||||
@@ -17,16 +17,15 @@ public class InferenceResultShpService {
|
||||
private final InferenceResultShpCoreService coreService;
|
||||
private final ShpWriter shpWriter;
|
||||
|
||||
/**
|
||||
* inference_results -> tb_map_sheet_anal_data_inference / geom 업서트
|
||||
*/
|
||||
/** inference_results -> tb_map_sheet_anal_data_inference / geom 업서트 */
|
||||
@Transactional
|
||||
public void saveInferenceResultData() {
|
||||
coreService.buildInferenceData();
|
||||
}
|
||||
|
||||
/**
|
||||
* dataUid 단위로 재생성(덮어쓰기) - reset(inference false + geom 전부 false) - geom 엔티티 조회 -> dto 변환 - shp/geojson 생성 - 성공 geo_uid만 true - inference true
|
||||
* dataUid 단위로 재생성(덮어쓰기) - reset(inference false + geom 전부 false) - geom 엔티티 조회 -> dto 변환 -
|
||||
* shp/geojson 생성 - 성공 geo_uid만 true - inference true
|
||||
*/
|
||||
@Transactional
|
||||
public void createShpFile() {
|
||||
@@ -34,8 +33,8 @@ public class InferenceResultShpService {
|
||||
// TODO 경로는 설정으로 빼는 게 좋음
|
||||
String baseDir = System.getProperty("user.home") + "/export";
|
||||
|
||||
int batchSize = 100; // 한번에 처리할 data_uid 개수
|
||||
int geomLimit = 500000; // data_uid 당 최대 geom 로딩 수 (메모리/시간 보고 조절)
|
||||
int batchSize = 100; // 한번에 처리할 data_uid 개수
|
||||
int geomLimit = 500000; // data_uid 당 최대 geom 로딩 수 (메모리/시간 보고 조절)
|
||||
|
||||
List<Long> dataUids = coreService.findPendingDataUids(batchSize);
|
||||
|
||||
@@ -46,7 +45,7 @@ public class InferenceResultShpService {
|
||||
|
||||
// 2) 생성 대상 조회(엔티티)
|
||||
List<MapSheetAnalDataInferenceGeomEntity> entities =
|
||||
coreService.loadGeomEntities(dataUid, geomLimit);
|
||||
coreService.loadGeomEntities(dataUid, geomLimit);
|
||||
|
||||
if (entities.isEmpty()) {
|
||||
// 실패 상태(false 유지) -> 다음 배치에서 다시 덮어쓰기로 시도
|
||||
@@ -55,19 +54,19 @@ public class InferenceResultShpService {
|
||||
|
||||
// 3) 엔티티 -> DTO
|
||||
List<InferenceResultShpDto.Basic> dtoList =
|
||||
entities.stream().map(InferenceResultShpDto.Basic::from).toList();
|
||||
entities.stream().map(InferenceResultShpDto.Basic::from).toList();
|
||||
|
||||
// 4) 파일명: stage_mapSheet_compare_target (첫 row 기준)
|
||||
MapSheetAnalDataInferenceGeomEntity first = entities.get(0);
|
||||
String baseName =
|
||||
String.format(
|
||||
"%d_%d_%d_%d",
|
||||
first.getStage(),
|
||||
first.getMapSheetNum(),
|
||||
first.getCompareYyyy(),
|
||||
first.getTargetYyyy());
|
||||
String.format(
|
||||
"%d_%d_%d_%d",
|
||||
first.getStage(),
|
||||
first.getMapSheetNum(),
|
||||
first.getCompareYyyy(),
|
||||
first.getTargetYyyy());
|
||||
|
||||
String shpBasePath = baseDir + "/shp/" + baseName; // 확장자 없이
|
||||
String shpBasePath = baseDir + "/shp/" + baseName; // 확장자 없이
|
||||
String geoJsonPath = baseDir + "/geojson/" + baseName + ".geojson";
|
||||
|
||||
// 5) 파일 생성 (예외 발생 시 성공 마킹 안 됨 -> 다음에 덮어쓰기 재시도)
|
||||
@@ -75,7 +74,8 @@ public class InferenceResultShpService {
|
||||
shpWriter.writeGeoJson(geoJsonPath, dtoList);
|
||||
|
||||
// 6) 성공 마킹: geo_uid만 true
|
||||
List<Long> geoUids = entities.stream().map(MapSheetAnalDataInferenceGeomEntity::getGeoUid).toList();
|
||||
List<Long> geoUids =
|
||||
entities.stream().map(MapSheetAnalDataInferenceGeomEntity::getGeoUid).toList();
|
||||
coreService.markSuccess(dataUid, geoUids);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user