mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
maquinista view-basic
This commit is contained in:
@ -404,12 +404,29 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
->select([
|
||||
'lg_maquinas.id as maquinaId',
|
||||
'lg_maquinas.nombre',
|
||||
'COUNT(orden_trabajo_tareas.id) as countTareas'
|
||||
'COUNT(tarea_progress.ot_tarea_id) as countTareas'
|
||||
])
|
||||
->join('orden_trabajo_tareas','orden_trabajo_tareas.maquina_id = lg_maquinas.id','left')
|
||||
->join('orden_trabajo_tareas', 'orden_trabajo_tareas.maquina_id = lg_maquinas.id', 'left')
|
||||
->join(
|
||||
"(SELECT ot_tarea_id, estado,deleted_at
|
||||
FROM orden_trabajo_tarea_progress_dates
|
||||
WHERE (ot_tarea_id, created_at) IN (
|
||||
SELECT ot_tarea_id, MAX(created_at)
|
||||
FROM orden_trabajo_tarea_progress_dates
|
||||
WHERE estado = 'P'
|
||||
GROUP BY ot_tarea_id
|
||||
)
|
||||
) as tarea_progress",
|
||||
'tarea_progress.ot_tarea_id = orden_trabajo_tareas.id',
|
||||
'left'
|
||||
)
|
||||
->join('ordenes_trabajo', 'ordenes_trabajo.id = orden_trabajo_tareas.orden_trabajo_id', 'left')
|
||||
->join('pedidos', 'pedidos.id = ordenes_trabajo.pedido_id', 'left')
|
||||
->where('lg_maquinas.tipo', $maquina_tipo)
|
||||
->where('lg_maquinas.deleted_at',null)
|
||||
->groupBy('lg_maquinas.id');
|
||||
->where('lg_maquinas.deleted_at', null)
|
||||
->where('tarea_progress.deleted_at', null)
|
||||
->groupBy('lg_maquinas.id')
|
||||
->orderBy('countTareas','DESC');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user