sttc 엔티티 수정

This commit is contained in:
2025-11-28 12:01:43 +09:00
parent 7ee3afb8f0
commit c13cd3661b
6 changed files with 192 additions and 188 deletions

View File

@@ -2,7 +2,6 @@ package com.kamco.cd.kamcoback.postgres.core;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto; import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.Dashboard; import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.Dashboard;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalSttcEntity;
import com.kamco.cd.kamcoback.postgres.repository.Inference.InferenceResultRepository; import com.kamco.cd.kamcoback.postgres.repository.Inference.InferenceResultRepository;
import jakarta.persistence.EntityNotFoundException; import jakarta.persistence.EntityNotFoundException;
import java.util.List; import java.util.List;
@@ -23,7 +22,7 @@ public class InferenceResultCoreService {
* @return * @return
*/ */
public Page<InferenceResultDto.AnalResList> getInferenceResultList( public Page<InferenceResultDto.AnalResList> getInferenceResultList(
InferenceResultDto.SearchReq searchReq) { InferenceResultDto.SearchReq searchReq) {
return inferenceResultRepository.getInferenceResultList(searchReq); return inferenceResultRepository.getInferenceResultList(searchReq);
} }
@@ -35,9 +34,9 @@ public class InferenceResultCoreService {
*/ */
public InferenceResultDto.AnalResSummary getInferenceResultSummary(Long id) { public InferenceResultDto.AnalResSummary getInferenceResultSummary(Long id) {
InferenceResultDto.AnalResSummary summary = InferenceResultDto.AnalResSummary summary =
inferenceResultRepository inferenceResultRepository
.getInferenceResultSummary(id) .getInferenceResultSummary(id)
.orElseThrow(() -> new EntityNotFoundException("요약정보를 찾을 수 없습니다. " + id)); .orElseThrow(() -> new EntityNotFoundException("요약정보를 찾을 수 없습니다. " + id));
return summary; return summary;
} }
@@ -48,9 +47,10 @@ public class InferenceResultCoreService {
* @return * @return
*/ */
public List<Dashboard> getInferenceResultDashboard(Long id) { public List<Dashboard> getInferenceResultDashboard(Long id) {
return inferenceResultRepository.getInferenceResultDashboard(id).stream() return null;
.map(MapSheetAnalSttcEntity::toDto) // inferenceResultRepository.getInferenceResultDashboard(id).stream()
.toList(); // .map(MapSheetAnalSttcEntity::toDto)
// .toList();
} }
/** /**
@@ -60,7 +60,12 @@ public class InferenceResultCoreService {
* @return * @return
*/ */
public Page<InferenceResultDto.Geom> getInferenceResultGeomList( public Page<InferenceResultDto.Geom> getInferenceResultGeomList(
InferenceResultDto.SearchGeoReq searchGeoReq) { InferenceResultDto.SearchGeoReq searchGeoReq) {
return inferenceResultRepository.getInferenceGeomList(searchGeoReq); return inferenceResultRepository.getInferenceGeomList(searchGeoReq);
} }
//
// public List<Long> getSheets(
// return inferenceResultRepository.get
//
// }
} }

View File

@@ -1,12 +1,12 @@
package com.kamco.cd.kamcoback.postgres.entity; package com.kamco.cd.kamcoback.postgres.entity;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.EmbeddedId; import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.time.ZonedDateTime; import jakarta.validation.constraints.Size;
import java.time.OffsetDateTime;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
@@ -17,26 +17,29 @@ import org.hibernate.annotations.ColumnDefault;
@Table(name = "tb_map_sheet_anal_sttc") @Table(name = "tb_map_sheet_anal_sttc")
public class MapSheetAnalSttcEntity { public class MapSheetAnalSttcEntity {
@EmbeddedId private MapSheetAnalSttcEntityId id; @EmbeddedId
private MapSheetAnalSttcEntityId id;
@ColumnDefault("0")
@Column(name = "class_before_cnt") @Column(name = "class_before_cnt")
private Long classBeforeCnt; private Long classBeforeCnt;
@ColumnDefault("0")
@Column(name = "class_after_cnt") @Column(name = "class_after_cnt")
private Long classAfterCnt; private Long classAfterCnt;
@ColumnDefault("now()") @ColumnDefault("now()")
@Column(name = "created_dttm") @Column(name = "created_dttm")
private ZonedDateTime createdDttm; private OffsetDateTime createdDttm;
@Column(name = "created_uid") @Column(name = "created_uid")
private Long createdUid; private Long createdUid;
@ColumnDefault("now()") @ColumnDefault("now()")
@Column(name = "updated_dttm") @Column(name = "updated_dttm")
private ZonedDateTime updatedDttm; private OffsetDateTime updatedDttm;
@Column(name = "updated_uid", length = Integer.MAX_VALUE) @Column(name = "updated_uid")
private Long updatedUid; private Long updatedUid;
@NotNull @NotNull
@@ -47,26 +50,12 @@ public class MapSheetAnalSttcEntity {
@Column(name = "data_uid", nullable = false) @Column(name = "data_uid", nullable = false)
private Long dataUid; private Long dataUid;
@Column(name = "class_before_cd") @Size(max = 30)
@Column(name = "class_before_cd", length = 30)
private String classBeforeCd; private String classBeforeCd;
@Column(name = "class_after_cd") @Size(max = 30)
@Column(name = "class_after_cd", length = 30)
private String classAfterCd; private String classAfterCd;
public InferenceResultDto.Dashboard toDto() {
return new InferenceResultDto.Dashboard(
id.getCompareYyyy(),
id.getTargetYyyy(),
id.getMapSheetNum(),
id.getClassBeforeName(),
id.getClassAfterName(),
this.classBeforeCnt,
this.classAfterCnt,
this.createdDttm,
this.createdUid,
this.updatedDttm,
this.updatedUid,
this.refMapSheetNum,
this.dataUid);
}
} }

View File

@@ -3,7 +3,6 @@ package com.kamco.cd.kamcoback.postgres.entity;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Embeddable; import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
import lombok.Getter; import lombok.Getter;
@@ -15,8 +14,7 @@ import org.hibernate.Hibernate;
@Embeddable @Embeddable
public class MapSheetAnalSttcEntityId implements Serializable { public class MapSheetAnalSttcEntityId implements Serializable {
private static final long serialVersionUID = -8630519290255405042L; private static final long serialVersionUID = 2285491656408229553L;
@NotNull @NotNull
@Column(name = "compare_yyyy", nullable = false) @Column(name = "compare_yyyy", nullable = false)
private Integer compareYyyy; private Integer compareYyyy;
@@ -29,16 +27,6 @@ public class MapSheetAnalSttcEntityId implements Serializable {
@Column(name = "map_sheet_num", nullable = false) @Column(name = "map_sheet_num", nullable = false)
private Long mapSheetNum; private Long mapSheetNum;
@Size(max = 64)
@NotNull
@Column(name = "class_before_name", nullable = false, length = 64)
private String classBeforeName;
@Size(max = 64)
@NotNull
@Column(name = "class_after_name", nullable = false, length = 64)
private String classAfterName;
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) {
@@ -48,15 +36,14 @@ public class MapSheetAnalSttcEntityId implements Serializable {
return false; return false;
} }
MapSheetAnalSttcEntityId entity = (MapSheetAnalSttcEntityId) o; MapSheetAnalSttcEntityId entity = (MapSheetAnalSttcEntityId) o;
return Objects.equals(this.targetYyyy, entity.targetYyyy) return Objects.equals(this.targetYyyy, entity.targetYyyy) &&
&& Objects.equals(this.classBeforeName, entity.classBeforeName) Objects.equals(this.compareYyyy, entity.compareYyyy) &&
&& Objects.equals(this.classAfterName, entity.classAfterName) Objects.equals(this.mapSheetNum, entity.mapSheetNum);
&& Objects.equals(this.compareYyyy, entity.compareYyyy)
&& Objects.equals(this.mapSheetNum, entity.mapSheetNum);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(targetYyyy, classBeforeName, classAfterName, compareYyyy, mapSheetNum); return Objects.hash(targetYyyy, compareYyyy, mapSheetNum);
} }
} }

View File

@@ -7,12 +7,15 @@ import java.util.Optional;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
public interface InferenceResultRepositoryCustom { public interface InferenceResultRepositoryCustom {
Page<InferenceResultDto.AnalResList> getInferenceResultList( Page<InferenceResultDto.AnalResList> getInferenceResultList(
InferenceResultDto.SearchReq searchReq); InferenceResultDto.SearchReq searchReq);
Optional<InferenceResultDto.AnalResSummary> getInferenceResultSummary(Long id); Optional<InferenceResultDto.AnalResSummary> getInferenceResultSummary(Long id);
List<MapSheetAnalSttcEntity> getInferenceResultDashboard(Long id); List<MapSheetAnalSttcEntity> getInferenceResultDashboard(Long id);
Page<InferenceResultDto.Geom> getInferenceGeomList(InferenceResultDto.SearchGeoReq searchGeoReq); Page<InferenceResultDto.Geom> getInferenceGeomList(InferenceResultDto.SearchGeoReq searchGeoReq);
List<Long> getSheets(Long id);
} }

View File

@@ -3,6 +3,7 @@ package com.kamco.cd.kamcoback.postgres.repository.Inference;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto; import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.SearchGeoReq; import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.SearchGeoReq;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalSttcEntity; import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalSttcEntity;
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataEntity;
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataGeomEntity; import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataGeomEntity;
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalEntity; import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalEntity;
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalSttcEntity; import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalSttcEntity;
@@ -27,13 +28,14 @@ import org.springframework.stereotype.Repository;
public class InferenceResultRepositoryImpl implements InferenceResultRepositoryCustom { public class InferenceResultRepositoryImpl implements InferenceResultRepositoryCustom {
private final JPAQueryFactory queryFactory; private final JPAQueryFactory queryFactory;
private final QMapSheetAnalEntity mapSheetAnal = QMapSheetAnalEntity.mapSheetAnalEntity;
private final QModelMngEntity tmm = QModelMngEntity.modelMngEntity; private final QModelMngEntity tmm = QModelMngEntity.modelMngEntity;
private final QModelVerEntity tmv = QModelVerEntity.modelVerEntity; private final QModelVerEntity tmv = QModelVerEntity.modelVerEntity;
private final QMapSheetAnalEntity mapSheetAnal = QMapSheetAnalEntity.mapSheetAnalEntity;
private final QMapSheetAnalDataEntity mapSheetAnalEntity = QMapSheetAnalDataEntity.mapSheetAnalDataEntity;
private final QMapSheetAnalSttcEntity mapSheetAnalSttc = private final QMapSheetAnalSttcEntity mapSheetAnalSttc =
QMapSheetAnalSttcEntity.mapSheetAnalSttcEntity; QMapSheetAnalSttcEntity.mapSheetAnalSttcEntity;
private final QMapSheetAnalDataGeomEntity mapSheetAnalDataGeom = private final QMapSheetAnalDataGeomEntity mapSheetAnalDataGeom =
QMapSheetAnalDataGeomEntity.mapSheetAnalDataGeomEntity; QMapSheetAnalDataGeomEntity.mapSheetAnalDataGeomEntity;
/** /**
* 분석결과 목록 조회 * 분석결과 목록 조회
@@ -43,7 +45,7 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
*/ */
@Override @Override
public Page<InferenceResultDto.AnalResList> getInferenceResultList( public Page<InferenceResultDto.AnalResList> getInferenceResultList(
InferenceResultDto.SearchReq searchReq) { InferenceResultDto.SearchReq searchReq) {
Pageable pageable = searchReq.toPageable(); Pageable pageable = searchReq.toPageable();
// "0000" 전체조회 // "0000" 전체조회
BooleanBuilder builder = new BooleanBuilder(); BooleanBuilder builder = new BooleanBuilder();
@@ -57,31 +59,31 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
} }
List<InferenceResultDto.AnalResList> content = List<InferenceResultDto.AnalResList> content =
queryFactory queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
InferenceResultDto.AnalResList.class, InferenceResultDto.AnalResList.class,
mapSheetAnal.id, mapSheetAnal.id,
mapSheetAnal.analTitle, mapSheetAnal.analTitle,
mapSheetAnal.analMapSheet, mapSheetAnal.analMapSheet,
mapSheetAnal.detectingCnt, mapSheetAnal.detectingCnt,
mapSheetAnal.analStrtDttm, mapSheetAnal.analStrtDttm,
mapSheetAnal.analEndDttm, mapSheetAnal.analEndDttm,
mapSheetAnal.analSec, mapSheetAnal.analSec,
mapSheetAnal.analPredSec, mapSheetAnal.analPredSec,
mapSheetAnal.analState, mapSheetAnal.analState,
Expressions.stringTemplate( Expressions.stringTemplate(
"fn_code_name({0}, {1})", "0002", mapSheetAnal.analState), "fn_code_name({0}, {1})", "0002", mapSheetAnal.analState),
mapSheetAnal.gukyuinUsed)) mapSheetAnal.gukyuinUsed))
.from(mapSheetAnal) .from(mapSheetAnal)
.where(builder) .where(builder)
.offset(pageable.getOffset()) .offset(pageable.getOffset())
.limit(pageable.getPageSize()) .limit(pageable.getPageSize())
.orderBy(mapSheetAnal.createdDttm.desc()) .orderBy(mapSheetAnal.createdDttm.desc())
.fetch(); .fetch();
long total = long total =
queryFactory.select(mapSheetAnal.id).from(mapSheetAnal).where(builder).fetchCount(); queryFactory.select(mapSheetAnal.id).from(mapSheetAnal).where(builder).fetchCount();
return new PageImpl<>(content, pageable, total); return new PageImpl<>(content, pageable, total);
} }
@@ -97,37 +99,37 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
// 1. 최신 버전 UID를 가져오는 서브쿼리 // 1. 최신 버전 UID를 가져오는 서브쿼리
JPQLQuery<Long> latestVerUidSub = JPQLQuery<Long> 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<InferenceResultDto.AnalResSummary> content = Optional<InferenceResultDto.AnalResSummary> content =
Optional.ofNullable( Optional.ofNullable(
queryFactory queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
InferenceResultDto.AnalResSummary.class, InferenceResultDto.AnalResSummary.class,
mapSheetAnal.id, mapSheetAnal.id,
mapSheetAnal.analTitle, mapSheetAnal.analTitle,
tmm.modelNm.concat(" ").concat(tmv.modelVer).as("modelInfo"), tmm.modelNm.concat(" ").concat(tmv.modelVer).as("modelInfo"),
mapSheetAnal.targetYyyy, mapSheetAnal.targetYyyy,
mapSheetAnal.compareYyyy, mapSheetAnal.compareYyyy,
mapSheetAnal.analMapSheet, mapSheetAnal.analMapSheet,
mapSheetAnal.analStrtDttm, mapSheetAnal.analStrtDttm,
mapSheetAnal.analEndDttm, mapSheetAnal.analEndDttm,
mapSheetAnal.analSec, mapSheetAnal.analSec,
mapSheetAnal.analPredSec, mapSheetAnal.analPredSec,
mapSheetAnal.resultUrl, mapSheetAnal.resultUrl,
mapSheetAnal.detectingCnt, mapSheetAnal.detectingCnt,
mapSheetAnal.accuracy, mapSheetAnal.accuracy,
mapSheetAnal.analState, mapSheetAnal.analState,
Expressions.stringTemplate( Expressions.stringTemplate(
"fn_code_name({0}, {1})", "0002", mapSheetAnal.analState))) "fn_code_name({0}, {1})", "0002", mapSheetAnal.analState)))
.from(mapSheetAnal) .from(mapSheetAnal)
.leftJoin(tmm) .leftJoin(tmm)
.on(mapSheetAnal.modelUid.eq(tmm.id)) .on(mapSheetAnal.modelUid.eq(tmm.id))
.leftJoin(tmv) .leftJoin(tmv)
.on(tmv.modelUid.eq(tmm.id).and(tmv.id.eq(latestVerUidSub))) .on(tmv.modelUid.eq(tmm.id).and(tmv.id.eq(latestVerUidSub)))
.where(mapSheetAnal.id.eq(id)) .where(mapSheetAnal.id.eq(id))
.fetchOne()); .fetchOne());
return content; return content;
} }
@@ -140,10 +142,10 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
@Override @Override
public List<MapSheetAnalSttcEntity> getInferenceResultDashboard(Long id) { public List<MapSheetAnalSttcEntity> getInferenceResultDashboard(Long id) {
return queryFactory return queryFactory
.select(mapSheetAnalSttc) .select(mapSheetAnalSttc)
.from(mapSheetAnalSttc) .from(mapSheetAnalSttc)
.where(mapSheetAnalSttc.dataUid.eq(id)) .where(mapSheetAnalSttc.dataUid.eq(id))
.fetch(); .fetch();
} }
/** /**
@@ -174,32 +176,50 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
} }
List<InferenceResultDto.Geom> content = List<InferenceResultDto.Geom> content =
queryFactory queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
InferenceResultDto.Geom.class, InferenceResultDto.Geom.class,
mapSheetAnalDataGeom.compareYyyy, mapSheetAnalDataGeom.compareYyyy,
mapSheetAnalDataGeom.targetYyyy, mapSheetAnalDataGeom.targetYyyy,
mapSheetAnalDataGeom.classBeforeCd, mapSheetAnalDataGeom.classBeforeCd,
Expressions.stringTemplate( Expressions.stringTemplate(
"fn_code_name({0}, {1})", "0000", mapSheetAnalDataGeom.classBeforeCd), "fn_code_name({0}, {1})", "0000", mapSheetAnalDataGeom.classBeforeCd),
mapSheetAnalDataGeom.classBeforeProb, mapSheetAnalDataGeom.classBeforeProb,
mapSheetAnalDataGeom.classAfterCd, mapSheetAnalDataGeom.classAfterCd,
Expressions.stringTemplate( Expressions.stringTemplate(
"fn_code_name({0}, {1})", "0000", mapSheetAnalDataGeom.classAfterCd), "fn_code_name({0}, {1})", "0000", mapSheetAnalDataGeom.classAfterCd),
mapSheetAnalDataGeom.classAfterProb, mapSheetAnalDataGeom.classAfterProb,
mapSheetAnalDataGeom.mapSheetNum)) mapSheetAnalDataGeom.mapSheetNum))
.from(mapSheetAnalDataGeom) .from(mapSheetAnalDataGeom)
.where(builder) .where(builder)
.fetch(); .fetch();
long total = long total =
queryFactory queryFactory
.select(mapSheetAnalDataGeom.id) .select(mapSheetAnalDataGeom.id)
.from(mapSheetAnalDataGeom) .from(mapSheetAnalDataGeom)
.where(builder) .where(builder)
.fetchCount(); .fetchCount();
return new PageImpl<>(content, pageable, total); return new PageImpl<>(content, pageable, total);
} }
/**
* 추론된 5000:1 도엽 목록
*
* @param id
* @return
*/
@Override
public List<Long> getSheets(Long id) {
return queryFactory
.select(mapSheetAnalDataGeom.mapSheetNum)
.from(mapSheetAnal)
.join(mapSheetAnalEntity).on(mapSheetAnalEntity.analUid.eq(mapSheetAnal.id))
.join(mapSheetAnalDataGeom).on(mapSheetAnalDataGeom.dataUid.eq(mapSheetAnalEntity.id))
.where(mapSheetAnal.id.eq(id))
.groupBy(mapSheetAnalDataGeom.mapSheetNum)
.fetch();
}
} }

View File

@@ -18,7 +18,7 @@ import java.util.List;
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport; import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
implements ChangeDetectionRepositoryCustom { implements ChangeDetectionRepositoryCustom {
private final JPAQueryFactory queryFactory; private final JPAQueryFactory queryFactory;
@@ -36,75 +36,75 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
@Override @Override
public List<String> findPolygonJson() { public List<String> findPolygonJson() {
return queryFactory return queryFactory
.select(Expressions.stringTemplate("ST_AsGeoJSON({0})", mapSheetAnalDataGeomEntity.geom)) .select(Expressions.stringTemplate("ST_AsGeoJSON({0})", mapSheetAnalDataGeomEntity.geom))
.from(mapSheetAnalDataGeomEntity) .from(mapSheetAnalDataGeomEntity)
.orderBy(mapSheetAnalDataGeomEntity.id.desc()) .orderBy(mapSheetAnalDataGeomEntity.id.desc())
.fetch(); .fetch();
} }
@Override @Override
public List<ChangeDetectionDto.CountDto> getChangeDetectionClassCount(Long id) { public List<ChangeDetectionDto.CountDto> getChangeDetectionClassCount(Long id) {
return queryFactory return queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
ChangeDetectionDto.CountDto.class, ChangeDetectionDto.CountDto.class,
mapSheetAnalSttcEntity.classAfterCd.toUpperCase(), mapSheetAnalSttcEntity.classAfterCd.toUpperCase(),
mapSheetAnalSttcEntity.id.classAfterName, null, // TOOD classAfterName 삭제해서 수정 필요
mapSheetAnalSttcEntity.classAfterCnt.sum())) mapSheetAnalSttcEntity.classAfterCnt.sum()))
.from(mapSheetAnalEntity) .from(mapSheetAnalEntity)
.innerJoin(mapSheetAnalDataEntity) .innerJoin(mapSheetAnalDataEntity)
.on(mapSheetAnalDataEntity.analUid.eq(mapSheetAnalEntity.id)) .on(mapSheetAnalDataEntity.analUid.eq(mapSheetAnalEntity.id))
.innerJoin(mapSheetAnalSttcEntity) .innerJoin(mapSheetAnalSttcEntity)
.on(mapSheetAnalSttcEntity.dataUid.eq(mapSheetAnalDataEntity.id)) .on(mapSheetAnalSttcEntity.dataUid.eq(mapSheetAnalDataEntity.id))
.where(mapSheetAnalEntity.id.eq(id)) .where(mapSheetAnalEntity.id.eq(id))
.groupBy(mapSheetAnalSttcEntity.classAfterCd, mapSheetAnalSttcEntity.id.classAfterName) .groupBy(mapSheetAnalSttcEntity.classAfterCd)
.fetch(); .fetch();
} }
@Override @Override
public ChangeDetectionDto.CogUrlDto getChangeDetectionCogUrl(ChangeDetectionDto.CogUrlReq req) { public ChangeDetectionDto.CogUrlDto getChangeDetectionCogUrl(ChangeDetectionDto.CogUrlReq req) {
return queryFactory return queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
ChangeDetectionDto.CogUrlDto.class, ChangeDetectionDto.CogUrlDto.class,
makeCogUrl(req.getBeforeYear()).max().as("beforeCogUrl"), makeCogUrl(req.getBeforeYear()).max().as("beforeCogUrl"),
makeCogUrl(req.getAfterYear()).max().as("afterCogUrl"), makeCogUrl(req.getAfterYear()).max().as("afterCogUrl"),
mapInkx5kEntity.geom.as("bbox"))) mapInkx5kEntity.geom.as("bbox")))
.from(imageryEntity) .from(imageryEntity)
.innerJoin(mapInkx5kEntity) .innerJoin(mapInkx5kEntity)
.on(imageryEntity.scene5k.eq(mapInkx5kEntity.mapidcdNo)) .on(imageryEntity.scene5k.eq(mapInkx5kEntity.mapidcdNo))
.where( .where(
imageryEntity imageryEntity
.year .year
.eq(req.getBeforeYear()) .eq(req.getBeforeYear())
.or(imageryEntity.year.eq(req.getAfterYear())), .or(imageryEntity.year.eq(req.getAfterYear())),
imageryEntity.scene5k.eq(req.getMapSheetNum())) imageryEntity.scene5k.eq(req.getMapSheetNum()))
.groupBy(mapInkx5kEntity.geom) .groupBy(mapInkx5kEntity.geom)
.fetchOne(); .fetchOne();
} }
@Override @Override
public List<ChangeDetectionDto.AnalYearList> getChangeDetectionYearList() { public List<ChangeDetectionDto.AnalYearList> getChangeDetectionYearList() {
return queryFactory return queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
ChangeDetectionDto.AnalYearList.class, ChangeDetectionDto.AnalYearList.class,
mapSheetAnalEntity.id, mapSheetAnalEntity.id,
mapSheetAnalEntity.analTitle, mapSheetAnalEntity.analTitle,
mapSheetAnalEntity.compareYyyy.as("beforeYear"), mapSheetAnalEntity.compareYyyy.as("beforeYear"),
mapSheetAnalEntity.targetYyyy.as("afterYear"), mapSheetAnalEntity.targetYyyy.as("afterYear"),
mapSheetAnalEntity.baseMapSheetNum)) mapSheetAnalEntity.baseMapSheetNum))
.from(mapSheetAnalEntity) .from(mapSheetAnalEntity)
.orderBy(mapSheetAnalEntity.id.asc()) .orderBy(mapSheetAnalEntity.id.asc())
.fetch(); .fetch();
} }
private StringExpression makeCogUrl(Integer year) { private StringExpression makeCogUrl(Integer year) {
return new CaseBuilder() return new CaseBuilder()
.when(imageryEntity.year.eq(year)) .when(imageryEntity.year.eq(year))
.then( .then(
Expressions.stringTemplate( Expressions.stringTemplate(
"{0} || {1}", imageryEntity.cogMiddlePath, imageryEntity.cogFilename)) "{0} || {1}", imageryEntity.cogMiddlePath, imageryEntity.cogFilename))
.otherwise(""); .otherwise("");
} }
} }