(case when t1.quantity_out_stock>0 then 2 when t1.`status` then 1 else 3 end) as 'type',
t6.suppliers_id,
t1.quantity_out_stock
t1.quantity_out_stock,
(
case when t6.buyer_name in ('张莹霞','张莹霞1') and t1.warehouse_code='GZBLWH' then 1
else 0
end
) as 'purchase_type_jit'
from dc_auto_turnover 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 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 dc_auto_jit_tag as t8 on t1.tag_id = t8.id
where t6.`status`=2 and 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') )
and (
( t6.buyer_name not in ('赵美聪','张莹霞','张莹霞1','冯兆欣') or t1.warehouse_code not in ('GZBLWH','GZBLYS') )
or
( t1.tag_id > 0 and t8.is_eliminate = 0 )
) -- 非jit 或者 jit 备货
) as t1 where t1.quantity_final_advise>0
)
...
...
@@ -210,7 +220,7 @@ where t2.`status`=2 and t1.bailun_sku = t2.bailun_sku and quantity_final_advise=
_connection.Execute(@" INSERT into dc_auto_purchase_advise_detailed(`bailun_sku`,`warehouse_code`,`quantity_init_advise`,`quantity_final_advise`,