2024-01-15 11:31:03 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
|
|
SQL SECURITY DEFINER
|
|
|
|
VIEW `srt`.`bufferStock`
|
|
|
|
AS SELECT `e`.`id` AS `expeditionFk`,
|
|
|
|
`e`.`bufferFk` AS `bufferFk`,
|
|
|
|
`e`.`position` AS `position`,
|
2024-04-30 09:48:18 +00:00
|
|
|
`srt`.`dayMinute`(IFNULL(`rs`.`eta`, `z`.`hour`)) AS `dayMinute`,
|
2024-01-15 11:31:03 +00:00
|
|
|
IFNULL(
|
2024-04-30 09:48:18 +00:00
|
|
|
`rs`.`eta`,
|
2024-01-15 11:31:03 +00:00
|
|
|
`util`.`VN_CURDATE`() + INTERVAL `srt`.`dayMinute`(`z`.`hour`) + 120 MINUTE
|
|
|
|
) AS `eta`,
|
|
|
|
`ve`.`ticketFk` AS `ticketFk`,
|
|
|
|
IFNULL(`t`.`routeFk`, `t`.`agencyModeFk`) AS `routeFk`,
|
|
|
|
`z`.`name` AS `zonaTicket`,
|
2024-04-30 09:48:18 +00:00
|
|
|
`rs`.`description` AS `truck`,
|
2024-01-15 11:31:03 +00:00
|
|
|
`es`.`description` AS `expeditionState`,
|
|
|
|
`b`.`hasWorkerWaiting` AS `hasWorkerWaiting`,
|
|
|
|
`b`.`isActive` AS `isActive`,
|
|
|
|
IF(
|
2024-04-30 09:48:18 +00:00
|
|
|
`rs`.`id` IS NULL,
|
2024-01-15 11:31:03 +00:00
|
|
|
`c`.`bufferDefault`,
|
2024-04-30 09:48:18 +00:00
|
|
|
`rs`.`bufferFk`
|
2024-01-15 11:31:03 +00:00
|
|
|
) AS `bufferTruck`,
|
|
|
|
`bt`.`typeName` AS `typeName`,
|
|
|
|
`rm`.`bufferFk` AS `routeBuffer`
|
|
|
|
FROM (
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
`srt`.`expedition` `e`
|
|
|
|
LEFT JOIN `vn`.`expedition` `ve` ON(`ve`.`id` = `e`.`id`)
|
|
|
|
)
|
|
|
|
JOIN `srt`.`expeditionState` `es` ON(`es`.`id` = `e`.`stateFk`)
|
|
|
|
)
|
|
|
|
JOIN `srt`.`buffer` `b` ON(`b`.`id` = `e`.`bufferFk`)
|
|
|
|
)
|
|
|
|
LEFT JOIN `vn`.`ticket` `t` ON(`t`.`id` = `ve`.`ticketFk`)
|
|
|
|
)
|
|
|
|
LEFT JOIN `vn`.`zone` `z` ON(`z`.`id` = `t`.`zoneFk`)
|
|
|
|
)
|
|
|
|
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
|
|
|
)
|
|
|
|
JOIN `srt`.`config` `c`
|
|
|
|
)
|
|
|
|
JOIN `srt`.`bufferType` `bt` ON(`bt`.`id` = `b`.`typeFk`)
|
|
|
|
)
|
|
|
|
WHERE `bt`.`typeName` <> 'DISABLED'
|