fix: refs #7781 prevent pallet merge
gitea/salix/pipeline/pr-master This commit looks good Details

This commit is contained in:
Pablo Natek 2024-07-25 15:03:33 +02:00
parent 25464f8a96
commit 6845f1456e
1 changed files with 40 additions and 31 deletions

View File

@ -18,9 +18,11 @@ BEGIN
*/
DECLARE vCounter INT;
DECLARE vExpeditionFk INT;
DECLARE vExpeditionWithPallet INT;
DECLARE vTruckFk INT;
DECLARE vPrinterFk INT;
DECLARE vExpeditionStateTypeFk INT;
DECLARE vExpeditionWithOutPallet INT;
CREATE OR REPLACE TEMPORARY TABLE tExpedition (
expeditionFk INT,
@ -44,23 +46,21 @@ BEGIN
WHERE e.id = vExpeditionFk;
END WHILE;
SELECT palletFk INTO vPalletFk
FROM (
SELECT palletFk, count(*) n
SELECT COUNT(palletFk) INTO vExpeditionWithPallet FROM tExpedition;
SELECT GROUP_CONCAT(expeditionFk SEPARATOR ', ') INTO vExpeditionWithOutPallet
FROM tExpedition
WHERE palletFk > 0
GROUP BY palletFk
ORDER BY n DESC
LIMIT 100
) sub
LIMIT 1;
WHERE palletFk;
IF NOT vExpeditionWithPallet THEN
CALL util.throw ('NO_FREE_EXPEDITIONS');
END IF;
IF vPalletFk IS NULL THEN
SELECT roadmapStopFk INTO vTruckFk
FROM (
SELECT rm.roadmapStopFk, count(*) n
FROM routesMonitor rm
JOIN tExpedition e ON e.routeFk = rm.routeFk
WHERE e.palletFk IS NULL
GROUP BY roadmapStopFk
ORDER BY n DESC
LIMIT 1
@ -73,19 +73,28 @@ BEGIN
INSERT INTO expeditionPallet SET truckFk = vTruckFk;
SET vPalletFk = LAST_INSERT_ID();
END IF;
INSERT INTO expeditionScan(expeditionFk, palletFk, workerFk)
SELECT expeditionFk, vPalletFk, vWorkerFk
FROM tExpedition
ON DUPLICATE KEY UPDATE palletFk = vPalletFk, workerFk = vWorkerFk;
WHERE palletFk IS NULL;
SELECT id INTO vExpeditionStateTypeFk
FROM expeditionStateType
WHERE code = 'PALLETIZED';
INSERT INTO expeditionState(expeditionFk, typeFk)
SELECT expeditionFk, vExpeditionStateTypeFk FROM tExpedition;
SELECT expeditionFk, vExpeditionStateTypeFk
FROM tExpedition
WHERE palletFk IS NULL;
IF vExpeditionWithPallet THEN
UPDATE arcRead
SET error = vExpeditionWithOutPallet
WHERE id = vArcId;
ELSE
UPDATE arcRead SET error = NULL WHERE id = vArcId;
END IF;
SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId;