2022-10-04 08:55:13 +00:00
|
|
|
SELECT c.itemPackingTypeFk,
|
|
|
|
CONCAT(tc.collectionFk, ' ', LEFT(cc.code, 4)) color,
|
2022-11-29 07:22:32 +00:00
|
|
|
CONCAT(tc.collectionFk, ' ', SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`) levelV,
|
2022-10-04 08:55:13 +00:00
|
|
|
tc.ticketFk,
|
|
|
|
LEFT(COALESCE(et.description, zo.name, am.name),12) agencyDescription,
|
|
|
|
am.name,
|
|
|
|
t.clientFk,
|
|
|
|
CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5, 2)), 'm³') m3 ,
|
2022-11-29 07:22:32 +00:00
|
|
|
IF(ic.code = 'plant', CONCAT(MAX(i.`size`),' cm'), CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5, 2)), 'm³')) `value`,
|
2022-10-04 08:55:13 +00:00
|
|
|
w.code workerCode,
|
|
|
|
tt.labelCount,
|
2022-11-08 13:40:38 +00:00
|
|
|
IF(HOUR(t.shipped), TIME_FORMAT(t.shipped, '%H:%i'), TIME_FORMAT(zo.`hour`, '%H:%i')) agencyHour,
|
|
|
|
DATE_FORMAT(t.shipped, '%d/%m/%y') shipped,
|
2022-10-04 08:55:13 +00:00
|
|
|
COUNT(*) lineCount,
|
2022-11-29 07:22:32 +00:00
|
|
|
LEFT(t.nickName, 29) nickName
|
2022-10-04 08:55:13 +00:00
|
|
|
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
|
|
|
|
LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id
|
|
|
|
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
|
|
|
|
LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
|
2022-11-08 13:40:38 +00:00
|
|
|
WHERE tc.ticketFk IN (?)
|
2022-10-04 08:55:13 +00:00
|
|
|
GROUP BY t.id
|
|
|
|
ORDER BY cc.`code`;
|