41 lines
1.1 KiB
MySQL
41 lines
1.1 KiB
MySQL
|
USE `vn`;
|
||
|
DROP procedure IF EXISTS `zone_getLanded`;
|
||
|
|
||
|
DELIMITER $$
|
||
|
USE `vn`$$
|
||
|
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT, vShowExpiredZones BOOLEAN)
|
||
|
BEGIN
|
||
|
/**
|
||
|
* Devuelve una tabla temporal con el dia de recepcion para vShipped.
|
||
|
*
|
||
|
* @param vShipped Fecha de preparacion de mercancia
|
||
|
* @param vAddressFk Id de consignatario, %NULL para recogida
|
||
|
* @param vAgencyModeFk Id agencia
|
||
|
* @param vWarehouseFk vWarehouseFk
|
||
|
* @table tmp.zoneGetLanded Datos de recepción
|
||
|
*/
|
||
|
|
||
|
CALL zone_getFromGeo(address_getGeo(vAddressFk));
|
||
|
CALL zone_getOptionsForShipment(vShipped, vShowExpiredZones);
|
||
|
|
||
|
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded;
|
||
|
CREATE TEMPORARY TABLE tmp.zoneGetLanded
|
||
|
ENGINE = MEMORY
|
||
|
SELECT vWarehouseFk warehouseFk,
|
||
|
TIMESTAMPADD(DAY,zo.travelingDays, vShipped) landed,
|
||
|
zo.zoneFk
|
||
|
FROM tmp.zoneOption zo
|
||
|
JOIN zone z ON z.id = zo.zoneFk
|
||
|
JOIN zoneWarehouse zw ON zw.zoneFk = z.id
|
||
|
WHERE agencyModeFk = vAgencyModeFk
|
||
|
AND zw.warehouseFk = vWarehouseFk;
|
||
|
|
||
|
DROP TEMPORARY TABLE
|
||
|
tmp.zone,
|
||
|
tmp.zoneOption;
|
||
|
|
||
|
END$$
|
||
|
|
||
|
DELIMITER ;
|
||
|
|