추론실행 shp파일 생성 jar

This commit is contained in:
2026-01-16 16:56:07 +09:00
parent 53a07da4b1
commit c56259ad80
14 changed files with 310 additions and 12 deletions

View File

@@ -4,18 +4,19 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
import com.kamco.cd.kamcoback.common.service.ExternalJarRunner;
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient;
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.InferenceBatchSheet;
import com.kamco.cd.kamcoback.inference.dto.InferenceProgressDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.SaveInferenceAiDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.Status;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultsTestingDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceSendDto;
import com.kamco.cd.kamcoback.inference.service.InferenceResultShpService;
import com.kamco.cd.kamcoback.postgres.core.InferenceResultCoreService;
import com.kamco.cd.kamcoback.scheduler.dto.JobStatusDto;
import jakarta.transaction.Transactional;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -36,9 +37,9 @@ import org.springframework.stereotype.Service;
public class MapSheetInferenceJobService {
private final InferenceResultCoreService inferenceResultCoreService;
private final InferenceResultShpService inferenceResultShpService;
private final ExternalHttpClient externalHttpClient;
private final ObjectMapper objectMapper;
private final ExternalJarRunner externalJarRunner;
@Value("${inference.batch-url}")
private String batchUrl;
@@ -49,12 +50,11 @@ public class MapSheetInferenceJobService {
@Value("${inference.url}")
private String inferenceUrl;
@Value("${mapsheet.shp.baseurl}")
private String baseDir;
@Value("${inference.jar-path}")
private String jarPath;
/** 추론 진행 배치 1분 */
@Scheduled(fixedDelay = 60_000)
@Transactional
public void runBatch() {
if (isLocalProfile()) {
return;
@@ -213,11 +213,36 @@ public class MapSheetInferenceJobService {
// 추론 종료일때 geom 데이터 저장
inferenceResultCoreService.upsertGeomData(sheet.getId());
// 추론 종료일때 도엽별 실패여부 저장
// TODO jar로 생성하는걸로 변경
// 추론 종료일때 shp 파일 생성
// inferenceResultShpService.createShpFile(sheet.getId());
List<Long> batchIds = new ArrayList<>();
batchIds.add(sheet.getM1BatchId());
batchIds.add(sheet.getM2BatchId());
batchIds.add(sheet.getM3BatchId());
List<InferenceResultsTestingDto.ShpDto> resultList =
inferenceResultCoreService.getInferenceResults(batchIds);
String inferenceId = "";
boolean first = true;
StringBuilder sb = new StringBuilder();
for (InferenceResultsTestingDto.ShpDto dto : resultList) {
if (dto.getMapId() == null) {
continue;
}
if (!sb.isEmpty()) {
sb.append(",");
}
sb.append("\"").append(dto.getMapId()).append("\"");
if (first) {
inferenceId = dto.getUid();
first = false;
}
}
String mapIds = sb.toString();
String batchId = sheet.getM1BatchId() + "," + sheet.getM2BatchId() + "," + sheet.getM3BatchId();
externalJarRunner.run(jarPath, batchId, inferenceId, mapIds);
}
/**
@@ -435,6 +460,7 @@ public class MapSheetInferenceJobService {
.map(Long::valueOf)
.toList();
// 도엽별 실패여부 업데이트
inferenceResultCoreService.saveFail5k(uuid, failedIds, type);
}