salix/db/routines/vn/procedures/itemPlacementSupplyStockGet...

33 lines
909 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-11-13 08:03:44 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyStockGetTargetList`(
vItemFk INT,
vSectorFk INT
)
BEGIN
/**
* Devuelve la lista de ubicaciones para itemFk en ese sector. Se utiliza en la preparación previa.
* Este proc se llama a continuacion de ticketToPrePrepare
*
* @param vItemFk Identificador de vn.item
* @param vSectorFk Identificador de vn.sector
*/
SELECT ish.shelvingFk shelving,
2024-01-31 08:38:57 +00:00
p.code parking,
2024-02-06 07:05:30 +00:00
SUM(ish.visible) stockTotal,
2024-01-31 08:38:57 +00:00
ish.created,
p.pickingOrder
2024-11-13 08:03:44 +00:00
FROM itemShelving ish
JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector sc ON sc.id = p.sectorFk
JOIN warehouse w ON w.id = sc.warehouseFk
WHERE ish.visible > 0
2024-02-06 07:05:30 +00:00
AND ish.itemFk = vItemFk
GROUP BY ish.id
ORDER BY
(sc.id = vSectorFk) DESC,
sh.priority DESC,
2024-02-06 07:05:30 +00:00
ish.created,
p.pickingOrder;
END$$
2024-01-31 08:38:57 +00:00
DELIMITER ;