- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
// This is de facto a Map<Integer, Long> because SUM() returns longs, but
// QueryDSL's type inference makes a fluke here and thinks sum() is an Integer.
// So the return type is Map<Integer, Integer>. Aren't generics fun?
final Map<Integer, ? extends Number> map =
dsl.from(q).where(q.department.eq(params.getDepartment()), q.quantity.ne(0),
q.action.in(UserAction.ORDER_ENGRAVE, UserAction.ORDER_STOCK_WASTAGE,
UserAction.ORDER_INVOICE, UserAction.ORDER_STOCK_ADJUSTMENT),
QueryDsl.subFrom(q2).where(q2.order.eq(q.order), q2.timestamp.goe(interval.getA()),
q2.timestamp.lt(interval.getB()),
q2.action.in(UserAction.ORDER_ENGRAVE, UserAction.ORDER_STOCK_WASTAGE,
UserAction.ORDER_INVOICE, UserAction.ORDER_STOCK_ADJUSTMENT)).exists())
.groupBy(q.order.id).having(q.quantity.sum().gt(0)).map(q.order.id, q.quantity.sum());
guest8 09.04.2019 12:09 # −999