Here’s a comprehensive approach to implementing proper resource conflict detection for API-based routing updates:
Resource Conflict Detection:
Implement a multi-step validation process before submitting routing changes:
- Check existing job schedules:
GET /api/v1/resources/MACHINE-A/availability
?startDate=2025-01-06T08:00:00Z
&endDate=2025-01-06T12:00:00Z
// Returns list of scheduled jobs in that window
-
Verify maintenance windows:
Query the maintenance calendar to identify planned downtime that would conflict with your proposed schedule.
-
Validate shift schedules:
Ensure the scheduled time falls within active shift hours for the work center.
-
Apply buffer times:
Add setup/teardown buffers (typically 15-30 minutes) before and after your operation to prevent tight coupling.
Routing Validation with API:
Use the validateConflicts flag in your routing update payload:
{
"jobId": "JOB-5678",
"validateConflicts": true,
"routingSteps": [{
"stepId": "STEP-01",
"resourceId": "MACHINE-A",
"scheduledStart": "2025-01-06T08:00:00Z",
"duration": 240,
"setupTime": 15,
"teardownTime": 15
}]
}
With validateConflicts enabled, the API returns:
- 200 Success: No conflicts detected, routing updated
- 409 Conflict: Response includes conflicting job details and overlap time ranges
- 400 Bad Request: Invalid resource ID or scheduling parameters
Schedule Constraints Enforcement:
The API validates these constraints when validateConflicts=true:
- Resource capacity (no double-booking)
- Sequence dependencies (predecessor steps must complete first)
- Lead time requirements (minimum time between operations)
- Maximum queue time (WIP time limits between steps)
It does NOT automatically validate:
- Maintenance windows (query separately)
- Shift calendar compliance (validate client-side)
- Operator skill requirements (check resource capabilities)
Real-time Availability Checking Best Practices:
Build a pre-validation function that runs before every routing update:
function validateScheduleUpdate(jobId, routingSteps) {
for each step in routingSteps:
// Check resource availability
availability = getResourceAvailability(step.resourceId, step.scheduledStart, step.duration)
if availability.isBooked: return conflict error
// Check maintenance windows
maintenance = getMaintenanceWindows(step.resourceId, step.scheduledStart, step.duration)
if maintenance.overlaps: return maintenance conflict
// Validate shift schedule
shifts = getWorkCenterShifts(step.workCenter, step.scheduledStart)
if not shifts.isActiveTime: return shift violation
// All checks passed, proceed with API call
return submitRoutingUpdate(jobId, routingSteps, validateConflicts=true)
}
Implement pessimistic locking: when your validation passes and you submit the routing update, there’s still a race condition window. Use transaction-level locking or implement an optimistic concurrency pattern where you include the resource’s lastModified timestamp in your request. If another process updated the schedule between your validation and submission, the API will reject with 412 Precondition Failed.
Monitor for conflicts that slip through: even with proper validation, schedule drift can cause conflicts to emerge later (jobs running longer than planned, early starts, etc.). Implement periodic schedule validation jobs that scan for conflicts and alert planners to resolve them before they impact production.
This multi-layered approach ensures routing updates maintain schedule integrity whether submitted through UI or API.