2019-10-29 11:29:38 +00:00
|
|
|
|
USE `vn`;
|
|
|
|
|
DROP procedure IF EXISTS `zone_getShippedWarehouse`;
|
|
|
|
|
|
|
|
|
|
DELIMITER $$
|
|
|
|
|
USE `vn`$$
|
|
|
|
|
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getShippedWarehouse`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT)
|
|
|
|
|
BEGIN
|
|
|
|
|
/**
|
|
|
|
|
* Devuelve la mÃnima fecha de envÃo para cada warehouse
|
|
|
|
|
*
|
|
|
|
|
* @param vLanded La fecha de recepcion
|
|
|
|
|
* @param vAddressFk Id del consignatario
|
|
|
|
|
* @param vAgencyModeFk Id de la agencia
|
|
|
|
|
* @return tmp.zoneGetShipped
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
CALL zone_getFromGeo(address_getGeo(vAddressFk));
|
2019-10-31 11:54:16 +00:00
|
|
|
|
CALL zone_getOptionsForLanding(vLanded);
|
2019-10-29 11:29:38 +00:00
|
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetShipped;
|
|
|
|
|
CREATE TEMPORARY TABLE tmp.zoneGetShipped
|
|
|
|
|
ENGINE = MEMORY
|
|
|
|
|
SELECT * FROM (
|
|
|
|
|
SELECT zo.zoneFk,
|
|
|
|
|
TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped,
|
|
|
|
|
zw.warehouseFk
|
|
|
|
|
FROM tmp.zoneOption zo
|
|
|
|
|
JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk
|
|
|
|
|
ORDER BY shipped) t
|
|
|
|
|
GROUP BY warehouseFk;
|
|
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE
|
|
|
|
|
tmp.zone,
|
|
|
|
|
tmp.zoneOption;
|
|
|
|
|
END$$
|
|
|
|
|
|
|
|
|
|
DELIMITER ;
|
|
|
|
|
|