salix/db/routines/vn/procedures/itemShelving_getAlternative...

33 lines
1008 B
MySQL
Raw Normal View History

DELIMITER $$
2024-11-13 08:03:44 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getAlternatives`(
vShelvingCode VARCHAR(10)
)
BEGIN
/**
2024-11-13 08:03:44 +00:00
* Devuelve un listado de posibles ubicaciones alternativas a ubicar
* los item de la matricula del carro que se le ha pasado.
*
2024-11-13 08:03:44 +00:00
* @param vShelvingCode Matricula del carro
*/
2024-11-13 08:03:44 +00:00
DECLARE vShelvingFk INT;
SELECT id INTO vShelvingFk
FROM shelving
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
SELECT is2.id,is2.shelvingFk, p.code, is2.itemFk , is2.visible, p.pickingOrder
FROM itemShelving is2
2024-11-13 08:03:44 +00:00
JOIN shelving sh ON sh.id = is2.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk
2024-11-13 08:03:44 +00:00
LEFT JOIN operator o ON o.sectorFk = s.id
AND o.workerFk = account.myUser_getId()
JOIN warehouse wh ON wh.id = s.warehouseFk
2024-11-13 08:03:44 +00:00
JOIN itemShelving is3 ON is3.itemFk = is2.itemFk
AND is3.shelvingFk = vShelvingFk
WHERE is2.shelvingFk <> vShelvingFk
GROUP BY is2.id
ORDER BY p.pickingOrder DESC;
END$$
DELIMITER ;