@ -27,198 +27,194 @@
ss_num,
unloading_team_name
from (select
d.train_number train_number,
d.task_time task_time,
d.warehouse_name warehouse_name,
CASE
WHEN d.type = 1 THEN
'商配'
WHEN d.type = 2 THEN
'市配'
ELSE ''
END type,
CASE
WHEN d.kind = 1 THEN
'自主配送'
WHEN d.kind = 2 THEN
'自主配送'
ELSE ''
END kind,
d.vehicle_name vehicle_name,
d.driver_name driver_name,
d.distribution_company distribution_company,
CASE
WHEN d.delivery_status = 1 THEN
'待配送'
WHEN d.delivery_status = 2 THEN
'配送中'
WHEN d.delivery_status = 3 THEN
'已完成'
ELSE ''
END delivery_status,
d.customers_number customers_number,
d.price,
d.order_number order_number,
rn.num reservation_num,
rn.stnum reservation_stock_listNum,
IFNULL(loadScan.loadedNum, 0) loaded_num,
IFNULL(loadscaninvn.loadedNum, 0) invn_loaded_num,
IFNULL(loadScan.exLoadedNum, 0) ex_loaded_num,
IFNULL(loadScan.reNum, 0) re_num,
IFNULL(loadscaninvn.reNum, 0) invn_re_num,
IFNULL(loadScan.exReNum, 0) ex_reNum,
ifnull(rn.dsNum, 0) ds_num,
ifnull(rn.ssNum, 0) ss_num,
ifnull(d.unloading_team_name, '') unloading_team_name
from
logpm_distribution_delivery_list d
LEFT JOIN (
SELECT lds.delivery_id,
COALESCE(sum(ldr1.reservation_num), 0) num,
COALESCE(sum(ldr1.reservation_stock_list_num), 0) stnum,
SUM(CASE
WHEN lds.driver_signing = 2 THEN
1
ELSE
0
END) dsNum,
SUM(CASE
WHEN lds.signing_status = 2 THEN
1
ELSE
0
END) ssNum
FROM logpm_distribution_signfor lds
JOIN logpm_distribution_reservation ldr1 ON lds.reservation_id = ldr1.id
WHERE ldr1.reservation_status != '40'
GROUP BY lds.delivery_id order by null
) rn ON rn.delivery_id = d.id
left join (select t.delivery_id,
SUM(t.loaded_nub) loadedNum,
sum(t.received_quantity) reNum,
sum(if(t.is_abnormal_loading = 1, 0, 1)) exLoadedNum,
sum(if(t.is_abnormal_signing = 1, 0, 1)) exReNum
from logpm_distribution_loadscan t
where t.scan_status != 1
group by t.delivery_id order by null) loadScan on loadScan.delivery_id = d.id
left join (select t.delivery_id,
SUM(t.loaded_nub) loadedNum,
sum(t.received_quantity) reNum
from logpm_distribution_loadscaninvn t
where t.scan_status != 1
group by t.delivery_id order by null) loadscaninvn on loadscaninvn.delivery_id = d.id
where d.customers_number != 0) t
d.train_number train_number,
d.task_time task_time,
d.warehouse_name warehouse_name,
CASE
WHEN d.type = 1 THEN
'商配'
WHEN d.type = 2 THEN
'市配'
ELSE ''
END type,
CASE
WHEN d.kind = 1 THEN
'自主配送'
WHEN d.kind = 2 THEN
'自主配送'
ELSE ''
END kind,
d.vehicle_name vehicle_name,
d.driver_name driver_name,
d.distribution_company distribution_company,
CASE
WHEN d.delivery_status = 1 THEN
'待配送'
WHEN d.delivery_status = 2 THEN
'配送中'
WHEN d.delivery_status = 3 THEN
'已完成'
ELSE ''
END delivery_status,
d.customers_number customers_number,
d.price,
d.order_number order_number,
rn.num reservation_num,
rn.stnum reservation_stock_listNum,
IFNULL(loadScan.loadedNum, 0) loaded_num,
IFNULL(loadscaninvn.loadedNum, 0) invn_loaded_num,
IFNULL(loadScan.exLoadedNum, 0) ex_loaded_num,
IFNULL(loadScan.reNum, 0) re_num,
IFNULL(loadscaninvn.reNum, 0) invn_re_num,
IFNULL(loadScan.exReNum, 0) ex_reNum,
ifnull(rn.dsNum, 0) ds_num,
ifnull(rn.ssNum, 0) ss_num,
ifnull(d.unloading_team_name, '') unloading_team_name
from logpm_distribution_delivery_list d
LEFT JOIN (SELECT lds.delivery_id,
COALESCE(sum(ldr1.reservation_num), 0) num,
COALESCE(sum(ldr1.reservation_stock_list_num), 0) stnum,
SUM(CASE
WHEN lds.driver_signing = 2 THEN
1
ELSE
0
END) dsNum,
SUM(CASE
WHEN lds.signing_status = 2 THEN
1
ELSE
0
END) ssNum
FROM logpm_distribution_signfor lds
left JOIN logpm_distribution_reservation ldr1 ON lds.reservation_id = ldr1.id
WHERE ldr1.reservation_status <![CDATA[<]]> '40'
GROUP BY lds.delivery_id
order by null) rn ON rn.delivery_id = d.id
left join (select t.delivery_id,
SUM(t.loaded_nub) loadedNum,
sum(t.received_quantity) reNum,
sum(if(t.is_abnormal_loading = 1, 0, 1)) exLoadedNum,
sum(if(t.is_abnormal_signing = 1, 0, 1)) exReNum
from logpm_distribution_loadscan t
where t.scan_status != 1
group by t.delivery_id
order by null) loadScan on loadScan.delivery_id = d.id
left join (select t.delivery_id,
SUM(t.loaded_nub) loadedNum,
sum(t.received_quantity) reNum
from logpm_distribution_loadscaninvn t
where t.scan_status != 1
group by t.delivery_id
order by null) loadscaninvn on loadscaninvn.delivery_id = d.id
where
d.customers_number > 0
and rn.num > 0) t
${ew.customSqlSegment}
</select>
<select id= "getCustomerPage" resultType= "com.logpm.report.vo.ReportCustomerVO" >
select train_number,
reservation_code,
stock_article_id,
task_time,
warehouse_name,
receiving_unit,
mall_name,
consignee,
delivery_phone,
delivery_address,
type,
kind,
vehicle_name,
driver_name,
distribution_company,
delivery_status,
order_number,
reservation_num,
reservation_stock_sist_num,
loaded_num,
invn_loaded_num,
ex_loaded_num,
re_num,
invn_re_num,
ex_re_num,
sjsigning_time,
signee_name,
signing_time,
examine_user_name
reservation_code,
stock_article_id,
task_time,
warehouse_name,
receiving_unit,
mall_name,
consignee,
delivery_phone,
delivery_address,
type,
kind,
vehicle_name,
driver_name,
distribution_company,
delivery_status,
order_number,
reservation_num,
reservation_stock_sist_num,
loaded_num,
invn_loaded_num,
ex_loaded_num,
re_num,
invn_re_num,
ex_re_num,
sjsigning_time,
signee_name,
signing_time,
examine_user_name
from (select lddl.train_number train_number,
obj.reservation_code reservation_code,
obj.stock_article_id stock_article_id,
lddl.task_time task_time,
lddl.warehouse_name warehouse_name,
obj.receiving_unit receiving_unit,
obj.mall_name mall_name,
obj.consignee,
obj.delivery_phone delivery_phone,
obj.delivery_address delivery_address,
CASE
WHEN lddl.type = 1 THEN
'商配'
WHEN lddl.type = 2 THEN
'市配'
ELSE ''
END type,
CASE
WHEN lddl.kind = 1 THEN
'自主配送'
WHEN lddl.kind = 2 THEN
'自主配送'
ELSE ''
END kind,
lddl.vehicle_name vehicle_name,
lddl.driver_name driver_name,
lddl.distribution_company distribution_company,
CASE
WHEN lddl.delivery_status = 1 THEN
'待配送'
WHEN lddl.delivery_status = 2 THEN
'配送中'
WHEN lddl.delivery_status = 3 THEN
'已完成'
ELSE ''
END delivery_status,
lddl.order_number order_number,
rn.num reservation_num,
rsln.num reservation_stock_sist_num,
IFNULL(loadScan.loadedNum, 0) loaded_num,
IFNULL(loadscaninvn.loadedNum, 0) invn_loaded_num,
IFNULL(loadScan.exLoadedNum, 0) ex_loaded_num,
IFNULL(loadScan.reNum, 0) re_num,
IFNULL(loadscaninvn.reNum, 0) invn_re_num,
IFNULL(loadScan.exReNum, 0) ex_re_num,
lds.sjsigning_time sjsigning_time,
lds.signee_name signee_name,
lds.signing_time signing_time,
lds.examine_user_name examine_user_name
from logpm_distribution_reservation obj
left join logpm_distribution_signfor lds on lds.reservation_id = obj.id
left join logpm_distribution_delivery_list lddl on lds.delivery_id = lddl.id
LEFT JOIN (SELECT lds.delivery_id,
COALESCE(sum(ldr.reservation_num), 0) num
FROM logpm_distribution_signfor lds
JOIN logpm_distribution_reservation ldr ON lds.reservation_id = ldr.id
WHERE ldr.reservation_status != '40'
GROUP BY lds.delivery_id) rn ON rn.delivery_id = lddl.id
LEFT JOIN (SELECT lds.delivery_id,
COALESCE(sum(ldr.reservation_stock_list_num), 0) num
FROM logpm_distribution_signfor lds
JOIN logpm_distribution_reservation ldr ON lds.reservation_id = ldr.id
GROUP BY lds.delivery_id) rsln ON rsln.delivery_id = lddl.id
left join (select t.delivery_id,
SUM(t.loaded_nub) loadedNum,
sum(t.received_quantity) reNum,
sum(if(t.is_abnormal_loading = 1, 0, 1)) exLoadedNum,
sum(if(t.is_abnormal_signing = 1, 0, 1)) exReNum
from logpm_distribution_loadscan t
where t.scan_status != 1
group by t.delivery_id) loadScan on loadScan.delivery_id = lddl.id
obj.reservation_code reservation_code,
stockarticle.code stock_article_id,
lddl.task_time task_time,
lddl.warehouse_name warehouse_name,
obj.receiving_unit receiving_unit,
obj.mall_name mall_name,
obj.consignee,
obj.delivery_phone delivery_phone,
obj.delivery_address delivery_address,
CASE
WHEN lddl.type = 1 THEN
'商配'
WHEN lddl.type = 2 THEN
'市配'
ELSE ''
END type,
CASE
WHEN lddl.kind = 1 THEN
'自主配送'
WHEN lddl.kind = 2 THEN
'自主配送'
ELSE ''
END kind,
lddl.vehicle_name vehicle_name,
lddl.driver_name driver_name,
lddl.distribution_company distribution_company,
CASE
WHEN lddl.delivery_status = 1 THEN
'待配送'
WHEN lddl.delivery_status = 2 THEN
'配送中'
WHEN lddl.delivery_status = 3 THEN
'已完成'
ELSE ''
END delivery_status,
stockarticle.num order_number,
obj.reservation_num reservation_num,
obj.reservation_stock_list_num reservation_stock_sist_num,
IFNULL(loadScan.loadedNum, 0) loaded_num,
IFNULL(loadscaninvn.loadedNum, 0) invn_loaded_num,
IFNULL(loadScan.exLoadedNum, 0) ex_loaded_num,
IFNULL(loadScan.reNum, 0) re_num,
IFNULL(loadscaninvn.reNum, 0) invn_re_num,
IFNULL(loadScan.exReNum, 0) ex_re_num,
lds.sjsigning_time sjsigning_time,
lds.signee_name signee_name,
lds.signing_time signing_time,
lds.examine_user_name examine_user_name
from logpm_distribution_reservation obj
left join logpm_distribution_signfor lds on lds.reservation_id = obj.id
left join logpm_distribution_delivery_list lddl on lds.delivery_id = lddl.id
left join (select stockarticle.reservation_id, count(*) num, group_concat(ldsa.order_code) code
from logpm_distribution_reservation_stockarticle stockarticle
left join logpm_distribution_stock_article ldsa on ldsa.id = stockarticle.stock_article_id
where stockarticle.stock_article_status != 2
group by stockarticle.reservation_id order by null) stockarticle on stockarticle.reservation_id = obj.id
left join (select t.reservation_id,
SUM(t.loaded_nub) loadedNum,
sum(t.received_quantity) reNum,
sum(if(t.is_abnormal_loading = 1, 0, 1)) exLoadedNum,
sum(if(t.is_abnormal_signing = 1, 0, 1)) exReNum
from logpm_distribution_loadscan t
where t.scan_status != 1
group by t.reservation_id) loadScan on loadScan.reservation_id = obj.id
left join (select t.delivery_id,
SUM(t.loaded_nub) loadedNum,
sum(t.received_quantity) reNum
from logpm_distribution_loadscaninvn t
group by t.delivery_id) loadscaninvn on loadscaninvn.delivery_id = lddl.id) t
left join (select t.reservation_id,
SUM(t.loaded_nub) loadedNum,
sum(t.received_quantity) reNum
from logpm_distribution_loadscaninvn t
group by t.reservation_id) loadscaninvn on loadscaninvn.reservation_id = obj.id
where obj.reservation_status <![CDATA[<]]> '40'
) t
${ew.customSqlSegment}
</select>
<select id= "getDetailsPage" resultType= "com.logpm.report.vo.ReportDetailVO" >