You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two related capabilities: an auto-schedule engine that fills the schedule for all released orders, and a read-only Gantt chart to visualize the result.
Auto-Schedule Engine
UX Flow
Navigate to /admin/production — filter to Released orders
Click Auto Schedule button
Engine runs through all released orders and their operations:
Checks printer/resource compatibility per operation's material requirements
Checks capacity — no double-booking resources
Prioritizes by due date (earliest due = highest priority)
Assigns scheduled_start / scheduled_end to each operation
Updates PO estimated_completion_date
Result shown as a preview — list of orders with proposed times and any warnings (conflicts that couldn't be resolved, incompatible resources, etc.)
User clicks Confirm Schedule to commit, or Discard to throw it away
Reschedule
Same logic as initial schedule
Skips operations already running or complete — does not move in-flight work
Re-schedules all pending and queued operations from now forward
Available as a separate Reschedule button once a schedule exists
Backend
POST /api/v1/production-orders/auto-schedule — accepts list of PO IDs (or "all released"), returns proposed schedule as a dry-run response (no DB write yet)
POST /api/v1/production-orders/auto-schedule/confirm — commits the proposed schedule (writes scheduled_start/scheduled_end to operations, updates PO status to scheduled, sets estimated_completion_date)
Scheduling algorithm:
Sort orders by due date (nulls last), then priority
For each order, for each operation in sequence:
Find next available slot on a compatible resource/printer using find_next_available_slot + get_earliest_start_after_predecessors
Assign greedily — first compatible resource with earliest availability wins
Return per-operation assignments and per-order estimated completion
Reschedule variant: same algorithm, skip running/complete operations, treat their end times as floor for successors
Frontend
Auto Schedule button on production page (visible when released orders exist)
Preview modal: table of orders → operations → proposed start/end/resource, with warnings highlighted
Confirm / Discard actions
Reschedule button on production page (visible when scheduled/in_progress orders exist)
Gantt Chart (read-only, v1)
What it shows
Horizontal axis: time (day/week/month zoom)
Vertical axis: resources/printers (one row per machine)
Bars: each scheduled operation as a colored bar, labeled with PO code + op name
Color by status: queued (blue), running (purple/pulsing), complete (green)
Tooltip on hover: PO code, operation, start, end, duration
Scope (v1 — intentionally limited)
Read-only — no drag-to-reschedule, no click-to-edit
Renders from existing scheduled_start / scheduled_end data on operations
Zoom: Day / Week / Month toggle
Filter: by work center or printer group
Frontend
New page or tab: /admin/production/schedule or tab on production page
SVG or CSS-grid based Gantt (no heavy charting library dependency)
Zoom controls (Day / Week / Month)
Work center filter
Auto-refreshes every 60s (or on manual refresh)
Backend
GET /api/v1/production-orders/schedule-view?start=&end=&work_center_id= — returns all operations with scheduled_start/scheduled_end in the range, grouped by resource
The find_next_available_slot and get_earliest_start_after_predecessors helpers in resource_scheduling.py are already built — the engine is mostly orchestration on top of them
Gantt v1 is intentionally non-interactive. Drag-to-reschedule is a v2 feature.
Consider session/locking: if two users run auto-schedule simultaneously, results could collide — the confirm step should detect conflicts and reject if the proposed slots are no longer free
Feature Overview
Two related capabilities: an auto-schedule engine that fills the schedule for all released orders, and a read-only Gantt chart to visualize the result.
Auto-Schedule Engine
UX Flow
/admin/production— filter to Released ordersscheduled_start/scheduled_endto each operationestimated_completion_dateReschedule
runningorcomplete— does not move in-flight workpendingandqueuedoperations from now forwardBackend
POST /api/v1/production-orders/auto-schedule— accepts list of PO IDs (or "all released"), returns proposed schedule as a dry-run response (no DB write yet)POST /api/v1/production-orders/auto-schedule/confirm— commits the proposed schedule (writesscheduled_start/scheduled_endto operations, updates PO status toscheduled, setsestimated_completion_date)find_next_available_slot+get_earliest_start_after_predecessorsrunning/completeoperations, treat their end times as floor for successorsFrontend
Gantt Chart (read-only, v1)
What it shows
Scope (v1 — intentionally limited)
scheduled_start/scheduled_enddata on operationsFrontend
/admin/production/scheduleor tab on production pageBackend
GET /api/v1/production-orders/schedule-view?start=&end=&work_center_id=— returns all operations withscheduled_start/scheduled_endin the range, grouped by resourceNotes
releasedstatus existing (feat: implement full PO status workflow — draft → released → scheduled → in_progress → complete #535) — orders must be released before they can be auto-scheduledfind_next_available_slotandget_earliest_start_after_predecessorshelpers inresource_scheduling.pyare already built — the engine is mostly orchestration on top of themRelated