mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'fix/orden_trabajo_tareas_tiempo_estimado' into 'main'
solucionado el problema que al borrar una fecha de la OT se quedaba en caché... See merge request jjimenez/safekat!853
This commit is contained in:
@ -116,6 +116,8 @@ class Ordentrabajo extends BaseController
|
||||
$bodyData = $this->request->getPost();
|
||||
$validated = $this->validation->run($bodyData, "orden_trabajo_tarea");
|
||||
if ($validated) {
|
||||
$tareaEntity = $this->otTarea->find($bodyData["orden_trabajo_tarea_id"]);
|
||||
$this->produccionService->init($tareaEntity->orden_trabajo_id);
|
||||
$r = $this->produccionService->updateOrdenTrabajoTarea($bodyData["orden_trabajo_tarea_id"], $bodyData);
|
||||
$tareaEntity = $this->otTarea->find($bodyData["orden_trabajo_tarea_id"]);
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $tareaEntity]);
|
||||
@ -167,6 +169,7 @@ class Ordentrabajo extends BaseController
|
||||
if ($validated) {
|
||||
$validatedData = $bodyData;
|
||||
$r = $this->produccionService->emptyOrdenTrabajoDate($validatedData['orden_trabajo_id'], $validatedData['name']);
|
||||
$this->produccionService->init($validatedData['orden_trabajo_id']); // Re-init service to update the state of the OT
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "user" => auth()->user(), "data" => $bodyData]);
|
||||
} else {
|
||||
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
|
||||
|
||||
@ -450,7 +450,7 @@ class ProductionService extends BaseService
|
||||
'nombre' => lang('Produccion.end_cut'),
|
||||
'maquina_id' => $maquina_id,
|
||||
'orden' => $maquinaCorteEntity->orden_planning,
|
||||
'tiempo_estimado' => $this->tiempoCorteFinalEstimado($maquinaCorteEntity),
|
||||
'tiempo_estimado' => $this->tiempoEstimadoPorUnidad($maquinaCorteEntity),
|
||||
'tiempo_real' => 0,
|
||||
'is_corte' => true,
|
||||
'tipo_corte' => "bobina",
|
||||
@ -546,12 +546,14 @@ class ProductionService extends BaseService
|
||||
$ot_tareas = [];
|
||||
if (count($p_linea_maquinas) > 0) {
|
||||
$linea_maquina = $p_linea_maquinas[0]; //Se obtiene la primera máquina aunque tenga varias
|
||||
$maquinaEntity = $this->maquinaModel->find($linea_maquina->id);
|
||||
$ot_tareas["orden_trabajo_id"] = $this->ot->id;
|
||||
$ot_tareas["presupuesto_acabado_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;
|
||||
$ot_tareas['tiempo_estimado'] = $this->tiempoEstimadoPorUnidad($maquinaEntity);
|
||||
$this->otTarea->insert($ot_tareas);
|
||||
$ot_tareas = [];
|
||||
} else {
|
||||
@ -577,12 +579,14 @@ class ProductionService extends BaseService
|
||||
$ot_tareas = [];
|
||||
if (count($p_linea_maquinas) > 0) {
|
||||
$linea_maquina = $p_linea_maquinas[0]; //Se obtiene la primera máquina aunque tenga varias
|
||||
$maquinaEntity = $this->maquinaModel->find($linea_maquina->id);
|
||||
$ot_tareas["orden_trabajo_id"] = $this->ot->id;
|
||||
$ot_tareas["presupuesto_manipulado_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;
|
||||
$ot_tareas['tiempo_estimado'] = $this->tiempoEstimadoPorUnidad($maquinaEntity);
|
||||
$this->otTarea->insert($ot_tareas);
|
||||
$ot_tareas = [];
|
||||
} else {
|
||||
@ -608,12 +612,14 @@ class ProductionService extends BaseService
|
||||
$ot_tareas = [];
|
||||
if (count($p_linea_maquinas) > 0) {
|
||||
$linea_maquina = $p_linea_maquinas[0]; //Se obtiene la primera máquina aunque tenga varias
|
||||
$maquinaEntity = $this->maquinaModel->find($linea_maquina->id);
|
||||
$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;
|
||||
$ot_tareas['tiempo_estimado'] = $this->tiempoEstimadoPorUnidad($maquinaEntity);
|
||||
$this->otTarea->insert($ot_tareas);
|
||||
$ot_tareas = [];
|
||||
} else {
|
||||
@ -639,12 +645,18 @@ class ProductionService extends BaseService
|
||||
$ot_tareas = [];
|
||||
if (count($p_linea_maquinas) > 0) {
|
||||
$linea_maquina = $p_linea_maquinas[0]; //Se obtiene la primera máquina aunque tenga varias
|
||||
$maquinaEntity = $this->maquinaModel->find($linea_maquina->id);
|
||||
$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["tiempo_estimado"] = $p_linea->tiempo;
|
||||
if($p_linea->tiempo <= 0){
|
||||
$ot_tareas["tiempo_estimado"] = $this->tiempoEstimadoPorUnidad($maquinaEntity);
|
||||
}
|
||||
else{
|
||||
$ot_tareas["tiempo_estimado"] = $p_linea->tiempo*3600; // El manipulado viene en horas
|
||||
}
|
||||
$ot_tareas["tiempo_real"] = $p_linea->tiempo;
|
||||
$ot_tareas["imposicion_id"] = null;
|
||||
$this->otTarea->insert($ot_tareas);
|
||||
@ -1115,6 +1127,11 @@ class ProductionService extends BaseService
|
||||
|
||||
public function updateOrdenTrabajoTarea($tarea_id, $data): bool
|
||||
{
|
||||
$tareaEntity = $this->otTarea->find($tarea_id);
|
||||
if(isset($data['maquina_id']) && $tareaEntity->maquina_id != $data['maquina_id']) {
|
||||
$maquinaEntity = $this->maquinaModel->find($data['maquina_id']);
|
||||
$data['tiempo_estimado'] = $this->tiempoEstimadoPorUnidad($maquinaEntity);
|
||||
}
|
||||
if (isset($data['maquina_id'])) {
|
||||
$maquina = model(MaquinaModel::class)->find($data['maquina_id']);
|
||||
$data['orden'] = $maquina->orden_planning;
|
||||
@ -2424,7 +2441,7 @@ class ProductionService extends BaseService
|
||||
* @param MaquinaEntity $maquina
|
||||
* @return float $seconds
|
||||
*/
|
||||
public function tiempoCorteFinalEstimado(MaquinaEntity $maquina): float
|
||||
public function tiempoEstimadoPorUnidad(MaquinaEntity $maquina): float
|
||||
{
|
||||
$seconds = 0;
|
||||
if ($this->presupuesto->tirada > 0) {
|
||||
|
||||
Reference in New Issue
Block a user