This commit is contained in:
parent
941438efd0
commit
0b648d09af
|
@ -56,13 +56,13 @@ BEGIN
|
|||
LIMIT 1;
|
||||
|
||||
IF vPalletFk IS NULL THEN
|
||||
SELECT expeditionTruckFk
|
||||
SELECT roadmapStopFk
|
||||
INTO vTruckFk
|
||||
FROM (
|
||||
SELECT rm.expeditionTruckFk, count(*) n
|
||||
SELECT rm.roadmapStopFk, count(*) n
|
||||
FROM vn.routesMonitor rm
|
||||
JOIN tExpedition e ON e.routeFk = rm.routeFk
|
||||
GROUP BY expeditionTruckFk
|
||||
GROUP BY roadmapStopFk
|
||||
ORDER BY n DESC
|
||||
LIMIT 1) sub;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ AS SELECT `rs`.`id` AS `truckFk`,
|
|||
`t`.`routeFk` AS `routeFk`,
|
||||
`es`.`id` AS `scanFk`,
|
||||
`e`.`id` AS `expeditionFk`,
|
||||
`r`.`roadmapStopFk` AS `expeditionTruckFk`,
|
||||
`r`.`roadmapStopFk` AS `roadmapStopFk`,
|
||||
`t`.`warehouseFk` AS `warehouseFk`,
|
||||
`e`.`created` AS `lastPacked`,
|
||||
`t`.`id` AS `ticketFk`
|
||||
|
|
|
@ -11,9 +11,9 @@ AS SELECT `e`.`truckFk` AS `id`,
|
|||
COUNT(DISTINCT `e`.`routeFk`) AS `routes`,
|
||||
COUNT(DISTINCT `e`.`scanFk`) AS `scans`,
|
||||
COUNT(DISTINCT `e`.`expeditionFk`) AS `expeditions`,
|
||||
sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,
|
||||
sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`,
|
||||
max(`e`.`lastPacked`) AS `lastPacked`
|
||||
FROM `vn`.`expeditionCommon` `e`
|
||||
GROUP BY `e`.`truckFk`
|
||||
ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC,
|
||||
ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC,
|
||||
`e`.`eta`
|
||||
|
|
|
@ -7,12 +7,12 @@ AS SELECT `e`.`truckFk` AS `id`,
|
|||
`e`.`palletFk` AS `pallet`,
|
||||
COUNT(DISTINCT `e`.`routeFk`) AS `routes`,
|
||||
COUNT(DISTINCT `e`.`scanFk`) AS `scans`,
|
||||
COUNT(DISTINCT `e`.`expeditionTruckFk`) AS `destinos`,
|
||||
sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,
|
||||
COUNT(DISTINCT `e`.`roadmapStopFk`) AS `destinos`,
|
||||
sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`,
|
||||
max(`e`.`lastPacked`) AS `lastPacked`
|
||||
FROM `vn`.`expeditionCommon` `e`
|
||||
GROUP BY `e`.`truckFk`,
|
||||
`e`.`palletFk`
|
||||
ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC,
|
||||
ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC,
|
||||
`e`.`eta`,
|
||||
`e`.`truckFk`
|
||||
|
|
|
@ -8,15 +8,15 @@ AS SELECT `e`.`truckFk` AS `id`,
|
|||
`e`.`routeFk` AS `route`,
|
||||
COUNT(DISTINCT `e`.`scanFk`) AS `scans`,
|
||||
`rs`.`description` AS `destinos`,
|
||||
sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,
|
||||
`e`.`expeditionTruckFk` AS `expeditionTruckFk`,
|
||||
max(`e`.`lastPacked`) AS `lastPacked`
|
||||
SUM(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`,
|
||||
`e`.`roadmapStopFk` AS `roadmapStopFk`,
|
||||
MAX(`e`.`lastPacked`) AS `lastPacked`
|
||||
FROM (
|
||||
`vn`.`expeditionCommon` `e`
|
||||
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `e`.`expeditionTruckFk`)
|
||||
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `e`.`roadmapStopFk`)
|
||||
)
|
||||
GROUP BY `e`.`truckFk`,
|
||||
`e`.`palletFk`,
|
||||
`e`.`routeFk`
|
||||
ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC,
|
||||
ORDER BY SUM(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC,
|
||||
`e`.`palletFk`
|
||||
|
|
Loading…
Reference in New Issue