This commit is contained in:
parent
9d49d23be8
commit
9f2057fdd0
|
@ -6,23 +6,25 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_bu
|
|||
OUT vPalletFk INT
|
||||
)
|
||||
BEGIN
|
||||
/** Construye un pallet de expediciones.
|
||||
/**
|
||||
* Builds an expedition pallet.
|
||||
*
|
||||
* Primero comprueba si esas expediciones ya pertenecen a otro pallet,
|
||||
* en cuyo caso actualiza ese pallet.
|
||||
* First, it checks if these expeditions already belong to another pallet,
|
||||
* in which case it returns an error.
|
||||
*
|
||||
* @param vExpeditions JSON_ARRAY con esta estructura [exp1, exp2, exp3, ...]
|
||||
* @param vArcId INT Identificador de arcRead
|
||||
* @param vWorkerFk INT Identificador de worker
|
||||
* @param out vPalletFk Identificador de expeditionPallet
|
||||
* @param vExpeditions JSON_ARRAY with this structure [exp1, exp2, exp3, ...]
|
||||
* @param vArcId INT Identifier of arcRead
|
||||
* @param vWorkerFk INT Identifier of worker
|
||||
* @param out vPalletFk Identifier of expeditionPallet
|
||||
*/
|
||||
|
||||
DECLARE vCounter INT;
|
||||
DECLARE vExpeditionFk INT;
|
||||
DECLARE vExpeditionWithPallet INT;
|
||||
DECLARE vTruckFk INT;
|
||||
DECLARE vPrinterFk INT;
|
||||
DECLARE vExpeditionStateTypeFk INT;
|
||||
DECLARE vExpeditionWithOutPallet INT;
|
||||
DECLARE vFreeExpeditionCount INT;
|
||||
DECLARE vExpeditionWithPallet INT;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tExpedition (
|
||||
expeditionFk INT,
|
||||
|
@ -46,15 +48,19 @@ BEGIN
|
|||
WHERE e.id = vExpeditionFk;
|
||||
END WHILE;
|
||||
|
||||
SELECT COUNT(palletFk) INTO vExpeditionWithPallet FROM tExpedition;
|
||||
SELECT GROUP_CONCAT(expeditionFk SEPARATOR ', ') INTO vExpeditionWithOutPallet
|
||||
SELECT COUNT(expeditionFk) INTO vFreeExpeditionCount
|
||||
FROM tExpedition
|
||||
WHERE palletFk IS NULL;
|
||||
|
||||
SELECT GROUP_CONCAT(expeditionFk SEPARATOR ', ') INTO vExpeditionWithPallet
|
||||
FROM tExpedition
|
||||
WHERE palletFk;
|
||||
|
||||
IF NOT vExpeditionWithPallet THEN
|
||||
IF NOT vFreeExpeditionCount THEN
|
||||
CALL util.throw ('NO_FREE_EXPEDITIONS');
|
||||
END IF;
|
||||
|
||||
|
||||
SELECT roadmapStopFk INTO vTruckFk
|
||||
FROM (
|
||||
SELECT rm.roadmapStopFk, count(*) n
|
||||
|
@ -88,9 +94,9 @@ BEGIN
|
|||
FROM tExpedition
|
||||
WHERE palletFk IS NULL;
|
||||
|
||||
IF vExpeditionWithOutPallet THEN
|
||||
IF vExpeditionWithPallet THEN
|
||||
UPDATE arcRead
|
||||
SET error = vExpeditionWithOutPallet
|
||||
SET error = vExpeditionWithPallet
|
||||
WHERE id = vArcId;
|
||||
ELSE
|
||||
UPDATE arcRead SET error = NULL WHERE id = vArcId;
|
||||
|
|
Loading…
Reference in New Issue