left JOIN logpm_distribution_signfor lds on lddl.id = lds.delivery_id
LEFT JOIN logpm_distribution_reservation ldr on ldr.id = lds.reservation_id
<where>
lddl.is_deleted = 0 AND (IF(lddl.delivery_number is null ,0,lddl.delivery_number) + IF(lddl.inventory_nub is null ,0,lddl.inventory_nub)) > 0 AND lddl.customers_number > 0
lddl.is_deleted = 0 AND (IF(lddl.delivery_number is null ,0,lddl.delivery_number) + IF(lddl.inventory_nub is null ,0,lddl.inventory_nub)) > 0 AND (lddl.customers_number > 0 AND ldr.reservation_num + ldr.reservation_stock_list_num) >0
<iftest="param.trainNumber != null and param.trainNumber!=''">
and lddl.train_number like concat('%',#{param.trainNumber},'%')