From baa1498923c7434a9f780e91876544b121526ed8 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 29 Jul 2024 13:29:26 +0200 Subject: [PATCH 1/3] feat: refs #7712 sizeLimit --- db/routines/vn/procedures/collection_new.sql | 19 +++++++++++++++---- .../11171-maroonMoss/00-firstScript.sql | 8 ++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 db/versions/11171-maroonMoss/00-firstScript.sql diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index 0bd6e1b25..f7f342ea7 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -9,10 +9,11 @@ BEGIN DECLARE vWarehouseFk INT; DECLARE vWagons INT; DECLARE vTrainFk INT; - DECLARE vLinesLimit INT DEFAULT NULL; + DECLARE vLinesLimit INT; DECLARE vTicketLines INT; - DECLARE vVolumeLimit DECIMAL DEFAULT NULL; + DECLARE vVolumeLimit DECIMAL; DECLARE vTicketVolume DECIMAL; + DECLARE vSizeLimit INT; DECLARE vMaxTickets INT; DECLARE vStateFk VARCHAR(45); DECLARE vFirstTicketFk INT; @@ -77,6 +78,7 @@ BEGIN o.trainFk, o.linesLimit, o.volumeLimit, + o.sizeLimit, pc.collection_new_lockname INTO vMaxTickets, vHasUniqueCollectionTime, @@ -88,6 +90,7 @@ BEGIN vTrainFk, vLinesLimit, vVolumeLimit, + vSizeLimit, vLockName FROM productionConfig pc JOIN worker w ON w.id = vUserFk @@ -172,6 +175,13 @@ BEGIN JOIN state s ON s.id = pb.state JOIN agencyMode am ON am.id = pb.agencyModeFk JOIN agency a ON a.id = am.agencyFk + LEFT JOIN ( + SELECT pb.ticketFk, MAX(i.`size`) maxSize + FROM tmp.productionBuffer pb + JOIN ticket t ON t.id = pb.ticketfk + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + ) sub ON sub.ticketFk = pb.ticketFk JOIN productionConfig pc WHERE pb.shipped <> util.VN_CURDATE() OR (pb.ubicacion IS NULL AND a.isOwn) @@ -183,8 +193,9 @@ BEGIN OR (NOT pb.V AND vItemPackingTypeFk = 'V') OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking) OR LENGTH(pb.problem) > 0 - OR (pb.lines >= vLinesLimit AND vLinesLimit IS NOT NULL) - OR (pb.m3 >= vVolumeLimit AND vVolumeLimit IS NOT NULL); + OR (pb.lines > vLinesLimit AND vLinesLimit IS NOT NULL) + OR (pb.m3 > vVolumeLimit AND vVolumeLimit IS NOT NULL) + OR ((sub.maxSize > vSizeLimit OR sub.maxSize IS NOT NULL) AND vSizeLimit IS NOT NULL); END IF; -- Es importante que el primer ticket se coja en todos los casos diff --git a/db/versions/11171-maroonMoss/00-firstScript.sql b/db/versions/11171-maroonMoss/00-firstScript.sql new file mode 100644 index 000000000..1bf0d646b --- /dev/null +++ b/db/versions/11171-maroonMoss/00-firstScript.sql @@ -0,0 +1,8 @@ +ALTER TABLE vn.operator + ADD sizeLimit int(10) unsigned DEFAULT 90 NULL + COMMENT 'Límite de altura en una colección para la asignación de pedidos' + AFTER volumeLimit; + +ALTER TABLE vn.operator + MODIFY COLUMN linesLimit int(10) unsigned DEFAULT 20 NULL + COMMENT 'Límite de lineas en una colección para la asignación de pedidos'; -- 2.40.1 From f9d0afa5da61834c0ac60a5f1b041d9bf90412da Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 09:30:25 +0200 Subject: [PATCH 2/3] feat: refs #7712 Fix --- db/routines/vn/procedures/collection_new.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index f7f342ea7..ee76f3994 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -181,6 +181,7 @@ BEGIN JOIN ticket t ON t.id = pb.ticketfk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk + GROUP BY pb.ticketFk ) sub ON sub.ticketFk = pb.ticketFk JOIN productionConfig pc WHERE pb.shipped <> util.VN_CURDATE() -- 2.40.1 From 1f5145ba9e0a7439ff0165ad8ff0b15cc2ba17aa Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 09:34:02 +0200 Subject: [PATCH 3/3] feat: refs #7712 Unify --- db/versions/11171-maroonMoss/00-firstScript.sql | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/db/versions/11171-maroonMoss/00-firstScript.sql b/db/versions/11171-maroonMoss/00-firstScript.sql index 1bf0d646b..0632239ac 100644 --- a/db/versions/11171-maroonMoss/00-firstScript.sql +++ b/db/versions/11171-maroonMoss/00-firstScript.sql @@ -1,8 +1,3 @@ ALTER TABLE vn.operator - ADD sizeLimit int(10) unsigned DEFAULT 90 NULL - COMMENT 'Límite de altura en una colección para la asignación de pedidos' - AFTER volumeLimit; - -ALTER TABLE vn.operator - MODIFY COLUMN linesLimit int(10) unsigned DEFAULT 20 NULL - COMMENT 'Límite de lineas en una colección para la asignación de pedidos'; + ADD COLUMN sizeLimit int(10) unsigned DEFAULT 90 NULL COMMENT 'Límite de altura en una colección para la asignación de pedidos' AFTER volumeLimit, + MODIFY COLUMN linesLimit int(10) unsigned DEFAULT 20 NULL COMMENT 'Límite de lineas en una colección para la asignación de pedidos'; -- 2.40.1