From 690e166d4998350c7df76cf8dac22a514c30a7a8 Mon Sep 17 00:00:00 2001 From: Moon Date: Thu, 22 Jan 2026 12:34:53 +0900 Subject: [PATCH 01/11] =?UTF-8?q?=EC=84=9C=EB=B2=84=EC=83=81=ED=83=9C,=20h?= =?UTF-8?q?ttpclient=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Innopam/InnopamApiController.java | 179 +++++------------- .../kamcoback/common/utils/FIleChecker.java | 1 + .../resttemplate/ExternalHttpClient.java | 4 + .../inference/dto/InferenceResultDto.java | 24 ++- .../service/InferenceResultService.java | 37 +++- .../MapSheetLearnRepositoryImpl.java | 4 + 6 files changed, 116 insertions(+), 133 deletions(-) diff --git a/src/main/java/com/kamco/cd/kamcoback/Innopam/InnopamApiController.java b/src/main/java/com/kamco/cd/kamcoback/Innopam/InnopamApiController.java index e266552e..b70631c0 100644 --- a/src/main/java/com/kamco/cd/kamcoback/Innopam/InnopamApiController.java +++ b/src/main/java/com/kamco/cd/kamcoback/Innopam/InnopamApiController.java @@ -1,11 +1,17 @@ package com.kamco.cd.kamcoback.Innopam; +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.ChngDetectMastSearchDto; +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.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.config.api.ApiResponseDto; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; @@ -26,13 +32,13 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -@Tag(name = "이노펨 mockup API", description = "이노펨 mockup API") +@Tag(name = "이노펨 연동 API", description = "이노펨 연동 API") @RestController @RequiredArgsConstructor -@RequestMapping("/api/kcd/cdi/detect") +@RequestMapping("/api/innopam/") public class InnopamApiController { - private final DetectMastService detectMastService; + private final InnopamApiService innopamApiService; /** 탐지결과 등록 */ @Operation(summary = "탐지결과 등록", description = "탐지결과 등록") @@ -49,142 +55,57 @@ public class InnopamApiController { @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @PostMapping("/mast/regist") - public DetectMastReq setChangeDetection( - @RequestBody @Valid DetectMastDto.DetectMastReq detectMast) { - detectMastService.saveDetectMast(detectMast); - return detectMast; + public ChngDetectMastDto.Basic regist( + @RequestBody @Valid ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) { + //innopamApiService.saveDetectMast(chnDetectMastReq); + return innopamApiService.regist(chnDetectMastReq); } + @Operation(summary = "탐지결과 삭제", description = "탐지결과 삭제") @ApiResponses( - value = { - @ApiResponse( - responseCode = "201", - description = "등록 성공", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = DetectMastReq.class))), - @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), - @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - }) + value = { + @ApiResponse( + responseCode = "201", + description = "등록 성공", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = ChnDetectMastReqDto.class))), + @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), + @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) + }) @PostMapping("/mast/remove") - public String deleteChangeDetection(@RequestBody DetectMastReq detectMast) { - return "OK"; + public ResReturn remove( + @RequestBody @Valid ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) { + return innopamApiService.remove(chnDetectMastReq); } @Operation(summary = "탐지결과 등록목록 조회", description = "탐지결과 등록목록 조회") @GetMapping("/mast/list") @ApiResponses( - value = { - @ApiResponse( - responseCode = "200", - description = "목록 성공", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = Basic.class))), - @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), - @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - }) - public List selectChangeDetectionList( - @RequestParam(required = false) String cprsBfYr, - @RequestParam(required = false) String cprsAdYr, - @RequestParam(required = false) Integer dtctSno) { - DetectMastSearch detectMastSearch = new DetectMastSearch(); - detectMastSearch.setCprsAdYr(cprsAdYr); - detectMastSearch.setCprsBfYr(cprsBfYr); - detectMastSearch.setDtctSno(dtctSno); - return detectMastService.selectDetectMast(detectMastSearch); + value = { + @ApiResponse( + responseCode = "200", + description = "목록 성공", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = Basic.class))), + @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), + @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) + }) + public List selectChangeDetectionList( + @RequestParam(required = false) String chnDtctId, + @RequestParam(required = false) String cprsYr, + @RequestParam(required = false) String crtrYr, + @RequestParam(required = false) String chnDtctSno) { + ChngDetectMastSearchDto searchDto = new ChngDetectMastSearchDto(); + searchDto.setChnDtctId(chnDtctId); + searchDto.setCprsYr(cprsYr); + searchDto.setCrtrYr(crtrYr); + searchDto.setChnDtctSno(chnDtctSno); + return innopamApiService.list(searchDto); } - @Operation(summary = "탐지결과 등록목록 상세 조회", description = "탐지결과 등록목록 상세 조회") - @ApiResponses( - value = { - @ApiResponse( - responseCode = "200", - description = "목록 성공", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = Basic.class))), - @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), - @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - }) - @GetMapping("/mast/list/{dtctMstId}") - public Basic selectChangeDetectionDetail(@PathVariable Long dtctMstId) { - return detectMastService.selectDetectMast(dtctMstId); - } - - @Operation(summary = "탐지객체 랜덤 PNU 리스트 조회", description = "탐지객체 PNU 랜덤값을 생성해서 보여준다") - @ApiResponses( - value = { - @ApiResponse( - responseCode = "200", - description = "목록 성공", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = FeaturePnuDto.class))), - @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), - @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - }) - @GetMapping("/pnu/{cprsBfYr}/{cprsAfYr}/{dtctSno}") - public List selectPnuList( - @PathVariable String cprsBfYr, @PathVariable String cprsAfYr, @PathVariable Integer dtctSno) { - DetectMastSearch detectMastSearch = new DetectMastSearch(); - detectMastSearch.setCprsAdYr(cprsAfYr); - detectMastSearch.setCprsBfYr(cprsBfYr); - detectMastSearch.setDtctSno(dtctSno); - return detectMastService.findPnuData(detectMastSearch); - } - - @Operation(summary = "탐지객체 랜덤 PNU 상세 조회", description = "탐지객체 PNU 랜덤값을 생성해서 보여준다") - @ApiResponses( - value = { - @ApiResponse( - responseCode = "200", - description = "목록 성공", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = FeaturePnuDto.class))), - @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), - @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - }) - @GetMapping("/pnu/{cprsBfYr}/{cprsAfYr}/{dtctSno}/{featureId}") - public FeaturePnuDto selectPnuDetail( - @Parameter(description = "이전년도", example = "2022") @PathVariable String cprsBfYr, - @Parameter(description = "기준년도", example = "2024") @PathVariable String cprsAfYr, - @Parameter(description = "회차", example = "4") @PathVariable Integer dtctSno, - @Parameter(description = "featureId", example = "000e161b-1955-4c89-ad87-0b3b4a91d00f") - @PathVariable - UUID featureId) { - return detectMastService.selectPnuDetail(featureId); - } - - @Operation( - summary = "탐지객체 랜덤 PNU GEOM 업데이트(이노펨에 없는 API)", - description = "탐지객체 랜덤 PNU GEOM 업데이트(이노펨에 없는 API)") - @ApiResponses( - value = { - @ApiResponse( - responseCode = "201", - description = "pnu 업데이트 성공", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = Integer.class))), - @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), - @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - }) - @PutMapping("/pnu/{cprsBfYr}/{cprsAfYr}/{dtctSno}") - public Integer updatePnuList( - @PathVariable String cprsBfYr, @PathVariable String cprsAfYr, @PathVariable Integer dtctSno) { - DetectMastSearch detectMastSearch = new DetectMastSearch(); - detectMastSearch.setCprsAdYr(cprsAfYr); - detectMastSearch.setCprsBfYr(cprsBfYr); - detectMastSearch.setDtctSno(dtctSno); - return detectMastService.updatePnuData(detectMastSearch); - } } diff --git a/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java b/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java index fbe82c07..28656121 100644 --- a/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java +++ b/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java @@ -439,6 +439,7 @@ public class FIleChecker { String parentPath = path.getParent().toString(); String fullPath = path.toAbsolutePath().toString(); + File file = new File(fullPath); long fileSize = file.length(); String lastModified = dttmFormat.format(new Date(file.lastModified())); diff --git a/src/main/java/com/kamco/cd/kamcoback/config/resttemplate/ExternalHttpClient.java b/src/main/java/com/kamco/cd/kamcoback/config/resttemplate/ExternalHttpClient.java index 013e01b5..928e72d1 100644 --- a/src/main/java/com/kamco/cd/kamcoback/config/resttemplate/ExternalHttpClient.java +++ b/src/main/java/com/kamco/cd/kamcoback/config/resttemplate/ExternalHttpClient.java @@ -1,5 +1,7 @@ package com.kamco.cd.kamcoback.config.resttemplate; +import java.net.InetAddress; +import java.net.UnknownHostException; import lombok.RequiredArgsConstructor; import lombok.extern.log4j.Log4j2; import org.springframework.http.HttpEntity; @@ -69,4 +71,6 @@ public class ExternalHttpClient { } public record ExternalCallResult(int statusCode, boolean success, T body) {} + + } diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java b/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java index 9c8f5f37..e5eb4a0a 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java @@ -537,9 +537,9 @@ public class InferenceResultDto { } public String getServerStatusName() { - // String enumId = "SAFETY"; - // if( this.cpu_user+this.cpu_system >= 80 )enumId = "CAUTION"; - return ServerStatus.SAFETY.getText(); + String enumStr = ServerStatus.SAFETY.getText(); + if( this.cpu_user+this.cpu_system+this.gpuUtil+this.kbmemused == 0 )enumStr = ServerStatus.FAILUR.getText(); + return enumStr; } public String getCpuStatus() { @@ -547,6 +547,9 @@ public class InferenceResultDto { if (this.cpu_user + this.cpu_system >= 80) { enumId = "CAUTION"; } + else if (this.cpu_user + this.cpu_system == 0) { + enumId = "FAILUR"; + } return enumId; } @@ -555,6 +558,9 @@ public class InferenceResultDto { if (this.gpuUtil >= 80) { enumId = "CAUTION"; } + else if (this.cpu_user + this.cpu_system == 0) { + enumId = "FAILUR"; + } return enumId; } @@ -563,6 +569,9 @@ public class InferenceResultDto { if (this.memused >= 80) { enumId = "CAUTION"; } + else if (this.cpu_user + this.cpu_system == 0) { + enumId = "FAILUR"; + } return enumId; } @@ -570,6 +579,9 @@ public class InferenceResultDto { if (this.cpu_user + this.cpu_system >= 80) { return ServerStatus.CAUTION.getText(); } + else if (this.cpu_user + this.cpu_system == 0) { + return ServerStatus.FAILUR.getText(); + } return ServerStatus.SAFETY.getText(); } @@ -577,6 +589,9 @@ public class InferenceResultDto { if (this.gpuUtil >= 80) { return ServerStatus.CAUTION.getText(); } + else if (this.cpu_user + this.cpu_system == 0) { + return ServerStatus.FAILUR.getText(); + } return ServerStatus.SAFETY.getText(); } @@ -584,6 +599,9 @@ public class InferenceResultDto { if (this.memused >= 80) { return ServerStatus.CAUTION.getText(); } + else if (this.cpu_user + this.cpu_system == 0) { + return ServerStatus.FAILUR.getText(); + } return ServerStatus.SAFETY.getText(); } } diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java b/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java index d6bef76f..798d9a72 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java @@ -1,5 +1,8 @@ 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.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -514,7 +517,39 @@ public class InferenceResultService { } public List getInferenceServerStatusList() { - return inferenceResultCoreService.getInferenceServerStatusList(); + + List dtoList = inferenceResultCoreService.getInferenceServerStatusList(); + int size = dtoList.size(); + + System.out.println("size ="+size); + + if( size == 0 ) + { + for(int k=0; k<4; k++) + { + InferenceServerStatusDto dto = new InferenceServerStatusDto(); + dto.setServerName("server0"+k); + dto.setCpu_user(0); + dto.setCpu_system(0); + dto.setMemused(0); + dto.setKbmemused(0L); + dto.setGpuUtil(0); + + dtoList.add(dto); + } + } + + /* + systemMetricEntity.serverName, + systemMetricEntity.cpuUser, + systemMetricEntity.cpuSystem, + systemMetricEntity.memused, + systemMetricEntity.kbmemused, + gpuMetricEntity.gpuUtil + */ + //if( dtoList) + + return dtoList; } /** diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java index cb43eadb..1d659c99 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java @@ -118,6 +118,8 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto queryFactory .select(systemMetricEntity.timestamp.max()) .from(systemMetricEntity) + //.where(systemMetricEntity.timestamp.goe(OffsetDateTime.now().minusMinutes(5))) + .where(systemMetricEntity.timestamp.goe(OffsetDateTime.now().minusSeconds(30))) .groupBy(systemMetricEntity.serverName) .fetch(); @@ -125,6 +127,8 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto queryFactory .select(gpuMetricEntity.timestamp.max()) .from(gpuMetricEntity) + //.where(gpuMetricEntity.timestamp.goe(OffsetDateTime.now().minusMinutes(5))) + .where(gpuMetricEntity.timestamp.goe(OffsetDateTime.now().minusSeconds(30))) .groupBy(gpuMetricEntity.serverName) .fetch(); From 14394eb909b2e176630c9e991aaa261be704ea9d Mon Sep 17 00:00:00 2001 From: teddy Date: Thu, 22 Jan 2026 13:31:03 +0900 Subject: [PATCH 02/11] =?UTF-8?q?=EC=B6=94=EB=A1=A0=20=EA=B2=B0=EA=B3=BC?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/enums/ImageryFitStatus.java | 17 +++++++++++++++++ .../inference/InferenceResultApiController.java | 6 +++--- .../inference/dto/InferenceDetailDto.java | 12 ++++++++++++ .../service/InferenceResultService.java | 3 ++- .../Inference/MapSheetLearnRepositoryImpl.java | 2 +- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/kamco/cd/kamcoback/common/enums/ImageryFitStatus.java b/src/main/java/com/kamco/cd/kamcoback/common/enums/ImageryFitStatus.java index c5f3aa20..ad7df5a3 100644 --- a/src/main/java/com/kamco/cd/kamcoback/common/enums/ImageryFitStatus.java +++ b/src/main/java/com/kamco/cd/kamcoback/common/enums/ImageryFitStatus.java @@ -2,6 +2,7 @@ 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 java.util.Arrays; import lombok.AllArgsConstructor; import lombok.Getter; @@ -23,4 +24,20 @@ public enum ImageryFitStatus implements EnumType { public String getText() { return desc; } + + public static ImageryFitStatus fromCode(String code) { + if (code == null) { + return null; + } + String c = code.trim(); + return Arrays.stream(values()) + .filter(v -> v.name().equalsIgnoreCase(c)) + .findFirst() + .orElse(null); + } + + public static String getDescByCode(String code) { + ImageryFitStatus status = fromCode(code); + return status != null ? status.getDesc() : null; + } } diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/InferenceResultApiController.java b/src/main/java/com/kamco/cd/kamcoback/inference/InferenceResultApiController.java index 2c977bef..0ffde09a 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/InferenceResultApiController.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/InferenceResultApiController.java @@ -168,9 +168,9 @@ public class InferenceResultApiController { @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @DeleteMapping("/end") - public ApiResponseDto getInferenceGeomList() { - inferenceResultService.deleteInferenceEnd(); - return ApiResponseDto.ok(null); + public ApiResponseDto getInferenceGeomList() { + UUID uuid = inferenceResultService.deleteInferenceEnd(); + return ApiResponseDto.ok(uuid); } @Operation(summary = "분석 모델 선택 조회", description = "변화탐지 실행 정보 입력 모델선택 팝업 ") diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceDetailDto.java b/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceDetailDto.java index 4f4f4413..c187d03d 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceDetailDto.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceDetailDto.java @@ -2,7 +2,9 @@ package com.kamco.cd.kamcoback.inference.dto; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; import com.kamco.cd.kamcoback.common.enums.DetectionClassification; +import com.kamco.cd.kamcoback.common.enums.ImageryFitStatus; import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm; import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.DetectOption; import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetScope; @@ -308,6 +310,16 @@ public class InferenceDetailDto { String pnu; String passYn; + @JsonProperty("passYn") + public String getPassYn() { + return this.passYn == null ? null : this.passYn; + } + + @JsonProperty("passYnName") + public String getPassYnName() { + return ImageryFitStatus.getDescByCode(this.passYn); + } + // @JsonIgnore String gemoStr; // @JsonIgnore String geomCenterStr; // JsonNode gemo; diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java b/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java index d6bef76f..71307414 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java @@ -542,7 +542,7 @@ public class InferenceResultService { /** 추론 종료 */ @Transactional - public void deleteInferenceEnd() { + public UUID deleteInferenceEnd() { SaveInferenceAiDto dto = inferenceResultCoreService.getProcessing(); if (dto == null) { throw new CustomApiException("NOT_FOUND", HttpStatus.NOT_FOUND); @@ -571,6 +571,7 @@ public class InferenceResultService { // upsertGeomData Long learnId = inferenceResultCoreService.getInferenceLearnIdByUuid(dto.getUuid()); inferenceResultCoreService.upsertGeomData(learnId); + return dto.getUuid(); } /** diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java index 0c332003..1ba1768b 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java @@ -442,7 +442,7 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto "substring({0} from 1 for 8)", mapSheetAnalDataInferenceGeomEntity.resultUid), pnu, - Expressions.nullExpression(String.class))) + mapSheetAnalDataInferenceGeomEntity.passYn)) .from(mapSheetAnalInferenceEntity) .join(mapSheetAnalDataInferenceEntity) .on(mapSheetAnalDataInferenceEntity.analUid.eq(mapSheetAnalInferenceEntity.id)) From f1a673d3674324c6de339a4722dbde84b67aa3c8 Mon Sep 17 00:00:00 2001 From: Moon Date: Thu, 22 Jan 2026 13:38:50 +0900 Subject: [PATCH 03/11] =?UTF-8?q?=EC=84=9C=EB=B2=84=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inference/dto/InferenceResultDto.java | 11 ++--- .../service/InferenceResultService.java | 41 ++++++++++++++----- .../MapSheetLearnRepositoryImpl.java | 8 ++-- 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java b/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java index f6920397..711e5006 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java @@ -538,6 +538,7 @@ public class InferenceResultDto { public String getServerStatus() { String enumId = "SAFETY"; + if( this.cpu_user+this.cpu_system+this.gpuUtil+this.kbmemused == 0 )enumId = "FAILUR"; // if( this.cpu_user+this.cpu_system >= 80 )enumId = "CAUTION"; return enumId; } @@ -553,7 +554,7 @@ public class InferenceResultDto { if (this.cpu_user + this.cpu_system >= 80) { enumId = "CAUTION"; } - else if (this.cpu_user + this.cpu_system == 0) { + else if (this.cpu_user + this.cpu_system + this.memused == 0) { enumId = "FAILUR"; } return enumId; @@ -575,7 +576,7 @@ public class InferenceResultDto { if (this.memused >= 80) { enumId = "CAUTION"; } - else if (this.cpu_user + this.cpu_system == 0) { + else if (this.cpu_user + this.cpu_system + this.memused == 0) { enumId = "FAILUR"; } return enumId; @@ -585,7 +586,7 @@ public class InferenceResultDto { if (this.cpu_user + this.cpu_system >= 80) { return ServerStatus.CAUTION.getText(); } - else if (this.cpu_user + this.cpu_system == 0) { + else if (this.cpu_user + this.cpu_system + this.memused == 0) { return ServerStatus.FAILUR.getText(); } return ServerStatus.SAFETY.getText(); @@ -595,7 +596,7 @@ public class InferenceResultDto { if (this.gpuUtil >= 80) { return ServerStatus.CAUTION.getText(); } - else if (this.cpu_user + this.cpu_system == 0) { + else if (this.cpu_user + this.cpu_system + this.memused == 0) { return ServerStatus.FAILUR.getText(); } return ServerStatus.SAFETY.getText(); @@ -605,7 +606,7 @@ public class InferenceResultDto { if (this.memused >= 80) { return ServerStatus.CAUTION.getText(); } - else if (this.cpu_user + this.cpu_system == 0) { + else if (this.cpu_user + this.cpu_system + this.memused == 0) { return ServerStatus.FAILUR.getText(); } return ServerStatus.SAFETY.getText(); diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java b/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java index 798d9a72..e9cf0ef0 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java @@ -44,6 +44,7 @@ import jakarta.validation.constraints.NotNull; import java.nio.file.Path; import java.time.ZonedDateTime; import java.util.ArrayList; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -525,7 +526,7 @@ public class InferenceResultService { if( size == 0 ) { - for(int k=0; k<4; k++) + for(int k=1; k<=4; k++) { InferenceServerStatusDto dto = new InferenceServerStatusDto(); dto.setServerName("server0"+k); @@ -538,16 +539,36 @@ public class InferenceResultService { dtoList.add(dto); } } + else + { + for(int k=1; k<=4; k++) + { + String srvNm = "server"+k; + String srvNmChk = "N"; + for (InferenceServerStatusDto dto : dtoList) { + if( srvNm.equals(dto.getServerName()) ){ + srvNmChk = "Y"; + break; + } + } - /* - systemMetricEntity.serverName, - systemMetricEntity.cpuUser, - systemMetricEntity.cpuSystem, - systemMetricEntity.memused, - systemMetricEntity.kbmemused, - gpuMetricEntity.gpuUtil - */ - //if( dtoList) + if( srvNmChk.equals("N") ) + { + InferenceServerStatusDto dto = new InferenceServerStatusDto(); + dto.setServerName(srvNm); + dto.setCpu_user(0); + dto.setCpu_system(0); + dto.setMemused(0); + dto.setKbmemused(0L); + dto.setGpuUtil(0); + dtoList.add(dto); + } + + } + + } + + dtoList.sort(Comparator.comparing(InferenceServerStatusDto::getServerName)); return dtoList; } diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java index 667771e1..f334efed 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java @@ -121,8 +121,8 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto queryFactory .select(systemMetricEntity.timestamp.max()) .from(systemMetricEntity) - //.where(systemMetricEntity.timestamp.goe(OffsetDateTime.now().minusMinutes(5))) - .where(systemMetricEntity.timestamp.goe(OffsetDateTime.now().minusSeconds(30))) + .where(systemMetricEntity.timestamp.goe(OffsetDateTime.now().minusMinutes(5))) + //.where(systemMetricEntity.timestamp.goe(OffsetDateTime.now().minusSeconds(30))) .groupBy(systemMetricEntity.serverName) .fetch(); @@ -130,8 +130,8 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto queryFactory .select(gpuMetricEntity.timestamp.max()) .from(gpuMetricEntity) - //.where(gpuMetricEntity.timestamp.goe(OffsetDateTime.now().minusMinutes(5))) - .where(gpuMetricEntity.timestamp.goe(OffsetDateTime.now().minusSeconds(30))) + .where(gpuMetricEntity.timestamp.goe(OffsetDateTime.now().minusMinutes(5))) + //.where(gpuMetricEntity.timestamp.goe(OffsetDateTime.now().minusSeconds(30))) .groupBy(gpuMetricEntity.serverName) .fetch(); From d92b38b9d519a9309b2096ff45c0f8cf549e07d4 Mon Sep 17 00:00:00 2001 From: teddy Date: Thu, 22 Jan 2026 13:42:46 +0900 Subject: [PATCH 04/11] =?UTF-8?q?shp=20=EC=88=98=EB=8F=99=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InferenceResultShpApiController.java | 10 ++++------ .../inference/dto/InferenceResultShpDto.java | 8 ++++++++ .../service/InferenceResultShpService.java | 17 ++++++++++++----- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/InferenceResultShpApiController.java b/src/main/java/com/kamco/cd/kamcoback/inference/InferenceResultShpApiController.java index d5b4cfbb..c4fa7307 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/InferenceResultShpApiController.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/InferenceResultShpApiController.java @@ -2,6 +2,7 @@ package com.kamco.cd.kamcoback.inference; import com.kamco.cd.kamcoback.config.api.ApiResponseDto; 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 io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; @@ -12,8 +13,8 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; @Tag(name = "추론결과 데이터 생성", description = "추론결과 데이터 생성 API") @@ -47,11 +48,8 @@ public class InferenceResultShpApiController { @Operation(summary = "추론결과 shp 생성", description = "추론결과 shp 생성") @PostMapping("/shp/{uid}") public ApiResponseDto createShp( - @PathVariable String uid, - @RequestParam Long m1BatchId, - @RequestParam Long m2BatchId, - @RequestParam Long m3BatchId) { - inferenceResultShpService.createShp(uid, m1BatchId, m2BatchId, m3BatchId); + @PathVariable String uid, @RequestBody CreateShpRequest req) { + inferenceResultShpService.createShp(uid, req); return ApiResponseDto.createOK(null); } } diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultShpDto.java b/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultShpDto.java index 566699dc..20e0ac05 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultShpDto.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultShpDto.java @@ -102,4 +102,12 @@ public class InferenceResultShpDto { @Schema(description = "geojson 파일 생성 수 (덮어쓰기 포함)", example = "120") private int geojson; } + + @Getter + public static class CreateShpRequest { + + private Long m1BatchId; + private Long m2BatchId; + private Long m3BatchId; + } } diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultShpService.java b/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultShpService.java index db8c4b78..d6a2a1c7 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultShpService.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultShpService.java @@ -1,6 +1,7 @@ package com.kamco.cd.kamcoback.inference.service; 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.postgres.core.InferenceResultCoreService; import com.kamco.cd.kamcoback.postgres.core.InferenceResultShpCoreService; @@ -36,11 +37,17 @@ public class InferenceResultShpService { 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 batchIds = new ArrayList<>(); - batchIds.add(m1BatchId); - batchIds.add(m2BatchId); - batchIds.add(m3BatchId); + batchIds.add(req.getM1BatchId()); + batchIds.add(req.getM2BatchId()); + batchIds.add(req.getM3BatchId()); List resultList = inferenceResultCoreService.getInferenceResults(batchIds); @@ -58,7 +65,7 @@ public class InferenceResultShpService { } inferenceId = uid; String mapIds = sb.toString(); - String batchId = m1BatchId + "," + m2BatchId + "," + m3BatchId; + String batchId = req.getM1BatchId() + "," + req.getM2BatchId() + "," + req.getM3BatchId(); // shp 파일 비동기 생성 shpPipelineService.runPipeline(jarPath, datasetDir, batchId, inferenceId, mapIds); From 890e7c65d3441ecdd09c1fb787552b41bd129a00 Mon Sep 17 00:00:00 2001 From: teddy Date: Thu, 22 Jan 2026 13:43:21 +0900 Subject: [PATCH 05/11] =?UTF-8?q?spotlessApply=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Innopam/InnopamApiController.java | 77 ++++++++----------- .../kamcoback/common/utils/FIleChecker.java | 1 - .../resttemplate/ExternalHttpClient.java | 4 - .../inference/dto/InferenceResultDto.java | 23 +++--- .../service/InferenceResultService.java | 32 +++----- .../MapSheetLearnRepositoryImpl.java | 6 +- 6 files changed, 56 insertions(+), 87 deletions(-) diff --git a/src/main/java/com/kamco/cd/kamcoback/Innopam/InnopamApiController.java b/src/main/java/com/kamco/cd/kamcoback/Innopam/InnopamApiController.java index b70631c0..cf4d49eb 100644 --- a/src/main/java/com/kamco/cd/kamcoback/Innopam/InnopamApiController.java +++ b/src/main/java/com/kamco/cd/kamcoback/Innopam/InnopamApiController.java @@ -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.ChngDetectMastSearchDto; 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.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.config.api.ApiResponseDto; 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.Schema; 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 jakarta.validation.Valid; import java.util.List; -import java.util.UUID; import lombok.RequiredArgsConstructor; 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.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -57,55 +48,53 @@ public class InnopamApiController { @PostMapping("/mast/regist") public ChngDetectMastDto.Basic regist( @RequestBody @Valid ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) { - //innopamApiService.saveDetectMast(chnDetectMastReq); + // innopamApiService.saveDetectMast(chnDetectMastReq); return innopamApiService.regist(chnDetectMastReq); } - @Operation(summary = "탐지결과 삭제", description = "탐지결과 삭제") @ApiResponses( - value = { - @ApiResponse( - responseCode = "201", - description = "등록 성공", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = ChnDetectMastReqDto.class))), - @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), - @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - }) + value = { + @ApiResponse( + responseCode = "201", + description = "등록 성공", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = ChnDetectMastReqDto.class))), + @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), + @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) + }) @PostMapping("/mast/remove") public ResReturn remove( - @RequestBody @Valid ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) { + @RequestBody @Valid ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) { return innopamApiService.remove(chnDetectMastReq); } @Operation(summary = "탐지결과 등록목록 조회", description = "탐지결과 등록목록 조회") @GetMapping("/mast/list") @ApiResponses( - value = { - @ApiResponse( - responseCode = "200", - description = "목록 성공", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = Basic.class))), - @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), - @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - }) + value = { + @ApiResponse( + responseCode = "200", + description = "목록 성공", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = Basic.class))), + @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), + @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) + }) public List selectChangeDetectionList( - @RequestParam(required = false) String chnDtctId, - @RequestParam(required = false) String cprsYr, - @RequestParam(required = false) String crtrYr, - @RequestParam(required = false) String chnDtctSno) { - ChngDetectMastSearchDto searchDto = new ChngDetectMastSearchDto(); - searchDto.setChnDtctId(chnDtctId); - searchDto.setCprsYr(cprsYr); - searchDto.setCrtrYr(crtrYr); - searchDto.setChnDtctSno(chnDtctSno); + @RequestParam(required = false) String chnDtctId, + @RequestParam(required = false) String cprsYr, + @RequestParam(required = false) String crtrYr, + @RequestParam(required = false) String chnDtctSno) { + ChngDetectMastSearchDto searchDto = new ChngDetectMastSearchDto(); + searchDto.setChnDtctId(chnDtctId); + searchDto.setCprsYr(cprsYr); + searchDto.setCrtrYr(crtrYr); + searchDto.setChnDtctSno(chnDtctSno); return innopamApiService.list(searchDto); } - } diff --git a/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java b/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java index 28656121..fbe82c07 100644 --- a/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java +++ b/src/main/java/com/kamco/cd/kamcoback/common/utils/FIleChecker.java @@ -439,7 +439,6 @@ public class FIleChecker { String parentPath = path.getParent().toString(); String fullPath = path.toAbsolutePath().toString(); - File file = new File(fullPath); long fileSize = file.length(); String lastModified = dttmFormat.format(new Date(file.lastModified())); diff --git a/src/main/java/com/kamco/cd/kamcoback/config/resttemplate/ExternalHttpClient.java b/src/main/java/com/kamco/cd/kamcoback/config/resttemplate/ExternalHttpClient.java index 928e72d1..013e01b5 100644 --- a/src/main/java/com/kamco/cd/kamcoback/config/resttemplate/ExternalHttpClient.java +++ b/src/main/java/com/kamco/cd/kamcoback/config/resttemplate/ExternalHttpClient.java @@ -1,7 +1,5 @@ package com.kamco.cd.kamcoback.config.resttemplate; -import java.net.InetAddress; -import java.net.UnknownHostException; import lombok.RequiredArgsConstructor; import lombok.extern.log4j.Log4j2; import org.springframework.http.HttpEntity; @@ -71,6 +69,4 @@ public class ExternalHttpClient { } public record ExternalCallResult(int statusCode, boolean success, T body) {} - - } diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java b/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java index 711e5006..657c5132 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceResultDto.java @@ -538,14 +538,15 @@ public class InferenceResultDto { public String getServerStatus() { String enumId = "SAFETY"; - if( this.cpu_user+this.cpu_system+this.gpuUtil+this.kbmemused == 0 )enumId = "FAILUR"; + if (this.cpu_user + this.cpu_system + this.gpuUtil + this.kbmemused == 0) enumId = "FAILUR"; // if( this.cpu_user+this.cpu_system >= 80 )enumId = "CAUTION"; return enumId; } public String getServerStatusName() { 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; } @@ -553,8 +554,7 @@ public class InferenceResultDto { String enumId = "SAFETY"; if (this.cpu_user + this.cpu_system >= 80) { 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"; } return enumId; @@ -564,8 +564,7 @@ public class InferenceResultDto { String enumId = "SAFETY"; if (this.gpuUtil >= 80) { enumId = "CAUTION"; - } - else if (this.cpu_user + this.cpu_system == 0) { + } else if (this.cpu_user + this.cpu_system == 0) { enumId = "FAILUR"; } return enumId; @@ -575,8 +574,7 @@ public class InferenceResultDto { String enumId = "SAFETY"; if (this.memused >= 80) { 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"; } return enumId; @@ -585,8 +583,7 @@ public class InferenceResultDto { public String getCpuStatusName() { if (this.cpu_user + this.cpu_system >= 80) { 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.SAFETY.getText(); @@ -595,8 +592,7 @@ public class InferenceResultDto { public String getGpuStatusName() { if (this.gpuUtil >= 80) { 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.SAFETY.getText(); @@ -605,8 +601,7 @@ public class InferenceResultDto { public String getMemStatusName() { if (this.memused >= 80) { 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.SAFETY.getText(); diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java b/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java index 04c63e15..49709195 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/service/InferenceResultService.java @@ -1,8 +1,5 @@ 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.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -519,17 +516,16 @@ public class InferenceResultService { public List getInferenceServerStatusList() { - List dtoList = inferenceResultCoreService.getInferenceServerStatusList(); + List dtoList = + inferenceResultCoreService.getInferenceServerStatusList(); int size = dtoList.size(); - System.out.println("size ="+size); + System.out.println("size =" + size); - if( size == 0 ) - { - for(int k=1; k<=4; k++) - { + if (size == 0) { + for (int k = 1; k <= 4; k++) { InferenceServerStatusDto dto = new InferenceServerStatusDto(); - dto.setServerName("server0"+k); + dto.setServerName("server0" + k); dto.setCpu_user(0); dto.setCpu_system(0); dto.setMemused(0); @@ -538,22 +534,18 @@ public class InferenceResultService { dtoList.add(dto); } - } - else - { - for(int k=1; k<=4; k++) - { - String srvNm = "server"+k; + } else { + for (int k = 1; k <= 4; k++) { + String srvNm = "server" + k; String srvNmChk = "N"; for (InferenceServerStatusDto dto : dtoList) { - if( srvNm.equals(dto.getServerName()) ){ + if (srvNm.equals(dto.getServerName())) { srvNmChk = "Y"; break; } } - if( srvNmChk.equals("N") ) - { + if (srvNmChk.equals("N")) { InferenceServerStatusDto dto = new InferenceServerStatusDto(); dto.setServerName(srvNm); dto.setCpu_user(0); @@ -563,9 +555,7 @@ public class InferenceResultService { dto.setGpuUtil(0); dtoList.add(dto); } - } - } dtoList.sort(Comparator.comparing(InferenceServerStatusDto::getServerName)); diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java index 82550b3b..813081e5 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java @@ -121,8 +121,8 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto queryFactory .select(systemMetricEntity.timestamp.max()) .from(systemMetricEntity) - .where(systemMetricEntity.timestamp.goe(OffsetDateTime.now().minusMinutes(5))) - //.where(systemMetricEntity.timestamp.goe(OffsetDateTime.now().minusSeconds(30))) + .where(systemMetricEntity.timestamp.goe(OffsetDateTime.now().minusMinutes(5))) + // .where(systemMetricEntity.timestamp.goe(OffsetDateTime.now().minusSeconds(30))) .groupBy(systemMetricEntity.serverName) .fetch(); @@ -131,7 +131,7 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto .select(gpuMetricEntity.timestamp.max()) .from(gpuMetricEntity) .where(gpuMetricEntity.timestamp.goe(OffsetDateTime.now().minusMinutes(5))) - //.where(gpuMetricEntity.timestamp.goe(OffsetDateTime.now().minusSeconds(30))) + // .where(gpuMetricEntity.timestamp.goe(OffsetDateTime.now().minusSeconds(30))) .groupBy(gpuMetricEntity.serverName) .fetch(); From 4af9ade77f63db25cce27c56ff052d37870b4a6d Mon Sep 17 00:00:00 2001 From: Moon Date: Thu, 22 Jan 2026 13:44:03 +0900 Subject: [PATCH 06/11] =?UTF-8?q?=EB=84=A4=ED=8A=B8=EC=9B=8C=ED=81=AC?= =?UTF-8?q?=EC=97=B0=EA=B3=84=EC=9C=A0=ED=8B=B8=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cd/kamcoback/common/utils/NetUtils.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/main/java/com/kamco/cd/kamcoback/common/utils/NetUtils.java diff --git a/src/main/java/com/kamco/cd/kamcoback/common/utils/NetUtils.java b/src/main/java/com/kamco/cd/kamcoback/common/utils/NetUtils.java new file mode 100644 index 00000000..3426057e --- /dev/null +++ b/src/main/java/com/kamco/cd/kamcoback/common/utils/NetUtils.java @@ -0,0 +1,64 @@ +package com.kamco.cd.kamcoback.common.utils; + +import com.fasterxml.jackson.databind.ObjectMapper; +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.regex.Pattern; +import java.util.stream.Collectors; +import org.mindrot.jbcrypt.BCrypt; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; + +public class NetUtils { + + public String getLocalIP(){ + + String ip; + { + try { + InetAddress local = InetAddress.getLocalHost(); + ip = local.getHostAddress(); + } catch (UnknownHostException e) { + throw new RuntimeException(e); + } + } + + return ip; + } + + + public String dtoToQueryString(Object dto, String queryString) { + ObjectMapper objectMapper = new ObjectMapper(); + // 1. DTO를 Map으로 변환 + Map map = objectMapper.convertValue(dto, Map.class); + + String qStr = map.entrySet().stream() + .filter(entry -> entry.getValue() != null) // null 제외 + .map(entry -> String.format("%s=%s", + entry.getKey(), + URLEncoder.encode(entry.getValue().toString(), StandardCharsets.UTF_8))) + .collect(Collectors.joining("&")); + + if( queryString == null || queryString.isEmpty() ) { + queryString = "?"+qStr; + }else{ + queryString = queryString +"&" + qStr; + } + + // 2. Map을 쿼리 스트링 문자열로 변환 + return queryString; + } + + public HttpHeaders jsonHeaders() { + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.setAccept(List.of(MediaType.APPLICATION_JSON)); + + return headers; + } + +} From fc0190c4ce7d2521704fb0003cd57612b6e69c98 Mon Sep 17 00:00:00 2001 From: Moon Date: Thu, 22 Jan 2026 13:49:59 +0900 Subject: [PATCH 07/11] =?UTF-8?q?=EC=B6=94=EB=A1=A0=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Innopam/dto/ChngDetectMastDto.java | 155 ++++++++++++++++++ .../Innopam/service/InnopamApiService.java | 134 +++++++++++++++ 2 files changed, 289 insertions(+) create mode 100644 src/main/java/com/kamco/cd/kamcoback/Innopam/dto/ChngDetectMastDto.java create mode 100644 src/main/java/com/kamco/cd/kamcoback/Innopam/service/InnopamApiService.java diff --git a/src/main/java/com/kamco/cd/kamcoback/Innopam/dto/ChngDetectMastDto.java b/src/main/java/com/kamco/cd/kamcoback/Innopam/dto/ChngDetectMastDto.java new file mode 100644 index 00000000..94ec81c1 --- /dev/null +++ b/src/main/java/com/kamco/cd/kamcoback/Innopam/dto/ChngDetectMastDto.java @@ -0,0 +1,155 @@ +package com.kamco.cd.kamcoback.Innopam.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.springframework.web.bind.annotation.RequestParam; + +public class ChngDetectMastDto { + + @Getter + @Setter + @NoArgsConstructor + @AllArgsConstructor + public static class Basic { + + private String chnDtctMstId; // 탐지마스터아이디 + private String cprsYr; // 비교년도 2023 + private String crtrYr; // 기준년도 2024 + private String chnDtctSno; // 차수 (1 | 2 | ...) + private String chnDtctId; // 탐지아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성 + private String chnDtctCnt; // 탐지객체개수 + private String pnuMpngCnt; // PNU매핑개수 + private String lrmYmd; // 지적도일자 + private String pathNm; // 탐지결과 절대경로명 /kamco_nas/export/{chnDtctId} + private List excnList; // 등록진행상태히스토리 (최근것부터 DESC) + private String excnStepCd; // 실행단계코드 + private String excnStep; // 실행단계코드에 해당하는 영문명 + private String excnPgrt; // 실행단계진행율 + private String excnBngnDt; // 실행단계시작시간 + private String excnEndDt; // 실행단계종료시간 + private String rmk; // 비고 + private String crtDt; // 생성일시 + private String crtEpno; // 생성사원번호 + private String crtIp; // 생성사원아이피 + private String chgDt; // 변경일시 + private String chgEpno; // 변경사원번호 + private String chgIp; // 변경사원아이피 + private String delYn; // 삭제여부 + // + private String reqEpno; // 요청사원번호 + private String reqIp; // 요청사원어이피 + } + + @Getter + @Setter + @NoArgsConstructor + @AllArgsConstructor + public static class ChnDetectMastExcnStepDto { + + private String srno; // 일련번호 + private String chnDtctMstId; // 탐지마스터아이디 + private String excnStepCd; // 실행단계코드 + private String excnStep; // 실행단계코드에 해당하는 영문명 + private String excnPgrt; // 실행단계진행율 + private String excnEndDt; // 실행단계종료시간 + private String errCd; // 오류코드 + private String errMsg; // 오류메세지 + private String crtDt; // 실행단계시작시간 + } + + @Getter + @Setter + @NoArgsConstructor + @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; // 사원아이피 + } + + + + @Getter + @Setter + @NoArgsConstructor + @AllArgsConstructor + public static class ChnDetectContDto { + + private String chnDtctMstId; // 탐지콘텐츠아이디 + private String chnDtctContId; // 탐지마스타아이디 + private String cprsYr; // 비교년도 2023 + private String crtrYr; // 기준년도 2024 + private String chnDtctSno; // 차수 (1 | 2 | ...) + private String mpqdNo; // 도엽번호 + private String chnDtctId; // 탐지아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성 + private String chnDtctObjtId; // 탐지객체아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성 + private String chnDtctPolygon; // 탐지객체폴리곤 + private String chnDtctSqms; // 탐지객체면적 + private String chnCd; // 변화코드 + private String chnDtctJson; // 변화탐지JSON + private String chnDtctProb; // 변화탐지정확도 + private String bfClsCd; // 이전부류코드 + private String bfClsProb; // 이전분류정확도 + private String afClsCd; // 이후분류코드 + private String afClsProb; // 이후분류정확도 + private String crtDt; // 생성일시 + private String crtEpno; // 생성사원번호 + private String crtIp; // 생성사원아이피 + private String delYn; // 삭제여부 + // + private String reqEpno; // 요청사원번호 + private String reqIp; // 요청사원아이피 + } + + + @Getter + @Setter + @NoArgsConstructor + @AllArgsConstructor + public static class ChnDetectContReqDto { + + private String cprsYr; // 비교년도 2023 + private String crtrYr; // 기준년도 2024 + private String chnDtctSno; // 차수 (1 | 2 | ...) + private String mpqdNo; // 도엽번호 + private String chnDtctId; // 탐지아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성 + private String chnDtctObjtId; // 탐지객체아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성 + private String reqEpno; // 사원번호 + private String reqIp; + + } + + @Getter + @Setter + @NoArgsConstructor + @AllArgsConstructor + public static class ChngDetectMastSearchDto { + private String chnDtctId; + private String cprsYr; + private String crtrYr; + private String chnDtctSno; + } + + + @Schema(name = "ResReturn", description = "수행 후 리턴") + @Getter + @Setter + @NoArgsConstructor + @AllArgsConstructor + public static class ResReturn { + + private String flag; + private String message; + } + +} diff --git a/src/main/java/com/kamco/cd/kamcoback/Innopam/service/InnopamApiService.java b/src/main/java/com/kamco/cd/kamcoback/Innopam/service/InnopamApiService.java new file mode 100644 index 00000000..31773e84 --- /dev/null +++ b/src/main/java/com/kamco/cd/kamcoback/Innopam/service/InnopamApiService.java @@ -0,0 +1,134 @@ +package com.kamco.cd.kamcoback.Innopam.service; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.kamco.cd.kamcoback.Innopam.dto.ChngDetectMastDto; +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.DetectMastDto; +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.DetectMastSearch; +import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.FeaturePnuDto; +import com.kamco.cd.kamcoback.Innopam.postgres.core.DetectMastCoreService; +import com.kamco.cd.kamcoback.common.utils.NetUtils; +import com.kamco.cd.kamcoback.common.utils.UserUtil; +import com.kamco.cd.kamcoback.config.api.ApiResponseDto; +import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient; +import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult; +import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.DmlReturn; +import java.io.InputStream; +import java.net.InetAddress; +import java.net.URLEncoder; +import java.net.UnknownHostException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.util.UriComponentsBuilder; + +@Service +@Transactional(readOnly = true) +@RequiredArgsConstructor +public class InnopamApiService { + + @Value("${spring.profiles.active:local}") + private String profile; + + @Value("${innopam.url}") + private String innopamUrl; + + @Value("${innopam.mast}") + private String innopamMastUrl; + + + private final DetectMastCoreService detectMastCoreService; + + private final ExternalHttpClient externalHttpClient; + private final UserUtil userUtil = new UserUtil(); + private final NetUtils netUtils = new NetUtils(); + + private final JsonFactory jsonFactory = new JsonFactory(); + + @Transactional + public ChngDetectMastDto.Basic regist(ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) { + + ChngDetectMastDto.Basic basic = new ChngDetectMastDto.Basic(); + + String url = innopamMastUrl + "/regist"; + //url = "http://localhost:8080/api/kcd/cdi/detect/mast/regist"; + + String myip = netUtils.getLocalIP(); + chnDetectMastReq.setReqIp(myip); + + System.out.println("url == "+ url); + System.out.println("url == "+ myip); + + ExternalCallResult result = + externalHttpClient.call(url, HttpMethod.POST, chnDetectMastReq, netUtils.jsonHeaders(), String.class); + + System.out.println("result == " + result); + + return basic; + } + + @Transactional + public ResReturn remove(ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) { + ChngDetectMastDto.Basic basic = new ChngDetectMastDto.Basic(); + + String url = innopamMastUrl + "/remove"; + //url = "http://localhost:8080/api/kcd/cdi/detect/mast/remove"; + + String myip = netUtils.getLocalIP(); + chnDetectMastReq.setReqIp(myip); + + System.out.println("url == "+ url); + System.out.println("url == "+ myip); + + ExternalCallResult result = + externalHttpClient.call(url, HttpMethod.POST, chnDetectMastReq, netUtils.jsonHeaders(), String.class); + + System.out.println("result == " + result); + + return new ResReturn("success", "탐지결과 삭제 되었습니다."); + } + + @Transactional + public List list(ChngDetectMastDto.ChngDetectMastSearchDto searchDto) { + List masterList = new ArrayList<>(); + + String queryString = netUtils.dtoToQueryString(searchDto, null); + String url = innopamMastUrl+queryString; + + ExternalCallResult result = + externalHttpClient.call(url, HttpMethod.GET, null, netUtils.jsonHeaders(), String.class); + + System.out.println("list result == " + result); + + return masterList; + } + + + + + + +} From 90be304948c72bc2938bae7d42944066cb310b88 Mon Sep 17 00:00:00 2001 From: Moon Date: Thu, 22 Jan 2026 13:50:33 +0900 Subject: [PATCH 08/11] =?UTF-8?q?=EC=97=B0=EA=B3=84=EC=8B=9Cfunction?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/kamco/cd/kamcoback/common/utils/NetUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/kamco/cd/kamcoback/common/utils/NetUtils.java b/src/main/java/com/kamco/cd/kamcoback/common/utils/NetUtils.java index 3426057e..55e89daa 100644 --- a/src/main/java/com/kamco/cd/kamcoback/common/utils/NetUtils.java +++ b/src/main/java/com/kamco/cd/kamcoback/common/utils/NetUtils.java @@ -33,7 +33,7 @@ public class NetUtils { public String dtoToQueryString(Object dto, String queryString) { ObjectMapper objectMapper = new ObjectMapper(); - // 1. DTO를 Map으로 변환 + Map map = objectMapper.convertValue(dto, Map.class); String qStr = map.entrySet().stream() From 5d2ba49d06f9573ab8ac2109a14f9b14f938b237 Mon Sep 17 00:00:00 2001 From: DanielLee <198891672+sanghyeonhd@users.noreply.github.com> Date: Thu, 22 Jan 2026 13:58:25 +0900 Subject: [PATCH 09/11] linux package add --- gradle/linux/pack_offline_bundle_airgap.sh | 550 ++++++++++++++++++ .../linux/unpack_and_offline_build_airgap.sh | 347 +++++++++++ 2 files changed, 897 insertions(+) create mode 100644 gradle/linux/pack_offline_bundle_airgap.sh create mode 100644 gradle/linux/unpack_and_offline_build_airgap.sh diff --git a/gradle/linux/pack_offline_bundle_airgap.sh b/gradle/linux/pack_offline_bundle_airgap.sh new file mode 100644 index 00000000..9cc9fc5f --- /dev/null +++ b/gradle/linux/pack_offline_bundle_airgap.sh @@ -0,0 +1,550 @@ +#!/bin/bash +# pack_offline_bundle_airgap.sh +# ============================================================================ +# Gradle Offline Bundle Packer +# ============================================================================ +# Version: 4.0 +# +# WORKFLOW: +# 1. [ONLINE] Build project (./gradlew bootJar) - downloads all deps +# 2. [ONLINE] Test run (./gradlew bootRun) - verify app works +# 3. [OFFLINE TEST] Verify offline build works +# 4. Create bundle with all cached dependencies +# +# REQUIREMENTS: +# - Internet connection (for initial build) +# - Project with gradlew +# ============================================================================ + +set -e + +# ============================================================================ +# Configuration +# ============================================================================ +WRAPPER_SEED_PATH="wrapper_jar_seed" +OFFLINE_HOME_NAME="_offline_gradle_home" +BOOTRUN_TIMEOUT_SECONDS=60 + +# Color codes +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +CYAN='\033[0;36m' +GRAY='\033[0;90m' +WHITE='\033[1;37m' +NC='\033[0m' # No Color + +echo "" +echo -e "${CYAN}============================================================${NC}" +echo -e "${CYAN} Gradle Offline Bundle Packer v4.0${NC}" +echo -e "${CYAN}============================================================${NC}" +echo "" +echo -e "${WHITE} This script will:${NC}" +echo -e "${GRAY} 1. Build project with internet (download dependencies)${NC}" +echo -e "${GRAY} 2. Test run application (verify it works)${NC}" +echo -e "${GRAY} 3. Test offline build (verify cache is complete)${NC}" +echo -e "${GRAY} 4. Create offline bundle for air-gapped environment${NC}" +echo "" +echo -e "${CYAN}============================================================${NC}" +echo "" + +# ============================================================================ +# [1/20] Check Current Directory +# ============================================================================ +echo -e "${YELLOW}==[1/20] Check Current Directory ==${NC}" +ROOT="$(pwd)" +echo "ROOT_DIR: $ROOT" +echo "" + +# ============================================================================ +# [2/20] Check Required Files +# ============================================================================ +echo -e "${YELLOW}==[2/20] Check Required Files ==${NC}" + +if [ ! -f "./gradlew" ]; then + echo -e "${RED}ERROR: gradlew not found. Run from project root.${NC}" + exit 1 +fi +chmod +x ./gradlew +echo -e "${GREEN}[OK] gradlew${NC}" + +BUILD_FILE="" +if [ -f "./build.gradle" ]; then + BUILD_FILE="build.gradle" +elif [ -f "./build.gradle.kts" ]; then + BUILD_FILE="build.gradle.kts" +else + echo -e "${RED}ERROR: build.gradle(.kts) not found.${NC}" + exit 1 +fi +echo -e "${GREEN}[OK] $BUILD_FILE${NC}" + +SETTINGS_FILE="" +if [ -f "./settings.gradle" ]; then + SETTINGS_FILE="settings.gradle" + echo -e "${GREEN}[OK] $SETTINGS_FILE${NC}" +elif [ -f "./settings.gradle.kts" ]; then + SETTINGS_FILE="settings.gradle.kts" + echo -e "${GREEN}[OK] $SETTINGS_FILE${NC}" +fi +echo "" + +# ============================================================================ +# [3/20] Check Gradle Wrapper +# ============================================================================ +echo -e "${YELLOW}==[3/20] Check Gradle Wrapper ==${NC}" + +WRAPPER_DIR="$ROOT/gradle/wrapper" +WRAPPER_JAR="$WRAPPER_DIR/gradle-wrapper.jar" +WRAPPER_PROP="$WRAPPER_DIR/gradle-wrapper.properties" + +mkdir -p "$WRAPPER_DIR" + +if [ ! -f "$WRAPPER_PROP" ]; then + echo -e "${RED}ERROR: gradle-wrapper.properties not found.${NC}" + exit 1 +fi + +if [ ! -f "$WRAPPER_JAR" ]; then + SEED_JAR="$ROOT/$WRAPPER_SEED_PATH/gradle-wrapper.jar" + if [ -f "$SEED_JAR" ]; then + cp "$SEED_JAR" "$WRAPPER_JAR" + echo -e "${GREEN}[OK] Wrapper jar injected from seed${NC}" + else + echo -e "${RED}ERROR: gradle-wrapper.jar missing${NC}" + exit 1 + fi +else + echo -e "${GREEN}[OK] gradle-wrapper.jar exists${NC}" +fi + +# Create seed backup +SEED_DIR="$ROOT/$WRAPPER_SEED_PATH" +if [ ! -d "$SEED_DIR" ]; then + mkdir -p "$SEED_DIR" + cp "$WRAPPER_JAR" "$SEED_DIR/gradle-wrapper.jar" +fi +echo "" + +# ============================================================================ +# [4/20] Set GRADLE_USER_HOME (Project Local) +# ============================================================================ +echo -e "${YELLOW}==[4/20] Set GRADLE_USER_HOME ==${NC}" + +OFFLINE_HOME="$ROOT/$OFFLINE_HOME_NAME" +mkdir -p "$OFFLINE_HOME" +export GRADLE_USER_HOME="$OFFLINE_HOME" + +echo -e "${CYAN}GRADLE_USER_HOME = $GRADLE_USER_HOME${NC}" +echo -e "${GRAY}[INFO] All dependencies will be cached in project folder${NC}" +echo "" + +# ============================================================================ +# [5/20] Check Internet Connection +# ============================================================================ +echo -e "${YELLOW}==[5/20] Check Internet Connection ==${NC}" + +HAS_INTERNET=false +TEST_HOSTS=("plugins.gradle.org" "repo.maven.apache.org" "repo1.maven.org") + +for TEST_HOST in "${TEST_HOSTS[@]}"; do + if ping -c 1 -W 3 "$TEST_HOST" &>/dev/null; then + HAS_INTERNET=true + echo -e "${GREEN}[OK] Connected to $TEST_HOST${NC}" + break + fi +done + +if [ "$HAS_INTERNET" = false ]; then + # Try DNS resolution as fallback + if nslookup google.com &>/dev/null || host google.com &>/dev/null; then + HAS_INTERNET=true + echo -e "${GREEN}[OK] Internet available (DNS)${NC}" + fi +fi + +if [ "$HAS_INTERNET" = false ]; then + echo "" + echo -e "${RED}============================================================${NC}" + echo -e "${RED} ERROR: No Internet Connection!${NC}" + echo -e "${RED}============================================================${NC}" + echo "" + echo -e "${YELLOW}This script requires internet for initial build.${NC}" + echo -e "${YELLOW}Please connect to internet and run again.${NC}" + echo "" + exit 1 +fi +echo "" + +# ============================================================================ +# [6/20] Initial Gradle Setup +# ============================================================================ +echo -e "${YELLOW}==[6/20] Initial Gradle Setup ==${NC}" +echo -e "${GRAY}[INFO] Downloading Gradle distribution...${NC}" + +if ./gradlew --version &>/dev/null; then + GRADLE_VERSION=$(./gradlew --version 2>&1 | grep "^Gradle" | awk '{print $2}') + echo -e "${GREEN}[OK] Gradle $GRADLE_VERSION${NC}" +else + echo -e "${RED}[ERROR] Gradle setup failed${NC}" + exit 1 +fi +echo "" + +# ============================================================================ +# [7/20] ONLINE BUILD - bootJar (Download All Dependencies) +# ============================================================================ +echo -e "${YELLOW}==[7/20] ONLINE BUILD - bootJar ==${NC}" +echo "" +echo -e "${CYAN}============================================================${NC}" +echo -e "${CYAN} ONLINE BUILD (with Internet)${NC}" +echo -e "${CYAN} Downloading all dependencies to local cache${NC}" +echo -e "${CYAN}============================================================${NC}" +echo "" + +BUILD_SUCCESS=false + +./gradlew clean bootJar --no-daemon +if [ $? -eq 0 ]; then + BUILD_SUCCESS=true + echo "" + echo -e "${GREEN}============================================================${NC}" + echo -e "${GREEN} ONLINE BUILD SUCCESS!${NC}" + echo -e "${GREEN}============================================================${NC}" + echo "" + + if [ -d "./build/libs" ]; then + echo -e "${CYAN}JAR files:${NC}" + ls -lh ./build/libs/*.jar 2>/dev/null | awk '{print " " $9 " (" $5 ")"}' + fi +else + echo "" + echo -e "${RED}============================================================${NC}" + echo -e "${RED} BUILD FAILED!${NC}" + echo -e "${RED}============================================================${NC}" + echo "" + echo -e "${YELLOW}Build failed. Cannot continue.${NC}" + exit 1 +fi +echo "" + +# ============================================================================ +# [8/20] Stop Daemons +# ============================================================================ +echo -e "${YELLOW}==[8/20] Stop Daemons ==${NC}" + +./gradlew --stop &>/dev/null || true +sleep 2 +echo -e "${GREEN}[OK] Daemons stopped${NC}" +echo "" + +# ============================================================================ +# [9/20] ONLINE TEST - bootRun (Verify Application Works) +# ============================================================================ +echo -e "${YELLOW}==[9/20] ONLINE TEST - bootRun ==${NC}" +echo "" +echo -e "${CYAN}============================================================${NC}" +echo -e "${CYAN} Testing application startup (timeout: ${BOOTRUN_TIMEOUT_SECONDS}s)${NC}" +echo -e "${CYAN} Will automatically stop after successful startup${NC}" +echo -e "${CYAN}============================================================${NC}" +echo "" + +BOOTRUN_SUCCESS=false + +timeout ${BOOTRUN_TIMEOUT_SECONDS}s ./gradlew bootRun --no-daemon & +BOOTRUN_PID=$! + +sleep 10 + +if ps -p $BOOTRUN_PID &>/dev/null; then + BOOTRUN_SUCCESS=true + echo "" + echo -e "${GREEN}[OK] Application started successfully${NC}" + kill $BOOTRUN_PID &>/dev/null || true + sleep 2 +else + echo "" + echo -e "${YELLOW}[WARN] Application may not have started properly${NC}" +fi + +# Cleanup +pkill -f "gradle.*bootRun" &>/dev/null || true +sleep 2 +echo "" + +# ============================================================================ +# [10/20] Stop Daemons Again +# ============================================================================ +echo -e "${YELLOW}==[10/20] Stop Daemons Again ==${NC}" + +./gradlew --stop &>/dev/null || true +sleep 2 +echo -e "${GREEN}[OK] Daemons stopped${NC}" +echo "" + +# ============================================================================ +# [11/20] OFFLINE BUILD TEST (Verify Cache Completeness) +# ============================================================================ +echo -e "${YELLOW}==[11/20] OFFLINE BUILD TEST ==${NC}" +echo "" +echo -e "${CYAN}============================================================${NC}" +echo -e "${CYAN} OFFLINE BUILD TEST (--offline flag)${NC}" +echo -e "${CYAN} Verifying all dependencies are cached${NC}" +echo -e "${CYAN}============================================================${NC}" +echo "" + +OFFLINE_SUCCESS=false + +./gradlew clean bootJar --offline --no-daemon +if [ $? -eq 0 ]; then + OFFLINE_SUCCESS=true + echo "" + echo -e "${GREEN}============================================================${NC}" + echo -e "${GREEN} OFFLINE BUILD TEST PASSED!${NC}" + echo -e "${GREEN}============================================================${NC}" + echo "" + echo -e "${GREEN}[OK] All dependencies are cached${NC}" +else + echo "" + echo -e "${RED}============================================================${NC}" + echo -e "${RED} OFFLINE BUILD TEST FAILED!${NC}" + echo -e "${RED}============================================================${NC}" + echo "" + echo -e "${YELLOW}Some dependencies may be missing from cache.${NC}" + echo -e "${YELLOW}The bundle may not work in air-gapped environment.${NC}" + echo "" + + read -p "Continue anyway? (y/N): " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + exit 1 + fi +fi +echo "" + +# ============================================================================ +# [12/20] Stop Daemons Before Archive +# ============================================================================ +echo -e "${YELLOW}==[12/20] Stop Daemons Before Archive ==${NC}" + +./gradlew --stop &>/dev/null || true +sleep 2 +echo -e "${GREEN}[OK] Daemons stopped${NC}" +echo "" + +# ============================================================================ +# [13/20] Verify settings.gradle for Offline +# ============================================================================ +echo -e "${YELLOW}==[13/20] Verify settings.gradle ==${NC}" + +if [ -n "$SETTINGS_FILE" ]; then + if grep -q "mavenLocal()" "$SETTINGS_FILE" && grep -q "pluginManagement" "$SETTINGS_FILE"; then + echo -e "${GREEN}[OK] settings.gradle configured for offline${NC}" + else + echo -e "${YELLOW}[WARN] settings.gradle may need offline configuration${NC}" + echo -e "${GRAY}[INFO] Consider adding mavenLocal() to pluginManagement and repositories${NC}" + fi +else + echo -e "${GRAY}[INFO] No settings.gradle found${NC}" +fi +echo "" + +# ============================================================================ +# [14/20] Create Helper Scripts +# ============================================================================ +echo -e "${YELLOW}==[14/20] Create Helper Scripts ==${NC}" + +# run_offline_build.sh +cat > "$ROOT/run_offline_build.sh" << 'EOF' +#!/bin/bash +# run_offline_build.sh - Build JAR offline +export GRADLE_USER_HOME="$(pwd)/_offline_gradle_home" +echo "GRADLE_USER_HOME = $GRADLE_USER_HOME" +echo "" +./gradlew --offline bootJar --no-daemon +if [ $? -eq 0 ]; then + echo "" + echo "BUILD SUCCESS!" + echo "" + echo "JAR files:" + ls -lh ./build/libs/*.jar 2>/dev/null | awk '{print " " $9}' +else + echo "BUILD FAILED" +fi +EOF +chmod +x "$ROOT/run_offline_build.sh" +echo -e "${GREEN}[OK] run_offline_build.sh${NC}" + +# run_offline_bootrun.sh +cat > "$ROOT/run_offline_bootrun.sh" << 'EOF' +#!/bin/bash +# run_offline_bootrun.sh - Run application offline +export GRADLE_USER_HOME="$(pwd)/_offline_gradle_home" +echo "GRADLE_USER_HOME = $GRADLE_USER_HOME" +echo "" +echo "Starting application (Ctrl+C to stop)..." +echo "" +./gradlew --offline bootRun --no-daemon +EOF +chmod +x "$ROOT/run_offline_bootrun.sh" +echo -e "${GREEN}[OK] run_offline_bootrun.sh${NC}" +echo "" + +# ============================================================================ +# [15/20] Final Daemon Cleanup +# ============================================================================ +echo -e "${YELLOW}==[15/20] Final Daemon Cleanup ==${NC}" + +./gradlew --stop &>/dev/null || true +sleep 2 +echo -e "${GREEN}[OK] Daemons stopped${NC}" +echo "" + +# ============================================================================ +# [16/20] Clean Lock Files +# ============================================================================ +echo -e "${YELLOW}==[16/20] Clean Lock Files ==${NC}" + +DAEMON_DIR="$OFFLINE_HOME/daemon" +if [ -d "$DAEMON_DIR" ]; then + rm -rf "$DAEMON_DIR" 2>/dev/null || true +fi + +find "$OFFLINE_HOME" -type f \( -name "*.lock" -o -name "*.log" -o -name "*.tmp" \) -delete 2>/dev/null || true + +echo -e "${GREEN}[OK] Lock files cleaned${NC}" +echo "" + +# ============================================================================ +# [17/20] Calculate Cache Size +# ============================================================================ +echo -e "${YELLOW}==[17/20] Cache Summary ==${NC}" + +CACHES_DIR="$OFFLINE_HOME/caches" +WRAPPER_DISTS="$OFFLINE_HOME/wrapper/dists" + +TOTAL_SIZE=0 + +if [ -d "$CACHES_DIR" ]; then + SIZE=$(du -sb "$CACHES_DIR" 2>/dev/null | cut -f1) + TOTAL_SIZE=$((TOTAL_SIZE + SIZE)) + SIZE_MB=$(echo "scale=2; $SIZE / 1048576" | bc) + echo -e "${CYAN}[INFO] Dependencies: ${SIZE_MB} MB${NC}" +fi + +if [ -d "$WRAPPER_DISTS" ]; then + SIZE=$(du -sb "$WRAPPER_DISTS" 2>/dev/null | cut -f1) + TOTAL_SIZE=$((TOTAL_SIZE + SIZE)) + SIZE_MB=$(echo "scale=2; $SIZE / 1048576" | bc) + echo -e "${CYAN}[INFO] Gradle dist: ${SIZE_MB} MB${NC}" +fi + +TOTAL_MB=$(echo "scale=2; $TOTAL_SIZE / 1048576" | bc) +echo -e "${CYAN}[INFO] Total cache: ${TOTAL_MB} MB${NC}" +echo "" + +# ============================================================================ +# [18/20] Create Archive +# ============================================================================ +echo -e "${YELLOW}==[18/20] Create Archive ==${NC}" + +BASE_NAME=$(basename "$ROOT") +TIMESTAMP=$(date +"%Y%m%d_%H%M%S") +PARENT=$(dirname "$ROOT") +ARCHIVE_PATH="${PARENT}/${BASE_NAME}_offline_bundle_${TIMESTAMP}.tar.gz" + +echo "Archive: $ARCHIVE_PATH" +echo -e "${GRAY}[INFO] Creating archive (this may take several minutes)...${NC}" + +tar -czf "$ARCHIVE_PATH" \ + --exclude=".git" \ + --exclude=".idea" \ + --exclude=".DS_Store" \ + --exclude="*.log" \ + --exclude="*.lock" \ + --exclude="_offline_gradle_home/daemon" \ + --exclude="_offline_gradle_home/native" \ + --exclude="_offline_gradle_home/jdks" \ + --exclude="build" \ + --exclude="out" \ + --exclude=".gradle" \ + -C "$ROOT" . + +if [ $? -ne 0 ]; then + echo -e "${RED}ERROR: tar failed${NC}" + exit 1 +fi + +ARCHIVE_SIZE=$(stat -f%z "$ARCHIVE_PATH" 2>/dev/null || stat -c%s "$ARCHIVE_PATH" 2>/dev/null) +ARCHIVE_SIZE_MB=$(echo "scale=2; $ARCHIVE_SIZE / 1048576" | bc) +echo -e "${GREEN}[OK] Archive created: ${ARCHIVE_SIZE_MB} MB${NC}" +echo "" + +# ============================================================================ +# [19/20] Verify Archive +# ============================================================================ +echo -e "${YELLOW}==[19/20] Verify Archive ==${NC}" + +CHECKS=( + "gradle/wrapper/gradle-wrapper.jar" + "gradlew" + "_offline_gradle_home/caches" + "run_offline_build.sh" +) + +for CHECK in "${CHECKS[@]}"; do + if tar -tzf "$ARCHIVE_PATH" | grep -q "$CHECK"; then + echo -e " ${GREEN}[OK] $CHECK${NC}" + else + echo -e " ${YELLOW}[WARN] $CHECK${NC}" + fi +done +echo "" + +# ============================================================================ +# [20/20] Complete +# ============================================================================ +echo -e "${GREEN}============================================================${NC}" +echo -e "${GREEN} BUNDLE CREATION COMPLETE!${NC}" +echo -e "${GREEN}============================================================${NC}" +echo "" +echo -e "${CYAN}Archive: $ARCHIVE_PATH${NC}" +echo -e "${CYAN}Size: ${ARCHIVE_SIZE_MB} MB${NC}" +echo "" + +echo -e "${CYAN}============================================================${NC}" +echo -e "${CYAN} Test Results${NC}" +echo -e "${CYAN}============================================================${NC}" +if [ "$BUILD_SUCCESS" = true ]; then + echo -e " Online build (bootJar): ${GREEN}PASSED${NC}" +else + echo -e " Online build (bootJar): ${RED}FAILED${NC}" +fi +if [ "$BOOTRUN_SUCCESS" = true ]; then + echo -e " Online test (bootRun): ${GREEN}PASSED${NC}" +else + echo -e " Online test (bootRun): ${YELLOW}SKIPPED${NC}" +fi +if [ "$OFFLINE_SUCCESS" = true ]; then + echo -e " Offline build test: ${GREEN}PASSED${NC}" +else + echo -e " Offline build test: ${RED}FAILED${NC}" +fi +echo "" + +echo -e "${YELLOW}============================================================${NC}" +echo -e "${YELLOW} Usage in Air-gapped Environment${NC}" +echo -e "${YELLOW}============================================================${NC}" +echo "" +echo -e "${WHITE}Option 1: Use unpack script${NC}" +echo -e "${GRAY} ./unpack_and_offline_build_airgap.sh${NC}" +echo "" +echo -e "${WHITE}Option 2: Manual extraction${NC}" +echo -e "${GRAY} tar -xzf .tar.gz${NC}" +echo -e "${GRAY} cd ${NC}" +echo -e "${GRAY} ./run_offline_build.sh${NC}" +echo "" +echo -e "${WHITE}Option 3: Direct commands${NC}" +echo -e "${GRAY} export GRADLE_USER_HOME=\"./_offline_gradle_home\"${NC}" +echo -e "${GRAY} ./gradlew --offline bootJar --no-daemon${NC}" +echo "" diff --git a/gradle/linux/unpack_and_offline_build_airgap.sh b/gradle/linux/unpack_and_offline_build_airgap.sh new file mode 100644 index 00000000..b279202c --- /dev/null +++ b/gradle/linux/unpack_and_offline_build_airgap.sh @@ -0,0 +1,347 @@ +#!/bin/bash +# unpack_and_offline_build_airgap.sh +# ============================================================================ +# Execution Environment: OFFLINE (Air-gapped, No Internet) +# Purpose: Extract bundle and run offline build +# ============================================================================ +# Linux Bash Script +# Version: 3.1 +# +# IMPORTANT: This script automatically: +# 1. Extracts the archive +# 2. Sets GRADLE_USER_HOME to project local cache +# 3. Configures settings.gradle for offline resolution +# 4. Runs build with --offline flag +# ============================================================================ + +set -e + +# ============================================================================ +# Configuration +# ============================================================================ +WRAPPER_SEED_PATH="wrapper_jar_seed" +OFFLINE_HOME_NAME="_offline_gradle_home" + +# Color codes +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +CYAN='\033[0;36m' +GRAY='\033[0;90m' +WHITE='\033[1;37m' +NC='\033[0m' # No Color + +echo "" +echo -e "${CYAN}============================================================${NC}" +echo -e "${CYAN} Gradle Offline Build Runner${NC}" +echo -e "${CYAN} Environment: AIR-GAPPED (No Internet)${NC}" +echo -e "${CYAN} Mode: Fully Offline (--offline enforced)${NC}" +echo -e "${CYAN}============================================================${NC}" +echo "" + +# ============================================================================ +# [1/16] Check Current Directory +# ============================================================================ +echo -e "${YELLOW}==[1/16] Check Current Directory ==${NC}" +START_DIR="$(pwd)" +echo "PWD: $START_DIR" +echo "" + +# ============================================================================ +# [2/16] Select Archive +# ============================================================================ +echo -e "${YELLOW}==[2/16] Select Archive ==${NC}" + +ARCHIVE="" +if [ $# -ge 1 ]; then + ARCHIVE="$1" +fi + +if [ -z "$ARCHIVE" ]; then + # Auto-detect most recent .tar.gz file + ARCHIVE=$(find "$START_DIR" -maxdepth 1 -type f \( -name "*.tar.gz" -o -name "*.tgz" \) -printf '%T@ %p\n' 2>/dev/null | sort -rn | head -1 | cut -d' ' -f2-) + + if [ -z "$ARCHIVE" ]; then + echo -e "${RED}[ERROR] No archive found${NC}" + ls -lh "$START_DIR" + exit 1 + fi + + echo -e "${CYAN}[AUTO] $(basename "$ARCHIVE")${NC}" +else + if [ ! -f "$ARCHIVE" ]; then + ARCHIVE="$START_DIR/$ARCHIVE" + fi + echo -e "${CYAN}[USER] $(basename "$ARCHIVE")${NC}" +fi + +if [ ! -f "$ARCHIVE" ]; then + echo -e "${RED}ERROR: Archive not found: $ARCHIVE${NC}" + exit 1 +fi + +ARCHIVE_SIZE=$(stat -f%z "$ARCHIVE" 2>/dev/null || stat -c%s "$ARCHIVE" 2>/dev/null) +ARCHIVE_SIZE_MB=$(echo "scale=2; $ARCHIVE_SIZE / 1048576" | bc) +echo "Size: ${ARCHIVE_SIZE_MB} MB" +echo "" + +# ============================================================================ +# [3/16] Check tar +# ============================================================================ +echo -e "${YELLOW}==[3/16] Check tar ==${NC}" + +if ! command -v tar &>/dev/null; then + echo -e "${RED}ERROR: tar not found${NC}" + exit 1 +fi +echo -e "${GREEN}[OK] tar found${NC}" +echo "" + +# ============================================================================ +# [4/16] Extract Archive +# ============================================================================ +echo -e "${YELLOW}==[4/16] Extract Archive ==${NC}" +echo -e "${GRAY}[INFO] Extracting...${NC}" + +tar -xzf "$ARCHIVE" -C "$START_DIR" +if [ $? -ne 0 ]; then + echo -e "${RED}ERROR: Extraction failed${NC}" + exit 1 +fi +echo -e "${GREEN}[OK] Extracted${NC}" +echo "" + +# ============================================================================ +# [5/16] Set Permissions +# ============================================================================ +echo -e "${YELLOW}==[5/16] Set Permissions ==${NC}" + +chmod -R u+rw "$START_DIR" 2>/dev/null || true +echo -e "${GREEN}[OK] Permissions set${NC}" +echo "" + +# ============================================================================ +# [6/16] Find Project Root +# ============================================================================ +echo -e "${YELLOW}==[6/16] Find Project Root ==${NC}" + +GRADLEW=$(find "$START_DIR" -name "gradlew" -type f 2>/dev/null | sort | head -1) +if [ -z "$GRADLEW" ]; then + echo -e "${RED}ERROR: gradlew not found${NC}" + exit 1 +fi + +PROJECT_DIR=$(dirname "$GRADLEW") +echo -e "${CYAN}Project: $PROJECT_DIR${NC}" +cd "$PROJECT_DIR" +echo "" + +# ============================================================================ +# [7/16] Fix Permissions +# ============================================================================ +echo -e "${YELLOW}==[7/16] Fix Permissions ==${NC}" + +chmod +x ./gradlew +find . -name "*.sh" -type f -exec chmod +x {} \; 2>/dev/null || true +echo -e "${GREEN}[OK] Permissions fixed${NC}" +echo "" + +# ============================================================================ +# [8/16] Verify Wrapper +# ============================================================================ +echo -e "${YELLOW}==[8/16] Verify Wrapper ==${NC}" + +WRAPPER_DIR="$PROJECT_DIR/gradle/wrapper" +WRAPPER_JAR="$WRAPPER_DIR/gradle-wrapper.jar" +WRAPPER_PROP="$WRAPPER_DIR/gradle-wrapper.properties" + +if [ ! -f "$WRAPPER_PROP" ]; then + echo -e "${RED}ERROR: gradle-wrapper.properties missing${NC}" + exit 1 +fi + +if [ ! -f "$WRAPPER_JAR" ]; then + SEED_JAR="$PROJECT_DIR/$WRAPPER_SEED_PATH/gradle-wrapper.jar" + if [ -f "$SEED_JAR" ]; then + mkdir -p "$WRAPPER_DIR" + cp "$SEED_JAR" "$WRAPPER_JAR" + echo -e "${GREEN}[OK] Injected from seed${NC}" + else + echo -e "${RED}ERROR: wrapper jar missing${NC}" + exit 1 + fi +else + echo -e "${GREEN}[OK] Wrapper verified${NC}" +fi +echo "" + +# ============================================================================ +# [9/16] Set GRADLE_USER_HOME +# ============================================================================ +echo -e "${YELLOW}==[9/16] Set GRADLE_USER_HOME ==${NC}" + +OFFLINE_HOME="$PROJECT_DIR/$OFFLINE_HOME_NAME" +if [ ! -d "$OFFLINE_HOME" ]; then + echo -e "${RED}ERROR: _offline_gradle_home not found in archive${NC}" + exit 1 +fi + +export GRADLE_USER_HOME="$OFFLINE_HOME" +echo -e "${CYAN}GRADLE_USER_HOME = $GRADLE_USER_HOME${NC}" + +# Check cache +CACHES_DIR="$OFFLINE_HOME/caches" +if [ -d "$CACHES_DIR" ]; then + CACHE_SIZE=$(du -sb "$CACHES_DIR" 2>/dev/null | cut -f1) + CACHE_SIZE_MB=$(echo "scale=2; $CACHE_SIZE / 1048576" | bc) + echo -e "${CYAN}[INFO] Cache size: ${CACHE_SIZE_MB} MB${NC}" +else + echo -e "${YELLOW}[WARN] No cache folder found${NC}" +fi +echo "" + +# ============================================================================ +# [10/16] Verify settings.gradle +# ============================================================================ +echo -e "${YELLOW}==[10/16] Verify settings.gradle ==${NC}" + +SETTINGS_FILE="" +if [ -f "./settings.gradle" ]; then + SETTINGS_FILE="settings.gradle" +elif [ -f "./settings.gradle.kts" ]; then + SETTINGS_FILE="settings.gradle.kts" +fi + +if [ -n "$SETTINGS_FILE" ]; then + if grep -q "mavenLocal()" "$SETTINGS_FILE" && grep -q "pluginManagement" "$SETTINGS_FILE"; then + echo -e "${GREEN}[OK] settings.gradle configured for offline${NC}" + else + echo -e "${YELLOW}[WARN] settings.gradle may not be configured for offline${NC}" + echo -e "${GRAY}[INFO] Build may fail if plugins not cached${NC}" + fi +fi +echo "" + +# ============================================================================ +# [11/16] Test Gradle +# ============================================================================ +echo -e "${YELLOW}==[11/16] Test Gradle ==${NC}" + +GRADLE_WORKS=false +if ./gradlew --offline --version &>/dev/null; then + GRADLE_WORKS=true + echo -e "${GREEN}[OK] Gradle working in offline mode${NC}" +else + echo -e "${YELLOW}[WARN] Gradle --version failed${NC}" +fi +echo "" + +# ============================================================================ +# [12/16] Stop Daemon +# ============================================================================ +echo -e "${YELLOW}==[12/16] Stop Daemon ==${NC}" + +./gradlew --stop &>/dev/null || true +sleep 2 +echo -e "${GREEN}[OK] Daemon stopped${NC}" +echo "" + +# ============================================================================ +# [13/16] Run Offline Build +# ============================================================================ +echo -e "${YELLOW}==[13/16] Run Offline Build ==${NC}" +echo "" +echo -e "${CYAN}============================================================${NC}" +echo -e "${CYAN} Building with --offline flag${NC}" +echo -e "${CYAN} All dependencies from local cache${NC}" +echo -e "${CYAN}============================================================${NC}" +echo "" + +BUILD_SUCCESS=false +BUILD_TASK="" + +# Try bootJar +echo -e "${GRAY}[TRY] --offline bootJar...${NC}" +if ./gradlew --offline clean bootJar --no-daemon; then + BUILD_SUCCESS=true + BUILD_TASK="bootJar" +fi + +# Try jar +if [ "$BUILD_SUCCESS" = false ]; then + echo -e "${GRAY}[TRY] --offline jar...${NC}" + if ./gradlew --offline clean jar --no-daemon; then + BUILD_SUCCESS=true + BUILD_TASK="jar" + fi +fi + +# Try build +if [ "$BUILD_SUCCESS" = false ]; then + echo -e "${GRAY}[TRY] --offline build...${NC}" + if ./gradlew --offline build --no-daemon; then + BUILD_SUCCESS=true + BUILD_TASK="build" + fi +fi + +echo "" +if [ "$BUILD_SUCCESS" = true ]; then + echo -e "${GREEN}============================================================${NC}" + echo -e "${GREEN} BUILD SUCCESS! (task: $BUILD_TASK)${NC}" + echo -e "${GREEN}============================================================${NC}" +else + echo -e "${RED}============================================================${NC}" + echo -e "${RED} BUILD FAILED!${NC}" + echo -e "${RED}============================================================${NC}" + echo "" + echo -e "${YELLOW}Possible causes:${NC}" + echo -e "${WHITE} - Dependencies not in cache${NC}" + echo -e "${WHITE} - Plugin resolution failed${NC}" + echo -e "${WHITE} - Need complete build in online env first${NC}" + exit 1 +fi +echo "" + +# ============================================================================ +# [14/16] Show Build Output +# ============================================================================ +echo -e "${YELLOW}==[14/16] Build Output ==${NC}" + +LIBS_DIR="$PROJECT_DIR/build/libs" +if [ -d "$LIBS_DIR" ]; then + echo -e "${CYAN}build/libs contents:${NC}" + ls -lh "$LIBS_DIR"/*.jar 2>/dev/null | awk '{printf " %-40s %10s\n", $9, $5}' + + MAIN_JAR=$(find "$LIBS_DIR" -name "*.jar" -type f ! -name "*-plain.jar" ! -name "*-sources.jar" ! -name "*-javadoc.jar" 2>/dev/null | head -1) +else + echo -e "${YELLOW}[WARN] build/libs not found${NC}" +fi +echo "" + +# ============================================================================ +# [15/16] Run Instructions +# ============================================================================ +echo -e "${YELLOW}==[15/16] Run Instructions ==${NC}" +echo "" + +if [ -n "$MAIN_JAR" ]; then + echo -e "${CYAN}To run the application:${NC}" + echo -e "${WHITE} java -jar $(basename "$MAIN_JAR")${NC}" + echo "" +fi + +echo -e "${CYAN}To rebuild:${NC}" +echo -e "${WHITE} export GRADLE_USER_HOME=\"./_offline_gradle_home\"${NC}" +echo -e "${WHITE} ./gradlew --offline bootJar --no-daemon${NC}" +echo "" + +# ============================================================================ +# [16/16] Complete +# ============================================================================ +echo -e "${GREEN}============================================================${NC}" +echo -e "${GREEN} Offline Build Complete!${NC}" +echo -e "${GREEN}============================================================${NC}" +echo "" +echo -e "${CYAN}Project: $PROJECT_DIR${NC}" +echo "" From 146172cc4d34f5a2ee67bd29e5e0b8f208e56a72 Mon Sep 17 00:00:00 2001 From: Moon Date: Thu, 22 Jan 2026 14:05:15 +0900 Subject: [PATCH 10/11] =?UTF-8?q?=EC=9D=B4=EB=85=B8=ED=8C=B8=20=EC=97=B0?= =?UTF-8?q?=EB=8F=99=20URL=20=EA=B2=BD=EB=A1=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-dev.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index a265ea9d..436f2802 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -106,3 +106,8 @@ inference: batch-url: http://10.100.0.11:8000/batches geojson-dir: /kamco-nfs/requests/ jar-path: /kamco-nfs/dataset/shp_exporter-1.0.0.jar + +innopam: + #url: http://localhost:8080 + url: http://192.168.2.129:5301 + mast : ${innopam.url}/api/kcd/cdi/chn/mast From 6a1091a463e085894ee9b4bae45bcf5e5cdbd623 Mon Sep 17 00:00:00 2001 From: teddy Date: Thu, 22 Jan 2026 14:09:35 +0900 Subject: [PATCH 11/11] =?UTF-8?q?spotlessApply=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Innopam/dto/ChngDetectMastDto.java | 149 ++++++++---------- .../Innopam/service/InnopamApiService.java | 64 ++------ .../cd/kamcoback/common/utils/NetUtils.java | 30 ++-- .../InferenceResultApiController.java | 74 --------- .../inference/dto/InferenceDetailDto.java | 18 +-- .../MapSheetAnalDataInferenceGeomEntity.java | 7 - .../MapSheetLearnRepositoryImpl.java | 2 +- src/main/resources/application-prod.yml | 4 + 8 files changed, 114 insertions(+), 234 deletions(-) diff --git a/src/main/java/com/kamco/cd/kamcoback/Innopam/dto/ChngDetectMastDto.java b/src/main/java/com/kamco/cd/kamcoback/Innopam/dto/ChngDetectMastDto.java index 94ec81c1..27524c20 100644 --- a/src/main/java/com/kamco/cd/kamcoback/Innopam/dto/ChngDetectMastDto.java +++ b/src/main/java/com/kamco/cd/kamcoback/Innopam/dto/ChngDetectMastDto.java @@ -1,14 +1,11 @@ package com.kamco.cd.kamcoback.Innopam.dto; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import org.springframework.web.bind.annotation.RequestParam; public class ChngDetectMastDto { @@ -18,32 +15,32 @@ public class ChngDetectMastDto { @AllArgsConstructor public static class Basic { - private String chnDtctMstId; // 탐지마스터아이디 - private String cprsYr; // 비교년도 2023 - private String crtrYr; // 기준년도 2024 - private String chnDtctSno; // 차수 (1 | 2 | ...) - private String chnDtctId; // 탐지아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성 - private String chnDtctCnt; // 탐지객체개수 - private String pnuMpngCnt; // PNU매핑개수 - private String lrmYmd; // 지적도일자 - private String pathNm; // 탐지결과 절대경로명 /kamco_nas/export/{chnDtctId} + private String chnDtctMstId; // 탐지마스터아이디 + private String cprsYr; // 비교년도 2023 + private String crtrYr; // 기준년도 2024 + private String chnDtctSno; // 차수 (1 | 2 | ...) + private String chnDtctId; // 탐지아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성 + private String chnDtctCnt; // 탐지객체개수 + private String pnuMpngCnt; // PNU매핑개수 + private String lrmYmd; // 지적도일자 + private String pathNm; // 탐지결과 절대경로명 /kamco_nas/export/{chnDtctId} private List excnList; // 등록진행상태히스토리 (최근것부터 DESC) - private String excnStepCd; // 실행단계코드 - private String excnStep; // 실행단계코드에 해당하는 영문명 - private String excnPgrt; // 실행단계진행율 - private String excnBngnDt; // 실행단계시작시간 - private String excnEndDt; // 실행단계종료시간 - private String rmk; // 비고 - private String crtDt; // 생성일시 - private String crtEpno; // 생성사원번호 - private String crtIp; // 생성사원아이피 - private String chgDt; // 변경일시 - private String chgEpno; // 변경사원번호 - private String chgIp; // 변경사원아이피 - private String delYn; // 삭제여부 + private String excnStepCd; // 실행단계코드 + private String excnStep; // 실행단계코드에 해당하는 영문명 + private String excnPgrt; // 실행단계진행율 + private String excnBngnDt; // 실행단계시작시간 + private String excnEndDt; // 실행단계종료시간 + private String rmk; // 비고 + private String crtDt; // 생성일시 + private String crtEpno; // 생성사원번호 + private String crtIp; // 생성사원아이피 + private String chgDt; // 변경일시 + private String chgEpno; // 변경사원번호 + private String chgIp; // 변경사원아이피 + private String delYn; // 삭제여부 // - private String reqEpno; // 요청사원번호 - private String reqIp; // 요청사원어이피 + private String reqEpno; // 요청사원번호 + private String reqIp; // 요청사원어이피 } @Getter @@ -52,15 +49,15 @@ public class ChngDetectMastDto { @AllArgsConstructor public static class ChnDetectMastExcnStepDto { - private String srno; // 일련번호 - private String chnDtctMstId; // 탐지마스터아이디 - private String excnStepCd; // 실행단계코드 - private String excnStep; // 실행단계코드에 해당하는 영문명 - private String excnPgrt; // 실행단계진행율 - private String excnEndDt; // 실행단계종료시간 - private String errCd; // 오류코드 - private String errMsg; // 오류메세지 - private String crtDt; // 실행단계시작시간 + private String srno; // 일련번호 + private String chnDtctMstId; // 탐지마스터아이디 + private String excnStepCd; // 실행단계코드 + private String excnStep; // 실행단계코드에 해당하는 영문명 + private String excnPgrt; // 실행단계진행율 + private String excnEndDt; // 실행단계종료시간 + private String errCd; // 오류코드 + private String errMsg; // 오류메세지 + private String crtDt; // 실행단계시작시간 } @Getter @@ -68,65 +65,61 @@ public class ChngDetectMastDto { @NoArgsConstructor @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; // 사원아이피 + 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; // 사원아이피 } - - @Getter @Setter @NoArgsConstructor @AllArgsConstructor public static class ChnDetectContDto { - private String chnDtctMstId; // 탐지콘텐츠아이디 - private String chnDtctContId; // 탐지마스타아이디 - private String cprsYr; // 비교년도 2023 - private String crtrYr; // 기준년도 2024 - private String chnDtctSno; // 차수 (1 | 2 | ...) - private String mpqdNo; // 도엽번호 - private String chnDtctId; // 탐지아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성 - private String chnDtctObjtId; // 탐지객체아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성 - private String chnDtctPolygon; // 탐지객체폴리곤 - private String chnDtctSqms; // 탐지객체면적 - private String chnCd; // 변화코드 - private String chnDtctJson; // 변화탐지JSON - private String chnDtctProb; // 변화탐지정확도 - private String bfClsCd; // 이전부류코드 - private String bfClsProb; // 이전분류정확도 - private String afClsCd; // 이후분류코드 - private String afClsProb; // 이후분류정확도 - private String crtDt; // 생성일시 - private String crtEpno; // 생성사원번호 - private String crtIp; // 생성사원아이피 - private String delYn; // 삭제여부 + private String chnDtctMstId; // 탐지콘텐츠아이디 + private String chnDtctContId; // 탐지마스타아이디 + private String cprsYr; // 비교년도 2023 + private String crtrYr; // 기준년도 2024 + private String chnDtctSno; // 차수 (1 | 2 | ...) + private String mpqdNo; // 도엽번호 + private String chnDtctId; // 탐지아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성 + private String chnDtctObjtId; // 탐지객체아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성 + private String chnDtctPolygon; // 탐지객체폴리곤 + private String chnDtctSqms; // 탐지객체면적 + private String chnCd; // 변화코드 + private String chnDtctJson; // 변화탐지JSON + private String chnDtctProb; // 변화탐지정확도 + private String bfClsCd; // 이전부류코드 + private String bfClsProb; // 이전분류정확도 + private String afClsCd; // 이후분류코드 + private String afClsProb; // 이후분류정확도 + private String crtDt; // 생성일시 + private String crtEpno; // 생성사원번호 + private String crtIp; // 생성사원아이피 + private String delYn; // 삭제여부 // - private String reqEpno; // 요청사원번호 - private String reqIp; // 요청사원아이피 + private String reqEpno; // 요청사원번호 + private String reqIp; // 요청사원아이피 } - @Getter @Setter @NoArgsConstructor @AllArgsConstructor public static class ChnDetectContReqDto { - private String cprsYr; // 비교년도 2023 - private String crtrYr; // 기준년도 2024 - private String chnDtctSno; // 차수 (1 | 2 | ...) - private String mpqdNo; // 도엽번호 - private String chnDtctId; // 탐지아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성 - private String chnDtctObjtId; // 탐지객체아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성 - private String reqEpno; // 사원번호 + private String cprsYr; // 비교년도 2023 + private String crtrYr; // 기준년도 2024 + private String chnDtctSno; // 차수 (1 | 2 | ...) + private String mpqdNo; // 도엽번호 + private String chnDtctId; // 탐지아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성 + private String chnDtctObjtId; // 탐지객체아이디. UUID를 기반으로 '-'를 제거하고 대문자/숫자로 구성 + private String reqEpno; // 사원번호 private String reqIp; - } @Getter @@ -140,7 +133,6 @@ public class ChngDetectMastDto { private String chnDtctSno; } - @Schema(name = "ResReturn", description = "수행 후 리턴") @Getter @Setter @@ -151,5 +143,4 @@ public class ChngDetectMastDto { private String flag; private String message; } - } diff --git a/src/main/java/com/kamco/cd/kamcoback/Innopam/service/InnopamApiService.java b/src/main/java/com/kamco/cd/kamcoback/Innopam/service/InnopamApiService.java index 31773e84..3b38ebc8 100644 --- a/src/main/java/com/kamco/cd/kamcoback/Innopam/service/InnopamApiService.java +++ b/src/main/java/com/kamco/cd/kamcoback/Innopam/service/InnopamApiService.java @@ -1,49 +1,20 @@ package com.kamco.cd.kamcoback.Innopam.service; import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.ObjectMapper; import com.kamco.cd.kamcoback.Innopam.dto.ChngDetectMastDto; -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.DetectMastDto; -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.DetectMastSearch; -import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.FeaturePnuDto; import com.kamco.cd.kamcoback.Innopam.postgres.core.DetectMastCoreService; import com.kamco.cd.kamcoback.common.utils.NetUtils; import com.kamco.cd.kamcoback.common.utils.UserUtil; -import com.kamco.cd.kamcoback.config.api.ApiResponseDto; import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient; import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult; -import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.DmlReturn; -import java.io.InputStream; -import java.net.InetAddress; -import java.net.URLEncoder; -import java.net.UnknownHostException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ThreadLocalRandom; -import java.util.stream.Collectors; -import java.util.stream.Stream; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; -import org.springframework.http.MediaType; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.util.UriComponentsBuilder; @Service @Transactional(readOnly = true) @@ -59,7 +30,6 @@ public class InnopamApiService { @Value("${innopam.mast}") private String innopamMastUrl; - private final DetectMastCoreService detectMastCoreService; private final ExternalHttpClient externalHttpClient; @@ -74,16 +44,17 @@ public class InnopamApiService { ChngDetectMastDto.Basic basic = new ChngDetectMastDto.Basic(); String url = innopamMastUrl + "/regist"; - //url = "http://localhost:8080/api/kcd/cdi/detect/mast/regist"; + // url = "http://localhost:8080/api/kcd/cdi/detect/mast/regist"; String myip = netUtils.getLocalIP(); chnDetectMastReq.setReqIp(myip); - System.out.println("url == "+ url); - System.out.println("url == "+ myip); + System.out.println("url == " + url); + System.out.println("url == " + myip); ExternalCallResult result = - externalHttpClient.call(url, HttpMethod.POST, chnDetectMastReq, netUtils.jsonHeaders(), String.class); + externalHttpClient.call( + url, HttpMethod.POST, chnDetectMastReq, netUtils.jsonHeaders(), String.class); System.out.println("result == " + result); @@ -91,20 +62,21 @@ public class InnopamApiService { } @Transactional - public ResReturn remove(ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) { + public ResReturn remove(ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) { ChngDetectMastDto.Basic basic = new ChngDetectMastDto.Basic(); String url = innopamMastUrl + "/remove"; - //url = "http://localhost:8080/api/kcd/cdi/detect/mast/remove"; + // url = "http://localhost:8080/api/kcd/cdi/detect/mast/remove"; String myip = netUtils.getLocalIP(); chnDetectMastReq.setReqIp(myip); - System.out.println("url == "+ url); - System.out.println("url == "+ myip); + System.out.println("url == " + url); + System.out.println("url == " + myip); ExternalCallResult result = - externalHttpClient.call(url, HttpMethod.POST, chnDetectMastReq, netUtils.jsonHeaders(), String.class); + externalHttpClient.call( + url, HttpMethod.POST, chnDetectMastReq, netUtils.jsonHeaders(), String.class); System.out.println("result == " + result); @@ -112,23 +84,17 @@ public class InnopamApiService { } @Transactional - public List list(ChngDetectMastDto.ChngDetectMastSearchDto searchDto) { - List masterList = new ArrayList<>(); + public List list(ChngDetectMastDto.ChngDetectMastSearchDto searchDto) { + List masterList = new ArrayList<>(); String queryString = netUtils.dtoToQueryString(searchDto, null); - String url = innopamMastUrl+queryString; + String url = innopamMastUrl + queryString; ExternalCallResult result = - externalHttpClient.call(url, HttpMethod.GET, null, netUtils.jsonHeaders(), String.class); + externalHttpClient.call(url, HttpMethod.GET, null, netUtils.jsonHeaders(), String.class); System.out.println("list result == " + result); return masterList; } - - - - - - } diff --git a/src/main/java/com/kamco/cd/kamcoback/common/utils/NetUtils.java b/src/main/java/com/kamco/cd/kamcoback/common/utils/NetUtils.java index 55e89daa..ce74d280 100644 --- a/src/main/java/com/kamco/cd/kamcoback/common/utils/NetUtils.java +++ b/src/main/java/com/kamco/cd/kamcoback/common/utils/NetUtils.java @@ -7,15 +7,13 @@ import java.net.UnknownHostException; import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; -import java.util.regex.Pattern; import java.util.stream.Collectors; -import org.mindrot.jbcrypt.BCrypt; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; public class NetUtils { - public String getLocalIP(){ + public String getLocalIP() { String ip; { @@ -30,23 +28,26 @@ public class NetUtils { return ip; } - public String dtoToQueryString(Object dto, String queryString) { ObjectMapper objectMapper = new ObjectMapper(); Map map = objectMapper.convertValue(dto, Map.class); - String qStr = map.entrySet().stream() - .filter(entry -> entry.getValue() != null) // null 제외 - .map(entry -> String.format("%s=%s", - entry.getKey(), - URLEncoder.encode(entry.getValue().toString(), StandardCharsets.UTF_8))) - .collect(Collectors.joining("&")); + String qStr = + map.entrySet().stream() + .filter(entry -> entry.getValue() != null) // null 제외 + .map( + entry -> + String.format( + "%s=%s", + entry.getKey(), + URLEncoder.encode(entry.getValue().toString(), StandardCharsets.UTF_8))) + .collect(Collectors.joining("&")); - if( queryString == null || queryString.isEmpty() ) { - queryString = "?"+qStr; - }else{ - queryString = queryString +"&" + qStr; + if (queryString == null || queryString.isEmpty()) { + queryString = "?" + qStr; + } else { + queryString = queryString + "&" + qStr; } // 2. Map을 쿼리 스트링 문자열로 변환 @@ -60,5 +61,4 @@ public class NetUtils { return headers; } - } diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/InferenceResultApiController.java b/src/main/java/com/kamco/cd/kamcoback/inference/InferenceResultApiController.java index 0ffde09a..9e2c9abc 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/InferenceResultApiController.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/InferenceResultApiController.java @@ -204,80 +204,6 @@ public class InferenceResultApiController { return ApiResponseDto.ok(result); } - // @ApiResponses( - // value = { - // @ApiResponse( - // responseCode = "200", - // description = "검색 성공", - // content = - // @Content( - // mediaType = "application/json", - // schema = @Schema(implementation = InferenceDetailDto.AnalResSummary.class))), - // @ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content), - // @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - // }) - // @GetMapping("/summary/{id}") - // public ApiResponseDto getInferenceResultSummary( - // @Parameter(description = "목록 id", example = "53") @PathVariable Long id) { - // return ApiResponseDto.ok(inferenceResultService.getInferenceResultSummary(id)); - // } - // - // @Operation(summary = "추론관리 분석결과 상세", description = "분석결과 상제 정보 Summary, DashBoard") - // @ApiResponses( - // value = { - // @ApiResponse( - // responseCode = "200", - // description = "검색 성공", - // content = - // @Content( - // mediaType = "application/json", - // schema = @Schema(implementation = InferenceDetailDto.Detail.class))), - // @ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content), - // @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - // }) - // @GetMapping("/detail/{id}") - // public ApiResponseDto getInferenceDetail( - // @Parameter(description = "목록 id", example = "53") @PathVariable Long id) { - // return ApiResponseDto.ok(inferenceResultService.getDetail(id)); - // } - // - // @Operation(summary = "추론관리 분석결과 상세 목록", description = "추론관리 분석결과 상세 목록 geojson 데이터 조회") - // @ApiResponses( - // value = { - // @ApiResponse( - // responseCode = "200", - // description = "검색 성공", - // content = - // @Content( - // mediaType = "application/json", - // schema = @Schema(implementation = Page.class))), - // @ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content), - // @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - // }) - // @GetMapping("/geom/{id}") - // public ApiResponseDto> getInferenceResultGeomList( - // @Parameter(description = "분석결과 id", example = "53") @PathVariable Long id, - // @Parameter(description = "기준년도 분류", example = "land") @RequestParam(required = false) - // String targetClass, - // @Parameter(description = "비교년도 분류", example = "waste") @RequestParam(required = false) - // String compareClass, - // @Parameter(description = "5000:1 도협번호 37801011,37801012") @RequestParam(required = false) - // List mapSheetNum, - // @Parameter(description = "페이지 번호 (0부터 시작)", example = "0") @RequestParam(defaultValue = "0") - // int page, - // @Parameter(description = "페이지 크기", example = "20") @RequestParam(defaultValue = "20") - // int size, - // @Parameter(description = "정렬 조건 (형식: 필드명,방향)", example = "name,asc") - // @RequestParam(required = false) - // String sort) { - // InferenceDetailDto.SearchGeoReq searchGeoReq = - // new InferenceDetailDto.SearchGeoReq( - // targetClass, compareClass, mapSheetNum, page, size, sort); - // Page geomList = - // inferenceResultService.getInferenceResultGeomList(id, searchGeoReq); - // return ApiResponseDto.ok(geomList); - // } - @Operation(summary = "추론관리 추론진행 서버 현황", description = "추론관리 추론진행 서버 현황") @ApiResponses( value = { diff --git a/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceDetailDto.java b/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceDetailDto.java index c187d03d..51dbeb03 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceDetailDto.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/dto/InferenceDetailDto.java @@ -308,16 +308,16 @@ public class InferenceDetailDto { String mapSheetName; String subUid; String pnu; - String passYn; + String fitState; - @JsonProperty("passYn") - public String getPassYn() { - return this.passYn == null ? null : this.passYn; + @JsonProperty("fitState") + public String getFitState() { + return this.fitState == null ? null : this.fitState; } - @JsonProperty("passYnName") - public String getPassYnName() { - return ImageryFitStatus.getDescByCode(this.passYn); + @JsonProperty("fitStateName") + public String fitStateName() { + return ImageryFitStatus.getDescByCode(this.fitState); } // @JsonIgnore String gemoStr; @@ -339,7 +339,7 @@ public class InferenceDetailDto { String mapSheetName, String subUid, String pnu, - String passYn) { + String fitState) { this.uuid = uuid; this.uid = uid; this.compareYyyy = compareYyyy; @@ -355,7 +355,7 @@ public class InferenceDetailDto { this.mapSheetName = mapSheetName; this.subUid = subUid; this.pnu = pnu; - this.passYn = passYn; + this.fitState = fitState; } } diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/entity/MapSheetAnalDataInferenceGeomEntity.java b/src/main/java/com/kamco/cd/kamcoback/postgres/entity/MapSheetAnalDataInferenceGeomEntity.java index c08fee12..203028b8 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/entity/MapSheetAnalDataInferenceGeomEntity.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/entity/MapSheetAnalDataInferenceGeomEntity.java @@ -90,7 +90,6 @@ public class MapSheetAnalDataInferenceGeomEntity { private Long pnu; @Size(max = 20) - @ColumnDefault("'0'") @Column(name = "fit_state", length = 20) private String fitState; @@ -150,12 +149,6 @@ public class MapSheetAnalDataInferenceGeomEntity { @Column(name = "file_created_dttm") private ZonedDateTime fileCreatedDttm; - @Column(name = "pass_yn") - private String passYn; - - @Column(name = "pass_yn_dttm") - private ZonedDateTime passYnDttm; - @Column(name = "result_uid") private String resultUid; diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java index 813081e5..07e78bbc 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryImpl.java @@ -446,7 +446,7 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto "substring({0} from 1 for 8)", mapSheetAnalDataInferenceGeomEntity.resultUid), pnu, - mapSheetAnalDataInferenceGeomEntity.passYn)) + mapSheetAnalDataInferenceGeomEntity.fitState)) .from(mapSheetAnalInferenceEntity) .join(mapSheetAnalDataInferenceEntity) .on(mapSheetAnalDataInferenceEntity.analUid.eq(mapSheetAnalInferenceEntity.id)) diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index d3eafec4..eacb76ad 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -63,3 +63,7 @@ inference: geojson-dir: /kamco-nfs/requests/ jar-path: /kamco-nfs/dataset/shp_exporter-1.0.0.jar +innopam: + #url: http://localhost:8080 + url: http://192.168.2.129:5301 + mast: ${innopam.url}/api/kcd/cdi/chn/mast