2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`buy_getVolume`()
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Cálculo de volumen en líneas de compra
|
|
|
|
* @table tmp.buy(buyFk)
|
|
|
|
*/
|
|
|
|
SELECT t.name Temp,
|
|
|
|
CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
|
|
|
|
item_getVolume(b.itemFk, b.packagingFk)) / vc.trolleyM3 / 1000000 ,1) AS DECIMAL(10,2)) carros ,
|
|
|
|
CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
|
|
|
|
item_getVolume(b.itemFk, b.packagingFk)) / vc.palletM3 / 1000000,1) AS DECIMAL(10,2)) espais
|
|
|
|
FROM buy b
|
|
|
|
JOIN tmp.buy tb ON tb.buyFk = b.id
|
|
|
|
JOIN volumeConfig vc
|
|
|
|
JOIN item i ON i.id = b.itemFk
|
|
|
|
JOIN itemType it ON it.id = i.typeFk
|
|
|
|
LEFT JOIN temperature t ON t.code = it.temperatureFk
|
|
|
|
GROUP BY Temp;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|