Livraison & Routing (V2)
R182 L9 + async (audit 2026-06-23) — Optimisation VRP via OR-Tools.
R182 L9 + async (audit 2026-06-23) — Optimisation VRP via OR-Tools.
Le solver est lourd (~300s sur des plans réalistes) → exécution
synchrone in-request = timeout 502 + worker bloqué. Désormais :
- **petit plan + budget court** (≤ `VRP_SYNC_MAX_STOPS` stops ET
`time_budget_sec` ≤ `VRP_SYNC_MAX_BUDGET_SEC`) → exécution SYNCHRONE,
réponse 200 + résultat solver immédiat (comportement historique
préservé, UX instantanée) ;
- **sinon** → exécution ASYNCHRONE Celery, réponse **202** + `task_id`.
Le front poll `GET /plans/<id>/optimize/<task_id>/status`.
Body optionnel :
- `time_budget_sec` (int 1..300, default 10) : budget temps solver
- `vehicle_ids` (list[uuid]) : filtre véhicules autorisés
- `async` (bool) : force l'exécution asynchrone
- `sync` (bool) : force l'exécution synchrone (debug / petit plan)
Réponse sync : `{ok, solver_status, routes_created, total_distance_km,
total_duration_min, vehicles_used, stops_routed, stops_total}` ou
`{ok: False, reason}` (no_solution / ortools_unavailable).
Réponse async (202) : `{ok, async, status:"pending", task_id, plan_id,
stops_total, poll_url}`.
Permissions requises : livraison:dispatch
post/api/v1/livraison/plans/{plan_id}/optimize
Request
- Base URL: https://erp.eyeot.fr/api/v1
- URL: https://erp.eyeot.fr/api/v1/api/v1/livraison/plans/{plan_id}/optimize
- Auth: one of:
- HTTP bearer
- HTTP bearer
Response
Succès — payload {data, meta} (cf. API-GUIDE §3.1)
Changes
No recorded changes to this operation across all 1 revision of this API.