2022-11-30 07:18:37 +00:00
|
|
|
SELECT c.itemPackingTypeFk code,
|
2023-01-13 07:44:58 +00:00
|
|
|
tc.collectionFk,
|
|
|
|
SUBSTRING('ABCDEFGH', tc.wagon, 1) wagon,
|
|
|
|
tc.`level`,
|
|
|
|
t.id ticketFk,
|
2024-04-30 09:48:18 +00:00
|
|
|
COALESCE(rs.description, zo.name, am.name) agencyDescription,
|
2023-01-13 07:44:58 +00:00
|
|
|
cc.code color,
|
|
|
|
t.clientFk,
|
|
|
|
CAST(SUM(sv.volume) AS DECIMAL(5, 2)) volume,
|
2024-01-15 08:59:32 +00:00
|
|
|
MAX(
|
2024-01-15 09:03:05 +00:00
|
|
|
IF(sgd.id, IFNULL(pc.itemPreviousDefaultSize, i.`size`), i.`size`)
|
2024-01-15 08:59:32 +00:00
|
|
|
) `size`,
|
2023-01-13 07:44:58 +00:00
|
|
|
w.code workerCode,
|
2024-05-02 08:25:46 +00:00
|
|
|
w.id workerFk,
|
2023-01-13 07:44:58 +00:00
|
|
|
TIME_FORMAT(t.shipped, '%H:%i') shippedHour,
|
|
|
|
TIME_FORMAT(zo.`hour`, '%H:%i') zoneHour,
|
|
|
|
DATE_FORMAT(t.shipped, '%d/%m/%y') shipped,
|
|
|
|
tt.labelCount,
|
|
|
|
t.nickName,
|
2024-01-26 06:42:53 +00:00
|
|
|
SUM(IF(sgd.id IS NULL, 1, 0)) + IF(sgd.id , 1, 0) lineCount,
|
2023-01-13 07:44:58 +00:00
|
|
|
rm.routeFk
|
|
|
|
FROM vn.ticket t
|
|
|
|
JOIN vn.ticketCollection tc ON tc.ticketFk = t.id
|
|
|
|
JOIN vn.collection c ON c.id = tc.collectionFk
|
|
|
|
LEFT JOIN vn.collectionColors cc ON cc.shelve = tc.`level`
|
|
|
|
AND cc.wagon = tc.wagon
|
|
|
|
AND cc.trainFk = c.trainFk
|
|
|
|
JOIN vn.sale s ON s.ticketFk = t.id
|
2024-01-15 08:59:32 +00:00
|
|
|
LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id
|
2023-01-13 07:44:58 +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
|
|
|
|
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
|
2024-05-27 07:07:23 +00:00
|
|
|
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk
|
2024-01-15 08:59:32 +00:00
|
|
|
LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
|
|
|
|
JOIN vn.productionConfig pc
|
2023-01-13 07:44:58 +00:00
|
|
|
WHERE t.id IN (?)
|
|
|
|
GROUP BY t.id
|
2024-01-15 08:59:32 +00:00
|
|
|
ORDER BY cc.`code`
|