Commit e85415d4 by lizefeng

超出moq . 有超出的部分,把补单的(初始建议数为负数)按销量排序,逐个消减

parent 53eae7fa
......@@ -132,6 +132,29 @@ select
id = max_data.id
});
}
else if (difference < 0)
{
// 由于上面的补单规则,会导致超出moq . 有超出的部分,把补单的(初始建议数为负数)按销量排序,逐个消减
var abatement = 0 - difference;
foreach (var item in itemGoods.Where(s => s.quantity_init_advise < 0).OrderBy(s => s.goods_history_fourteenday_sales))
{
if (abatement >= item.quantity_final_advise)
{
_connection.Execute(" delete from dc_auto_purchase_advise_detailed where id=@id ", new { id = item.id });
abatement -= item.quantity_final_advise;
}
else
{
_connection.Execute(" update dc_auto_purchase_advise_detailed set quantity_final_advise=@quantity_final_advise where id=@id ", new { id = item.id, quantity_final_advise = item.quantity_final_advise - abatement });
abatement = 0;
}
if (abatement <= 0)
{
break;
}
}
}
}
}
......
......@@ -126,12 +126,15 @@ namespace AutoTurnOver.Services
purchase_advise.Del(id);
}
private static object _push_lock = new object();
/// <summary>
/// 把最新一批的采购单推送到采购系统
/// </summary>
/// <param name="mainId"></param>
public static void PushBuySys(List<dc_auto_purchase_advise_detailed_dto> datas,UserData user)
{
lock (_push_lock)
{
MySqlConnection conn = connectionHelper._connection;
conn.Open();
IDbTransaction transaction = conn.BeginTransaction();
......@@ -191,4 +194,6 @@ namespace AutoTurnOver.Services
}
}
}
}
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