Browse Source

queryDSL where절 Timezone 수정

pull/14/head
박재우 10 months ago
parent
commit
c8f5547f52
  1. 29
      pav-server/src/main/java/com/palnet/biz/jpa/repository/flt/FltPlanQueryRepository.java

29
pav-server/src/main/java/com/palnet/biz/jpa/repository/flt/FltPlanQueryRepository.java

@ -3,7 +3,10 @@ package com.palnet.biz.jpa.repository.flt;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Optional;
@ -1872,6 +1875,9 @@ public class FltPlanQueryRepository {
}
Instant now = Instant.now();
Instant todayStart = LocalDate.now().atStartOfDay().toInstant(ZoneOffset.UTC);
Instant todayEnd = LocalDate.now().plusDays(1).atStartOfDay().toInstant(ZoneOffset.UTC);
List<MainDashFlightListModel> result = query
.select(Projections.bean(MainDashFlightListModel.class,
pgb.groupNm,
@ -1885,9 +1891,10 @@ public class FltPlanQueryRepository {
ccb.cntrlStDt
).as("totalFlightTime"),
new CaseBuilder()
.when(ccb.statusCd.eq("01")).then("비행 중")
.when(ccb.statusCd.eq("99")).then("비행 완료")
.otherwise("비행 대기 중").as("status")
.when(ccb.statusCd.eq("01")).then("비행 중")
.when(ccb.statusCd.eq("99")).then("비행 완료")
.when(fpb.planSno.isNotNull()).then("비행 대기 중")
.otherwise("비행 없음").as("status")
))
.from(fpa)
.leftJoin(fpb).on(fpb.planSno.eq(fpa.planSno))
@ -1896,11 +1903,17 @@ public class FltPlanQueryRepository {
.leftJoin(fpccr).on(fpccr.planSno.eq(fpb.planSno))
.leftJoin(ccb).on(ccb.cntrlId.eq(fpccr.cntrlId))
.where(
builder
.and(fpb.schFltStDt.between(now, now.plus(Duration.ofDays(1))))
.and(fpb.schFltEndDt.between(now, now.plus(Duration.ofDays(1))))
.and(fpb.planSno.isNotNull())
)
builder
.and(fpb.schFltStDt.between(
now.atZone(ZoneId.of("Asia/Seoul")).truncatedTo(ChronoUnit.DAYS).toInstant(),
now.atZone(ZoneId.of("Asia/Seoul")).truncatedTo(ChronoUnit.DAYS).plus(1, ChronoUnit.DAYS).toInstant()
))
.and(fpb.schFltEndDt.between(
now.atZone(ZoneId.of("Asia/Seoul")).truncatedTo(ChronoUnit.DAYS).toInstant(),
now.atZone(ZoneId.of("Asia/Seoul")).truncatedTo(ChronoUnit.DAYS).plus(1, ChronoUnit.DAYS).toInstant()
))
.and(fpb.planSno.isNotNull())
)
.orderBy(((ComparableExpressionBase<Integer>) groupOrder).desc(), cib.createDt.asc())
.fetch();

Loading…
Cancel
Save