2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-11-13 08:03:44 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getAlternatives`(
|
|
|
|
vShelvingCode VARCHAR(10)
|
|
|
|
)
|
2024-01-15 11:31:03 +00:00
|
|
|
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-01-15 11:31:03 +00:00
|
|
|
*
|
2024-11-13 08:03:44 +00:00
|
|
|
* @param vShelvingCode Matricula del carro
|
2024-01-15 11:31:03 +00:00
|
|
|
*/
|
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
|
2024-01-15 11:31:03 +00:00
|
|
|
FROM itemShelving is2
|
2024-11-13 08:03:44 +00:00
|
|
|
JOIN shelving sh ON sh.id = is2.shelvingFk
|
2024-01-15 11:31:03 +00:00
|
|
|
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()
|
2024-01-15 11:31:03 +00:00
|
|
|
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
|
2024-01-15 11:31:03 +00:00
|
|
|
GROUP BY is2.id
|
|
|
|
ORDER BY p.pickingOrder DESC;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|