mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
toggle corte rotativa planning
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Database\Migrations\ConfigVariablesApp;
|
||||
use App\Entities\Clientes\ClienteEntity;
|
||||
use App\Entities\Pedidos\PedidoEntity;
|
||||
use App\Entities\Presupuestos\PresupuestoEntity;
|
||||
@ -15,6 +16,7 @@ use App\Models\Usuarios\UserModel;
|
||||
use CodeIgniter\Config\BaseService;
|
||||
use App\Entities\Configuracion\Maquina as MaquinaEntity;
|
||||
use App\Entities\Produccion\OrdenTrabajoTareaEntity;
|
||||
use App\Models\Configuracion\ConfigVariableModel;
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
use CodeIgniter\Database\BaseResult;
|
||||
@ -208,8 +210,8 @@ class ProductionService extends BaseService
|
||||
$ot_tareas["orden"] = $p_linea_maquina->orden_planning ?? 0;
|
||||
$ot_tareas["maquina_id"] = $p_linea_maquina->id;
|
||||
$ot_tareas["imposicion_id"] = null;
|
||||
$ot_tareas["tiempo_estimado"] = $p_linea->horas_maquina*3600;
|
||||
$ot_tareas["tiempo_real"] = $p_linea->horas_maquina*3600; //? Tiempo real se inserta manual?
|
||||
$ot_tareas["tiempo_estimado"] = $p_linea->horas_maquina * 3600;
|
||||
$ot_tareas["tiempo_real"] = $p_linea->horas_maquina * 3600; //? Tiempo real se inserta manual?
|
||||
$insert_query_result = $this->otTarea->insert($ot_tareas);
|
||||
$ot_tareas = [];
|
||||
$this->storeTareaCorte($p_linea);
|
||||
@ -226,8 +228,10 @@ class ProductionService extends BaseService
|
||||
'nombre' => 'Corte',
|
||||
'maquina_id' => $this->defaultMaquinaCorte->id,
|
||||
'orden' => $this->defaultMaquinaCorte->orden_planning,
|
||||
'tiempo_estimado' => $pLinea->rotativa_tiempo_corte*60,
|
||||
'tiempo_real' => $pLinea->rotativa_tiempo_corte*60
|
||||
'tiempo_estimado' => $pLinea->rotativa_tiempo_corte * 60,
|
||||
'tiempo_real' => $pLinea->rotativa_tiempo_corte * 60,
|
||||
'is_corte' => true,
|
||||
'tipo_corte' => "bobina",
|
||||
]);
|
||||
$otCorte = $this->otTarea->find($tareaId);
|
||||
}
|
||||
@ -293,15 +297,15 @@ class ProductionService extends BaseService
|
||||
$p_linea_maquinas = $p_linea->maquinas();
|
||||
$ot_tareas = [];
|
||||
if (count($p_linea_maquinas) > 0) {
|
||||
$linea_maquina = $p_linea_maquinas[0]; //Se obtiene la primera máquina aunque tenga varias
|
||||
$ot_tareas["orden_trabajo_id"] = $this->ot->id;
|
||||
$ot_tareas["presupuesto_preimpresion_id"] = $p_linea->id;
|
||||
$ot_tareas["nombre"] = $p_linea->tarifa()->nombre;
|
||||
$ot_tareas["orden"] = $linea_maquina->orden_planning ?? 100;
|
||||
$ot_tareas["maquina_id"] = $linea_maquina->id;
|
||||
$ot_tareas["imposicion_id"] = null;
|
||||
$this->otTarea->insert($ot_tareas);
|
||||
$ot_tareas = [];
|
||||
$linea_maquina = $p_linea_maquinas[0]; //Se obtiene la primera máquina aunque tenga varias
|
||||
$ot_tareas["orden_trabajo_id"] = $this->ot->id;
|
||||
$ot_tareas["presupuesto_preimpresion_id"] = $p_linea->id;
|
||||
$ot_tareas["nombre"] = $p_linea->tarifa()->nombre;
|
||||
$ot_tareas["orden"] = $linea_maquina->orden_planning ?? 100;
|
||||
$ot_tareas["maquina_id"] = $linea_maquina->id;
|
||||
$ot_tareas["imposicion_id"] = null;
|
||||
$this->otTarea->insert($ot_tareas);
|
||||
$ot_tareas = [];
|
||||
} else {
|
||||
$ot_tareas["orden_trabajo_id"] = $this->ot->id;
|
||||
$ot_tareas["presupuesto_preimpresion_id"] = $p_linea->id;
|
||||
@ -319,15 +323,15 @@ class ProductionService extends BaseService
|
||||
$p_linea_maquinas = $p_linea->maquinas();
|
||||
$ot_tareas = [];
|
||||
if (count($p_linea_maquinas) > 0) {
|
||||
$linea_maquina = $p_linea_maquinas[0]; //Se obtiene la primera máquina aunque tenga varias
|
||||
$ot_tareas["orden_trabajo_id"] = $this->ot->id;
|
||||
$ot_tareas["presupuesto_encuadernado_id"] = $p_linea->id;
|
||||
$ot_tareas["nombre"] = $p_linea->tarifa()->nombre;
|
||||
$ot_tareas["orden"] = $linea_maquina->orden_planning ?? 110;
|
||||
$ot_tareas["maquina_id"] = $linea_maquina->id;
|
||||
$ot_tareas["imposicion_id"] = null;
|
||||
$this->otTarea->insert($ot_tareas);
|
||||
$ot_tareas = [];
|
||||
$linea_maquina = $p_linea_maquinas[0]; //Se obtiene la primera máquina aunque tenga varias
|
||||
$ot_tareas["orden_trabajo_id"] = $this->ot->id;
|
||||
$ot_tareas["presupuesto_encuadernado_id"] = $p_linea->id;
|
||||
$ot_tareas["nombre"] = $p_linea->tarifa()->nombre;
|
||||
$ot_tareas["orden"] = $linea_maquina->orden_planning ?? 110;
|
||||
$ot_tareas["maquina_id"] = $linea_maquina->id;
|
||||
$ot_tareas["imposicion_id"] = null;
|
||||
$this->otTarea->insert($ot_tareas);
|
||||
$ot_tareas = [];
|
||||
} else {
|
||||
$ot_tareas["orden_trabajo_id"] = $this->ot->id;
|
||||
$ot_tareas["presupuesto_encuadernado_id"] = $p_linea->id;
|
||||
@ -345,15 +349,15 @@ class ProductionService extends BaseService
|
||||
$p_linea_maquinas = $p_linea->maquinas();
|
||||
$ot_tareas = [];
|
||||
if (count($p_linea_maquinas) > 0) {
|
||||
$linea_maquina = $p_linea_maquinas[0]; //Se obtiene la primera máquina aunque tenga varias
|
||||
$ot_tareas["orden_trabajo_id"] = $this->ot->id;
|
||||
$ot_tareas["presupuesto_extra_id"] = $p_linea->id;
|
||||
$ot_tareas["nombre"] = $p_linea->tarifa()->nombre;
|
||||
$ot_tareas["orden"] = $linea_maquina->orden_planning ?? 0;
|
||||
$ot_tareas["maquina_id"] = $linea_maquina->id;
|
||||
$ot_tareas["imposicion_id"] = null;
|
||||
$this->otTarea->insert($ot_tareas);
|
||||
$ot_tareas = [];
|
||||
$linea_maquina = $p_linea_maquinas[0]; //Se obtiene la primera máquina aunque tenga varias
|
||||
$ot_tareas["orden_trabajo_id"] = $this->ot->id;
|
||||
$ot_tareas["presupuesto_extra_id"] = $p_linea->id;
|
||||
$ot_tareas["nombre"] = $p_linea->tarifa()->nombre;
|
||||
$ot_tareas["orden"] = $linea_maquina->orden_planning ?? 0;
|
||||
$ot_tareas["maquina_id"] = $linea_maquina->id;
|
||||
$ot_tareas["imposicion_id"] = null;
|
||||
$this->otTarea->insert($ot_tareas);
|
||||
$ot_tareas = [];
|
||||
} else {
|
||||
$ot_tareas["orden_trabajo_id"] = $this->ot->id;
|
||||
$ot_tareas["presupuesto_extra_id"] = $p_linea->id;
|
||||
@ -715,7 +719,7 @@ class ProductionService extends BaseService
|
||||
|
||||
public function updateOrdenTrabajoTarea($tarea_id, $data): bool
|
||||
{
|
||||
if(isset($data['maquina_id'])){
|
||||
if (isset($data['maquina_id'])) {
|
||||
$maquina = model(MaquinaModel::class)->find($data['maquina_id']);
|
||||
$data['orden'] = $maquina->orden_planning;
|
||||
}
|
||||
@ -821,7 +825,8 @@ class ProductionService extends BaseService
|
||||
return ["title" => lang('ot.filter_by_task'), 'id' => $id];
|
||||
}
|
||||
|
||||
public function querySelectMaquinaPlanningRotativa($q){
|
||||
public function querySelectMaquinaPlanningRotativa($q)
|
||||
{
|
||||
$query = $this->otModel->builder()->select([
|
||||
"orden_trabajo_tareas.maquina_id as id",
|
||||
"lg_maquinas.nombre as name",
|
||||
@ -833,12 +838,13 @@ class ProductionService extends BaseService
|
||||
->where('lg_maquinas.is_rotativa', true)
|
||||
->where("orden_trabajo_tareas.deleted_at", null)
|
||||
->orderBy("orden_trabajo_tareas.orden", "ASC");
|
||||
if($q){
|
||||
$query->like('lg_maquinas.nombre',$q);
|
||||
if ($q) {
|
||||
$query->like('lg_maquinas.nombre', $q);
|
||||
}
|
||||
return $query->get()->getResultArray();
|
||||
}
|
||||
public function querySelectMaquinaPlanningPlana($q){
|
||||
public function querySelectMaquinaPlanningPlana($q)
|
||||
{
|
||||
$query = $this->otModel->builder()->select([
|
||||
"orden_trabajo_tareas.maquina_id as id",
|
||||
"lg_maquinas.nombre as name",
|
||||
@ -851,12 +857,13 @@ class ProductionService extends BaseService
|
||||
->where('lg_maquinas.is_rotativa', false)
|
||||
->where("orden_trabajo_tareas.deleted_at", null)
|
||||
->orderBy("orden_trabajo_tareas.orden", "ASC");
|
||||
if($q){
|
||||
$query->like('lg_maquinas.nombre',$q);
|
||||
if ($q) {
|
||||
$query->like('lg_maquinas.nombre', $q);
|
||||
}
|
||||
return $query->get()->getResultArray();
|
||||
}
|
||||
public function querySelectPapelPlanningRot(string $q){
|
||||
public function querySelectPapelPlanningRot(string $q)
|
||||
{
|
||||
$query = $this->otModel->builder()->select([
|
||||
"lg_papel_impresion.id",
|
||||
"lg_papel_impresion.nombre as name",
|
||||
@ -870,12 +877,13 @@ class ProductionService extends BaseService
|
||||
->where("orden_trabajo_tareas.presupuesto_linea_id IS NOT NULL", NULL, FALSE)
|
||||
->whereIn("presupuesto_linea.tipo", $this->TIPOS_ROTATIVA)
|
||||
->groupBy('lg_papel_impresion.id');
|
||||
if($q){
|
||||
$query->like('lg_papel_impresion.nombre',$q);
|
||||
if ($q) {
|
||||
$query->like('lg_papel_impresion.nombre', $q);
|
||||
}
|
||||
return $query->get()->getResultArray();
|
||||
}
|
||||
public function querySelectPapelPlanningPlana($q){
|
||||
public function querySelectPapelPlanningPlana($q)
|
||||
{
|
||||
$query = $this->otModel->builder()->select([
|
||||
"lg_papel_impresion.id",
|
||||
"lg_papel_impresion.nombre as name",
|
||||
@ -889,11 +897,33 @@ class ProductionService extends BaseService
|
||||
->where("orden_trabajo_tareas.presupuesto_linea_id IS NOT NULL", NULL, FALSE)
|
||||
->whereIn("presupuesto_linea.tipo", $this->TIPOS_PLANA)
|
||||
->groupBy('lg_papel_impresion.id');
|
||||
if($q){
|
||||
$query->like('lg_papel_impresion.nombre',$q);
|
||||
if ($q) {
|
||||
$query->like('lg_papel_impresion.nombre', $q);
|
||||
}
|
||||
return $query->get()->getResultArray();
|
||||
}
|
||||
|
||||
|
||||
public function tareaUpdateMaquinaCorte($orden_trabajo_id): bool
|
||||
{
|
||||
$cvm = model(ConfigVariableModel::class);
|
||||
$otTarea = $this->otTarea->where('orden_trabajo_id', $orden_trabajo_id)->where('is_corte', true)->first();
|
||||
$toggleCorte = "bobina";
|
||||
if ($otTarea->tipo_corte == "bobina") {
|
||||
$maquina_id = $cvm->where('name', "id_maquina_guillotina_corte_ot_tarea")->first()["value"];
|
||||
$toggleCorte = "guillotina";
|
||||
} elseif ($otTarea->tipo_corte == "guillotina") {
|
||||
$maquina_id = $cvm->where('name', "id_maquina_bobina_corte_ot_tarea")->first()["value"];
|
||||
$toggleCorte = "bobina";
|
||||
} else {
|
||||
$maquina_id = null;
|
||||
}
|
||||
return $this->otTarea
|
||||
->where('orden_trabajo_id', $orden_trabajo_id)
|
||||
->where('is_corte', true)
|
||||
->set(["maquina_id" => $maquina_id, "tipo_corte" => $toggleCorte])
|
||||
->update();
|
||||
}
|
||||
public function ordenTrabajoTareaCorte(int $ot_id): ?string
|
||||
{
|
||||
return $this->otTarea->where('orden_trabajo_id', $ot_id)->where('is_corte', true)?->first()->tipo_corte ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user