Skip to content

Instantly share code, notes, and snippets.

@msbaek
Last active March 9, 2024 00:38
Show Gist options
  • Save msbaek/8a71d5ccf47d96830c6ccd3a0ab6b19a to your computer and use it in GitHub Desktop.
Save msbaek/8a71d5ccf47d96830c6ccd3a0ab6b19a to your computer and use it in GitHub Desktop.
@Test
void queryDslQueryTest() {
JPAQuery<StatusCommonTemplateExcelData> query =
jpaQueryFactory.select(
Projections.constructor(
StatusCommonTemplateExcelData.class,
Expressions.stringTemplate("'집품'"),
qWarehouse.name, // "창고"
qPacking.status, // "포장 상태"
qShipping.deliverySeq, // "배송 ID"
qShipping.deliveryId, // "배송 번호"
qPacking.trackingNumber, // "송장 번호"
qShipping.carrier.name, // "배송 방식"
qPacking.boxCode, // "박스명"
qPacking.weight, // "실제 중량 무게"
qUser.username, // "작업자"
qUser.loginId, // "작업자 로그인 ID"
qPicking.startAt, // "시작 일시"
qPicking.completedAt, // "완료 일시"
qPicking.completedAt, // "완료일"
qPickingGroup.serialNumber, // "집품 그룹 ID"
JPAExpressions // "품목 수량"
.select(qShippingItem.itemId.countDistinct())
.from(qShippingItem)
.where(qShippingItem.shipping.id.eq(qShipping.id))
.groupBy(qShipping.id),
JPAExpressions // "아이템 수량"
.select(qShippingItem.qty.sum())
.from(qShippingItem)
.where(qShippingItem.shipping.id.eq(qShipping.id))
.groupBy(qShipping.id),
qShipping.shippingAddress.countryCode, // "배송 국가"
qPickingGroup.type, // "집품 구분"
qShipping.serialNumber //"출고 ID"
))
.from(qInspection)
.join(qShipping)
.on(qShipping.id.eq(qInspection.shipping.id))
.join(qUser)
.on(qInspection.updatedUserId.eq(qUser.id))
.join(qShippingItem)
.on(qShipping.id.eq(qShippingItem.shipping.id))
.join(qPickingShipping)
.on(qShipping.id.eq(qPickingShipping.shipping.id))
.join(qPicking)
.on(qPickingShipping.picking.id.eq(qPicking.id))
.join(qPickingGroup)
.on(qPicking.pickingGroup.id.eq(qPickingGroup.id))
.join(qPickingTote)
.on(qPickingShipping.picking.id.eq(qPickingTote.picking.id))
.join(qBin)
.on(qPickingTote.bin.id.eq(qBin.id))
.join(qWarehouse)
.on(qPickingGroup.warehouseId.eq(qWarehouse.id))
.leftJoin(qPacking)
.on(qShipping.id.eq(qPacking.shipping.id))
// .where(searchCondition(request))
.groupBy(qInspection.id); // .fetch()
Approvals.verify(query.toString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment