2024-01-15 11:31:03 +00:00
|
|
|
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;
|
|
|
|
|
2024-04-30 09:48:18 +00:00
|
|
|
SELECT HOUR(IFNULL(rs.ETD, z.`hour`)) * 60 + MINUTE(IFNULL(rs.ETD, z.`hour`)) INTO vDayMinute
|
2024-01-15 11:31:03 +00:00
|
|
|
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
|
2024-04-30 09:48:18 +00:00
|
|
|
LEFT JOIN vn.roadmapStop rs ON rm.expeditionTruckFk = rs.id
|
2024-01-15 11:31:03 +00:00
|
|
|
WHERE e.id = vExpeditionFk;
|
|
|
|
|
|
|
|
RETURN vDayMinute;
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|