Work Orders
Create, track, and manage maintenance work orders across your mining fleet with status tracking, priority levels, and audit logging.
Overview
Work orders in MineSync represent discrete maintenance or repair tasks for fleet vehicles. They track the full lifecycle of a task from creation through completion, recording status, priority, costs, scheduling, and assignment. The work orders page at /t/{slug}/lifecycle/work-orders displays historical component changes derived from maintenance logs, while the API supports full CRUD operations on work orders themselves.
Data Model
Each work order (WorkOrder table) contains:
| Field | Type | Description |
|---|---|---|
title | string | Short description of the work to be performed |
description | string | Detailed description (optional) |
status | enum | One of: OPEN, IN_PROGRESS, BLOCKED, DONE, CANCELED |
priority | enum | One of: LOW, MEDIUM, HIGH, CRITICAL |
vehicleId | string | Associated fleet vehicle (optional) |
profileId | string | Associated lifecycle profile (optional) |
assignedToUserId | string | User assigned to the work order (optional) |
dueDate | timestamp | Target completion date |
scheduledStart / scheduledEnd | timestamp | Scheduled work window |
completedAt | timestamp | Actual completion timestamp |
estimatedCost / actualCost | decimal | Cost tracking fields |
deletedAt | timestamp | Soft-delete marker (null when active) |
Status Workflow
Work orders follow a status progression:
OPEN --> IN_PROGRESS --> DONE
| |
v v
BLOCKED CANCELED- OPEN -- newly created, not yet started.
- IN_PROGRESS -- work has begun.
- BLOCKED -- waiting on parts, resources, or approvals.
- DONE -- work completed.
- CANCELED -- work order abandoned or no longer needed.
How to Use
Creating a Work Order
Work orders can be created through:
- Manual creation via the API with a title, optional description, status, priority, vehicle association, and due date.
- From benchmark data -- the
createPreventativeFromBenchmarkprocedure generates preventive work orders based on Weibull reliability analysis. It calculates a due date from the vehicle's current hours, the projected failure hours, and the daily utilization rate.
Required role: ADMIN, PLANNER, or TECHNICIAN.
Viewing Work Orders
The work orders list page shows historical component changes from maintenance logs in a table with columns:
- Vehicle -- unit number, serial, or model name.
- Component -- the catalog component affected.
- WO Install / WO Removal -- linked work orders for component installation and removal.
- Change (Frame Hour) -- the hour meter reading when the event occurred.
- Component Life -- calculated hours between this event and the previous event for the same vehicle/component combination.
- Root Cause -- editable dropdown with options: Wear, Damage, Preventive Maintenance, Failure, Upgrade, Other.
- Serial Number -- component serial number.
The list supports text search across vehicle names, component names, root causes, and serial numbers. Pagination is set at 50 records per page.
Filtering and Search
The API list procedure supports filtering by:
q-- full-text search across title, description, vehicle VIN, and model name.status-- filter by work order status.priority-- filter by priority level.title-- filter by title text.vehicle-- filter by vehicle VIN or model name.
Results are ordered by priority (descending) then due date (ascending), and support pagination with configurable page size (1--100, default 25).
Updating a Work Order
Update any combination of title, description, status, priority, vehicle, or due date. The system verifies that the work order belongs to the current tenant before applying changes. All updates are audit-logged with before/after state.
Required role: ADMIN, PLANNER, or TECHNICIAN.
Deleting a Work Order
Deletion is a soft-delete operation -- it sets the deletedAt timestamp rather than removing the record. Soft-deleted work orders are excluded from list queries. Deletion is audit-logged.
Required role: ADMIN or PLANNER.
Bulk Import
The work orders page includes a "Bulk Import" button that navigates to a dedicated import page for uploading maintenance log data in bulk. This is useful for migrating historical data from external systems.
Audit Trail
All work order mutations (create, update, delete) are recorded in the audit log using the auditInsert, auditUpdate, and auditDelete helpers. The audit trail captures the full before/after state of the record along with the tenant context.
Common Questions
What is the difference between the work orders page and the work orders API?
The work orders page (/lifecycle/work-orders) primarily displays maintenance log history -- component changes with their associated work orders. The tRPC workOrders router provides direct CRUD operations on the WorkOrder table itself. Both work together: maintenance logs reference work orders via installWorkOrderId and removalWorkOrderId.
How does the preventive work order from benchmark work?
When triggered, the system looks up the vehicle's current hours (hoursLTD) and daily utilization, calculates the remaining hours until the projected failure point, converts that to days, and sets the due date accordingly. The work order is created with MEDIUM priority and OPEN status.
Can I undo a delete?
Work orders use soft-delete, so the data is preserved. The maintenance log view also supports an undo toast that cancels the deletion within 5 seconds. However, there is no UI to restore a soft-deleted work order after the undo window closes.
What roles can manage work orders?
- Create/Update: ADMIN, PLANNER, or TECHNICIAN
- Delete: ADMIN or PLANNER only