From 6f25a5462cea12048de585887469788ec640ccda Mon Sep 17 00:00:00 2001 From: teddy Date: Mon, 1 Dec 2025 15:44:28 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B6=84=EC=84=9D=EA=B2=B0=EA=B3=BC=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=EB=AA=A9=EB=A1=9D=20class=20cd=20?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=20lower=20=EB=B9=84=EA=B5=90=EB=A1=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 --- .../InferenceResultRepositoryImpl.java | 228 +++++++++--------- 1 file changed, 118 insertions(+), 110 deletions(-) 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 bf905b9a..8582414b 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 @@ -32,11 +32,11 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC private final QModelVerEntity tmv = QModelVerEntity.modelVerEntity; private final QMapSheetAnalEntity mapSheetAnalEntity = QMapSheetAnalEntity.mapSheetAnalEntity; private final QMapSheetAnalDataEntity mapSheetAnalDataEntity = - QMapSheetAnalDataEntity.mapSheetAnalDataEntity; + QMapSheetAnalDataEntity.mapSheetAnalDataEntity; private final QMapSheetAnalDataGeomEntity mapSheetAnalDataGeomEntity = - QMapSheetAnalDataGeomEntity.mapSheetAnalDataGeomEntity; + QMapSheetAnalDataGeomEntity.mapSheetAnalDataGeomEntity; private final QMapSheetAnalSttcEntity mapSheetAnalSttcEntity = - QMapSheetAnalSttcEntity.mapSheetAnalSttcEntity; + QMapSheetAnalSttcEntity.mapSheetAnalSttcEntity; /** * 분석결과 목록 조회 @@ -46,7 +46,7 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC */ @Override public Page getInferenceResultList( - InferenceResultDto.SearchReq searchReq) { + InferenceResultDto.SearchReq searchReq) { Pageable pageable = searchReq.toPageable(); // "0000" 전체조회 BooleanBuilder builder = new BooleanBuilder(); @@ -60,35 +60,35 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC } List content = - queryFactory - .select( - Projections.constructor( - InferenceResultDto.AnalResList.class, - mapSheetAnalEntity.id, - mapSheetAnalEntity.analTitle, - mapSheetAnalEntity.analMapSheet, - mapSheetAnalEntity.detectingCnt, - mapSheetAnalEntity.analStrtDttm, - mapSheetAnalEntity.analEndDttm, - mapSheetAnalEntity.analSec, - mapSheetAnalEntity.analPredSec, - mapSheetAnalEntity.analState, - Expressions.stringTemplate( - "fn_code_name({0}, {1})", "0002", mapSheetAnalEntity.analState), - mapSheetAnalEntity.gukyuinUsed)) - .from(mapSheetAnalEntity) - .where(builder) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .orderBy(mapSheetAnalEntity.createdDttm.desc()) - .fetch(); + queryFactory + .select( + Projections.constructor( + InferenceResultDto.AnalResList.class, + mapSheetAnalEntity.id, + mapSheetAnalEntity.analTitle, + mapSheetAnalEntity.analMapSheet, + mapSheetAnalEntity.detectingCnt, + mapSheetAnalEntity.analStrtDttm, + mapSheetAnalEntity.analEndDttm, + mapSheetAnalEntity.analSec, + mapSheetAnalEntity.analPredSec, + mapSheetAnalEntity.analState, + Expressions.stringTemplate( + "fn_code_name({0}, {1})", "0002", mapSheetAnalEntity.analState), + mapSheetAnalEntity.gukyuinUsed)) + .from(mapSheetAnalEntity) + .where(builder) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .orderBy(mapSheetAnalEntity.createdDttm.desc()) + .fetch(); long total = - queryFactory - .select(mapSheetAnalEntity.id) - .from(mapSheetAnalEntity) - .where(builder) - .fetchCount(); + queryFactory + .select(mapSheetAnalEntity.id) + .from(mapSheetAnalEntity) + .where(builder) + .fetchCount(); return new PageImpl<>(content, pageable, total); } @@ -104,37 +104,37 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC // 1. 최신 버전 UID를 가져오는 서브쿼리 JPQLQuery latestVerUidSub = - JPAExpressions.select(tmv.id.max()).from(tmv).where(tmv.modelUid.eq(tmm.id)); + JPAExpressions.select(tmv.id.max()).from(tmv).where(tmv.modelUid.eq(tmm.id)); Optional content = - Optional.ofNullable( - queryFactory - .select( - Projections.constructor( - InferenceResultDto.AnalResSummary.class, - mapSheetAnalEntity.id, - mapSheetAnalEntity.analTitle, - tmm.modelNm.concat(" ").concat(tmv.modelVer).as("modelInfo"), - mapSheetAnalEntity.targetYyyy, - mapSheetAnalEntity.compareYyyy, - mapSheetAnalEntity.analMapSheet, - mapSheetAnalEntity.analStrtDttm, - mapSheetAnalEntity.analEndDttm, - mapSheetAnalEntity.analSec, - mapSheetAnalEntity.analPredSec, - mapSheetAnalEntity.resultUrl, - mapSheetAnalEntity.detectingCnt, - mapSheetAnalEntity.accuracy, - mapSheetAnalEntity.analState, - Expressions.stringTemplate( - "fn_code_name({0}, {1})", "0002", mapSheetAnalEntity.analState))) - .from(mapSheetAnalEntity) - .leftJoin(tmm) - .on(mapSheetAnalEntity.modelUid.eq(tmm.id)) - .leftJoin(tmv) - .on(tmv.modelUid.eq(tmm.id).and(tmv.id.eq(latestVerUidSub))) - .where(mapSheetAnalEntity.id.eq(id)) - .fetchOne()); + Optional.ofNullable( + queryFactory + .select( + Projections.constructor( + InferenceResultDto.AnalResSummary.class, + mapSheetAnalEntity.id, + mapSheetAnalEntity.analTitle, + tmm.modelNm.concat(" ").concat(tmv.modelVer).as("modelInfo"), + mapSheetAnalEntity.targetYyyy, + mapSheetAnalEntity.compareYyyy, + mapSheetAnalEntity.analMapSheet, + mapSheetAnalEntity.analStrtDttm, + mapSheetAnalEntity.analEndDttm, + mapSheetAnalEntity.analSec, + mapSheetAnalEntity.analPredSec, + mapSheetAnalEntity.resultUrl, + mapSheetAnalEntity.detectingCnt, + mapSheetAnalEntity.accuracy, + mapSheetAnalEntity.analState, + Expressions.stringTemplate( + "fn_code_name({0}, {1})", "0002", mapSheetAnalEntity.analState))) + .from(mapSheetAnalEntity) + .leftJoin(tmm) + .on(mapSheetAnalEntity.modelUid.eq(tmm.id)) + .leftJoin(tmv) + .on(tmv.modelUid.eq(tmm.id).and(tmv.id.eq(latestVerUidSub))) + .where(mapSheetAnalEntity.id.eq(id)) + .fetchOne()); return content; } @@ -147,16 +147,16 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC @Override public List getDashboard(Long id) { return queryFactory - .select( - Projections.constructor( - Dashboard.class, - mapSheetAnalSttcEntity.id.classAfterCd, - mapSheetAnalSttcEntity.classAfterCnt.sum())) - .from(mapSheetAnalSttcEntity) - .where(mapSheetAnalSttcEntity.id.analUid.eq(id)) - .groupBy(mapSheetAnalSttcEntity.id.classAfterCd) - .orderBy(mapSheetAnalSttcEntity.id.classAfterCd.asc()) - .fetch(); + .select( + Projections.constructor( + Dashboard.class, + mapSheetAnalSttcEntity.id.classAfterCd, + mapSheetAnalSttcEntity.classAfterCnt.sum())) + .from(mapSheetAnalSttcEntity) + .where(mapSheetAnalSttcEntity.id.analUid.eq(id)) + .groupBy(mapSheetAnalSttcEntity.id.classAfterCd) + .orderBy(mapSheetAnalSttcEntity.id.classAfterCd.asc()) + .fetch(); } /** @@ -175,12 +175,20 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC // 기준년도 분류 if (searchGeoReq.getTargetClass() != null && !searchGeoReq.getTargetClass().equals("")) { - builder.and(mapSheetAnalDataGeomEntity.classAfterCd.toLowerCase().eq(searchGeoReq.getTargetClass().toLowerCase())); + builder.and( + mapSheetAnalDataGeomEntity + .classAfterCd + .toLowerCase() + .eq(searchGeoReq.getTargetClass().toLowerCase())); } // 비교년도 분류 if (searchGeoReq.getCompareClass() != null && !searchGeoReq.getCompareClass().equals("")) { - builder.and(mapSheetAnalDataGeomEntity.classBeforeCd.toLowerCase().eq(searchGeoReq.getCompareClass().toLowerCase())); + builder.and( + mapSheetAnalDataGeomEntity + .classBeforeCd + .toLowerCase() + .eq(searchGeoReq.getCompareClass().toLowerCase())); } // 분석도엽 @@ -190,39 +198,39 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC } List content = - queryFactory - .select( - Projections.constructor( - InferenceResultDto.Geom.class, - mapSheetAnalDataGeomEntity.compareYyyy, - mapSheetAnalDataGeomEntity.targetYyyy, - mapSheetAnalDataGeomEntity.classBeforeCd, - mapSheetAnalDataGeomEntity.classBeforeProb, - mapSheetAnalDataGeomEntity.classAfterCd, - mapSheetAnalDataGeomEntity.classAfterProb, - mapSheetAnalDataGeomEntity.mapSheetNum, - mapSheetAnalDataGeomEntity.geom, - mapSheetAnalDataGeomEntity.geomCenter)) - .from(mapSheetAnalEntity) - .join(mapSheetAnalDataEntity) - .on(mapSheetAnalDataEntity.analUid.eq(mapSheetAnalEntity.id)) - .join(mapSheetAnalDataGeomEntity) - .on(mapSheetAnalDataGeomEntity.dataUid.eq(mapSheetAnalDataEntity.id)) - .where(builder) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + queryFactory + .select( + Projections.constructor( + InferenceResultDto.Geom.class, + mapSheetAnalDataGeomEntity.compareYyyy, + mapSheetAnalDataGeomEntity.targetYyyy, + mapSheetAnalDataGeomEntity.classBeforeCd, + mapSheetAnalDataGeomEntity.classBeforeProb, + mapSheetAnalDataGeomEntity.classAfterCd, + mapSheetAnalDataGeomEntity.classAfterProb, + mapSheetAnalDataGeomEntity.mapSheetNum, + mapSheetAnalDataGeomEntity.geom, + mapSheetAnalDataGeomEntity.geomCenter)) + .from(mapSheetAnalEntity) + .join(mapSheetAnalDataEntity) + .on(mapSheetAnalDataEntity.analUid.eq(mapSheetAnalEntity.id)) + .join(mapSheetAnalDataGeomEntity) + .on(mapSheetAnalDataGeomEntity.dataUid.eq(mapSheetAnalDataEntity.id)) + .where(builder) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); long total = - queryFactory - .select(mapSheetAnalDataGeomEntity.id) - .from(mapSheetAnalEntity) - .join(mapSheetAnalDataEntity) - .on(mapSheetAnalDataEntity.analUid.eq(mapSheetAnalEntity.id)) - .join(mapSheetAnalDataGeomEntity) - .on(mapSheetAnalDataGeomEntity.dataUid.eq(mapSheetAnalDataEntity.id)) - .where(builder) - .fetchCount(); + queryFactory + .select(mapSheetAnalDataGeomEntity.id) + .from(mapSheetAnalEntity) + .join(mapSheetAnalDataEntity) + .on(mapSheetAnalDataEntity.analUid.eq(mapSheetAnalEntity.id)) + .join(mapSheetAnalDataGeomEntity) + .on(mapSheetAnalDataGeomEntity.dataUid.eq(mapSheetAnalDataEntity.id)) + .where(builder) + .fetchCount(); return new PageImpl<>(content, pageable, total); } @@ -236,12 +244,12 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC @Override public List getSheets(Long id) { return queryFactory - .select(mapSheetAnalDataEntity.mapSheetNum) - .from(mapSheetAnalEntity) - .join(mapSheetAnalDataEntity) - .on(mapSheetAnalDataEntity.analUid.eq(mapSheetAnalEntity.id)) - .where(mapSheetAnalEntity.id.eq(id)) - .groupBy(mapSheetAnalDataEntity.mapSheetNum) - .fetch(); + .select(mapSheetAnalDataEntity.mapSheetNum) + .from(mapSheetAnalEntity) + .join(mapSheetAnalDataEntity) + .on(mapSheetAnalDataEntity.analUid.eq(mapSheetAnalEntity.id)) + .where(mapSheetAnalEntity.id.eq(id)) + .groupBy(mapSheetAnalDataEntity.mapSheetNum) + .fetch(); } }