IF(c.scan_user is not null,c.scan_user,IF(b.scan_user is not null,b.scan_user,a.scan_user)) AS scanUser,
IF(c.signing_user is not null,c.signing_user,IF(b.signing_user is not null,b.signing_user,a.signing_user)) AS signingUser,
IF(c.scan_time is not null,c.scan_time,IF(b.scan_time is not null,b.scan_time,a.scan_time)) AS loadingTime,
IF(c.signing_time is not null,c.signing_time,IF(b.signing_time is not null,b.signing_time,a.signing_time)) AS signingTime
IF(c.signing_time is not null,c.signing_time,IF(b.signing_time is not null,b.signing_time,a.signing_time)) AS signingTime,
m.qr_code AS goodsAllocation,
n.pallet_name AS pallet
FROM
logpm_distribution_parcel_list AS ldpl
LEFT JOIN logpm_warehouse_updown_goods lwug ON ldpl.id = lwug.association_id
LEFT JOIN logpm_warehouse_tray_goods lwtg ON ldpl.id = lwtg.association_id
LEFT join logpm_distribution_stock_article ldsa on ldsa.id = ldpl.stock_article_id
LEFT join logpm_warehouse_warehouse lww on lww.id = ldpl.warehouse_id
LEFT JOIN (SELECT lwug.association_id,lwga.qr_code,lwug.is_deleted FROM logpm_warehouse_updown_goods AS lwug LEFT JOIN logpm_warehouse_goods_allocation AS lwga ON lwug.allocation_id = lwga.id ) AS m ON m.association_id = ldpl.id
LEFT JOIN (SELECT lwtg.association_id,lwt.pallet_name,lwtg.is_deleted FROM logpm_warehouse_tray_goods AS lwtg LEFT JOIN logpm_warehouse_tray AS lwt ON lwtg.tray_id = lwt.id) AS n ON n.association_id = ldpl.id
LEFT JOIN
(SELECT
ldrp.parce_list_id,
@ -211,14 +215,18 @@
LEFT JOIN logpm_distribution_delivery_list lddl on lds.delivery_id =lddl.id
LEFT JOIN logpm_distrilbution_bill_lading ldbl ON ldrzp.reservation_id = ldbl.id
LEFT JOIN logpm_distribution_bill_lading_scan ldbls ON ldbls.parcel_list_id = ldrzp.parcel_list_id
<where>
</where>
) AS c ON c.parcel_list_id = ldpl.id
<where>
ldpl.is_deleted = 0
ldpl.is_deleted = 0 AND m.is_deleted = 0 AND n.is_deleted = 0
<iftest="param.warehouse !='' and param.warehouse != null">
and lww.name like concat('%',#{param.warehouse},'%')
</if>
<iftest="param.pallet !='' and param.pallet != null">
and n.pallet_name like concat('%',#{param.warehouse},'%')
</if>
<iftest="param.goodsAllocation !='' and param.goodsAllocation != null">
and m.qr_code like concat('%',#{param.warehouse},'%')
</if>
<iftest="param.orderPackageGroundingStatus !='' and param.orderPackageGroundingStatus != null">
and ldpl.order_package_grounding_status = #{param.orderPackageGroundingStatus}
(SELECT GROUP_CONCAT(material_name) FROM logpm_distribution_parcel_list WHERE is_deleted = 0 AND stock_article_id = ldsa.id GROUP BY stock_article_id) AS materialName,
CASE ldsa.is_zero
WHEN 0 THEN
(select COUNT(id) from logpm_distrilbution_bill_package
where stock_article_id = ldsa.id and packet_bar_status in (1,3) and bill_lading_id = #{param.billLadingId} ) + (SELECT IFNULL(SUM(quantity),0) FROM logpm_distribution_reservation_zero_package WHERE stock_article_id = ldsa.id AND zero_package_status IN ( 1, 3 ) AND reservation_id = #{param.billLadingId}) handQuantity,
(select IFNULL(SUM(quantity),0) from logpm_distribution_bill_lading_scan
where stock_article_id = ldsa.id ) pick_up_quantity,
where stock_article_id = ldsa.id and packet_bar_status in (1,3) and bill_lading_id = #{param.billLadingId} AND is_deleted = 0 )
ELSE
(select sum(quantity) from logpm_distribution_reservation_zero_package
where stock_article_id = ldsa.id and zero_package_status in (1,3) AND type =3 and reservation_id = #{param.billLadingId} AND is_deleted = 0 )
END handQuantity,
(select IFNULL(sum(quantity) ,0) from logpm_distribution_bill_lading_scan
where stock_article_id = ldsa.id AND bill_lading_id = #{param.billLadingId} AND is_deleted = 0 ) pick_up_quantity,
CASE
WHEN ( SELECT count( id ) FROM logpm_distribution_bill_lading_scan WHERE stock_article_id = ldsa.id ) = 0 THEN 10
WHEN ( SELECT count( id ) FROM logpm_distribution_bill_lading_scan WHERE stock_article_id = ldsa.id ) - ( SELECT count( id ) FROM logpm_distrilbution_bill_package WHERE stock_article_id = ldsa.id AND packet_bar_status IN ( 1, 3 ) ) < 0 THEN 20
WHEN ( SELECT count( id ) FROM logpm_distribution_bill_lading_scan WHERE stock_article_id = ldsa.id ) - ( SELECT count( id ) FROM logpm_distrilbution_bill_package WHERE stock_article_id = ldsa.id AND packet_bar_status IN ( 1, 3 ) ) = 0 THEN 30
WHEN (SELECT COUNT(id) FROM logpm_distribution_bill_lading_scan WHERE stock_article_id = ldsa.id AND is_deleted = 0) - (SELECT COUNT(id) FROM logpm_distrilbution_bill_package WHERE stock_article_id = ldsa.id AND packet_bar_status IN (1,3) AND is_deleted = 0) = 0 THEN '20'
WHEN (SELECT COUNT(id) FROM logpm_distribution_bill_lading_scan WHERE stock_article_id = ldsa.id AND is_deleted = 0) - (SELECT COUNT(id) FROM logpm_distrilbution_bill_package WHERE stock_article_id = ldsa.id AND packet_bar_status IN (1,3) AND is_deleted = 0) > 0 THEN '10'
WHEN (SELECT COUNT(id) FROM logpm_distribution_bill_lading_scan WHERE stock_article_id = ldsa.id AND is_deleted = 0) - (SELECT COUNT(id) FROM logpm_distrilbution_bill_package WHERE stock_article_id = ldsa.id AND packet_bar_status IN (1,3) AND is_deleted = 0) < 0 THEN '30'
LEFT JOIN logpm_distrilbution_bill_stock ldbs ON ldbs.bill_lading_id = ldbl.id
LEFT JOIN logpm_distribution_stock_article ldsa on ldbs.stock_article_id = ldsa.id
LEFT JOIN logpm_distribution_stock lds on lds.stock_article = ldbs.stock_article_id
LEFT JOIN logpm_distrilbution_bill_lading ldbl ON lds.stock_article = ldbl.stock_article_id
LEFT JOIN (SELECT ldbs.stock_article_id,GROUP_CONCAT(DISTINCT ldbls.scan_user) AS scan_user,MAX(ldbls.create_time) AS aaa FROM logpm_distrilbution_bill_stock AS ldbs LEFT JOIN logpm_distribution_bill_lading_scan AS ldbls ON ldbs.stock_article_id = ldbls.stock_article_id WHERE ldbs.order_status IN (
1,
3) AND ldbs.is_deleted = 0 AND ldbls.is_deleted = 0 GROUP BY ldbs.stock_article_id) AS t ON ldbs.stock_article_id = t.stock_article_id
<where>
ldbs.is_deleted = 0 and ldbs.bill_lading_id = #{param.billLadingId} and ldbs.order_status in (1,3)
</where>
@ -254,22 +260,33 @@
where ldbp.bill_lading_id = #{reservationId} and ldsa.is_zero = #{isZero} and ldbp.packet_bar_status in (1,3)
(SELECT GROUP_CONCAT(material_name) FROM logpm_distribution_parcel_list WHERE is_deleted = 0 AND stock_article_id = ldsa.id GROUP BY stock_article_id) AS materialName,
CASE ldsa.is_zero
WHEN 0 THEN
(select COUNT(id) from logpm_distrilbution_bill_package
where stock_article_id = ldsa.id and packet_bar_status in (1,3) and bill_lading_id = #{param.billLadingId} ) handQuantity,
(select COUNT(id) from logpm_distribution_bill_lading_scan
where stock_article_id = ldsa.id ) pick_up_quantity,
where stock_article_id = ldsa.id and packet_bar_status in (1,3) and bill_lading_id = #{param.billLadingId} AND is_deleted = 0 )
ELSE
(select sum(quantity) from logpm_distribution_reservation_zero_package
where stock_article_id = ldsa.id and zero_package_status in (1,3) AND type =3 and reservation_id = #{param.billLadingId} AND is_deleted = 0 )
END handQuantity,
(select IFNULL(sum(quantity) ,0) from logpm_distribution_bill_lading_scan
where stock_article_id = ldsa.id AND bill_lading_id = #{param.billLadingId} AND is_deleted = 0 ) pick_up_quantity,
CASE
WHEN (SELECT COUNT(id) FROM logpm_distribution_bill_lading_scan WHERE stock_article_id = ldsa.id) - (SELECT COUNT(id) FROM logpm_distrilbution_bill_package WHERE stock_article_id = ldsa.id AND packet_bar_status IN (1,3)) = 0 THEN 20
WHEN (SELECT COUNT(id) FROM logpm_distribution_bill_lading_scan WHERE stock_article_id = ldsa.id) - (SELECT COUNT(id) FROM logpm_distrilbution_bill_package WHERE stock_article_id = ldsa.id AND packet_bar_status IN (1,3)) > 0 THEN 10
WHEN (SELECT COUNT(id) FROM logpm_distribution_bill_lading_scan WHERE stock_article_id = ldsa.id) - (SELECT COUNT(id) FROM logpm_distrilbution_bill_package WHERE stock_article_id = ldsa.id AND packet_bar_status IN (1,3)) < 0 THEN 30
WHEN (SELECT COUNT(id) FROM logpm_distribution_bill_lading_scan WHERE stock_article_id = ldsa.id AND is_deleted = 0) - (SELECT COUNT(id) FROM logpm_distrilbution_bill_package WHERE stock_article_id = ldsa.id AND packet_bar_status IN (1,3) AND is_deleted = 0) = 0 THEN '20'
WHEN (SELECT COUNT(id) FROM logpm_distribution_bill_lading_scan WHERE stock_article_id = ldsa.id AND is_deleted = 0) - (SELECT COUNT(id) FROM logpm_distrilbution_bill_package WHERE stock_article_id = ldsa.id AND packet_bar_status IN (1,3) AND is_deleted = 0) > 0 THEN '10'
WHEN (SELECT COUNT(id) FROM logpm_distribution_bill_lading_scan WHERE stock_article_id = ldsa.id AND is_deleted = 0) - (SELECT COUNT(id) FROM logpm_distrilbution_bill_package WHERE stock_article_id = ldsa.id AND packet_bar_status IN (1,3) AND is_deleted = 0) < 0 THEN '30'