feat: refs #7505 Optimization
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-07-09 09:45:55 +02:00
parent 86acc644fe
commit 29f9fa0ce3
1 changed files with 9 additions and 10 deletions

View File

@ -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 ;