32 lines
919 B
SQL
32 lines
919 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `srt`.`expedition_getDayMinute`(vExpeditionFk INT)
|
|
RETURNS int(11)
|
|
NOT DETERMINISTIC
|
|
READS SQL DATA
|
|
BEGIN
|
|
|
|
/**
|
|
* Devuelve el minuto absoluto ( un dia tiene 24 x 60 minutos ) de salida del camión
|
|
*
|
|
* @param vExpeditionFk Identificador de srt.expedition
|
|
*
|
|
* @return vDayMinute Minuto absoluto diario
|
|
*/
|
|
|
|
DECLARE vDayMinute INT;
|
|
|
|
SELECT HOUR(IFNULL(et.ETD, z.`hour`)) * 60 + MINUTE(IFNULL(et.ETD, z.`hour`)) INTO vDayMinute
|
|
FROM vn.expedition e
|
|
JOIN vn.ticket t ON e.ticketFk = t.id
|
|
JOIN vn.`zone` z ON z.id = t.zoneFk
|
|
LEFT JOIN vn.route r ON r.id = t.routeFk
|
|
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
|
|
LEFT JOIN vn.routesMonitor rm ON t.routeFk = rm.routeFk
|
|
LEFT JOIN vn.expeditionTruck et ON rm.expeditionTruckFk = et.id
|
|
WHERE e.id = vExpeditionFk;
|
|
|
|
RETURN vDayMinute;
|
|
|
|
END$$
|
|
DELIMITER ;
|