feat: refs #7296 expeditionTruck to roadmapStop #2386

Merged
robert merged 9 commits from 7296-expeditionTruck into dev 2024-05-15 09:06:48 +00:00
25 changed files with 86 additions and 71 deletions

View File

@ -34,7 +34,7 @@ BEGIN
vPrinterFk,
IFNULL(right(`t`.`routeFk`, 3),0),
if (@vVolume := vn.ticketTotalVolume(t.id) > 1.5, @vVolume, IFNULL( rm.beachFk, 0)),
LEFT(IFNULL(et.description ,replace(`z`.`name`, 'ZONA ', 'Z')),14) truckName,
LEFT(IFNULL(rs.description ,replace(`z`.`name`, 'ZONA ', 'Z')),14) truckName,
t.clientFk ,
ifnull(c.mobile, ifnull(a.mobile, ifnull(c.phone, a.phone))),
LEFT(p.name, 20),
@ -46,7 +46,7 @@ BEGIN
JOIN vn.address a ON a.id = t.addressFk
JOIN vn.province p ON p.id = a.provinceFk
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk
LEFT JOIN vn.beach b ON b.code = rm.beachFk
LEFT JOIN vn.`zone`z ON z.id = t.zoneFk
JOIN vn.agencyMode am ON t.agencyModeFk = am.id

View File

@ -15,14 +15,14 @@ BEGIN
DECLARE vDayMinute INT;
SELECT HOUR(IFNULL(et.ETD, z.`hour`)) * 60 + MINUTE(IFNULL(et.ETD, z.`hour`)) INTO vDayMinute
SELECT HOUR(IFNULL(rs.ETD, z.`hour`)) * 60 + MINUTE(IFNULL(rs.ETD, z.`hour`)) INTO vDayMinute
FROM vn.expedition e
JOIN vn.ticket t ON e.ticketFk = t.id
JOIN vn.`zone` z ON z.id = t.zoneFk
LEFT JOIN vn.route r ON r.id = t.routeFk
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN vn.routesMonitor rm ON t.routeFk = rm.routeFk
LEFT JOIN vn.expeditionTruck et ON rm.expeditionTruckFk = et.id
LEFT JOIN vn.roadmapStop rs ON rm.expeditionTruckFk = rs.id
WHERE e.id = vExpeditionFk;
RETURN vDayMinute;

View File

@ -296,8 +296,8 @@ BEGIN
SET @dm := (24 * 60) - 10;
UPDATE vn.expeditionTruck et
SET et.eta = timestampadd(MINUTE ,@dm := 1 + @dm,util.VN_CURDATE())
UPDATE vn.roadmapStop rs
SET rs.eta = timestampadd(MINUTE ,@dm := 1 + @dm,util.VN_CURDATE())
WHERE description LIKE 'PRU%' ;
DELETE FROM srt.movingLog ;

View File

@ -3,10 +3,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
VIEW `srt`.`bufferDayMinute`
AS SELECT `b`.`id` AS `bufferFk`,
`e`.`id` AS `expeditionFk`,
`srt`.`dayMinute`(IFNULL(`et`.`eta`, `z`.`hour`)) AS `dayMinute`,
`srt`.`dayMinute`(IFNULL(`rs`.`eta`, `z`.`hour`)) AS `dayMinute`,
`e`.`position` AS `position`,
IFNULL(
`et`.`eta`,
`rs`.`eta`,
`util`.`VN_CURDATE`() + INTERVAL `srt`.`dayMinute`(`z`.`hour`) MINUTE
) AS `ETD`,
`e2`.`ticketFk` AS `ticketFk`,
@ -34,7 +34,7 @@ FROM (
)
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`)
)
LEFT JOIN `vn`.`expeditionTruck` `et` ON(`rm`.`expeditionTruckFk` = `et`.`id`)
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`)
)
LEFT JOIN `vn`.`zone` `z` ON(`z`.`id` = `t`.`zoneFk`)
)

View File

@ -4,22 +4,22 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
AS SELECT `e`.`id` AS `expeditionFk`,
`e`.`bufferFk` AS `bufferFk`,
`e`.`position` AS `position`,
`srt`.`dayMinute`(IFNULL(`et`.`eta`, `z`.`hour`)) AS `dayMinute`,
`srt`.`dayMinute`(IFNULL(`rs`.`eta`, `z`.`hour`)) AS `dayMinute`,
IFNULL(
`et`.`eta`,
`rs`.`eta`,
`util`.`VN_CURDATE`() + INTERVAL `srt`.`dayMinute`(`z`.`hour`) + 120 MINUTE
) AS `eta`,
`ve`.`ticketFk` AS `ticketFk`,
IFNULL(`t`.`routeFk`, `t`.`agencyModeFk`) AS `routeFk`,
`z`.`name` AS `zonaTicket`,
`et`.`description` AS `truck`,
`rs`.`description` AS `truck`,
`es`.`description` AS `expeditionState`,
`b`.`hasWorkerWaiting` AS `hasWorkerWaiting`,
`b`.`isActive` AS `isActive`,
IF(
`et`.`id` IS NULL,
`rs`.`id` IS NULL,
`c`.`bufferDefault`,
`et`.`bufferFk`
`rs`.`bufferFk`
) AS `bufferTruck`,
`bt`.`typeName` AS `typeName`,
`rm`.`bufferFk` AS `routeBuffer`
@ -45,7 +45,7 @@ FROM (
)
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`)
)
LEFT JOIN `vn`.`expeditionTruck` `et` ON(`rm`.`expeditionTruckFk` = `et`.`id`)
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`)
)
JOIN `srt`.`config` `c`
)

View File

@ -4,13 +4,13 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
AS SELECT `e`.`id` AS `expeditionFk`,
`e`.`id` MOD 10000 AS `expedition`,
IFNULL(
`et`.`eta`,
`rs`.`eta`,
`util`.`VN_CURDATE`() + INTERVAL `srt`.`dayMinute`(`z`.`hour`) + 120 MINUTE
) AS `ETD`,
`ve`.`ticketFk` AS `ticketFk`,
right(IFNULL(`t`.`routeFk`, `t`.`agencyModeFk`), 3) AS `routeFk`,
`z`.`name` AS `zonaTicket`,
`et`.`description` AS `truck`,
`rs`.`description` AS `truck`,
`epo`.`workerCode` AS `worker`,
`p`.`name` AS `labeler`,
`ve`.`counter` AS `expeditionCounter`,
@ -32,7 +32,7 @@ FROM (
)
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`)
)
LEFT JOIN `vn`.`expeditionTruck` `et` ON(`rm`.`expeditionTruckFk` = `et`.`id`)
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`)
)
JOIN `dipole`.`expedition_PrintOut` `epo` ON(`epo`.`expeditionFk` = `e`.`id`)
)

View File

@ -86,7 +86,7 @@ BEGIN
WHERE cs.description = 'Anulado'
AND c.created < v2Months;
DELETE FROM expeditionTruck WHERE eta < v3Months;
DELETE FROM roadmapStop WHERE eta < v3Months;
DELETE FROM XDiario WHERE FECHA < v3Months OR FECHA IS NULL;
-- Borrar travels sin entradas

View File

@ -24,7 +24,7 @@ BEGIN
10 * p.height as height,
IFNULL(t.routeFk,am.agencyFk) routeFk,
hour(e.created) * 60 + minute(e.created),
IFNULL(et.description , a.name),
IFNULL(rs.description , a.name),
IFNULL(t.routeFk,am.agencyFk) criterion,
IFNULL(p.conveyorBuildingClassFk , pc.defaultConveyorBuildingClass)
FROM vn.expedition e
@ -34,7 +34,7 @@ BEGIN
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
LEFT JOIN vn.agency a ON a.id = am.agencyFk
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk
JOIN vn.packagingConfig pc
WHERE t.warehouseFk IN (60,1,44)
AND e.created BETWEEN vStarted AND vEnded

View File

@ -2,7 +2,7 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionTruck_Add`(vHour VARCHAR(5), vDescription VARCHAR(45))
BEGIN
INSERT INTO vn.expeditionTruck(eta,description)
INSERT INTO vn.roadmapStop(eta,description)
VALUES(CONCAT(util.VN_CURDATE(), ' ', vHour), vDescription);
END$$

View File

@ -4,9 +4,9 @@ BEGIN
SELECT id truckFk,
eta,
description Destino
FROM expeditionTruck
WHERE eta BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
ORDER BY eta;
description Destino
FROM roadmapStop
WHERE eta BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
ORDER BY eta;
END$$
DELIMITER ;

View File

@ -53,8 +53,8 @@ BEGIN
am.name zonaRuta,
t.routeFk ruta,
rm.beachFk ubicacion,
et.eta ,
et.description camion,
rs.eta ,
rs.description camion,
vTicketsPendientes AS ticketsPendientes,
vEtiquetasTotales AS etiquetasTotales,
vEtiquetasEscaneadas AS etiquetasEscaneadas,
@ -67,7 +67,7 @@ BEGIN
LEFT JOIN vn.route r ON r.id = t.routeFk
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id
LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk
WHERE e.id = vExpeditionFk;
END$$

View File

@ -37,8 +37,8 @@ BEGIN
am.name zonaRuta,
t.routeFk ruta,
rm.beachFk ubicacion,
et.eta ,
et.description camion,
rs.eta ,
rs.description camion,
vTicketsPendientes AS ticketsPendientes,
vEtiquetasTotales AS etiquetasTotales,
vEtiquetasEscaneadas AS etiquetasEscaneadas
@ -50,7 +50,7 @@ BEGIN
LEFT JOIN vn.route r ON r.id = t.routeFk
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id
LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk
WHERE e.id = vExpeditionFk;
END$$

View File

@ -20,7 +20,7 @@ BEGIN
CONCAT(tc.collectionFk, ' ', LEFT(cc.code, 4)) color,
CONCAT(tc.collectionFk, ' ', SUBSTRING('ABCDEFGH',tc.wagon, 1), '-', tc.level) levelV,
tc.ticketFk,
LEFT(COALESCE(et.description, zo.name, am.name),12) agencyDescription,
LEFT(COALESCE(rs.description, zo.name, am.name),12) agencyDescription,
am.name,
t.clientFk,
CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5, 2)), '') m3 ,
@ -47,7 +47,7 @@ BEGIN
LEFT JOIN ticketTrolley tt ON tt.ticket = t.id
LEFT JOIN zone zo ON t.zoneFk = zo.id
LEFT JOIN routesMonitor rm ON rm.routeFk = t.routeFk
LEFT JOIN expeditionTruck et ON et.id = rm.expeditionTruckFk
LEFT JOIN roadmapStop rs ON rs.id = rm.expeditionTruckFk
WHERE IF(vIsCollection, tc.collectionFk = vParam, tc.ticketFk = vParam)
GROUP BY t.id
ORDER BY cc.code;

View File

@ -106,8 +106,8 @@ BEGIN
SET rm.m3boxes = sub.m3boxes;
UPDATE routesMonitor rm
JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
SET rm.etd = et.eta;
JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk
SET rm.etd = rs.eta;
DROP TEMPORARY TABLE tmp.routesMonitor;
END$$

View File

@ -1,9 +1,9 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`expeditionCommon`
AS SELECT `et`.`id` AS `truckFk`,
`et`.`eta` AS `eta`,
IFNULL(ucase(`et`.`description`), 'SIN ESCANEAR') AS `description`,
AS SELECT `rs`.`id` AS `truckFk`,
`rs`.`eta` AS `eta`,
IFNULL(ucase(`rs`.`description`), 'SIN ESCANEAR') AS `description`,
`es`.`palletFk` AS `palletFk`,
`t`.`routeFk` AS `routeFk`,
`es`.`id` AS `scanFk`,
@ -17,8 +17,8 @@ FROM (
(
(
(
`vn`.`expeditionTruck` `et`
LEFT JOIN `vn`.`routesMonitor` `r` ON(`et`.`id` = `r`.`expeditionTruckFk`)
`vn`.`roadmapStop` `rs`
LEFT JOIN `vn`.`routesMonitor` `r` ON(`rs`.`id` = `r`.`expeditionTruckFk`)
)
LEFT JOIN `vn`.`ticket` `t` ON(`r`.`routeFk` = `t`.`routeFk`)
)
@ -28,4 +28,4 @@ FROM (
)
LEFT JOIN `vn`.`expeditionPallet` `ep` ON(`es`.`palletFk` = `ep`.`id`)
)
WHERE `et`.`eta` >= `util`.`VN_CURDATE`()
WHERE `rs`.`eta` >= `util`.`VN_CURDATE`()

View File

@ -1,12 +1,12 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`expeditionPallet_Print`
AS SELECT `et2`.`description` AS `truck`,
AS SELECT `rs2`.`description` AS `truck`,
`t`.`routeFk` AS `routeFk`,
`r`.`description` AS `zone`,
COUNT(`es`.`id`) AS `eti`,
`ep`.`id` AS `palletFk`,
`et`.`id` <=> `rm`.`expeditionTruckFk` AS `isMatch`,
`rs`.`id` <=> `rm`.`expeditionTruckFk` AS `isMatch`,
`t`.`warehouseFk` AS `warehouseFk`,
IF(
`r`.`created` > `util`.`VN_CURDATE`() + INTERVAL 1 DAY,
@ -20,8 +20,8 @@ FROM (
(
(
(
`vn`.`expeditionTruck` `et`
JOIN `vn`.`expeditionPallet` `ep` ON(`ep`.`truckFk` = `et`.`id`)
`vn`.`roadmapStop` `rs`
JOIN `vn`.`expeditionPallet` `ep` ON(`ep`.`truckFk` = `rs`.`id`)
)
JOIN `vn`.`expeditionScan` `es` ON(`es`.`palletFk` = `ep`.`id`)
)
@ -33,7 +33,7 @@ FROM (
)
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `r`.`id`)
)
LEFT JOIN `vn`.`expeditionTruck` `et2` ON(`et2`.`id` = `rm`.`expeditionTruckFk`)
LEFT JOIN `vn`.`roadmapStop` `rs2` ON(`rs2`.`id` = `rm`.`expeditionTruckFk`)
)
GROUP BY `ep`.`id`,
`t`.`routeFk`

View File

@ -15,7 +15,7 @@ FROM (
`vn`.`route` `r`
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`r`.`id` = `rm`.`routeFk`)
)
LEFT JOIN `vn`.`expeditionTruck` `et` ON(`et`.`id` = `rm`.`expeditionTruckFk`)
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`expeditionTruckFk`)
)
JOIN `vn`.`ticket` `t` ON(`t`.`routeFk` = `r`.`id`)
)

View File

@ -1,9 +1,9 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`expeditionScan_Monitor`
AS SELECT `et`.`id` AS `truckFk`,
`et`.`eta` AS `ETD`,
`et`.`description` AS `description`,
AS SELECT `rs`.`id` AS `truckFk`,
`rs`.`eta` AS `ETD`,
`rs`.`description` AS `description`,
`ep`.`id` AS `palletFk`,
`ep`.`position` AS `position`,
`ep`.`built` AS `built`,
@ -12,8 +12,8 @@ AS SELECT `et`.`id` AS `truckFk`,
`es`.`scanned` AS `scanned`
FROM (
(
`vn`.`expeditionTruck` `et`
LEFT JOIN `vn`.`expeditionPallet` `ep` ON(`ep`.`truckFk` = `et`.`id`)
`vn`.`roadmapStop` `rs`
LEFT JOIN `vn`.`expeditionPallet` `ep` ON(`ep`.`truckFk` = `rs`.`id`)
)
LEFT JOIN `vn`.`expeditionScan` `es` ON(`es`.`palletFk` = `ep`.`id`)
)

View File

@ -14,7 +14,7 @@ AS SELECT `e`.`id` AS `expeditionFk`,
IF(
`t`.`routeFk`,
IFNULL(
`et`.`description`,
`rs`.`description`,
REPLACE(`am`.`name`, 'ZONA ', 'Z')
),
`z`.`name`
@ -45,7 +45,7 @@ FROM (
)
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `t`.`routeFk`)
)
LEFT JOIN `vn`.`expeditionTruck` `et` ON(`et`.`id` = `rm`.`expeditionTruckFk`)
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`expeditionTruckFk`)
)
LEFT JOIN `vn`.`beach` `b` ON(`b`.`code` = `rm`.`beachFk`)
)

View File

@ -4,7 +4,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
AS SELECT `t`.`id` AS `ticketFk`,
`t`.`warehouseFk` AS `warehouseFk`,
`t`.`routeFk` AS `routeFk`,
`et`.`description` AS `description`
`rs`.`description` AS `description`
FROM (
(
(
@ -13,7 +13,7 @@ FROM (
)
JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `t`.`routeFk`)
)
JOIN `vn`.`expeditionTruck` `et` ON(`et`.`id` = `rm`.`expeditionTruckFk`)
JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`expeditionTruckFk`)
)
WHERE `e`.`id` IS NULL
AND `et`.`eta` > `util`.`VN_CURDATE`()
AND `rs`.`eta` > `util`.`VN_CURDATE`()

View File

@ -7,13 +7,13 @@ AS SELECT `e`.`truckFk` AS `id`,
`e`.`palletFk` AS `pallet`,
`e`.`routeFk` AS `route`,
COUNT(DISTINCT `e`.`scanFk`) AS `scans`,
`et`.`description` AS `destinos`,
`rs`.`description` AS `destinos`,
sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,
`e`.`expeditionTruckFk` AS `expeditionTruckFk`,
max(`e`.`lastPacked`) AS `lastPacked`
FROM (
`vn`.`expeditionCommon` `e`
LEFT JOIN `vn`.`expeditionTruck` `et` ON(`et`.`id` = `e`.`expeditionTruckFk`)
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `e`.`expeditionTruckFk`)
)
GROUP BY `e`.`truckFk`,
`e`.`palletFk`,

View File

@ -6,8 +6,8 @@ AS SELECT `t`.`routeFk` AS `routeFk`,
COUNT(`es`.`id`) AS `scanned`,
COUNT(DISTINCT `es`.`palletFk`) AS `pallets`,
max(`es`.`scanned`) AS `lastScanned`,
max(`et`.`description`) AS `description`,
max(`et`.`eta`) AS `eta`
max(`rs`.`description`) AS `description`,
max(`rs`.`eta`) AS `eta`
FROM (
(
(
@ -19,9 +19,9 @@ FROM (
)
LEFT JOIN `vn`.`expeditionPallet` `ep` ON(`ep`.`id` = `es`.`palletFk`)
)
LEFT JOIN `vn`.`expeditionTruck` `et` ON(`et`.`id` = `ep`.`truckFk`)
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `ep`.`truckFk`)
)
WHERE `t`.`shipped` >= `util`.`VN_CURDATE`()
AND `t`.`routeFk` <> 0
GROUP BY `t`.`routeFk`
ORDER BY max(`et`.`eta`)
ORDER BY max(`rs`.`eta`)

View File

@ -0,0 +1,15 @@
-- Place your SQL code here
ALTER TABLE IF EXISTS vn.expeditionTruck RENAME vn.roadmapStop;
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`expeditionTruck`
AS SELECT `rs`.`id` AS `id`,
`rs`.`roadmapFk` AS `roadmapFk`,
`rs`.`warehouseFk` AS `warehouseFk`,
`rs`.`eta` AS `eta`,
`rs`.`description` AS `description`,
`rs`.`bufferFk` AS `bufferFk`,
`rs`.`created` AS `created`,
`rs`.`userFk` AS `userFk`
FROM `vn`.`roadmapStop` `rs`;

View File

@ -3,7 +3,7 @@ SELECT c.itemPackingTypeFk code,
SUBSTRING('ABCDEFGH', tc.wagon, 1) wagon,
tc.`level`,
t.id ticketFk,
COALESCE(et.description, zo.name, am.name) agencyDescription,
COALESCE(rs.description, zo.name, am.name) agencyDescription,
cc.code color,
t.clientFk,
CAST(SUM(sv.volume) AS DECIMAL(5, 2)) volume,
@ -35,7 +35,7 @@ SELECT c.itemPackingTypeFk code,
LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id
LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk
LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
JOIN vn.productionConfig pc
WHERE t.id IN (?)

View File

@ -1,19 +1,19 @@
SELECT ep.id palletFk,
t.routeFk,
et2.description truck,
rs2.description truck,
r.description `zone`,
COUNT(es.id) labels,
t.warehouseFk warehouseFk,
dayname(r.created) `dayName`,
et.id <=> rm.expeditionTruckFk isMatch
FROM vn.expeditionTruck et
JOIN vn.expeditionPallet ep ON ep.truckFk = et.id
rs.id <=> rm.expeditionTruckFk isMatch
FROM vn.roadmapStop rs
JOIN vn.expeditionPallet ep ON ep.truckFk = rs.id
JOIN vn.expeditionScan es ON es.palletFk = ep.id
JOIN vn.expedition e ON e.id = es.expeditionFk
JOIN vn.ticket t ON t.id = e.ticketFk
JOIN vn.route r ON r.id = t.routeFk
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id
LEFT JOIN vn.expeditionTruck et2 ON et2.id = rm.expeditionTruckFk
LEFT JOIN vn.roadmapStop rs2 ON rs2.id = rm.expeditionTruckFk
WHERE ep.id = ?
GROUP BY ep.id, t.routeFk
ORDER BY t.routeFk