geojson 파일생성 api 추가
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.kamco.cd.kamcoback.inference;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
|
||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.Scene;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultShpDto;
|
||||
import com.kamco.cd.kamcoback.inference.service.InferenceResultShpService;
|
||||
@@ -10,20 +12,28 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
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 java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Tag(name = "추론결과 데이터 생성", description = "추론결과 데이터 생성 API")
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/inference/shp")
|
||||
public class InferenceResultShpApiController {
|
||||
|
||||
private final InferenceResultShpService inferenceResultShpService;
|
||||
public static final String MAP_ID =
|
||||
"{ \"mapIds\": [\"37716096\",\"37716095\",\"37716094\",\"37716091\",\"37716086\",\"37716085\",\"37716084\",\"37716083\",\"37716076\",\"37716066\",\"37716065\",\"37716064\",\"37716063\",\"37716061\",\"37716051\",\"37716011\"] }";
|
||||
|
||||
@Operation(summary = "추론결과 데이터 저장", description = "추론결과 데이터 저장")
|
||||
@ApiResponses(
|
||||
@@ -52,4 +62,29 @@ public class InferenceResultShpApiController {
|
||||
inferenceResultShpService.createShp(uuid);
|
||||
return ApiResponseDto.createOK(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "추론실행에 필요한 geojson 파일 생성", description = "추론실행에 필요한 geojson 파일 생성")
|
||||
@PostMapping("/geojson/{yyyy}/{mapSheetScope}/{detectOption}")
|
||||
public ApiResponseDto<Scene> createGeojson(
|
||||
@Schema(description = "년도") @PathVariable String yyyy,
|
||||
@Schema(description = "전체(ALL),부분(PART)", example = "PART") @PathVariable
|
||||
String mapSheetScope,
|
||||
@Schema(description = "추론제외(EXCL),이전 년도 도엽 사용(PREV)", example = "EXCL") @PathVariable
|
||||
String detectOption,
|
||||
@Schema(description = "5k도엽번호", example = MAP_ID) @RequestBody Map<String, Object> body) {
|
||||
|
||||
Object raw = body.get("mapIds");
|
||||
|
||||
if (raw == null) {
|
||||
throw new CustomApiException("BAD_REQUEST", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> mapIds = (List<String>) raw;
|
||||
|
||||
Scene scene =
|
||||
inferenceResultShpService.createGeojson(yyyy, mapSheetScope, detectOption, mapIds);
|
||||
|
||||
return ApiResponseDto.createOK(scene);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
package com.kamco.cd.kamcoback.inference.service;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.Scene;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceLearnDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultShpDto;
|
||||
import com.kamco.cd.kamcoback.postgres.core.InferenceResultCoreService;
|
||||
import com.kamco.cd.kamcoback.postgres.core.InferenceResultShpCoreService;
|
||||
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngCoreService;
|
||||
import com.kamco.cd.kamcoback.scheduler.service.ShpPipelineService;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -19,9 +24,11 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Transactional(readOnly = true)
|
||||
public class InferenceResultShpService {
|
||||
|
||||
private static final Logger log = LogManager.getLogger(InferenceResultShpService.class);
|
||||
private final InferenceResultShpCoreService coreService;
|
||||
private final InferenceResultCoreService inferenceResultCoreService;
|
||||
private final ShpPipelineService shpPipelineService;
|
||||
private final MapSheetMngCoreService mapSheetMngCoreService;
|
||||
|
||||
@Value("${mapsheet.shp.baseurl}")
|
||||
private String baseDir;
|
||||
@@ -59,4 +66,21 @@ public class InferenceResultShpService {
|
||||
// shp 파일 비동기 생성
|
||||
shpPipelineService.runPipeline(jarPath, datasetDir, batchId, dto.getUid());
|
||||
}
|
||||
|
||||
/**
|
||||
* 추론 실행전 geojson 파일 생성
|
||||
*
|
||||
* @param yyyy
|
||||
* @param mapSheetScope
|
||||
* @param detectOption
|
||||
* @param mapIds
|
||||
* @return
|
||||
*/
|
||||
public Scene createGeojson(
|
||||
String yyyy, String mapSheetScope, String detectOption, List<String> mapIds) {
|
||||
Scene getSceneInference =
|
||||
mapSheetMngCoreService.getSceneInference(yyyy, mapIds, mapSheetScope, detectOption);
|
||||
log.info("getSceneInference: {}", getSceneInference);
|
||||
return getSceneInference;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user