"coalesce(prd_line,''),coalesce((select name from product_product where id=product_id),''),"+\
"coalesce(batch_no,''),coalesce((select name from inventory_storehouse where id=store_id),''),qty,lv,"+\
"(select count(*) from mes_labelbindhx"+sWhere+" and inbound=false "+\
"and product_id=g.product_id and batch_no=g.batch_no and store_id=g.store_id and dt=g.dt)+"+\
"and prd_line=g.prd_line and prd_shop=g.prd_shop and product_id=g.product_id and batch_no=g.batch_no and store_id=g.store_id and dt=g.dt)+"+\
"(select count(*) from mes_labelbindpx"+sWhere+" and inbound=false "+\
"and product_id=g.product_id and batch_no=g.batch_no and store_id=g.store_id and dt=g.dt) qty_inbound, "+\
"and coalesce(prd_line,'')=g.prd_line and coalesce(prd_shop,'')=g.prd_shop and product_id=g.product_id and batch_no=g.batch_no and store_id=g.store_id and dt=g.dt) qty_inbound, "+\
"q0,coalesce((SELECT value FROM product_productprop where company_id="+cid+" and categoryprop_id="+\
"(SELECT id FROM company_categoryprop where name='package' "+\
"and category_id=(select category_id from company_company where id="+cid+")) "+\
"and id in (select prd_property_id from product_prdprops where product_id=g.product_id) limit 1),''),g.dt,"+\
"(select name from gis.adm_map_cn where id=origin_adm_id) "+\
"(select name from gis.adm_map_cn where id=origin_adm_id),"+\
"coalesce(prd_shop,''),coalesce(qc,'') "+\
"from "+\
"(select min(tm1) tm1,max(tm2) tm2,prd_line,batch_no,store_id,product_id,count(*) qty,'三级绑定' lv,sum(q0) q0,dt,null origin_adm_id from "+\
"(select min(tm) tm1,max(tm) tm2,prd_line,batch_no,store_id,product_id,carton_code,count(*) q0,dt FROM mes_labelbindhx"+sWhere+\
"group by prd_line,batch_no,store_id,product_id,carton_code,dt"+\
"(select min(tm1) tm1,max(tm2) tm2,prd_line,batch_no,store_id,product_id,count(*) qty,'三级绑定' lv,sum(q0) q0,dt,null origin_adm_id,prd_shop,qc from "+\