2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`machineWorker_add`(vPlate VARCHAR(10), vWorkerFk INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inserta registro si el vWorkerFk no ha registrado nada en las últimas 12 horas
|
|
|
|
* @param vPlate número de matrícula
|
|
|
|
* @param vWorkerFk id del worker
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
UPDATE vn.machineWorker mw
|
|
|
|
JOIN vn.machine m ON m.id = mw.machineFk
|
|
|
|
SET mw.outTimed = util.VN_NOW()
|
|
|
|
WHERE (mw.workerFk = vWorkerFk OR m.plate = vPlate)
|
|
|
|
AND ISNULL(mw.outTimed);
|
|
|
|
|
|
|
|
INSERT INTO machineWorker (machineFk, workerFk)
|
|
|
|
SELECT m.id, vWorkerFk
|
|
|
|
FROM machine m
|
|
|
|
WHERE m.plate= vPlate;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|