Commit 3b70f33c by lizefeng

修改缺货推送算法

parent 528ca474
......@@ -15,6 +15,7 @@ namespace AutoGeneratePurchaseAdvise
// 创建采购计划
//PurchaseAdviseServices.Generate();
//PurchaseAdviseServices.AutoPushBuySys();
//purchase_advise.ImportJITShortageDetailed(0);
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{
services.AddHostedService<GeneratePurchaseAdviseBackgroundService>();
......
......@@ -204,7 +204,7 @@ where t2.`status`=2 and t1.bailun_sku = t2.bailun_sku and quantity_final_advise=
{
mainID = purchase_advise.Add(new dc_auto_purchase_advise { create_time = DateTime.Now, no = purchase_advise.GenerateOrderNo() }) ?? 0;
}
// 采购员为 赵美聪 的商品 按缺货数量下单
// 采购员为 张莹霞 的商品 按缺货数量下单
_connection.Execute(@" INSERT into dc_auto_purchase_advise_detailed(`bailun_sku`,`warehouse_code`,`quantity_init_advise`,`quantity_final_advise`,
`product_inner_code`,`goods_quantity_init_advise`,`goods_moq`,`good_sku_codes`,`goods_history_fourteenday_sales`,`history_fourteenday_sales`,
`quantity_actual`,`main_id`,
......@@ -213,28 +213,28 @@ where t2.`status`=2 and t1.bailun_sku = t2.bailun_sku and quantity_final_advise=
select
t1.bailun_sku,
'GZBLWH' as 'warehouse_code',
sum(t1.quantity_init_advise) as 'quantity_init_advise', -- 原始采购建议数量 new
( sum(t7.quantity_out_stock) - ( sum((case when t7.quantity_out_stock>0 then 0 else t1.quantity_inventory end )) + sum(t1.quantity_transfer) + sum(t1.quantity_purchase) ) ) as 'quantity_final_advise', -- 计算moq之后的数量 new
-1 as 'quantity_init_advise', -- 原始采购建议数量 new
( sum(t7.quantity_out_stock) - ( sum((case when t7.quantity_out_stock>0 then 0 else t1.usable_stock end )) + sum(t1.quantity_transfer) + sum(t7.quantity_purchase) ) ) as 'quantity_final_advise', -- 计算moq之后的数量 new
t6.product_inner_code as 'product_inner_code', -- 内部商品编码 new
0 as 'goods_quantity_init_advise', -- 商品本次的建议下单数量 new
0 as 'goods_moq', -- 商品的moq new
0 as 'good_sku_codes', -- 商品涉及的下单所有sku new
0 as 'goods_history_fourteenday_sales', -- 商品的最近14日总日均销量
t1.history_fourteenday_sales as 'history_fourteenday_sales', -- sku的最近14日日均
-1 as 'history_fourteenday_sales', -- sku的最近14日日均
0 as 'quantity_actual', -- 真实下单数量
@main_id as 'main_id',
t2.forecast_formula as 'forecast_formula',
t2.fit_forecast_formula as 'fit_forecast_formula',
t1.turnover_days,
t1.supplier_delivery,
t1.inspection_delivery,
t1.transfer_delivery,
t1.sales_upper_limit,
0 as 'turnover_days',
0 as 'supplier_delivery',
0 as inspection_delivery,
0 as transfer_delivery,
0 as sales_upper_limit,
0 as 'ispush',
2 as 'type',
t6.suppliers_id,
t7.quantity_out_stock
from dc_auto_turnover as t1
from dc_base_stock as t1
left join dc_auto_sales as t2 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
left join dc_auto_config_sku_warehouse as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
......@@ -242,7 +242,7 @@ where t2.`status`=2 and t1.bailun_sku = t2.bailun_sku and quantity_final_advise=
where t6.`status`=2 and ( ( t6.buyer_name in ('张莹霞','张莹霞1') and t1.warehouse_code in ('GZBLWH','GZBLYS') ) or t1.warehouse_code='BLGZ03' )
and ( t5.`status`=0 or t5.`status` is null )
GROUP BY t1.bailun_sku
HAVING ( sum((case when t7.quantity_out_stock>0 then 0 else t1.quantity_inventory end )) + sum(t1.quantity_transfer) + sum(t1.quantity_purchase) < sum(t7.quantity_out_stock) )
HAVING ( sum((case when t7.quantity_out_stock>0 then 0 else t1.usable_stock end )) + sum(t7.quantity_transfer) + sum(t7.quantity_purchase) < sum(t7.quantity_out_stock) )
) ", new { main_id = mainID }, commandTimeout: 0);
......@@ -263,28 +263,28 @@ where t2.`status`=2 and t1.bailun_sku = t2.bailun_sku and quantity_final_advise=
select
t1.bailun_sku,
'GZBLWH' as 'warehouse_code',
sum(t1.quantity_init_advise) as 'quantity_init_advise', -- 原始采购建议数量 new
( sum(t7.quantity_out_stock) - ( sum((case when t7.quantity_out_stock>0 then 0 else t1.quantity_inventory end )) + sum(t1.quantity_transfer) + sum(t1.quantity_purchase) ) ) as 'quantity_final_advise', -- 计算moq之后的数量 new
-1 as 'quantity_init_advise', -- 原始采购建议数量 new
( sum(t7.quantity_out_stock) - ( sum((case when t7.quantity_out_stock>0 then 0 else t1.usable_stock end )) + sum(t1.quantity_transfer) + sum(t7.quantity_purchase) ) ) as 'quantity_final_advise', -- 计算moq之后的数量 new
t6.product_inner_code as 'product_inner_code', -- 内部商品编码 new
0 as 'goods_quantity_init_advise', -- 商品本次的建议下单数量 new
0 as 'goods_moq', -- 商品的moq new
0 as 'good_sku_codes', -- 商品涉及的下单所有sku new
0 as 'goods_history_fourteenday_sales', -- 商品的最近14日总日均销量
t1.history_fourteenday_sales as 'history_fourteenday_sales', -- sku的最近14日日均
-1 as 'history_fourteenday_sales', -- sku的最近14日日均
0 as 'quantity_actual', -- 真实下单数量
@main_id as 'main_id',
t2.forecast_formula as 'forecast_formula',
t2.fit_forecast_formula as 'fit_forecast_formula',
t1.turnover_days,
t1.supplier_delivery,
t1.inspection_delivery,
t1.transfer_delivery,
t1.sales_upper_limit,
0 as 'turnover_days',
0 as 'supplier_delivery',
0 as inspection_delivery,
0 as transfer_delivery,
0 as sales_upper_limit,
0 as 'ispush',
2 as 'type',
t6.suppliers_id,
t7.quantity_out_stock
from dc_auto_turnover as t1
from dc_base_stock as t1
left join dc_auto_sales as t2 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
left join dc_auto_config_sku_warehouse as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
......@@ -292,7 +292,7 @@ where t2.`status`=2 and t1.bailun_sku = t2.bailun_sku and quantity_final_advise=
where t6.`status`=2 and ( ( t6.buyer_name in ('赵美聪') and t1.warehouse_code in ('GZBLWH','GZBLYS') ) or t1.warehouse_code='BLGZ03' )
and ( t5.`status`=0 or t5.`status` is null )
GROUP BY t1.bailun_sku
HAVING ( sum((case when t7.quantity_out_stock>0 then 0 else t1.quantity_inventory end )) + sum(t1.quantity_transfer) + sum(t1.quantity_purchase) < sum(t7.quantity_out_stock) )
HAVING ( sum((case when t7.quantity_out_stock>0 then 0 else t1.usable_stock end )) + sum(t7.quantity_transfer) + sum(t7.quantity_purchase) < sum(t7.quantity_out_stock) )
) ", new { main_id = mainID }, commandTimeout: 0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment