From 29f9fa0ce36d6c1b9eab9c220b48d9454451f953 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 09:45:55 +0200 Subject: [PATCH] feat: refs #7505 Optimization --- .../vn/procedures/multipleInventory.sql | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/db/routines/vn/procedures/multipleInventory.sql b/db/routines/vn/procedures/multipleInventory.sql index 33eb0b0ed..6cd584c6e 100644 --- a/db/routines/vn/procedures/multipleInventory.sql +++ b/db/routines/vn/procedures/multipleInventory.sql @@ -10,7 +10,7 @@ proc: BEGIN DECLARE vDateTo DATETIME; DECLARE vDateToTomorrow DATETIME; DECLARE vDefaultDayRange INT; - DECLARE vCalc INT; + DECLARE vCalcFk INT; IF vDate < util.VN_CURDATE() THEN LEAVE proc; @@ -83,19 +83,18 @@ proc: BEGIN ai.sd = iic.quantity; -- Cálculo del visible - CALL cache.stock_refresh(false); + CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk); - CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible + CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc (PRIMARY KEY (item_id)) ENGINE = MEMORY - SELECT item_id, amount stock, amount visible - FROM cache.stock - WHERE warehouse_id = vWarehouseFk; + SELECT item_id, visible + FROM cache.visible + WHERE calc_id = vCalcFk; - CALL item_calcVisible(NULL, vWarehouseFk, vDate); UPDATE tmp.itemInventory it - JOIN tmp.itemVisible iv ON iv.item_id = it.id - SET it.visible = it.visible + iv.visible; + JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id + SET it.visible = it.visible + ivc.visible; -- Calculo del disponible CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc @@ -168,6 +167,6 @@ proc: BEGIN tmp.itemCalc, tmp.itemAtp, tItemInventoryCalc, - tmp.itemVisible; + tItemVisibleCalc; END$$ DELIMITER ;