Paros (Downtime) API
The Paros API manages machine downtime events during production shifts, tracking causes, duration, and impact on production efficiency.
Authentication
Read operations : VIEW_PRODUCTION permission
Write operations : MANAGE_PRODUCTION permission
Get Downtime by Process
GET /api/paros?bitacora_id={id}&proceso_id={pid}
Permission: VIEW_PRODUCTION
Returns all downtime events for a specific process in a shift.
Query Parameters
Bit\u00e1cora (shift log) ID
Response
Array of downtime events Affected machine ID (if applicable)
Downtime type/category ID
Downtime type name (e.g., “Mec\u00e1nico”, “El\u00e9ctrico”, “Falta de material”)
Detailed description of the downtime cause
Start time (HH:MM format)
User who recorded the event
Example Request
curl -X GET "https://api.example.com/api/paros?bitacora_id=43&proceso_id=2" \\
-H "Authorization: Bearer <token>"
Example Response
{
"success" : true ,
"data" : {
"paros" : [
{
"id" : 101 ,
"bitacora_id" : 43 ,
"proceso_id" : 2 ,
"maquina_id" : 3 ,
"tipo_paro_id" : 2 ,
"tipo_paro_nombre" : "Mec \u00e1 nico" ,
"minutos" : 45 ,
"descripcion" : "Falla en tensor principal - requiri \u00f3 ajuste y verificaci \u00f3 n" ,
"hora_inicio" : "10:15" ,
"hora_fin" : "11:00" ,
"registrado_por" : "Juan P \u00e9 rez"
},
{
"id" : 102 ,
"bitacora_id" : 43 ,
"proceso_id" : 2 ,
"maquina_id" : 5 ,
"tipo_paro_id" : 4 ,
"tipo_paro_nombre" : "Falta de material" ,
"minutos" : 20 ,
"descripcion" : "Espera de lote extrusor - lote anterior agotado" ,
"hora_inicio" : "13:00" ,
"hora_fin" : "13:20" ,
"registrado_por" : "Mar \u00ed a L \u00f3 pez"
}
]
}
}
Create Downtime Event
Permission: MANAGE_PRODUCTION
Records a new downtime event.
Request Body
Bit\u00e1cora (shift log) ID
Affected machine ID (optional for process-level downtime)
Downtime type ID (from motivos catalog)
Duration in minutes (must be positive)
Detailed description of the downtime cause (minimum 10 characters)
Start time in HH:MM format (e.g., “10:15”)
End time in HH:MM format (e.g., “11:00”)
Business Rules
Total downtime for a shift cannot exceed programmed time (typically 480 minutes for 8-hour shift)
hora_fin must be after hora_inicio
Calculated duration (hora_fin - hora_inicio) must match minutos field
Downtime events are validated during shift closure
Example Request
curl -X POST https://api.example.com/api/paros \\
-H "Authorization: Bearer <token>" \\
-H "Content-Type: application/json" \\
-d '{
"bitacora_id": 43,
"proceso_id": 2,
"maquina_id": 3,
"tipo_paro_id": 1,
"minutos": 30,
"descripcion": "Falla el\u00e9ctrica en motor principal - requiri\u00f3 reseteo y verificaci\u00f3n",
"hora_inicio": "14:00",
"hora_fin": "14:30"
}'
Example Response
{
"success" : true ,
"data" : {
"id" : 103 ,
"mensaje" : "Paro registrado correctamente"
}
}
Update Downtime Event
Permission: MANAGE_PRODUCTION
Updates an existing downtime event.
Path Parameters
Request Body
Same fields as create, all optional. Only provided fields will be updated.
Cannot update downtime events after shift is closed.
Delete Downtime Event
Permission: MANAGE_PRODUCTION
Deletes a downtime event.
Path Parameters
Business Rules
Can only delete events from open shifts (estado = ABIERTA)
Deletion is logged in audit trail
Consider updating instead of deleting for audit purposes
Example Response
{
"success" : true ,
"data" : {
"mensaje" : "Paro eliminado correctamente"
}
}
Get Downtime Types
Permission: VIEW_PRODUCTION
Returns the catalog of downtime types/categories.
Response
Array of downtime type objects Category: Mec\u00e1nico, El\u00e9ctrico, Operacional, Calidad, Externo
Example Response
{
"success" : true ,
"data" : {
"motivos" : [
{ "id" : 1 , "nombre" : "Falla el \u00e9 ctrica" , "categoria" : "El \u00e9 ctrico" },
{ "id" : 2 , "nombre" : "Falla mec \u00e1 nica" , "categoria" : "Mec \u00e1 nico" },
{ "id" : 3 , "nombre" : "Cambio de orden" , "categoria" : "Operacional" },
{ "id" : 4 , "nombre" : "Falta de material" , "categoria" : "Externo" },
{ "id" : 5 , "nombre" : "Rechazo de calidad" , "categoria" : "Calidad" },
{ "id" : 6 , "nombre" : "Falta de personal" , "categoria" : "Externo" },
{ "id" : 7 , "nombre" : "Limpieza/sanitizaci \u00f3 n" , "categoria" : "Operacional" },
{ "id" : 8 , "nombre" : "Corte de energ \u00ed a" , "categoria" : "Externo" }
]
}
}
Downtime Analysis
OEE Calculation
Downtime data feeds into Overall Equipment Effectiveness (OEE) calculations:
Tiempo Disponible = Tiempo Programado - Paros Externos
Tiempo Operativo = Tiempo Disponible - Paros Internos
Disponibilidad = Tiempo Operativo / Tiempo Disponible
Categorization
Paros Externos (not counted against machine efficiency):
Falta de material
Falta de personal
Corte de energ\u00eda
Sin \u00f3rdenes programadas
Paros Internos (counted against machine efficiency):
Fallas mec\u00e1nicas
Fallas el\u00e9ctricas
Cambios de orden
Rechazos de calidad
Limpieza operacional
Integration with Shift Closure
From bitacora.service.js:45:
async calcularResumenTiempo ( bitacoraId , procesoId ) {
const status = await this . bitacoraRepository . getProcesoStatus ( bitacoraId , procesoId );
const tiempoProgramado = status ? status . tiempo_programado_minutos : 480 ;
const totalParos = await this . paroRepository . sumMinutosByBitacoraAndProceso ( bitacoraId , procesoId );
const tiempoEfectivo = tiempoProgramado - totalParos ;
return {
tiempo_programado: tiempoProgramado ,
total_paros: totalParos ,
tiempo_efectivo: tiempoEfectivo
};
}
Closure Validation (bitacora.service.js:117):
Total downtime cannot exceed programmed time
Negative effective time blocks shift closure
All downtime must have valid motivo and description
Best Practices
Real-Time Recording : Record downtime events as they occur, not at end of shift. This ensures:
Accurate time tracking
Better root cause analysis
Timely response to recurring issues
Detailed Descriptions : Include specific information:
Component/system affected
Symptoms observed
Corrective actions taken
Follow-up required
Time Validation : Ensure hora_inicio and hora_fin match actual events. Inaccurate times distort efficiency metrics and prevent effective analysis.
Error Responses
Validation errors: {
"success" : false ,
"error" : "El tiempo efectivo no puede ser negativo. Total de paros (520 min) excede el tiempo programado (480 min)."
}
Event not found: {
"success" : false ,
"error" : "Paro no encontrado."
}