Skip to content

feat: auto-schedule engine with Gantt chart view #536

@Blb3D

Description

@Blb3D

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

  1. Navigate to /admin/production — filter to Released orders
  2. Click Auto Schedule button
  3. Engine runs through all released orders and their operations:
    • Respects operation sequence (predecessor constraints)
    • 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
  4. Result shown as a preview — list of orders with proposed times and any warnings (conflicts that couldn't be resolved, incompatible resources, etc.)
  5. 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

Notes

  • Auto-schedule depends on released status existing (feat: implement full PO status workflow — draft → released → scheduled → in_progress → complete #535) — orders must be released before they can be auto-scheduled
  • 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

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions