From e2eb653df75c1f98e5e8414ec6351fc81e645b47 Mon Sep 17 00:00:00 2001 From: teddy Date: Thu, 22 Jan 2026 12:13:19 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B6=94=EB=A1=A0=20=EA=B2=B0=EA=B3=BC=20?= =?UTF-8?q?=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 --- .../inference/dto/InferenceDetailDto.java | 181 ++++--- .../inference/dto/InferenceResultDto.java | 105 ++-- .../postgres/entity/MapSheetLearnEntity.java | 32 +- .../kamcoback/postgres/entity/PnuEntity.java | 51 ++ .../MapSheetLearn5kRepositoryImpl.java | 125 ++--- .../MapSheetLearnRepositoryImpl.java | 477 +++++++++--------- 6 files changed, 530 insertions(+), 441 deletions(-) create mode 100644 src/main/java/com/kamco/cd/kamcoback/postgres/entity/PnuEntity.java 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 1a358bd2..45d31e70 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 @@ -29,20 +29,22 @@ public class InferenceDetailDto { private String dataName; private Long mapSheepNum; private Long detectingCnt; - @JsonFormatDttm private ZonedDateTime analStrtDttm; - @JsonFormatDttm private ZonedDateTime analEndDttm; + @JsonFormatDttm + private ZonedDateTime analStrtDttm; + @JsonFormatDttm + private ZonedDateTime analEndDttm; private Long analSec; private String analState; public Basic( - Long id, - String dataName, - Long mapSheepNum, - Long detectingCnt, - ZonedDateTime analStrtDttm, - ZonedDateTime analEndDttm, - Long analSec, - String analState) { + Long id, + String dataName, + Long mapSheepNum, + Long detectingCnt, + ZonedDateTime analStrtDttm, + ZonedDateTime analEndDttm, + Long analSec, + String analState) { this.id = id; this.dataName = dataName; this.mapSheepNum = mapSheepNum; @@ -61,8 +63,10 @@ public class InferenceDetailDto { private Long id; private String analTitle; private Long detectingCnt; - @JsonFormatDttm private ZonedDateTime analStrtDttm; - @JsonFormatDttm private ZonedDateTime analEndDttm; + @JsonFormatDttm + private ZonedDateTime analStrtDttm; + @JsonFormatDttm + private ZonedDateTime analEndDttm; private Long analSec; private Long analPredSec; private String analState; @@ -70,16 +74,16 @@ public class InferenceDetailDto { private String gukyuinUsed; public AnalResList( - Long id, - String analTitle, - Long detectingCnt, - ZonedDateTime analStrtDttm, - ZonedDateTime analEndDttm, - Long analSec, - Long analPredSec, - String analState, - String analStateNm, - String gukyuinUsed) { + Long id, + String analTitle, + Long detectingCnt, + ZonedDateTime analStrtDttm, + ZonedDateTime analEndDttm, + Long analSec, + Long analPredSec, + String analState, + String analStateNm, + String gukyuinUsed) { this.id = id; this.analTitle = analTitle; this.detectingCnt = detectingCnt; @@ -102,8 +106,10 @@ public class InferenceDetailDto { private String modelInfo; private Integer targetYyyy; private Integer compareYyyy; - @JsonFormatDttm private ZonedDateTime analStrtDttm; - @JsonFormatDttm private ZonedDateTime analEndDttm; + @JsonFormatDttm + private ZonedDateTime analStrtDttm; + @JsonFormatDttm + private ZonedDateTime analEndDttm; private Long analSec; private Long analPredSec; private String resultUrl; @@ -113,20 +119,20 @@ public class InferenceDetailDto { private String analStateNm; public AnalResSummary( - Long id, - String analTitle, - String modelInfo, - Integer targetYyyy, - Integer compareYyyy, - ZonedDateTime analStrtDttm, - ZonedDateTime analEndDttm, - Long analSec, - Long analPredSec, - String resultUrl, - Long detectingCnt, - Double accuracy, - String analState, - String analStateNm) { + Long id, + String analTitle, + String modelInfo, + Integer targetYyyy, + Integer compareYyyy, + ZonedDateTime analStrtDttm, + ZonedDateTime analEndDttm, + Long analSec, + Long analPredSec, + String resultUrl, + Long detectingCnt, + Double accuracy, + String analState, + String analStateNm) { this.id = id; this.analTitle = analTitle; this.modelInfo = modelInfo; @@ -183,16 +189,17 @@ public class InferenceDetailDto { private Clazzes target; private MapSheet mapSheet; private Coordinate center; - @JsonFormatDttm private ZonedDateTime updatedDttm; + @JsonFormatDttm + private ZonedDateTime updatedDttm; public DetailListEntity( - UUID uuid, - Double detectionScore, - Clazzes compare, - Clazzes target, - MapSheet mapSheet, - Coordinate center, - ZonedDateTime updatedDttm) { + UUID uuid, + Double detectionScore, + Clazzes compare, + Clazzes target, + MapSheet mapSheet, + Coordinate center, + ZonedDateTime updatedDttm) { this.code = new Uid(uuid); this.detectionScore = detectionScore; this.compare = compare; @@ -233,7 +240,8 @@ public class InferenceDetailDto { private String code; private String name; - @JsonIgnore private Double score; + @JsonIgnore + private Double score; public Clazz(String code, Double score) { this.code = code; @@ -305,6 +313,7 @@ public class InferenceDetailDto { Long mapSheetNum; String mapSheetName; String subUid; + String pnu; // @JsonIgnore String gemoStr; // @JsonIgnore String geomCenterStr; @@ -312,18 +321,19 @@ public class InferenceDetailDto { // JsonNode geomCenter; public Geom( - UUID uuid, - String uid, - Integer compareYyyy, - Integer targetYyyy, - Double cdProb, - String classBeforeCd, - Double classBeforeProb, - String classAfterCd, - Double classAfterProb, - Long mapSheetNum, - String mapSheetName, - String subUid) { + UUID uuid, + String uid, + Integer compareYyyy, + Integer targetYyyy, + Double cdProb, + String classBeforeCd, + Double classBeforeProb, + String classAfterCd, + Double classAfterProb, + Long mapSheetNum, + String mapSheetName, + String subUid, + String pnu) { this.uuid = uuid; this.uid = uid; this.compareYyyy = compareYyyy; @@ -338,20 +348,7 @@ public class InferenceDetailDto { this.mapSheetNum = mapSheetNum; this.mapSheetName = mapSheetName; this.subUid = subUid; - // this.gemoStr = gemoStr; - // this.geomCenterStr = geomCenterStr; - // - // ObjectMapper mapper = new ObjectMapper(); - // JsonNode geomJson; - // JsonNode geomCenterJson; - // try { - // geomJson = mapper.readTree(gemoStr); - // geomCenterJson = mapper.readTree(geomCenterStr); - // } catch (JsonProcessingException e) { - // throw new RuntimeException(e); - // } - // this.gemo = geomJson; - // this.geomCenter = geomCenterJson; + this.pnu = pnu; } } @@ -399,7 +396,7 @@ public class InferenceDetailDto { String[] sortParams = sort.split(","); String property = sortParams[0]; Sort.Direction direction = - sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC; + sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC; return PageRequest.of(page, size, Sort.by(direction, property)); } return PageRequest.of(page, size); @@ -439,25 +436,27 @@ public class InferenceDetailDto { private Integer targetYyyy; private String detectOption; private String mapSheetScope; - @JsonFormatDttm private ZonedDateTime inferStartDttm; - @JsonFormatDttm private ZonedDateTime inferEndDttm; + @JsonFormatDttm + private ZonedDateTime inferStartDttm; + @JsonFormatDttm + private ZonedDateTime inferEndDttm; private Integer stage; private String elapsedDuration; private String subUid; public AnalResultInfo( - String analTitle, - String modelVer1, - String modelVer2, - String modelVer3, - Integer compareYyyy, - Integer targetYyyy, - String detectOption, - String mapSheetScope, - ZonedDateTime inferStartDttm, - ZonedDateTime inferEndDttm, - Integer stage, - String subUid) { + String analTitle, + String modelVer1, + String modelVer2, + String modelVer3, + Integer compareYyyy, + Integer targetYyyy, + String detectOption, + String mapSheetScope, + ZonedDateTime inferStartDttm, + ZonedDateTime inferEndDttm, + Integer stage, + String subUid) { this.analTitle = analTitle; this.modelVer1 = modelVer1; this.modelVer2 = modelVer2; @@ -471,9 +470,9 @@ public class InferenceDetailDto { this.stage = stage; this.subUid = subUid; Duration elapsed = - (inferStartDttm != null && inferEndDttm != null) - ? Duration.between(inferStartDttm, inferEndDttm) - : null; + (inferStartDttm != null && inferEndDttm != null) + ? Duration.between(inferStartDttm, inferEndDttm) + : null; if (elapsed != null) { long seconds = elapsed.getSeconds(); 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..00226db1 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 @@ -23,7 +23,9 @@ import org.springframework.data.domain.Pageable; public class InferenceResultDto { - /** 분석대상 도엽 enum */ + /** + * 분석대상 도엽 enum + */ @Getter @AllArgsConstructor public enum MapSheetScope implements EnumType { @@ -52,7 +54,9 @@ public class InferenceResultDto { } } - /** 탐지 데이터 옵션 dto */ + /** + * 탐지 데이터 옵션 dto + */ @Getter @AllArgsConstructor public enum DetectOption implements EnumType { @@ -129,7 +133,9 @@ public class InferenceResultDto { } } - /** 목록조회 dto */ + /** + * 목록조회 dto + */ @Schema(name = "ResultList", description = "추론관리 목록") @Getter @Setter @@ -178,6 +184,12 @@ public class InferenceResultDto { @Schema(description = "uid") private String uid; + @Schema(description = "uid 앞 8자리") + @JsonProperty("subUid") + public String subUid() { + return this.uid.substring(0, 8).toUpperCase(); + } + @Schema(description = "상태명") @JsonProperty("statusName") public String statusName() { @@ -207,7 +219,9 @@ public class InferenceResultDto { } } - /** 목록조회 검색 조건 dto */ + /** + * 목록조회 검색 조건 dto + */ @Getter @Setter @NoArgsConstructor @@ -229,7 +243,9 @@ public class InferenceResultDto { } } - /** 변화탐지 실행 정보 저장 요청 정보 */ + /** + * 변화탐지 실행 정보 저장 요청 정보 + */ @Getter @Setter @NoArgsConstructor @@ -268,8 +284,8 @@ public class InferenceResultDto { @Schema(description = "탐지 데이터 옵션 - 추론제외(EXCL), 이전 년도 도엽 사용(PREV)", example = "EXCL") @NotBlank @EnumValid( - enumClass = DetectOption.class, - message = "탐지 데이터 옵션은 '추론제외', '이전 년도 도엽 사용' 만 사용 가능합니다.") + enumClass = DetectOption.class, + message = "탐지 데이터 옵션은 '추론제외', '이전 년도 도엽 사용' 만 사용 가능합니다.") private String detectOption; @Schema(description = "5k 도협 번호 목록", example = "[33605,33606, 33610, 34802, 35603, 35611]") @@ -381,33 +397,33 @@ public class InferenceResultDto { private String modelVer3; public InferenceStatusDetailDto( - Long detectingCnt, - Integer m1PendingJobs, - Integer m2PendingJobs, - Integer m3PendingJobs, - Integer m1CompletedJobs, - Integer m2CompletedJobs, - Integer m3CompletedJobs, - Integer m1FailedJobs, - Integer m2FailedJobs, - Integer m3FailedJobs, - ZonedDateTime m1ModelStartDttm, - ZonedDateTime m2ModelStartDttm, - ZonedDateTime m3ModelStartDttm, - ZonedDateTime m1ModelEndDttm, - ZonedDateTime m2ModelEndDttm, - ZonedDateTime m3ModelEndDttm, - String title, - Integer compareYyyy, - Integer targetYyyy, - Integer stage, - ZonedDateTime inferStartDttm, - ZonedDateTime inferEndDttm, - String detectOption, - String mapSheetScope, - String modelVer1, - String modelVer2, - String modelVer3) { + Long detectingCnt, + Integer m1PendingJobs, + Integer m2PendingJobs, + Integer m3PendingJobs, + Integer m1CompletedJobs, + Integer m2CompletedJobs, + Integer m3CompletedJobs, + Integer m1FailedJobs, + Integer m2FailedJobs, + Integer m3FailedJobs, + ZonedDateTime m1ModelStartDttm, + ZonedDateTime m2ModelStartDttm, + ZonedDateTime m3ModelStartDttm, + ZonedDateTime m1ModelEndDttm, + ZonedDateTime m2ModelEndDttm, + ZonedDateTime m3ModelEndDttm, + String title, + Integer compareYyyy, + Integer targetYyyy, + Integer stage, + ZonedDateTime inferStartDttm, + ZonedDateTime inferEndDttm, + String detectOption, + String mapSheetScope, + String modelVer1, + String modelVer2, + String modelVer3) { this.detectingCnt = detectingCnt; this.m1PendingJobs = m1PendingJobs; this.m2PendingJobs = m2PendingJobs; @@ -443,12 +459,12 @@ public class InferenceResultDto { long tiles = this.detectingCnt; // 도엽수 int models = 3; // 모델 개수 int completed = - this.m1CompletedJobs - + this.m2CompletedJobs - + this.m3CompletedJobs - + this.m1FailedJobs - + this.m2FailedJobs - + this.m3FailedJobs; // 완료수 + this.m1CompletedJobs + + this.m2CompletedJobs + + this.m3CompletedJobs + + this.m1FailedJobs + + this.m2FailedJobs + + this.m3FailedJobs; // 완료수 long total = tiles * models; // 전체 작업량 if (completed >= total) { @@ -513,9 +529,12 @@ public class InferenceResultDto { public static class InferenceServerStatusDto { private String serverName; - @JsonIgnore private float cpu_user; - @JsonIgnore private float cpu_system; - @JsonIgnore private float memused; + @JsonIgnore + private float cpu_user; + @JsonIgnore + private float cpu_system; + @JsonIgnore + private float memused; private Long kbmemused; private float gpuUtil; diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/entity/MapSheetLearnEntity.java b/src/main/java/com/kamco/cd/kamcoback/postgres/entity/MapSheetLearnEntity.java index c3b85779..43f267fc 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/entity/MapSheetLearnEntity.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/entity/MapSheetLearnEntity.java @@ -25,9 +25,9 @@ public class MapSheetLearnEntity { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "tb_map_sheet_learn_id_gen") @SequenceGenerator( - name = "tb_map_sheet_learn_id_gen", - sequenceName = "tb_map_sheet_learn_uid", - allocationSize = 1) + name = "tb_map_sheet_learn_id_gen", + sequenceName = "tb_map_sheet_learn_uid", + allocationSize = 1) @Column(name = "id", nullable = false) private Long id; @@ -191,18 +191,18 @@ public class MapSheetLearnEntity { public InferenceResultDto.ResultList toDto() { return new InferenceResultDto.ResultList( - this.uuid, - this.title, - this.stage, - this.status, - this.mapSheetCnt, - this.detectingCnt, - this.inferStartDttm, - this.inferEndDttm, - this.applyYn, - this.applyDttm, - this.compareYyyy, - this.targetYyyy, - this.uid); + this.uuid, + this.title, + this.stage, + this.status, + this.mapSheetCnt, + this.detectingCnt, + this.inferStartDttm, + this.inferEndDttm, + this.applyYn, + this.applyDttm, + this.compareYyyy, + this.targetYyyy, + this.uid); } } diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/entity/PnuEntity.java b/src/main/java/com/kamco/cd/kamcoback/postgres/entity/PnuEntity.java new file mode 100644 index 00000000..a0af0aac --- /dev/null +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/entity/PnuEntity.java @@ -0,0 +1,51 @@ +package com.kamco.cd.kamcoback.postgres.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.SequenceGenerator; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import java.time.OffsetDateTime; +import lombok.Getter; +import lombok.Setter; +import org.hibernate.annotations.ColumnDefault; + +@Getter +@Setter +@Entity +@Table(name = "tb_pnu") +public class PnuEntity { + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "tb_pnu_id_gen") + @SequenceGenerator(name = "tb_pnu_id_gen", sequenceName = "tb_pnu_uid", allocationSize = 1) + @Column(name = "id", nullable = false) + private Long id; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn(name = "geo_uid", nullable = false) + private MapSheetAnalDataInferenceGeomEntity geo; + + @Size(max = 19) + @Column(name = "pnu", length = 19) + private String pnu; + + @Column(name = "created_dttm") + private OffsetDateTime createdDttm; + + @Column(name = "created_uid") + private Long createdUid; + + @ColumnDefault("false") + @Column(name = "del_yn") + private Boolean delYn; + +} diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearn5kRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearn5kRepositoryImpl.java index 78c1cd70..52b063c6 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearn5kRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/Inference/MapSheetLearn5kRepositoryImpl.java @@ -1,8 +1,10 @@ package com.kamco.cd.kamcoback.postgres.repository.Inference; +import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx50kEntity.mapInkx50kEntity; import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx5kEntity.mapInkx5kEntity; import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearn5kEntity.mapSheetLearn5kEntity; import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnEntity.mapSheetLearnEntity; +import static com.querydsl.jpa.JPAExpressions.select; import com.kamco.cd.kamcoback.scheduler.dto.JobStatusDto; import com.querydsl.core.BooleanBuilder; @@ -10,7 +12,6 @@ import com.querydsl.core.types.dsl.BooleanPath; import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.NumberPath; import com.querydsl.core.types.dsl.StringPath; -import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; import java.util.List; import java.util.UUID; @@ -55,22 +56,22 @@ public class MapSheetLearn5kRepositoryImpl implements MapSheetLearn5kRepositoryC } var learnIdSubQuery = - JPAExpressions.select(mapSheetLearnEntity.id) - .from(mapSheetLearnEntity) - .where(mapSheetLearnEntity.uuid.eq(uuid)); + select(mapSheetLearnEntity.id) + .from(mapSheetLearnEntity) + .where(mapSheetLearnEntity.uuid.eq(uuid)); queryFactory - .update(mapSheetLearn5kEntity) - .set(failPath, Boolean.TRUE) - .set(jobIdPath, jobDto.getId()) - .set(errorMsgPath, jobDto.getErrorMessage()) - .where( - mapSheetLearn5kEntity - .learn - .id - .eq(learnIdSubQuery) - .and(mapSheetLearn5kEntity.mapSheetNum.eq(Long.valueOf(jobDto.getSceneId())))) - .execute(); + .update(mapSheetLearn5kEntity) + .set(failPath, Boolean.TRUE) + .set(jobIdPath, jobDto.getId()) + .set(errorMsgPath, jobDto.getErrorMessage()) + .where( + mapSheetLearn5kEntity + .learn + .id + .eq(learnIdSubQuery) + .and(mapSheetLearn5kEntity.mapSheetNum.eq(Long.valueOf(jobDto.getSceneId())))) + .execute(); } @Override @@ -102,21 +103,21 @@ public class MapSheetLearn5kRepositoryImpl implements MapSheetLearn5kRepositoryC } var learnIdSubQuery = - JPAExpressions.select(mapSheetLearnEntity.id) - .from(mapSheetLearnEntity) - .where(mapSheetLearnEntity.uuid.eq(uuid)); + select(mapSheetLearnEntity.id) + .from(mapSheetLearnEntity) + .where(mapSheetLearnEntity.uuid.eq(uuid)); queryFactory - .update(mapSheetLearn5kEntity) - .set(failPath, Boolean.FALSE) - .set(jobIdPath, jobDto.getId()) - .where( - mapSheetLearn5kEntity - .learn - .id - .eq(learnIdSubQuery) - .and(mapSheetLearn5kEntity.mapSheetNum.eq(Long.valueOf(jobDto.getSceneId())))) - .execute(); + .update(mapSheetLearn5kEntity) + .set(failPath, Boolean.FALSE) + .set(jobIdPath, jobDto.getId()) + .where( + mapSheetLearn5kEntity + .learn + .id + .eq(learnIdSubQuery) + .and(mapSheetLearn5kEntity.mapSheetNum.eq(Long.valueOf(jobDto.getSceneId())))) + .execute(); } @Override @@ -152,16 +153,16 @@ public class MapSheetLearn5kRepositoryImpl implements MapSheetLearn5kRepositoryC } return queryFactory - .select(jobIdPath) - .from(mapSheetLearn5kEntity) - .join(mapSheetLearn5kEntity.learn, mapSheetLearnEntity) - .where( - mapSheetLearnEntity - .uuid - .eq(uuid) - .and(failPath.isFalse().or(failPath.isNull())) - .and(jobIdPath.in(failIds))) - .fetch(); + .select(jobIdPath) + .from(mapSheetLearn5kEntity) + .join(mapSheetLearn5kEntity.learn, mapSheetLearnEntity) + .where( + mapSheetLearnEntity + .uuid + .eq(uuid) + .and(failPath.isFalse().or(failPath.isNull())) + .and(jobIdPath.in(failIds))) + .fetch(); } @Override @@ -194,31 +195,37 @@ public class MapSheetLearn5kRepositoryImpl implements MapSheetLearn5kRepositoryC } return queryFactory - .select(jobIdPath) - .from(mapSheetLearn5kEntity) - .join(mapSheetLearn5kEntity.learn, mapSheetLearnEntity) - .where(mapSheetLearnEntity.uuid.eq(uuid).and(jobIdPath.in(completedIds))) - .fetch(); + .select(jobIdPath) + .from(mapSheetLearn5kEntity) + .join(mapSheetLearn5kEntity.learn, mapSheetLearnEntity) + .where(mapSheetLearnEntity.uuid.eq(uuid).and(jobIdPath.in(completedIds))) + .fetch(); } + /** + * 추론 진행 도엽 목록 + * + * @param uuid uuid + * @return + */ @Override public List getInferenceRunMapId(UUID uuid) { return queryFactory - .select(mapInkx5kEntity.mapidNm) - .from(mapSheetLearnEntity) - .innerJoin(mapSheetLearn5kEntity) - .on(mapSheetLearn5kEntity.learn.id.eq(mapSheetLearnEntity.id)) - .innerJoin(mapInkx5kEntity) - .on( - Expressions.booleanTemplate( - "function('regexp_match', {0}, '^[0-9]+$') is not null", - mapInkx5kEntity.mapidcdNo) - .and( - mapSheetLearn5kEntity.mapSheetNum.eq( - Expressions.numberTemplate( - Long.class, "cast({0} as long)", mapInkx5kEntity.mapidcdNo)))) - .where(mapSheetLearnEntity.uuid.eq(uuid)) - .groupBy(mapInkx5kEntity.mapidNm) - .fetch(); + .select(mapInkx50kEntity.mapidNm.concat(mapInkx50kEntity.mapidcdNo)) + .from(mapInkx50kEntity) + .join(mapInkx5kEntity).on(mapInkx5kEntity.mapInkx50k.fid.eq(mapInkx50kEntity.fid)) + .where( + mapInkx5kEntity.mapidcdNo.in( + select( + Expressions.stringTemplate("CAST({0} AS text)", mapSheetLearn5kEntity.mapSheetNum) + ) + .from(mapSheetLearnEntity) + .join(mapSheetLearn5kEntity).on(mapSheetLearn5kEntity.learn.id.eq(mapSheetLearnEntity.id)) + .where(mapSheetLearnEntity.uuid.eq(uuid)) + ) + ) + .groupBy(mapInkx50kEntity.mapidcdNo, mapInkx50kEntity.mapidNm) + .orderBy(mapInkx50kEntity.mapidNm.asc()) + .fetch(); } } 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..63860784 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 @@ -7,6 +7,7 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceG import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity; import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalSttcEntity.mapSheetAnalSttcEntity; import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnEntity.mapSheetLearnEntity; +import static com.kamco.cd.kamcoback.postgres.entity.QPnuEntity.pnuEntity; import static com.kamco.cd.kamcoback.postgres.entity.QSystemMetricEntity.systemMetricEntity; import com.kamco.cd.kamcoback.common.exception.CustomApiException; @@ -28,6 +29,8 @@ import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.CaseBuilder; import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.NumberExpression; +import com.querydsl.core.types.dsl.StringExpression; +import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; import java.time.OffsetDateTime; import java.util.List; @@ -55,7 +58,7 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto BooleanBuilder builder = new BooleanBuilder(); NumberExpression statusOrder = - new CaseBuilder().when(mapSheetLearnEntity.status.eq("Y")).then(0).otherwise(1); + new CaseBuilder().when(mapSheetLearnEntity.status.eq("Y")).then(0).otherwise(1); // 국유인 반영 여부 if (StringUtils.isNotBlank(req.getApplyYn())) { @@ -69,10 +72,10 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto // 국유인 반영일 if (req.getStrtDttm() != null && req.getEndDttm() != null) { builder.and( - mapSheetLearnEntity - .applyDttm - .goe(DateRange.start(req.getStrtDttm())) - .and(mapSheetLearnEntity.applyDttm.lt(DateRange.end(req.getEndDttm())))); + mapSheetLearnEntity + .applyDttm + .goe(DateRange.start(req.getStrtDttm())) + .and(mapSheetLearnEntity.applyDttm.lt(DateRange.end(req.getEndDttm())))); } // 제목 @@ -81,21 +84,21 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto } List content = - queryFactory - .select(mapSheetLearnEntity) - .from(mapSheetLearnEntity) - .where(builder) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .orderBy(mapSheetLearnEntity.id.desc()) - .fetch(); + queryFactory + .select(mapSheetLearnEntity) + .from(mapSheetLearnEntity) + .where(builder) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .orderBy(mapSheetLearnEntity.id.desc()) + .fetch(); Long total = - queryFactory - .select(mapSheetLearnEntity.count()) - .from(mapSheetLearnEntity) - .where(builder) - .fetchOne(); + queryFactory + .select(mapSheetLearnEntity.count()) + .from(mapSheetLearnEntity) + .where(builder) + .fetchOne(); return new PageImpl<>(content, pageable, total == null ? 0L : total); } @@ -103,10 +106,10 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto @Override public Optional getInferenceResultByUuid(UUID uuid) { return Optional.ofNullable( - queryFactory - .selectFrom(mapSheetLearnEntity) - .where(mapSheetLearnEntity.uuid.eq(uuid)) - .fetchOne()); + queryFactory + .selectFrom(mapSheetLearnEntity) + .where(mapSheetLearnEntity.uuid.eq(uuid)) + .fetchOne()); } @Override @@ -115,44 +118,44 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto BooleanBuilder builder = new BooleanBuilder(); List latestIds = - queryFactory - .select(systemMetricEntity.timestamp.max()) - .from(systemMetricEntity) - .groupBy(systemMetricEntity.serverName) - .fetch(); + queryFactory + .select(systemMetricEntity.timestamp.max()) + .from(systemMetricEntity) + .groupBy(systemMetricEntity.serverName) + .fetch(); List latestGpuIds = - queryFactory - .select(gpuMetricEntity.timestamp.max()) - .from(gpuMetricEntity) - .groupBy(gpuMetricEntity.serverName) - .fetch(); + queryFactory + .select(gpuMetricEntity.timestamp.max()) + .from(gpuMetricEntity) + .groupBy(gpuMetricEntity.serverName) + .fetch(); List foundContent = - queryFactory - .select( - Projections.constructor( - InferenceServerStatusDto.class, - systemMetricEntity.serverName, - systemMetricEntity.cpuUser, - systemMetricEntity.cpuSystem, - systemMetricEntity.memused, - systemMetricEntity.kbmemused, - gpuMetricEntity.gpuUtil - // gpuMetricEntity.gpuMemUsed, - // gpuMetricEntity.gpuMemTotal - )) - .from(systemMetricEntity) - .leftJoin(gpuMetricEntity) - .on( - gpuMetricEntity - .timestamp - .in(latestGpuIds) - .and(gpuMetricEntity.serverName.eq(systemMetricEntity.serverName))) - .where(systemMetricEntity.timestamp.in(latestIds)) // In 절 사용 - .orderBy(systemMetricEntity.serverName.asc()) - .limit(4) - .fetch(); + queryFactory + .select( + Projections.constructor( + InferenceServerStatusDto.class, + systemMetricEntity.serverName, + systemMetricEntity.cpuUser, + systemMetricEntity.cpuSystem, + systemMetricEntity.memused, + systemMetricEntity.kbmemused, + gpuMetricEntity.gpuUtil + // gpuMetricEntity.gpuMemUsed, + // gpuMetricEntity.gpuMemTotal + )) + .from(systemMetricEntity) + .leftJoin(gpuMetricEntity) + .on( + gpuMetricEntity + .timestamp + .in(latestGpuIds) + .and(gpuMetricEntity.serverName.eq(systemMetricEntity.serverName))) + .where(systemMetricEntity.timestamp.in(latestIds)) // In 절 사용 + .orderBy(systemMetricEntity.serverName.asc()) + .limit(4) + .fetch(); return foundContent; } @@ -160,11 +163,11 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto @Override public Optional getInferenceResultByStatus(String status) { return Optional.ofNullable( - queryFactory - .selectFrom(mapSheetLearnEntity) - .where(mapSheetLearnEntity.status.eq(status)) - .limit(1) - .fetchOne()); + queryFactory + .selectFrom(mapSheetLearnEntity) + .where(mapSheetLearnEntity.status.eq(status)) + .limit(1) + .fetchOne()); } /** @@ -183,46 +186,46 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto QModelMngEntity m3Model = new QModelMngEntity("m3Model"); InferenceStatusDetailDto foundContent = - queryFactory - .select( - Projections.constructor( - InferenceStatusDetailDto.class, - mapSheetLearnEntity.detectingCnt, - mapSheetLearnEntity.m1PendingJobs, - mapSheetLearnEntity.m2PendingJobs, - mapSheetLearnEntity.m3PendingJobs, - mapSheetLearnEntity.m1CompletedJobs, - mapSheetLearnEntity.m2CompletedJobs, - mapSheetLearnEntity.m3CompletedJobs, - mapSheetLearnEntity.m1FailedJobs, - mapSheetLearnEntity.m2FailedJobs, - mapSheetLearnEntity.m3FailedJobs, - mapSheetLearnEntity.m1ModelStartDttm, - mapSheetLearnEntity.m2ModelStartDttm, - mapSheetLearnEntity.m3ModelStartDttm, - mapSheetLearnEntity.m1ModelEndDttm, - mapSheetLearnEntity.m2ModelEndDttm, - mapSheetLearnEntity.m3ModelEndDttm, - mapSheetLearnEntity.title, - mapSheetLearnEntity.compareYyyy, - mapSheetLearnEntity.targetYyyy, - mapSheetLearnEntity.stage, - mapSheetLearnEntity.inferStartDttm, - mapSheetLearnEntity.inferEndDttm, - mapSheetLearnEntity.detectOption, - mapSheetLearnEntity.mapSheetScope, - m1Model.modelVer.as("model1Ver"), - m2Model.modelVer.as("model2Ver"), - m3Model.modelVer.as("model3Ver"))) - .from(mapSheetLearnEntity) - .leftJoin(m1Model) - .on(m1Model.uuid.eq(mapSheetLearnEntity.m1ModelUuid)) - .leftJoin(m2Model) - .on(m2Model.uuid.eq(mapSheetLearnEntity.m2ModelUuid)) - .leftJoin(m3Model) - .on(m3Model.uuid.eq(mapSheetLearnEntity.m3ModelUuid)) - .where(mapSheetLearnEntity.uuid.eq(uuid)) - .fetchOne(); + queryFactory + .select( + Projections.constructor( + InferenceStatusDetailDto.class, + mapSheetLearnEntity.detectingCnt, + mapSheetLearnEntity.m1PendingJobs, + mapSheetLearnEntity.m2PendingJobs, + mapSheetLearnEntity.m3PendingJobs, + mapSheetLearnEntity.m1CompletedJobs, + mapSheetLearnEntity.m2CompletedJobs, + mapSheetLearnEntity.m3CompletedJobs, + mapSheetLearnEntity.m1FailedJobs, + mapSheetLearnEntity.m2FailedJobs, + mapSheetLearnEntity.m3FailedJobs, + mapSheetLearnEntity.m1ModelStartDttm, + mapSheetLearnEntity.m2ModelStartDttm, + mapSheetLearnEntity.m3ModelStartDttm, + mapSheetLearnEntity.m1ModelEndDttm, + mapSheetLearnEntity.m2ModelEndDttm, + mapSheetLearnEntity.m3ModelEndDttm, + mapSheetLearnEntity.title, + mapSheetLearnEntity.compareYyyy, + mapSheetLearnEntity.targetYyyy, + mapSheetLearnEntity.stage, + mapSheetLearnEntity.inferStartDttm, + mapSheetLearnEntity.inferEndDttm, + mapSheetLearnEntity.detectOption, + mapSheetLearnEntity.mapSheetScope, + m1Model.modelVer.as("model1Ver"), + m2Model.modelVer.as("model2Ver"), + m3Model.modelVer.as("model3Ver"))) + .from(mapSheetLearnEntity) + .leftJoin(m1Model) + .on(m1Model.uuid.eq(mapSheetLearnEntity.m1ModelUuid)) + .leftJoin(m2Model) + .on(m2Model.uuid.eq(mapSheetLearnEntity.m2ModelUuid)) + .leftJoin(m3Model) + .on(m3Model.uuid.eq(mapSheetLearnEntity.m3ModelUuid)) + .where(mapSheetLearnEntity.uuid.eq(uuid)) + .fetchOne(); return foundContent; } @@ -233,30 +236,30 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto QModelMngEntity model = new QModelMngEntity("model"); InferenceProgressDto dto = - queryFactory - .select( - Projections.constructor( - InferenceProgressDto.class, - Projections.constructor( - InferenceProgressDto.pred_requests_areas.class, - mapSheetLearnEntity.compareYyyy, - mapSheetLearnEntity.targetYyyy, - mapSheetLearnEntity.modelComparePath, - mapSheetLearnEntity.modelTargetPath), - model.modelVer.as("modelVer"), - model.cdModelPath.as("cdModelPath"), - model.cdModelFileName.as("cdModelFileName"), - model.cdModelConfigPath.as("cdModelConfigPath"), - model.cdModelConfigFileName.as("cdModelConfigFileName"), - model.clsModelPath, - model.clsModelFileName, - model.clsModelVersion, - model.priority)) - .from(mapSheetLearnEntity) - .join(model) - .on(model.uuid.eq(modelUuid)) - .where(mapSheetLearnEntity.id.eq(id)) - .fetchOne(); + queryFactory + .select( + Projections.constructor( + InferenceProgressDto.class, + Projections.constructor( + InferenceProgressDto.pred_requests_areas.class, + mapSheetLearnEntity.compareYyyy, + mapSheetLearnEntity.targetYyyy, + mapSheetLearnEntity.modelComparePath, + mapSheetLearnEntity.modelTargetPath), + model.modelVer.as("modelVer"), + model.cdModelPath.as("cdModelPath"), + model.cdModelFileName.as("cdModelFileName"), + model.cdModelConfigPath.as("cdModelConfigPath"), + model.cdModelConfigFileName.as("cdModelConfigFileName"), + model.clsModelPath, + model.clsModelFileName, + model.clsModelVersion, + model.priority)) + .from(mapSheetLearnEntity) + .join(model) + .on(model.uuid.eq(modelUuid)) + .where(mapSheetLearnEntity.id.eq(id)) + .fetchOne(); return dto; } @@ -267,26 +270,26 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto */ public MapSheetLearnEntity getProcessing() { return queryFactory - .select(mapSheetLearnEntity) - .from(mapSheetLearnEntity) - .where(mapSheetLearnEntity.status.eq("IN_PROGRESS")) - .fetchOne(); + .select(mapSheetLearnEntity) + .from(mapSheetLearnEntity) + .where(mapSheetLearnEntity.status.eq("IN_PROGRESS")) + .fetchOne(); } @Override public Integer getLearnStage(Integer compareYear, Integer targetYear) { Integer stage = - queryFactory - .select(mapSheetLearnEntity.stage) - .from(mapSheetLearnEntity) - .where( - mapSheetLearnEntity - .compareYyyy - .eq(compareYear) - .and(mapSheetLearnEntity.targetYyyy.eq(targetYear))) - .orderBy(mapSheetLearnEntity.id.desc()) - .limit(1) - .fetchOne(); + queryFactory + .select(mapSheetLearnEntity.stage) + .from(mapSheetLearnEntity) + .where( + mapSheetLearnEntity + .compareYyyy + .eq(compareYear) + .and(mapSheetLearnEntity.targetYyyy.eq(targetYear))) + .orderBy(mapSheetLearnEntity.id.desc()) + .limit(1) + .fetchOne(); return stage == null ? 1 : stage + 1; } @@ -298,30 +301,30 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto QModelMngEntity m3 = new QModelMngEntity("m3"); return queryFactory - .select( - Projections.constructor( - AnalResultInfo.class, - mapSheetLearnEntity.title, - m1.modelVer, - m2.modelVer, - m3.modelVer, - mapSheetLearnEntity.compareYyyy, - mapSheetLearnEntity.targetYyyy, - mapSheetLearnEntity.detectOption, - mapSheetLearnEntity.mapSheetScope, - mapSheetLearnEntity.inferStartDttm, - mapSheetLearnEntity.inferEndDttm, - mapSheetLearnEntity.stage, - Expressions.stringTemplate("substring({0} from 1 for 8)", mapSheetLearnEntity.uid))) - .from(mapSheetLearnEntity) - .leftJoin(m1) - .on(mapSheetLearnEntity.m1ModelUuid.eq(m1.uuid)) - .leftJoin(m2) - .on(mapSheetLearnEntity.m2ModelUuid.eq(m2.uuid)) - .leftJoin(m3) - .on(mapSheetLearnEntity.m3ModelUuid.eq(m3.uuid)) - .where(mapSheetLearnEntity.uuid.eq(uuid)) - .fetchOne(); + .select( + Projections.constructor( + AnalResultInfo.class, + mapSheetLearnEntity.title, + m1.modelVer, + m2.modelVer, + m3.modelVer, + mapSheetLearnEntity.compareYyyy, + mapSheetLearnEntity.targetYyyy, + mapSheetLearnEntity.detectOption, + mapSheetLearnEntity.mapSheetScope, + mapSheetLearnEntity.inferStartDttm, + mapSheetLearnEntity.inferEndDttm, + mapSheetLearnEntity.stage, + Expressions.stringTemplate("substring({0} from 1 for 8)", mapSheetLearnEntity.uid))) + .from(mapSheetLearnEntity) + .leftJoin(m1) + .on(mapSheetLearnEntity.m1ModelUuid.eq(m1.uuid)) + .leftJoin(m2) + .on(mapSheetLearnEntity.m2ModelUuid.eq(m2.uuid)) + .leftJoin(m3) + .on(mapSheetLearnEntity.m3ModelUuid.eq(m3.uuid)) + .where(mapSheetLearnEntity.uuid.eq(uuid)) + .fetchOne(); } @Override @@ -329,28 +332,28 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto // analUid로 분석 정보 조회 MapSheetLearnEntity learnEntity = - queryFactory - .selectFrom(mapSheetLearnEntity) - .where(mapSheetLearnEntity.uuid.eq(uuid)) - .fetchOne(); + queryFactory + .selectFrom(mapSheetLearnEntity) + .where(mapSheetLearnEntity.uuid.eq(uuid)) + .fetchOne(); if (Objects.isNull(learnEntity)) { throw new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND); } return queryFactory - .select( - Projections.constructor( - Dashboard.class, - mapSheetAnalSttcEntity.id.classAfterCd.toUpperCase(), - mapSheetAnalSttcEntity.classAfterCnt.sum())) - .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(); + .select( + Projections.constructor( + Dashboard.class, + mapSheetAnalSttcEntity.id.classAfterCd.toUpperCase(), + mapSheetAnalSttcEntity.classAfterCnt.sum())) + .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(); } /** @@ -366,10 +369,10 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto // 1) 분석 엔티티 조회 MapSheetLearnEntity analEntity = - queryFactory - .selectFrom(mapSheetLearnEntity) - .where(mapSheetLearnEntity.uuid.eq(uuid)) - .fetchOne(); + queryFactory + .selectFrom(mapSheetLearnEntity) + .where(mapSheetLearnEntity.uuid.eq(uuid)) + .fetchOne(); if (analEntity == null) { throw new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND); @@ -380,22 +383,22 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto if (searchGeoReq.getTargetClass() != null && !searchGeoReq.getTargetClass().isBlank()) { where.and( - mapSheetAnalDataInferenceGeomEntity.classAfterCd.eq( - searchGeoReq.getTargetClass().toLowerCase())); + mapSheetAnalDataInferenceGeomEntity.classAfterCd.eq( + searchGeoReq.getTargetClass().toLowerCase())); } if (searchGeoReq.getCompareClass() != null && !searchGeoReq.getCompareClass().isBlank()) { where.and( - mapSheetAnalDataInferenceGeomEntity.classBeforeCd.eq( - searchGeoReq.getCompareClass().toLowerCase())); + mapSheetAnalDataInferenceGeomEntity.classBeforeCd.eq( + searchGeoReq.getCompareClass().toLowerCase())); } if (searchGeoReq.getMapSheetNum() != null) { // // where.and(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.eq(searchGeoReq.getMapSheetNum())); where.and( - mapSheetAnalDataInferenceGeomEntity.mapSheetNum.like( - "%" + searchGeoReq.getMapSheetNum() + "%")); + mapSheetAnalDataInferenceGeomEntity.mapSheetNum.like( + "%" + searchGeoReq.getMapSheetNum() + "%")); } where.and(mapSheetAnalDataInferenceGeomEntity.classAfterCd.isNotNull()); @@ -405,56 +408,66 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto // 3) inkx 조인 조건: JPQL/HQL에서 '~' 불가 → function('regexp_match', ...) 사용 BooleanExpression inkxIsNumeric = - Expressions.booleanTemplate( - "function('regexp_match', {0}, '^[0-9]+$') is not null", mapInkx5kEntity.mapidcdNo); + Expressions.booleanTemplate( + "function('regexp_match', {0}, '^[0-9]+$') is not null", mapInkx5kEntity.mapidcdNo); NumberExpression inkxNoAsLong = - Expressions.numberTemplate(Long.class, "cast({0} as long)", mapInkx5kEntity.mapidcdNo); + Expressions.numberTemplate(Long.class, "cast({0} as long)", mapInkx5kEntity.mapidcdNo); + + StringExpression pnu = + Expressions.stringTemplate( + "coalesce(({0}), '')", + JPAExpressions + .select(Expressions.stringTemplate("string_agg({0}, ',')", pnuEntity.pnu)) + .from(pnuEntity) + .where(pnuEntity.geo.geoUid.eq(mapSheetAnalDataInferenceGeomEntity.geoUid)) + ); // 4) content List content = - queryFactory - .select( - Projections.constructor( - Geom.class, - mapSheetAnalDataInferenceGeomEntity.uuid, - mapSheetAnalDataInferenceGeomEntity.resultUid, - mapSheetAnalDataInferenceGeomEntity.compareYyyy, - mapSheetAnalDataInferenceGeomEntity.targetYyyy, - mapSheetAnalDataInferenceGeomEntity.cdProb, - mapSheetAnalDataInferenceGeomEntity.classBeforeCd, - mapSheetAnalDataInferenceGeomEntity.classBeforeProb, - mapSheetAnalDataInferenceGeomEntity.classAfterCd, - mapSheetAnalDataInferenceGeomEntity.classAfterProb, - mapSheetAnalDataInferenceGeomEntity.mapSheetNum, - mapInkx5kEntity.mapidNm, - Expressions.stringTemplate( - "substring({0} from 1 for 8)", - mapSheetAnalDataInferenceGeomEntity.resultUid))) - .from(mapSheetAnalInferenceEntity) - .join(mapSheetAnalDataInferenceEntity) - .on(mapSheetAnalDataInferenceEntity.analUid.eq(mapSheetAnalInferenceEntity.id)) - .join(mapSheetAnalDataInferenceGeomEntity) - .on(mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id)) - .join(mapInkx5kEntity) - .on(inkxIsNumeric.and(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.eq(inkxNoAsLong))) - .where(where) - .orderBy(mapSheetAnalDataInferenceGeomEntity.geoUid.desc()) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + queryFactory + .select( + Projections.constructor( + Geom.class, + mapSheetAnalDataInferenceGeomEntity.uuid, + mapSheetAnalDataInferenceGeomEntity.resultUid, + mapSheetAnalDataInferenceGeomEntity.compareYyyy, + mapSheetAnalDataInferenceGeomEntity.targetYyyy, + mapSheetAnalDataInferenceGeomEntity.cdProb, + mapSheetAnalDataInferenceGeomEntity.classBeforeCd, + mapSheetAnalDataInferenceGeomEntity.classBeforeProb, + mapSheetAnalDataInferenceGeomEntity.classAfterCd, + mapSheetAnalDataInferenceGeomEntity.classAfterProb, + mapSheetAnalDataInferenceGeomEntity.mapSheetNum, + mapInkx5kEntity.mapidNm, + Expressions.stringTemplate( + "substring({0} from 1 for 8)", + mapSheetAnalDataInferenceGeomEntity.resultUid + ), pnu)) + .from(mapSheetAnalInferenceEntity) + .join(mapSheetAnalDataInferenceEntity) + .on(mapSheetAnalDataInferenceEntity.analUid.eq(mapSheetAnalInferenceEntity.id)) + .join(mapSheetAnalDataInferenceGeomEntity) + .on(mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id)) + .join(mapInkx5kEntity) + .on(inkxIsNumeric.and(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.eq(inkxNoAsLong))) + .where(where) + .orderBy(mapSheetAnalDataInferenceGeomEntity.geoUid.desc()) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); // 5) total (조인 최소화 유지) Long total = - queryFactory - .select(mapSheetAnalDataInferenceGeomEntity.geoUid.count()) - .from(mapSheetAnalInferenceEntity) - .join(mapSheetAnalDataInferenceEntity) - .on(mapSheetAnalDataInferenceEntity.analUid.eq(mapSheetAnalInferenceEntity.id)) - .join(mapSheetAnalDataInferenceGeomEntity) - .on(mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id)) - .where(where) - .fetchOne(); + queryFactory + .select(mapSheetAnalDataInferenceGeomEntity.geoUid.count()) + .from(mapSheetAnalInferenceEntity) + .join(mapSheetAnalDataInferenceEntity) + .on(mapSheetAnalDataInferenceEntity.analUid.eq(mapSheetAnalInferenceEntity.id)) + .join(mapSheetAnalDataInferenceGeomEntity) + .on(mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id)) + .where(where) + .fetchOne(); return new PageImpl<>(content, pageable, total == null ? 0L : total); }