revision ot v2

This commit is contained in:
amazuecos
2025-05-04 17:25:53 +02:00
parent db70c57fb3
commit fb7f2a28d9
30 changed files with 897 additions and 169 deletions

View File

@ -141,7 +141,8 @@ class Ordentrabajo extends BaseController
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
}
}
public function update_presupuesto_tarea_proveedor(){
public function update_presupuesto_tarea_proveedor()
{
$bodyData = $this->request->getPost();
$validated = $this->validation->run($bodyData, "proveedor_tarea");
if ($validated) {
@ -151,7 +152,6 @@ class Ordentrabajo extends BaseController
} else {
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
}
}
public function reset_orden_trabajo_date()
{
@ -242,7 +242,7 @@ class Ordentrabajo extends BaseController
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery()->whereIn("ordenes_trabajo.estado", ["I", "PM"]);
$q = $this->otModel->getDatatableQuery()->whereIn("ordenes_trabajo.estado", ["I", "PM"])->where('ordenes_trabajo.preimpresion_revisada', true);
// return $this->response->setJSON($q->get()->getResultArray());
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
@ -257,7 +257,7 @@ class Ordentrabajo extends BaseController
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery()->where('presupuestos.ferro',1)->where("ferro_ok_at", null);
$q = $this->otModel->getDatatableQuery()->where('presupuestos.ferro', 1)->where("ferro_ok_at", null);
// return $this->response->setJSON($q->get()->getResultArray());
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
@ -272,7 +272,7 @@ class Ordentrabajo extends BaseController
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery()->where('presupuestos.ferro',1)->where("ferro_ok_at is NOT NULL", NULL, FALSE);
$q = $this->otModel->getDatatableQuery()->where('presupuestos.ferro', 1)->where("ferro_ok_at is NOT NULL", NULL, FALSE);
// return $this->response->setJSON($q->get()->getResultArray());
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
@ -287,7 +287,7 @@ class Ordentrabajo extends BaseController
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery()->where('ordenes_trabajo.preimpresion_revisada',false);
$q = $this->otModel->getDatatableQuery()->where('ordenes_trabajo.preimpresion_revisada', false);
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
@ -301,7 +301,7 @@ class Ordentrabajo extends BaseController
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery()->where('presupuestos.ferro',1)->where("ferro_ok_at is NOT NULL", NULL, FALSE);
$q = $this->otModel->getDatatableQuery()->where('ordenes_trabajo.preimpresion_revisada', true)->where('pedidos.estado', 'produccion');
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
@ -315,7 +315,7 @@ class Ordentrabajo extends BaseController
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery()->where('ordenes_trabajo.is_pedido_espera',1);
$q = $this->otModel->getDatatableQuery()->where('ordenes_trabajo.is_pedido_espera', 1);
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
@ -329,7 +329,7 @@ class Ordentrabajo extends BaseController
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery()->where('presupuestos.ferro',1)->where("ferro_ok_at is NOT NULL", NULL, FALSE);
$q = $this->otModel->getDatatableQuery()->where('presupuestos.ferro', 1)->where("ferro_ok_at is NOT NULL", NULL, FALSE);
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
@ -374,6 +374,7 @@ class Ordentrabajo extends BaseController
return DataTable::of($q)
->add("action", fn($q) => $q)
->edit("orden", fn($q) => ["id" => $q->id, "orden" => $q->orden])
->add("tarea_estado", fn($q) => $this->produccionService->getTitleTareaEstado($q->id))
->edit("tiempo_estimado", fn($q) => float_seconds_to_hhmm_string($q->tiempo_estimado))
->edit("tiempo_real", fn($q) => float_seconds_to_hhmm_string($q->tiempo_real))
->add("proveedor", fn($q) => $this->produccionService->getProveedorTarea($q->id))
@ -602,6 +603,19 @@ class Ordentrabajo extends BaseController
$this->viewData["maquinaEntity"] = $maquina;
return view(static::$viewPath . '/maquinista/viewMaquinistaMaquinaTareas', $this->viewData);
}
public function maquinista_maquina_tareas_fichaje_automatico(int $maquina_id)
{
$maquina = $this->maquinaModel->find($maquina_id);
$this->viewData["maquinaEntity"] = $maquina;
return view(static::$viewPath . '/maquinista/viewMaquinistaFichajeAutomatico', $this->viewData);
}
public function maquinista_maquina_tareas_scan(int $maquina_id)
{
$maquina = $this->maquinaModel->find($maquina_id);
$this->viewData["maquinaEntity"] = $maquina;
return view(static::$viewPath . '/maquinista/viewMaquinistaTareaScan', $this->viewData);
}
public function maquinista_maquina_tarea_view(int $orden_trabajo_tarea_id)
{
$otTareaEntity = $this->otTarea->find($orden_trabajo_tarea_id);
@ -629,6 +643,16 @@ class Ordentrabajo extends BaseController
}
return DataTable::of($pm)
->edit('fecha_impresion', fn($q) => $q->fecha_impresion ? Time::createFromFormat('Y-m-d H:i:s', $q->fecha_impresion)->format('d/m/Y') : '')
->add("tareaEstado", fn($q) => $this->produccionService->getTitleTareaEstado($q->ot_tarea_id))
->add('action', fn($q) => $this->produccionService->buttonActionDatatableTareaList($q->ot_tarea_id))
->toJson(true);
}
public function maquinista_maquina_tareas_aplazada_datatable(int $maquina_id)
{
$pm = $this->produccionService->getMaquinaImpresionTareasList($maquina_id)->where("tarea_progress.estado", 'D');
return DataTable::of($pm)
->edit('fecha_impresion', fn($q) => $q->fecha_impresion ? Time::createFromFormat('Y-m-d H:i:s', $q->fecha_impresion)->format('d/m/Y') : '')
->add("tareaEstado", fn($q) => $this->produccionService->getTitleTareaEstado($q->ot_tarea_id))
->add('action', fn($q) => $this->produccionService->buttonActionDatatableTareaList($q->ot_tarea_id))
->toJson(true);
}
@ -639,13 +663,12 @@ class Ordentrabajo extends BaseController
try {
$bodyData = $this->request->getPost();
$validated = $this->validation->run($bodyData, "orden_trabajo_tarea_progress_date");
// return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "data" => $this->validation->getValidated(),"errors" => $this->validation->getErrors()]);
if ($validated) {
$validatedData = $this->validation->getValidated();
$r = $this->produccionService->storeOrdenTrabajoTareaProgressDate($validatedData);
$otTareaEntity = $this->otTarea->find($validatedData['ot_tarea_id']);
$data = [
"tiempo_trabajado" => float_seconds_to_hhmm_string($otTareaEntity->tiempo_trabajado()),
"tiempo_trabajado" => float_seconds_to_hhmm_string($otTareaEntity->tiempo_real),
"tarea" => $otTareaEntity,
"estado" => $validatedData['estado'],
];
@ -673,20 +696,65 @@ class Ordentrabajo extends BaseController
}
public function update_pod_pedido_dates($orden_trabajo_id)
{
$this->produccionService->init($orden_trabajo_id);
if($this->produccionService->isPOD){
if ($this->produccionService->isPOD) {
$status = $this->produccionService->updatePodDates();
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $status, "data" => $this->produccionService->getPedido()]);
}else{
} else {
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => false, "data" => $this->produccionService->getPedido()]);
}
}
public function get_orden_trabajo_tareas_dates($orden_trabajo_id)
{
$data = $this->produccionService->init($orden_trabajo_id)->getOrdenTrabajoTareaDates();
return $this->response->setJSON(["data" => $data ]);
return $this->response->setJSON(["data" => $data]);
}
public function get_tareas_ot_maquina(int $orden_trabajo_id, int $maquina_id)
{
$tareasWithMaquina = $this->produccionService->init($orden_trabajo_id)->getTareasWithMaquina($maquina_id, ['P', 'I', 'S', 'D']);
if ($tareasWithMaquina) {
$data = [
'tareas' => $tareasWithMaquina,
'ot' => $this->produccionService->getOrdenTrabajo(),
'presupuesto' => $this->produccionService->getPresupuesto()
];
return $this->response->setJSON(["message" => lang("App.global_alert_fetch_success"), "data" => $data]);
} else {
$tareasWithMaquina = $this->produccionService->init($orden_trabajo_id)->getTareasWithMaquina($maquina_id, ['F']);
if($tareasWithMaquina){
return $this->response->setJSON(["message" => lang("Produccion.errors.tareas_finalizadas"), "data" => $tareasWithMaquina])->setStatusCode(400);
}else{
return $this->response->setJSON(["message" => lang("Produccion.errors.maquina_not_in_ot"), "data" => null])->setStatusCode(400);
}
}
}
public function update_orden_trabajo_fa_tareas()
{
$bodyData = $this->request->getPost();
$validated = $this->validation->run($bodyData, "orden_trabajo_fichaje_auto");
if ($validated) {
$validatedData = $this->validation->getValidated();
$this->produccionService->init($validatedData['orden_trabajo_id']);
foreach ($validatedData['tareas'] as $key => $tareaId) {
$this->produccionService->storeOrdenTrabajoTareaProgressDate(
[
'estado' => 'F',
'ot_tarea_id' => $tareaId
]
);
$tareaEntity = $this->otTarea->find($tareaId);
$tiempo_trabajado = $tareaEntity->tiempo_trabajado();
$tareaEntity->tiempo_real = $tiempo_trabajado / count($validatedData['tareas']);
$tareaEntity->click_init = $validatedData['click_init'] / count($validatedData['tareas']);
$tareaEntity->click_end = $validatedData['click_end'] / count($validatedData['tareas']);
$this->otTarea->save($tareaEntity);
}
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true, "data" => $validatedData]);
} else {
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
}
}
}