varliststock=cn.Query<Models.Warehouse.mWarehouseRedundancy>($@"select t1.bailun_sku,t1.warehouse_code,t1.usable_stock,t2.sku_title_cn,t2.unit_price,t3.warehouse_name,t4.quantity,t5.quantity_out_stock,t6.oneday_total_sales,t6.threeday_total_sales,t6.sevenday_total_sales,t6.fourteenday_total_sales,t6.thirtyday_total_sales,t6.threeday_average_sales,t6.sevenday_average_sales,t6.fourteenday_average_sales,t6.thirtyday_average_sales,t5.quantity_purchase,t5.quantity_transfer,t2.product_code,t2.bailun_category_id,t2.bailun_category_name,t7.status as 'monitorstatus',t8.tortstatus
from dc_daily_stock t1
from dc_base_stock t1
join dc_base_sku t2 on t1.bailun_sku=t2.bailun_sku
join dc_base_warehouse t3 on t1.warehouse_code=t3.warehouse_code
left join dc_auto_daily_redundance t4 on t4.record_time='{DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}' and t1.bailun_sku=t4.bailun_sku and t1.warehouse_code=t4.warehouse_code -- 仓库冗余
...
...
@@ -383,7 +383,6 @@ namespace Bailun.DC.Services
left join dc_daily_sales t6 on t1.bailun_sku=t6.bailun_sku and t6.record_date='{DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}' and t1.warehouse_code=t6.warehouse_code
left join dc_auto_config_sku_warehouse t7 on t7.bailun_sku=t1.bailun_sku and t7.warehouse_code=t1.warehouse_code
left join dc_sku_monitor t8 on t8.sku=t1.bailun_sku and t8.warehousecode=t1.warehouse_code
where t1.record_time='{DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}'
varsql=@"select t1.*,t2.groupname from dc_datawarehouse t1 left join dc_sku_monitor t2 on t2.sku=t1.sku and t2.warehousecode=t1.warehouse_code where 1=1 ";
varcountsql="select count(t1.id) from dc_datawarehouse t1 left join dc_sku_monitor t2 on t2.sku=t1.sku and t2.warehousecode=t1.warehouse_code where 1=1 ";
varsql=@"select t2.hq_type as warehousetype,t2.warehouse_name as warehousename,t2.warehouse_code,t1.bailun_sku as sku,t3.category_id,t3.category_name,t3.sku_title_cn as skuname,(case when t4.status=0 then 1 else 2 end) monitorstatus,t5.clearancestatus,t5.tortstatus,t5.str_skutag,t3.unit_price as buyprice,t1.usable_stock,(t1.usable_stock*t3.unit_price) amount_stock,t6.quantity_purchase,(t6.quantity_purchase*t3.unit_price) as purchase_amount,t6.quantity_transfer,(t6.quantity_transfer*t3.unit_price) amount_transit,t6.quantity_out_stock,t7.oneday_total_sales,(t7.oneday_total_sales*t3.unit_price) as amount_onedaysale,t7.sevenday_total_sales,(t7.sevenday_total_sales*t3.unit_price) amount_sevendaysale,t7.fourteenday_total_sales,t7.thirtyday_total_sales,t7.sevenday_average_sales,t7.fourteenday_average_sales,t7.thirtyday_average_sales,t3.create_time as skucreatetime,t2.area_id,t2.area_name,t5.groupname,t6.quantity_unshipped
from dc_base_stock t1
left join dc_base_warehouse t2 on t1.warehouse_code=t2.warehouse_code
left join dc_base_sku t3 on t1.bailun_sku=t3.bailun_sku
left join dc_auto_config_sku_warehouse t4 on t4.bailun_sku=t1.bailun_sku and t4.warehouse_code=t1.warehouse_code
left join dc_sku_monitor t5 on t5.sku=t1.bailun_sku and t5.warehousecode=t1.warehouse_code
left join dc_mid_transit t6 on t1.bailun_sku=t6.bailun_sku and t1.warehouse_code=t6.warehouse_code
left join dc_daily_sales t7 on t7.record_date = DATE_SUB(curdate(),INTERVAL 1 DAY) and t1.bailun_sku=t7.bailun_sku and t7.warehouse_code=t1.warehouse_code
where 1=1 ";
varcountsql=@"select count(t1.id) from dc_base_stock t1
left join dc_base_warehouse t2 on t1.warehouse_code = t2.warehouse_code
left join dc_base_sku t3 on t1.bailun_sku = t3.bailun_sku
left join dc_auto_config_sku_warehouse t4 on t4.bailun_sku = t1.bailun_sku and t4.warehouse_code = t1.warehouse_code
left join dc_sku_monitor t5 on t5.sku = t1.bailun_sku and t5.warehousecode = t1.warehouse_code
left join dc_mid_transit t6 on t1.bailun_sku = t6.bailun_sku and t1.warehouse_code = t6.warehouse_code
left join dc_daily_sales t7 on t7.record_date = DATE_SUB(curdate(), INTERVAL 1 DAY) and t1.bailun_sku = t7.bailun_sku and t7.warehouse_code = t1.warehouse_code
where 1 = 1 ";
if(!string.IsNullOrWhiteSpace(searchkey))
{
...
...
@@ -43,58 +59,58 @@ namespace Bailun.DC.Services
if(arr.Count>0)
{
sql+=" and t1.sku in @searchkey";
countsql+=" and t1.sku in @searchkey";
sql+=" and t1.bailun_sku in @searchkey";
countsql+=" and t1.bailun_sku in @searchkey";
sqlparams.Add("searchkey",arr.ToArray());
}
}
if(!string.IsNullOrWhiteSpace(warehousetype))
{
sql+=" and t1.warehousetype=@hq_type";
countsql+=" and t1.warehousetype=@hq_type";
sql+=" and t2.hq_type=@hq_type";
countsql+=" and t2.hq_type=@hq_type";
sqlparams.Add("hq_type",warehousetype);
}
if(!string.IsNullOrWhiteSpace(warehousecode))
{
sql+=" and t1.warehouse_code=@warehousecode";
countsql+=" and t1.warehouse_code=@warehousecode";
sql+=" and t2.warehouse_code=@warehousecode";
countsql+=" and t2.warehouse_code=@warehousecode";
varsql=@"select sum(t1.usable_stock) usable_stock,sum(t1.amount_stock) amount_stock,sum(t1.quantity_purchase) quantity_purchase,sum(t1.purchase_amount) purchase_amount,sum(t1.quantity_transfer) quantity_transfer,sum(t1.amount_transit) amount_transit,sum(t1.quantity_out_stock) quantity_out_stock,sum(t1.oneday_total_sales) oneday_total_sales,sum(t1.amount_onedaysale) amount_onedaysale,sum(t1.sevenday_total_sales) sevenday_total_sales,sum(t1.fourteenday_total_sales) fourteenday_total_sales,sum(t1.thirtyday_total_sales) thirtyday_total_sales,(sum(t1.sevenday_average_sales)/count(t1.id)) sevenday_average_sales,(sum(t1.fourteenday_average_sales)/count(t1.id)) fourteenday_average_sales,(sum(t1.thirtyday_average_sales)/count(t1.id)) thirtyday_average_sales,sum(t1.amount_sevendaysale) amount_sevendaysale from dc_datawarehouse t1 left join dc_sku_monitor t2 on t2.sku=t1.sku and t2.warehousecode=t1.warehouse_code where 1=1 ";
varsql=@"select sum(t1.usable_stock) usable_stock,sum(t1.usable_stock*t3.unit_price) amount_stock,sum(t6.quantity_purchase) quantity_purchase,sum(t6.quantity_purchase*t3.unit_price) as purchase_amount,sum(t6.quantity_transfer) quantity_transfer,sum(t6.quantity_transfer*t3.unit_price) amount_transit,sum(t6.quantity_out_stock) quantity_out_stock,sum(t7.oneday_total_sales) oneday_total_sales,sum(t7.oneday_total_sales*t3.unit_price) as amount_onedaysale,sum(t7.sevenday_total_sales) sevenday_total_sales,sum(t7.sevenday_total_sales*t3.unit_price) amount_sevendaysale,sum(t7.fourteenday_total_sales) fourteenday_total_sales,sum(t7.thirtyday_total_sales) thirtyday_total_sales,sum(t7.sevenday_average_sales) sevenday_average_sales,sum(t7.fourteenday_average_sales) fourteenday_average_sales,sum(t7.thirtyday_average_sales) thirtyday_average_sales from dc_base_stock t1 left join dc_base_warehouse t2 on t1.warehouse_code=t2.warehouse_code left join dc_base_sku t3 on t1.bailun_sku=t3.bailun_sku left join dc_auto_config_sku_warehouse t4 on t4.bailun_sku=t1.bailun_sku and t4.warehouse_code=t1.warehouse_code left join dc_sku_monitor t5 on t5.sku=t1.bailun_sku and t5.warehousecode=t1.warehouse_code left join dc_mid_transit t6 on t1.bailun_sku=t6.bailun_sku and t1.warehouse_code=t6.warehouse_code left join dc_daily_sales t7 on t7.record_date = DATE_SUB(curdate(),INTERVAL 1 DAY) and t1.bailun_sku=t7.bailun_sku and t7.warehouse_code=t1.warehouse_code where 1=1 ";