return_connection.Query<temp_sku_dto>(@"select t1.bailun_sku,t1.warehouse_code,t1.supplier_id from dc_base_purchase as t1
return_connection.Query<temp_sku_dto>(@"select t1.bailun_sku,t1.warehouse_code,t1.supplier_id from dc_base_purchase as t1
where t1.supplier_id>0 and buy_status=4
where t1.supplier_id>0 and buy_status=4
-- and EXISTS ( select * from dc_base_stock as t2 where t1.bailun_sku =t2.bailun_sku and t1.warehouse_code = t2.warehouse_code)
-- and EXISTS ( select * from dc_base_stock as t2 where t1.bailun_sku =t2.bailun_sku and t1.warehouse_code = t2.warehouse_code)
-- and t1.bailun_sku='262412401' and t1.warehouse_code='GZBLWH'
-- and t1.bailun_sku='366628401' and t1.warehouse_code='GZBLWH'
GROUP BY t1.bailun_sku,t1.warehouse_code,t1.supplier_id ");
GROUP BY t1.bailun_sku,t1.warehouse_code,t1.supplier_id ");
//return _connection.Query<temp_sku_dto>("select t1.bailun_sku,t1.warehouse_code,t1.supplier_id from dc_base_purchase as t1 where t1.update_time>=@time group by t1.bailun_sku,t1.warehouse_code,t1.supplier_id ", parameters);
//return _connection.Query<temp_sku_dto>("select t1.bailun_sku,t1.warehouse_code,t1.supplier_id from dc_base_purchase as t1 where t1.update_time>=@time group by t1.bailun_sku,t1.warehouse_code,t1.supplier_id ", parameters);
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_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_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
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','冯兆欣') or t1.warehouse_code not in ('GZBLWH','GZBLYS') )
where t1.warehouse_code!='BLGZ03' and (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
) as t1 where t1.quantity_final_advise>0
)
)
...
@@ -195,7 +195,7 @@ where t1.bailun_sku = t2.bailun_sku and quantity_final_advise=1 and quantity_ini
...
@@ -195,7 +195,7 @@ where t1.bailun_sku = t2.bailun_sku and quantity_final_advise=1 and quantity_ini
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_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_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 t7 on t1.bailun_sku = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code
where ( t6.buyer_name in ('赵美聪','张莹霞','张莹霞1') and t1.warehouse_code in ('GZBLWH','GZBLYS') )
where ( ( 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 )
and ( t5.`status`=0 or t5.`status` is null )
GROUP BY t1.bailun_sku
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.quantity_inventory end )) + sum(t1.quantity_transfer) + sum(t1.quantity_purchase) < sum(t7.quantity_out_stock) )
...
@@ -344,7 +344,7 @@ select
...
@@ -344,7 +344,7 @@ select
t1.*,t2.warehouse_name,t3.sku_title_cn as 'sku_name',t4.create_time,t3.buyer_name,
t1.*,t2.warehouse_name,t3.sku_title_cn as 'sku_name',t4.create_time,t3.buyer_name,
(t5.quantity_safe_inventory) as 'quantity_safe_inventory', -- 安全库存
(t5.quantity_safe_inventory) as 'quantity_safe_inventory', -- 安全库存
(t5.daily_weighted_sales) as 'daily_weighted_sales', -- 日均加权
(t5.daily_weighted_sales) as 'daily_weighted_sales', -- 日均加权
(t1.quantity_out_stock) as 'quantity_out_stock', -- 缺货
(t7.quantity_out_stock) as 'realtime_quantity_out_stock', -- 实时缺货
(t7.quantity_out_stock) as 'realtime_quantity_out_stock', -- 实时缺货
(t5.quantity_transfer) as 'quantity_transfer', -- 调拨在途
(t5.quantity_transfer) as 'quantity_transfer', -- 调拨在途
(t5.quantity_purchase) as 'quantity_purchase', -- 采购在途
(t5.quantity_purchase) as 'quantity_purchase', -- 采购在途