Commit 2b564228 by 泽锋 李

10点钟那波张莹霞的缺货,。要减在途了

parent 58b3c48f
......@@ -1223,6 +1223,76 @@ where t1.bailun_order_status != 'Canceled'
// 采购员为 张莹霞 的商品 按缺货数量下单
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@"select
t1.bailun_sku,
'GZBLWH' as 'warehouse_code',
( sum(t7.quantity_out_stock) - ( sum((case when t7.quantity_out_stock>0 then 0 else (t1.usable_stock+t1.occupy_order) end )) + sum(t1.quantity_transfer) + sum(t7.quantity_purchase) ) ) as 'quantity_init_advise', -- 原始采购建议数量 new
GREATEST(5,
( sum(t7.quantity_out_stock) - ( sum((case when t7.quantity_out_stock>0 then 0 else (t1.usable_stock+t1.occupy_order) 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日总日均销量
-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',
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,
2 as 'purchase_type_jit',
sum(t7.quantity_out_stock_aliexpress) as 'quantity_out_stock_aliexpress',
sum(t7.quantity_out_stock_amazon) as 'quantity_out_stock_amazon',
sum(t7.quantity_out_stock_other) as 'quantity_out_stock_other',
t9.quantity_transfer_order as 'quantity_transfer_order',
t9.quantity_transfer_temp_schedule as 'quantity_transfer_temp_schedule',
t9.quantity_transfer_temporary_storage as 'quantity_transfer_temporary_storage'
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
left join dc_mid_transit as t7 on t1.bailun_sku = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code
left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse_code = t9.warehouse_code
where t6.`status`=2 and ( t6.buyer_name in ('张莹霞1') and t1.warehouse_code in ('GZBLWH','GZBLYS') )
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.usable_stock+t1.occupy_order) end )) + sum(t7.quantity_transfer) + sum(t7.quantity_purchase) < sum(t7.quantity_out_stock) ) ", new { main_id = mainID }, commandTimeout: 0).ToList();
if (datas != null && datas.Count >= 1)
{
WritePurchaseAdvise(datas);
}
return mainID;
}
/// <summary>
/// 导入缺货明细 张莹霞1
/// </summary>
/// <param name="mainID"></param>
public static int ImportJITShortageDetailed1_bak(int mainID)
{
var time = DateTime.Now;
// 计算之前先刷新一遍缺货,一面产生间隙(8点56进系统的单,没有算到缺货里面,下午1点那波也不会算上他)
//ResetShortageField();
if (mainID <= 0)
{
mainID = purchase_advise.Add(new dc_auto_purchase_advise { create_time = time, no = purchase_advise.GenerateOrderNo(), buy_sys_plan_no = "ImportJITShortageDetailed1", title = $" jit 缺货 {DateTime.Now.ToString("HH:mm")}" }) ?? 0;
}
// 采购员为 张莹霞 的商品 按缺货数量下单
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@" select
t1.bailun_sku,
'GZBLWH' as 'warehouse_code',
......
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