2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost`
|
2024-01-15 11:31:03 +00:00
|
|
|
SQL SECURITY DEFINER
|
|
|
|
VIEW `vn`.`lastHourProduction`
|
|
|
|
AS SELECT `t`.`warehouseFk` AS `warehouseFk`,
|
|
|
|
cast(
|
|
|
|
sum(
|
|
|
|
IFNULL(
|
|
|
|
`p`.`volume`,
|
|
|
|
`p`.`width` * `p`.`height` * `p`.`depth`
|
|
|
|
) / 1000000
|
|
|
|
) AS decimal(5, 1)
|
|
|
|
) AS `m3`
|
|
|
|
FROM (
|
|
|
|
(
|
|
|
|
(
|
|
|
|
`vn`.`warehouse` `w`
|
|
|
|
JOIN `vn`.`ticket` `t` ON(`t`.`warehouseFk` = `w`.`id`)
|
|
|
|
)
|
|
|
|
LEFT JOIN `vn`.`expedition` `e` ON(`t`.`id` = `e`.`ticketFk`)
|
|
|
|
)
|
|
|
|
LEFT JOIN `vn`.`packaging` `p` ON(`p`.`id` = `e`.`packagingFk`)
|
|
|
|
)
|
|
|
|
WHERE `e`.`created` BETWEEN `util`.`VN_NOW`() - INTERVAL 1 HOUR
|
|
|
|
AND `util`.`VN_NOW`()
|
|
|
|
GROUP BY `t`.`warehouseFk`
|