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