From e47b8c10568d4453bb7ce16fe4059dd9c980c8de Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 26 Mar 2024 08:52:01 +0100 Subject: [PATCH 1/7] fix: solo un trabajador por fallo --- .../vn/procedures/productionError_add.sql | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/db/routines/vn/procedures/productionError_add.sql b/db/routines/vn/procedures/productionError_add.sql index 5e0ce93f0..a872ca511 100644 --- a/db/routines/vn/procedures/productionError_add.sql +++ b/db/routines/vn/procedures/productionError_add.sql @@ -34,16 +34,22 @@ BEGIN -- Rellena la tabla tmp.errorsByChecker con fallos de revisores CREATE OR REPLACE TEMPORARY TABLE tmp.errorsByChecker ENGINE = MEMORY - SELECT st.workerFk, - COUNT(t.id) errors - FROM saleMistake sm - JOIN saleTracking st ON sm.saleFk = st.saleFk - JOIN `state` s2 ON s2.id = st.stateFk - JOIN sale s ON s.id = sm.saleFk - JOIN ticket t on t.id = s.ticketFk - WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) - AND s2.code IN ('OK','PREVIOUS_PREPARATION','PREPARED','CHECKED') - GROUP BY st.workerFk; + WITH rankedWorkers AS ( + SELECT sm.id, + st.workerFk, + ROW_NUMBER() OVER(PARTITION BY sm.id ORDER BY s2.`order`) AS rnk + FROM saleMistake sm + JOIN saleTracking st ON sm.saleFk = st.saleFk + JOIN `state` s2 ON s2.id = st.stateFk + JOIN sale s ON s.id = sm.saleFk + JOIN ticket t ON t.id = s.ticketFk + WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + AND s2.code IN ('OK', 'PREVIOUS_PREPARATION', 'PREPARED', 'CHECKED') + ) + SELECT workerFk, COUNT(*) AS errors + FROM rankedWorkers + WHERE rnk = 1 + GROUP BY workerFk; -- Rellena la tabla tmp.expeditionErrors con fallos de expediciones CREATE OR REPLACE TEMPORARY TABLE tmp.expeditionErrors From b978833a64151646a1587138dfcf05f39656dd6b Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 26 Mar 2024 09:46:53 +0100 Subject: [PATCH 2/7] fix: #6782 with con esquema --- db/routines/vn/procedures/productionError_add.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/productionError_add.sql b/db/routines/vn/procedures/productionError_add.sql index a872ca511..dcbe379dc 100644 --- a/db/routines/vn/procedures/productionError_add.sql +++ b/db/routines/vn/procedures/productionError_add.sql @@ -38,11 +38,11 @@ BEGIN SELECT sm.id, st.workerFk, ROW_NUMBER() OVER(PARTITION BY sm.id ORDER BY s2.`order`) AS rnk - FROM saleMistake sm - JOIN saleTracking st ON sm.saleFk = st.saleFk - JOIN `state` s2 ON s2.id = st.stateFk - JOIN sale s ON s.id = sm.saleFk - JOIN ticket t ON t.id = s.ticketFk + FROM vn.saleMistake sm + JOIN vn.saleTracking st ON sm.saleFk = st.saleFk + JOIN vn.`state` s2 ON s2.id = st.stateFk + JOIN vn.sale s ON s.id = sm.saleFk + JOIN vn.ticket t ON t.id = s.ticketFk WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND s2.code IN ('OK', 'PREVIOUS_PREPARATION', 'PREPARED', 'CHECKED') ) From a2a16d227cfe22f060898f2f7b9f151c4ffdcca8 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 26 Mar 2024 12:41:30 +0000 Subject: [PATCH 3/7] refs #5858 fix rename file --- .../{01-notification.vn.sql => 01-notification.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/versions/10881-greenHydrangea/{01-notification.vn.sql => 01-notification.sql} (100%) diff --git a/db/versions/10881-greenHydrangea/01-notification.vn.sql b/db/versions/10881-greenHydrangea/01-notification.sql similarity index 100% rename from db/versions/10881-greenHydrangea/01-notification.vn.sql rename to db/versions/10881-greenHydrangea/01-notification.sql From 1472fc6fc24a45798946a67096468e96e25697d9 Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 26 Mar 2024 14:02:47 +0100 Subject: [PATCH 4/7] feat: #6782 sin as --- db/routines/vn/procedures/productionError_add.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/productionError_add.sql b/db/routines/vn/procedures/productionError_add.sql index dcbe379dc..e29accac9 100644 --- a/db/routines/vn/procedures/productionError_add.sql +++ b/db/routines/vn/procedures/productionError_add.sql @@ -37,7 +37,7 @@ BEGIN WITH rankedWorkers AS ( SELECT sm.id, st.workerFk, - ROW_NUMBER() OVER(PARTITION BY sm.id ORDER BY s2.`order`) AS rnk + ROW_NUMBER() OVER(PARTITION BY sm.id ORDER BY s2.`order`) rnk FROM vn.saleMistake sm JOIN vn.saleTracking st ON sm.saleFk = st.saleFk JOIN vn.`state` s2 ON s2.id = st.stateFk @@ -46,7 +46,7 @@ BEGIN WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND s2.code IN ('OK', 'PREVIOUS_PREPARATION', 'PREPARED', 'CHECKED') ) - SELECT workerFk, COUNT(*) AS errors + SELECT workerFk, COUNT(*) errors FROM rankedWorkers WHERE rnk = 1 GROUP BY workerFk; From 38c5209c33ec01855200467390d1809e361df25f Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 26 Mar 2024 14:59:19 +0100 Subject: [PATCH 5/7] refs #6930 fix more endpoints --- front/core/services/file.js | 2 +- front/core/services/report.js | 2 +- .../back/methods/claim/claimPickupPdf.js | 3 +- .../back/methods/client/campaignMetricsPdf.js | 3 +- .../entry/back/methods/entry/entryOrderPdf.js | 3 +- .../back/methods/invoiceOut/exportationPdf.js | 3 +- .../back/methods/invoiceOut/invoiceCsv.js | 37 ++++++++++--------- .../methods/invoiceOut/negativeBasesCsv.js | 3 +- .../methods/supplier/campaignMetricsPdf.js | 3 +- .../back/methods/ticket/deliveryNoteCsv.js | 37 ++++++++++--------- .../back/methods/ticket/deliveryNotePdf.js | 3 +- .../back/methods/travel/extraCommunityPdf.js | 3 +- modules/travel/front/extra-community/index.js | 2 +- 13 files changed, 57 insertions(+), 47 deletions(-) diff --git a/front/core/services/file.js b/front/core/services/file.js index 25ace4470..dfd2ebc83 100644 --- a/front/core/services/file.js +++ b/front/core/services/file.js @@ -14,7 +14,7 @@ class File { */ getPath(dmsUrl) { const serializedParams = this.$httpParamSerializer({ - access_token: this.vnToken.token + access_token: this.vnToken.tokenMultimedia }); return `${dmsUrl}?${serializedParams}`; diff --git a/front/core/services/report.js b/front/core/services/report.js index d6eb28ea4..e3579dd5a 100644 --- a/front/core/services/report.js +++ b/front/core/services/report.js @@ -15,7 +15,7 @@ class Report { */ show(path, params) { params = Object.assign({ - access_token: this.vnToken.token + access_token: this.vnToken.tokenMultimedia }, params); const serializedParams = this.$httpParamSerializer(params); const query = serializedParams ? `?${serializedParams}` : ''; diff --git a/modules/claim/back/methods/claim/claimPickupPdf.js b/modules/claim/back/methods/claim/claimPickupPdf.js index 4927efa0f..4b66bd418 100644 --- a/modules/claim/back/methods/claim/claimPickupPdf.js +++ b/modules/claim/back/methods/claim/claimPickupPdf.js @@ -34,7 +34,8 @@ module.exports = Self => { http: { path: '/:id/claim-pickup-pdf', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.claimPickupPdf = (ctx, id) => Self.printReport(ctx, id, 'claim-pickup-order'); diff --git a/modules/client/back/methods/client/campaignMetricsPdf.js b/modules/client/back/methods/client/campaignMetricsPdf.js index e163b0619..20c35494e 100644 --- a/modules/client/back/methods/client/campaignMetricsPdf.js +++ b/modules/client/back/methods/client/campaignMetricsPdf.js @@ -45,7 +45,8 @@ module.exports = Self => { http: { path: '/:id/campaign-metrics-pdf', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'campaign-metrics'); diff --git a/modules/entry/back/methods/entry/entryOrderPdf.js b/modules/entry/back/methods/entry/entryOrderPdf.js index f77832162..93c1b6bd9 100644 --- a/modules/entry/back/methods/entry/entryOrderPdf.js +++ b/modules/entry/back/methods/entry/entryOrderPdf.js @@ -33,7 +33,8 @@ module.exports = Self => { http: { path: '/:id/entry-order-pdf', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.entryOrderPdf = (ctx, id) => Self.printReport(ctx, id, 'entry-order'); diff --git a/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js b/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js index 7a2526b35..0b08aec6d 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js +++ b/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js @@ -34,7 +34,8 @@ module.exports = Self => { http: { path: '/:reference/exportation-pdf', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.exportationPdf = (ctx, reference) => Self.printReport(ctx, reference, 'exportation'); diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js index c734b588c..6822e5a23 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js +++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js @@ -37,23 +37,24 @@ module.exports = Self => { http: { path: '/:reference/invoice-csv', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.invoiceCsv = async reference => { const sales = await Self.rawSql(` SELECT io.ref Invoice, io.issued InvoiceDate, - s.ticketFk Ticket, - s.itemFk Item, - s.concept Description, - i.size, + s.ticketFk Ticket, + s.itemFk Item, + s.concept Description, + i.size, i.subName Producer, - s.quantity Quantity, - s.price Price, - s.discount Discount, - s.created Created, - tc.code Taxcode, + s.quantity Quantity, + s.price Price, + s.discount Discount, + s.created Created, + tc.code Taxcode, tc.description TaxDescription, i.tag5, i.value5, @@ -67,14 +68,14 @@ module.exports = Self => { i.value9, i.tag10, i.value10 - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN item i ON i.id = s.itemFk - JOIN supplier s2 ON s2.id = t.companyFk - JOIN itemTaxCountry itc ON itc.itemFk = i.id - AND itc.countryFk = s2.countryFk - JOIN taxClass tc ON tc.id = itc.taxClassFk - JOIN invoiceOut io ON io.ref = t.refFk + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN supplier s2 ON s2.id = t.companyFk + JOIN itemTaxCountry itc ON itc.itemFk = i.id + AND itc.countryFk = s2.countryFk + JOIN taxClass tc ON tc.id = itc.taxClassFk + JOIN invoiceOut io ON io.ref = t.refFk WHERE t.refFk = ? ORDER BY s.ticketFk, s.created`, [reference]); diff --git a/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js b/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js index 87e9a67ea..6ac56b68c 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js +++ b/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js @@ -39,7 +39,8 @@ module.exports = Self => { http: { path: '/negativeBasesCsv', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.negativeBasesCsv = async(ctx, options) => { diff --git a/modules/supplier/back/methods/supplier/campaignMetricsPdf.js b/modules/supplier/back/methods/supplier/campaignMetricsPdf.js index f7ff900e7..51c626e69 100644 --- a/modules/supplier/back/methods/supplier/campaignMetricsPdf.js +++ b/modules/supplier/back/methods/supplier/campaignMetricsPdf.js @@ -44,7 +44,8 @@ module.exports = Self => { http: { path: '/:id/campaign-metrics-pdf', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'supplier-campaign-metrics'); diff --git a/modules/ticket/back/methods/ticket/deliveryNoteCsv.js b/modules/ticket/back/methods/ticket/deliveryNoteCsv.js index 40526ac16..9fa3c183e 100644 --- a/modules/ticket/back/methods/ticket/deliveryNoteCsv.js +++ b/modules/ticket/back/methods/ticket/deliveryNoteCsv.js @@ -37,23 +37,24 @@ module.exports = Self => { http: { path: '/:id/delivery-note-csv', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.deliveryNoteCsv = async id => { const sales = await Self.rawSql(` SELECT io.ref Invoice, io.issued InvoiceDate, - s.ticketFk Ticket, - s.itemFk Item, - s.concept Description, - i.size, + s.ticketFk Ticket, + s.itemFk Item, + s.concept Description, + i.size, i.subName Producer, - s.quantity Quantity, - s.price Price, - s.discount Discount, - s.created Created, - tc.code Taxcode, + s.quantity Quantity, + s.price Price, + s.discount Discount, + s.created Created, + tc.code Taxcode, tc.description TaxDescription, i.tag5, i.value5, @@ -67,14 +68,14 @@ module.exports = Self => { i.value9, i.tag10, i.value10 - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.supplier s2 ON s2.id = t.companyFk - JOIN vn.itemTaxCountry itc ON itc.itemFk = i.id - AND itc.countryFk = s2.countryFk - JOIN vn.taxClass tc ON tc.id = itc.taxClassFk - LEFT JOIN vn.invoiceOut io ON io.id = t.refFk + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.supplier s2 ON s2.id = t.companyFk + JOIN vn.itemTaxCountry itc ON itc.itemFk = i.id + AND itc.countryFk = s2.countryFk + JOIN vn.taxClass tc ON tc.id = itc.taxClassFk + LEFT JOIN vn.invoiceOut io ON io.id = t.refFk WHERE s.ticketFk = ? ORDER BY s.ticketFk, s.created`, [id]); const content = toCSV(sales); diff --git a/modules/ticket/back/methods/ticket/deliveryNotePdf.js b/modules/ticket/back/methods/ticket/deliveryNotePdf.js index 628e16bcd..adc9e4435 100644 --- a/modules/ticket/back/methods/ticket/deliveryNotePdf.js +++ b/modules/ticket/back/methods/ticket/deliveryNotePdf.js @@ -41,7 +41,8 @@ module.exports = Self => { http: { path: '/:id/delivery-note-pdf', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.deliveryNotePdf = (ctx, id) => Self.printReport(ctx, id, 'delivery-note'); diff --git a/modules/travel/back/methods/travel/extraCommunityPdf.js b/modules/travel/back/methods/travel/extraCommunityPdf.js index 676b98be2..73748ac50 100644 --- a/modules/travel/back/methods/travel/extraCommunityPdf.js +++ b/modules/travel/back/methods/travel/extraCommunityPdf.js @@ -78,7 +78,8 @@ module.exports = Self => { http: { path: '/extra-community-pdf', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.extraCommunityPdf = ctx => Self.printReport(ctx, null, 'extra-community'); diff --git a/modules/travel/front/extra-community/index.js b/modules/travel/front/extra-community/index.js index 2028c9c19..6e9c39f43 100644 --- a/modules/travel/front/extra-community/index.js +++ b/modules/travel/front/extra-community/index.js @@ -144,7 +144,7 @@ class Controller extends Section { const currentFilter = this.$.model.currentFilter; return Object.assign({ - authorization: this.vnToken.token, + authorization: this.vnToken.tokenMultimedia, filter: currentFilter }, userParams); } From 9aa46c3a90d7f54dfa36ffda42d1464ef9225d1a Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 26 Mar 2024 16:50:15 +0100 Subject: [PATCH 6/7] fix: HOTFIX PROC vn.collection_new release lock on error --- db/routines/vn/procedures/collection_new.sql | 26 +++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index d91c63c24..82196585d 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -28,6 +28,7 @@ proc:BEGIN DECLARE vLockName VARCHAR(215); DECLARE vLockTime INT DEFAULT 15; DECLARE vFreeWagonFk INT; + DECLARE c1 CURSOR FOR SELECT ticketFk, `lines`, m3 FROM tmp.productionBuffer @@ -44,13 +45,21 @@ proc:BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + IF vLockName IS NOT NULL THEN + DO RELEASE_LOCK(vLockName); + END IF; + + RESIGNAL; + END; + SELECT pc.ticketTrolleyMax * o.numberOfWagons, pc.hasUniqueCollectionTime, w.code, o.warehouseFk, o.itemPackingTypeFk, st.code, - CONCAT('collection_new', o.warehouseFk, ':',o.itemPackingTypeFk), o.numberOfWagons, o.trainFk, o.linesLimit, @@ -61,7 +70,6 @@ proc:BEGIN vWarehouseFk, vItemPackingTypeFk, vStateFk, - vLockName, vWagons, vTrainFk, vLinesLimit, @@ -71,6 +79,12 @@ proc:BEGIN JOIN state st ON st.`code` = 'ON_PREPARATION' JOIN operator o ON o.workerFk = vUserFk; + SET vLockName = CONCAT_WS('/', + 'collection_new', + vWarehouseFk, + vItemPackingTypeFk + ); + IF NOT GET_LOCK(vLockName, vLockTime) THEN LEAVE proc; END IF; @@ -250,13 +264,13 @@ proc:BEGIN UPDATE tTrain SET ticketFk = vFirstTicketFk WHERE wagon = vFreeWagonFk; - + -- Se anulan el resto de carros libres para que sólo uno lleve un pedido excesivo DELETE tt.* FROM tTrain tt LEFT JOIN ( - SELECT DISTINCT wagon - FROM tTrain + SELECT DISTINCT wagon + FROM tTrain WHERE ticketFk IS NOT NULL ) nn ON nn.wagon = tt.wagon WHERE nn.wagon IS NULL; @@ -271,7 +285,7 @@ proc:BEGIN FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume; IF vDone THEN LEAVE read_loop; - END IF; + END IF; END IF; END LOOP; CLOSE c1; From fe042e4d86b8807a80f33d21ac336e2db2348fc7 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 27 Mar 2024 06:50:22 +0100 Subject: [PATCH 7/7] refs #5858 fix: test --- db/dump/fixtures.before.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 4af445bfa..69e00b6c8 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2802,7 +2802,7 @@ INSERT INTO `vn`.`packingSiteConfig` (`id`, `shinobiUrl`, `shinobiToken`, `shino INSERT INTO `util`.`notificationConfig` SET `id` = 1, `cleanDays` = 90; - +TRUNCATE `util`.`notification`; INSERT INTO `util`.`notification` (`id`, `name`, `description`) VALUES (1, 'print-email', 'notification fixture one'), @@ -2813,6 +2813,7 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`) (6, 'book-entry-deleted', 'accounting entries deleted'), (7, 'zone-included','An email to notify zoneCollisions'); +TRUNCATE `util`.`notificationAcl`; INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) VALUES (1, 9), @@ -2824,11 +2825,13 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) (6, 9), (7, 9); +TRUNCATE `util`.`notificationQueue`; INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) VALUES (1, 'print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE()), (2, 'print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE()), (3, 'print-email', null, null, 'pending', util.VN_CURDATE()); +TRUNCATE `util`.`notificationSubscription`; INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) VALUES