./gradlew :spotlessApply 실행

This commit is contained in:
2025-11-26 10:13:11 +09:00
parent 51a9f18af2
commit e96cff6ea5
54 changed files with 2095 additions and 2214 deletions

View File

@@ -4,200 +4,195 @@ import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnDataEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnDataGeomEntity;
import com.kamco.cd.kamcoback.postgres.repository.MapSheetLearnDataGeomRepository;
import com.kamco.cd.kamcoback.postgres.repository.MapSheetLearnDataRepository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* GeoJSON 데이터 조회 및 테스트용 API 컨트롤러
*/
/** GeoJSON 데이터 조회 및 테스트용 API 컨트롤러 */
@Slf4j
@RestController
@RequestMapping("/api/geojson/data")
@RequiredArgsConstructor
public class GeoJsonDataController {
private final MapSheetLearnDataRepository mapSheetLearnDataRepository;
private final MapSheetLearnDataGeomRepository mapSheetLearnDataGeomRepository;
private final MapSheetLearnDataRepository mapSheetLearnDataRepository;
private final MapSheetLearnDataGeomRepository mapSheetLearnDataGeomRepository;
/**
* 학습 데이터 목록 조회
*/
@GetMapping("/learn-data")
public ResponseEntity<Map<String, Object>> getLearnDataList(
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam(required = false) String dataState,
@RequestParam(required = false) String analState) {
try {
PageRequest pageRequest = PageRequest.of(page, size);
List<MapSheetLearnDataEntity> learnDataList;
if (dataState != null) {
learnDataList = mapSheetLearnDataRepository.findByDataState(dataState);
} else if (analState != null) {
learnDataList = mapSheetLearnDataRepository.findByAnalState(analState);
} else {
learnDataList = mapSheetLearnDataRepository.findAll(pageRequest).getContent();
}
Map<String, Object> response = new HashMap<>();
response.put("data", learnDataList);
response.put("totalCount", learnDataList.size());
response.put("page", page);
response.put("size", size);
return ResponseEntity.ok(response);
} catch (Exception e) {
log.error("학습 데이터 목록 조회 실패", e);
return ResponseEntity.internalServerError()
.body(Map.of("error", "데이터 조회 실패: " + e.getMessage()));
}
}
/** 학습 데이터 목록 조회 */
@GetMapping("/learn-data")
public ResponseEntity<Map<String, Object>> getLearnDataList(
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam(required = false) String dataState,
@RequestParam(required = false) String analState) {
try {
PageRequest pageRequest = PageRequest.of(page, size);
List<MapSheetLearnDataEntity> learnDataList;
/**
* 특정 학습 데이터 상세 조회
*/
@GetMapping("/learn-data/{id}")
public ResponseEntity<Map<String, Object>> getLearnDataDetail(@PathVariable Long id) {
try {
if (id == null) {
return ResponseEntity.badRequest()
.body(Map.of("error", "ID가 필요합니다."));
}
Optional<MapSheetLearnDataEntity> learnDataOpt = mapSheetLearnDataRepository.findById(id);
if (learnDataOpt.isEmpty()) {
return ResponseEntity.notFound().build();
}
MapSheetLearnDataEntity learnData = learnDataOpt.get();
List<MapSheetLearnDataGeomEntity> geometryList = mapSheetLearnDataGeomRepository.findByDataUid(id);
Map<String, Object> response = new HashMap<>();
response.put("learnData", learnData);
response.put("geometryData", geometryList);
response.put("geometryCount", geometryList.size());
return ResponseEntity.ok(response);
} catch (Exception e) {
log.error("학습 데이터 상세 조회 실패: {}", id, e);
return ResponseEntity.internalServerError()
.body(Map.of("error", "데이터 조회 실패: " + e.getMessage()));
}
}
if (dataState != null) {
learnDataList = mapSheetLearnDataRepository.findByDataState(dataState);
} else if (analState != null) {
learnDataList = mapSheetLearnDataRepository.findByAnalState(analState);
} else {
learnDataList = mapSheetLearnDataRepository.findAll(pageRequest).getContent();
}
/**
* Geometry 데이터 목록 조회
*/
@GetMapping("/geometry")
public ResponseEntity<Map<String, Object>> getGeometryDataList(
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam(required = false) Long dataUid,
@RequestParam(required = false) String geoType) {
try {
List<MapSheetLearnDataGeomEntity> geometryList;
if (dataUid != null) {
geometryList = mapSheetLearnDataGeomRepository.findByDataUid(dataUid);
} else if (geoType != null) {
geometryList = mapSheetLearnDataGeomRepository.findByGeoType(geoType);
} else {
PageRequest pageRequest = PageRequest.of(page, size);
geometryList = mapSheetLearnDataGeomRepository.findAll(pageRequest).getContent();
}
Map<String, Object> response = new HashMap<>();
response.put("data", geometryList);
response.put("totalCount", geometryList.size());
response.put("page", page);
response.put("size", size);
return ResponseEntity.ok(response);
} catch (Exception e) {
log.error("Geometry 데이터 목록 조회 실패", e);
return ResponseEntity.internalServerError()
.body(Map.of("error", "데이터 조회 실패: " + e.getMessage()));
}
}
Map<String, Object> response = new HashMap<>();
response.put("data", learnDataList);
response.put("totalCount", learnDataList.size());
response.put("page", page);
response.put("size", size);
/**
* 시스템 통계 정보 조회
*/
@GetMapping("/statistics")
public ResponseEntity<Map<String, Object>> getStatistics() {
try {
long totalLearnData = mapSheetLearnDataRepository.count();
long totalGeometryData = mapSheetLearnDataGeomRepository.count();
List<MapSheetLearnDataEntity> processedData = mapSheetLearnDataRepository.findByDataState("PROCESSED");
List<MapSheetLearnDataEntity> pendingAnalysis = mapSheetLearnDataRepository.findByAnalState("PENDING");
List<MapSheetLearnDataEntity> completedAnalysis = mapSheetLearnDataRepository.findByAnalState("COMPLETED");
List<MapSheetLearnDataEntity> errorAnalysis = mapSheetLearnDataRepository.findByAnalState("ERROR");
Map<String, Object> statistics = new HashMap<>();
statistics.put("totalLearnData", totalLearnData);
statistics.put("totalGeometryData", totalGeometryData);
statistics.put("processedDataCount", processedData.size());
statistics.put("pendingAnalysisCount", pendingAnalysis.size());
statistics.put("completedAnalysisCount", completedAnalysis.size());
statistics.put("errorAnalysisCount", errorAnalysis.size());
// 처리 완료율 계산
if (totalLearnData > 0) {
double completionRate = (double) completedAnalysis.size() / totalLearnData * 100;
statistics.put("completionRate", Math.round(completionRate * 100.0) / 100.0);
} else {
statistics.put("completionRate", 0.0);
}
return ResponseEntity.ok(Map.of(
"statistics", statistics,
"timestamp", java.time.Instant.now()
));
} catch (Exception e) {
log.error("통계 정보 조회 실패", e);
return ResponseEntity.internalServerError()
.body(Map.of("error", "통계 조회 실패: " + e.getMessage()));
}
return ResponseEntity.ok(response);
} catch (Exception e) {
log.error("학습 데이터 목록 조회 실패", e);
return ResponseEntity.internalServerError()
.body(Map.of("error", "데이터 조회 실패: " + e.getMessage()));
}
}
/**
* 데이터 상태별 카운트 조회
*/
@GetMapping("/status-counts")
public ResponseEntity<Map<String, Object>> getStatusCounts() {
try {
Map<String, Long> dataStateCounts = new HashMap<>();
Map<String, Long> analStateCounts = new HashMap<>();
// 데이터 상태별 카운트
dataStateCounts.put("PROCESSED", mapSheetLearnDataRepository.findByDataState("PROCESSED").size() + 0L);
dataStateCounts.put("PENDING", mapSheetLearnDataRepository.findByDataStateIsNullOrDataState("PENDING").size() + 0L);
// 분석 상태별 카운트
analStateCounts.put("PENDING", mapSheetLearnDataRepository.findByAnalState("PENDING").size() + 0L);
analStateCounts.put("COMPLETED", mapSheetLearnDataRepository.findByAnalState("COMPLETED").size() + 0L);
analStateCounts.put("ERROR", mapSheetLearnDataRepository.findByAnalState("ERROR").size() + 0L);
return ResponseEntity.ok(Map.of(
"dataStateCounts", dataStateCounts,
"analStateCounts", analStateCounts,
"timestamp", java.time.Instant.now()
));
} catch (Exception e) {
log.error("상태별 카운트 조회 실패", e);
return ResponseEntity.internalServerError()
.body(Map.of("error", "카운트 조회 실패: " + e.getMessage()));
}
/** 특정 학습 데이터 상세 조회 */
@GetMapping("/learn-data/{id}")
public ResponseEntity<Map<String, Object>> getLearnDataDetail(@PathVariable Long id) {
try {
if (id == null) {
return ResponseEntity.badRequest().body(Map.of("error", "ID가 필요합니다."));
}
Optional<MapSheetLearnDataEntity> learnDataOpt = mapSheetLearnDataRepository.findById(id);
if (learnDataOpt.isEmpty()) {
return ResponseEntity.notFound().build();
}
MapSheetLearnDataEntity learnData = learnDataOpt.get();
List<MapSheetLearnDataGeomEntity> geometryList =
mapSheetLearnDataGeomRepository.findByDataUid(id);
Map<String, Object> response = new HashMap<>();
response.put("learnData", learnData);
response.put("geometryData", geometryList);
response.put("geometryCount", geometryList.size());
return ResponseEntity.ok(response);
} catch (Exception e) {
log.error("학습 데이터 상세 조회 실패: {}", id, e);
return ResponseEntity.internalServerError()
.body(Map.of("error", "데이터 조회 실패: " + e.getMessage()));
}
}
}
/** Geometry 데이터 목록 조회 */
@GetMapping("/geometry")
public ResponseEntity<Map<String, Object>> getGeometryDataList(
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam(required = false) Long dataUid,
@RequestParam(required = false) String geoType) {
try {
List<MapSheetLearnDataGeomEntity> geometryList;
if (dataUid != null) {
geometryList = mapSheetLearnDataGeomRepository.findByDataUid(dataUid);
} else if (geoType != null) {
geometryList = mapSheetLearnDataGeomRepository.findByGeoType(geoType);
} else {
PageRequest pageRequest = PageRequest.of(page, size);
geometryList = mapSheetLearnDataGeomRepository.findAll(pageRequest).getContent();
}
Map<String, Object> response = new HashMap<>();
response.put("data", geometryList);
response.put("totalCount", geometryList.size());
response.put("page", page);
response.put("size", size);
return ResponseEntity.ok(response);
} catch (Exception e) {
log.error("Geometry 데이터 목록 조회 실패", e);
return ResponseEntity.internalServerError()
.body(Map.of("error", "데이터 조회 실패: " + e.getMessage()));
}
}
/** 시스템 통계 정보 조회 */
@GetMapping("/statistics")
public ResponseEntity<Map<String, Object>> getStatistics() {
try {
long totalLearnData = mapSheetLearnDataRepository.count();
long totalGeometryData = mapSheetLearnDataGeomRepository.count();
List<MapSheetLearnDataEntity> processedData =
mapSheetLearnDataRepository.findByDataState("PROCESSED");
List<MapSheetLearnDataEntity> pendingAnalysis =
mapSheetLearnDataRepository.findByAnalState("PENDING");
List<MapSheetLearnDataEntity> completedAnalysis =
mapSheetLearnDataRepository.findByAnalState("COMPLETED");
List<MapSheetLearnDataEntity> errorAnalysis =
mapSheetLearnDataRepository.findByAnalState("ERROR");
Map<String, Object> statistics = new HashMap<>();
statistics.put("totalLearnData", totalLearnData);
statistics.put("totalGeometryData", totalGeometryData);
statistics.put("processedDataCount", processedData.size());
statistics.put("pendingAnalysisCount", pendingAnalysis.size());
statistics.put("completedAnalysisCount", completedAnalysis.size());
statistics.put("errorAnalysisCount", errorAnalysis.size());
// 처리 완료율 계산
if (totalLearnData > 0) {
double completionRate = (double) completedAnalysis.size() / totalLearnData * 100;
statistics.put("completionRate", Math.round(completionRate * 100.0) / 100.0);
} else {
statistics.put("completionRate", 0.0);
}
return ResponseEntity.ok(
Map.of("statistics", statistics, "timestamp", java.time.Instant.now()));
} catch (Exception e) {
log.error("통계 정보 조회 실패", e);
return ResponseEntity.internalServerError()
.body(Map.of("error", "통계 조회 실패: " + e.getMessage()));
}
}
/** 데이터 상태별 카운트 조회 */
@GetMapping("/status-counts")
public ResponseEntity<Map<String, Object>> getStatusCounts() {
try {
Map<String, Long> dataStateCounts = new HashMap<>();
Map<String, Long> analStateCounts = new HashMap<>();
// 데이터 상태별 카운트
dataStateCounts.put(
"PROCESSED", mapSheetLearnDataRepository.findByDataState("PROCESSED").size() + 0L);
dataStateCounts.put(
"PENDING",
mapSheetLearnDataRepository.findByDataStateIsNullOrDataState("PENDING").size() + 0L);
// 분석 상태별 카운트
analStateCounts.put(
"PENDING", mapSheetLearnDataRepository.findByAnalState("PENDING").size() + 0L);
analStateCounts.put(
"COMPLETED", mapSheetLearnDataRepository.findByAnalState("COMPLETED").size() + 0L);
analStateCounts.put(
"ERROR", mapSheetLearnDataRepository.findByAnalState("ERROR").size() + 0L);
return ResponseEntity.ok(
Map.of(
"dataStateCounts", dataStateCounts,
"analStateCounts", analStateCounts,
"timestamp", java.time.Instant.now()));
} catch (Exception e) {
log.error("상태별 카운트 조회 실패", e);
return ResponseEntity.internalServerError()
.body(Map.of("error", "카운트 조회 실패: " + e.getMessage()));
}
}
}

View File

@@ -2,153 +2,133 @@ package com.kamco.cd.kamcoback.geojson.controller;
import com.kamco.cd.kamcoback.geojson.service.GeoJsonFileMonitorService;
import com.kamco.cd.kamcoback.geojson.service.GeometryConversionService;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* GeoJSON 파일 모니터링 및 처리 API 컨트롤러
*/
/** GeoJSON 파일 모니터링 및 처리 API 컨트롤러 */
@Slf4j
@RestController
@RequestMapping("/api/geojson")
@RequiredArgsConstructor
public class GeoJsonMonitorController {
private final GeoJsonFileMonitorService monitorService;
private final GeometryConversionService geometryConversionService;
private final GeoJsonFileMonitorService monitorService;
private final GeometryConversionService geometryConversionService;
/**
* 모니터링 상태 조회
*/
@GetMapping("/monitor/status")
public Map<String, Object> getMonitorStatus() {
return monitorService.getMonitorStatus();
}
/** 모니터링 상태 조회 */
@GetMapping("/monitor/status")
public Map<String, Object> getMonitorStatus() {
return monitorService.getMonitorStatus();
}
/**
* 시스템 통계 정보 조회
*/
@GetMapping("/monitor/stats")
public ResponseEntity<Map<String, Object>> getSystemStats() {
try {
Map<String, Object> stats = monitorService.getSystemStats();
return ResponseEntity.ok(stats);
} catch (Exception e) {
log.error("시스템 통계 조회 실패", e);
return ResponseEntity.internalServerError()
.body(Map.of(
"error", "시스템 통계 조회 실패: " + e.getMessage(),
"status", "error"
));
}
/** 시스템 통계 정보 조회 */
@GetMapping("/monitor/stats")
public ResponseEntity<Map<String, Object>> getSystemStats() {
try {
Map<String, Object> stats = monitorService.getSystemStats();
return ResponseEntity.ok(stats);
} catch (Exception e) {
log.error("시스템 통계 조회 실패", e);
return ResponseEntity.internalServerError()
.body(Map.of("error", "시스템 통계 조회 실패: " + e.getMessage(), "status", "error"));
}
}
/**
* 디렉토리 초기화 (수동 실행)
*/
@PostMapping("/monitor/init-directories")
public ResponseEntity<Map<String, Object>> initializeDirectories() {
try {
log.info("디렉토리 초기화 수동 실행 요청");
monitorService.initializeDirectoriesManually();
return ResponseEntity.ok(Map.of(
"message", "디렉토리 초기화가 완료되었습니다.",
"status", "success"
));
} catch (Exception e) {
log.error("디렉토리 초기화 실패", e);
return ResponseEntity.internalServerError()
.body(Map.of(
"error", "디렉토리 초기화 실패: " + e.getMessage(),
"status", "error"
));
}
}
/** 디렉토리 초기화 (수동 실행) */
@PostMapping("/monitor/init-directories")
public ResponseEntity<Map<String, Object>> initializeDirectories() {
try {
log.info("디렉토리 초기화 수동 실행 요청");
monitorService.initializeDirectoriesManually();
/**
* 수동으로 특정 파일 처리
*/
@PostMapping("/process/file")
public ResponseEntity<Map<String, Object>> processFileManually(@RequestParam String filePath) {
try {
log.info("수동 파일 처리 요청: {}", filePath);
monitorService.processFileManually(filePath);
return ResponseEntity.ok(Map.of(
"message", "파일 처리가 완료되었습니다.",
"filePath", filePath,
"status", "success"
));
} catch (Exception e) {
log.error("수동 파일 처리 실패: {}", filePath, e);
return ResponseEntity.internalServerError()
.body(Map.of(
"error", "파일 처리 실패: " + e.getMessage(),
"filePath", filePath,
"status", "error"
));
}
return ResponseEntity.ok(
Map.of(
"message", "디렉토리 초기화가 완료되었습니다.",
"status", "success"));
} catch (Exception e) {
log.error("디렉토리 초기화 실패", e);
return ResponseEntity.internalServerError()
.body(Map.of("error", "디렉토리 초기화 실패: " + e.getMessage(), "status", "error"));
}
}
/**
* 미처리된 Geometry 데이터 수동 변환
*/
@PostMapping("/process/geometry")
public ResponseEntity<Map<String, Object>> processUnprocessedGeometry() {
try {
log.info("미처리 Geometry 변환 수동 실행 요청");
List<Long> processedIds = geometryConversionService.processUnprocessedLearnData();
return ResponseEntity.ok(Map.of(
"message", "Geometry 변환이 완료되었습니다.",
"processedCount", processedIds.size(),
"processedIds", processedIds,
"status", "success"
));
} catch (Exception e) {
log.error("Geometry 변환 실패", e);
return ResponseEntity.internalServerError()
.body(Map.of(
"error", "Geometry 변환 실패: " + e.getMessage(),
"status", "error"
));
}
}
/** 수동으로 특정 파일 처리 */
@PostMapping("/process/file")
public ResponseEntity<Map<String, Object>> processFileManually(@RequestParam String filePath) {
try {
log.info("수동 파일 처리 요청: {}", filePath);
monitorService.processFileManually(filePath);
/**
* 특정 학습 데이터의 Geometry 변환
*/
@PostMapping("/process/geometry/convert")
public ResponseEntity<Map<String, Object>> convertSpecificGeometry(@RequestBody List<Long> learnDataIds) {
try {
if (learnDataIds == null || learnDataIds.isEmpty()) {
return ResponseEntity.badRequest()
.body(Map.of("error", "변환할 학습 데이터 ID가 없습니다."));
}
log.info("특정 학습 데이터 Geometry 변환 요청: {}", learnDataIds);
List<Long> geometryIds = geometryConversionService.convertToGeometryData(learnDataIds);
return ResponseEntity.ok(Map.of(
"message", "Geometry 변환이 완료되었습니다.",
"inputCount", learnDataIds.size(),
"outputCount", geometryIds.size(),
"geometryIds", geometryIds,
"status", "success"
));
} catch (Exception e) {
log.error("특정 Geometry 변환 실패: {}", learnDataIds, e);
return ResponseEntity.internalServerError()
.body(Map.of(
"error", "Geometry 변환 실패: " + e.getMessage(),
"status", "error"
));
}
return ResponseEntity.ok(
Map.of(
"message", "파일 처리가 완료되었습니다.",
"filePath", filePath,
"status", "success"));
} catch (Exception e) {
log.error("수동 파일 처리 실패: {}", filePath, e);
return ResponseEntity.internalServerError()
.body(
Map.of(
"error", "파일 처리 실패: " + e.getMessage(), "filePath", filePath, "status", "error"));
}
}
}
/** 미처리된 Geometry 데이터 수동 변환 */
@PostMapping("/process/geometry")
public ResponseEntity<Map<String, Object>> processUnprocessedGeometry() {
try {
log.info("미처리 Geometry 변환 수동 실행 요청");
List<Long> processedIds = geometryConversionService.processUnprocessedLearnData();
return ResponseEntity.ok(
Map.of(
"message",
"Geometry 변환이 완료되었습니다.",
"processedCount",
processedIds.size(),
"processedIds",
processedIds,
"status",
"success"));
} catch (Exception e) {
log.error("Geometry 변환 실패", e);
return ResponseEntity.internalServerError()
.body(Map.of("error", "Geometry 변환 실패: " + e.getMessage(), "status", "error"));
}
}
/** 특정 학습 데이터의 Geometry 변환 */
@PostMapping("/process/geometry/convert")
public ResponseEntity<Map<String, Object>> convertSpecificGeometry(
@RequestBody List<Long> learnDataIds) {
try {
if (learnDataIds == null || learnDataIds.isEmpty()) {
return ResponseEntity.badRequest().body(Map.of("error", "변환할 학습 데이터 ID가 없습니다."));
}
log.info("특정 학습 데이터 Geometry 변환 요청: {}", learnDataIds);
List<Long> geometryIds = geometryConversionService.convertToGeometryData(learnDataIds);
return ResponseEntity.ok(
Map.of(
"message",
"Geometry 변환이 완료되었습니다.",
"inputCount",
learnDataIds.size(),
"outputCount",
geometryIds.size(),
"geometryIds",
geometryIds,
"status",
"success"));
} catch (Exception e) {
log.error("특정 Geometry 변환 실패: {}", learnDataIds, e);
return ResponseEntity.internalServerError()
.body(Map.of("error", "Geometry 변환 실패: " + e.getMessage(), "status", "error"));
}
}
}