2021-01-18 07:33:20 +00:00
|
|
|
SELECT
|
2021-06-16 11:04:54 +00:00
|
|
|
e.id,
|
|
|
|
e.travelFk,
|
|
|
|
e.ref,
|
|
|
|
s.name AS supplierName,
|
|
|
|
SUM(b.stickers) AS stickers,
|
|
|
|
CAST(SUM(i.density * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) as DECIMAL(10,0)) as loadedKg,
|
|
|
|
CAST(SUM(167.5 * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) as DECIMAL(10,0)) as volumeKg
|
|
|
|
FROM travel t
|
|
|
|
JOIN entry e ON e.travelFk = t.id
|
|
|
|
JOIN buy b ON b.entryFk = e.id
|
|
|
|
JOIN packaging pkg ON pkg.id = b.packageFk
|
|
|
|
JOIN item i ON i.id = b.itemFk
|
|
|
|
JOIN itemType it ON it.id = i.typeFk
|
|
|
|
JOIN supplier s ON s.id = e.supplierFk
|
|
|
|
WHERE t.id IN(?)
|
|
|
|
GROUP BY e.id
|