2024-01-15 11:31:03 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
|
|
SQL SECURITY DEFINER
|
|
|
|
VIEW `vn`.`ticketPreviousPreparingList`
|
|
|
|
AS SELECT `s`.`ticketFk` AS `ticketFk`,
|
|
|
|
`w`.`code` AS `code`,
|
|
|
|
COUNT(`s`.`id`) AS `saleLines`,
|
|
|
|
sum(`s`.`isPicked` <> 0) AS `alreadyMadeSaleLines`,
|
|
|
|
sum(`s`.`isPicked` <> 0) / COUNT(`s`.`id`) AS `madeRate`,
|
|
|
|
`sg`.`created` AS `created`,
|
|
|
|
`p`.`code` AS `parking`,
|
|
|
|
`iss`.`sectorFk` AS `sectorFk`,
|
|
|
|
`al`.`code` AS `alertCode`
|
|
|
|
FROM (
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
`vn`.`saleGroup` `sg`
|
|
|
|
JOIN `vn`.`saleGroupDetail` `sgd` ON(`sgd`.`saleGroupFk` = `sg`.`id`)
|
|
|
|
)
|
2024-06-10 09:32:44 +00:00
|
|
|
JOIN `vn`.`sale` `s` FORCE INDEX (PRIMARY) ON(`s`.`id` = `sgd`.`saleFk`)
|
2024-01-15 11:31:03 +00:00
|
|
|
)
|
|
|
|
JOIN `vn`.`ticketState` `tls` ON(`tls`.`ticketFk` = `s`.`ticketFk`)
|
|
|
|
)
|
|
|
|
JOIN `vn`.`alertLevel` `al` ON(`al`.`id` = `tls`.`alertLevel`)
|
|
|
|
)
|
|
|
|
JOIN `vn`.`worker` `w` ON(`w`.`id` = `sg`.`userFk`)
|
|
|
|
)
|
|
|
|
LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sg`.`parkingFk`)
|
|
|
|
)
|
|
|
|
JOIN `vn`.`itemShelvingStock` `iss` ON(`iss`.`itemFk` = `s`.`itemFk`)
|
|
|
|
)
|
|
|
|
WHERE `sg`.`created` >= `util`.`VN_CURDATE`() + INTERVAL 0.1 DAY
|
|
|
|
GROUP BY `sg`.`id`
|