1. Java / Говнокод #8525

    +121

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 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());

    Запостил: someone, 15 Ноября 2011

    Комментарии (1) RSS

    Добавить комментарий