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 e47761d9..5f4189c4 100644 --- a/src/main/java/com/kamco/cd/kamcoback/inference/InferenceResultApiController.java +++ b/src/main/java/com/kamco/cd/kamcoback/inference/InferenceResultApiController.java @@ -323,9 +323,9 @@ public class InferenceResultApiController { }) @GetMapping("/infer-result-info") public ApiResponseDto getInferenceResultInfo( - @Parameter(description = "회차 uuid", example = "932fbd72-2e8e-4a49-b189-09046787f9d1") + @Parameter(description = "회차 uuid", example = "f30e8817-9625-4fff-ba43-c1e6ed2067c4") @RequestParam - String uuid) { + UUID uuid) { return ApiResponseDto.ok(inferenceResultService.getInferenceResultInfo(uuid)); } @@ -344,9 +344,9 @@ public class InferenceResultApiController { }) @GetMapping("/infer-class-count") public ApiResponseDto> getInferenceClassCountList( - @Parameter(description = "회차 uuid", example = "8584e8d4-53b3-4582-bde2-28a81495a626") + @Parameter(description = "회차 uuid", example = "242750c5-a627-429b-950a-dce5a87c1c01") @RequestParam - String uuid) { + UUID uuid) { return ApiResponseDto.ok(inferenceResultService.getInferenceClassCountList(uuid)); } @@ -365,7 +365,7 @@ public class InferenceResultApiController { }) @GetMapping("/geom-list") public ApiResponseDto> getInferenceGeomList( - @Parameter(description = "회차 uuid", example = "8584e8d4-53b3-4582-bde2-28a81495a626") + @Parameter(description = "회차 uuid", example = "242750c5-a627-429b-950a-dce5a87c1c01") @RequestParam(required = true) UUID uuid, @Parameter(description = "기준년도 분류", example = "land") @RequestParam(required = false) 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 d825a462..1bb42407 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 @@ -472,14 +472,16 @@ public class InferenceDetailDto { ? Duration.between(inferStartDttm, inferEndDttm) : null; - long seconds = elapsed.getSeconds(); - long abs = Math.abs(seconds); + if (elapsed != null) { + long seconds = elapsed.getSeconds(); + long abs = Math.abs(seconds); - long h = abs / 3600; - long m = (abs % 3600) / 60; - long s = abs % 60; + long h = abs / 3600; + long m = (abs % 3600) / 60; + long s = abs % 60; - this.elapsedDuration = String.format("%02d:%02d:%02d", h, m, s); + this.elapsedDuration = String.format("%02d:%02d:%02d", h, m, s); + } } } } 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 e017e5c5..b502c4cb 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 @@ -62,6 +62,7 @@ public class InferenceResultService { private final ModelMngCoreService modelMngCoreService; private final ExternalHttpClient externalHttpClient; private final ObjectMapper objectMapper; + private final UserUtil userUtil; @Value("${inference.url}") private String inferenceUrl; @@ -72,8 +73,6 @@ public class InferenceResultService { @Value("${spring.profiles.active}") private String profile; - private final UserUtil userUtil; - /** * 추론관리 목록 * @@ -494,11 +493,11 @@ public class InferenceResultService { return dto; } - public AnalResultInfo getInferenceResultInfo(String uuid) { + public AnalResultInfo getInferenceResultInfo(UUID uuid) { return inferenceResultCoreService.getInferenceResultInfo(uuid); } - public List getInferenceClassCountList(String uuid) { + public List getInferenceClassCountList(UUID uuid) { return inferenceResultCoreService.getInferenceClassCountList(uuid); } diff --git a/src/main/java/com/kamco/cd/kamcoback/label/LabelAllocateApiController.java b/src/main/java/com/kamco/cd/kamcoback/label/LabelAllocateApiController.java index 6745a735..11243bb8 100644 --- a/src/main/java/com/kamco/cd/kamcoback/label/LabelAllocateApiController.java +++ b/src/main/java/com/kamco/cd/kamcoback/label/LabelAllocateApiController.java @@ -256,36 +256,18 @@ public class LabelAllocateApiController { mediaType = "application/json", schema = @Schema(implementation = UpdateClosedRequest.class), examples = { - @io.swagger.v3.oas.annotations.media.ExampleObject( - name = "라벨링 종료", - value = - """ - {"closedType": "LABELING", "closedYn": "Y"} - """), - @io.swagger.v3.oas.annotations.media.ExampleObject( - name = "검수 종료", - value = - """ - {"closedType": "INSPECTION", "closedYn": "Y"} - """), - @io.swagger.v3.oas.annotations.media.ExampleObject( - name = "라벨링 재개", - value = - """ - {"closedType": "LABELING", "closedYn": "N"} - """), - @io.swagger.v3.oas.annotations.media.ExampleObject( - name = "검수 재개", - value = - """ - {"closedType": "INSPECTION", "closedYn": "N"} - """), @io.swagger.v3.oas.annotations.media.ExampleObject( name = "특정 프로젝트 라벨링 전체 종료", value = """ + {"uuid": "f97dc186-e6d3-4645-9737-3173dde8dc64", "closedType": "LABELING", "closedYn": "Y"} + """), + @io.swagger.v3.oas.annotations.media.ExampleObject( + name = "특정 프로젝트 검수 전체 종료", + value = + """ {"uuid": "f97dc186-e6d3-4645-9737-3173dde8dc64", "closedType": "INSPECTION", "closedYn": "Y"} - """) + """) })) @RequestBody @Valid diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/core/InferenceResultCoreService.java b/src/main/java/com/kamco/cd/kamcoback/postgres/core/InferenceResultCoreService.java index ff92c270..aea7bcbf 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/core/InferenceResultCoreService.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/core/InferenceResultCoreService.java @@ -403,11 +403,11 @@ public class InferenceResultCoreService { return dto; } - public AnalResultInfo getInferenceResultInfo(String uuid) { + public AnalResultInfo getInferenceResultInfo(UUID uuid) { return mapSheetLearnRepository.getInferenceResultInfo(uuid); } - public List getInferenceClassCountList(String uuid) { + public List getInferenceClassCountList(UUID uuid) { return mapSheetLearnRepository.getInferenceClassCountList(uuid); } diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/InferenceResultRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/InferenceResultRepositoryImpl.java index 1e6bcc15..9b623183 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/InferenceResultRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/InferenceResultRepositoryImpl.java @@ -37,38 +37,38 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC public Long upsertGroupsFromMapSheetAnal(Long id) { String sql = """ - INSERT INTO tb_map_sheet_anal_inference ( - stage, - compare_yyyy, - target_yyyy, - anal_title, - detecting_cnt, - created_dttm, - m1_model_batch_id, - m2_model_batch_id, - m3_model_batch_id, - learn_id - ) - SELECT - r.stage, - r.compare_yyyy, - r.target_yyyy, - CONCAT(r.stage, '_', r.compare_yyyy, '_', r.target_yyyy) AS anal_title, - r.detecting_cnt, - now(), - r.m1_model_batch_id, - r.m2_model_batch_id, - r.m3_model_batch_id, - r.id - FROM tb_map_sheet_learn r - WHERE r.id = :id - ON CONFLICT (stage, compare_yyyy, target_yyyy) - DO UPDATE SET - detecting_cnt = EXCLUDED.detecting_cnt, - anal_title = EXCLUDED.anal_title, - updated_dttm = now(), - learn_id = EXCLUDED.learn_id - RETURNING anal_uid + INSERT INTO tb_map_sheet_anal_inference ( + stage, + compare_yyyy, + target_yyyy, + anal_title, + detecting_cnt, + created_dttm, + m1_model_batch_id, + m2_model_batch_id, + m3_model_batch_id, + learn_id + ) + SELECT + r.stage, + r.compare_yyyy, + r.target_yyyy, + r.title, + r.detecting_cnt, + now(), + r.m1_model_batch_id, + r.m2_model_batch_id, + r.m3_model_batch_id, + r.id + FROM tb_map_sheet_learn r + WHERE r.id = :id + ON CONFLICT (stage, compare_yyyy, target_yyyy) + DO UPDATE SET + detecting_cnt = EXCLUDED.detecting_cnt, + anal_title = EXCLUDED.anal_title, + updated_dttm = now(), + learn_id = EXCLUDED.learn_id + RETURNING anal_uid """; Object result = em.createNativeQuery(sql).setParameter("id", id).getSingleResult(); diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryCustom.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryCustom.java index 55683c6b..fef0cb99 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryCustom.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearnRepositoryCustom.java @@ -32,9 +32,9 @@ public interface MapSheetLearnRepositoryCustom { Integer getLearnStage(Integer compareYear, Integer targetYear); - AnalResultInfo getInferenceResultInfo(String uuid); + AnalResultInfo getInferenceResultInfo(UUID uuid); - List getInferenceClassCountList(String uuid); + List getInferenceClassCountList(UUID uuid); Page getInferenceGeomList(UUID uuid, SearchGeoReq searchGeoReq); } 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 70d1892c..a0a5f1ab 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 @@ -19,7 +19,6 @@ import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto; import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceServerStatusDto; import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceStatusDetailDto; import com.kamco.cd.kamcoback.model.service.ModelMngService; -import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalInferenceEntity; import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnEntity; import com.kamco.cd.kamcoback.postgres.entity.QModelMngEntity; import com.querydsl.core.BooleanBuilder; @@ -28,7 +27,6 @@ import com.querydsl.core.types.dsl.CaseBuilder; import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.NumberExpression; import com.querydsl.jpa.impl.JPAQueryFactory; -import jakarta.persistence.EntityNotFoundException; import java.time.OffsetDateTime; import java.util.List; import java.util.Objects; @@ -292,7 +290,7 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto } @Override - public AnalResultInfo getInferenceResultInfo(String uuid) { + public AnalResultInfo getInferenceResultInfo(UUID uuid) { QModelMngEntity m1 = new QModelMngEntity("m1"); QModelMngEntity m2 = new QModelMngEntity("m2"); QModelMngEntity m3 = new QModelMngEntity("m3"); @@ -319,22 +317,22 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto .on(mapSheetLearnEntity.m2ModelUuid.eq(m2.uuid)) .leftJoin(m3) .on(mapSheetLearnEntity.m3ModelUuid.eq(m3.uuid)) - .where(mapSheetLearnEntity.uuid.eq(UUID.fromString(uuid))) + .where(mapSheetLearnEntity.uuid.eq(uuid)) .fetchOne(); } @Override - public List getInferenceClassCountList(String uuid) { + public List getInferenceClassCountList(UUID uuid) { // analUid로 분석 정보 조회 - MapSheetAnalInferenceEntity analEntity = + MapSheetLearnEntity learnEntity = queryFactory - .selectFrom(mapSheetAnalInferenceEntity) - .where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid))) + .selectFrom(mapSheetLearnEntity) + .where(mapSheetLearnEntity.uuid.eq(uuid)) .fetchOne(); - if (Objects.isNull(analEntity)) { - throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: "); + if (Objects.isNull(learnEntity)) { + throw new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND); } return queryFactory @@ -343,8 +341,10 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto Dashboard.class, mapSheetAnalSttcEntity.id.classAfterCd, mapSheetAnalSttcEntity.classAfterCnt.sum())) - .from(mapSheetAnalSttcEntity) - .where(mapSheetAnalSttcEntity.id.analUid.eq(analEntity.getId())) + .from(mapSheetAnalInferenceEntity) + .innerJoin(mapSheetAnalSttcEntity) + .on(mapSheetAnalInferenceEntity.id.eq(mapSheetAnalSttcEntity.id.analUid)) + .where(mapSheetAnalInferenceEntity.learnId.eq(learnEntity.getId())) .groupBy(mapSheetAnalSttcEntity.id.classAfterCd) .orderBy(mapSheetAnalSttcEntity.id.classAfterCd.asc()) .fetch(); @@ -362,10 +362,10 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto BooleanBuilder builder = new BooleanBuilder(); // analUid로 분석 정보 조회 - MapSheetAnalInferenceEntity analEntity = + MapSheetLearnEntity analEntity = queryFactory - .selectFrom(mapSheetAnalInferenceEntity) - .where(mapSheetAnalInferenceEntity.uuid.eq(uuid)) + .selectFrom(mapSheetLearnEntity) + .where(mapSheetLearnEntity.uuid.eq(uuid)) .fetchOne(); if (Objects.isNull(analEntity)) { @@ -373,7 +373,7 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto } // 추론결과 id - builder.and(mapSheetAnalInferenceEntity.id.eq(analEntity.getId())); + builder.and(mapSheetAnalInferenceEntity.learnId.eq(analEntity.getId())); // 기준년도 분류 if (searchGeoReq.getTargetClass() != null && !searchGeoReq.getTargetClass().equals("")) {