2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` FUNCTION `vn`.`item_getPackage`(vItemFk INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
RETURNS varchar(50) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
|
|
|
|
DETERMINISTIC
|
|
|
|
BEGIN
|
|
|
|
|
|
|
|
DECLARE vDiameter INT;
|
|
|
|
DECLARE vPackageFk VARCHAR(50);
|
|
|
|
DECLARE vCoeficient DOUBLE DEFAULT 1.08;
|
|
|
|
|
|
|
|
SELECT MAX(LEFT(value,3)) INTO vDiameter
|
|
|
|
FROM vn.itemTag it
|
|
|
|
JOIN vn.tag t ON t.id = it.tagFk
|
|
|
|
WHERE it.itemFk = vItemFk
|
|
|
|
AND t.overwrite = 'diameter';
|
|
|
|
|
|
|
|
SELECT 8000 + FLOOR(vc.ccLength * vc.ccWidth / (vCoeficient * PI() * (vDiameter / 2) * (vDiameter / 2)))
|
|
|
|
INTO vPackageFk
|
|
|
|
FROM vn.volumeConfig vc;
|
|
|
|
|
|
|
|
INSERT IGNORE INTO vn.packaging(id, width, `depth`)
|
|
|
|
SELECT vPackageFk,
|
|
|
|
FLOOR(vc.ccWidth / FLOOR(vc.ccWidth / vDiameter)),
|
|
|
|
FLOOR(vc.ccLength / FLOOR(vc.ccLength / vDiameter))
|
|
|
|
FROM vn.volumeConfig vc;
|
|
|
|
|
|
|
|
RETURN vPackageFk;
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|