planning rot

This commit is contained in:
amazuecos
2025-03-27 13:57:37 +01:00
parent e6ce820480
commit 5a5e0be855
11 changed files with 179 additions and 133 deletions

View File

@ -33,7 +33,7 @@ class ProductionService extends BaseService
protected array $MAPPING_DATE_USER = [
"fecha_encuadernado_at" => "encuadernacion_user_id",
// "fecha_externo_at" => "null",
"fecha_impresion_at" => "null",
"fecha_impresion_at" => null,
"pendiente_ferro_at" => "pendiente_ferro_user_id",
"ferro_en_cliente_at" => "ferro_en_cliente_user_id",
"ferro_ok_at" => "ferro_ok_user_id",
@ -44,7 +44,7 @@ class ProductionService extends BaseService
"plastificado_at" => "plastificado_user_id",
"corte_at" => "corte_user_id",
"embalaje_at" => "embalaje_user_id",
"entrada_manipulado_at" => "entrada_manipulado_user_id"
"entrada_manipulado_at" => "entrada_manipulado_user_id"
];
/**
@ -60,13 +60,13 @@ class ProductionService extends BaseService
*/
protected PresupuestoEntity $presupuesto;
public function __construct() {
public function __construct()
{
$this->otModel = model(OrdenTrabajoModel::class);
$this->otDate = model(OrdenTrabajoDate::class);
$this->otTarea = model(OrdenTrabajoTarea::class);
$this->otUser = model(OrdenTrabajoUser::class);
$this->userModel = model(UserModel::class);
}
public function init(int $orden_trabajo_id): self
{
@ -135,7 +135,7 @@ class ProductionService extends BaseService
* @param OrdenTrabajoEntity $ot
* @return integer|boolean|string ID
*/
protected function storeOrdenTrabajoDates() : int|bool|string
protected function storeOrdenTrabajoDates(): int|bool|string
{
$fecha_encuadernado = Time::now()->addDays(2)->format("Y-m-d");
$fecha_entrega_real = Time::now()->addDays(5)->format("Y-m-d");
@ -149,7 +149,7 @@ class ProductionService extends BaseService
"fecha_entrega_externo" => $this->pedido->fecha_entrega_externo,
]);
}
protected function storeOrdenTrabajoUsers() : int|bool|string
protected function storeOrdenTrabajoUsers(): int|bool|string
{
return $this->otUser->insert([
"orden_trabajo_id" => $this->ot->id,
@ -351,7 +351,7 @@ class ProductionService extends BaseService
public function getPdf()
{
return view("themes/vuexy/pdfs/orden_trabajo",$this->getDataPdf());
return view("themes/vuexy/pdfs/orden_trabajo", $this->getDataPdf());
}
/**
* Query para mostrar en datatable
@ -388,7 +388,7 @@ class ProductionService extends BaseService
->orderBy("orden_trabajo_tareas.orden", "ASC");
return $q;
}
/**
/**
* Query para mostrar en datatable
*
* @return BaseBuilder
@ -402,8 +402,8 @@ class ProductionService extends BaseService
"orden_trabajo_tareas.maquina_id",
"lg_maquinas.nombre as maquina_planning_nombre",
"ordenes_trabajo.total_tirada as ot_tirada",
"lg_papel_formato.ancho as maquina_ancho",
"lg_papel_formato.alto as maquina_alto",
"lg_papel_formato.ancho as papel_ancho",
"lg_papel_formato.alto as papel_alto",
// "JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_ancho') as maquina_ancho",
// "JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_alto') as maquina_alto",
"lg_papel_impresion.nombre as papel_impresion",
@ -422,7 +422,7 @@ class ProductionService extends BaseService
->join("lg_maquinas as lgmp", "lgmp.id = presupuesto_linea.maquina_id", "left")
->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id", "left")
// ->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id)
->whereIn("presupuesto_linea.tipo", ["lp_rot_bn","lp_rot_color"])
->whereIn("presupuesto_linea.tipo", ["lp_rot_bn", "lp_rot_color"])
->where("orden_trabajo_tareas.deleted_at", null)
->orderBy("orden_trabajo_tareas.orden", "ASC");
return $q;
@ -461,24 +461,28 @@ class ProductionService extends BaseService
->orderBy("orden_trabajo_tareas.orden", "ASC");
return $q;
}
public function papelGramajeDatatableQuery() : BaseBuilder
public function papelGramajeDatatableQuery(): BaseBuilder
{
$q = $this->otModel->builder()->select([
"lg_papel_impresion.id as papelImpresionId",
"lg_papel_impresion.nombre as papelImpresionNombre",
"lg_papel_impresion.gramaje as papelImpresionGramaje",
"COUNT(orden_trabajo_tareas.id) as tareasCount",
"CAST(JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_ancho') AS DOUBLE) as maquina_ancho",
"CAST(JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_alto') AS DOUBLE) as maquina_alto",
"lg_papel_formato.ancho as papel_ancho",
"lg_papel_formato.alto as papel_alto",
// "CAST(JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_ancho') AS DOUBLE) as maquina_ancho",
// "CAST(JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_alto') AS DOUBLE) as maquina_alto",
"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("lg_papel_impresion","presupuesto_linea.papel_impresion_id = lg_papel_impresion.id","left")
->where("orden_trabajo_tareas.deleted_at", null)
->where("orden_trabajo_tareas.presupuesto_linea_id IS NOT NULL", NULL,FALSE)
->groupBy('lg_papel_impresion.id');
->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_papel_impresion", "presupuesto_linea.papel_impresion_id = lg_papel_impresion.id", "left")
->join("lg_papel_formato", "lg_papel_formato.id = presupuestos.papel_formato_id", "left")
->where("orden_trabajo_tareas.deleted_at", null)
->where("orden_trabajo_tareas.presupuesto_linea_id IS NOT NULL", NULL, FALSE)
->groupBy('lg_papel_impresion.id');
@ -519,7 +523,8 @@ class ProductionService extends BaseService
];
return $summary;
}
public function getDataPdf(){
public function getDataPdf()
{
$logistica_data = $this->logistica_data();
return [
"ot" => $this->ot,
@ -540,88 +545,92 @@ class ProductionService extends BaseService
"peso_pedido" => $logistica_data["peso_pedido"]
];
}
public function getTareaImpresionSobreCubierta() : array
public function getTareaImpresionSobreCubierta(): array
{
$q = $this->otTarea->select('orden_trabajo_tareas.*')
->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left")
->where("orden_trabajo_tareas.orden_trabajo_id",$this->ot->id)
->whereIn("presupuesto_linea.tipo",["lp_sobrecubierta"])->findAll();
->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left")
->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id)
->whereIn("presupuesto_linea.tipo", ["lp_sobrecubierta"])->findAll();
return $q;
}
public function getTareaImpresionCubierta() : array
public function getTareaImpresionCubierta(): array
{
$q = $this->otTarea->select('orden_trabajo_tareas.*')
->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left")
->where("orden_trabajo_tareas.orden_trabajo_id",$this->ot->id)
->whereIn("presupuesto_linea.tipo",["lp_cubierta"])->findAll();
->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left")
->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id)
->whereIn("presupuesto_linea.tipo", ["lp_cubierta"])->findAll();
return $q;
}
public function getTareaImpresionInteriorBn() : array
public function getTareaImpresionInteriorBn(): array
{
$q = $this->otTarea->select('orden_trabajo_tareas.*')
->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left")
->where("orden_trabajo_tareas.orden_trabajo_id",$this->ot->id)
->whereIn("presupuesto_linea.tipo",["lp_rot_bn","lp_bn","lp_bnhq"])->findAll();
->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left")
->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id)
->whereIn("presupuesto_linea.tipo", ["lp_rot_bn", "lp_bn", "lp_bnhq"])->findAll();
return $q;
}
public function getTareaImpresionInteriorColor() : array
public function getTareaImpresionInteriorColor(): array
{
$q = $this->otTarea->select('orden_trabajo_tareas.*')
->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left")
->where("orden_trabajo_tareas.orden_trabajo_id",$this->ot->id)
->whereIn("presupuesto_linea.tipo",["lp_rot_color","lp_color","lp_colorhq"])->findAll();
->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left")
->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id)
->whereIn("presupuesto_linea.tipo", ["lp_rot_color", "lp_color", "lp_colorhq"])->findAll();
return $q;
}
public function getPresupuestoLineaImpresion(){
}
public function getPresupuestoLineaImpresion() {}
public function tareas_acabado(): array
{
$q = $this->otTarea->where("presupuesto_acabado_id IS NOT NULL",NULL,FALSE)->findAll();
$q = $this->otTarea->where("presupuesto_acabado_id IS NOT NULL", NULL, FALSE)->findAll();
return $q;
}
public function tareas_impresion(): array
{
$q = $this->otTarea->where("presupuesto_linea_id IS NOT NULL",NULL,FALSE)->findAll();
$q = $this->otTarea->where("presupuesto_linea_id IS NOT NULL", NULL, FALSE)->findAll();
return $q;
}
public function tareas_encuadernacion(): array
{
$q = $this->otTarea->where("presupuesto_encuadernado_id IS NOT NULL",NULL,FALSE)->findAll();
$q = $this->otTarea->where("presupuesto_encuadernado_id IS NOT NULL", NULL, FALSE)->findAll();
return $q;
}
public function tareas_preimpresion(): array
{
$q = $this->otTarea->where("presupuesto_preimpresion_id IS NOT NULL",NULL,FALSE)->findAll();
$q = $this->otTarea->where("presupuesto_preimpresion_id IS NOT NULL", NULL, FALSE)->findAll();
return $q;
}
public function tareas_manipulado(): array
{
$q = $this->otTarea->where("presupuesto_manipulado_id IS NOT NULL",NULL,FALSE)->findAll();
$q = $this->otTarea->where("presupuesto_manipulado_id IS NOT NULL", NULL, FALSE)->findAll();
return $q;
}
/**========================================================================
* UPDATES
*========================================================================**/
public function updateOrdenTrabajoTarea($tarea_id,$data) : bool
public function updateOrdenTrabajoTarea($tarea_id, $data): bool
{
return $this->otTarea->update($tarea_id,$data);
return $this->otTarea->update($tarea_id, $data);
}
public function updateOrdenTrabajoDate($data)
public function updateOrdenTrabajoDate($data)
{
// return $this->otDate->find($this->ot->id);
$r = $this->otDate->update($this->ot->id,$data);
// // return $this->otDate->find($this->ot->id);
$otDate = $this->otDate->where('orden_trabajo_id', $this->ot->id)
->set([$data['name'] => $data[$data['name']]])
->update($data);
$ot_users = $this->ot->users();
$ot_users = $ot_users->toArray();
$user_id = $ot_users[$this->MAPPING_DATE_USER[$data["name"]]];
$user = $this->userModel->find($user_id);
return ["user" => $user,"status" => $r];
if($this->MAPPING_DATE_USER[$data["name"]]){
$user_id = $ot_users->{$this->MAPPING_DATE_USER[$data["name"]]};
$user = $this->userModel->find($user_id);
return ["user" => $user, "status" => $otDate];
}else{
return ["user" => null, "status" => false];
}
}
public function updateOrdenTrabajo($data) : bool
public function updateOrdenTrabajo($data): bool
{
return $this->otModel->update($this->ot->id,$data);
return $this->otModel->update($this->ot->id, $data);
}
/**========================================================================
* RELATION METHODS
@ -679,7 +688,7 @@ class ProductionService extends BaseService
{
return $this->presupuesto->extras();
}
protected function logistica_data() : array
protected function logistica_data(): array
{
$presupuesto_lineas = $this->presupuesto->presupuestoLineas();
$peso = 0;
@ -688,14 +697,12 @@ class ProductionService extends BaseService
}
return [
"peso_unidad" => $peso,
"peso_pedido" => $peso*$this->ot->total_tirada
"peso_pedido" => $peso * $this->ot->total_tirada
];
}
protected function actionButtonFilterTask(int $id)
{
return ["title" => lang('ot.filter_by_task'),'id' => $id];
}
protected function actionButtonFilterTask(int $id)
{
return ["title" => lang('ot.filter_by_task'), 'id' => $id];
}
}