From 1ec7cd9540dc3e1d003cbb8d31e3b291383af0fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 3 Jul 2024 16:59:01 +0200 Subject: [PATCH 1/3] Hotfix sale_getProblems --- db/routines/vn/procedures/sale_getProblems.sql | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 9944ab0c2..f198be54b 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -278,12 +278,11 @@ BEGIN -- Redondeo: Cantidad pedida incorrecta en al grouping de la Ășltima compra CALL buyUltimate(vWarehouseFk, vDate); INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) - SELECT ticketFk, problem, saleFk + SELECT ticketFk,problem , saleFk FROM ( SELECT tl.ticketFk, - s.id saleFk , - LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,''), ' '), 250) problem, - MOD(s.quantity, b.`grouping`) hasRounding + s.id saleFk, + LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,''), ' '), 250) problem FROM tmp.ticket_list tl JOIN ticket t ON t.id = tl.ticketFk AND t.warehouseFk = vWarehouseFk @@ -291,9 +290,9 @@ BEGIN JOIN item i ON i.id = s.itemFk JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk JOIN buy b ON b.id = bu.buyFk + WHERE MOD(s.quantity, b.`grouping`) GROUP BY tl.ticketFk - HAVING hasRounding - ) sub + )sub ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; END LOOP; CLOSE vCursor; From 097350adb66a233515018f2e8a17b86065fdef54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 3 Jul 2024 17:07:25 +0200 Subject: [PATCH 2/3] Hotfix sale_getProblems --- db/routines/vn/procedures/sale_getProblems.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index f198be54b..ba4ff5857 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -278,11 +278,11 @@ BEGIN -- Redondeo: Cantidad pedida incorrecta en al grouping de la Ășltima compra CALL buyUltimate(vWarehouseFk, vDate); INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) - SELECT ticketFk,problem , saleFk + SELECT ticketFk, problem ,saleFk FROM ( SELECT tl.ticketFk, s.id saleFk, - LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,''), ' '), 250) problem + LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem FROM tmp.ticket_list tl JOIN ticket t ON t.id = tl.ticketFk AND t.warehouseFk = vWarehouseFk From a7b653c42a5f886d8eba1507fff24bcbc8dbdb4d Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 4 Jul 2024 07:34:41 +0200 Subject: [PATCH 3/3] refs #7486 Fix collection_new --- .../vn/procedures/collection_assign.sql | 4 +- db/routines/vn/procedures/collection_get.sql | 45 ++++++++++--------- .../vn/procedures/productionControl.sql | 8 +++- db/routines/vn/procedures/ticket_Clone.sql | 5 +++ 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index 84067e7d8..bf130b2c6 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -47,9 +47,9 @@ BEGIN INTO vHasTooMuchCollections, vLockName FROM productionConfig pc - LEFT JOIN tCollection ON TRUE; + LEFT JOIN tmp.collection ON TRUE; - DROP TEMPORARY TABLE tCollection; + DROP TEMPORARY TABLE tmp.collection; IF vHasTooMuchCollections THEN CALL util.throw('Hay colecciones pendientes'); diff --git a/db/routines/vn/procedures/collection_get.sql b/db/routines/vn/procedures/collection_get.sql index 372d963c0..d29f14ca9 100644 --- a/db/routines/vn/procedures/collection_get.sql +++ b/db/routines/vn/procedures/collection_get.sql @@ -7,27 +7,32 @@ BEGIN * @param vWorkerFk id del worker. * @table Devuelve tabla temporal con las colecciones pendientes */ - DROP TEMPORARY TABLE IF EXISTS tCollection; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + RESIGNAL; + END; - CREATE TEMPORARY TABLE tCollection - SELECT c.id collectionFk, - date(c.created) created, - COUNT(DISTINCT tc.ticketFk) ticketTotalCount - FROM collection c - JOIN ticketCollection tc ON tc.collectionFk = c.id - JOIN sale s ON s.ticketFk = tc.ticketFk - JOIN ticketState ts ON ts.ticketFk = tc.ticketFk - JOIN state s2 ON s2.id = ts.stateFk - JOIN productionConfig pc - JOIN vn.state ss on ss.code = 'PREPARED' - LEFT JOIN vn.saleTracking st on st.saleFk = s.id AND st.stateFk = ss.id - WHERE c.workerFk = vWorkerFk - AND TIMESTAMPDIFF(HOUR, c.created , util.VN_NOW()) < pc.pendingCollectionsAge - AND s.quantity != 0 - AND s2.order < pc.pendingCollectionsOrder - GROUP BY c.id - HAVING COUNT(*) > COUNT(DISTINCT st.id); + CREATE OR REPLACE TEMPORARY TABLE tmp.collection + ENGINE = MEMORY + SELECT c.id collectionFk, + DATE(c.created) created, + COUNT(DISTINCT tc.ticketFk) ticketTotalCount + FROM collection c + JOIN ticketCollection tc ON tc.collectionFk = c.id + JOIN sale s ON s.ticketFk = tc.ticketFk + JOIN ticketState ts ON ts.ticketFk = tc.ticketFk + JOIN state s2 ON s2.id = ts.stateFk + JOIN productionConfig pc + JOIN vn.state ss ON ss.code = 'PREPARED' + LEFT JOIN vn.saleTracking st ON st.saleFk = s.id + AND st.stateFk = ss.id + WHERE c.workerFk = vWorkerFk + AND TIMESTAMPDIFF(HOUR, c.created , util.VN_NOW()) < pc.pendingCollectionsAge + AND s.quantity + AND s2.order < pc.pendingCollectionsOrder + GROUP BY c.id + HAVING COUNT(*) > COUNT(DISTINCT st.id); - SELECT * FROM tCollection; + SELECT * FROM tmp.collection; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index 09c01d1ef..dad46393d 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -15,6 +15,11 @@ proc: BEGIN DECLARE vEndingDate DATETIME; DECLARE vIsTodayRelative BOOLEAN; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + RESIGNAL; + END; + SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY INTO vEndingDate FROM productionConfig; @@ -31,7 +36,8 @@ proc: BEGIN CALL prepareClientList(); CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems - (INDEX (ticketFk)) ENGINE = MEMORY + (INDEX (ticketFk)) + ENGINE = MEMORY SELECT tt.ticketFk, tt.clientFk, t.warehouseFk, t.shipped FROM tmp.productionTicket tt JOIN ticket t ON t.id = tt.ticketFk; diff --git a/db/routines/vn/procedures/ticket_Clone.sql b/db/routines/vn/procedures/ticket_Clone.sql index 7670e832e..d22d3c7ff 100644 --- a/db/routines/vn/procedures/ticket_Clone.sql +++ b/db/routines/vn/procedures/ticket_Clone.sql @@ -9,6 +9,11 @@ BEGIN */ DECLARE vStateFk INT; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + RESIGNAL; + END; + INSERT INTO ticket ( clientFk, shipped,