From 2273dc636e4652900fd816301d2baba335483bff Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 09:56:38 +0100 Subject: [PATCH] refactor: refs #7920 Major changes --- db/routines/vn/procedures/shelvingChange.sql | 11 +++++------ .../vn/procedures/shelvingParking_get.sql | 19 +++++++++++-------- .../vn/procedures/shelving_getSpam.sql | 4 ++-- .../ticketDown_PrintableSelection.sql | 2 +- .../vn/procedures/ticket_DelayTruckSplit.sql | 2 +- .../vn/procedures/ticket_getSplitList.sql | 2 +- db/routines/vn/views/itemShelvingList.sql | 2 +- .../itemShelvingPlacementSupplyStock.sql | 2 +- db/routines/vn/views/itemShelvingSaleSum.sql | 2 +- db/routines/vn/views/itemShelvingStock.sql | 2 +- .../vn/views/itemShelvingStockFull.sql | 2 +- 11 files changed, 26 insertions(+), 24 deletions(-) diff --git a/db/routines/vn/procedures/shelvingChange.sql b/db/routines/vn/procedures/shelvingChange.sql index 2e7e92082..f0756b385 100644 --- a/db/routines/vn/procedures/shelvingChange.sql +++ b/db/routines/vn/procedures/shelvingChange.sql @@ -1,11 +1,10 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingChange`(IN `vShelvingO` VARCHAR(8), IN `vShelvingD` VARCHAR(8)) BEGIN - - UPDATE vn.itemShelving - SET shelvingFk = vShelvingD COLLATE utf8_unicode_ci - WHERE shelvingFk = vShelvingO COLLATE utf8_unicode_ci; - - + UPDATE itemShelving ish + JOIN shelving sh1 ON sh1.code = vShelvingD COLLATE utf8_unicode_ci + JOIN shelving sh2 ON sh2.code = vShelvingO COLLATE utf8_unicode_ci + SET ish.shelvingFk = sh1.id + WHERE ish.shelvingFk = sh2.id; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/shelvingParking_get.sql b/db/routines/vn/procedures/shelvingParking_get.sql index a9ed9f74a..c05e8afc3 100644 --- a/db/routines/vn/procedures/shelvingParking_get.sql +++ b/db/routines/vn/procedures/shelvingParking_get.sql @@ -1,8 +1,10 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingParking_get`(vShelvingFk VARCHAR(10), vWarehouseFk INT, vDayRange INT) -BEGIN - - +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingParking_get`( + vShelvingCode VARCHAR(10), + vWarehouseFk INT, + vDayRange INT +) +BEGIN SELECT s.itemFk, s.concept, CAST(SUM(s.quantity) AS DECIMAL(10,0)) as sinServir, @@ -10,14 +12,15 @@ SELECT s.itemFk, FROM vn.sale s LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id JOIN vn.ticket t ON t.id = s.ticketFk - LEFT JOIN vn.itemShelvingStock ist ON ist.itemFk = s.itemFk AND ist.warehouseFk = vWarehouseFk - JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk AND ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci + LEFT JOIN vn.itemShelvingStock ist ON ist.itemFk = s.itemFk + AND ist.warehouseFk = vWarehouseFk + JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk + JOIN shelving sh ON sh.id = ish.shelvingFk + AND sh.code = vShelvingCode COLLATE utf8_general_ci WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(TIMESTAMPADD(DAY, GREATEST(0,vDayRange), util.VN_CURDATE())) AND iss.saleFk IS NULL AND t.warehouseFk = vWarehouseFk GROUP BY s.itemFk HAVING sinServir > aparcado; - - END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/shelving_getSpam.sql b/db/routines/vn/procedures/shelving_getSpam.sql index cef407285..a80021cdf 100644 --- a/db/routines/vn/procedures/shelving_getSpam.sql +++ b/db/routines/vn/procedures/shelving_getSpam.sql @@ -25,7 +25,7 @@ BEGIN LEFT JOIN ( SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS reserva FROM vn.itemShelving ish - JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.shelving sh ON sh.id = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector s ON s.id = p.sectorFk WHERE s.code = 'FUENTES_PICASSE' @@ -68,7 +68,7 @@ BEGIN sh.isSpam FROM vn.itemShelving ish JOIN vn.item i ON i.id = ish.itemFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.shelving sh ON sh.id = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector s ON s.id = p.sectorFk JOIN vn.warehouse w ON w.id = s.warehouseFk diff --git a/db/routines/vn/procedures/ticketDown_PrintableSelection.sql b/db/routines/vn/procedures/ticketDown_PrintableSelection.sql index 082a890a6..8f448d647 100644 --- a/db/routines/vn/procedures/ticketDown_PrintableSelection.sql +++ b/db/routines/vn/procedures/ticketDown_PrintableSelection.sql @@ -9,7 +9,7 @@ BEGIN JOIN vn.sale s ON s.ticketFk = t.id JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id JOIN vn.itemShelving ish ON ish.id = iss.itemShelvingFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.shelving sh ON sh.id = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk WHERE p.sectorFk = vSectorFk ) sub ON sub.id = td.ticketFk diff --git a/db/routines/vn/procedures/ticket_DelayTruckSplit.sql b/db/routines/vn/procedures/ticket_DelayTruckSplit.sql index 1dc45d065..3d22207f3 100644 --- a/db/routines/vn/procedures/ticket_DelayTruckSplit.sql +++ b/db/routines/vn/procedures/ticket_DelayTruckSplit.sql @@ -27,7 +27,7 @@ BEGIN SUM(ish.visible) visible, s.warehouseFk warehouseFk FROM itemShelving ish - JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN sector s ON s.id = p.sectorFk GROUP BY ish.itemFk, diff --git a/db/routines/vn/procedures/ticket_getSplitList.sql b/db/routines/vn/procedures/ticket_getSplitList.sql index 988bc2931..66e9bdb57 100644 --- a/db/routines/vn/procedures/ticket_getSplitList.sql +++ b/db/routines/vn/procedures/ticket_getSplitList.sql @@ -28,7 +28,7 @@ BEGIN SUM(ish.visible) visible, s.warehouseFk warehouseFk FROM itemShelving ish - JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN sector s ON s.id = p.sectorFk GROUP BY ish.itemFk, diff --git a/db/routines/vn/views/itemShelvingList.sql b/db/routines/vn/views/itemShelvingList.sql index 457d6f28a..f2cfeda58 100644 --- a/db/routines/vn/views/itemShelvingList.sql +++ b/db/routines/vn/views/itemShelvingList.sql @@ -15,7 +15,7 @@ FROM ( ( ( `vn`.`itemShelving` `ish` - JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) + JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`) ) JOIN `vn`.`item` `i` ON(`i`.`id` = `ish`.`itemFk`) ) diff --git a/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql b/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql index fa1c11314..1ebb6410c 100644 --- a/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql +++ b/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql @@ -18,7 +18,7 @@ FROM ( ( ( `vn`.`itemShelving` `ish` - JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) + JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`) ) LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`) ) diff --git a/db/routines/vn/views/itemShelvingSaleSum.sql b/db/routines/vn/views/itemShelvingSaleSum.sql index 9a402d6f4..60581faa9 100644 --- a/db/routines/vn/views/itemShelvingSaleSum.sql +++ b/db/routines/vn/views/itemShelvingSaleSum.sql @@ -13,7 +13,7 @@ FROM ( `vn`.`itemShelvingSale` `iss` JOIN `vn`.`itemShelving` `ish` ON(`ish`.`id` = `iss`.`itemShelvingFk`) ) - JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) + JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`) ) JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`) ) diff --git a/db/routines/vn/views/itemShelvingStock.sql b/db/routines/vn/views/itemShelvingStock.sql index 41777eaec..725a06f88 100644 --- a/db/routines/vn/views/itemShelvingStock.sql +++ b/db/routines/vn/views/itemShelvingStock.sql @@ -21,7 +21,7 @@ FROM ( ( ( `vn`.`itemShelving` `ish` - LEFT JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) + LEFT JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`) ) LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`) ) diff --git a/db/routines/vn/views/itemShelvingStockFull.sql b/db/routines/vn/views/itemShelvingStockFull.sql index c767823d6..c8a82685c 100644 --- a/db/routines/vn/views/itemShelvingStockFull.sql +++ b/db/routines/vn/views/itemShelvingStockFull.sql @@ -19,7 +19,7 @@ FROM ( ( ( `vn`.`itemShelving` `ish` - JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) + JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`) ) JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`) )