salix/db/routines/vn/views/expeditionPallet_Print.sql

40 lines
1.1 KiB
MySQL
Raw Normal View History

2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`expeditionPallet_Print`
AS SELECT `rs2`.`description` AS `truck`,
`t`.`routeFk` AS `routeFk`,
`r`.`description` AS `zone`,
COUNT(`es`.`id`) AS `eti`,
`ep`.`id` AS `palletFk`,
`rs`.`id` <=> `rm`.`roadmapStopFk` AS `isMatch`,
`t`.`warehouseFk` AS `warehouseFk`,
IF(
`r`.`dated` > `util`.`VN_CURDATE`() + INTERVAL 1 DAY,
ucase(dayname(`r`.`dated`)),
NULL
) AS `nombreDia`
FROM (
(
(
(
(
(
(
2024-04-30 10:02:19 +00:00
`vn`.`roadmapStop` `rs`
JOIN `vn`.`expeditionPallet` `ep` ON(`ep`.`truckFk` = `rs`.`id`)
)
JOIN `vn`.`expeditionScan` `es` ON(`es`.`palletFk` = `ep`.`id`)
)
JOIN `vn`.`expedition` `e` ON(`e`.`id` = `es`.`expeditionFk`)
)
JOIN `vn`.`ticket` `t` ON(`t`.`id` = `e`.`ticketFk`)
)
JOIN `vn`.`route` `r` ON(`r`.`id` = `t`.`routeFk`)
)
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `r`.`id`)
)
LEFT JOIN `vn`.`roadmapStop` `rs2` ON(`rs2`.`id` = `rm`.`roadmapStopFk`)
)
GROUP BY `ep`.`id`,
`t`.`routeFk`