2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`setParking`(IN `vParam` VARCHAR(8), IN `vParkingCode` VARCHAR(8))
|
|
|
|
proc: BEGIN
|
|
|
|
/**
|
|
|
|
* Aparca una colección, un ticket, un saleGroup o un shelving en un parking
|
|
|
|
*
|
|
|
|
* @param vParam id del ticket, colección, saleGroup o shelving
|
|
|
|
* @param vParkingCode código del parking
|
|
|
|
*/
|
|
|
|
DECLARE vParkingFk INT;
|
|
|
|
DECLARE vIsSaleGroup BOOL;
|
|
|
|
DECLARE vIsTicket BOOL;
|
|
|
|
DECLARE vIsCollection BOOL;
|
|
|
|
|
|
|
|
SET vParkingCode = replace(vParkingCode,' ','');
|
|
|
|
|
|
|
|
SELECT id INTO vParkingFk
|
|
|
|
FROM vn.parking
|
|
|
|
WHERE code = vParkingCode COLLATE utf8_unicode_ci;
|
|
|
|
|
|
|
|
IF vParkingFk IS NULL THEN
|
|
|
|
CALL util.throw('parkingNotExist');
|
|
|
|
LEAVE proc;
|
|
|
|
END IF;
|
2024-07-01 07:25:00 +00:00
|
|
|
|
|
|
|
IF vParam REGEXP '^[0-9]+$' THEN
|
|
|
|
-- Se comprueba si es una preparación previa
|
|
|
|
SELECT COUNT(*) INTO vIsSaleGroup
|
|
|
|
FROM vn.saleGroup sg
|
|
|
|
WHERE sg.id = vParam;
|
|
|
|
|
|
|
|
IF vIsSaleGroup THEN
|
|
|
|
CALL vn.saleGroup_setParking(vParam, vParkingFk);
|
|
|
|
LEAVE proc;
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
-- Se comprueba si es un ticket
|
|
|
|
SELECT COUNT(*) INTO vIsTicket
|
|
|
|
FROM vn.ticket t
|
|
|
|
WHERE t.id = vParam
|
|
|
|
AND t.shipped >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
|
|
|
|
|
|
|
|
IF vIsTicket THEN
|
|
|
|
CALL vn.ticket_setParking(vParam, vParkingFk);
|
|
|
|
LEAVE proc;
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
-- Se comprueba si es una coleccion de tickets
|
|
|
|
SELECT COUNT(*) INTO vIsCollection
|
|
|
|
FROM vn.collection c
|
|
|
|
WHERE c.id = vParam
|
|
|
|
AND c.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
|
|
|
|
|
|
|
|
IF vIsCollection THEN
|
|
|
|
CALL vn.collection_setParking(vParam, vParkingFk);
|
|
|
|
LEAVE proc;
|
|
|
|
END IF;
|
|
|
|
ELSE
|
|
|
|
-- Por descarte, se considera una matrícula
|
|
|
|
CALL vn.shelving_setParking(vParam, vParkingFk);
|
2024-01-15 11:31:03 +00:00
|
|
|
END IF;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|