2022-11-30 07:18:37 +00:00
|
|
|
SELECT c.itemPackingTypeFk code,
|
|
|
|
tc.collectionFk,
|
2022-11-29 10:56:05 +00:00
|
|
|
SUBSTRING('ABCDEFGH', tc.wagon, 1) wagon,
|
|
|
|
tc.`level`,
|
|
|
|
t.id ticketFk,
|
|
|
|
COALESCE(et.description, zo.name, am.name) agencyDescription,
|
2022-11-30 07:18:37 +00:00
|
|
|
cc.code color,
|
2022-10-04 08:55:13 +00:00
|
|
|
t.clientFk,
|
2022-11-29 10:56:05 +00:00
|
|
|
CAST(SUM(sv.volume) AS DECIMAL(5, 2)) volume,
|
|
|
|
MAX(i.`size`) `size`,
|
2022-10-04 08:55:13 +00:00
|
|
|
w.code workerCode,
|
2022-11-29 10:56:05 +00:00
|
|
|
TIME_FORMAT(t.shipped, '%H:%i') shippedHour,
|
|
|
|
TIME_FORMAT(zo.`hour`, '%H:%i') zoneHour,
|
2022-11-08 13:40:38 +00:00
|
|
|
DATE_FORMAT(t.shipped, '%d/%m/%y') shipped,
|
2022-12-14 15:15:41 +00:00
|
|
|
tt.labelCount,
|
2022-11-29 10:56:05 +00:00
|
|
|
t.nickName,
|
|
|
|
COUNT(*) lineCount
|
2022-10-04 08:55:13 +00:00
|
|
|
FROM vn.ticket t
|
2022-11-30 09:52:52 +00:00
|
|
|
JOIN vn.ticketCollection tc ON tc.ticketFk = t.id
|
|
|
|
JOIN vn.collection c ON c.id = tc.collectionFk
|
2022-10-04 08:55:13 +00:00
|
|
|
LEFT JOIN vn.collectionColors cc ON cc.shelve = tc.`level`
|
|
|
|
AND cc.wagon = tc.wagon
|
|
|
|
AND cc.trainFk = c.trainFk
|
2022-11-30 09:52:52 +00:00
|
|
|
JOIN vn.sale s ON s.ticketFk = t.id
|
2022-10-04 08:55:13 +00:00
|
|
|
LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id
|
2022-11-30 09:52:52 +00:00
|
|
|
JOIN vn.item i ON i.id = s.itemFk
|
|
|
|
JOIN vn.itemType it ON it.id = i.typeFk
|
|
|
|
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
|
|
|
|
JOIN vn.worker w ON w.id = c.workerFk
|
|
|
|
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
|
2022-10-04 08:55:13 +00:00
|
|
|
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
|
2022-11-29 10:56:05 +00:00
|
|
|
WHERE t.id IN (?)
|
2022-10-04 08:55:13 +00:00
|
|
|
GROUP BY t.id
|
|
|
|
ORDER BY cc.`code`;
|