concat(ifnull(t1.allocation_ids,''),if(t1.allocation_ids is not null,',',''), ifnull(t2.allocation_ids,'')) as allocations,
ldsl.description_goods materialName,
ldsl.sku sku,
ldsl.cargo_norms cargoNorms,
@ -594,10 +593,20 @@
lddd.id deliveryDetailsId
from logpm_distribution_delivery_details lddd
LEFT JOIN logpm_distribution_stock_list ldsl on lddd.stock_list_id = ldsl.id
LEFT JOIN logpm_warehouse_updown_goods lwug
on lwug.association_id = ldsl.material_id and lwug.association_type = '4'
and ldsl.market_id = lwug.market_id and ldsl.incoming_batch = lwug.incoming_batch and
ldsl.warehouse_id = lwug.warehouse_id
LEFT JOIN ( SELECT association_value,warehouse_id, GROUP_CONCAT( DISTINCT ( allocation_id )) AS allocation_ids FROM logpm_warehouse_updown_goods WHERE association_type = 4 GROUP BY association_value,warehouse_id ) AS t2 ON ldsl.cargo_number = t2.association_value and ldsl.warehouse_id=t2.warehouse_id
LEFT JOIN ( SELECT
ldpl.material_code,
ldpl.warehouse_id,
GROUP_CONCAT( DISTINCT ( lwug.allocation_id ) ) AS allocation_ids
FROM
logpm_warehouse_updown_goods lwug
LEFT JOIN logpm_distribution_parcel_list ldpl ON ldpl.id = lwug.association_id
WHERE
lwug.association_type != 4
AND ldpl.conditions = 2
GROUP BY ldpl.material_code,ldpl.warehouse_id ) AS t1 ON ldsl.cargo_number = t1.material_code and ldsl.warehouse_id=t1.warehouse_id
where lddd.bill_lading_id = #{reservationId}
GROUP BY lddd.stock_list_id, ldsl.description_goods, ldsl.sku, ldsl.cargo_norms, lddd.quantity, ldsl.cargo_unit,