varsql=@"select t1.id,t4.hq_type as warehousetype,t1.warehousename,t1.sku,t2.category_name as categoryname,t2.sku_title_cn as skuname,t1.monitorstatus,t1.clearancestatus,t1.tortstatus,t1.str_skutag,t2.unit_price as buyprice,t3.usable_stock as inventorycount,t2.unit_price*t3.usable_stock as inventoryamount,t5.quantity_purchase as purchaseonwaycount,t5.quantity_transfer as allotcount
varsql=@"select t4.hq_type as warehousetype,t4.warehouse_name as warehousename,t0.bailun_sku as sku,t2.category_name as categoryname,t2.sku_title_cn as skuname,t1.monitorstatus,t1.clearancestatus,t1.tortstatus,t1.str_skutag,t2.unit_price as buyprice,t3.usable_stock as inventorycount,t2.unit_price*t3.usable_stock as inventoryamount,t5.quantity_purchase as purchaseonwaycount,t5.quantity_transfer as allotcount
from dc_sku_monitor t1
from (SELECT t1.warehouse_code,t1.bailun_sku FROM dc_mid_transit AS t1 union SELECT t1.warehouse_code,t1.bailun_sku FROM dc_base_stock AS t1) t0
left join dc_base_sku t2 on t1.sku=t2.bailun_sku
left join dc_base_stock t3 on t0.bailun_sku=t3.bailun_sku and t0.warehouse_code=t3.warehouse_code
left join dc_base_stock t3 on t1.sku=t3.bailun_sku and t1.warehousecode=t3.warehouse_code
left join dc_sku_monitor t1 on t1.sku=t0.bailun_sku and t1.warehousecode=t0.warehouse_code
left join dc_base_warehouse t4 on t1.warehousecode=t4.warehouse_code
left join dc_base_sku t2 on t0.bailun_sku=t2.bailun_sku
left join dc_mid_transit t5 on t1.sku=t5.bailun_sku and t1.warehousecode=t5.warehouse_code where 1=1";
left join dc_base_warehouse t4 on t0.warehouse_code=t4.warehouse_code
left join dc_mid_transit t5 on t0.bailun_sku=t5.bailun_sku and t0.warehouse_code=t5.warehouse_code where 1=1";
varsql=@"select sum(t3.usable_stock) as inventorycount,sum(t2.unit_price*t3.usable_stock) as inventoryamount,sum(t5.quantity_purchase) as purchaseonwaycount,sum(t5.quantity_purchase*t2.unit_price) purchaseonwayamount,sum(t5.quantity_transfer) as allotcount,sum(t5.quantity_transfer*t2.unit_price) allotamount
from (SELECT t1.warehouse_code,t1.bailun_sku FROM dc_mid_transit AS t1 union SELECT t1.warehouse_code,t1.bailun_sku FROM dc_base_stock AS t1) t0
left join dc_base_stock t3 on t0.bailun_sku=t3.bailun_sku and t0.warehouse_code=t3.warehouse_code
left join dc_sku_monitor t1 on t1.sku=t0.bailun_sku and t1.warehousecode=t0.warehouse_code
left join dc_base_sku t2 on t0.bailun_sku=t2.bailun_sku
left join dc_base_warehouse t4 on t0.warehouse_code=t4.warehouse_code
left join dc_mid_transit t5 on t0.bailun_sku=t5.bailun_sku and t0.warehouse_code=t5.warehouse_code where 1=1";