Merge branch 'develop' of ssh://192.168.2.126:2222/MVPTeam/kamco-cd-api into develop
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.kamco.cd.kamcoback.common.enums;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.utils.enums.CodeExpose;
|
||||
import com.kamco.cd.kamcoback.common.utils.enums.EnumType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@CodeExpose
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CrsType implements EnumType {
|
||||
EPSG_3857("Web Mercator, 웹지도 미터(EPSG:900913 동일)"),
|
||||
EPSG_4326("WGS84 위경도, GeoJSON/OSM 기본"),
|
||||
EPSG_5186("Korea 2000 중부 TM, 한국 SHP");
|
||||
|
||||
private final String desc;
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
@@ -54,8 +54,8 @@ public class ExternalJarRunner {
|
||||
public void run(String jarPath, String register, String layer) {
|
||||
List<String> args = new ArrayList<>();
|
||||
|
||||
addArg(args, "register", register);
|
||||
addArg(args, "layer", layer);
|
||||
addArg(args, "upload-shp", register);
|
||||
// addArg(args, "layer", layer);
|
||||
|
||||
execJar(jarPath, args);
|
||||
}
|
||||
|
||||
@@ -30,12 +30,14 @@ import java.util.stream.Stream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.geotools.coverage.grid.GridCoverage2D;
|
||||
import org.geotools.gce.geotiff.GeoTiffReader;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Slf4j
|
||||
public class FIleChecker {
|
||||
|
||||
static SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
@@ -138,7 +140,9 @@ public class FIleChecker {
|
||||
// null을 넣으면 전체 영역을 읽지 않고 메타데이터 위주로 체크하여 빠름
|
||||
GridCoverage2D coverage = reader.read(null);
|
||||
|
||||
if (coverage == null) return false;
|
||||
if (coverage == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 3. GIS 필수 정보(좌표계)가 있는지 확인
|
||||
// if (coverage.getCoordinateReferenceSystem() == null) {
|
||||
@@ -152,7 +156,9 @@ public class FIleChecker {
|
||||
return false;
|
||||
} finally {
|
||||
// 리소스 해제 (필수)
|
||||
if (reader != null) reader.dispose();
|
||||
if (reader != null) {
|
||||
reader.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +302,8 @@ public class FIleChecker {
|
||||
|
||||
boolean isValid =
|
||||
!NameValidator.containsKorean(folderNm)
|
||||
&& !NameValidator.containsWhitespaceRegex(folderNm);
|
||||
&& !NameValidator.containsWhitespaceRegex(folderNm)
|
||||
&& !parentFolderNm.equals("kamco-nfs");
|
||||
|
||||
File file = new File(fullPath);
|
||||
int childCnt = getChildFolderCount(file);
|
||||
@@ -586,7 +593,9 @@ public class FIleChecker {
|
||||
}
|
||||
|
||||
public static boolean checkExtensions(String fileName, String ext) {
|
||||
if (fileName == null) return false;
|
||||
if (fileName == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase().equals(ext)) {
|
||||
return false;
|
||||
@@ -690,6 +699,7 @@ public class FIleChecker {
|
||||
@Schema(name = "Folder", description = "폴더 정보")
|
||||
@Getter
|
||||
public static class Folder {
|
||||
|
||||
private final String folderNm;
|
||||
private final String parentFolderNm;
|
||||
private final String parentPath;
|
||||
|
||||
@@ -5,11 +5,9 @@ import java.net.InetAddress;
|
||||
import java.net.URLEncoder;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
public class NetUtils {
|
||||
|
||||
@@ -56,9 +54,8 @@ public class NetUtils {
|
||||
|
||||
public HttpHeaders jsonHeaders() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.setAccept(List.of(MediaType.APPLICATION_JSON));
|
||||
|
||||
headers.set(HttpHeaders.ACCEPT, "application/json;charset=UTF-8");
|
||||
headers.set(HttpHeaders.CONTENT_TYPE, "application/json;charset=UTF-8");
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,8 +465,7 @@ public class GlobalExceptionHandler {
|
||||
String stackTraceStr =
|
||||
Arrays.stream(stackTrace)
|
||||
.map(StackTraceElement::toString)
|
||||
.collect(Collectors.joining("\n"))
|
||||
.substring(0, 255);
|
||||
.collect(Collectors.joining("\n"));
|
||||
|
||||
String actionType = HeaderUtil.get(request, "kamco-action-type");
|
||||
|
||||
|
||||
@@ -85,7 +85,8 @@ public class SecurityConfig {
|
||||
"/api/model/file-chunk-upload",
|
||||
"/api/upload/file-chunk-upload",
|
||||
"/api/upload/chunk-upload-complete",
|
||||
"/api/change-detection/**")
|
||||
"/api/change-detection/**",
|
||||
"/api/layer/map/**")
|
||||
.permitAll()
|
||||
// 로그인한 사용자만 가능 IAM
|
||||
.requestMatchers(
|
||||
|
||||
@@ -1,72 +1,120 @@
|
||||
package com.kamco.cd.kamcoback.config.resttemplate;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.HttpServerErrorException;
|
||||
import org.springframework.web.client.HttpStatusCodeException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Component
|
||||
@Log4j2
|
||||
@RequiredArgsConstructor
|
||||
public class ExternalHttpClient {
|
||||
|
||||
private final RestTemplate restTemplate;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public <T> ExternalCallResult<T> call(
|
||||
String url, HttpMethod method, Object body, HttpHeaders headers, Class<T> responseType) {
|
||||
|
||||
HttpEntity<Object> entity = new HttpEntity<>(body, headers);
|
||||
// responseType 기반으로 Accept 동적 세팅
|
||||
HttpHeaders resolvedHeaders = resolveHeaders(headers, responseType);
|
||||
logRequestBody(body);
|
||||
|
||||
// 요청 로그
|
||||
log.info("[HTTP-REQ] {} {}", method, url);
|
||||
if (body != null) {
|
||||
log.debug("[HTTP-REQ-BODY] {}", body);
|
||||
}
|
||||
HttpEntity<Object> entity = new HttpEntity<>(body, resolvedHeaders);
|
||||
|
||||
try {
|
||||
// String: raw bytes -> UTF-8 string
|
||||
if (responseType == String.class) {
|
||||
ResponseEntity<byte[]> res = restTemplate.exchange(url, method, entity, byte[].class);
|
||||
String raw =
|
||||
(res.getBody() == null) ? null : new String(res.getBody(), StandardCharsets.UTF_8);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
T casted = (T) raw;
|
||||
return new ExternalCallResult<>(res.getStatusCodeValue(), true, casted, null);
|
||||
}
|
||||
|
||||
// byte[]: raw bytes로 받고, JSON이면 에러로 처리
|
||||
if (responseType == byte[].class) {
|
||||
ResponseEntity<byte[]> res = restTemplate.exchange(url, method, entity, byte[].class);
|
||||
|
||||
MediaType ct = res.getHeaders().getContentType();
|
||||
byte[] bytes = res.getBody();
|
||||
|
||||
if (isJsonLike(ct)) {
|
||||
String err = (bytes == null) ? null : new String(bytes, StandardCharsets.UTF_8);
|
||||
return new ExternalCallResult<>(res.getStatusCodeValue(), false, null, err);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
T casted = (T) bytes;
|
||||
return new ExternalCallResult<>(res.getStatusCodeValue(), true, casted, null);
|
||||
}
|
||||
|
||||
// DTO 등: 일반 역직렬화
|
||||
ResponseEntity<T> res = restTemplate.exchange(url, method, entity, responseType);
|
||||
return new ExternalCallResult<>(res.getStatusCodeValue(), true, res.getBody(), null);
|
||||
|
||||
int code = res.getStatusCodeValue();
|
||||
|
||||
// 응답 로그
|
||||
log.info("[HTTP-RES] {} {} -> {}", method, url, code);
|
||||
log.debug("[HTTP-RES-BODY] {}", res.getBody());
|
||||
|
||||
return new ExternalCallResult<>(code, code >= 200 && code < 300, res.getBody());
|
||||
|
||||
} catch (HttpClientErrorException.NotFound e) {
|
||||
log.info("[HTTP-RES] {} {} -> 404 (Not Found)", method, url);
|
||||
log.debug("[HTTP-RES-BODY] {}", e.getResponseBodyAsString());
|
||||
|
||||
return new ExternalCallResult<>(404, false, null);
|
||||
|
||||
} catch (HttpClientErrorException e) {
|
||||
// 기타 4xx
|
||||
log.warn(
|
||||
"[HTTP-ERR] {} {} -> {} body={}",
|
||||
method,
|
||||
url,
|
||||
e.getStatusCode().value(),
|
||||
e.getResponseBodyAsString());
|
||||
throw e;
|
||||
|
||||
} catch (HttpServerErrorException e) {
|
||||
// 5xx
|
||||
log.error(
|
||||
"[HTTP-ERR] {} {} -> {} body={}",
|
||||
method,
|
||||
url,
|
||||
e.getStatusCode().value(),
|
||||
e.getResponseBodyAsString());
|
||||
throw e;
|
||||
} catch (HttpStatusCodeException e) {
|
||||
return new ExternalCallResult<>(
|
||||
e.getStatusCode().value(), false, null, e.getResponseBodyAsString());
|
||||
}
|
||||
}
|
||||
|
||||
public record ExternalCallResult<T>(int statusCode, boolean success, T body) {}
|
||||
// 기존 resolveJsonHeaders를 "동적"으로 교체
|
||||
private HttpHeaders resolveHeaders(HttpHeaders headers, Class<?> responseType) {
|
||||
// 원본 headers를 그대로 쓰면 외부에서 재사용할 때 사이드이펙트 날 수 있어서 복사 권장
|
||||
HttpHeaders h = (headers == null) ? new HttpHeaders() : new HttpHeaders(headers);
|
||||
|
||||
// 요청 바디 기본은 JSON이라고 가정 (필요하면 호출부에서 덮어쓰기)
|
||||
if (h.getContentType() == null) {
|
||||
h.setContentType(MediaType.APPLICATION_JSON);
|
||||
}
|
||||
|
||||
// 호출부에서 Accept를 명시했으면 존중
|
||||
if (h.getAccept() != null && !h.getAccept().isEmpty()) {
|
||||
return h;
|
||||
}
|
||||
|
||||
// responseType 기반 Accept 자동 지정
|
||||
if (responseType == byte[].class) {
|
||||
h.setAccept(
|
||||
List.of(
|
||||
MediaType.APPLICATION_OCTET_STREAM,
|
||||
MediaType.valueOf("application/zip"),
|
||||
MediaType.APPLICATION_JSON // 실패(JSON 에러 바디) 대비
|
||||
));
|
||||
} else {
|
||||
h.setAccept(List.of(MediaType.APPLICATION_JSON));
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
private boolean isJsonLike(MediaType ct) {
|
||||
if (ct == null) return false;
|
||||
return ct.includes(MediaType.APPLICATION_JSON)
|
||||
|| "application/problem+json".equalsIgnoreCase(ct.toString());
|
||||
}
|
||||
|
||||
private void logRequestBody(Object body) {
|
||||
try {
|
||||
if (body != null) {
|
||||
log.info("[HTTP-REQ-BODY-JSON] {}", objectMapper.writeValueAsString(body));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("[HTTP-REQ-BODY-JSON] serialize failed: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public record ExternalCallResult<T>(int statusCode, boolean success, T body, String errBody) {}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.client.BufferingClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@@ -13,10 +14,20 @@ public class RestTemplateConfig {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate(RestTemplateBuilder builder) {
|
||||
SimpleClientHttpRequestFactory f = new SimpleClientHttpRequestFactory();
|
||||
f.setConnectTimeout(2000);
|
||||
f.setReadTimeout(3000);
|
||||
SimpleClientHttpRequestFactory baseFactory = new SimpleClientHttpRequestFactory();
|
||||
baseFactory.setConnectTimeout(2000);
|
||||
baseFactory.setReadTimeout(3000);
|
||||
|
||||
return builder.requestFactory(() -> f).additionalInterceptors(new RetryInterceptor()).build();
|
||||
RestTemplate rt =
|
||||
builder
|
||||
.requestFactory(() -> new BufferingClientHttpRequestFactory(baseFactory))
|
||||
.additionalInterceptors(new RetryInterceptor())
|
||||
.build();
|
||||
|
||||
// byte[] 응답은 무조건 raw로 읽게 강제 (Jackson이 끼어들 여지 제거)
|
||||
rt.getMessageConverters()
|
||||
.add(0, new org.springframework.http.converter.ByteArrayHttpMessageConverter());
|
||||
|
||||
return rt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.kamco.cd.kamcoback.config.resttemplate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.http.client.ClientHttpRequestExecution;
|
||||
import org.springframework.http.client.ClientHttpRequestInterceptor;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
|
||||
@Log4j2
|
||||
public class RetryInterceptor implements ClientHttpRequestInterceptor {
|
||||
|
||||
private static final int MAX_RETRY = 3;
|
||||
@@ -20,21 +23,25 @@ public class RetryInterceptor implements ClientHttpRequestInterceptor {
|
||||
|
||||
for (int attempt = 1; attempt <= MAX_RETRY; attempt++) {
|
||||
try {
|
||||
// HTTP 응답을 받으면(2xx/4xx/5xx 포함) 그대로 반환
|
||||
return execution.execute(request, body);
|
||||
log.info("[WIRE-REQ] {} {}", request.getMethod(), request.getURI());
|
||||
log.info("[WIRE-REQ-HEADERS] {}", request.getHeaders());
|
||||
log.info("[WIRE-REQ-BODY] {}", new String(body, StandardCharsets.UTF_8));
|
||||
|
||||
ClientHttpResponse response = execution.execute(request, body);
|
||||
|
||||
log.info("[WIRE-RES-STATUS] {}", response.getStatusCode());
|
||||
return response;
|
||||
|
||||
} catch (IOException e) {
|
||||
// 네트워크/타임아웃 등 I/O 예외만 재시도
|
||||
lastException = e;
|
||||
log.error("[WIRE-IO-ERR] attempt={} msg={}", attempt, e.getMessage(), e);
|
||||
}
|
||||
|
||||
// 마지막 시도가 아니면 대기
|
||||
if (attempt < MAX_RETRY) {
|
||||
sleep();
|
||||
}
|
||||
}
|
||||
|
||||
// 마지막 예외를 그대로 던져서 원인이 로그에 남게 함
|
||||
throw lastException;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.kamco.cd.kamcoback.gukyuin;
|
||||
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ResponseObj;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ChnDetectMastReqDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ChngDetectMastSearchDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LabelSendDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResReturn;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.DetectMastDto.Basic;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.DetectMastDto.DetectMastReq;
|
||||
@@ -18,6 +20,8 @@ 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 jakarta.validation.Valid;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -51,7 +55,7 @@ public class GukYuinApiController {
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PostMapping("/chn/mast/regist")
|
||||
public ApiResponseDto<ChngDetectMastDto.Basic> regist(
|
||||
public ApiResponseDto<ChngDetectMastDto.RegistResDto> regist(
|
||||
@RequestBody @Valid ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) {
|
||||
return ApiResponseDto.ok(gukYuinApiService.regist(chnDetectMastReq));
|
||||
}
|
||||
@@ -133,9 +137,9 @@ public class GukYuinApiController {
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
public ApiResponseDto<ChngDetectMastDto.ResultDto> selectChangeDetectionList(
|
||||
public ApiResponseDto<ChngDetectMastDto.ResultDto> selectChangeDetectionDetail(
|
||||
@PathVariable String chnDtctMstId) {
|
||||
return ApiResponseDto.ok(gukYuinApiService.list(chnDtctMstId));
|
||||
return ApiResponseDto.ok(gukYuinApiService.detail(chnDtctMstId));
|
||||
}
|
||||
|
||||
@Operation(summary = "국유in연동 가능여부 확인", description = "국유in연동 가능여부 확인")
|
||||
@@ -239,4 +243,20 @@ public class GukYuinApiController {
|
||||
@PathVariable String chnDtctObjtId, @PathVariable String lblYn) {
|
||||
return ApiResponseDto.ok(gukYuinApiService.updateChnDtctObjtLabelingYn(chnDtctObjtId, lblYn));
|
||||
}
|
||||
|
||||
@Operation(summary = "국유in연동 등록", description = "국유in연동 등록")
|
||||
@PostMapping("/mast/reg/{uuid}")
|
||||
public ApiResponseDto<ResponseObj> connectChnMastRegist(
|
||||
@Parameter(description = "uuid", example = "7a593d0e-76a8-4b50-8978-9af1fbe871af")
|
||||
@PathVariable
|
||||
UUID uuid) {
|
||||
return ApiResponseDto.ok(gukYuinApiService.connectChnMastRegist(uuid));
|
||||
}
|
||||
|
||||
@Operation(summary = "라벨 전송 완료 리스트", description = "라벨 전송 완료 리스트")
|
||||
@GetMapping("/label/send-list")
|
||||
public ApiResponseDto<List<LabelSendDto>> findLabelingCompleteSendList(
|
||||
@Parameter(description = "어제 날짜", example = "2026-01-29") LocalDate yesterday) {
|
||||
return ApiResponseDto.ok(gukYuinApiService.findLabelingCompleteSendList(yesterday));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.kamco.cd.kamcoback.gukyuin.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
@@ -66,13 +67,30 @@ public class ChngDetectMastDto {
|
||||
@AllArgsConstructor
|
||||
public static class ChnDetectMastReqDto {
|
||||
|
||||
private String cprsYr; // 비교년도 2023
|
||||
private String crtrYr; // 기준년도 2024
|
||||
private String chnDtctSno; // 차수 (1 | 2 | ...)
|
||||
private String chnDtctId; // 탐지아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성
|
||||
private String pathNm; // 탐지결과 절대경로명 /kamco_nas/export/{chnDtctId}
|
||||
private String reqEpno; // 사원번호
|
||||
private String reqIp; // 사원아이피
|
||||
@Schema(description = "비교년도", example = "2023")
|
||||
private String cprsYr;
|
||||
|
||||
@Schema(description = "기준년도", example = "2024")
|
||||
private String crtrYr;
|
||||
|
||||
@Schema(description = "차수", example = "1")
|
||||
private String chnDtctSno;
|
||||
|
||||
@Schema(
|
||||
description = "탐지아이디, UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성",
|
||||
example = "D5F192EC76D34F6592035BE63A84F591")
|
||||
private String chnDtctId;
|
||||
|
||||
@Schema(
|
||||
description = "탐지결과 절대경로명 /kamco_nas/export/{chnDtctId}",
|
||||
example = "/kamco-nfs/dataset/export/D5F192EC76D34F6592035BE63A84F591")
|
||||
private String pathNm;
|
||||
|
||||
@Schema(description = "사원번호", example = "123456")
|
||||
private String reqEpno;
|
||||
|
||||
@Schema(description = "사원아이피", example = "127.0.0.1")
|
||||
private String reqIp;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@@ -158,4 +176,44 @@ public class ChngDetectMastDto {
|
||||
private List<Basic> result;
|
||||
private Boolean success;
|
||||
}
|
||||
|
||||
@Schema(name = "RegistResDto", description = "reg 등록 후 리턴 형태")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class RegistResDto {
|
||||
|
||||
private Integer code;
|
||||
private String message;
|
||||
private Basic result;
|
||||
private Boolean success;
|
||||
}
|
||||
|
||||
@Schema(name = "LearnKeyDto", description = "learn 엔티티 key 정보")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class LearnKeyDto {
|
||||
|
||||
private Long id;
|
||||
private String uid;
|
||||
private String chnDtctMstId;
|
||||
}
|
||||
|
||||
@Schema(name = "LabelSendDto", description = "라벨링 전송한 목록")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class LabelSendDto {
|
||||
|
||||
private String chnDtctObjtId;
|
||||
private String labelerId;
|
||||
private ZonedDateTime labelerWorkDttm;
|
||||
private String reviewerId;
|
||||
private ZonedDateTime reviewerWorkDttm;
|
||||
private ZonedDateTime labelSendDttm;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,13 @@
|
||||
package com.kamco.cd.kamcoback.gukyuin.dto;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.utils.enums.EnumType;
|
||||
import java.util.UUID;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class GukYuinDto {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class GukYuinLinkableRes {
|
||||
|
||||
private boolean linkable;
|
||||
// private GukYuinLinkFailCode code;
|
||||
private String message;
|
||||
}
|
||||
|
||||
/** 실패 코드 enum */
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@@ -39,10 +31,42 @@ public class GukYuinDto {
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class GukYuinLinkableRes {
|
||||
|
||||
private boolean linkable;
|
||||
// private GukYuinLinkFailCode code;
|
||||
private String message;
|
||||
}
|
||||
|
||||
// Repository가 반환할 Fact(조회 결과)
|
||||
public record GukYuinLinkFacts(
|
||||
boolean existsLearn,
|
||||
boolean isPartScope,
|
||||
boolean hasRunningInference,
|
||||
boolean hasOtherUnfinishedGukYuin) {}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public static class LearnInfo {
|
||||
|
||||
private Long id;
|
||||
private UUID uuid;
|
||||
private Integer compareYyyy;
|
||||
private Integer targetYyyy;
|
||||
private Integer stage;
|
||||
private String uid;
|
||||
private String applyStatus;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public static class GeomUidDto {
|
||||
|
||||
private Long geoUid;
|
||||
private String resultUid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ public enum GukYuinStatus implements EnumType {
|
||||
IN_PROGRESS("진행중"),
|
||||
GUK_COMPLETED("국유인 매핑 완료"),
|
||||
PNU_COMPLETED("PNU 싱크 완료"),
|
||||
PNU_FAILED("PNU 싱크 중 에러"),
|
||||
CANCELED("취소");
|
||||
|
||||
private final String desc;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.kamco.cd.kamcoback.gukyuin.service;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.utils.NetUtils;
|
||||
import com.kamco.cd.kamcoback.common.utils.UserUtil;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiLogFunction;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ApiResponseCode;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ResponseObj;
|
||||
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient;
|
||||
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto;
|
||||
@@ -8,22 +12,33 @@ import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto.ContBasic;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto.ResultContDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto.ResultPnuDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ChnDetectMastReqDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LabelSendDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResReturn;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResultDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GukYuinLinkFacts;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GukYuinLinkFailCode;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GukYuinLinkableRes;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.LearnInfo;
|
||||
import com.kamco.cd.kamcoback.log.dto.EventStatus;
|
||||
import com.kamco.cd.kamcoback.log.dto.EventType;
|
||||
import com.kamco.cd.kamcoback.postgres.core.GukYuinCoreService;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.AuditLogEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.log.AuditLogRepository;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
@Transactional
|
||||
@RequiredArgsConstructor
|
||||
public class GukYuinApiService {
|
||||
|
||||
@@ -31,6 +46,9 @@ public class GukYuinApiService {
|
||||
private final ExternalHttpClient externalHttpClient;
|
||||
private final NetUtils netUtils = new NetUtils();
|
||||
|
||||
private final UserUtil userUtil;
|
||||
private final AuditLogRepository auditLogRepository;
|
||||
|
||||
@Value("${spring.profiles.active:local}")
|
||||
private String profile;
|
||||
|
||||
@@ -41,25 +59,42 @@ public class GukYuinApiService {
|
||||
private String gukyuinCdiUrl;
|
||||
|
||||
@Transactional
|
||||
public ChngDetectMastDto.Basic regist(ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) {
|
||||
public ChngDetectMastDto.RegistResDto regist(
|
||||
ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) {
|
||||
|
||||
String url = gukyuinCdiUrl + "/chn/mast/regist";
|
||||
|
||||
String myip = netUtils.getLocalIP();
|
||||
chnDetectMastReq.setReqIp(myip);
|
||||
chnDetectMastReq.setReqEpno("1234567"); // TODO
|
||||
chnDetectMastReq.setReqEpno(userUtil.getEmployeeNo());
|
||||
|
||||
ExternalCallResult<ChngDetectMastDto.Basic> result =
|
||||
ExternalCallResult<ChngDetectMastDto.RegistResDto> result =
|
||||
externalHttpClient.call(
|
||||
url,
|
||||
HttpMethod.POST,
|
||||
chnDetectMastReq,
|
||||
netUtils.jsonHeaders(),
|
||||
ChngDetectMastDto.Basic.class);
|
||||
ChngDetectMastDto.RegistResDto.class);
|
||||
|
||||
ChngDetectMastDto.Basic resultBody = result.body();
|
||||
gukyuinCoreService.updateGukYuinMastRegResult(resultBody);
|
||||
ChngDetectMastDto.RegistResDto resultBody = result.body();
|
||||
Boolean success = false;
|
||||
if (resultBody != null) {
|
||||
ChngDetectMastDto.Basic registRes = resultBody.getResult();
|
||||
// 추론 회차에 applyStatus, applyStatusDttm 업데이트
|
||||
gukyuinCoreService.updateGukYuinMastRegResult(registRes);
|
||||
|
||||
// anal_inference 에도 국유인 반영여부, applyDttm 업데이트
|
||||
gukyuinCoreService.updateAnalInferenceApplyDttm(registRes);
|
||||
success = resultBody.getSuccess();
|
||||
}
|
||||
|
||||
this.insertGukyuinAuditLog(
|
||||
EventType.ADDED.getId(),
|
||||
myip,
|
||||
userUtil.getId(),
|
||||
url.replace(gukyuinUrl, ""),
|
||||
chnDetectMastReq,
|
||||
success);
|
||||
return resultBody;
|
||||
}
|
||||
|
||||
@@ -69,7 +104,7 @@ public class GukYuinApiService {
|
||||
|
||||
String myip = netUtils.getLocalIP();
|
||||
chnDetectMastReq.setReqIp(myip);
|
||||
chnDetectMastReq.setReqEpno("1234567"); // TODO
|
||||
chnDetectMastReq.setReqEpno(userUtil.getEmployeeNo());
|
||||
|
||||
ExternalCallResult<ChngDetectMastDto.Basic> result =
|
||||
externalHttpClient.call(
|
||||
@@ -82,11 +117,18 @@ public class GukYuinApiService {
|
||||
ChngDetectMastDto.Basic resultBody = result.body();
|
||||
gukyuinCoreService.updateGukYuinMastRegRemove(resultBody);
|
||||
|
||||
this.insertGukyuinAuditLog(
|
||||
EventType.REMOVE.getId(),
|
||||
myip,
|
||||
userUtil.getId(),
|
||||
url.replace(gukyuinUrl, ""),
|
||||
chnDetectMastReq,
|
||||
true); // TODO : successFail 여부
|
||||
return new ResReturn("success", "탐지결과 삭제 되었습니다.");
|
||||
}
|
||||
|
||||
// 등록목록 1개 확인
|
||||
public ChngDetectMastDto.ResultDto list(String chnDtctMstId) {
|
||||
public ChngDetectMastDto.ResultDto detail(String chnDtctMstId) {
|
||||
|
||||
String url = gukyuinCdiUrl + "/chn/mast/list/" + chnDtctMstId;
|
||||
|
||||
@@ -94,6 +136,13 @@ public class GukYuinApiService {
|
||||
externalHttpClient.call(
|
||||
url, HttpMethod.GET, null, netUtils.jsonHeaders(), ChngDetectMastDto.ResultDto.class);
|
||||
|
||||
this.insertGukyuinAuditLog(
|
||||
EventType.DETAIL.getId(),
|
||||
netUtils.getLocalIP(),
|
||||
userUtil.getId(),
|
||||
url.replace(gukyuinUrl, ""),
|
||||
null,
|
||||
result.body().getSuccess());
|
||||
return result.body();
|
||||
}
|
||||
|
||||
@@ -108,6 +157,13 @@ public class GukYuinApiService {
|
||||
externalHttpClient.call(
|
||||
url, HttpMethod.GET, null, netUtils.jsonHeaders(), ChngDetectMastDto.ResultDto.class);
|
||||
|
||||
this.insertGukyuinAuditLog(
|
||||
EventType.LIST.getId(),
|
||||
netUtils.getLocalIP(),
|
||||
userUtil.getId(),
|
||||
url.replace(gukyuinUrl, ""),
|
||||
null,
|
||||
result.body().getSuccess());
|
||||
return result.body();
|
||||
}
|
||||
|
||||
@@ -188,6 +244,14 @@ public class GukYuinApiService {
|
||||
}
|
||||
}
|
||||
|
||||
this.insertGukyuinAuditLog(
|
||||
EventType.LIST.getId(),
|
||||
netUtils.getLocalIP(),
|
||||
userUtil.getId(),
|
||||
url.replace(gukyuinUrl, ""),
|
||||
null,
|
||||
result.body().getSuccess());
|
||||
|
||||
return result.body();
|
||||
}
|
||||
|
||||
@@ -202,6 +266,14 @@ public class GukYuinApiService {
|
||||
netUtils.jsonHeaders(),
|
||||
ChngDetectContDto.ResultPnuDto.class);
|
||||
|
||||
this.insertGukyuinAuditLog(
|
||||
EventType.DETAIL.getId(),
|
||||
netUtils.getLocalIP(),
|
||||
userUtil.getId(),
|
||||
url.replace(gukyuinUrl, ""),
|
||||
null,
|
||||
result.body().getSuccess());
|
||||
|
||||
return result.body();
|
||||
}
|
||||
|
||||
@@ -218,6 +290,14 @@ public class GukYuinApiService {
|
||||
|
||||
ChngDetectContDto.ResultPnuDto dto = result.body();
|
||||
|
||||
this.insertGukyuinAuditLog(
|
||||
EventType.MODIFIED.getId(),
|
||||
netUtils.getLocalIP(),
|
||||
userUtil.getId(),
|
||||
url.replace(gukyuinUrl, ""),
|
||||
null,
|
||||
result.body().getSuccess());
|
||||
|
||||
return new ResReturn(dto.getCode() > 200000 ? "fail" : "success", dto.getMessage());
|
||||
}
|
||||
|
||||
@@ -232,6 +312,13 @@ public class GukYuinApiService {
|
||||
netUtils.jsonHeaders(),
|
||||
ChngDetectContDto.ResultContDto.class);
|
||||
|
||||
this.insertGukyuinAuditLog(
|
||||
EventType.LIST.getId(),
|
||||
netUtils.getLocalIP(),
|
||||
userUtil.getId(),
|
||||
url.replace(gukyuinUrl, ""),
|
||||
null,
|
||||
result.body().getSuccess());
|
||||
return result.body();
|
||||
}
|
||||
|
||||
@@ -242,6 +329,74 @@ public class GukYuinApiService {
|
||||
externalHttpClient.call(
|
||||
url, HttpMethod.GET, null, netUtils.jsonHeaders(), ChngDetectMastDto.ResultDto.class);
|
||||
|
||||
this.insertGukyuinAuditLog(
|
||||
EventType.DETAIL.getId(),
|
||||
netUtils.getLocalIP(),
|
||||
userUtil.getId(),
|
||||
url.replace(gukyuinUrl, ""),
|
||||
null,
|
||||
result.body().getSuccess());
|
||||
|
||||
return result.body();
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
|
||||
public void insertGukyuinAuditLog(
|
||||
String actionType,
|
||||
String myIp,
|
||||
Long userUid,
|
||||
String requestUri,
|
||||
Object requestBody,
|
||||
boolean successFail) {
|
||||
try {
|
||||
AuditLogEntity log =
|
||||
new AuditLogEntity(
|
||||
userUid,
|
||||
EventType.fromName(actionType),
|
||||
successFail ? EventStatus.SUCCESS : EventStatus.FAILED,
|
||||
"GUKYUIN", // 메뉴도 국유인으로 하나 따기
|
||||
myIp,
|
||||
requestUri,
|
||||
requestBody == null ? null : ApiLogFunction.cutRequestBody(requestBody.toString()),
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
auditLogRepository.save(log);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public ResponseObj connectChnMastRegist(UUID uuid) {
|
||||
// uuid로 추론 회차 조회
|
||||
LearnInfo info = gukyuinCoreService.findMapSheetLearnInfo(uuid);
|
||||
// if (info.getApplyStatus() != null &&
|
||||
// !info.getApplyStatus().equals(GukYuinStatus.PENDING.getId()))
|
||||
// {
|
||||
// return new ResponseObj(ApiResponseCode.DUPLICATE_DATA, "이미 국유인 연동을 한 추론 회차입니다.");
|
||||
// }
|
||||
|
||||
// 비교년도,기준년도로 전송한 데이터 있는지 확인 후 회차 번호 생성
|
||||
Integer maxStage =
|
||||
gukyuinCoreService.findMapSheetLearnYearStage(info.getCompareYyyy(), info.getTargetYyyy());
|
||||
|
||||
// reqDto 셋팅
|
||||
ChnDetectMastReqDto reqDto = new ChnDetectMastReqDto();
|
||||
reqDto.setCprsYr(String.valueOf(info.getCompareYyyy()));
|
||||
reqDto.setCrtrYr(String.valueOf(info.getTargetYyyy()));
|
||||
reqDto.setChnDtctSno(String.valueOf(maxStage + 1));
|
||||
reqDto.setChnDtctId(info.getUid());
|
||||
reqDto.setPathNm("/kamco-nfs/dataset/export/" + info.getUid());
|
||||
|
||||
// 국유인 /chn/mast/regist 전송
|
||||
this.regist(reqDto);
|
||||
|
||||
return new ResponseObj(ApiResponseCode.OK, "");
|
||||
}
|
||||
|
||||
public List<LabelSendDto> findLabelingCompleteSendList(LocalDate yesterday) {
|
||||
return gukyuinCoreService.findLabelingCompleteSendList(yesterday);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,13 @@ package com.kamco.cd.kamcoback.layer;
|
||||
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.IsMapYn;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.LayerMapDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.OrderReq;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.SearchReq;
|
||||
import com.kamco.cd.kamcoback.layer.service.LayerService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -76,10 +79,24 @@ public class LayerApiController {
|
||||
})
|
||||
@PostMapping("/save/{layerType}")
|
||||
public ApiResponseDto<UUID> save(
|
||||
@PathVariable String layerType, @RequestBody LayerDto.AddReq dto) {
|
||||
@Schema(description = "TILE,GEOJSON,WMS,WMTS", example = "GEOJSON") @PathVariable
|
||||
String layerType,
|
||||
@RequestBody LayerDto.AddReq dto) {
|
||||
return ApiResponseDto.ok(layerService.saveLayers(layerType, dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "순서 변경", description = "순서 변경 api")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "201",
|
||||
description = "등록 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = Void.class))),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PutMapping("/order")
|
||||
public ApiResponseDto<Void> updateOrder(@RequestBody List<OrderReq> dto) {
|
||||
layerService.orderUpdate(dto);
|
||||
@@ -152,6 +169,24 @@ public class LayerApiController {
|
||||
return ApiResponseDto.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "맵 노출여부 수정", description = "맵 노출여부 수정 api")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "201",
|
||||
description = "수정 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = Void.class))),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PutMapping("/update-map/{uuid}")
|
||||
public ApiResponseDto<Void> updateIsMap(@PathVariable UUID uuid, @RequestBody IsMapYn isMapYn) {
|
||||
layerService.updateIsMap(uuid, isMapYn);
|
||||
return ApiResponseDto.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "wmts tile 조회", description = "wmts tile 조회 api")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@@ -187,4 +222,55 @@ public class LayerApiController {
|
||||
public ApiResponseDto<List<String>> getWmsTile() {
|
||||
return ApiResponseDto.ok(layerService.getWmsTitle());
|
||||
}
|
||||
|
||||
@Operation(summary = "변화지도 레이어 조회", description = "변화지도 레이어 조회")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "검색 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
array = @ArraySchema(schema = @Schema(implementation = String.class)))),
|
||||
@ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping("/map/change-detection")
|
||||
public ApiResponseDto<List<LayerMapDto>> changeDetectionMap() {
|
||||
return ApiResponseDto.ok(layerService.findLayerMapList("change-detection"));
|
||||
}
|
||||
|
||||
@Operation(summary = "라벨링 툴 레이어 조회", description = "라벨링 툴 레이어 조회")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "검색 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
array = @ArraySchema(schema = @Schema(implementation = String.class)))),
|
||||
@ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping("/map/labeling")
|
||||
public ApiResponseDto<List<LayerMapDto>> labelingMap() {
|
||||
return ApiResponseDto.ok(layerService.findLayerMapList("labeling"));
|
||||
}
|
||||
|
||||
@Operation(summary = "년도별 tile Url(before,after 모두 조회)", description = "년도별 tile Url")
|
||||
@GetMapping("/tile-url")
|
||||
public ApiResponseDto<LayerDto.YearTileDto> getChangeDetectionTileUrl(
|
||||
@Parameter(description = "이전 년도", example = "2023") @RequestParam Integer beforeYear,
|
||||
@Parameter(description = "이후 년도", example = "2024") @RequestParam Integer afterYear) {
|
||||
return ApiResponseDto.ok(layerService.getChangeDetectionTileUrl(beforeYear, afterYear));
|
||||
}
|
||||
|
||||
@Operation(summary = "년도별 tile Url(년도 1개만 조회)", description = "년도별 tile Url")
|
||||
@GetMapping("/tile-url-year")
|
||||
public ApiResponseDto<LayerDto.TileUrlDto> getChangeDetectionTileOneYearUrl(
|
||||
@Parameter(description = "년도", example = "2023") @RequestParam Integer year) {
|
||||
return ApiResponseDto.ok(layerService.getChangeDetectionTileOneYearUrl(year));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package com.kamco.cd.kamcoback.layer.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.math.BigDecimal;
|
||||
@@ -12,11 +17,17 @@ import lombok.Setter;
|
||||
|
||||
public class LayerDto {
|
||||
|
||||
public enum MapType {
|
||||
CHANGE_MAP,
|
||||
LABELING_MAP
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "LayerBasic")
|
||||
public static class Basic {
|
||||
|
||||
@Schema(description = "uuid")
|
||||
private UUID uuid;
|
||||
|
||||
@@ -48,6 +59,7 @@ public class LayerDto {
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "LayerDetail")
|
||||
public static class Detail {
|
||||
|
||||
@Schema(description = "uuid")
|
||||
private UUID uuid;
|
||||
|
||||
@@ -96,6 +108,9 @@ public class LayerDto {
|
||||
@JsonFormatDttm
|
||||
@Schema(description = "등록일시")
|
||||
private ZonedDateTime createdDttm;
|
||||
|
||||
@Schema(description = "좌표계")
|
||||
private String crs;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@@ -104,7 +119,7 @@ public class LayerDto {
|
||||
@Schema(name = "LayerAddReq")
|
||||
public static class AddReq {
|
||||
|
||||
@Schema(description = "title")
|
||||
@Schema(description = "title WMS, WMTS 선택한 tile")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "설명")
|
||||
@@ -133,6 +148,9 @@ public class LayerDto {
|
||||
|
||||
@Schema(description = "zoom max", example = "18")
|
||||
private Short max;
|
||||
|
||||
@Schema(description = "좌표계", example = "EPSG_3857")
|
||||
private String crs;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@@ -153,6 +171,7 @@ public class LayerDto {
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class SearchReq {
|
||||
|
||||
private String tag;
|
||||
private String layerType;
|
||||
}
|
||||
@@ -162,6 +181,7 @@ public class LayerDto {
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class TileAddReqDto {
|
||||
|
||||
@Schema(description = "설명", example = "배경지도 입니다.")
|
||||
private String description;
|
||||
|
||||
@@ -189,4 +209,224 @@ public class LayerDto {
|
||||
@Schema(description = "zoom max", example = "18")
|
||||
private Short max;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(name = "LayerMapDto")
|
||||
public static class LayerMapDto {
|
||||
|
||||
@Schema(example = "WMTS", description = "유형 (TILE/GEOJSON/WMTS/WMS)")
|
||||
private String layerType;
|
||||
|
||||
@Schema(description = "title")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "설명")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "태그")
|
||||
private String tag;
|
||||
|
||||
@Schema(description = "순서")
|
||||
private Long sortOrder;
|
||||
|
||||
@Schema(description = "url")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "좌측상단 경도", example = "126.0")
|
||||
private BigDecimal minLon;
|
||||
|
||||
@Schema(description = "좌측상단 위도", example = "34.0")
|
||||
private BigDecimal minLat;
|
||||
|
||||
@Schema(description = "우측하단 경도", example = "130.0")
|
||||
private BigDecimal maxLon;
|
||||
|
||||
@Schema(description = "우측하단 위도", example = "38.5")
|
||||
private BigDecimal maxLat;
|
||||
|
||||
@Schema(description = "zoom min", example = "5")
|
||||
private Short minZoom;
|
||||
|
||||
@Schema(description = "zoom max", example = "18")
|
||||
private Short maxZoom;
|
||||
|
||||
@Schema(description = "bbox")
|
||||
private JsonNode bbox;
|
||||
|
||||
@JsonIgnore private String bboxGeometry;
|
||||
|
||||
@Schema(description = "uuid")
|
||||
private UUID uuid;
|
||||
|
||||
@JsonIgnore private String rawJsonString;
|
||||
|
||||
@Schema(description = "rawJson")
|
||||
private JsonNode rawJson;
|
||||
|
||||
@Schema(description = "crs")
|
||||
private String crs;
|
||||
|
||||
public LayerMapDto(
|
||||
String layerType,
|
||||
String tag,
|
||||
Long sortOrder,
|
||||
String url,
|
||||
BigDecimal minLon,
|
||||
BigDecimal minLat,
|
||||
BigDecimal maxLon,
|
||||
BigDecimal maxLat,
|
||||
Short minZoom,
|
||||
Short maxZoom,
|
||||
String bboxGeometry,
|
||||
UUID uuid,
|
||||
String rawJsonString,
|
||||
String crs) {
|
||||
this.layerType = layerType;
|
||||
this.tag = tag;
|
||||
this.sortOrder = sortOrder;
|
||||
this.url = url;
|
||||
this.minLon = minLon;
|
||||
this.minLat = minLat;
|
||||
this.maxLon = maxLon;
|
||||
this.maxLat = maxLat;
|
||||
this.minZoom = minZoom;
|
||||
this.maxZoom = maxZoom;
|
||||
this.bboxGeometry = bboxGeometry;
|
||||
this.uuid = uuid;
|
||||
this.rawJsonString = rawJsonString;
|
||||
|
||||
JsonNode geoJson = null;
|
||||
JsonNode rawJson = null;
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
if (bboxGeometry != null) {
|
||||
try {
|
||||
geoJson = mapper.readTree(bboxGeometry);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (rawJsonString != null) {
|
||||
try {
|
||||
rawJson = mapper.readTree(rawJsonString);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
this.rawJson = rawJson;
|
||||
this.bbox = geoJson;
|
||||
this.crs = crs;
|
||||
}
|
||||
|
||||
@JsonProperty("workspace")
|
||||
public String getWorkSpace() {
|
||||
return "cd";
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "TileUrlDto", description = "Tile Url 정보")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public static class TileUrlDto {
|
||||
|
||||
@Schema(description = "mngYyyy")
|
||||
private Integer mngYyyy;
|
||||
|
||||
@Schema(description = "url")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "태그")
|
||||
private String tag;
|
||||
|
||||
@Schema(description = "좌측상단 경도", example = "126.0")
|
||||
private BigDecimal minLon;
|
||||
|
||||
@Schema(description = "좌측상단 위도", example = "34.0")
|
||||
private BigDecimal minLat;
|
||||
|
||||
@Schema(description = "우측하단 경도", example = "130.0")
|
||||
private BigDecimal maxLon;
|
||||
|
||||
@Schema(description = "우측하단 위도", example = "38.5")
|
||||
private BigDecimal maxLat;
|
||||
|
||||
@Schema(description = "zoom min", example = "5")
|
||||
private Short minZoom;
|
||||
|
||||
@Schema(description = "zoom max", example = "18")
|
||||
private Short maxZoom;
|
||||
|
||||
@Schema(description = "bbox")
|
||||
private JsonNode bbox;
|
||||
|
||||
@JsonIgnore private String bboxGeometry;
|
||||
|
||||
private String crs;
|
||||
|
||||
public TileUrlDto(
|
||||
Integer mngYyyy,
|
||||
String url,
|
||||
String tag,
|
||||
BigDecimal minLon,
|
||||
BigDecimal minLat,
|
||||
BigDecimal maxLon,
|
||||
BigDecimal maxLat,
|
||||
Short minZoom,
|
||||
Short maxZoom,
|
||||
String bboxGeometry,
|
||||
String crs) {
|
||||
this.mngYyyy = mngYyyy;
|
||||
this.url = url;
|
||||
this.tag = tag;
|
||||
this.minLon = minLon;
|
||||
this.minLat = minLat;
|
||||
this.maxLon = maxLon;
|
||||
this.maxLat = maxLat;
|
||||
this.minZoom = minZoom;
|
||||
this.maxZoom = maxZoom;
|
||||
this.bboxGeometry = bboxGeometry;
|
||||
|
||||
JsonNode geoJson = null;
|
||||
|
||||
if (bboxGeometry != null) {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
geoJson = mapper.readTree(bboxGeometry);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
this.bbox = geoJson;
|
||||
this.crs = crs;
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "TileUrlDto", description = "Tile Url 정보")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class YearTileDto {
|
||||
|
||||
private TileUrlDto before;
|
||||
private TileUrlDto after;
|
||||
}
|
||||
|
||||
@Schema(name = "맵 노출 여부", description = "맵 노출 여부")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class IsMapYn {
|
||||
|
||||
@Schema(description = "CHANGE_MAP(변화지도), LABELING_MAP(라벨링지도)", example = "CHANGE_MAP")
|
||||
private String mapType;
|
||||
|
||||
@Schema(description = "노출여부 true, false", example = "true")
|
||||
private Boolean isMapYn;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,171 +2,46 @@ package com.kamco.cd.kamcoback.layer.dto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/** WMS 레이어 정보를 담는 DTO 클래스 */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WmsLayerInfo {
|
||||
|
||||
private String name;
|
||||
private String title;
|
||||
private String abstractText;
|
||||
private List<String> keywords;
|
||||
|
||||
private List<String> keywords = new ArrayList<>();
|
||||
private BoundingBox boundingBox;
|
||||
private List<String> crs; // 지원하는 좌표계 목록
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WmsLayerInfo{"
|
||||
+ "name='"
|
||||
+ name
|
||||
+ '\''
|
||||
+ ", title='"
|
||||
+ title
|
||||
+ '\''
|
||||
+ ", abstractText='"
|
||||
+ abstractText
|
||||
+ '\''
|
||||
+ ", keywords="
|
||||
+ keywords
|
||||
+ ", boundingBox="
|
||||
+ boundingBox
|
||||
+ ", crs="
|
||||
+ crs
|
||||
+ '}';
|
||||
}
|
||||
/** 지원하는 좌표계 목록 */
|
||||
private List<String> crs = new ArrayList<>();
|
||||
|
||||
public WmsLayerInfo() {
|
||||
this.keywords = new ArrayList<>();
|
||||
this.crs = new ArrayList<>();
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getAbstractText() {
|
||||
return abstractText;
|
||||
}
|
||||
|
||||
public void setAbstractText(String abstractText) {
|
||||
this.abstractText = abstractText;
|
||||
}
|
||||
|
||||
public List<String> getKeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public void setKeywords(List<String> keywords) {
|
||||
this.keywords = keywords;
|
||||
}
|
||||
/* ===== convenience methods ===== */
|
||||
|
||||
public void addKeyword(String keyword) {
|
||||
this.keywords.add(keyword);
|
||||
}
|
||||
|
||||
public BoundingBox getBoundingBox() {
|
||||
return boundingBox;
|
||||
}
|
||||
|
||||
public void setBoundingBox(BoundingBox boundingBox) {
|
||||
this.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
public List<String> getCrs() {
|
||||
return crs;
|
||||
}
|
||||
|
||||
public void setCrs(List<String> crs) {
|
||||
this.crs = crs;
|
||||
}
|
||||
|
||||
public void addCrs(String crsValue) {
|
||||
this.crs.add(crsValue);
|
||||
}
|
||||
|
||||
/** BoundingBox 정보를 담는 내부 클래스 */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class BoundingBox {
|
||||
|
||||
private String crs;
|
||||
private double minX;
|
||||
private double minY;
|
||||
private double maxX;
|
||||
private double maxY;
|
||||
|
||||
public BoundingBox(String crs, double minX, double minY, double maxX, double maxY) {
|
||||
this.crs = crs;
|
||||
this.minX = minX;
|
||||
this.minY = minY;
|
||||
this.maxX = maxX;
|
||||
this.maxY = maxY;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public String getCrs() {
|
||||
return crs;
|
||||
}
|
||||
|
||||
public void setCrs(String crs) {
|
||||
this.crs = crs;
|
||||
}
|
||||
|
||||
public double getMinX() {
|
||||
return minX;
|
||||
}
|
||||
|
||||
public void setMinX(double minX) {
|
||||
this.minX = minX;
|
||||
}
|
||||
|
||||
public double getMinY() {
|
||||
return minY;
|
||||
}
|
||||
|
||||
public void setMinY(double minY) {
|
||||
this.minY = minY;
|
||||
}
|
||||
|
||||
public double getMaxX() {
|
||||
return maxX;
|
||||
}
|
||||
|
||||
public void setMaxX(double maxX) {
|
||||
this.maxX = maxX;
|
||||
}
|
||||
|
||||
public double getMaxY() {
|
||||
return maxY;
|
||||
}
|
||||
|
||||
public void setMaxY(double maxY) {
|
||||
this.maxY = maxY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BoundingBox{"
|
||||
+ "crs='"
|
||||
+ crs
|
||||
+ '\''
|
||||
+ ", minX="
|
||||
+ minX
|
||||
+ ", minY="
|
||||
+ minY
|
||||
+ ", maxX="
|
||||
+ maxX
|
||||
+ ", maxY="
|
||||
+ maxY
|
||||
+ '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +1,51 @@
|
||||
package com.kamco.cd.kamcoback.layer.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/** WMTS 레이어 정보를 담는 DTO 클래스 */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WmtsLayerInfo {
|
||||
|
||||
public String identifier;
|
||||
public String title;
|
||||
public String abstractText;
|
||||
public List<String> keywords = new ArrayList<>();
|
||||
public BoundingBox boundingBox;
|
||||
public List<String> formats = new ArrayList<>();
|
||||
public List<String> tileMatrixSetLinks = new ArrayList<>();
|
||||
public List<ResourceUrl> resourceUrls = new ArrayList<>();
|
||||
public List<Style> styles = new ArrayList<>();
|
||||
private String identifier;
|
||||
private String title;
|
||||
private String abstractText;
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
private List<String> keywords = new ArrayList<>();
|
||||
private BoundingBox boundingBox;
|
||||
private List<String> formats = new ArrayList<>();
|
||||
private List<TileMatrixSetLink> tileMatrixSetLinks = new ArrayList<>();
|
||||
private List<ResourceUrl> resourceUrls = new ArrayList<>();
|
||||
private List<Style> styles = new ArrayList<>();
|
||||
|
||||
private List<String> matrixIds = new ArrayList<>(); // 20250130
|
||||
private String workspace; // 20250130
|
||||
|
||||
private List<TileMatric> tileMatrices = new ArrayList<>();
|
||||
|
||||
// (선택) 기존 add 메서드 유지하고 싶으면 남겨도 됨
|
||||
public void addTileMatric(TileMatric tileMatric) {
|
||||
this.tileMatrices.add(tileMatric);
|
||||
}
|
||||
|
||||
public void setAbstractText(String abstractText) {
|
||||
this.abstractText = abstractText;
|
||||
public void addMatrixId(String matrixId) {
|
||||
this.matrixIds.add(matrixId);
|
||||
}
|
||||
|
||||
public void setBoundingBox(BoundingBox boundingBox) {
|
||||
this.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WmtsLayerInfo{"
|
||||
+ "identifier='"
|
||||
+ identifier
|
||||
+ '\''
|
||||
+ ", title='"
|
||||
+ title
|
||||
+ '\''
|
||||
+ ", abstractText='"
|
||||
+ abstractText
|
||||
+ '\''
|
||||
+ ", keywords="
|
||||
+ keywords
|
||||
+ ", boundingBox="
|
||||
+ boundingBox
|
||||
+ ", formats="
|
||||
+ formats
|
||||
+ ", tileMatrixSetLinks="
|
||||
+ tileMatrixSetLinks
|
||||
+ ", resourceUrls="
|
||||
+ resourceUrls
|
||||
+ ", styles="
|
||||
+ styles
|
||||
+ '}';
|
||||
}
|
||||
|
||||
public void addKeyword(String keywowrd) {
|
||||
this.keywords.add(keywowrd);
|
||||
public void addKeyword(String keyword) {
|
||||
this.keywords.add(keyword);
|
||||
}
|
||||
|
||||
public void addFormat(String format) {
|
||||
this.formats.add(format);
|
||||
}
|
||||
|
||||
public void addTileMatrixSetLink(String tileMatrixSetLink) {
|
||||
public void addTileMatrixSetLink(TileMatrixSetLink tileMatrixSetLink) {
|
||||
this.tileMatrixSetLinks.add(tileMatrixSetLink);
|
||||
}
|
||||
|
||||
@@ -77,200 +58,61 @@ public class WmtsLayerInfo {
|
||||
}
|
||||
|
||||
/** BoundingBox 정보를 담는 내부 클래스 */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class BoundingBox {
|
||||
|
||||
public String crs;
|
||||
public double lowerCornerX;
|
||||
public double lowerCornerY;
|
||||
public double upperCornerX;
|
||||
public double upperCornerY;
|
||||
|
||||
public BoundingBox() {}
|
||||
|
||||
public BoundingBox(
|
||||
String crs,
|
||||
double lowerCornerX,
|
||||
double lowerCornerY,
|
||||
double upperCornerX,
|
||||
double upperCornerY) {
|
||||
this.crs = crs;
|
||||
this.lowerCornerX = lowerCornerX;
|
||||
this.lowerCornerY = lowerCornerY;
|
||||
this.upperCornerX = upperCornerX;
|
||||
this.upperCornerY = upperCornerY;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public String getCrs() {
|
||||
return crs;
|
||||
}
|
||||
|
||||
public void setCrs(String crs) {
|
||||
this.crs = crs;
|
||||
}
|
||||
|
||||
public double getLowerCornerX() {
|
||||
return lowerCornerX;
|
||||
}
|
||||
|
||||
public void setLowerCornerX(double lowerCornerX) {
|
||||
this.lowerCornerX = lowerCornerX;
|
||||
}
|
||||
|
||||
public double getLowerCornerY() {
|
||||
return lowerCornerY;
|
||||
}
|
||||
|
||||
public void setLowerCornerY(double lowerCornerY) {
|
||||
this.lowerCornerY = lowerCornerY;
|
||||
}
|
||||
|
||||
public double getUpperCornerX() {
|
||||
return upperCornerX;
|
||||
}
|
||||
|
||||
public void setUpperCornerX(double upperCornerX) {
|
||||
this.upperCornerX = upperCornerX;
|
||||
}
|
||||
|
||||
public double getUpperCornerY() {
|
||||
return upperCornerY;
|
||||
}
|
||||
|
||||
public void setUpperCornerY(double upperCornerY) {
|
||||
this.upperCornerY = upperCornerY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BoundingBox{"
|
||||
+ "crs='"
|
||||
+ crs
|
||||
+ '\''
|
||||
+ ", lowerCorner=["
|
||||
+ lowerCornerX
|
||||
+ ", "
|
||||
+ lowerCornerY
|
||||
+ ']'
|
||||
+ ", upperCorner=["
|
||||
+ upperCornerX
|
||||
+ ", "
|
||||
+ upperCornerY
|
||||
+ ']'
|
||||
+ '}';
|
||||
}
|
||||
private String crs;
|
||||
private double lowerCornerX;
|
||||
private double lowerCornerY;
|
||||
private double upperCornerX;
|
||||
private double upperCornerY;
|
||||
}
|
||||
|
||||
/** ResourceURL 정보를 담는 내부 클래스 (타일 URL 템플릿) */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ResourceUrl {
|
||||
|
||||
private String format;
|
||||
private String resourceType;
|
||||
private String template;
|
||||
|
||||
public ResourceUrl() {}
|
||||
|
||||
public ResourceUrl(String format, String resourceType, String template) {
|
||||
this.format = format;
|
||||
this.resourceType = resourceType;
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public String getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
public String getTemplate() {
|
||||
return template;
|
||||
}
|
||||
|
||||
public void setTemplate(String template) {
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ResourceUrl{"
|
||||
+ "format='"
|
||||
+ format
|
||||
+ '\''
|
||||
+ ", resourceType='"
|
||||
+ resourceType
|
||||
+ '\''
|
||||
+ ", template='"
|
||||
+ template
|
||||
+ '\''
|
||||
+ '}';
|
||||
}
|
||||
}
|
||||
|
||||
/** Style 정보를 담는 내부 클래스 */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class Style {
|
||||
|
||||
private String identifier;
|
||||
private String title;
|
||||
|
||||
@JsonProperty("default")
|
||||
private boolean isDefault;
|
||||
}
|
||||
|
||||
public Style() {}
|
||||
/** TileMatrix 정보를 담는 내부 클래스 */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class TileMatric {
|
||||
private String identifier;
|
||||
private String scaleDenominator;
|
||||
private String topLeftCorner;
|
||||
// private String tileWidth;
|
||||
// private String tileHeight;
|
||||
// private String matrixWidth;
|
||||
// private String matrixHeight;
|
||||
}
|
||||
|
||||
public Style(String identifier, String title, boolean isDefault) {
|
||||
this.identifier = identifier;
|
||||
this.title = title;
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
/** TileMatrixSetLink 정보를 담는 내부 클래스 */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class TileMatrixSetLink {
|
||||
private String tileMatrixSet;
|
||||
private List<String> zoomLevels = new ArrayList<>();
|
||||
|
||||
// Getters and Setters
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public boolean isDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public void setDefault(boolean isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Style{"
|
||||
+ "identifier='"
|
||||
+ identifier
|
||||
+ '\''
|
||||
+ ", title='"
|
||||
+ title
|
||||
+ '\''
|
||||
+ ", isDefault="
|
||||
+ isDefault
|
||||
+ '}';
|
||||
public void addZoomLevel(String zoomLevel) {
|
||||
this.zoomLevels.add(zoomLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,10 @@ import com.kamco.cd.kamcoback.common.enums.LayerType;
|
||||
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.Basic;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.IsMapYn;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.LayerMapDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.OrderReq;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.TileUrlDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.WmsDto.WmsAddDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.WmsDto.WmsAddReqDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.WmsLayerInfo;
|
||||
@@ -14,6 +17,7 @@ import com.kamco.cd.kamcoback.postgres.core.MapLayerCoreService;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -27,6 +31,12 @@ public class LayerService {
|
||||
private final WmtsService wmtsService;
|
||||
private final WmsService wmsService;
|
||||
|
||||
@Value("${layer.geoserver-url}")
|
||||
private String geoserverUrl;
|
||||
|
||||
@Value("${layer.path}")
|
||||
private String geoserverPath;
|
||||
|
||||
/**
|
||||
* 지도 레이어 관리 목록
|
||||
*
|
||||
@@ -55,7 +65,7 @@ public class LayerService {
|
||||
}
|
||||
|
||||
case GEOJSON -> {
|
||||
mapLayerCoreService.saveGeoJson(dto);
|
||||
return mapLayerCoreService.saveGeoJson(dto);
|
||||
}
|
||||
|
||||
case WMTS -> {
|
||||
@@ -81,7 +91,6 @@ public class LayerService {
|
||||
|
||||
default -> throw new CustomApiException("BAD_REQUEST", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,6 +133,17 @@ public class LayerService {
|
||||
mapLayerCoreService.update(uuid, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 맵 노출 여부 수정
|
||||
*
|
||||
* @param uuid
|
||||
* @param isMapYn
|
||||
*/
|
||||
@Transactional
|
||||
public void updateIsMap(UUID uuid, IsMapYn isMapYn) {
|
||||
mapLayerCoreService.updateIsMap(uuid, isMapYn);
|
||||
}
|
||||
|
||||
/**
|
||||
* wmts tile 조회
|
||||
*
|
||||
@@ -159,4 +179,35 @@ public class LayerService {
|
||||
addDto.setTag(dto.getTag());
|
||||
return mapLayerCoreService.saveWms(addDto);
|
||||
}
|
||||
|
||||
public List<LayerMapDto> findLayerMapList(String type) {
|
||||
List<LayerMapDto> layerMapDtoList = mapLayerCoreService.findLayerMapList(type);
|
||||
layerMapDtoList.forEach(
|
||||
dto -> {
|
||||
if (dto.getLayerType().equals("WMS") || dto.getLayerType().equals("WMTS")) {
|
||||
dto.setUrl(
|
||||
String.format(
|
||||
"%s/%s/%s",
|
||||
trimSlash(geoserverUrl),
|
||||
trimSlash(geoserverPath),
|
||||
dto.getLayerType().toLowerCase()));
|
||||
}
|
||||
});
|
||||
return layerMapDtoList;
|
||||
}
|
||||
|
||||
private String trimSlash(String s) {
|
||||
if (s == null) {
|
||||
return "";
|
||||
}
|
||||
return s.replaceAll("/+$", "").replaceAll("^/+", "");
|
||||
}
|
||||
|
||||
public LayerDto.YearTileDto getChangeDetectionTileUrl(Integer beforeYear, Integer afterYear) {
|
||||
return mapLayerCoreService.getChangeDetectionTileUrl(beforeYear, afterYear);
|
||||
}
|
||||
|
||||
public TileUrlDto getChangeDetectionTileOneYearUrl(Integer year) {
|
||||
return mapLayerCoreService.getChangeDetectionTileOneYearUrl(year);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class WmtsService {
|
||||
List<String> titles = new ArrayList<>();
|
||||
|
||||
for (WmtsLayerInfo layer : layers) {
|
||||
titles.add(layer.title);
|
||||
titles.add(layer.getTitle()); // ✅ getter로 변경
|
||||
}
|
||||
return titles;
|
||||
}
|
||||
@@ -50,7 +50,14 @@ public class WmtsService {
|
||||
return getLayerInfoByTitle(geoserverUrl, workspace, tile);
|
||||
}
|
||||
|
||||
private List<WmtsLayerInfo> getAllLayers(String geoserverUrl, String workspace) {
|
||||
/**
|
||||
* WMTS Capabilities URL에서 모든 레이어 정보를 가져옵니다.
|
||||
*
|
||||
* @param geoserverUrl 예: http://localhost:8080
|
||||
* @param workspace 워크스페이스 이름
|
||||
* @return 모든 레이어 정보 리스트
|
||||
*/
|
||||
public List<WmtsLayerInfo> getAllLayers(String geoserverUrl, String workspace) {
|
||||
List<WmtsLayerInfo> layers = new ArrayList<>();
|
||||
try {
|
||||
// 1. XML 문서 로드 및 파싱
|
||||
@@ -75,7 +82,7 @@ public class WmtsService {
|
||||
String title = getChildValue(layerNode, "Title");
|
||||
|
||||
if (title != null && !title.trim().isEmpty()) {
|
||||
WmtsLayerInfo layerInfo = parseLayerNode(layerNode, title);
|
||||
WmtsLayerInfo layerInfo = parseLayerNode(workspace, doc, layerNode, title);
|
||||
layers.add(layerInfo);
|
||||
}
|
||||
}
|
||||
@@ -88,151 +95,6 @@ public class WmtsService {
|
||||
return layers;
|
||||
}
|
||||
|
||||
// 특정 노드 아래의 자식 태그 값 추출 (예: <Title>값)
|
||||
private String getChildValue(Node parent, String childName) {
|
||||
Node child = findChildNode(parent, childName);
|
||||
return (child != null) ? child.getTextContent() : null;
|
||||
}
|
||||
|
||||
// 이름으로 자식 노드 찾기 (Local Name 기준)
|
||||
private Node findChildNode(Node parent, String localName) {
|
||||
NodeList children = parent.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
Node node = children.item(i);
|
||||
// 네임스페이스 접두사(ows:, wmts:)를 무시하고 태그 이름 확인
|
||||
if (node.getNodeName().endsWith(":" + localName) || node.getNodeName().equals(localName)) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 레이어 노드를 Java 객체로 변환
|
||||
private WmtsLayerInfo parseLayerNode(Node layerNode, String title) {
|
||||
WmtsLayerInfo info = new WmtsLayerInfo();
|
||||
info.title = title;
|
||||
info.identifier = getChildValue(layerNode, "Identifier");
|
||||
info.abstractText = getChildValue(layerNode, "Abstract");
|
||||
|
||||
// Keywords 파싱
|
||||
// 구조: <ows:Keywords><ows:Keyword>...</ows:Keyword></ows:Keywords>
|
||||
info.keywords = getChildValues(layerNode, "Keywords", "Keyword");
|
||||
|
||||
// BoundingBox 파싱 (WGS84BoundingBox 기준)
|
||||
info.boundingBox = parseBoundingBox(layerNode);
|
||||
|
||||
// Formats 파싱
|
||||
info.formats = getChildValuesDirect(layerNode, "Format");
|
||||
|
||||
// TileMatrixSetLink 파싱
|
||||
// 구조: <TileMatrixSetLink><TileMatrixSet>...</TileMatrixSet></TileMatrixSetLink>
|
||||
info.tileMatrixSetLinks = getChildValues(layerNode, "TileMatrixSetLink", "TileMatrixSet");
|
||||
|
||||
// ResourceURL 파싱
|
||||
info.resourceUrls = parseResourceUrls(layerNode);
|
||||
|
||||
// Styles 파싱
|
||||
info.styles = parseStyles(layerNode);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
// 특정 노드 아래의 반복되는 자식 구조 값 추출 (예: Keywords -> Keyword)
|
||||
private List<String> getChildValues(Node parent, String wrapperName, String childName) {
|
||||
List<String> results = new ArrayList<>();
|
||||
Node wrapper = findChildNode(parent, wrapperName);
|
||||
if (wrapper != null) {
|
||||
NodeList children = wrapper.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
Node node = children.item(i);
|
||||
if (node.getNodeName().endsWith(childName)) {
|
||||
results.add(node.getTextContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private WmtsLayerInfo.BoundingBox parseBoundingBox(Node layerNode) {
|
||||
// 보통 <ows:WGS84BoundingBox>를 찾음
|
||||
Node bboxNode = findChildNode(layerNode, "WGS84BoundingBox");
|
||||
if (bboxNode == null) bboxNode = findChildNode(layerNode, "BoundingBox");
|
||||
|
||||
if (bboxNode != null) {
|
||||
WmtsLayerInfo.BoundingBox bbox = new WmtsLayerInfo.BoundingBox();
|
||||
bbox.crs = getAttributeValue(bboxNode, "crs"); // WGS84는 보통 CRS 속성이 없을 수 있음(Default EPSG:4326)
|
||||
|
||||
String lowerCorner = getChildValue(bboxNode, "LowerCorner");
|
||||
String upperCorner = getChildValue(bboxNode, "UpperCorner");
|
||||
|
||||
if (lowerCorner != null) {
|
||||
String[] coords = lowerCorner.split(" ");
|
||||
bbox.lowerCornerX = Double.parseDouble(coords[0]);
|
||||
bbox.lowerCornerY = Double.parseDouble(coords[1]);
|
||||
}
|
||||
if (upperCorner != null) {
|
||||
String[] coords = upperCorner.split(" ");
|
||||
bbox.upperCornerX = Double.parseDouble(coords[0]);
|
||||
bbox.upperCornerY = Double.parseDouble(coords[1]);
|
||||
}
|
||||
return bbox;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getAttributeValue(Node node, String attrName) {
|
||||
if (node.hasAttributes()) {
|
||||
Node attr = node.getAttributes().getNamedItem(attrName);
|
||||
if (attr != null) return attr.getNodeValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Wrapper 없이 바로 반복되는 값 추출 (예: Format)
|
||||
private List<String> getChildValuesDirect(Node parent, String childName) {
|
||||
List<String> results = new ArrayList<>();
|
||||
NodeList children = parent.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
Node node = children.item(i);
|
||||
if (node.getNodeName().endsWith(childName)) {
|
||||
results.add(node.getTextContent());
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private List<WmtsLayerInfo.ResourceUrl> parseResourceUrls(Node layerNode) {
|
||||
List<WmtsLayerInfo.ResourceUrl> list = new ArrayList<>();
|
||||
NodeList children = layerNode.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
Node node = children.item(i);
|
||||
if (node.getNodeName().contains("ResourceURL")) { // local-name check simplification
|
||||
WmtsLayerInfo.ResourceUrl url = new WmtsLayerInfo.ResourceUrl();
|
||||
url.setFormat(getAttributeValue(node, "format"));
|
||||
url.setResourceType(getAttributeValue(node, "resourceType"));
|
||||
url.setTemplate(getAttributeValue(node, "template"));
|
||||
list.add(url);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<WmtsLayerInfo.Style> parseStyles(Node layerNode) {
|
||||
List<WmtsLayerInfo.Style> styles = new ArrayList<>();
|
||||
NodeList children = layerNode.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
Node node = children.item(i);
|
||||
if (node.getNodeName().endsWith("Style")) {
|
||||
WmtsLayerInfo.Style style = new WmtsLayerInfo.Style();
|
||||
style.setDefault(Boolean.parseBoolean(getAttributeValue(node, "isDefault")));
|
||||
style.setIdentifier(getChildValue(node, "Identifier"));
|
||||
style.setTitle(getChildValue(node, "Title"));
|
||||
styles.add(style);
|
||||
}
|
||||
}
|
||||
return styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* WMTS Capabilities URL에서 특정 타이틀의 레이어 정보를 가져옵니다. // * @param capabilitiesUrl 예:
|
||||
* http://localhost:8080/geoserver/gwc/service/wmts?REQUEST=GetCapabilities
|
||||
@@ -268,7 +130,7 @@ public class WmtsService {
|
||||
|
||||
// 타이틀이 일치하면 객체 매핑 시작
|
||||
if (title != null && title.trim().equals(targetTitle)) {
|
||||
return parseLayerNode(layerNode, title);
|
||||
return parseLayerNode(workspace, doc, layerNode, title);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,4 +141,325 @@ public class WmtsService {
|
||||
|
||||
return null; // 찾지 못한 경우
|
||||
}
|
||||
|
||||
// 레이어 노드를 Java 객체로 변환 20250130
|
||||
private WmtsLayerInfo parseLayerNode(
|
||||
String workspace, Document doc, Node layerNode, String title) {
|
||||
WmtsLayerInfo info = new WmtsLayerInfo();
|
||||
|
||||
info.setWorkspace(workspace); // 20250130
|
||||
info.setTitle(title);
|
||||
info.setIdentifier(getChildValue(layerNode, "Identifier"));
|
||||
info.setAbstractText(getChildValue(layerNode, "Abstract"));
|
||||
|
||||
// Keywords 파싱
|
||||
info.setKeywords(getChildValues(layerNode, "Keywords", "Keyword"));
|
||||
|
||||
// BoundingBox 파싱 (WGS84BoundingBox 기준)
|
||||
info.setBoundingBox(parseBoundingBox(layerNode));
|
||||
|
||||
// Formats 파싱
|
||||
info.setFormats(getChildValuesDirect(layerNode, "Format"));
|
||||
|
||||
// TileMatrixSetLink 파싱 (TileMatrixSet + Zoom Levels)
|
||||
info.setTileMatrixSetLinks(parseTileMatrixSetLinks(layerNode));
|
||||
|
||||
// TileMatrixSetLimits에서 줌 레벨 추출 (개별 zoom 리스트)
|
||||
info.setMatrixIds(parseMatrixIds(layerNode)); // 20260130
|
||||
|
||||
// ResourceURL 파싱
|
||||
info.setResourceUrls(parseResourceUrls(layerNode));
|
||||
|
||||
// Styles 파싱
|
||||
info.setStyles(parseStyles(layerNode));
|
||||
|
||||
// TileMatrixSet의 TileMatrix 정보 파싱
|
||||
List<String> tileMatrixSetNames = new ArrayList<>();
|
||||
if (info.getTileMatrixSetLinks() != null) {
|
||||
for (WmtsLayerInfo.TileMatrixSetLink link : info.getTileMatrixSetLinks()) {
|
||||
tileMatrixSetNames.add(link.getTileMatrixSet());
|
||||
}
|
||||
}
|
||||
|
||||
info.setTileMatrices(parseTileMatrices(doc, tileMatrixSetNames));
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
// --- Helper Methods ---
|
||||
|
||||
private WmtsLayerInfo.BoundingBox parseBoundingBox(Node layerNode) {
|
||||
// 보통 <ows:WGS84BoundingBox>를 찾음
|
||||
Node bboxNode = findChildNode(layerNode, "WGS84BoundingBox");
|
||||
if (bboxNode == null) bboxNode = findChildNode(layerNode, "BoundingBox");
|
||||
|
||||
if (bboxNode != null) {
|
||||
WmtsLayerInfo.BoundingBox bbox = new WmtsLayerInfo.BoundingBox();
|
||||
|
||||
// WGS84는 CRS 속성이 없을 수 있음
|
||||
bbox.setCrs(getAttributeValue(bboxNode, "crs"));
|
||||
|
||||
String lowerCorner = getChildValue(bboxNode, "LowerCorner");
|
||||
String upperCorner = getChildValue(bboxNode, "UpperCorner");
|
||||
|
||||
if (lowerCorner != null) {
|
||||
String[] coords = lowerCorner.split(" ");
|
||||
bbox.setLowerCornerX(Double.parseDouble(coords[0]));
|
||||
bbox.setLowerCornerY(Double.parseDouble(coords[1]));
|
||||
}
|
||||
|
||||
if (upperCorner != null) {
|
||||
String[] coords = upperCorner.split(" ");
|
||||
bbox.setUpperCornerX(Double.parseDouble(coords[0]));
|
||||
bbox.setUpperCornerY(Double.parseDouble(coords[1]));
|
||||
}
|
||||
|
||||
return bbox;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<WmtsLayerInfo.ResourceUrl> parseResourceUrls(Node layerNode) {
|
||||
List<WmtsLayerInfo.ResourceUrl> list = new ArrayList<>();
|
||||
NodeList children = layerNode.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
Node node = children.item(i);
|
||||
if (node.getNodeName().contains("ResourceURL")) { // local-name check simplification
|
||||
WmtsLayerInfo.ResourceUrl url = new WmtsLayerInfo.ResourceUrl();
|
||||
url.setFormat(getAttributeValue(node, "format"));
|
||||
url.setResourceType(getAttributeValue(node, "resourceType"));
|
||||
url.setTemplate(getAttributeValue(node, "template"));
|
||||
list.add(url);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<WmtsLayerInfo.Style> parseStyles(Node layerNode) {
|
||||
List<WmtsLayerInfo.Style> styles = new ArrayList<>();
|
||||
NodeList children = layerNode.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
Node node = children.item(i);
|
||||
if (node.getNodeName().endsWith("Style")) {
|
||||
WmtsLayerInfo.Style style = new WmtsLayerInfo.Style();
|
||||
style.setDefault(Boolean.parseBoolean(getAttributeValue(node, "isDefault")));
|
||||
style.setIdentifier(getChildValue(node, "Identifier"));
|
||||
style.setTitle(getChildValue(node, "Title"));
|
||||
styles.add(style);
|
||||
}
|
||||
}
|
||||
return styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* TileMatrixSetLimits에서 줌 레벨을 추출합니다. 예: "EPSG:4326:0" → "0", "EPSG:4326:1" → "1"
|
||||
*
|
||||
* @param layerNode Layer 노드
|
||||
* @return 줌 레벨 문자열 리스트
|
||||
*/
|
||||
private List<String> parseMatrixIds(Node layerNode) {
|
||||
List<String> matrixIds = new ArrayList<>();
|
||||
NodeList children = layerNode.getChildNodes();
|
||||
|
||||
// 모든 TileMatrixSetLink 찾기
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
Node node = children.item(i);
|
||||
if (node.getNodeName().contains("TileMatrixSetLink")) {
|
||||
// TileMatrixSetLimits 찾기
|
||||
Node limitsNode = findChildNode(node, "TileMatrixSetLimits");
|
||||
if (limitsNode != null) {
|
||||
NodeList limitsList = limitsNode.getChildNodes();
|
||||
// 각 TileMatrixLimits 처리
|
||||
for (int j = 0; j < limitsList.getLength(); j++) {
|
||||
Node limitNode = limitsList.item(j);
|
||||
if (limitNode.getNodeName().contains("TileMatrixLimits")) {
|
||||
// TileMatrix 또는 Identifier 값 추출
|
||||
String identifier = getChildValue(limitNode, "TileMatrix");
|
||||
if (identifier == null) {
|
||||
identifier = getChildValue(limitNode, "Identifier");
|
||||
}
|
||||
// 마지막 콜론 이후 값(줌 레벨) 추출
|
||||
if (identifier != null && identifier.contains(":")) {
|
||||
String[] parts = identifier.split(":");
|
||||
String zoomLevel = parts[parts.length - 1];
|
||||
matrixIds.add(zoomLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return matrixIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* TileMatrixSetLink 정보를 파싱합니다. 각 TileMatrixSetLink에서 TileMatrixSet 이름과 줌 레벨들을 추출합니다.
|
||||
*
|
||||
* @param layerNode Layer 노드
|
||||
* @return TileMatrixSetLink 객체 리스트
|
||||
*/
|
||||
private List<WmtsLayerInfo.TileMatrixSetLink> parseTileMatrixSetLinks(Node layerNode) {
|
||||
List<WmtsLayerInfo.TileMatrixSetLink> links = new ArrayList<>();
|
||||
NodeList children = layerNode.getChildNodes();
|
||||
|
||||
// 모든 TileMatrixSetLink 찾기
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
Node node = children.item(i);
|
||||
if (node.getNodeName().contains("TileMatrixSetLink")) {
|
||||
|
||||
// TileMatrixSet 이름 추출
|
||||
String tileMatrixSet = getChildValue(node, "TileMatrixSet");
|
||||
|
||||
// 줌 레벨들 추출
|
||||
List<String> zoomLevels = new ArrayList<>();
|
||||
Node limitsNode = findChildNode(node, "TileMatrixSetLimits");
|
||||
if (limitsNode != null) {
|
||||
NodeList limitsList = limitsNode.getChildNodes();
|
||||
for (int j = 0; j < limitsList.getLength(); j++) {
|
||||
Node limitNode = limitsList.item(j);
|
||||
if (limitNode.getNodeName().contains("TileMatrixLimits")) {
|
||||
// TileMatrix 또는 Identifier 값 추출
|
||||
String identifier = getChildValue(limitNode, "TileMatrix");
|
||||
if (identifier == null) {
|
||||
identifier = getChildValue(limitNode, "Identifier");
|
||||
}
|
||||
// 마지막 콜론 이후 값(줌 레벨) 추출
|
||||
if (identifier != null && identifier.contains(":")) {
|
||||
String[] parts = identifier.split(":");
|
||||
String zoomLevel = parts[parts.length - 1];
|
||||
zoomLevels.add(zoomLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TileMatrixSetLink 객체 생성 및 추가
|
||||
if (tileMatrixSet != null) {
|
||||
WmtsLayerInfo.TileMatrixSetLink link =
|
||||
new WmtsLayerInfo.TileMatrixSetLink(tileMatrixSet, zoomLevels);
|
||||
links.add(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Document에서 TileMatrixSet의 TileMatrix 정보를 파싱합니다.
|
||||
*
|
||||
* @param doc WMTS Capabilities Document
|
||||
* @param tileMatrixSetNames 조회할 TileMatrixSet 이름 리스트
|
||||
* @return TileMatric 객체 리스트
|
||||
*/
|
||||
private List<WmtsLayerInfo.TileMatric> parseTileMatrices(
|
||||
Document doc, List<String> tileMatrixSetNames) {
|
||||
List<WmtsLayerInfo.TileMatric> allMatrices = new ArrayList<>();
|
||||
|
||||
try {
|
||||
XPathFactory xPathFactory = XPathFactory.newInstance();
|
||||
XPath xpath = xPathFactory.newXPath();
|
||||
|
||||
// 각 TileMatrixSet 이름에 대해 TileMatrix 찾기
|
||||
for (String tileMatrixSetName : tileMatrixSetNames) {
|
||||
// TileMatrixSet 찾기
|
||||
String expression = "//*[local-name()='TileMatrixSet']";
|
||||
NodeList tileMatrixSetNodes =
|
||||
(NodeList) xpath.compile(expression).evaluate(doc, XPathConstants.NODESET);
|
||||
|
||||
for (int i = 0; i < tileMatrixSetNodes.getLength(); i++) {
|
||||
Node tileMatrixSetNode = tileMatrixSetNodes.item(i);
|
||||
String identifier = getChildValue(tileMatrixSetNode, "Identifier");
|
||||
|
||||
// 일치하는 TileMatrixSet 찾으면 TileMatrix 파싱
|
||||
if (tileMatrixSetName.equals(identifier)) {
|
||||
NodeList children = tileMatrixSetNode.getChildNodes();
|
||||
for (int j = 0; j < children.getLength(); j++) {
|
||||
Node node = children.item(j);
|
||||
if (node.getNodeName().contains("TileMatrix")) {
|
||||
WmtsLayerInfo.TileMatric tileMatric = new WmtsLayerInfo.TileMatric();
|
||||
|
||||
// TileMatrix 정보 추출
|
||||
tileMatric.setScaleDenominator(getChildValue(node, "ScaleDenominator"));
|
||||
tileMatric.setTopLeftCorner(getChildValue(node, "TopLeftCorner"));
|
||||
tileMatric.setIdentifier(getChildValue(node, "Identifier"));
|
||||
|
||||
/* 미사용 정보 주석처리함
|
||||
tileMatric.setTileWidth(getChildValue(node, "TileWidth"));
|
||||
tileMatric.setTileHeight(getChildValue(node, "TileHeight"));
|
||||
tileMatric.setMatrixWidth(getChildValue(node, "MatrixWidth"));
|
||||
tileMatric.setMatrixHeight(getChildValue(node, "MatrixHeight"));
|
||||
*/
|
||||
|
||||
allMatrices.add(tileMatric);
|
||||
}
|
||||
}
|
||||
break; // 일치하는 TileMatrixSet 찾았으므로 다음으로
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return allMatrices;
|
||||
}
|
||||
|
||||
// 특정 노드 아래의 자식 태그 값 추출 (예: <Title>값)
|
||||
private String getChildValue(Node parent, String childName) {
|
||||
Node child = findChildNode(parent, childName);
|
||||
return (child != null) ? child.getTextContent() : null;
|
||||
}
|
||||
|
||||
// 특정 노드 아래의 반복되는 자식 구조 값 추출 (예: Keywords -> Keyword)
|
||||
private List<String> getChildValues(Node parent, String wrapperName, String childName) {
|
||||
List<String> results = new ArrayList<>();
|
||||
Node wrapper = findChildNode(parent, wrapperName);
|
||||
if (wrapper != null) {
|
||||
NodeList children = wrapper.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
Node node = children.item(i);
|
||||
if (node.getNodeName().endsWith(childName)) {
|
||||
results.add(node.getTextContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
// Wrapper 없이 바로 반복되는 값 추출 (예: Format)
|
||||
private List<String> getChildValuesDirect(Node parent, String childName) {
|
||||
List<String> results = new ArrayList<>();
|
||||
NodeList children = parent.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
Node node = children.item(i);
|
||||
if (node.getNodeName().endsWith(childName)) {
|
||||
results.add(node.getTextContent());
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
// 이름으로 자식 노드 찾기 (Local Name 기준)
|
||||
private Node findChildNode(Node parent, String localName) {
|
||||
NodeList children = parent.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
Node node = children.item(i);
|
||||
// 네임스페이스 접두사(ows:, wmts:)를 무시하고 태그 이름 확인
|
||||
if (node.getNodeName().endsWith(":" + localName) || node.getNodeName().equals(localName)) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getAttributeValue(Node node, String attrName) {
|
||||
if (node.hasAttributes()) {
|
||||
Node attr = node.getAttributes().getNamedItem(attrName);
|
||||
if (attr != null) return attr.getNodeValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.kamco.cd.kamcoback.common.utils.enums.EnumType;
|
||||
import com.kamco.cd.kamcoback.common.utils.enums.Enums;
|
||||
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -77,6 +78,34 @@ public class MapSheetMngDto {
|
||||
@Schema(description = "선택폴더경로", example = "D:\\app\\original-images\\2022")
|
||||
private String mngPath;
|
||||
|
||||
// Tile 등록 로직
|
||||
@Schema(description = "url")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "좌측상단 경도", example = "126.0")
|
||||
private BigDecimal minLon;
|
||||
|
||||
@Schema(description = "좌측상단 위도", example = "34.0")
|
||||
private BigDecimal minLat;
|
||||
|
||||
@Schema(description = "우측하단 경도", example = "130.0")
|
||||
private BigDecimal maxLon;
|
||||
|
||||
@Schema(description = "우측하단 위도", example = "38.5")
|
||||
private BigDecimal maxLat;
|
||||
|
||||
@Schema(description = "zoom min", example = "5")
|
||||
private Short minZoom;
|
||||
|
||||
@Schema(description = "zoom max", example = "18")
|
||||
private Short maxZoom;
|
||||
|
||||
@Schema(description = "tag")
|
||||
private String tag;
|
||||
|
||||
@Schema(description = "crs 좌표계")
|
||||
private String crs;
|
||||
|
||||
@JsonIgnore private Long createdUid;
|
||||
}
|
||||
|
||||
|
||||
@@ -341,12 +341,14 @@ public class MapSheetMngService {
|
||||
String dirPath = syncRootDir + srchDto.getDirPath();
|
||||
String sortType = "name desc";
|
||||
|
||||
List<FIleChecker.Folder> folderList = FIleChecker.getFolderAll(dirPath);
|
||||
List<FIleChecker.Folder> folderList =
|
||||
FIleChecker.getFolderAll(dirPath).stream()
|
||||
.filter(dir -> dir.getIsValid().equals(true))
|
||||
.toList();
|
||||
|
||||
int folderTotCnt = folderList.size();
|
||||
int folderErrTotCnt =
|
||||
(int)
|
||||
folderList.stream().filter(dto -> dto.getIsValid().toString().equals("false")).count();
|
||||
(int) folderList.stream().filter(dto -> dto.getIsValid().equals(false)).count();
|
||||
|
||||
return new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderList);
|
||||
}
|
||||
|
||||
@@ -243,8 +243,6 @@ public class ModelMngService {
|
||||
List<Basic> files =
|
||||
FIleChecker.getFilesFromAllDepth(dirPath, "*", "pth,py,json", 10, "name", startPos, endPos);
|
||||
|
||||
boolean hasPt = false; // pt 파일 존재 여부
|
||||
|
||||
for (Basic dto : files) {
|
||||
// 예: 파일명 출력 및 추가 작업
|
||||
String foldNm = dto.getFullPath().replace(dto.getFileNm(), "");
|
||||
@@ -265,17 +263,15 @@ public class ModelMngService {
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasPt) {
|
||||
// cls model 적용
|
||||
String defaultPath = ptPath;
|
||||
String defaultFileName = ptFileName;
|
||||
|
||||
String defaultPath = ptPath;
|
||||
String defaultFileName = ptFileName;
|
||||
Path ptPath = Paths.get(defaultPath, defaultFileName);
|
||||
|
||||
Path ptPath = Paths.get(defaultPath, defaultFileName);
|
||||
|
||||
if (Files.exists(ptPath)) {
|
||||
modelUploadResDto.setClsModelPath(defaultPath);
|
||||
modelUploadResDto.setClsModelFileName(defaultFileName);
|
||||
}
|
||||
if (Files.exists(ptPath)) {
|
||||
modelUploadResDto.setClsModelPath(defaultPath);
|
||||
modelUploadResDto.setClsModelFileName(defaultFileName);
|
||||
}
|
||||
|
||||
// int fileListPos = 0;
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.Basic;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LabelSendDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GukYuinLinkFacts;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.LearnInfo;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.Inference.MapSheetLearnRepository;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.gukyuin.GukYuinRepository;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -44,4 +48,20 @@ public class GukYuinCoreService {
|
||||
public void insertGeoUidPnuData(Long geoUid, String[] pnuList) {
|
||||
gukYuinRepository.insertGeoUidPnuData(geoUid, pnuList);
|
||||
}
|
||||
|
||||
public LearnInfo findMapSheetLearnInfo(UUID uuid) {
|
||||
return gukYuinRepository.findMapSheetLearnInfo(uuid);
|
||||
}
|
||||
|
||||
public Integer findMapSheetLearnYearStage(Integer compareYyyy, Integer targetYyyy) {
|
||||
return gukYuinRepository.findMapSheetLearnYearStage(compareYyyy, targetYyyy);
|
||||
}
|
||||
|
||||
public void updateAnalInferenceApplyDttm(Basic registRes) {
|
||||
gukYuinRepository.updateAnalInferenceApplyDttm(registRes);
|
||||
}
|
||||
|
||||
public List<LabelSendDto> findLabelingCompleteSendList(LocalDate yesterday) {
|
||||
return gukYuinRepository.findLabelingCompleteSendList(yesterday);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LearnKeyDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GeomUidDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.gukyuin.GukYuinRepository;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -13,11 +16,23 @@ public class GukYuinJobCoreService {
|
||||
this.gukYuinRepository = gukYuinRepository;
|
||||
}
|
||||
|
||||
public List<String> findGukyuinApplyIngUidList() {
|
||||
return gukYuinRepository.findGukyuinApplyIngUidList();
|
||||
public void updateGukYuinApplyStateComplete(Long id, GukYuinStatus status) {
|
||||
gukYuinRepository.updateGukYuinApplyStateComplete(id, status);
|
||||
}
|
||||
|
||||
public void updateGukYuinApplyStateComplete(String uid) {
|
||||
gukYuinRepository.updateGukYuinApplyStateComplete(uid);
|
||||
public List<LearnKeyDto> findGukyuinApplyStatusUidList(List<String> gukYuinStatus) {
|
||||
return gukYuinRepository.findGukyuinApplyStatusUidList(gukYuinStatus);
|
||||
}
|
||||
|
||||
public long upsertMapSheetDataAnalGeomPnu(String chnDtctObjtId, String[] pnuList) {
|
||||
return gukYuinRepository.upsertMapSheetDataAnalGeomPnu(chnDtctObjtId, pnuList);
|
||||
}
|
||||
|
||||
public List<GeomUidDto> findYesterdayLabelingCompleteList() {
|
||||
return gukYuinRepository.findYesterdayLabelingCompleteList();
|
||||
}
|
||||
|
||||
public void updateAnalDataInferenceGeomSendDttm(Long geoUid) {
|
||||
gukYuinRepository.updateAnalDataInferenceGeomSendDttm(geoUid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,12 @@ import jakarta.persistence.EntityNotFoundException;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
@@ -81,23 +83,29 @@ public class InferenceResultCoreService {
|
||||
* @param req
|
||||
*/
|
||||
public UUID saveInferenceInfo(InferenceResultDto.RegReq req, List<MngListDto> targetList) {
|
||||
String firstMapSheetName = null;
|
||||
String mapSheetName = "";
|
||||
int detectingCnt = 0;
|
||||
|
||||
for (MngListDto dto : targetList) {
|
||||
if (detectingCnt == 0) {
|
||||
firstMapSheetName = dto.getMapSheetName();
|
||||
}
|
||||
detectingCnt++;
|
||||
}
|
||||
List<MngListDto> distinctList =
|
||||
targetList.stream()
|
||||
.filter(dto -> dto.getMapSheetName() != null && !dto.getMapSheetName().isBlank())
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
MngListDto::getMapSheetName,
|
||||
dto -> dto,
|
||||
(existing, duplicate) -> existing,
|
||||
LinkedHashMap::new))
|
||||
.values()
|
||||
.stream()
|
||||
.toList();
|
||||
|
||||
int detectingCnt = distinctList.size();
|
||||
|
||||
String mapSheetName;
|
||||
if (detectingCnt == 0) {
|
||||
mapSheetName = "";
|
||||
} else if (detectingCnt == 1) {
|
||||
mapSheetName = firstMapSheetName + " 1건";
|
||||
mapSheetName = distinctList.get(0).getMapSheetName() + " 1건";
|
||||
} else {
|
||||
mapSheetName = firstMapSheetName + " 외 " + (detectingCnt - 1) + "건";
|
||||
mapSheetName = distinctList.get(0).getMapSheetName() + " 외 " + (detectingCnt - 1) + "건";
|
||||
}
|
||||
|
||||
MapSheetLearnEntity mapSheetLearnEntity = new MapSheetLearnEntity();
|
||||
@@ -113,7 +121,7 @@ public class InferenceResultCoreService {
|
||||
mapSheetLearnEntity.setCreatedUid(userUtil.getId());
|
||||
mapSheetLearnEntity.setMapSheetCnt(mapSheetName);
|
||||
mapSheetLearnEntity.setDetectingCnt(0L);
|
||||
mapSheetLearnEntity.setTotalJobs((long) detectingCnt);
|
||||
mapSheetLearnEntity.setTotalJobs((long) targetList.size());
|
||||
|
||||
// 회차는 국유인 반영할때 update로 변경됨
|
||||
// mapSheetLearnEntity.setStage(
|
||||
|
||||
@@ -6,7 +6,10 @@ import com.kamco.cd.kamcoback.common.enums.LayerType;
|
||||
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
|
||||
import com.kamco.cd.kamcoback.common.utils.UserUtil;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.IsMapYn;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.LayerMapDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.OrderReq;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.TileUrlDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.WmsDto.WmsAddDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.WmtsDto.WmtsAddDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapLayerEntity;
|
||||
@@ -25,6 +28,7 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MapLayerCoreService {
|
||||
|
||||
private final MapLayerRepository mapLayerRepository;
|
||||
private final UserUtil userUtil;
|
||||
private final ObjectMapper objectMapper;
|
||||
@@ -127,10 +131,40 @@ public class MapLayerCoreService {
|
||||
entity.setIsLabelingMap(dto.getIsLabelingMap());
|
||||
}
|
||||
|
||||
if (dto.getCrs() != null) {
|
||||
entity.setCrs(dto.getCrs());
|
||||
}
|
||||
|
||||
entity.setUpdatedUid(userUtil.getId());
|
||||
entity.setUpdatedDttm(ZonedDateTime.now());
|
||||
}
|
||||
|
||||
/**
|
||||
* 맵 노출 여부
|
||||
*
|
||||
* @param uuid
|
||||
* @param isMapYn
|
||||
*/
|
||||
public void updateIsMap(UUID uuid, IsMapYn isMapYn) {
|
||||
MapLayerEntity entity =
|
||||
mapLayerRepository
|
||||
.findDetailByUuid(uuid)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
|
||||
LayerDto.MapType mapType;
|
||||
|
||||
try {
|
||||
mapType = LayerDto.MapType.valueOf(isMapYn.getMapType());
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new CustomApiException("BAD_REQUEST", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
switch (mapType) {
|
||||
case CHANGE_MAP -> entity.setIsChangeMap(isMapYn.getIsMapYn());
|
||||
case LABELING_MAP -> entity.setIsLabelingMap(isMapYn.getIsMapYn());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 순서 수정
|
||||
*
|
||||
@@ -180,13 +214,7 @@ public class MapLayerCoreService {
|
||||
* @param dto
|
||||
*/
|
||||
public UUID saveTile(LayerDto.AddReq dto) {
|
||||
LayerDto.SearchReq searchReq = new LayerDto.SearchReq();
|
||||
searchReq.setLayerType(LayerType.TILE.getId());
|
||||
List<LayerDto.Basic> entityList = mapLayerRepository.findAllLayer(searchReq);
|
||||
|
||||
if (!entityList.isEmpty()) {
|
||||
throw new CustomApiException("DUPLICATE_DATA", HttpStatus.CONFLICT);
|
||||
}
|
||||
Long order = mapLayerRepository.findSortOrderDesc();
|
||||
|
||||
MapLayerEntity mapLayerEntity = new MapLayerEntity();
|
||||
mapLayerEntity.setDescription(dto.getDescription());
|
||||
@@ -198,11 +226,12 @@ public class MapLayerCoreService {
|
||||
mapLayerEntity.setMaxLat(dto.getMaxLat());
|
||||
mapLayerEntity.setMinZoom(dto.getMin());
|
||||
mapLayerEntity.setMaxZoom(dto.getMax());
|
||||
mapLayerEntity.setCrs(dto.getCrs());
|
||||
|
||||
mapLayerEntity.setCreatedUid(userUtil.getId());
|
||||
mapLayerEntity.setIsChangeMap(true);
|
||||
mapLayerEntity.setIsLabelingMap(false);
|
||||
mapLayerEntity.setOrder(1L);
|
||||
mapLayerEntity.setIsLabelingMap(true);
|
||||
mapLayerEntity.setOrder(order + 1);
|
||||
mapLayerEntity.setLayerType(LayerType.TILE.getId());
|
||||
mapLayerEntity.setUpdatedDttm(ZonedDateTime.now());
|
||||
return mapLayerRepository.save(mapLayerEntity).getUuid();
|
||||
@@ -225,6 +254,7 @@ public class MapLayerCoreService {
|
||||
mapLayerEntity.setIsChangeMap(true);
|
||||
mapLayerEntity.setIsLabelingMap(true);
|
||||
mapLayerEntity.setLayerType(LayerType.GEOJSON.getId());
|
||||
mapLayerEntity.setCrs(addDto.getCrs());
|
||||
mapLayerEntity.setUpdatedDttm(ZonedDateTime.now());
|
||||
mapLayerEntity.setOrder(order + 1);
|
||||
return mapLayerRepository.save(mapLayerEntity).getUuid();
|
||||
@@ -291,4 +321,16 @@ public class MapLayerCoreService {
|
||||
mapLayerEntity.setTag(addDto.getTag());
|
||||
return mapLayerRepository.save(mapLayerEntity).getUuid();
|
||||
}
|
||||
|
||||
public List<LayerMapDto> findLayerMapList(String type) {
|
||||
return mapLayerRepository.findLayerMapList(type);
|
||||
}
|
||||
|
||||
public LayerDto.YearTileDto getChangeDetectionTileUrl(Integer beforeYear, Integer afterYear) {
|
||||
return mapLayerRepository.getChangeDetectionTileUrl(beforeYear, afterYear);
|
||||
}
|
||||
|
||||
public TileUrlDto getChangeDetectionTileOneYearUrl(Integer year) {
|
||||
return mapLayerRepository.getChangeDetectionTileOneYearUrl(year);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +162,9 @@ public class MapSheetMngCoreService {
|
||||
saved.getMngYyyy(), saved.getMngPath());
|
||||
mapSheetMngRepository.updateYearState(saved.getMngYyyy(), "DONE");
|
||||
|
||||
// 년도별 Tile 정보 등록
|
||||
mapSheetMngRepository.insertMapSheetMngTile(addReq);
|
||||
|
||||
return hstCnt;
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,9 @@ public class MapLayerEntity {
|
||||
@Column(name = "is_deleted")
|
||||
private Boolean isDeleted = false;
|
||||
|
||||
@Column(name = "crs")
|
||||
private String crs;
|
||||
|
||||
public LayerDto.Detail toDto() {
|
||||
return new LayerDto.Detail(
|
||||
this.uuid,
|
||||
@@ -120,6 +123,7 @@ public class MapLayerEntity {
|
||||
this.maxLat,
|
||||
this.minZoom,
|
||||
this.maxZoom,
|
||||
this.createdDttm);
|
||||
this.createdDttm,
|
||||
this.crs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,6 +156,9 @@ public class MapSheetAnalDataInferenceGeomEntity {
|
||||
@JoinColumn(name = "map_5k_id", referencedColumnName = "fid")
|
||||
private MapInkx5kEntity map5k;
|
||||
|
||||
@Column(name = "label_send_dttm")
|
||||
private ZonedDateTime labelSendDttm;
|
||||
|
||||
public InferenceDetailDto.DetailListEntity toEntity() {
|
||||
DetectionClassification classification = DetectionClassification.fromString(classBeforeCd);
|
||||
Clazzes comparedClazz = new Clazzes(classification, classBeforeProb);
|
||||
|
||||
@@ -199,6 +199,9 @@ public class MapSheetLearnEntity {
|
||||
@Column(name = "total_jobs")
|
||||
private Long totalJobs;
|
||||
|
||||
@Column(name = "chn_dtct_mst_id")
|
||||
private String chnDtctMstId;
|
||||
|
||||
public InferenceResultDto.ResultList toDto() {
|
||||
return new InferenceResultDto.ResultList(
|
||||
this.uuid,
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.kamco.cd.kamcoback.postgres.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.ZonedDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "tb_map_sheet_mng_tile")
|
||||
public class MapSheetMngTileEntity {
|
||||
|
||||
@Id
|
||||
@Column(name = "mng_yyyy", nullable = false)
|
||||
private Integer mngYyyy;
|
||||
|
||||
@Column(name = "url", length = Integer.MAX_VALUE)
|
||||
private String url;
|
||||
|
||||
@Column(name = "min_lon", precision = 10, scale = 7)
|
||||
private BigDecimal minLon;
|
||||
|
||||
@Column(name = "min_lat", precision = 10, scale = 7)
|
||||
private BigDecimal minLat;
|
||||
|
||||
@Column(name = "max_lon", precision = 10, scale = 7)
|
||||
private BigDecimal maxLon;
|
||||
|
||||
@Column(name = "max_lat", precision = 10, scale = 7)
|
||||
private BigDecimal maxLat;
|
||||
|
||||
@Column(name = "min_zoom")
|
||||
private Short minZoom;
|
||||
|
||||
@Column(name = "max_zoom")
|
||||
private Short maxZoom;
|
||||
|
||||
@Column(name = "tag")
|
||||
private String tag;
|
||||
|
||||
@Column(name = "crs")
|
||||
private String crs;
|
||||
|
||||
@NotNull
|
||||
@ColumnDefault("now()")
|
||||
@Column(name = "created_dttm", nullable = false)
|
||||
private ZonedDateTime createdDttm = ZonedDateTime.now();
|
||||
|
||||
@Column(name = "updated_dttm")
|
||||
private ZonedDateTime updatedDttm;
|
||||
}
|
||||
@@ -1,7 +1,14 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.gukyuin;
|
||||
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.Basic;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LabelSendDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LearnKeyDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GeomUidDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.LearnInfo;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface GukYuinRepositoryCustom {
|
||||
|
||||
@@ -15,7 +22,21 @@ public interface GukYuinRepositoryCustom {
|
||||
|
||||
void insertGeoUidPnuData(Long geoUid, String[] pnuList);
|
||||
|
||||
List<String> findGukyuinApplyIngUidList();
|
||||
void updateGukYuinApplyStateComplete(Long id, GukYuinStatus status);
|
||||
|
||||
void updateGukYuinApplyStateComplete(String uid);
|
||||
List<LearnKeyDto> findGukyuinApplyStatusUidList(List<String> gukYuinStatus);
|
||||
|
||||
long upsertMapSheetDataAnalGeomPnu(String uid, String[] pnuList);
|
||||
|
||||
LearnInfo findMapSheetLearnInfo(UUID uuid);
|
||||
|
||||
Integer findMapSheetLearnYearStage(Integer compareYyyy, Integer targetYyyy);
|
||||
|
||||
void updateAnalInferenceApplyDttm(Basic registRes);
|
||||
|
||||
List<GeomUidDto> findYesterdayLabelingCompleteList();
|
||||
|
||||
void updateAnalDataInferenceGeomSendDttm(Long geoUid);
|
||||
|
||||
List<LabelSendDto> findLabelingCompleteSendList(LocalDate yesterday);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,31 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.gukyuin;
|
||||
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QLabelingAssignmentEntity.labelingAssignmentEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnEntity.mapSheetLearnEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QPnuEntity.pnuEntity;
|
||||
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.Basic;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LabelSendDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LearnKeyDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GeomUidDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.LearnInfo;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InspectState;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.core.types.dsl.NumberExpression;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -37,6 +51,7 @@ public class GukYuinRepositoryImpl implements GukYuinRepositoryCustom {
|
||||
.set(mapSheetLearnEntity.stage, stage)
|
||||
.set(mapSheetLearnEntity.applyStatus, status.getId())
|
||||
.set(mapSheetLearnEntity.applyStatusDttm, ZonedDateTime.now())
|
||||
.set(mapSheetLearnEntity.chnDtctMstId, resultBody.getChnDtctMstId())
|
||||
.where(mapSheetLearnEntity.uid.eq(resultBody.getChnDtctId()))
|
||||
.execute();
|
||||
}
|
||||
@@ -81,22 +96,184 @@ public class GukYuinRepositoryImpl implements GukYuinRepositoryCustom {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> findGukyuinApplyIngUidList() {
|
||||
public List<LearnKeyDto> findGukyuinApplyStatusUidList(List<String> status) {
|
||||
return queryFactory
|
||||
.select(mapSheetLearnEntity.uid)
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LearnKeyDto.class,
|
||||
mapSheetLearnEntity.id,
|
||||
mapSheetLearnEntity.uid,
|
||||
mapSheetLearnEntity.chnDtctMstId))
|
||||
.from(mapSheetLearnEntity)
|
||||
.where(mapSheetLearnEntity.applyStatus.eq(GukYuinStatus.IN_PROGRESS.getId()))
|
||||
.where(mapSheetLearnEntity.applyStatus.in(status))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long upsertMapSheetDataAnalGeomPnu(String chnDtctObjtId, String[] pnuList) {
|
||||
long length = pnuList.length;
|
||||
queryFactory
|
||||
.update(mapSheetAnalDataInferenceGeomEntity)
|
||||
.set(mapSheetAnalDataInferenceGeomEntity.pnu, length)
|
||||
.where(mapSheetAnalDataInferenceGeomEntity.resultUid.eq(chnDtctObjtId))
|
||||
.execute();
|
||||
|
||||
Long geoUid =
|
||||
queryFactory
|
||||
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
|
||||
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||
.where(mapSheetAnalDataInferenceGeomEntity.resultUid.eq(chnDtctObjtId))
|
||||
.fetchOne();
|
||||
|
||||
long succCnt = 0;
|
||||
for (String pnu : pnuList) {
|
||||
long result =
|
||||
queryFactory
|
||||
.insert(pnuEntity)
|
||||
.columns(pnuEntity.geo.geoUid, pnuEntity.pnu, pnuEntity.createdDttm)
|
||||
.values(geoUid, pnu, ZonedDateTime.now())
|
||||
.execute();
|
||||
if (result > 0) {
|
||||
succCnt++;
|
||||
}
|
||||
}
|
||||
return succCnt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LearnInfo findMapSheetLearnInfo(UUID uuid) {
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LearnInfo.class,
|
||||
mapSheetLearnEntity.id,
|
||||
mapSheetLearnEntity.uuid,
|
||||
mapSheetLearnEntity.compareYyyy,
|
||||
mapSheetLearnEntity.targetYyyy,
|
||||
mapSheetLearnEntity.stage,
|
||||
mapSheetLearnEntity.uid,
|
||||
mapSheetLearnEntity.applyStatus))
|
||||
.from(mapSheetLearnEntity)
|
||||
.where(mapSheetLearnEntity.uuid.eq(uuid))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer findMapSheetLearnYearStage(Integer compareYyyy, Integer targetYyyy) {
|
||||
NumberExpression<Integer> stageExpr =
|
||||
Expressions.numberTemplate(Integer.class, "coalesce({0}, 0)", mapSheetLearnEntity.stage);
|
||||
|
||||
return queryFactory
|
||||
.select(stageExpr.max())
|
||||
.from(mapSheetLearnEntity)
|
||||
.where(
|
||||
mapSheetLearnEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetLearnEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetLearnEntity.applyStatus.isNotNull(),
|
||||
mapSheetLearnEntity.applyStatus.ne(GukYuinStatus.PENDING.getId()))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAnalInferenceApplyDttm(Basic registRes) {
|
||||
Long learnId =
|
||||
queryFactory
|
||||
.select(mapSheetLearnEntity.id)
|
||||
.from(mapSheetLearnEntity)
|
||||
.where(mapSheetLearnEntity.uid.eq(registRes.getChnDtctId()))
|
||||
.fetchOne();
|
||||
|
||||
queryFactory
|
||||
.update(mapSheetAnalInferenceEntity)
|
||||
.set(mapSheetAnalInferenceEntity.gukyuinUsed, "Y")
|
||||
.set(mapSheetAnalInferenceEntity.gukyuinApplyDttm, ZonedDateTime.now())
|
||||
.where(mapSheetAnalInferenceEntity.learnId.eq(learnId))
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GeomUidDto> findYesterdayLabelingCompleteList() {
|
||||
ZoneId zone = ZoneId.of("Asia/Seoul");
|
||||
ZonedDateTime todayStart = ZonedDateTime.now(zone).toLocalDate().atStartOfDay(zone);
|
||||
ZonedDateTime yesterdayStart = todayStart.minusDays(1);
|
||||
|
||||
BooleanExpression isYesterday =
|
||||
labelingAssignmentEntity
|
||||
.inspectStatDttm
|
||||
.goe(yesterdayStart)
|
||||
.and(labelingAssignmentEntity.inspectStatDttm.lt(todayStart));
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
GeomUidDto.class,
|
||||
labelingAssignmentEntity.inferenceGeomUid,
|
||||
mapSheetAnalDataInferenceGeomEntity.resultUid))
|
||||
.from(labelingAssignmentEntity)
|
||||
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||
.on(
|
||||
labelingAssignmentEntity.inferenceGeomUid.eq(
|
||||
mapSheetAnalDataInferenceGeomEntity.geoUid))
|
||||
.innerJoin(mapSheetAnalInferenceEntity)
|
||||
.on(labelingAssignmentEntity.analUid.eq(mapSheetAnalInferenceEntity.id))
|
||||
.innerJoin(mapSheetLearnEntity)
|
||||
.on(
|
||||
mapSheetAnalInferenceEntity.learnId.eq(mapSheetLearnEntity.id),
|
||||
mapSheetLearnEntity.applyStatus.in(
|
||||
GukYuinStatus.GUK_COMPLETED.getId(), GukYuinStatus.PNU_COMPLETED.getId()))
|
||||
.where(labelingAssignmentEntity.inspectState.eq(InspectState.COMPLETE.getId()), isYesterday)
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAnalDataInferenceGeomSendDttm(Long geoUid) {
|
||||
queryFactory
|
||||
.update(mapSheetAnalDataInferenceGeomEntity)
|
||||
.set(mapSheetAnalDataInferenceGeomEntity.labelSendDttm, ZonedDateTime.now())
|
||||
.where(mapSheetAnalDataInferenceGeomEntity.geoUid.eq(geoUid))
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LabelSendDto> findLabelingCompleteSendList(LocalDate yesterday) {
|
||||
|
||||
ZoneId zone = ZoneId.of("Asia/Seoul");
|
||||
ZonedDateTime from = yesterday.atStartOfDay(zone);
|
||||
ZonedDateTime to = from.plusDays(1);
|
||||
|
||||
BooleanExpression isYesterday =
|
||||
labelingAssignmentEntity
|
||||
.inspectStatDttm
|
||||
.goe(from)
|
||||
.and(labelingAssignmentEntity.inspectStatDttm.lt(to));
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LabelSendDto.class,
|
||||
mapSheetAnalDataInferenceGeomEntity.resultUid,
|
||||
labelingAssignmentEntity.workerUid,
|
||||
labelingAssignmentEntity.workStatDttm,
|
||||
labelingAssignmentEntity.inspectorUid,
|
||||
labelingAssignmentEntity.inspectStatDttm,
|
||||
mapSheetAnalDataInferenceGeomEntity.labelSendDttm))
|
||||
.from(labelingAssignmentEntity)
|
||||
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||
.on(
|
||||
labelingAssignmentEntity.inferenceGeomUid.eq(
|
||||
mapSheetAnalDataInferenceGeomEntity.geoUid))
|
||||
.where(labelingAssignmentEntity.inspectState.eq(InspectState.COMPLETE.getId()), isYesterday)
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateGukYuinApplyStateComplete(String uid) {
|
||||
public void updateGukYuinApplyStateComplete(Long id, GukYuinStatus status) {
|
||||
queryFactory
|
||||
.update(mapSheetLearnEntity)
|
||||
.set(mapSheetLearnEntity.applyStatus, GukYuinStatus.PNU_COMPLETED.getId())
|
||||
.set(mapSheetLearnEntity.applyStatus, status.getId())
|
||||
.set(mapSheetLearnEntity.applyStatusDttm, ZonedDateTime.now())
|
||||
.where(mapSheetLearnEntity.uid.eq(uid))
|
||||
.where(mapSheetLearnEntity.id.eq(id))
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.layer;
|
||||
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.LayerMapDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.TileUrlDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapLayerEntity;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -8,6 +10,7 @@ import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface MapLayerRepositoryCustom {
|
||||
|
||||
Long findSortOrderDesc();
|
||||
|
||||
List<LayerDto.Basic> findAllLayer(LayerDto.SearchReq searchReq);
|
||||
@@ -15,4 +18,10 @@ public interface MapLayerRepositoryCustom {
|
||||
Optional<MapLayerEntity> findDetailByUuid(UUID uuid);
|
||||
|
||||
List<MapLayerEntity> findAllByUuidIn(Collection<UUID> uuids);
|
||||
|
||||
List<LayerMapDto> findLayerMapList(String type);
|
||||
|
||||
LayerDto.YearTileDto getChangeDetectionTileUrl(Integer beforeYear, Integer afterYear);
|
||||
|
||||
TileUrlDto getChangeDetectionTileOneYearUrl(Integer year);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.layer;
|
||||
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapLayerEntity.mapLayerEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngTileEntity.mapSheetMngTileEntity;
|
||||
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.LayerMapDto;
|
||||
import com.kamco.cd.kamcoback.layer.dto.LayerDto.TileUrlDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapLayerEntity;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.core.types.dsl.NumberExpression;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -84,4 +90,139 @@ public class MapLayerRepositoryImpl implements MapLayerRepositoryCustom {
|
||||
.orderBy(mapLayerEntity.order.asc())
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LayerMapDto> findLayerMapList(String type) {
|
||||
NumberExpression<Integer> crsInt =
|
||||
Expressions.numberTemplate(
|
||||
Integer.class, "cast(replace({0}, 'EPSG_', '') as integer)", mapLayerEntity.crs);
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LayerMapDto.class,
|
||||
mapLayerEntity.layerType,
|
||||
mapLayerEntity.tag,
|
||||
mapLayerEntity.order,
|
||||
mapLayerEntity.url,
|
||||
mapLayerEntity.minLon,
|
||||
mapLayerEntity.minLat,
|
||||
mapLayerEntity.maxLon,
|
||||
mapLayerEntity.maxLat,
|
||||
mapLayerEntity.minZoom,
|
||||
mapLayerEntity.maxZoom,
|
||||
Expressions.stringTemplate(
|
||||
"ST_AsGeoJSON(ST_Transform(ST_MakeEnvelope({0}, {1}, {2}, {3}, 4326), {4}))",
|
||||
mapLayerEntity.minLon,
|
||||
mapLayerEntity.minLat,
|
||||
mapLayerEntity.maxLon,
|
||||
mapLayerEntity.maxLat,
|
||||
crsInt),
|
||||
mapLayerEntity.uuid,
|
||||
Expressions.stringTemplate("cast({0} as text)", mapLayerEntity.rawJson),
|
||||
mapLayerEntity.crs))
|
||||
.from(mapLayerEntity)
|
||||
.where(layerTypeCondition(type), mapLayerEntity.isDeleted.isFalse())
|
||||
.orderBy(mapLayerEntity.order.asc())
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LayerDto.YearTileDto getChangeDetectionTileUrl(Integer beforeYear, Integer afterYear) {
|
||||
NumberExpression<Integer> crsInt =
|
||||
Expressions.numberTemplate(
|
||||
Integer.class, "cast(replace({0}, 'EPSG_', '') as integer)", mapSheetMngTileEntity.crs);
|
||||
|
||||
LayerDto.TileUrlDto before =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LayerDto.TileUrlDto.class,
|
||||
mapSheetMngTileEntity.mngYyyy,
|
||||
mapSheetMngTileEntity.tag,
|
||||
mapSheetMngTileEntity.url,
|
||||
mapSheetMngTileEntity.minLon,
|
||||
mapSheetMngTileEntity.minLat,
|
||||
mapSheetMngTileEntity.maxLon,
|
||||
mapSheetMngTileEntity.maxLat,
|
||||
mapSheetMngTileEntity.minZoom,
|
||||
mapSheetMngTileEntity.maxZoom,
|
||||
Expressions.stringTemplate(
|
||||
"ST_AsGeoJSON(ST_Transform(ST_MakeEnvelope({0}, {1}, {2}, {3}, 4326), {4}))",
|
||||
mapSheetMngTileEntity.minLon,
|
||||
mapSheetMngTileEntity.minLat,
|
||||
mapSheetMngTileEntity.maxLon,
|
||||
mapSheetMngTileEntity.maxLat,
|
||||
crsInt),
|
||||
mapSheetMngTileEntity.crs))
|
||||
.from(mapSheetMngTileEntity)
|
||||
.where(mapSheetMngTileEntity.mngYyyy.eq(beforeYear))
|
||||
.fetchOne();
|
||||
|
||||
LayerDto.TileUrlDto after =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LayerDto.TileUrlDto.class,
|
||||
mapSheetMngTileEntity.mngYyyy,
|
||||
mapSheetMngTileEntity.tag,
|
||||
mapSheetMngTileEntity.url,
|
||||
mapSheetMngTileEntity.minLon,
|
||||
mapSheetMngTileEntity.minLat,
|
||||
mapSheetMngTileEntity.maxLon,
|
||||
mapSheetMngTileEntity.maxLat,
|
||||
mapSheetMngTileEntity.minZoom,
|
||||
mapSheetMngTileEntity.maxZoom,
|
||||
Expressions.stringTemplate(
|
||||
"ST_AsGeoJSON(ST_Transform(ST_MakeEnvelope({0}, {1}, {2}, {3}, 4326), {4}))",
|
||||
mapSheetMngTileEntity.minLon,
|
||||
mapSheetMngTileEntity.minLat,
|
||||
mapSheetMngTileEntity.maxLon,
|
||||
mapSheetMngTileEntity.maxLat,
|
||||
crsInt),
|
||||
mapSheetMngTileEntity.crs))
|
||||
.from(mapSheetMngTileEntity)
|
||||
.where(mapSheetMngTileEntity.mngYyyy.eq(afterYear))
|
||||
.fetchOne();
|
||||
|
||||
return new LayerDto.YearTileDto(before, after);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileUrlDto getChangeDetectionTileOneYearUrl(Integer year) {
|
||||
NumberExpression<Integer> crsInt =
|
||||
Expressions.numberTemplate(
|
||||
Integer.class, "cast(replace({0}, 'EPSG_', '') as integer)", mapSheetMngTileEntity.crs);
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LayerDto.TileUrlDto.class,
|
||||
mapSheetMngTileEntity.mngYyyy,
|
||||
mapSheetMngTileEntity.tag,
|
||||
mapSheetMngTileEntity.url,
|
||||
mapSheetMngTileEntity.minLon,
|
||||
mapSheetMngTileEntity.minLat,
|
||||
mapSheetMngTileEntity.maxLon,
|
||||
mapSheetMngTileEntity.maxLat,
|
||||
mapSheetMngTileEntity.minZoom,
|
||||
mapSheetMngTileEntity.maxZoom,
|
||||
Expressions.stringTemplate(
|
||||
"ST_AsGeoJSON(ST_Transform(ST_MakeEnvelope({0}, {1}, {2}, {3}, 4326), {4}))",
|
||||
mapSheetMngTileEntity.minLon,
|
||||
mapSheetMngTileEntity.minLat,
|
||||
mapSheetMngTileEntity.maxLon,
|
||||
mapSheetMngTileEntity.maxLat,
|
||||
crsInt),
|
||||
mapSheetMngTileEntity.crs))
|
||||
.from(mapSheetMngTileEntity)
|
||||
.where(mapSheetMngTileEntity.mngYyyy.eq(year))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
private BooleanExpression layerTypeCondition(String type) {
|
||||
return type.equals("change-detection")
|
||||
? mapLayerEntity.isChangeMap.isTrue()
|
||||
: mapLayerEntity.isLabelingMap.isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
|
||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.ImageFeature;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.AddReq;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.YearSearchReq;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||
@@ -77,4 +78,6 @@ public interface MapSheetMngRepositoryCustom {
|
||||
List<ImageFeature> getSceneInference(String yyyy, List<String> mapSheetNums);
|
||||
|
||||
void updateMapSheetMngHstUploadId(Long hstUid, UUID uuid, String uploadId);
|
||||
|
||||
void insertMapSheetMngTile(@Valid AddReq addReq);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx5kEntity.mapInkx5kE
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngEntity.mapSheetMngEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngFileEntity.mapSheetMngFileEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngHstEntity.mapSheetMngHstEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngTileEntity.mapSheetMngTileEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QYearEntity.yearEntity;
|
||||
import static com.querydsl.core.types.dsl.Expressions.nullExpression;
|
||||
|
||||
@@ -12,6 +13,7 @@ import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.ImageFeature;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetScope;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.AddReq;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.YearSearchReq;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||
@@ -1040,6 +1042,36 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertMapSheetMngTile(AddReq addReq) {
|
||||
long execute =
|
||||
queryFactory
|
||||
.insert(mapSheetMngTileEntity)
|
||||
.columns(
|
||||
mapSheetMngTileEntity.mngYyyy,
|
||||
mapSheetMngTileEntity.url,
|
||||
mapSheetMngTileEntity.minLon,
|
||||
mapSheetMngTileEntity.minLat,
|
||||
mapSheetMngTileEntity.maxLon,
|
||||
mapSheetMngTileEntity.maxLat,
|
||||
mapSheetMngTileEntity.minZoom,
|
||||
mapSheetMngTileEntity.maxZoom,
|
||||
mapSheetMngTileEntity.tag,
|
||||
mapSheetMngTileEntity.crs)
|
||||
.values(
|
||||
addReq.getMngYyyy(),
|
||||
addReq.getUrl(),
|
||||
addReq.getMinLon(),
|
||||
addReq.getMinLat(),
|
||||
addReq.getMaxLon(),
|
||||
addReq.getMaxLat(),
|
||||
addReq.getMinZoom(),
|
||||
addReq.getMaxZoom(),
|
||||
addReq.getTag(),
|
||||
addReq.getCrs())
|
||||
.execute();
|
||||
}
|
||||
|
||||
private BooleanExpression eqYearStatus(QYearEntity years, String status) {
|
||||
if (status == null) {
|
||||
return null;
|
||||
|
||||
@@ -6,6 +6,7 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx5kEntity.mapInkx5kE
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnDataGeomEntity.mapSheetLearnDataGeomEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QPnuEntity.pnuEntity;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -466,6 +467,14 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
|
||||
}
|
||||
|
||||
// 5. DTO 생성
|
||||
// pnu list 조회
|
||||
List<String> pnuList =
|
||||
queryFactory
|
||||
.select(pnuEntity.pnu)
|
||||
.from(pnuEntity)
|
||||
.where(pnuEntity.geo.geoUid.eq(mapSheetAnalDataInferenceGeomEntityEntity.getGeoUid()))
|
||||
.fetch();
|
||||
|
||||
var changeDetectionInfo =
|
||||
ChangeDetectionInfo.builder()
|
||||
.mapSheetInfo(mapSheetEntity != null ? mapSheetEntity.getMapidNm() : "")
|
||||
@@ -507,10 +516,7 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
|
||||
mapSheetAnalDataInferenceGeomEntityEntity.getCdProb() != null
|
||||
? mapSheetAnalDataInferenceGeomEntityEntity.getCdProb()
|
||||
: 0.0)
|
||||
.pnu(
|
||||
mapSheetAnalDataInferenceGeomEntityEntity.getPnu() != null
|
||||
? mapSheetAnalDataInferenceGeomEntityEntity.getPnu()
|
||||
: 0L)
|
||||
.pnu(pnuList)
|
||||
.mapSheetNum(
|
||||
mapSheetAnalDataInferenceGeomEntityEntity.getMapSheetNum() != null
|
||||
? mapSheetAnalDataInferenceGeomEntityEntity.getMapSheetNum()
|
||||
|
||||
@@ -7,6 +7,7 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceG
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnDataGeomEntity.mapSheetLearnDataGeomEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMemberEntity.memberEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QPnuEntity.pnuEntity;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -494,6 +495,14 @@ public class TrainingDataReviewRepositoryImpl extends QuerydslRepositorySupport
|
||||
}
|
||||
|
||||
// 5. DTO 생성
|
||||
// pnu list 조회
|
||||
List<String> pnuList =
|
||||
queryFactory
|
||||
.select(pnuEntity.pnu)
|
||||
.from(pnuEntity)
|
||||
.where(pnuEntity.geo.geoUid.eq(mapSheetAnalDataInferenceGeomEntityEntity.getGeoUid()))
|
||||
.fetch();
|
||||
|
||||
var changeDetectionInfo =
|
||||
ChangeDetectionInfo.builder()
|
||||
.mapSheetInfo(mapSheetEntity != null ? mapSheetEntity.getMapidNm() : "")
|
||||
@@ -535,10 +544,7 @@ public class TrainingDataReviewRepositoryImpl extends QuerydslRepositorySupport
|
||||
mapSheetAnalDataInferenceGeomEntityEntity.getCdProb() != null
|
||||
? mapSheetAnalDataInferenceGeomEntityEntity.getCdProb()
|
||||
: 0.0)
|
||||
.pnu(
|
||||
mapSheetAnalDataInferenceGeomEntityEntity.getPnu() != null
|
||||
? mapSheetAnalDataInferenceGeomEntityEntity.getPnu()
|
||||
: 0L)
|
||||
.pnu(pnuList)
|
||||
.mapSheetNum(
|
||||
mapSheetAnalDataInferenceGeomEntityEntity.getMapSheetNum() != null
|
||||
? mapSheetAnalDataInferenceGeomEntityEntity.getMapSheetNum()
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.kamco.cd.kamcoback.scheduler.service;
|
||||
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto.ResultContDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LearnKeyDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResultDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GeomUidDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
|
||||
import com.kamco.cd.kamcoback.gukyuin.service.GukYuinApiService;
|
||||
import com.kamco.cd.kamcoback.postgres.core.GukYuinJobCoreService;
|
||||
import java.util.List;
|
||||
@@ -31,23 +36,26 @@ public class GukYuinApiJobService {
|
||||
return "local".equalsIgnoreCase(profile);
|
||||
}
|
||||
|
||||
/** 국유인 연동 후, 100% 되었는지 확인하는 스케줄링 매 10분마다 호출 */
|
||||
@Scheduled(cron = "0 0/10 * * * *")
|
||||
public void findGukYuinMastCompleteYn() {
|
||||
if (isLocalProfile()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> list = gukYuinJobCoreService.findGukyuinApplyIngUidList();
|
||||
List<LearnKeyDto> list =
|
||||
gukYuinJobCoreService.findGukyuinApplyStatusUidList(
|
||||
List.of(GukYuinStatus.IN_PROGRESS.getId()));
|
||||
if (list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String uid : list) {
|
||||
for (LearnKeyDto dto : list) {
|
||||
try {
|
||||
ResultDto result = gukYuinApiService.listChnDtctId(uid);
|
||||
ResultDto result = gukYuinApiService.detail(dto.getChnDtctMstId());
|
||||
|
||||
if (result == null || result.getResult() == null || result.getResult().isEmpty()) {
|
||||
log.warn("[GUKYUIN] empty result uid={}", uid);
|
||||
log.warn("[GUKYUIN] empty result chnDtctMstId={}", dto.getChnDtctMstId());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -56,18 +64,109 @@ public class GukYuinApiJobService {
|
||||
Integer progress =
|
||||
basic.getExcnPgrt() == null ? null : Integer.parseInt(basic.getExcnPgrt().trim());
|
||||
if (progress != null && progress == 100) {
|
||||
gukYuinJobCoreService.updateGukYuinApplyStateComplete(uid);
|
||||
gukYuinJobCoreService.updateGukYuinApplyStateComplete(
|
||||
dto.getId(), GukYuinStatus.GUK_COMPLETED);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("[GUKYUIN] failed uid={}", uid, e);
|
||||
log.error("[GUKYUIN] failed uid={}", dto.getChnDtctMstId(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 국유인 등록 완료 후, 탐지객체 조회해서 PNU 업데이트 하는 스케줄링 하루 1번 새벽 1시에 실행 */
|
||||
@Scheduled(cron = "0 0 1 * * *")
|
||||
public void findGukYuinContListPnuUpdate() {
|
||||
if (isLocalProfile()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<LearnKeyDto> list =
|
||||
gukYuinJobCoreService.findGukyuinApplyStatusUidList(
|
||||
List.of(GukYuinStatus.GUK_COMPLETED.getId(), GukYuinStatus.PNU_FAILED.getId()));
|
||||
if (list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (LearnKeyDto dto : list) {
|
||||
try {
|
||||
long succCnt = processUid(dto.getChnDtctMstId(), dto.getUid());
|
||||
if (succCnt > 0) {
|
||||
gukYuinJobCoreService.updateGukYuinApplyStateComplete(
|
||||
dto.getId(), GukYuinStatus.PNU_COMPLETED);
|
||||
} else {
|
||||
gukYuinJobCoreService.updateGukYuinApplyStateComplete(
|
||||
dto.getId(), GukYuinStatus.PNU_FAILED);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("[GUKYUIN] failed uid={}", dto.getUid(), e);
|
||||
gukYuinJobCoreService.updateGukYuinApplyStateComplete(
|
||||
dto.getId(), GukYuinStatus.PNU_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long processUid(String chnDtctMstId, String uid) {
|
||||
long succCnt = 0;
|
||||
ResultDto result = gukYuinApiService.detail(chnDtctMstId);
|
||||
if (result == null || result.getResult() == null || result.getResult().isEmpty()) {
|
||||
return succCnt;
|
||||
}
|
||||
|
||||
ChngDetectMastDto.Basic basic = result.getResult().get(0);
|
||||
String chnDtctCnt = basic.getChnDtctCnt();
|
||||
if (chnDtctCnt == null || chnDtctCnt.isEmpty()) {
|
||||
return succCnt;
|
||||
}
|
||||
|
||||
// page 계산
|
||||
int pageSize = 100;
|
||||
int totalCount = Integer.parseInt(chnDtctCnt);
|
||||
int totalPages = (totalCount + pageSize - 1) / pageSize;
|
||||
|
||||
for (int page = 0; page < totalPages; page++) {
|
||||
succCnt += processPage(uid, page, pageSize);
|
||||
}
|
||||
|
||||
return succCnt;
|
||||
}
|
||||
|
||||
private long processPage(String uid, int page, int pageSize) {
|
||||
long result = 0;
|
||||
ResultContDto cont = gukYuinApiService.findChnContList(uid, page, pageSize);
|
||||
if (cont == null || cont.getResult().isEmpty()) {
|
||||
return result; // 외부 API 이상 방어
|
||||
}
|
||||
|
||||
// pnuList 업데이트
|
||||
|
||||
for (ChngDetectContDto.ContBasic contBasic : cont.getResult()) {
|
||||
if (contBasic.getPnuList() == null || contBasic.getChnDtctObjtId() == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
long upsertCnt =
|
||||
gukYuinJobCoreService.upsertMapSheetDataAnalGeomPnu(
|
||||
contBasic.getChnDtctObjtId(), contBasic.getPnuList());
|
||||
result += upsertCnt;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 어제 라벨링 검수 완료된 것 -> 국유인에 전송 */
|
||||
@Scheduled(cron = "0 0 1 * * *")
|
||||
public void findLabelingCompleteSend() {
|
||||
|
||||
List<GeomUidDto> list = gukYuinJobCoreService.findYesterdayLabelingCompleteList();
|
||||
if (list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (GeomUidDto dto : list) {
|
||||
gukYuinApiService.updateChnDtctObjtLabelingYn(dto.getResultUid(), "Y");
|
||||
|
||||
// inference_geom 에 label_send_dttm 업데이트 하기
|
||||
gukYuinJobCoreService.updateAnalDataInferenceGeomSendDttm(dto.getGeoUid());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,31 +125,6 @@ public class TrainingDataReviewJobService {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 라벨러 완료,SKIP 시 호출 -> 미사용
|
||||
@Transactional
|
||||
public void assignRealtime(String assignmentUid) {
|
||||
Tasks task = trainingDataReviewJobCoreService.findAssignmentTask(assignmentUid);
|
||||
Long analUid = task.getAnalUid();
|
||||
|
||||
// pending 계산
|
||||
List<InspectorPendingDto> pendings =
|
||||
trainingDataReviewJobCoreService.findInspectorPendingByRound(analUid);
|
||||
|
||||
if (pendings.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> order = pendings.stream().map(InspectorPendingDto::getInspectorUid).toList();
|
||||
|
||||
trainingDataReviewJobCoreService.lockInspectors(analUid, order);
|
||||
|
||||
trainingDataReviewJobCoreService.assignReviewer(task.getAssignmentUid(), order.getFirst());
|
||||
|
||||
List<Long> geomUids = new ArrayList<>();
|
||||
geomUids.add(task.getInferenceUid());
|
||||
trainingDataReviewJobCoreService.updateGeomUidTestState(geomUids);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Scheduled(cron = "0 0 2 * * *")
|
||||
public void exportGeojsonLabelingGeom() {
|
||||
|
||||
@@ -358,7 +358,7 @@ public class TrainingDataLabelDto {
|
||||
private Double detectionAccuracy;
|
||||
|
||||
@Schema(description = "PNU (필지고유번호)", example = "36221202306020")
|
||||
private Long pnu;
|
||||
private List<String> pnu;
|
||||
|
||||
@Schema(description = "도엽번호 (map_sheet_num)", example = "34602057")
|
||||
private Long mapSheetNum;
|
||||
|
||||
@@ -351,7 +351,7 @@ public class TrainingDataReviewDto {
|
||||
private Double detectionAccuracy;
|
||||
|
||||
@Schema(description = "PNU (필지고유번호)", example = "36221202306020")
|
||||
private Long pnu;
|
||||
private List<String> pnu;
|
||||
|
||||
@Schema(description = "도엽번호 (map_sheet_num)", example = "34602057")
|
||||
private Long mapSheetNum;
|
||||
|
||||
@@ -108,10 +108,10 @@ file:
|
||||
pt-FileName: yolov8_6th-6m.pt
|
||||
|
||||
inference:
|
||||
url: http://10.100.0.11:8000/jobs
|
||||
batch-url: http://10.100.0.11:8000/batches
|
||||
url: http://192.168.2.183:8000/jobs
|
||||
batch-url: http://192.168.2.183:8000/batches
|
||||
geojson-dir: /kamco-nfs/requests/
|
||||
jar-path: /kamco-nfs/dataset/shp/shp-exporter-1.0.0.jar
|
||||
jar-path: /kamco-nfs/dataset/shp/shp-exporter.jar
|
||||
inference-server-name: server1,server2,server3,server4
|
||||
|
||||
gukyuin:
|
||||
@@ -124,4 +124,5 @@ training-data:
|
||||
|
||||
layer:
|
||||
geoserver-url: https://kamco.geo-dev.gs.dabeeo.com
|
||||
path: geoserver/cd/gwc/service
|
||||
workspace: cd
|
||||
|
||||
@@ -6,7 +6,7 @@ spring:
|
||||
jpa:
|
||||
show-sql: false
|
||||
hibernate:
|
||||
ddl-auto: update # 로컬만 완화(시킬려면 update으로 변경)
|
||||
ddl-auto: validate # 로컬만 완화(시킬려면 update으로 변경)
|
||||
properties:
|
||||
hibernate:
|
||||
default_batch_fetch_size: 100 # ✅ 성능 - N+1 쿼리 방지
|
||||
@@ -15,10 +15,12 @@ spring:
|
||||
format_sql: true # ⚠️ 선택 - SQL 포맷팅 (가독성)
|
||||
|
||||
datasource:
|
||||
#url: jdbc:postgresql://192.168.2.127:15432/kamco_cds
|
||||
url: jdbc:postgresql://localhost:5432/kamco_cds # 로컬호스트
|
||||
url: jdbc:postgresql://192.168.2.127:15432/kamco_cds
|
||||
# url: jdbc:postgresql://localhost:5432/local_0128
|
||||
username: kamco_cds
|
||||
password: kamco_cds_Q!W@E#R$
|
||||
# username: postgres
|
||||
# password: 1234
|
||||
hikari:
|
||||
minimum-idle: 1
|
||||
maximum-pool-size: 5
|
||||
@@ -68,18 +70,18 @@ mapsheet:
|
||||
|
||||
|
||||
file:
|
||||
sync-root-dir: /Users/bokmin/kamco-nfs/images/
|
||||
sync-root-dir: C:/Users/gypark/kamco-nfs/images/
|
||||
#sync-root-dir: /kamco-nfs/images/
|
||||
sync-tmp-dir: ${file.sync-root-dir}/tmp
|
||||
sync-tmp-dir: ${file.sync-root-dir}/tmp/
|
||||
sync-file-extention: tfw,tif
|
||||
sync-auto-exception-start-year: 2024
|
||||
sync-auto-exception-start-year: 2025
|
||||
sync-auto-exception-before-year-cnt: 3
|
||||
|
||||
dataset-dir: /Users/bokmin/kamco-nfs/dataset/export/
|
||||
dataset-dir: C:/Users/gypark/kamco-nfs/dataset/
|
||||
#dataset-dir: /kamco-nfs/dataset/export/
|
||||
dataset-tmp-dir: ${file.dataset-dir}tmp/
|
||||
|
||||
model-dir: /Users/bokmin/kamco-nfs/ckpt/model/
|
||||
model-dir: C:/Users/gypark/kamco-nfs/ckpt/model/
|
||||
#model-dir: /kamco-nfs/ckpt/model/
|
||||
model-tmp-dir: ${file.model-dir}tmp/
|
||||
model-file-extention: pth,json,py
|
||||
@@ -90,18 +92,19 @@ file:
|
||||
inference:
|
||||
url: http://10.100.0.11:8000/jobs
|
||||
batch-url: http://10.100.0.11:8000/batches
|
||||
geojson-dir: /Users/bokmin/kamco-nfs/requests/
|
||||
jar-path: /Users/bokmin/kamco-nfs/dataset/shp/shp-exporter-1.0.0.jar
|
||||
geojson-dir: /kamco-nfs/requests/
|
||||
jar-path: jar/makeshp-1.0.0.jar
|
||||
inference-server-name: server1,server2,server3,server4
|
||||
|
||||
gukyuin:
|
||||
#url: http://localhost:8080
|
||||
url: http://192.168.2.129:5301
|
||||
mast: ${gukyuin.url}/api/kcd/cdi/chn/mast
|
||||
cdi: ${gukyuin.url}/api/kcd/cdi
|
||||
|
||||
training-data:
|
||||
geojson-dir: /Users/bokmin/kamco-nfs/model_output/labeling/
|
||||
geojson-dir: /kamco-nfs/model_output/labeling/
|
||||
|
||||
layer:
|
||||
geoserver-url: http://localhost:9080
|
||||
geoserver-url: https://kamco.geo-dev.gs.dabeeo.com
|
||||
path: /geoserver/cd/gwc/service/
|
||||
workspace: cd
|
||||
|
||||
@@ -63,10 +63,10 @@ file:
|
||||
pt-FileName: yolov8_6th-6m.pt
|
||||
|
||||
inference:
|
||||
url: http://10.100.0.11:8000/jobs
|
||||
batch-url: http://10.100.0.11:8000/batches
|
||||
url: http://192.168.2.183:8000/jobs
|
||||
batch-url: http://192.168.2.183:8000/batches
|
||||
geojson-dir: /kamco-nfs/requests/
|
||||
jar-path: /kamco-nfs/dataset/shp/shp-exporter-1.0.0.jar
|
||||
jar-path: /kamco-nfs/dataset/shp/shp-exporter.jar
|
||||
inference-server-name: server1,server2,server3,server4
|
||||
|
||||
gukyuin:
|
||||
@@ -79,4 +79,5 @@ training-data:
|
||||
|
||||
layer:
|
||||
geoserver-url: https://kamco.geo-dev.gs.dabeeo.com
|
||||
path: /geoserver/cd/gwc/service/
|
||||
workspace: cd
|
||||
|
||||
Reference in New Issue
Block a user