Compare commits
1 Commits
dev
...
7486-fixCo
Author | SHA1 | Date |
---|---|---|
Guillermo Bonet | b457da31e5 |
|
@ -20,13 +20,36 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const [, , [{collectionFk}]] =
|
let threadId;
|
||||||
await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk',
|
|
||||||
|
try {
|
||||||
|
const result =
|
||||||
|
await Self.rawSql(`
|
||||||
|
CALL vn.collection_assign(?, @vCollectionFk);
|
||||||
|
SELECT @vCollectionFk collectionFk,
|
||||||
|
CONNECTION_ID() threadId
|
||||||
|
`,
|
||||||
[userId], myOptions);
|
[userId], myOptions);
|
||||||
|
|
||||||
if (!collectionFk) throw new UserError('There are not picking tickets');
|
threadId = result[2][0].threadId;
|
||||||
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);
|
const collectionFk = result[2][0].collectionFk;
|
||||||
|
if (!collectionFk) throw new UserError('There are not picking tickets');
|
||||||
|
|
||||||
return collectionFk;
|
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);
|
||||||
|
|
||||||
|
return collectionFk;
|
||||||
|
} catch (e) {
|
||||||
|
// Error deadlock refs #7486
|
||||||
|
if (e.code === 'ER_LOCK_DEADLOCK') {
|
||||||
|
const [hasLock] = await Self.rawSql(`
|
||||||
|
SELECT COUNT(*) FROM INFORMATION_SCHEMA.METADATA_LOCK_INFO
|
||||||
|
WHERE LOCK_MODE = 'MDL_SHARED_NO_WRITE'
|
||||||
|
AND THREAD_ID = ?
|
||||||
|
`,
|
||||||
|
[threadId], myOptions);
|
||||||
|
if (hasLock) await Self.rawSql(`KILL ?`, [threadId], myOptions);
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,22 +17,9 @@ BEGIN
|
||||||
DECLARE vWarehouseFk INT;
|
DECLARE vWarehouseFk INT;
|
||||||
DECLARE vLockName VARCHAR(215);
|
DECLARE vLockName VARCHAR(215);
|
||||||
DECLARE vLockTime INT DEFAULT 30;
|
DECLARE vLockTime INT DEFAULT 30;
|
||||||
DECLARE vErrorNumber INT;
|
|
||||||
DECLARE vErrorMsg TEXT;
|
|
||||||
|
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
BEGIN
|
BEGIN
|
||||||
GET DIAGNOSTICS CONDITION 1
|
|
||||||
vErrorNumber = MYSQL_ERRNO,
|
|
||||||
vErrorMsg = MESSAGE_TEXT;
|
|
||||||
|
|
||||||
CALL util.debugAdd('collection_assign', JSON_OBJECT(
|
|
||||||
'errorNumber', vErrorNumber,
|
|
||||||
'errorMsg', vErrorMsg,
|
|
||||||
'lockName', vLockName,
|
|
||||||
'userFk', vUserFk
|
|
||||||
)); -- Tmp
|
|
||||||
|
|
||||||
IF vLockName IS NOT NULL THEN
|
IF vLockName IS NOT NULL THEN
|
||||||
DO RELEASE_LOCK(vLockName);
|
DO RELEASE_LOCK(vLockName);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -7,11 +7,6 @@ BEGIN
|
||||||
* @param vWorkerFk id del worker.
|
* @param vWorkerFk id del worker.
|
||||||
* @table Devuelve tabla temporal con las colecciones pendientes
|
* @table Devuelve tabla temporal con las colecciones pendientes
|
||||||
*/
|
*/
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
||||||
BEGIN
|
|
||||||
RESIGNAL;
|
|
||||||
END;
|
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.collection
|
CREATE OR REPLACE TEMPORARY TABLE tmp.collection
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT c.id collectionFk,
|
SELECT c.id collectionFk,
|
||||||
|
|
|
@ -28,8 +28,6 @@ BEGIN
|
||||||
DECLARE vLockName VARCHAR(215);
|
DECLARE vLockName VARCHAR(215);
|
||||||
DECLARE vLockTime INT DEFAULT 30;
|
DECLARE vLockTime INT DEFAULT 30;
|
||||||
DECLARE vFreeWagonFk INT;
|
DECLARE vFreeWagonFk INT;
|
||||||
DECLARE vErrorNumber INT;
|
|
||||||
DECLARE vErrorMsg TEXT;
|
|
||||||
|
|
||||||
DECLARE c1 CURSOR FOR
|
DECLARE c1 CURSOR FOR
|
||||||
SELECT ticketFk, `lines`, m3
|
SELECT ticketFk, `lines`, m3
|
||||||
|
@ -49,18 +47,6 @@ BEGIN
|
||||||
|
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
BEGIN
|
BEGIN
|
||||||
GET DIAGNOSTICS CONDITION 1
|
|
||||||
vErrorNumber = MYSQL_ERRNO,
|
|
||||||
vErrorMsg = MESSAGE_TEXT;
|
|
||||||
|
|
||||||
CALL util.debugAdd('collection_new', JSON_OBJECT(
|
|
||||||
'errorNumber', vErrorNumber,
|
|
||||||
'errorMsg', vErrorMsg,
|
|
||||||
'lockName', vLockName,
|
|
||||||
'userFk', vUserFk,
|
|
||||||
'ticketFk', vTicketFk
|
|
||||||
)); -- Tmp
|
|
||||||
|
|
||||||
IF vLockName IS NOT NULL THEN
|
IF vLockName IS NOT NULL THEN
|
||||||
DO RELEASE_LOCK(vLockName);
|
DO RELEASE_LOCK(vLockName);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -15,11 +15,6 @@ proc: BEGIN
|
||||||
DECLARE vEndingDate DATETIME;
|
DECLARE vEndingDate DATETIME;
|
||||||
DECLARE vIsTodayRelative BOOLEAN;
|
DECLARE vIsTodayRelative BOOLEAN;
|
||||||
|
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
||||||
BEGIN
|
|
||||||
RESIGNAL;
|
|
||||||
END;
|
|
||||||
|
|
||||||
SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY
|
SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY
|
||||||
INTO vEndingDate
|
INTO vEndingDate
|
||||||
FROM productionConfig;
|
FROM productionConfig;
|
||||||
|
|
|
@ -9,11 +9,6 @@ BEGIN
|
||||||
*/
|
*/
|
||||||
DECLARE vStateFk INT;
|
DECLARE vStateFk INT;
|
||||||
|
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
||||||
BEGIN
|
|
||||||
RESIGNAL;
|
|
||||||
END;
|
|
||||||
|
|
||||||
INSERT INTO ticket (
|
INSERT INTO ticket (
|
||||||
clientFk,
|
clientFk,
|
||||||
shipped,
|
shipped,
|
||||||
|
|
|
@ -27,20 +27,6 @@ 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
|
|
||||||
GET DIAGNOSTICS CONDITION 1
|
|
||||||
vErrorNumber = MYSQL_ERRNO,
|
|
||||||
vErrorMsg = MESSAGE_TEXT;
|
|
||||||
|
|
||||||
CALL util.debugAdd('ticket_splitItemPackingType', JSON_OBJECT(
|
|
||||||
'errorNumber', vErrorNumber,
|
|
||||||
'errorMsg', vErrorMsg,
|
|
||||||
'ticketFk', vTicketFk
|
|
||||||
)); -- Tmp
|
|
||||||
RESIGNAL;
|
|
||||||
END;
|
|
||||||
|
|
||||||
DELETE FROM vn.sale
|
DELETE FROM vn.sale
|
||||||
WHERE quantity = 0
|
WHERE quantity = 0
|
||||||
AND ticketFk = vTicketFk;
|
AND ticketFk = vTicketFk;
|
||||||
|
|
Loading…
Reference in New Issue