fix: solo un trabajador por fallo #2210

Merged
jgallego merged 4 commits from 6782-productionError_add into dev 2024-03-27 06:24:26 +00:00
16 changed files with 81 additions and 54 deletions
Showing only changes of commit c3aa4c9355 - Show all commits

View File

@ -2802,7 +2802,7 @@ INSERT INTO `vn`.`packingSiteConfig` (`id`, `shinobiUrl`, `shinobiToken`, `shino
INSERT INTO `util`.`notificationConfig` INSERT INTO `util`.`notificationConfig`
SET `id` = 1, SET `id` = 1,
`cleanDays` = 90; `cleanDays` = 90;
TRUNCATE `util`.`notification`;
INSERT INTO `util`.`notification` (`id`, `name`, `description`) INSERT INTO `util`.`notification` (`id`, `name`, `description`)
VALUES VALUES
(1, 'print-email', 'notification fixture one'), (1, 'print-email', 'notification fixture one'),
@ -2813,6 +2813,7 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`)
(6, 'book-entry-deleted', 'accounting entries deleted'), (6, 'book-entry-deleted', 'accounting entries deleted'),
(7, 'zone-included','An email to notify zoneCollisions'); (7, 'zone-included','An email to notify zoneCollisions');
TRUNCATE `util`.`notificationAcl`;
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
VALUES VALUES
(1, 9), (1, 9),
@ -2824,11 +2825,13 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
(6, 9), (6, 9),
(7, 9); (7, 9);
TRUNCATE `util`.`notificationQueue`;
INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`)
VALUES VALUES
(1, 'print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE()), (1, 'print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE()),
(2, 'print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE()), (2, 'print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE()),
(3, 'print-email', null, null, 'pending', util.VN_CURDATE()); (3, 'print-email', null, null, 'pending', util.VN_CURDATE());
TRUNCATE `util`.`notificationSubscription`;
INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`)
VALUES VALUES

View File

@ -28,6 +28,7 @@ proc:BEGIN
DECLARE vLockName VARCHAR(215); DECLARE vLockName VARCHAR(215);
DECLARE vLockTime INT DEFAULT 15; DECLARE vLockTime INT DEFAULT 15;
DECLARE vFreeWagonFk INT; DECLARE vFreeWagonFk INT;
DECLARE c1 CURSOR FOR DECLARE c1 CURSOR FOR
SELECT ticketFk, `lines`, m3 SELECT ticketFk, `lines`, m3
FROM tmp.productionBuffer FROM tmp.productionBuffer
@ -44,13 +45,21 @@ proc:BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; 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, SELECT pc.ticketTrolleyMax * o.numberOfWagons,
pc.hasUniqueCollectionTime, pc.hasUniqueCollectionTime,
w.code, w.code,
o.warehouseFk, o.warehouseFk,
o.itemPackingTypeFk, o.itemPackingTypeFk,
st.code, st.code,
CONCAT('collection_new', o.warehouseFk, ':',o.itemPackingTypeFk),
o.numberOfWagons, o.numberOfWagons,
o.trainFk, o.trainFk,
o.linesLimit, o.linesLimit,
@ -61,7 +70,6 @@ proc:BEGIN
vWarehouseFk, vWarehouseFk,
vItemPackingTypeFk, vItemPackingTypeFk,
vStateFk, vStateFk,
vLockName,
vWagons, vWagons,
vTrainFk, vTrainFk,
vLinesLimit, vLinesLimit,
@ -71,6 +79,12 @@ proc:BEGIN
JOIN state st ON st.`code` = 'ON_PREPARATION' JOIN state st ON st.`code` = 'ON_PREPARATION'
JOIN operator o ON o.workerFk = vUserFk; JOIN operator o ON o.workerFk = vUserFk;
SET vLockName = CONCAT_WS('/',
'collection_new',
vWarehouseFk,
vItemPackingTypeFk
);
IF NOT GET_LOCK(vLockName, vLockTime) THEN IF NOT GET_LOCK(vLockName, vLockTime) THEN
LEAVE proc; LEAVE proc;
END IF; END IF;
@ -250,13 +264,13 @@ proc:BEGIN
UPDATE tTrain UPDATE tTrain
SET ticketFk = vFirstTicketFk SET ticketFk = vFirstTicketFk
WHERE wagon = vFreeWagonFk; WHERE wagon = vFreeWagonFk;
-- Se anulan el resto de carros libres para que sólo uno lleve un pedido excesivo -- Se anulan el resto de carros libres para que sólo uno lleve un pedido excesivo
DELETE tt.* DELETE tt.*
FROM tTrain tt FROM tTrain tt
LEFT JOIN ( LEFT JOIN (
SELECT DISTINCT wagon SELECT DISTINCT wagon
FROM tTrain FROM tTrain
WHERE ticketFk IS NOT NULL WHERE ticketFk IS NOT NULL
) nn ON nn.wagon = tt.wagon ) nn ON nn.wagon = tt.wagon
WHERE nn.wagon IS NULL; WHERE nn.wagon IS NULL;
@ -271,7 +285,7 @@ proc:BEGIN
FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume; FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume;
IF vDone THEN IF vDone THEN
LEAVE read_loop; LEAVE read_loop;
END IF; END IF;
END IF; END IF;
END LOOP; END LOOP;
CLOSE c1; CLOSE c1;

View File

@ -14,7 +14,7 @@ class File {
*/ */
getPath(dmsUrl) { getPath(dmsUrl) {
const serializedParams = this.$httpParamSerializer({ const serializedParams = this.$httpParamSerializer({
access_token: this.vnToken.token access_token: this.vnToken.tokenMultimedia
}); });
return `${dmsUrl}?${serializedParams}`; return `${dmsUrl}?${serializedParams}`;

View File

@ -15,7 +15,7 @@ class Report {
*/ */
show(path, params) { show(path, params) {
params = Object.assign({ params = Object.assign({
access_token: this.vnToken.token access_token: this.vnToken.tokenMultimedia
}, params); }, params);
const serializedParams = this.$httpParamSerializer(params); const serializedParams = this.$httpParamSerializer(params);
const query = serializedParams ? `?${serializedParams}` : ''; const query = serializedParams ? `?${serializedParams}` : '';

View File

@ -34,7 +34,8 @@ module.exports = Self => {
http: { http: {
path: '/:id/claim-pickup-pdf', path: '/:id/claim-pickup-pdf',
verb: 'GET' verb: 'GET'
} },
accessScopes: ['read:multimedia']
}); });
Self.claimPickupPdf = (ctx, id) => Self.printReport(ctx, id, 'claim-pickup-order'); Self.claimPickupPdf = (ctx, id) => Self.printReport(ctx, id, 'claim-pickup-order');

View File

@ -45,7 +45,8 @@ module.exports = Self => {
http: { http: {
path: '/:id/campaign-metrics-pdf', path: '/:id/campaign-metrics-pdf',
verb: 'GET' verb: 'GET'
} },
accessScopes: ['read:multimedia']
}); });
Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'campaign-metrics'); Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'campaign-metrics');

View File

@ -33,7 +33,8 @@ module.exports = Self => {
http: { http: {
path: '/:id/entry-order-pdf', path: '/:id/entry-order-pdf',
verb: 'GET' verb: 'GET'
} },
accessScopes: ['read:multimedia']
}); });
Self.entryOrderPdf = (ctx, id) => Self.printReport(ctx, id, 'entry-order'); Self.entryOrderPdf = (ctx, id) => Self.printReport(ctx, id, 'entry-order');

View File

@ -34,7 +34,8 @@ module.exports = Self => {
http: { http: {
path: '/:reference/exportation-pdf', path: '/:reference/exportation-pdf',
verb: 'GET' verb: 'GET'
} },
accessScopes: ['read:multimedia']
}); });
Self.exportationPdf = (ctx, reference) => Self.printReport(ctx, reference, 'exportation'); Self.exportationPdf = (ctx, reference) => Self.printReport(ctx, reference, 'exportation');

View File

@ -37,23 +37,24 @@ module.exports = Self => {
http: { http: {
path: '/:reference/invoice-csv', path: '/:reference/invoice-csv',
verb: 'GET' verb: 'GET'
} },
accessScopes: ['read:multimedia']
}); });
Self.invoiceCsv = async reference => { Self.invoiceCsv = async reference => {
const sales = await Self.rawSql(` const sales = await Self.rawSql(`
SELECT io.ref Invoice, SELECT io.ref Invoice,
io.issued InvoiceDate, io.issued InvoiceDate,
s.ticketFk Ticket, s.ticketFk Ticket,
s.itemFk Item, s.itemFk Item,
s.concept Description, s.concept Description,
i.size, i.size,
i.subName Producer, i.subName Producer,
s.quantity Quantity, s.quantity Quantity,
s.price Price, s.price Price,
s.discount Discount, s.discount Discount,
s.created Created, s.created Created,
tc.code Taxcode, tc.code Taxcode,
tc.description TaxDescription, tc.description TaxDescription,
i.tag5, i.tag5,
i.value5, i.value5,
@ -67,14 +68,14 @@ module.exports = Self => {
i.value9, i.value9,
i.tag10, i.tag10,
i.value10 i.value10
FROM sale s FROM sale s
JOIN ticket t ON t.id = s.ticketFk JOIN ticket t ON t.id = s.ticketFk
JOIN item i ON i.id = s.itemFk JOIN item i ON i.id = s.itemFk
JOIN supplier s2 ON s2.id = t.companyFk JOIN supplier s2 ON s2.id = t.companyFk
JOIN itemTaxCountry itc ON itc.itemFk = i.id JOIN itemTaxCountry itc ON itc.itemFk = i.id
AND itc.countryFk = s2.countryFk AND itc.countryFk = s2.countryFk
JOIN taxClass tc ON tc.id = itc.taxClassFk JOIN taxClass tc ON tc.id = itc.taxClassFk
JOIN invoiceOut io ON io.ref = t.refFk JOIN invoiceOut io ON io.ref = t.refFk
WHERE t.refFk = ? WHERE t.refFk = ?
ORDER BY s.ticketFk, s.created`, [reference]); ORDER BY s.ticketFk, s.created`, [reference]);

View File

@ -39,7 +39,8 @@ module.exports = Self => {
http: { http: {
path: '/negativeBasesCsv', path: '/negativeBasesCsv',
verb: 'GET' verb: 'GET'
} },
accessScopes: ['read:multimedia']
}); });
Self.negativeBasesCsv = async(ctx, options) => { Self.negativeBasesCsv = async(ctx, options) => {

View File

@ -44,7 +44,8 @@ module.exports = Self => {
http: { http: {
path: '/:id/campaign-metrics-pdf', path: '/:id/campaign-metrics-pdf',
verb: 'GET' verb: 'GET'
} },
accessScopes: ['read:multimedia']
}); });
Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'supplier-campaign-metrics'); Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'supplier-campaign-metrics');

View File

@ -37,23 +37,24 @@ module.exports = Self => {
http: { http: {
path: '/:id/delivery-note-csv', path: '/:id/delivery-note-csv',
verb: 'GET' verb: 'GET'
} },
accessScopes: ['read:multimedia']
}); });
Self.deliveryNoteCsv = async id => { Self.deliveryNoteCsv = async id => {
const sales = await Self.rawSql(` const sales = await Self.rawSql(`
SELECT io.ref Invoice, SELECT io.ref Invoice,
io.issued InvoiceDate, io.issued InvoiceDate,
s.ticketFk Ticket, s.ticketFk Ticket,
s.itemFk Item, s.itemFk Item,
s.concept Description, s.concept Description,
i.size, i.size,
i.subName Producer, i.subName Producer,
s.quantity Quantity, s.quantity Quantity,
s.price Price, s.price Price,
s.discount Discount, s.discount Discount,
s.created Created, s.created Created,
tc.code Taxcode, tc.code Taxcode,
tc.description TaxDescription, tc.description TaxDescription,
i.tag5, i.tag5,
i.value5, i.value5,
@ -67,14 +68,14 @@ module.exports = Self => {
i.value9, i.value9,
i.tag10, i.tag10,
i.value10 i.value10
FROM vn.sale s FROM vn.sale s
JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.ticket t ON t.id = s.ticketFk
JOIN vn.item i ON i.id = s.itemFk JOIN vn.item i ON i.id = s.itemFk
JOIN vn.supplier s2 ON s2.id = t.companyFk JOIN vn.supplier s2 ON s2.id = t.companyFk
JOIN vn.itemTaxCountry itc ON itc.itemFk = i.id JOIN vn.itemTaxCountry itc ON itc.itemFk = i.id
AND itc.countryFk = s2.countryFk AND itc.countryFk = s2.countryFk
JOIN vn.taxClass tc ON tc.id = itc.taxClassFk JOIN vn.taxClass tc ON tc.id = itc.taxClassFk
LEFT JOIN vn.invoiceOut io ON io.id = t.refFk LEFT JOIN vn.invoiceOut io ON io.id = t.refFk
WHERE s.ticketFk = ? WHERE s.ticketFk = ?
ORDER BY s.ticketFk, s.created`, [id]); ORDER BY s.ticketFk, s.created`, [id]);
const content = toCSV(sales); const content = toCSV(sales);

View File

@ -41,7 +41,8 @@ module.exports = Self => {
http: { http: {
path: '/:id/delivery-note-pdf', path: '/:id/delivery-note-pdf',
verb: 'GET' verb: 'GET'
} },
accessScopes: ['read:multimedia']
}); });
Self.deliveryNotePdf = (ctx, id) => Self.printReport(ctx, id, 'delivery-note'); Self.deliveryNotePdf = (ctx, id) => Self.printReport(ctx, id, 'delivery-note');

View File

@ -78,7 +78,8 @@ module.exports = Self => {
http: { http: {
path: '/extra-community-pdf', path: '/extra-community-pdf',
verb: 'GET' verb: 'GET'
} },
accessScopes: ['read:multimedia']
}); });
Self.extraCommunityPdf = ctx => Self.printReport(ctx, null, 'extra-community'); Self.extraCommunityPdf = ctx => Self.printReport(ctx, null, 'extra-community');

View File

@ -144,7 +144,7 @@ class Controller extends Section {
const currentFilter = this.$.model.currentFilter; const currentFilter = this.$.model.currentFilter;
return Object.assign({ return Object.assign({
authorization: this.vnToken.token, authorization: this.vnToken.tokenMultimedia,
filter: currentFilter filter: currentFilter
}, userParams); }, userParams);
} }