feat: add filter maquina plana

This commit is contained in:
amazuecos
2025-05-30 11:45:48 +02:00
parent cd0a1c3c2a
commit 52c53e6920
7 changed files with 159 additions and 36 deletions

View File

@ -822,6 +822,7 @@ $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], func
$routes->get('rotativa', 'Ordentrabajo::index_planning_rotativa');
$routes->get('papel/datatable', 'Ordentrabajo::papel_gramaje_datatable');
$routes->get('papel/plana/datatable', 'Ordentrabajo::papel_pliego_datatable');
$routes->get('maquina/plana/datatable', 'Ordentrabajo::maquina_plana_datatable');
$routes->get('rotativa/datatable', 'Ordentrabajo::planning_rotativa_datatable');
$routes->get('plana/datatable', 'Ordentrabajo::planning_plana_datatable');
$routes->post('tarea/toggle/corte/(:num)', 'Ordentrabajo::tarea_toggle_corte/$1');

View File

@ -372,6 +372,15 @@ class Ordentrabajo extends BaseController
->add("action", fn($q) => ["title" => lang('Produccion.datatable.filter_by_paper'), 'data' => $q])
->toJson(true);
}
public function maquina_plana_datatable()
{
// return $this->response->setStatusCode(400);
$q = $this->produccionService->maquinaPlanaDatatableQuery();
return DataTable::of($q)
->edit("tiempoReal", fn($q) => $q->tiempoReal)
->add("action", fn($q) => ["title" => lang('Produccion.datatable.filter_by_machine'), 'data' => $q])
->toJson(true);
}
public function reset_tareas(int $orden_trabajo_id)
{
$r = $this->produccionService->init($orden_trabajo_id)->resetAllTareas();

View File

@ -13,6 +13,7 @@ return [
'prod' => 'Producción'
],
"datatable" => [
"nombre" => "Nombre",
"ot_id" => "OT ID",
"barcode" => "Código",
"pedido_id" => "Pedido ID",
@ -38,6 +39,7 @@ return [
"progreso" => "Progreso",
"logo" => "Logo impresion",
"filter_by_task" => "Filtrar por tarea",
"filter_by_machine" => "Filtrar por máquina",
"filter_by_paper" => "Filtrar por papel",
"metros" => "Metros",
"corte" => "Corte",
@ -141,7 +143,7 @@ return [
"attr_not_exist" => "El atributo {0,string} no pertenece al modelo Pedido"
],
"maquinas_planas" => "Máquinas planas",
"progress_ferro" => "Ferro",
"progress_preimpresion" => "Preimpresión",
"progress_logistica" => "Logística",

View File

@ -913,6 +913,29 @@ class ProductionService extends BaseService
return $q;
}
public function maquinaPlanaDatatableQuery()
{
$q = $this->otModel->builder()->select([
"lg_maquinas.nombre as maquinaNombre",
"lg_maquinas.id as maquinaId",
"COUNT(orden_trabajo_tareas.id) as tareasCount",
"presupuesto_linea.pliegos_pedido as pliegosPedido",
"SUM(ordenes_trabajo.total_tirada) as totalTirada",
"SUM(orden_trabajo_tareas.tiempo_real) as tiempoReal"
])
->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left")
->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left")
->join("presupuestos", "presupuestos.id = presupuesto_linea.presupuesto_id", "right")
->join('lg_maquinas',"lg_maquinas.id = orden_trabajo_tareas.maquina_id","left")
->where("orden_trabajo_tareas.deleted_at", null)
->where("orden_trabajo_tareas.presupuesto_linea_id IS NOT NULL", NULL, FALSE)
->whereIn("presupuesto_linea.tipo", $this->TIPOS_PLANA)
->groupBy('lg_maquinas.id');
return $q;
}
/**
@ -1323,7 +1346,8 @@ class ProductionService extends BaseService
->whereIn("presupuesto_linea.tipo", $this->TIPOS_ROTATIVA)
->where('lg_maquinas.is_rotativa', true)
->where("orden_trabajo_tareas.deleted_at", null)
->orderBy("orden_trabajo_tareas.orden", "ASC");
->orderBy("orden_trabajo_tareas.orden", "ASC")
->groupBy('lg_maquinas.id');
if ($q) {
$query->like('lg_maquinas.nombre', $q);
}
@ -1341,7 +1365,8 @@ class ProductionService extends BaseService
->whereIn("presupuesto_linea.tipo", $this->TIPOS_PLANA)
->where('lg_maquinas.is_rotativa', false)
->where("orden_trabajo_tareas.deleted_at", null)
->orderBy("orden_trabajo_tareas.orden", "ASC");
->orderBy("orden_trabajo_tareas.orden", "ASC")
->groupBy('lg_maquinas.id');
if ($q) {
$query->like('lg_maquinas.nombre', $q);
}

View File

@ -0,0 +1,28 @@
<div class="table-responsive">
<table id="<?= $id ?>" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('Produccion.datatable.nombre') ?></th>
<th><?= lang('Produccion.datatable.tareas') ?></th>
<th><?= lang('Produccion.datatable.tirada') ?></th>
<th><?= lang('Produccion.datatable.pliegos_libro') ?></th>
<th><?= lang('Produccion.datatable.tiempo') ?>(HH:MM)</th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<th colspan="3" style="text-align:right">Total:</th>
<th><span id="total-pliegos-maquina"></span></th>
<th id="total-tiempo-pliego-maquina"></th>
<th></th>
</tr>
</tfoot>
</table>
</div>

View File

@ -76,14 +76,17 @@
<button type="button" class="accordion-button" data-bs-toggle="collapse"
data-bs-target="#accordionPapelPliegoContainer" aria-expanded="false"
aria-controls="accordionPapelPliegoContainer">
<h4><?= lang("Produccion.papel_gramajes") ?></h4>
<h4><?= lang("Produccion.maquinas_planas") ?></h4>
</button>
</h2>
<div id="accordionPapelPliegoContainer" class="accordion-collapse collapse show"
data-bs-parent="#accordionPapelPliego">
<div class="accordion-body">
<?= view("themes/vuexy/components/tables/planning_papel_pliego_table.php", ["id" => "planning-pliego-datatable"]) ?>
<div class="d-none">
<?= view("themes/vuexy/components/tables/planning_papel_pliego_table.php", ["id" => "planning-pliego-datatable"]) ?>
</div>
<?= view("themes/vuexy/components/tables/planning_maquina_table.php", ["id" => "planning-maquina-datatable"]) ?>
</div>
</div>
</div>