refs #5483 fix: zoneEstimatedDelivery in salix
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2024-01-29 07:39:39 +01:00
parent a35db0cefd
commit 149c2b0293
1 changed files with 22 additions and 45 deletions

View File

@ -1,48 +1,25 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`zoneEstimatedDelivery`
AS SELECT `t`.`zoneFk` AS `zoneFk`,
`zc`.`hour` AS `zoneClosureHour`,
`z`.`hour` AS `zoneHour`,
`sv`.`volume` AS `volume`,
`al`.`hasToRecalcPrice` AS `hasToRecalcPrice`,
`lhp`.`m3` AS `m3`,
`dl`.`minSpeed` AS `minSpeed`
FROM (
(
(
(
(
(
(
(
(
(
`vn`.`ticket` `t`
JOIN `vn`.`ticketStateToday` `tst` ON(`tst`.`ticket` = `t`.`id`)
)
JOIN `vn`.`state` `s` ON(`s`.`id` = `tst`.`state`)
)
JOIN `vn`.`saleVolume` `sv` ON(`sv`.`ticketFk` = `t`.`id`)
)
LEFT JOIN `vn`.`lastHourProduction` `lhp` ON(`lhp`.`warehouseFk` = `t`.`warehouseFk`)
)
JOIN `vn`.`warehouse` `w` ON(`w`.`id` = `t`.`warehouseFk`)
)
JOIN `vn`.`warehouseAlias` `wa` ON(`wa`.`id` = `w`.`aliasFk`)
) STRAIGHT_JOIN `vn`.`zone` `z` ON(`z`.`id` = `t`.`zoneFk`)
)
LEFT JOIN `vn`.`zoneClosure` `zc` ON(
`zc`.`zoneFk` = `t`.`zoneFk`
AND `zc`.`dated` = `util`.`VN_CURDATE`()
)
)
LEFT JOIN `cache`.`departure_limit` `dl` ON(
`dl`.`warehouse_id` = `t`.`warehouseFk`
AND `dl`.`fecha` = `util`.`VN_CURDATE`()
)
)
JOIN `vn`.`alertLevel` `al` ON(`al`.`id` = `s`.`alertLevel`)
)
WHERE `w`.`hasProduction` <> 0
AND cast(`t`.`shipped` AS date) = `util`.`VN_CURDATE`()
AS SELECT t.zoneFk,
zc.`hour` zoneClosureHour,
z.`hour` zoneHour,
sv.volume volume,
al.hasToRecalcPrice,
lhp.m3,
dl.minSpeed
FROM ticket t
JOIN ticketStateToday tst ON tst.ticket = t.id
JOIN state s ON s.id = tst.state
JOIN saleVolume sv ON sv.ticketFk = t.id
LEFT JOIN lastHourProduction lhp ON lhp.warehouseFk = t.warehouseFk
JOIN warehouse w ON w.id = t.warehouseFk
JOIN warehouseAlias wa ON wa.id = w.aliasFk
STRAIGHT_JOIN `zone` z ON z.id = t.zoneFk
LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk
AND zc.dated = util.VN_CURDATE()
LEFT JOIN cache.departure_limit dl ON dl.warehouse_id = t.warehouseFk
AND dl.fecha = util.VN_CURDATE()
JOIN alertLevel al ON al.id = s.alertLevel
WHERE w.hasProduction
AND DATE(t.shipped) = util.VN_CURDATE()