This commit is contained in:
parent
1bb20b1bc3
commit
b457da31e5
|
@ -20,13 +20,36 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const [, , [{collectionFk}]] =
|
||||
await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk',
|
||||
let threadId;
|
||||
|
||||
try {
|
||||
const result =
|
||||
await Self.rawSql(`
|
||||
CALL vn.collection_assign(?, @vCollectionFk);
|
||||
SELECT @vCollectionFk collectionFk,
|
||||
CONNECTION_ID() threadId
|
||||
`,
|
||||
[userId], myOptions);
|
||||
|
||||
if (!collectionFk) throw new UserError('There are not picking tickets');
|
||||
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);
|
||||
threadId = result[2][0].threadId;
|
||||
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 vLockName VARCHAR(215);
|
||||
DECLARE vLockTime INT DEFAULT 30;
|
||||
DECLARE vErrorNumber INT;
|
||||
DECLARE vErrorMsg TEXT;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
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
|
||||
DO RELEASE_LOCK(vLockName);
|
||||
END IF;
|
||||
|
|
|
@ -7,11 +7,6 @@ BEGIN
|
|||
* @param vWorkerFk id del worker.
|
||||
* @table Devuelve tabla temporal con las colecciones pendientes
|
||||
*/
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.collection
|
||||
ENGINE = MEMORY
|
||||
SELECT c.id collectionFk,
|
||||
|
|
|
@ -28,8 +28,6 @@ BEGIN
|
|||
DECLARE vLockName VARCHAR(215);
|
||||
DECLARE vLockTime INT DEFAULT 30;
|
||||
DECLARE vFreeWagonFk INT;
|
||||
DECLARE vErrorNumber INT;
|
||||
DECLARE vErrorMsg TEXT;
|
||||
|
||||
DECLARE c1 CURSOR FOR
|
||||
SELECT ticketFk, `lines`, m3
|
||||
|
@ -49,18 +47,6 @@ BEGIN
|
|||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
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
|
||||
DO RELEASE_LOCK(vLockName);
|
||||
END IF;
|
||||
|
|
|
@ -15,11 +15,6 @@ 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;
|
||||
|
|
|
@ -9,11 +9,6 @@ BEGIN
|
|||
*/
|
||||
DECLARE vStateFk INT;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
INSERT INTO ticket (
|
||||
clientFk,
|
||||
shipped,
|
||||
|
|
|
@ -27,20 +27,6 @@ BEGIN
|
|||
|
||||
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
|
||||
WHERE quantity = 0
|
||||
AND ticketFk = vTicketFk;
|
||||
|
|
Loading…
Reference in New Issue