Merge remote-tracking branch 'origin/feat/infer_dev_260107' into feat/infer_dev_260107

This commit is contained in:
Moon
2026-01-22 13:51:03 +09:00
9 changed files with 80 additions and 98 deletions

View File

@@ -4,16 +4,10 @@ import com.kamco.cd.kamcoback.Innopam.dto.ChngDetectMastDto;
import com.kamco.cd.kamcoback.Innopam.dto.ChngDetectMastDto.ChnDetectMastReqDto; import com.kamco.cd.kamcoback.Innopam.dto.ChngDetectMastDto.ChnDetectMastReqDto;
import com.kamco.cd.kamcoback.Innopam.dto.ChngDetectMastDto.ChngDetectMastSearchDto; import com.kamco.cd.kamcoback.Innopam.dto.ChngDetectMastDto.ChngDetectMastSearchDto;
import com.kamco.cd.kamcoback.Innopam.dto.ChngDetectMastDto.ResReturn; import com.kamco.cd.kamcoback.Innopam.dto.ChngDetectMastDto.ResReturn;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.Basic; import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.Basic;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.DetectMastReq; import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.DetectMastReq;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.DetectMastSearch;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.FeaturePnuDto;
import com.kamco.cd.kamcoback.Innopam.service.DetectMastService;
import com.kamco.cd.kamcoback.Innopam.service.InnopamApiService; import com.kamco.cd.kamcoback.Innopam.service.InnopamApiService;
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
@@ -21,12 +15,9 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import java.util.List; import java.util.List;
import java.util.UUID;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -61,7 +52,6 @@ public class InnopamApiController {
return innopamApiService.regist(chnDetectMastReq); return innopamApiService.regist(chnDetectMastReq);
} }
@Operation(summary = "탐지결과 삭제", description = "탐지결과 삭제") @Operation(summary = "탐지결과 삭제", description = "탐지결과 삭제")
@ApiResponses( @ApiResponses(
value = { value = {
@@ -107,5 +97,4 @@ public class InnopamApiController {
searchDto.setChnDtctSno(chnDtctSno); searchDto.setChnDtctSno(chnDtctSno);
return innopamApiService.list(searchDto); return innopamApiService.list(searchDto);
} }
} }

View File

@@ -439,7 +439,6 @@ public class FIleChecker {
String parentPath = path.getParent().toString(); String parentPath = path.getParent().toString();
String fullPath = path.toAbsolutePath().toString(); String fullPath = path.toAbsolutePath().toString();
File file = new File(fullPath); File file = new File(fullPath);
long fileSize = file.length(); long fileSize = file.length();
String lastModified = dttmFormat.format(new Date(file.lastModified())); String lastModified = dttmFormat.format(new Date(file.lastModified()));

View File

@@ -1,7 +1,5 @@
package com.kamco.cd.kamcoback.config.resttemplate; package com.kamco.cd.kamcoback.config.resttemplate;
import java.net.InetAddress;
import java.net.UnknownHostException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
@@ -71,6 +69,4 @@ public class ExternalHttpClient {
} }
public record ExternalCallResult<T>(int statusCode, boolean success, T body) {} public record ExternalCallResult<T>(int statusCode, boolean success, T body) {}
} }

View File

@@ -2,6 +2,7 @@ package com.kamco.cd.kamcoback.inference;
import com.kamco.cd.kamcoback.config.api.ApiResponseDto; import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultShpDto; import com.kamco.cd.kamcoback.inference.dto.InferenceResultShpDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultShpDto.CreateShpRequest;
import com.kamco.cd.kamcoback.inference.service.InferenceResultShpService; import com.kamco.cd.kamcoback.inference.service.InferenceResultShpService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Content;
@@ -12,8 +13,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@Tag(name = "추론결과 데이터 생성", description = "추론결과 데이터 생성 API") @Tag(name = "추론결과 데이터 생성", description = "추론결과 데이터 생성 API")
@@ -47,11 +48,8 @@ public class InferenceResultShpApiController {
@Operation(summary = "추론결과 shp 생성", description = "추론결과 shp 생성") @Operation(summary = "추론결과 shp 생성", description = "추론결과 shp 생성")
@PostMapping("/shp/{uid}") @PostMapping("/shp/{uid}")
public ApiResponseDto<Void> createShp( public ApiResponseDto<Void> createShp(
@PathVariable String uid, @PathVariable String uid, @RequestBody CreateShpRequest req) {
@RequestParam Long m1BatchId, inferenceResultShpService.createShp(uid, req);
@RequestParam Long m2BatchId,
@RequestParam Long m3BatchId) {
inferenceResultShpService.createShp(uid, m1BatchId, m2BatchId, m3BatchId);
return ApiResponseDto.createOK(null); return ApiResponseDto.createOK(null);
} }
} }

View File

@@ -545,7 +545,8 @@ public class InferenceResultDto {
public String getServerStatusName() { public String getServerStatusName() {
String enumStr = ServerStatus.SAFETY.getText(); String enumStr = ServerStatus.SAFETY.getText();
if( this.cpu_user+this.cpu_system+this.gpuUtil+this.kbmemused == 0 )enumStr = ServerStatus.FAILUR.getText(); if (this.cpu_user + this.cpu_system + this.gpuUtil + this.kbmemused == 0)
enumStr = ServerStatus.FAILUR.getText();
return enumStr; return enumStr;
} }
@@ -553,8 +554,7 @@ public class InferenceResultDto {
String enumId = "SAFETY"; String enumId = "SAFETY";
if (this.cpu_user + this.cpu_system >= 80) { if (this.cpu_user + this.cpu_system >= 80) {
enumId = "CAUTION"; enumId = "CAUTION";
} } else if (this.cpu_user + this.cpu_system + this.memused == 0) {
else if (this.cpu_user + this.cpu_system + this.memused == 0) {
enumId = "FAILUR"; enumId = "FAILUR";
} }
return enumId; return enumId;
@@ -564,8 +564,7 @@ public class InferenceResultDto {
String enumId = "SAFETY"; String enumId = "SAFETY";
if (this.gpuUtil >= 80) { if (this.gpuUtil >= 80) {
enumId = "CAUTION"; enumId = "CAUTION";
} } else if (this.cpu_user + this.cpu_system == 0) {
else if (this.cpu_user + this.cpu_system == 0) {
enumId = "FAILUR"; enumId = "FAILUR";
} }
return enumId; return enumId;
@@ -575,8 +574,7 @@ public class InferenceResultDto {
String enumId = "SAFETY"; String enumId = "SAFETY";
if (this.memused >= 80) { if (this.memused >= 80) {
enumId = "CAUTION"; enumId = "CAUTION";
} } else if (this.cpu_user + this.cpu_system + this.memused == 0) {
else if (this.cpu_user + this.cpu_system + this.memused == 0) {
enumId = "FAILUR"; enumId = "FAILUR";
} }
return enumId; return enumId;
@@ -585,8 +583,7 @@ public class InferenceResultDto {
public String getCpuStatusName() { public String getCpuStatusName() {
if (this.cpu_user + this.cpu_system >= 80) { if (this.cpu_user + this.cpu_system >= 80) {
return ServerStatus.CAUTION.getText(); return ServerStatus.CAUTION.getText();
} } else if (this.cpu_user + this.cpu_system + this.memused == 0) {
else if (this.cpu_user + this.cpu_system + this.memused == 0) {
return ServerStatus.FAILUR.getText(); return ServerStatus.FAILUR.getText();
} }
return ServerStatus.SAFETY.getText(); return ServerStatus.SAFETY.getText();
@@ -595,8 +592,7 @@ public class InferenceResultDto {
public String getGpuStatusName() { public String getGpuStatusName() {
if (this.gpuUtil >= 80) { if (this.gpuUtil >= 80) {
return ServerStatus.CAUTION.getText(); return ServerStatus.CAUTION.getText();
} } else if (this.cpu_user + this.cpu_system + this.memused == 0) {
else if (this.cpu_user + this.cpu_system + this.memused == 0) {
return ServerStatus.FAILUR.getText(); return ServerStatus.FAILUR.getText();
} }
return ServerStatus.SAFETY.getText(); return ServerStatus.SAFETY.getText();
@@ -605,8 +601,7 @@ public class InferenceResultDto {
public String getMemStatusName() { public String getMemStatusName() {
if (this.memused >= 80) { if (this.memused >= 80) {
return ServerStatus.CAUTION.getText(); return ServerStatus.CAUTION.getText();
} } else if (this.cpu_user + this.cpu_system + this.memused == 0) {
else if (this.cpu_user + this.cpu_system + this.memused == 0) {
return ServerStatus.FAILUR.getText(); return ServerStatus.FAILUR.getText();
} }
return ServerStatus.SAFETY.getText(); return ServerStatus.SAFETY.getText();

View File

@@ -102,4 +102,12 @@ public class InferenceResultShpDto {
@Schema(description = "geojson 파일 생성 수 (덮어쓰기 포함)", example = "120") @Schema(description = "geojson 파일 생성 수 (덮어쓰기 포함)", example = "120")
private int geojson; private int geojson;
} }
@Getter
public static class CreateShpRequest {
private Long m1BatchId;
private Long m2BatchId;
private Long m3BatchId;
}
} }

View File

@@ -1,8 +1,5 @@
package com.kamco.cd.kamcoback.inference.service; package com.kamco.cd.kamcoback.inference.service;
import static com.kamco.cd.kamcoback.postgres.entity.QGpuMetricEntity.gpuMetricEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QSystemMetricEntity.systemMetricEntity;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
@@ -519,15 +516,14 @@ public class InferenceResultService {
public List<InferenceServerStatusDto> getInferenceServerStatusList() { public List<InferenceServerStatusDto> getInferenceServerStatusList() {
List<InferenceServerStatusDto> dtoList = inferenceResultCoreService.getInferenceServerStatusList(); List<InferenceServerStatusDto> dtoList =
inferenceResultCoreService.getInferenceServerStatusList();
int size = dtoList.size(); int size = dtoList.size();
System.out.println("size =" + size); System.out.println("size =" + size);
if( size == 0 ) if (size == 0) {
{ for (int k = 1; k <= 4; k++) {
for(int k=1; k<=4; k++)
{
InferenceServerStatusDto dto = new InferenceServerStatusDto(); InferenceServerStatusDto dto = new InferenceServerStatusDto();
dto.setServerName("server0" + k); dto.setServerName("server0" + k);
dto.setCpu_user(0); dto.setCpu_user(0);
@@ -538,11 +534,8 @@ public class InferenceResultService {
dtoList.add(dto); dtoList.add(dto);
} }
} } else {
else for (int k = 1; k <= 4; k++) {
{
for(int k=1; k<=4; k++)
{
String srvNm = "server" + k; String srvNm = "server" + k;
String srvNmChk = "N"; String srvNmChk = "N";
for (InferenceServerStatusDto dto : dtoList) { for (InferenceServerStatusDto dto : dtoList) {
@@ -552,8 +545,7 @@ public class InferenceResultService {
} }
} }
if( srvNmChk.equals("N") ) if (srvNmChk.equals("N")) {
{
InferenceServerStatusDto dto = new InferenceServerStatusDto(); InferenceServerStatusDto dto = new InferenceServerStatusDto();
dto.setServerName(srvNm); dto.setServerName(srvNm);
dto.setCpu_user(0); dto.setCpu_user(0);
@@ -563,9 +555,7 @@ public class InferenceResultService {
dto.setGpuUtil(0); dto.setGpuUtil(0);
dtoList.add(dto); dtoList.add(dto);
} }
} }
} }
dtoList.sort(Comparator.comparing(InferenceServerStatusDto::getServerName)); dtoList.sort(Comparator.comparing(InferenceServerStatusDto::getServerName));

View File

@@ -1,6 +1,7 @@
package com.kamco.cd.kamcoback.inference.service; package com.kamco.cd.kamcoback.inference.service;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultShpDto; import com.kamco.cd.kamcoback.inference.dto.InferenceResultShpDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultShpDto.CreateShpRequest;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultsTestingDto; import com.kamco.cd.kamcoback.inference.dto.InferenceResultsTestingDto;
import com.kamco.cd.kamcoback.postgres.core.InferenceResultCoreService; import com.kamco.cd.kamcoback.postgres.core.InferenceResultCoreService;
import com.kamco.cd.kamcoback.postgres.core.InferenceResultShpCoreService; import com.kamco.cd.kamcoback.postgres.core.InferenceResultShpCoreService;
@@ -36,11 +37,17 @@ public class InferenceResultShpService {
return coreService.buildInferenceData(id); return coreService.buildInferenceData(id);
} }
public void createShp(String uid, Long m1BatchId, Long m2BatchId, Long m3BatchId) { /**
* shp 파일 수동생성
*
* @param uid
* @param req
*/
public void createShp(String uid, CreateShpRequest req) {
List<Long> batchIds = new ArrayList<>(); List<Long> batchIds = new ArrayList<>();
batchIds.add(m1BatchId); batchIds.add(req.getM1BatchId());
batchIds.add(m2BatchId); batchIds.add(req.getM2BatchId());
batchIds.add(m3BatchId); batchIds.add(req.getM3BatchId());
List<InferenceResultsTestingDto.ShpDto> resultList = List<InferenceResultsTestingDto.ShpDto> resultList =
inferenceResultCoreService.getInferenceResults(batchIds); inferenceResultCoreService.getInferenceResults(batchIds);
@@ -58,7 +65,7 @@ public class InferenceResultShpService {
} }
inferenceId = uid; inferenceId = uid;
String mapIds = sb.toString(); String mapIds = sb.toString();
String batchId = m1BatchId + "," + m2BatchId + "," + m3BatchId; String batchId = req.getM1BatchId() + "," + req.getM2BatchId() + "," + req.getM3BatchId();
// shp 파일 비동기 생성 // shp 파일 비동기 생성
shpPipelineService.runPipeline(jarPath, datasetDir, batchId, inferenceId, mapIds); shpPipelineService.runPipeline(jarPath, datasetDir, batchId, inferenceId, mapIds);