2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`conveyorExpedition_Add`(vStarted DATETIME, vEnded DATETIME)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
DECLARE startingMinute INT;
|
|
|
|
|
|
|
|
TRUNCATE vn.conveyorExpedition;
|
|
|
|
|
|
|
|
INSERT INTO vn.conveyorExpedition( expeditionFk,
|
|
|
|
created,
|
|
|
|
length,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
routeFk,
|
|
|
|
productionMinute,
|
|
|
|
truck,
|
|
|
|
criterion,
|
|
|
|
conveyorBuildingClassFk)
|
|
|
|
SELECT e.id,
|
|
|
|
e.created,
|
|
|
|
10 * p.depth as depth,
|
|
|
|
10 * p.width as width,
|
|
|
|
10 * p.height as height,
|
|
|
|
IFNULL(t.routeFk,am.agencyFk) routeFk,
|
|
|
|
hour(e.created) * 60 + minute(e.created),
|
2024-04-30 09:48:18 +00:00
|
|
|
IFNULL(rs.description , a.name),
|
2024-01-15 11:31:03 +00:00
|
|
|
IFNULL(t.routeFk,am.agencyFk) criterion,
|
|
|
|
IFNULL(p.conveyorBuildingClassFk , pc.defaultConveyorBuildingClass)
|
|
|
|
FROM vn.expedition e
|
|
|
|
JOIN vn.ticket t ON t.id = e.ticketFk
|
|
|
|
JOIN vn.packaging p ON p.id = e.packagingFk
|
|
|
|
LEFT JOIN vn.zone z ON z.id = t.zoneFk
|
|
|
|
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
|
|
|
|
LEFT JOIN vn.agency a ON a.id = am.agencyFk
|
|
|
|
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
|
2024-05-27 07:07:23 +00:00
|
|
|
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk
|
2024-01-15 11:31:03 +00:00
|
|
|
JOIN vn.packagingConfig pc
|
|
|
|
WHERE t.warehouseFk IN (60,1,44)
|
|
|
|
AND e.created BETWEEN vStarted AND vEnded
|
|
|
|
AND p.height < 140
|
|
|
|
AND p.width < 60
|
|
|
|
AND p.depth < 125;
|
|
|
|
|
|
|
|
SELECT MIN(productionMinute) INTO startingMinute
|
|
|
|
FROM vn.conveyorExpedition ce ;
|
|
|
|
|
|
|
|
UPDATE vn.conveyorExpedition
|
|
|
|
SET productionMinute = productionMinute - startingMinute;
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|