SELECT (IF((SELECT sum(loaded_nub) FROM logpm_distribution_loadscan WHERE reservation_id = #{reservationId} AND scan_state != 1 AND is_abnormal_loading != 2) is null,0,(SELECT sum(loaded_nub) FROM logpm_distribution_loadscan WHERE reservation_id = #{reservationId} AND scan_state != 1 AND is_abnormal_loading != 2)))
SELECT (IF((SELECT sum(loaded_nub) FROM logpm_distribution_loadscan WHERE reservation_id = #{reservationId} AND scan_state != 1 AND is_abnormal_loading != 2) is null,0,(SELECT sum(loaded_nub) FROM logpm_distribution_loadscan WHERE reservation_id = #{reservationId} AND scan_state != 1 AND is_abnormal_loading != 2)))
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 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 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