Commit 845346ac by lizefeng

张莹霞,张莹霞1,冯兆欣,国内仓,清远01 广州01 只要有缺货,就汇总sku的缺货数, 出建议单到 广州01

parent cd1fbdb9
......@@ -12,7 +12,7 @@ namespace AutoGeneratePurchaseAdvise
{
Console.WriteLine("采购建议计算任务启动...");
// 创建采购计划
//PurchaseAdviseServices.Generate();
PurchaseAdviseServices.Generate();
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{
services.AddHostedService<GeneratePurchaseAdviseBackgroundService>();
......
......@@ -86,7 +86,7 @@ select
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
left join view_goods_moq as t7 on t6.product_inner_code = t7.product_inner_code and t1.warehouse_code = t7.warehouse_code and t6.suppliers_id = t7.suppliers_id
where (t1.history_fourteenday_sales>0 or t1.quantity_out_stock>0 ) and ( t5.`status`=0 or t5.`status` is null ) and t7.sum_quantity_init_advise>0 and t6.buyer_name not in ('赵美聪','张莹霞','张莹霞1')
where (t1.history_fourteenday_sales>0 or t1.quantity_out_stock>0 ) and ( t5.`status`=0 or t5.`status` is null ) and t7.sum_quantity_init_advise>0 and ( t6.buyer_name not in ('赵美聪','张莹霞','张莹霞1','冯兆欣') or t1.warehouse_code not in ('GZBLWH','GZBLYS') )
) as t1 where t1.quantity_final_advise>0
)
......@@ -100,7 +100,7 @@ select
(
select
t1.bailun_sku,
t1.warehouse_code,
'GZBLWH' as 'warehouse_code',
t1.quantity_init_advise as 'quantity_init_advise', -- 原始采购建议数量 new
( t1.quantity_out_stock - ( t1.quantity_inventory + t1.quantity_transfer + t1.quantity_purchase ) ) as 'quantity_final_advise', -- 计算moq之后的数量 new
t6.product_inner_code as 'product_inner_code', -- 内部商品编码 new
......@@ -125,9 +125,9 @@ select
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
where t6.buyer_name in ('赵美聪','张莹霞','张莹霞1') and ( t1.quantity_inventory + t1.quantity_transfer + t1.quantity_purchase < t1.quantity_out_stock )
where t6.buyer_name in ('赵美聪','张莹霞','张莹霞1','冯兆欣') and t1.warehouse_code not in ('GZBLWH','GZBLYS') and ( t1.quantity_inventory + t1.quantity_transfer + t1.quantity_purchase < t1.quantity_out_stock )
) ", new { main_id = mainID });
) ", new { main_id = mainID }, commandTimeout: 0);
......@@ -135,20 +135,24 @@ select
_connection.Execute(@" update dc_auto_purchase_advise_detailed as t1,
dc_base_sku as t2
set t1.quantity_final_advise=2
where t1.quantity_final_advise=1 and t1.quantity_init_advise<=0 and t2.buyer_name not in ('赵美聪','张莹霞','张莹霞1') and t1.main_id=@main_id ", new { main_id = mainID });
where t1.bailun_sku = t2.bailun_sku and t1.quantity_final_advise=1 and t1.quantity_init_advise<=0 and t2.buyer_name not in ('赵美聪','张莹霞','张莹霞1') and t1.main_id=@main_id ", new { main_id = mainID }, commandTimeout: 0);
// 初始建议数为1,,系统建议数为1时 改为3 ( 只补缺货的不管 )
_connection.Execute(@" update dc_auto_purchase_advise_detailed as t1,
dc_base_sku as t2
set quantity_final_advise=3
where quantity_final_advise=1 and quantity_init_advise=1 and t2.buyer_name not in ('赵美聪','张莹霞','张莹霞1') and main_id=@main_id ", new { main_id = mainID });
where t1.bailun_sku = t2.bailun_sku and quantity_final_advise=1 and quantity_init_advise=1 and t2.buyer_name not in ('赵美聪','张莹霞','张莹霞1') and main_id=@main_id ", new { main_id = mainID }, commandTimeout: 0);
// 调整因为舍弃小数导致的moq不足
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(" select * from dc_auto_purchase_advise_detailed where main_id=@main_id ", new { main_id = mainID }).AsList();
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(" select * from dc_auto_purchase_advise_detailed where main_id=@main_id ", new { main_id = mainID }, commandTimeout: 0).AsList();
if (datas != null && datas.Count > 0)
{
foreach (var itemGoods in datas.GroupBy(s => new { s.suppliers_id, s.product_inner_code, s.warehouse_code }))
{
if (itemGoods.Key.product_inner_code == "8538364")
{
}
// 判断总建议采购数是否达到了moq
var difference = itemGoods.Max(s => s.goods_moq) - itemGoods.Sum(s => s.quantity_final_advise);
if (difference > 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