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不足
vardatas=_connection.Query<dc_auto_purchase_advise_detailed>(" select * from dc_auto_purchase_advise_detailed where main_id=@main_id ",new{main_id=mainID}).AsList();
vardatas=_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();