select P.BILLID,d.billcode PLANCODE,d.bizdate planDate, d.startDate,i.mttype,I.allissueCount,I.allnetWeight,I.allnewnetWeight,I.WAREHOUSENAME,
I.ALLSHIPPEDQTY,I.ALLTOTALREVERSEDQTY, P.BILLNUMBER,P.COMPANY,I.allmtcubage,I.allmtweight, P.BILLSTATUS, rl.linename,rl.lineid,rl.linenumber,
P.SALEORGNUMBER, P.SALEORGNAME, P.BIZTYPENAME, P.BIZDATE, P.ORGUNITNAME, P.SSOURCEBILLNUMBER, P.ODCUSTNUMBER,
P.ODCUSTNAME, P.ODSNAME, P.SALEPERSONNUMBER, P.SALEPERSONNAME, P.SALEGROUPNAME, P.POSTADDRESS, P.DLVCUSTNUMBER,
P.DLVCUSTNAME, P.DLVSNAME, P.RECCUSTNUMBER, P.RECCUSTNAME, P.RECCUSTSNAME, P.PAYCUSTNUMBER, P.PAYCUSTNAME,
P.PAYCUSTSNAME, P.DELIVERYTYPE, P.COMPTYPE, P.POSTCUSTNUMBER, P.POSTCUSTNAME, P.POSTSNAME,
Nvl(Sa.Address, p.Deliveryaddress) DELIVERYADDRESS, P.FXNUMBER, P.FXNAME, P.DEPNAME, NVL(Sr.Name,p.Receiver)RECEIVER,
P.RECEIVERPHONE, P.STOREINFO, P.RECBILLNUM, P.LINKMAN, P.AUDITOR, P.AUDITTIME, P.REMARK, B.ASSIGNDATE,
B.ASSIGNERCODE, B.ASSIGNERNAME, B.LOGISTICSCOMPANYCODE, B.LOGISTICSCOMPANYNAME, B.PLATFORMSTATUS, B.Remark ASSIGNREMARK,B.ITEMID,
decode(kc.customerid,null,0,1)kc,b.deliverydate,kc.DELIVERYDAY,wa.waId, w.startplace,pr.remark_num
from wl_eas_postrequisitionbill p --配送通知单表
left join wl_warehousestartplace w --仓库表
on p.warehousename=w.warehousename
left join wl_DeliveryPlanItem b --配送计划明细表
on b.postBillNumber = p.billnumber
left join wl_deliveryplan d --配送计划表
on b.plan_id=d.planid
left join wl_user u --用户表
on b.updater_id=u.userId
left join wl_user c --用户表
on b.customer_id=c.userid
left join wl_roadline rl --路线表
on b.roadline_id=rl.lineid
left join wl_keycustomer kc --重点客户表
on kc.customercode=p.dlvcustnumber
left join wl_mv_weekAddress wa
on wa.deliveryaddress=p.deliveryaddress and wa.receiver=p.receiver
left join wl_eas_postrequisition_Expand i on i.postnumber= P.BILLNUMBER
LEFT JOIN Wl_Commonreceiver Cr --一般接收人表
ON Cr.Name = p.Receiver
Left Join Wl_Standardreceiver Sr --标准接收人表
On Sr.Id = Cr.Standard_Id
Left Join Wl_Commonaddress Ca --一般地址表
On Ca.Address = p.Deliveryaddress
LEFT JOIN wl_standardaddress sa --标准地址表
ON sa.id = ca.standard_id
left join wl_v_postrequisitionremark pr
on pr.billnumber=p.billnumber
where 1>0 and p.bizdate>'2012-12-01'
and P.BILLSTATUS=4 --已审核状态
and P.FREEZE=0 --未冻结
and b.PLATFORMSTATUS is null