@@ -498,25 +498,29 @@ left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
where t1.usable_stock<=0 and t1.bailun_sku!=''
and ( t_db.hq_type!='国内仓' or t3.buyer_name not in ('张莹霞','张莹霞1','黄镜洁','赵美聪') )
and t1.warehouse_code in ('AU4PXBL','BLGZ03','DYGXC','GB4PXBL','GBBLJW','GBYKD','GZBLWH','QYBLZZ','US4PXBL','USGCBL')
and t1.warehouse_code in ('AU4PXBL','GB4PXBL','GBBLJW','GBYKD','GZBLWH','QYBLZZ','US4PXBL','USGCBL')
and (
case
when t_db.hq_type='国内仓' then t2.quantity_purchase
when t_db.hq_type='国内仓' then 0
else t2.quantity_transfer
end
)<=0
and not EXISTS (
select * from dc_base_stock as t_stock
left join dc_base_warehouse as t_stock_w on t_stock.warehouse_code = t_stock_w.warehouse_code
left join dc_mid_transit as t_stock_t on t_stock.warehouse_code =t_stock_t.warehouse_code and t_stock.bailun_sku =t_stock_t.bailun_sku
where ( ( t_stock_w.hq_type='国内仓' and t_db.hq_type='国内仓' ) or ( t_db.hq_type!='国内仓' and t_stock_w.hq_type!='国内仓' and t_db.area_id=t_stock_w.area_id ) ) and t_stock.bailun_sku= t1.bailun_sku and ( t_stock.usable_stock>0 or
(
case
when t_stock_w.hq_type='国内仓' then t_stock_t.quantity_purchase
else t_stock_t.quantity_transfer
end
)>0
)
)<=0 -- 国内仓有没有在途都要推 , 国外仓有调拨在途就不推了
and not EXISTS (
select * from dc_base_stock as t_stock
left join dc_base_warehouse as t_stock_w on t_stock.warehouse_code = t_stock_w.warehouse_code
left join dc_mid_transit as t_stock_t on t_stock.warehouse_code =t_stock_t.warehouse_code and t_stock.bailun_sku =t_stock_t.bailun_sku
where
t_stock.warehouse_code != 'BLGZ03'
and ( ( t_stock_w.hq_type='国内仓' and t_db.hq_type='国内仓' ) or ( t_db.hq_type!='国内仓' and t_stock_w.hq_type!='国内仓' and t_db.area_id=t_stock_w.area_id ) )
and t_stock.bailun_sku= t1.bailun_sku and
( t_stock.usable_stock>0 or
(
case
when t_stock_w.hq_type='国内仓' then 0 -- 国内其他仓有没有在途都要推 , 国外仓有调拨在途就不推了
else t_stock_t.quantity_transfer
end
)>0
)
) -- 同属性仓库 (是否国内) 有库存,就不算 0库存
and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_shortage_push_not_config.warehouse_code=t1.warehouse_code and dc_auto_shortage_push_not_config.bailun_sku=t1.bailun_sku )