shp파일 생성 수정, 미사용 소스 제거

This commit is contained in:
2026-01-23 11:41:25 +09:00
parent 39f9826891
commit ae031e35ca
23 changed files with 53 additions and 1506 deletions

View File

@@ -1,71 +0,0 @@
package com.kamco.cd.kamcoback.common.api;
import com.kamco.cd.kamcoback.common.api.HelloDto.Res;
import com.kamco.cd.kamcoback.common.service.ExternalJarRunner;
import com.kamco.cd.kamcoback.common.service.HelloService;
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient;
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult;
import io.swagger.v3.oas.annotations.Parameter;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@Log4j2
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/hello")
public class HelloApiController {
private final HelloService helloService;
private final ExternalJarRunner externalJarRunner;
private final ExternalHttpClient externalHttpClient;
@GetMapping
public HelloDto.Res hello(HelloDto.Req req) {
req.valid();
Res res = helloService.sayHello(req);
return res;
}
@GetMapping("/shp")
public void shp(
@Parameter(description = "jar 경로", example = "jar/makeshp-1.0.0.jar") @RequestParam
String jarPath,
@Parameter(description = "batchIds", example = "252,253,257") @RequestParam String batchIds,
@Parameter(description = "32길이 문자열 값", example = "") @RequestParam(required = false)
String inferenceId,
@Parameter(description = "5K 도엽번호", example = "") @RequestParam(required = false)
String mapIds) {
externalJarRunner.run(jarPath, batchIds, inferenceId, mapIds);
}
@GetMapping("/batch/{batchId}")
public String batch(@PathVariable String batchId) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setAccept(List.of(MediaType.APPLICATION_JSON));
String url = "http://10.100.0.11:8000/batches" + "/" + batchId;
ExternalCallResult<String> result =
externalHttpClient.call(url, HttpMethod.GET, null, headers, String.class);
int status = result.statusCode();
if (status == 404) {
log.info("Batch not found. batchId={}", batchId);
return null;
}
if (status < 200 || status >= 300) {
return null;
}
return result.toString();
}
}

View File

@@ -1,36 +0,0 @@
package com.kamco.cd.kamcoback.common.api;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
public class HelloDto {
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class Req {
private String id;
public void valid() {
if (id == null) {
throw new IllegalArgumentException(id);
}
}
}
@Getter
public static class Res {
private String id;
private String name;
@Builder
public Res(String id, String name) {
this.id = id;
this.name = name;
}
}
}

View File

@@ -18,27 +18,38 @@ public class ExternalJarRunner {
/**
* shp 파일 생성
*
* @param jarPath jar 경로
* @param batchIds 배치 아이디
* @param jarPath jar 경로
* @param batchIds 배치 아이디
* @param inferenceId uid
* @param mapIds 도엽 Id
* @param mapIds 추론 실행한 도엽 ids
* @param mode <p>MERGED - batch-ids 에 해당하는 **모든 데이터를 하나의 Shapefile로 병합 생성,
* <p>MAP_IDS - 명시적으로 전달한 map-ids만 대상으로 Shapefile 생성,
* <p>RESOLVE - batch-ids 기준으로 **JAR 내부에서 map_ids를 조회**한 뒤 Shapefile 생성
*/
public void run(String jarPath, String batchIds, String inferenceId, String mapIds) {
public void run(String jarPath, String batchIds, String inferenceId, String mapIds, String mode) {
List<String> args = new ArrayList<>();
addArg(args, "converter.inference-id", inferenceId);
addArg(args, "converter.map-ids", mapIds);
addArg(args, "converter.batch-ids", batchIds);
if (mapIds != null && !mapIds.isEmpty()) {
addArg(args, "converter.map-ids", mapIds);
}
if (mode != null && !mode.isEmpty()) {
addArg(args, "converter.mode", mode);
}
execJar(jarPath, args);
}
/**
* geoserver 등록
*
* @param jarPath jar 파일경로
* @param jarPath jar 파일경로
* @param register shp 경로
* @param layer geoserver에 등록될 레이어 이름
* @param layer geoserver에 등록될 레이어 이름
*/
public void run(String jarPath, String register, String layer) {
List<String> args = new ArrayList<>();
@@ -65,7 +76,7 @@ public class ExternalJarRunner {
Process p = pb.start();
try (BufferedReader br =
new BufferedReader(new InputStreamReader(p.getInputStream(), StandardCharsets.UTF_8))) {
new BufferedReader(new InputStreamReader(p.getInputStream(), StandardCharsets.UTF_8))) {
String line;
while ((line = br.readLine()) != null) {
out.append(line).append('\n');

View File

@@ -1,17 +0,0 @@
package com.kamco.cd.kamcoback.common.service;
import com.kamco.cd.kamcoback.common.api.HelloDto;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class HelloService {
public HelloDto.Res sayHello(HelloDto.Req req) {
log.info("hello");
String name = UUID.randomUUID().toString();
return HelloDto.Res.builder().id(req.getId()).name(name).build();
}
}