2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost`
|
2024-01-15 11:31:03 +00:00
|
|
|
SQL SECURITY DEFINER
|
|
|
|
VIEW `vn`.`workerSpeedSaleTracking`
|
|
|
|
AS SELECT `salesPreparedLastHour`.`warehouseFk` AS `warehouseFk`,
|
|
|
|
`salesPreparedLastHour`.`code` AS `state`,
|
|
|
|
`salesPreparedLastHour`.`workerCode` AS `workerCode`,
|
|
|
|
sum(`salesPreparedLastHour`.`litros`) AS `sumaLitros`,
|
|
|
|
min(`salesPreparedLastHour`.`created`) AS `started`,
|
|
|
|
max(`salesPreparedLastHour`.`created`) AS `finished`,
|
|
|
|
sum(
|
|
|
|
IF(
|
|
|
|
`salesPreparedLastHour`.`created` >= `util`.`VN_NOW`() + INTERVAL -1 HOUR,
|
|
|
|
`salesPreparedLastHour`.`litros`,
|
|
|
|
0
|
|
|
|
)
|
|
|
|
) AS `sumaLitrosLastHour`,
|
|
|
|
cast(
|
|
|
|
60 * sum(`salesPreparedLastHour`.`litros`) / time_to_sec(
|
|
|
|
timediff(
|
|
|
|
max(`salesPreparedLastHour`.`created`),
|
|
|
|
min(`salesPreparedLastHour`.`created`)
|
|
|
|
)
|
|
|
|
) AS decimal(10, 1)
|
|
|
|
) AS `litersByMinute`,
|
|
|
|
`salesPreparedLastHour`.`departmentName` AS `departmentName`
|
|
|
|
FROM `vn`.`salesPreparedLastHour`
|
|
|
|
GROUP BY `salesPreparedLastHour`.`warehouseFk`,
|
|
|
|
`salesPreparedLastHour`.`code`,
|
|
|
|
`salesPreparedLastHour`.`workerCode`
|