(SELECT SUM(aldrs.reality_num) FROM logpm_distribution_reservation_stocklist AS aldrs WHERE aldrs.reservation_id = #{reservationId} AND aldrs.stock_list_status != 2 AND FIND_IN_SET(aldrs.stocklist_id,t.aaa)) AS realNum,
(SELECT SUM(newldrs.reservation_num) FROM logpm_distribution_reservation_stocklist AS newldrs WHERE newldrs.reservation_id = #{reservationId} ANd newldrs.stock_list_status != 2 AND FIND_IN_SET(newldrs.stocklist_id,t.aaa)) AS planNum,
(
select GROUP_CONCAT( DISTINCT (allocation_id)) from logpm_warehouse_updown_goods where association_value =ldslNew.cargo_number and warehouse_id=#{warehouseId} or association_value in (
SELECT order_package_code from logpm_distribution_parcel_list where conditions=2 and material_code=ldslNew.cargo_number and warehouse_id=#{warehouseId} )
) as allocations
(SELECT SUM(newldrs.reservation_num) FROM logpm_distribution_reservation_stocklist AS newldrs WHERE newldrs.reservation_id = #{reservationId} ANd newldrs.stock_list_status != 2 AND FIND_IN_SET(newldrs.stocklist_id,t.aaa))
AS planNum,
concat(ifnull(t1.allocation_ids,''),if(t1.allocation_ids is not null,',',''), ifnull(t2.allocation_ids,'')) allocations
FROM
(
SELECT
@ -374,7 +372,23 @@
group by ldsl.cargo_number
) t
LEFT JOIN logpm_distribution_stock_list ldslNew ON t.cargo_number = ldslNew.cargo_number
LEFT JOIN logpm_distribution_stock ldss ON ldss.stock_list_id = t.id
LEFT JOIN logpm_distribution_stock ldss ON FIND_IN_SET(ldss.stock_list_id,t.aaa)
LEFT JOIN (
SELECT
ldpl.material_code,
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
AND ldpl.warehouse_id = #{warehouseId}
GROUP BY
ldpl.material_code
) AS t1 ON t.cargo_number = t1.material_code
LEFT JOIN ( SELECT association_value, GROUP_CONCAT( DISTINCT ( allocation_id )) AS allocation_ids FROM logpm_warehouse_updown_goods WHERE warehouse_id = #{warehouseId} AND association_type = 4 GROUP BY association_value ) AS t2 ON t.cargo_number = t2.association_value
GROUP_CONCAT(DISTINCT IFNULL( m.driverName,'')) AS driverName,
GROUP_CONCAT(DISTINCT IFNULL( m.vehicleName,'')) AS vehicleName,
GROUP_CONCAT(DISTINCT IFNULL( m.examine_user_name,'')) AS examineUserNames,
(SELECT MIN(create_time) FROM logpm_distribution_parcel_list WHERE stock_article_id = ldsa.id) AS earliestWarehouseEntryTime
k.earliestWarehouseEntryTime AS earliestWarehouseEntryTime
FROM
logpm_distribution_stock_article AS ldsa
LEFT JOIN (
@ -1198,44 +1198,45 @@
logpm_distribution_signfor As lds ON lds.reservation_id = ldr.id
LEFT JOIN logpm_distribution_delivery_list AS lddl ON lds.delivery_id = lddl.id
) AS m ON ldsa.id = m.stock_article_id AND t.reservation_id = m.reservation_id
LEFT JOIN ( SELECT stock_article_id, min( create_time ) AS earliestWarehouseEntryTime FROM logpm_distribution_parcel_list) AS k ON k.stock_article_id = ldsa.id
<where>
ldsa.order_status in ('70','80')
<iftest="param.waybillNumber != null and param.waybillNumber != ''">
AND ldsa.waybill_number like concat("%",#{param.waybillNumber},"%"})
AND ldsa.waybill_number like concat("%",#{param.waybillNumber},"%")
</if>
<iftest="param.serviceNumber != null and param.serviceNumber != ''">
AND ldsa.service_umber like concat("%",#{param.serviceNumber},"%"})
AND ldsa.service_number like concat("%",#{param.serviceNumber},"%")
</if>
<iftest="param.orderCode != null and param.orderCode != ''">
AND ldsa.order_code like concat("%",#{param.orderCode},"%"})
AND ldsa.order_code like concat("%",#{param.orderCode},"%")
</if>
<iftest="param.warehouseName != null and param.warehouseName != ''">
AND ldsa.warehouse like concat("%",#{param.warehouseName},"%"})
AND ldsa.warehouse like concat("%",#{param.warehouseName},"%")
</if>
<iftest="param.mallName != null and param.mallName != ''">
AND ldsa.mall_mame like concat("%",#{param.mallName},"%"})
AND ldsa.mall_name like concat("%",#{param.mallName},"%")
</if>
<iftest="param.brand != null and param.brand != ''">
AND ldsa.brand like concat("%",#{param.brand},"%"})
AND ldsa.brand like concat("%",#{param.brand},"%")
</if>
<iftest="param.consigneePerson != null and param.consigneePerson != ''">
AND ldsa.consignee_person like concat("%",#{param.consigneePerson},"%"})
AND ldsa.consignee_person like concat("%",#{param.consigneePerson},"%")
</if>
<iftest="param.consigneeUnit != null and param.consigneeUnit != ''">
AND ldsa.consignee_unit like concat("%",#{param.consigneeUnit},"%"})
AND ldsa.consignee_unit like concat("%",#{param.consigneeUnit},"%")
</if>
<iftest="param.deliveryListInfo != null and param.deliveryListInfo != ''">
AND m.mssg like concat("%",#{param.deliveryListInfo},"%"})
AND m.mssg like concat("%",#{param.deliveryListInfo},"%")
</if>
<iftest="param.driverName != null and param.driverName != ''">
AND m.driverName like concat("%",#{param.driverName},"%"})
AND m.driverName like concat("%",#{param.driverName},"%")
</if>
<iftest="param.examineUserNames != null and param.examineUserNames != ''">
AND m.examine_user_name like concat("%",#{param.examineUserNames},"%"})
AND m.examine_user_name like concat("%",#{param.examineUserNames},"%")
</if>
<iftest="param.reservationInfo != null and param.reservationInfo != ''">
AND t.msg like concat("%",#{param.reservationInfo},"%"})
AND t.msg like concat("%",#{param.reservationInfo},"%")
</if>
<iftest="param.warehouseId != null and param.warehouseId != ''">
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 +616,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,
IF((SELECT sum(packet_number) FROM logpm_distrilbution_bill_package WHERE bill_lading_id = #{billLadingId} AND packet_bar_status != 2) IS NULL,0,(SELECT sum(packet_number) FROM logpm_distrilbution_bill_package WHERE bill_lading_id = #{billLadingId} AND packet_bar_status != 2))
( SELECT count( 1 ) FROM logpm_distrilbution_bill_stock WHERE bill_lading_id = ldbl.id AND order_status != 2 AND is_deleted = 0) AS orderNum ,
(IFNULL((SELECT SUM(quantity) FROM logpm_distribution_reservation_zero_package WHERE reservation_id = ldbl.id AND is_deleted = 0),0)) + (IFNULL((SELECT sum(packet_number) FROM logpm_distrilbution_bill_package WHERE bill_lading_id = ldbl.id AND is_deleted = 0),0))+(IFNULL((SELECT SUM(quantity) FROM logpm_distribution_delivery_details WHERE bill_lading_id = ldbl.id AND is_deleted = 0),0)) AS planNum,
IFNULL((SELECT SUM(quantity) FROM logpm_distribution_delivery_details WHERE bill_lading_id = ldbl.id AND is_deleted = 0),0) AS inventoryNub,
IFNULL((SELECT SUM(quantity) FROM logpm_distribution_bill_lading_scan WHERE bill_lading_id = ldbl.id AND is_deleted = 0) ,0) AS signedNum
IF(IFNULL(SUM(ldbls.quantity),0) = sum( ldbp.packet_number ),1,0) c
FROM
logpm_distrilbution_bill_stock AS ldbs
LEFT JOIN logpm_distrilbution_bill_package AS ldbp ON ldbs.stock_article_id = ldbp.stock_article_id
AND ldbs.bill_lading_id = ldbp.bill_lading_id
LEFT JOIN logpm_distribution_bill_lading_scan AS ldbls ON ldbls.stock_article_id = ldbp.stock_article_id AND ldbls.bill_lading_id = ldbs.bill_lading_id
WHERE ldbs.bill_lading_id = #{billLadingId} GROUP BY ldbp.id