From e93f533c59288af5688f6824b74607ed0251be63 Mon Sep 17 00:00:00 2001 From: teddy Date: Thu, 2 Apr 2026 18:04:41 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=84=EC=8B=9C=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=EC=85=8B=20=ED=8F=B4=EB=8D=94=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?G4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cd/training/common/dto/HyperParam.java | 2 +- .../hyperparam/HyperParamApiController.java | 2 +- .../model/ModelTrainMngApiController.java | 2 +- .../dataset/DatasetRepositoryImpl.java | 4 +- .../model/ModelDatasetMappRepositoryImpl.java | 148 ++++++++++++++---- 5 files changed, 118 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/kamco/cd/training/common/dto/HyperParam.java b/src/main/java/com/kamco/cd/training/common/dto/HyperParam.java index a5c46f6..314b4e8 100644 --- a/src/main/java/com/kamco/cd/training/common/dto/HyperParam.java +++ b/src/main/java/com/kamco/cd/training/common/dto/HyperParam.java @@ -14,7 +14,7 @@ import lombok.Setter; public class HyperParam { @Schema(description = "모델", example = "G1") - private ModelType model; // G1, G2, G3 + private ModelType model; // G1, G2, G3, G4 // ------------------------- // Important diff --git a/src/main/java/com/kamco/cd/training/hyperparam/HyperParamApiController.java b/src/main/java/com/kamco/cd/training/hyperparam/HyperParamApiController.java index ef04353..83fad65 100644 --- a/src/main/java/com/kamco/cd/training/hyperparam/HyperParamApiController.java +++ b/src/main/java/com/kamco/cd/training/hyperparam/HyperParamApiController.java @@ -101,7 +101,7 @@ public class HyperParamApiController { LocalDate endDate, @Parameter(description = "버전명", example = "G1_000019") @RequestParam(required = false) String hyperVer, - @Parameter(description = "모델 타입 (G1, G2, G3 중 하나)", example = "G1") + @Parameter(description = "모델 타입 (G1, G2, G3, G4 중 하나)", example = "G1") @RequestParam(required = false) ModelType model, @Parameter( diff --git a/src/main/java/com/kamco/cd/training/model/ModelTrainMngApiController.java b/src/main/java/com/kamco/cd/training/model/ModelTrainMngApiController.java index 0439cff..40220fa 100644 --- a/src/main/java/com/kamco/cd/training/model/ModelTrainMngApiController.java +++ b/src/main/java/com/kamco/cd/training/model/ModelTrainMngApiController.java @@ -69,7 +69,7 @@ public class ModelTrainMngApiController { @Parameter( description = "모델", example = "G1", - schema = @Schema(allowableValues = {"G1", "G2", "G3"})) + schema = @Schema(allowableValues = {"G1", "G2", "G3", "G4"})) @RequestParam(required = false) String modelNo, @Parameter(description = "페이지 번호") @RequestParam(defaultValue = "0") int page, diff --git a/src/main/java/com/kamco/cd/training/postgres/repository/dataset/DatasetRepositoryImpl.java b/src/main/java/com/kamco/cd/training/postgres/repository/dataset/DatasetRepositoryImpl.java index 8e75dc4..9c600cf 100644 --- a/src/main/java/com/kamco/cd/training/postgres/repository/dataset/DatasetRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/training/postgres/repository/dataset/DatasetRepositoryImpl.java @@ -522,9 +522,7 @@ public class DatasetRepositoryImpl implements DatasetRepositoryCustom { dataset.targetYyyy, dataset.memo, new CaseBuilder() - .when( - datasetObjEntity.targetClassCd.equalsIgnoreCase( - DetectionClassification.SOLAR.getId())) + .when(datasetObjEntity.targetClassCd.eq(DetectionClassification.SOLAR.getId())) .then(1) .otherwise(0) .sum())) diff --git a/src/main/java/com/kamco/cd/training/postgres/repository/model/ModelDatasetMappRepositoryImpl.java b/src/main/java/com/kamco/cd/training/postgres/repository/model/ModelDatasetMappRepositoryImpl.java index f06ebdd..c0b3276 100644 --- a/src/main/java/com/kamco/cd/training/postgres/repository/model/ModelDatasetMappRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/training/postgres/repository/model/ModelDatasetMappRepositoryImpl.java @@ -1,9 +1,11 @@ package com.kamco.cd.training.postgres.repository.model; import static com.kamco.cd.training.postgres.entity.QDatasetEntity.datasetEntity; +import static com.kamco.cd.training.postgres.entity.QDatasetObjEntity.datasetObjEntity; import static com.kamco.cd.training.postgres.entity.QModelDatasetMappEntity.modelDatasetMappEntity; import static com.kamco.cd.training.postgres.entity.QModelMasterEntity.modelMasterEntity; +import com.kamco.cd.training.common.enums.DetectionClassification; import com.kamco.cd.training.common.enums.ModelType; import com.kamco.cd.training.postgres.entity.ModelDatasetMappEntity; import com.kamco.cd.training.postgres.entity.QDatasetObjEntity; @@ -11,6 +13,7 @@ import com.kamco.cd.training.postgres.entity.QDatasetTestObjEntity; import com.kamco.cd.training.postgres.entity.QDatasetValObjEntity; import com.kamco.cd.training.train.dto.ModelTrainLinkDto; import com.querydsl.core.types.Projections; +import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; import java.util.List; import lombok.RequiredArgsConstructor; @@ -33,9 +36,44 @@ public class ModelDatasetMappRepositoryImpl implements ModelDatasetMappRepositor @Override public List findDatasetTrainPath(Long modelId) { - QDatasetObjEntity datasetObjEntity = QDatasetObjEntity.datasetObjEntity; + // ===================== + // 조건 분리 + // ===================== + BooleanExpression g1 = + modelMasterEntity + .modelNo + .eq(ModelType.G1.getId()) + .and( + datasetObjEntity.targetClassCd.in( + DetectionClassification.CONTAINER.getId(), + DetectionClassification.BUILDING.getId())); + + BooleanExpression g2 = + modelMasterEntity + .modelNo + .eq(ModelType.G2.getId()) + .and(datasetObjEntity.targetClassCd.eq(DetectionClassification.WASTE.getId())); + + BooleanExpression g4 = + modelMasterEntity + .modelNo + .eq(ModelType.G4.getId()) + .and(datasetObjEntity.targetClassCd.eq(DetectionClassification.SOLAR.getId())); + + // G3 = 전체 허용 (fallback) + BooleanExpression g3 = + modelMasterEntity + .modelNo + .eq(ModelType.G3.getId()) + .and( + datasetObjEntity.targetClassCd.notIn( + DetectionClassification.CONTAINER.getId(), + DetectionClassification.BUILDING.getId(), + DetectionClassification.WASTE.getId(), + DetectionClassification.SOLAR.getId())); + return queryFactory .select( Projections.constructor( @@ -60,17 +98,7 @@ public class ModelDatasetMappRepositoryImpl implements ModelDatasetMappRepositor datasetObjEntity .datasetUid .eq(modelDatasetMappEntity.datasetUid) - .and( - modelMasterEntity - .modelNo - .eq(ModelType.G1.getId()) - .and(datasetObjEntity.targetClassCd.upper().in("CONTAINER", "BUILDING")) - .or( - modelMasterEntity - .modelNo - .eq(ModelType.G2.getId()) - .and(datasetObjEntity.targetClassCd.upper().eq("WASTE"))) - .or(modelMasterEntity.modelNo.eq(ModelType.G3.getId())))) + .and(g1.or(g2).or(g4).or(g3))) .where(modelMasterEntity.id.eq(modelId)) .fetch(); } @@ -80,6 +108,42 @@ public class ModelDatasetMappRepositoryImpl implements ModelDatasetMappRepositor QDatasetValObjEntity datasetValObjEntity = QDatasetValObjEntity.datasetValObjEntity; + // ===================== + // 조건 분리 + // ===================== + BooleanExpression g1 = + modelMasterEntity + .modelNo + .eq(ModelType.G1.getId()) + .and( + datasetValObjEntity.targetClassCd.in( + DetectionClassification.CONTAINER.getId(), + DetectionClassification.BUILDING.getId())); + + BooleanExpression g2 = + modelMasterEntity + .modelNo + .eq(ModelType.G2.getId()) + .and(datasetValObjEntity.targetClassCd.eq(DetectionClassification.WASTE.getId())); + + BooleanExpression g4 = + modelMasterEntity + .modelNo + .eq(ModelType.G4.getId()) + .and(datasetValObjEntity.targetClassCd.eq(DetectionClassification.SOLAR.getId())); + + // G3 = 전체 허용 (fallback) + BooleanExpression g3 = + modelMasterEntity + .modelNo + .eq(ModelType.G3.getId()) + .and( + datasetValObjEntity.targetClassCd.notIn( + DetectionClassification.CONTAINER.getId(), + DetectionClassification.BUILDING.getId(), + DetectionClassification.WASTE.getId(), + DetectionClassification.SOLAR.getId())); + return queryFactory .select( Projections.constructor( @@ -104,17 +168,7 @@ public class ModelDatasetMappRepositoryImpl implements ModelDatasetMappRepositor datasetValObjEntity .datasetUid .eq(modelDatasetMappEntity.datasetUid) - .and( - modelMasterEntity - .modelNo - .eq(ModelType.G1.getId()) - .and(datasetValObjEntity.targetClassCd.upper().in("CONTAINER", "BUILDING")) - .or( - modelMasterEntity - .modelNo - .eq(ModelType.G2.getId()) - .and(datasetValObjEntity.targetClassCd.upper().eq("WASTE"))) - .or(modelMasterEntity.modelNo.eq(ModelType.G3.getId())))) + .and(g1.or(g2).or(g4).or(g3))) .where(modelMasterEntity.id.eq(modelId)) .fetch(); } @@ -124,6 +178,42 @@ public class ModelDatasetMappRepositoryImpl implements ModelDatasetMappRepositor QDatasetTestObjEntity datasetTestObjEntity = QDatasetTestObjEntity.datasetTestObjEntity; + // ===================== + // 조건 분리 + // ===================== + BooleanExpression g1 = + modelMasterEntity + .modelNo + .eq(ModelType.G1.getId()) + .and( + datasetTestObjEntity.targetClassCd.in( + DetectionClassification.CONTAINER.getId(), + DetectionClassification.BUILDING.getId())); + + BooleanExpression g2 = + modelMasterEntity + .modelNo + .eq(ModelType.G2.getId()) + .and(datasetTestObjEntity.targetClassCd.eq(DetectionClassification.WASTE.getId())); + + BooleanExpression g4 = + modelMasterEntity + .modelNo + .eq(ModelType.G4.getId()) + .and(datasetTestObjEntity.targetClassCd.eq(DetectionClassification.SOLAR.getId())); + + // G3 = 전체 허용 (fallback) + BooleanExpression g3 = + modelMasterEntity + .modelNo + .eq(ModelType.G3.getId()) + .and( + datasetTestObjEntity.targetClassCd.notIn( + DetectionClassification.CONTAINER.getId(), + DetectionClassification.BUILDING.getId(), + DetectionClassification.WASTE.getId(), + DetectionClassification.SOLAR.getId())); + return queryFactory .select( Projections.constructor( @@ -148,17 +238,7 @@ public class ModelDatasetMappRepositoryImpl implements ModelDatasetMappRepositor datasetTestObjEntity .datasetUid .eq(modelDatasetMappEntity.datasetUid) - .and( - modelMasterEntity - .modelNo - .eq(ModelType.G1.getId()) - .and(datasetTestObjEntity.targetClassCd.upper().in("CONTAINER", "BUILDING")) - .or( - modelMasterEntity - .modelNo - .eq(ModelType.G2.getId()) - .and(datasetTestObjEntity.targetClassCd.upper().eq("WASTE"))) - .or(modelMasterEntity.modelNo.eq(ModelType.G3.getId())))) + .and(g1.or(g2).or(g4).or(g3))) .where(modelMasterEntity.id.eq(modelId)) .fetch(); } -- 2.49.1