varsql="select t1.bailun_sku,t1.warehouse_code,t2.warehouse_name,sum(t1.quantity_stock) as quantity_stock,sum(t1.quantity_stock*t1.unit_price) as amount from dc_mid_stock_date t1 ";
varsqlwhere=" join dc_base_warehouse t2 on t1.warehouse_code=t2.warehouse_code ";
if(!string.IsNullOrEmpty(warehousetype))
{
sqlwhere+=" and t2.hq_type=@warehousetype ";
sqlparam.Add("warehousetype",warehousetype);
}
sqlwhere+=" where t1.quantity_stock>0 ";
if(!string.IsNullOrEmpty(sku))
{
sqlwhere+=" and t1.bailun_sku = @sku";
sqlparam.Add("sku",sku);
}
if(!string.IsNullOrEmpty(warehouse))
{
sqlwhere+=" and t1.warehouse_code=@warehouse";
sqlparam.Add("warehouse",warehouse);
}
if(start.HasValue)
{
sqlwhere+=" and t1.stock_time>=@start";
sqlparam.Add("start",start.Value);
}
if(end.HasValue)
{
sqlwhere+=" and t1.stock_time<@end";
sqlparam.Add("end",end.Value.AddDays(1));
}
sqlwhere+=" group by t1.bailun_sku,t1.warehouse_code";
varsqlsort="";
if(!string.IsNullOrEmpty(parameter.sort))
{
sqlsort+=" order by "+parameter.sort+" "+parameter.order;
varobj=cn.Page<dc_mid_stock_date>(parameter.pageIndex,parameter.limit,sql+sqlwhere+sqlsort,reftotal,sqlparam,"select count(*) from (select t1.bailun_sku,t1.warehouse_code from dc_mid_stock_date t1 "+sqlwhere+") tb",2*60).AsList();