2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machineWorker_getHistorical`(vPlate VARCHAR(20), vWorkerFk INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Obtiene historial de la matrícula vPlate que el trabajador vWorkerFk escanea,
|
|
|
|
* si es jefe de producción muestra el historial completo.
|
|
|
|
*
|
|
|
|
* @param vPlate número de matrícula
|
|
|
|
* @param vWorkerFk id del trabajador
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
DECLARE vWorkerName VARCHAR(255) DEFAULT account.user_getNameFromId(vWorkerFk);
|
|
|
|
|
|
|
|
SELECT mw.inTimed,account.user_getNameFromId(mw.workerFk) as workerName, mw.outTimed
|
|
|
|
FROM machineWorker mw
|
|
|
|
JOIN machine m ON m.plate = vPlate
|
|
|
|
WHERE mw.machineFk = m.id
|
|
|
|
AND mw.workerFk = IF(account.user_hasRole(vWorkerName, 'coolerAssist'), mw.workerFk, vWorkerFk)
|
|
|
|
ORDER BY mw.inTimed DESC;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|