feat: refs #7264 Refactor proc itemShelvingRadar and added columns #2460

Merged
guillermo merged 4 commits from 7264-itemShelvingRadar into dev 2024-05-15 12:18:11 +00:00
1 changed files with 8 additions and 8 deletions
Showing only changes of commit 9134e0ff65 - Show all commits

View File

@ -32,7 +32,7 @@ BEGIN
CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE()); CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE());
IF hasFatherSector THEN IF hasFatherSector THEN
CREATE OR REPLACE TEMPORARY TABLE tmp.itemShelvingRadar CREATE OR REPLACE TEMPORARY TABLE tItemShelvingRadar
(PRIMARY KEY (itemFk)) (PRIMARY KEY (itemFk))
ENGINE = MEMORY ENGINE = MEMORY
SELECT * SELECT *
@ -97,7 +97,7 @@ BEGIN
SELECT ishr.*, SELECT ishr.*,
CAST(visible - upstairs - downstairs AS DECIMAL(10, 0)) nicho, CAST(visible - upstairs - downstairs AS DECIMAL(10, 0)) nicho,
CAST(downstairs - IFNULL(notPickedYed, 0) AS DECIMAL(10, 0)) pendiente CAST(downstairs - IFNULL(notPickedYed, 0) AS DECIMAL(10, 0)) pendiente
FROM tmp.itemShelvingRadar ishr FROM tItemShelvingRadar ishr
JOIN item i ON i.id = ishr.itemFk JOIN item i ON i.id = ishr.itemFk
LEFT JOIN ( LEFT JOIN (
SELECT s.itemFk, SUM(s.quantity) notPickedYed SELECT s.itemFk, SUM(s.quantity) notPickedYed
@ -111,7 +111,7 @@ BEGIN
) sub ON sub.itemFk = ishr.itemFk ) sub ON sub.itemFk = ishr.itemFk
ORDER BY i.typeFk, i.longName; ORDER BY i.typeFk, i.longName;
ELSE ELSE
CREATE OR REPLACE TEMPORARY TABLE tmp.itemShelvingRadar CREATE OR REPLACE TEMPORARY TABLE tItemShelvingRadar
(PRIMARY KEY (itemFk)) (PRIMARY KEY (itemFk))
ENGINE = MEMORY ENGINE = MEMORY
SELECT iss.itemFk, SELECT iss.itemFk,
@ -158,7 +158,7 @@ BEGIN
IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) `hours`, IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) `hours`,
IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) `minutes` IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) `minutes`
FROM itemTicketOut `io` FROM itemTicketOut `io`
JOIN tmp.itemShelvingRadar isr ON isr.itemFk = io.itemFk JOIN tItemShelvingRadar isr ON isr.itemFk = io.itemFk
JOIN ticket t ON t.id= io.ticketFk JOIN ticket t ON t.id= io.ticketFk
JOIN ticketState ts ON ts.ticketFk = io.ticketFk JOIN ticketState ts ON ts.ticketFk = io.ticketFk
JOIN `state` s ON s.id = ts.stateFk JOIN `state` s ON s.id = ts.stateFk
@ -178,14 +178,14 @@ BEGIN
) sub ) sub
GROUP BY itemFk, `hours`, `minutes`; GROUP BY itemFk, `hours`, `minutes`;
INSERT INTO tmp.itemShelvingRadar (itemFk) INSERT INTO tItemShelvingRadar (itemFk)
SELECT itemFk FROM tmp.itemOutTime SELECT itemFk FROM tmp.itemOutTime
ON DUPLICATE KEY UPDATE dayEndVisible = dayEndVisible + quantity, ON DUPLICATE KEY UPDATE dayEndVisible = dayEndVisible + quantity,
firstNegative = IF(firstNegative < 0, firstNegative, firstNegative + quantity), firstNegative = IF(firstNegative < 0, firstNegative, firstNegative + quantity),
`hour` = IFNULL(IF(firstNegative > 0 , `hour`, `hours`), 0), `hour` = IFNULL(IF(firstNegative > 0 , `hour`, `hours`), 0),
`minute` = IFNULL(IF(firstNegative > 0, `minute`, `minutes`), 0); `minute` = IFNULL(IF(firstNegative > 0, `minute`, `minutes`), 0);
UPDATE tmp.itemShelvingRadar isr UPDATE tItemShelvingRadar isr
JOIN ( JOIN (
SELECT s.itemFk, SUM(s.quantity) amount SELECT s.itemFk, SUM(s.quantity) amount
FROM sale s FROM sale s
@ -198,10 +198,10 @@ BEGIN
SET isr.dayEndVisible = dayEndVisible + sub.amount, SET isr.dayEndVisible = dayEndVisible + sub.amount,
firstNegative = firstNegative + sub.amount; firstNegative = firstNegative + sub.amount;
SELECT * FROM tmp.itemShelvingRadar; SELECT * FROM tItemShelvingRadar;
END IF; END IF;
DROP TEMPORARY TABLE tmp.itemShelvingRadar; DROP TEMPORARY TABLE tItemShelvingRadar;
END$$ END$$
DELIMITER ; DELIMITER ;