From 0e5a15dd4e1b9fc5ac5738280090663a6cf1f4b1 Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 24 May 2024 15:14:20 +0200 Subject: [PATCH 01/10] con addressFk --- db/dump/.dump/data.sql | 4 +-- db/dump/fixtures.before.sql | 19 +++++++++----- .../vn/procedures/expeditionTruck_Add.sql | 9 ------- .../vn/procedures/expeditionTruck_List.sql | 12 --------- .../vn/views/expeditionTruck_Control.sql | 19 -------------- .../views/expeditionTruck_Control_Detail.sql | 18 ------------- .../expeditionTruck_Control_Detail_Pallet.sql | 22 ---------------- .../00-roadmapAddress.sql | 8 ++++++ .../11063-purpleAnthurium/01-roadmapStop.sql | 7 +++++ .../02-roadmapStopGrants.sql | 11 ++++++++ .../route/back/locale/routesMonitor/en.yml | 4 +-- .../route/back/locale/routesMonitor/es.yml | 4 +-- modules/route/back/methods/roadmap/clone.js | 11 +++----- modules/route/back/model-config.json | 3 +++ modules/route/back/models/roadmapAddress.json | 26 +++++++++++++++++++ modules/route/back/models/roadmapStop.json | 8 +++--- 16 files changed, 81 insertions(+), 104 deletions(-) delete mode 100644 db/routines/vn/procedures/expeditionTruck_Add.sql delete mode 100644 db/routines/vn/procedures/expeditionTruck_List.sql delete mode 100644 db/routines/vn/views/expeditionTruck_Control.sql delete mode 100644 db/routines/vn/views/expeditionTruck_Control_Detail.sql delete mode 100644 db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql create mode 100644 db/versions/11063-purpleAnthurium/00-roadmapAddress.sql create mode 100644 db/versions/11063-purpleAnthurium/01-roadmapStop.sql create mode 100644 db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql create mode 100644 modules/route/back/models/roadmapAddress.json diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index f49e3f0f9..b1a69dee9 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -1747,8 +1747,8 @@ INSERT INTO `ACL` VALUES (688,'ClientSms','create','WRITE','ALLOW','ROLE','emplo INSERT INTO `ACL` VALUES (689,'Vehicle','sorted','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (690,'Roadmap','*','*','ALLOW','ROLE','palletizerBoss'); INSERT INTO `ACL` VALUES (691,'Roadmap','*','*','ALLOW','ROLE','productionBoss'); -INSERT INTO `ACL` VALUES (692,'ExpeditionTruck','*','*','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (693,'ExpeditionTruck','*','*','ALLOW','ROLE','productionBoss'); +INSERT INTO `ACL` VALUES (692,'roadmapStop','*','*','ALLOW','ROLE','production'); +INSERT INTO `ACL` VALUES (693,'roadmapStop','*','*','ALLOW','ROLE','productionBoss'); INSERT INTO `ACL` VALUES (695,'ViaexpressConfig','internationalExpedition','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (696,'ViaexpressConfig','renderer','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (697,'Ticket','transferClient','WRITE','ALLOW','ROLE','administrative'); diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 3e6edf07d..ccd6ef1d5 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2670,13 +2670,20 @@ INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`) (3, 6, 5), (4, 7, 1); +INSERT INTO `vn`.`roadmapAddress` (`addressFk`) + VALUES + (1), + (2), + (3), + (4); + INSERT INTO `vn`.`roadmap` (`id`, `name`, `tractorPlate`, `trailerPlate`, `phone`, `supplierFk`, `etd`, `observations`, `userFk`, `price`, `driverName`) VALUES - (1, 'val-algemesi', 'RE-001', 'PO-001', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'), - (2, 'alg-valencia', 'RE-002', 'PO-002', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'), - (3, 'alz-algemesi', 'RE-003', 'PO-003', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman'); + (1, 'val-algemesi', '1234-BCD', '9876-BCD', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'), + (2, 'alg-valencia', '2345-CDF', '8765-BCD', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'), + (3, 'alz-algemesi', '3456-DFG', '7654-BCD', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman'); -INSERT INTO `vn`.`expeditionTruck` (`id`, `roadmapFk`, `warehouseFk`, `eta`, `description`, `userFk`) +INSERT INTO `vn`.`roadmapStop` (`id`, `roadmapFk`, `addressFk`, `eta`, `description`, `userFk`) VALUES (1, 1, 1, DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY), 'Best truck in fleet', 1), (2, 1, 2, DATE_ADD(util.VN_NOW(), INTERVAL '1 2' DAY_HOUR), 'Second truck in fleet', 1), @@ -3788,7 +3795,7 @@ INSERT INTO vn.workerTeam(id, team, workerFk) VALUES (8, 1, 19); -INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment) +INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment) VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL); -UPDATE vn.locker SET workerFk = 1110 WHERE id = 147; \ No newline at end of file +UPDATE vn.locker SET workerFk = 1110 WHERE id = 147; diff --git a/db/routines/vn/procedures/expeditionTruck_Add.sql b/db/routines/vn/procedures/expeditionTruck_Add.sql deleted file mode 100644 index eabfa452c..000000000 --- a/db/routines/vn/procedures/expeditionTruck_Add.sql +++ /dev/null @@ -1,9 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionTruck_Add`(vHour VARCHAR(5), vDescription VARCHAR(45)) -BEGIN - - INSERT INTO vn.roadmapStop(eta,description) - VALUES(CONCAT(util.VN_CURDATE(), ' ', vHour), vDescription); - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/expeditionTruck_List.sql b/db/routines/vn/procedures/expeditionTruck_List.sql deleted file mode 100644 index c358df5e3..000000000 --- a/db/routines/vn/procedures/expeditionTruck_List.sql +++ /dev/null @@ -1,12 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionTruck_List`() -BEGIN - - SELECT id truckFk, - eta, - description Destino - FROM roadmapStop - WHERE eta BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) - ORDER BY eta; -END$$ -DELIMITER ; diff --git a/db/routines/vn/views/expeditionTruck_Control.sql b/db/routines/vn/views/expeditionTruck_Control.sql deleted file mode 100644 index 838e1f89e..000000000 --- a/db/routines/vn/views/expeditionTruck_Control.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`expeditionTruck_Control` -AS SELECT `e`.`truckFk` AS `id`, - `e`.`eta` AS `ETD`, - `e`.`description` AS `description`, - COUNT( - DISTINCT IF(`e`.`expeditionFk` IS NULL, `e`.`ticketFk`, NULL) - ) AS `ticketsSinBultos`, - COUNT(DISTINCT `e`.`palletFk`) AS `pallets`, - COUNT(DISTINCT `e`.`routeFk`) AS `routes`, - COUNT(DISTINCT `e`.`scanFk`) AS `scans`, - COUNT(DISTINCT `e`.`expeditionFk`) AS `expeditions`, - sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, - max(`e`.`lastPacked`) AS `lastPacked` -FROM `vn`.`expeditionCommon` `e` -GROUP BY `e`.`truckFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, - `e`.`eta` diff --git a/db/routines/vn/views/expeditionTruck_Control_Detail.sql b/db/routines/vn/views/expeditionTruck_Control_Detail.sql deleted file mode 100644 index 96a5b78e6..000000000 --- a/db/routines/vn/views/expeditionTruck_Control_Detail.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`expeditionTruck_Control_Detail` -AS SELECT `e`.`truckFk` AS `id`, - `e`.`eta` AS `eta`, - `e`.`description` AS `destino`, - `e`.`palletFk` AS `pallet`, - COUNT(DISTINCT `e`.`routeFk`) AS `routes`, - COUNT(DISTINCT `e`.`scanFk`) AS `scans`, - COUNT(DISTINCT `e`.`expeditionTruckFk`) AS `destinos`, - sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, - max(`e`.`lastPacked`) AS `lastPacked` -FROM `vn`.`expeditionCommon` `e` -GROUP BY `e`.`truckFk`, - `e`.`palletFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, - `e`.`eta`, - `e`.`truckFk` diff --git a/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql b/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql deleted file mode 100644 index 3f239432d..000000000 --- a/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`expeditionTruck_Control_Detail_Pallet` -AS SELECT `e`.`truckFk` AS `id`, - `e`.`eta` AS `eta`, - `e`.`description` AS `destino`, - `e`.`palletFk` AS `pallet`, - `e`.`routeFk` AS `route`, - COUNT(DISTINCT `e`.`scanFk`) AS `scans`, - `rs`.`description` AS `destinos`, - sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, - `e`.`expeditionTruckFk` AS `expeditionTruckFk`, - max(`e`.`lastPacked`) AS `lastPacked` -FROM ( - `vn`.`expeditionCommon` `e` - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `e`.`expeditionTruckFk`) - ) -GROUP BY `e`.`truckFk`, - `e`.`palletFk`, - `e`.`routeFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, - `e`.`palletFk` diff --git a/db/versions/11063-purpleAnthurium/00-roadmapAddress.sql b/db/versions/11063-purpleAnthurium/00-roadmapAddress.sql new file mode 100644 index 000000000..6435da1c9 --- /dev/null +++ b/db/versions/11063-purpleAnthurium/00-roadmapAddress.sql @@ -0,0 +1,8 @@ +CREATE TABLE `vn`.`roadmapAddress` ( + addressFk int(11) NULL, + isActive TINYINT DEFAULT 1 NULL, + PRIMARY KEY (addressFk) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Direcciones de los troncales'; + +ALTER TABLE vn.roadmapAddress + ADD CONSTRAINT roadmapAddress_address_FK FOREIGN KEY (addressFk) REFERENCES vn.address(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11063-purpleAnthurium/01-roadmapStop.sql b/db/versions/11063-purpleAnthurium/01-roadmapStop.sql new file mode 100644 index 000000000..844abf45f --- /dev/null +++ b/db/versions/11063-purpleAnthurium/01-roadmapStop.sql @@ -0,0 +1,7 @@ +ALTER TABLE vn.roadmapStop DROP FOREIGN KEY expeditionTruck_FK_1; +ALTER TABLE vn.roadmapStop DROP COLUMN warehouseFk; +ALTER TABLE vn.roadmapStop ADD addressFk int(11) NULL; +ALTER TABLE vn.roadmapStop CHANGE addressFk addressFk int(11) DEFAULT NULL NULL AFTER roadmapFk; + +ALTER TABLE vn.roadmapStop + ADD CONSTRAINT roadmapStop_roadmapAddress_FK FOREIGN KEY (addressFk) REFERENCES vn.roadmapAddress(addressFk) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql b/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql new file mode 100644 index 000000000..d2c8354c0 --- /dev/null +++ b/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql @@ -0,0 +1,11 @@ +DELETE FROM salix.ACL + WHERE model in ('expeditionTruck', 'Roadmap', 'roadmapStop', 'roadmapAddress'); + +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES + ('roadmapAddress', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), + ('roadmapAddress', '*', 'READ', 'ALLOW', 'ROLE', 'production'), + ('Roadmap', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), + ('Roadmap', '*', 'READ', 'ALLOW', 'ROLE', 'production'), + ('RoadmapStop', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), + ('RoadmapStop', '*', 'READ', 'ALLOW', 'ROLE', 'production'); diff --git a/modules/route/back/locale/routesMonitor/en.yml b/modules/route/back/locale/routesMonitor/en.yml index 8908ee636..0542ced54 100644 --- a/modules/route/back/locale/routesMonitor/en.yml +++ b/modules/route/back/locale/routesMonitor/en.yml @@ -13,7 +13,7 @@ columns: m3: m3 priority: priority etd: etd - expeditionTruckFk: truck + roadmapStopFk: truck m3boxes: m3 boxes bufferFk: buffer - isPickingAllowed: is picking allowed \ No newline at end of file + isPickingAllowed: is picking allowed diff --git a/modules/route/back/locale/routesMonitor/es.yml b/modules/route/back/locale/routesMonitor/es.yml index 9ded8983d..1ea0532c6 100644 --- a/modules/route/back/locale/routesMonitor/es.yml +++ b/modules/route/back/locale/routesMonitor/es.yml @@ -13,7 +13,7 @@ columns: m3: m3 priority: prioridad etd: etd - expeditionTruckFk: camión + roadmapStopFk: camión m3boxes: m3 cajas bufferFk: buffer - isPickingAllowed: está permitido recoger \ No newline at end of file + isPickingAllowed: está permitido recoger diff --git a/modules/route/back/methods/roadmap/clone.js b/modules/route/back/methods/roadmap/clone.js index b74cf803c..5f1ab9229 100644 --- a/modules/route/back/methods/roadmap/clone.js +++ b/modules/route/back/methods/roadmap/clone.js @@ -37,17 +37,12 @@ module.exports = Self => { fields: [ 'id', 'name', - 'tractorPlate', - 'trailerPlate', - 'phone', 'supplierFk', - 'etd', - 'observations', - 'price'], + 'etd'], include: [{ - relation: 'expeditionTruck', + relation: 'roadmapStop', scope: { - fields: ['roadmapFk', 'warehouseFk', 'eta', 'description'] + fields: ['roadmapFk', 'addressFk', 'eta', 'description'] } }] diff --git a/modules/route/back/model-config.json b/modules/route/back/model-config.json index 09cda6b2d..ccae87bd9 100644 --- a/modules/route/back/model-config.json +++ b/modules/route/back/model-config.json @@ -8,6 +8,9 @@ "DeliveryPoint": { "dataSource": "vn" }, + "RoadmapAddress": { + "dataSource": "vn" + }, "RoadmapStop": { "dataSource": "vn" }, diff --git a/modules/route/back/models/roadmapAddress.json b/modules/route/back/models/roadmapAddress.json new file mode 100644 index 000000000..0241ce0d8 --- /dev/null +++ b/modules/route/back/models/roadmapAddress.json @@ -0,0 +1,26 @@ +{ + "name": "RoadmapAddress", + "base": "VnModel", + "options": { + "mysql": { + "table": "roadmapAddress" + } + }, + "properties": { + "addressFk": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "isActive": { + "type": "number" + } + }, + "relations": { + "address": { + "type": "belongsTo", + "model": "Address", + "foreignKey": "addressFk" + } + } +} diff --git a/modules/route/back/models/roadmapStop.json b/modules/route/back/models/roadmapStop.json index 51aa3a6db..527bbae98 100644 --- a/modules/route/back/models/roadmapStop.json +++ b/modules/route/back/models/roadmapStop.json @@ -15,7 +15,7 @@ "roadmapFk": { "type": "number" }, - "warehouseFk": { + "addressFk": { "type": "number" }, "eta": { @@ -34,10 +34,10 @@ "model": "Roadmap", "foreignKey": "roadmapFk" }, - "warehouse": { + "address": { "type": "belongsTo", - "model": "Warehouse", - "foreignKey": "warehouseFk" + "model": "RoadmapAddress", + "foreignKey": "addressFk" } } } From da1b4649bb59414c6bde7be4511e73e6504754e6 Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 4 Jun 2024 11:58:39 +0200 Subject: [PATCH 02/10] feat: refs #4560 sin expeditionTruck --- .../11063-purpleAnthurium/02-roadmapStopGrants.sql | 4 ++-- modules/route/back/model-config.json | 3 --- modules/route/back/models/expedition-truck.json | 9 --------- modules/route/back/models/roadmapStop.json | 2 +- modules/route/back/models/routesMonitor.json | 3 --- 5 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 modules/route/back/models/expedition-truck.json diff --git a/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql b/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql index d2c8354c0..bba1c019c 100644 --- a/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql +++ b/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql @@ -3,8 +3,8 @@ DELETE FROM salix.ACL INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) VALUES - ('roadmapAddress', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), - ('roadmapAddress', '*', 'READ', 'ALLOW', 'ROLE', 'production'), + ('RoadmapAddress', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), + ('RoadmapAddress', '*', 'READ', 'ALLOW', 'ROLE', 'production'), ('Roadmap', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), ('Roadmap', '*', 'READ', 'ALLOW', 'ROLE', 'production'), ('RoadmapStop', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), diff --git a/modules/route/back/model-config.json b/modules/route/back/model-config.json index c315891fd..ccae87bd9 100644 --- a/modules/route/back/model-config.json +++ b/modules/route/back/model-config.json @@ -28,8 +28,5 @@ }, "RoutesMonitor": { "dataSource": "vn" - }, - "ExpeditionTruck": { - "dataSource": "vn" } } diff --git a/modules/route/back/models/expedition-truck.json b/modules/route/back/models/expedition-truck.json deleted file mode 100644 index fc9cd90f0..000000000 --- a/modules/route/back/models/expedition-truck.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "ExpeditionTruck", - "base": "RoadmapStop", - "options": { - "mysql": { - "table": "expeditionTruck" - } - } -} diff --git a/modules/route/back/models/roadmapStop.json b/modules/route/back/models/roadmapStop.json index 527bbae98..74b02cd7a 100644 --- a/modules/route/back/models/roadmapStop.json +++ b/modules/route/back/models/roadmapStop.json @@ -36,7 +36,7 @@ }, "address": { "type": "belongsTo", - "model": "RoadmapAddress", + "model": "Address", "foreignKey": "addressFk" } } diff --git a/modules/route/back/models/routesMonitor.json b/modules/route/back/models/routesMonitor.json index 122026336..a14680b5c 100644 --- a/modules/route/back/models/routesMonitor.json +++ b/modules/route/back/models/routesMonitor.json @@ -48,9 +48,6 @@ "priority": { "type": "number" }, - "expeditionTruckFk": { - "type": "number" - }, "m3boxes": { "type": "number" }, From 4089c7deb3fbdd424ff3f8d4624673aca3f638ea Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 4 Jun 2024 12:23:28 +0200 Subject: [PATCH 03/10] feat: refs #4560 minorChanges --- db/dump/.dump/data.sql | 4 ++-- modules/route/back/locale/routesMonitor/en.yml | 1 - modules/route/back/locale/routesMonitor/es.yml | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 8bc94e76f..3f2d8e22e 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -1772,8 +1772,8 @@ INSERT INTO `ACL` VALUES (688,'ClientSms','create','WRITE','ALLOW','ROLE','emplo INSERT INTO `ACL` VALUES (689,'Vehicle','sorted','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (690,'Roadmap','*','*','ALLOW','ROLE','palletizerBoss'); INSERT INTO `ACL` VALUES (691,'Roadmap','*','*','ALLOW','ROLE','productionBoss'); -INSERT INTO `ACL` VALUES (692,'roadmapStop','*','*','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (693,'roadmapStop','*','*','ALLOW','ROLE','productionBoss'); +INSERT INTO `ACL` VALUES (692,'RoadmapStop','*','*','ALLOW','ROLE','production'); +INSERT INTO `ACL` VALUES (693,'RoadmapStop','*','*','ALLOW','ROLE','productionBoss'); INSERT INTO `ACL` VALUES (695,'ViaexpressConfig','internationalExpedition','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (696,'ViaexpressConfig','renderer','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (697,'Ticket','transferClient','WRITE','ALLOW','ROLE','administrative'); diff --git a/modules/route/back/locale/routesMonitor/en.yml b/modules/route/back/locale/routesMonitor/en.yml index 0542ced54..c28c5cb4d 100644 --- a/modules/route/back/locale/routesMonitor/en.yml +++ b/modules/route/back/locale/routesMonitor/en.yml @@ -13,7 +13,6 @@ columns: m3: m3 priority: priority etd: etd - roadmapStopFk: truck m3boxes: m3 boxes bufferFk: buffer isPickingAllowed: is picking allowed diff --git a/modules/route/back/locale/routesMonitor/es.yml b/modules/route/back/locale/routesMonitor/es.yml index 1ea0532c6..a8e807626 100644 --- a/modules/route/back/locale/routesMonitor/es.yml +++ b/modules/route/back/locale/routesMonitor/es.yml @@ -13,7 +13,6 @@ columns: m3: m3 priority: prioridad etd: etd - roadmapStopFk: camión m3boxes: m3 cajas bufferFk: buffer isPickingAllowed: está permitido recoger From f2b443021f067b3579c31f53efea981a11b67676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 5 Jun 2024 10:03:37 +0200 Subject: [PATCH 04/10] hotfix: midnight deterministis refs #7213 --- db/routines/util/functions/midnight.sql | 2 +- db/routines/vn/functions/ticket_isTooLittle.sql | 2 +- db/routines/vn/procedures/ticket_setProblemRequest.sql | 2 +- .../vn/procedures/ticket_setProblemTooLittleItemCost.sql | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/db/routines/util/functions/midnight.sql b/db/routines/util/functions/midnight.sql index c80abdbb0..b37415682 100644 --- a/db/routines/util/functions/midnight.sql +++ b/db/routines/util/functions/midnight.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`midnight`() RETURNS datetime - NOT DETERMINISTIC + DETERMINISTIC READS SQL DATA BEGIN diff --git a/db/routines/vn/functions/ticket_isTooLittle.sql b/db/routines/vn/functions/ticket_isTooLittle.sql index 2ce24f0fa..bcbf09035 100644 --- a/db/routines/vn/functions/ticket_isTooLittle.sql +++ b/db/routines/vn/functions/ticket_isTooLittle.sql @@ -14,7 +14,7 @@ BEGIN DECLARE vIsTooLittle TINYINT(1); SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume - OR IFNULL(t.totalWithoutVat, 0) < vc.minTicketValue) INTO vIsTooLittle + AND IFNULL(t.totalWithoutVat, 0) < vc.minTicketValue) INTO vIsTooLittle FROM ticket t LEFT JOIN saleVolume sv ON sv.ticketFk = t.id JOIN volumeConfig vc diff --git a/db/routines/vn/procedures/ticket_setProblemRequest.sql b/db/routines/vn/procedures/ticket_setProblemRequest.sql index a5dc31472..19bba5b76 100644 --- a/db/routines/vn/procedures/ticket_setProblemRequest.sql +++ b/db/routines/vn/procedures/ticket_setProblemRequest.sql @@ -13,7 +13,7 @@ BEGIN ENGINE = MEMORY SELECT t.id ticketFk, FALSE hasProblem FROM ticket t - WHERE t.shipped >= util.midnight() + WHERE t.shipped >= util.VN_CURDATE() AND (vSelf IS NULL OR t.id = vSelf); UPDATE tmp.ticket t diff --git a/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql b/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql index 4403292fc..cd1f42783 100644 --- a/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql +++ b/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql @@ -16,7 +16,7 @@ BEGIN SELECT t.id ticketFk FROM vn.ticket t LEFT JOIN vn.sale s ON s.ticketFk = t.id - WHERE t.shipped >= util.midnight() + WHERE t.shipped >= util.VN_CURDATE() AND (s.itemFk = vItemFk OR vItemFk IS NULL) GROUP BY t.id )SELECT ticketFk, ticket_isTooLittle(ticketFk) hasProblem From 8b584a08dc73cba470f637c4d33c8d9d2775b73e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 5 Jun 2024 10:11:04 +0200 Subject: [PATCH 05/10] Hotfix: midnight deterministic refs #7213 --- .../vn/procedures/sale_setProblemComponentLackByComponent.sql | 2 +- db/routines/vn/procedures/ticket_setProblemFreeze.sql | 2 +- db/routines/vn/procedures/ticket_setProblemTaxDataChecked.sql | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql b/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql index 62db0d9cf..b911327dd 100644 --- a/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql +++ b/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql @@ -18,7 +18,7 @@ BEGIN FROM ticket t JOIN sale s ON s.ticketFk = t.id LEFT JOIN saleComponent sc ON sc.saleFk = s.id - WHERE t.shipped >= util.midnight() + WHERE t.shipped >= util.VN_CURDATE() AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk) GROUP BY s.id) sub; diff --git a/db/routines/vn/procedures/ticket_setProblemFreeze.sql b/db/routines/vn/procedures/ticket_setProblemFreeze.sql index 2a5d67b0d..560bce612 100644 --- a/db/routines/vn/procedures/ticket_setProblemFreeze.sql +++ b/db/routines/vn/procedures/ticket_setProblemFreeze.sql @@ -13,7 +13,7 @@ BEGIN ENGINE = MEMORY SELECT t.id ticketFk, FALSE hasProblem FROM ticket t - WHERE t.shipped >= util.midnight() + WHERE t.shipped >= util.VN_CURDATE() AND (vClientFk IS NULL OR t.clientFk = vClientFk); UPDATE tmp.ticket t diff --git a/db/routines/vn/procedures/ticket_setProblemTaxDataChecked.sql b/db/routines/vn/procedures/ticket_setProblemTaxDataChecked.sql index b6c2d8533..00918426b 100644 --- a/db/routines/vn/procedures/ticket_setProblemTaxDataChecked.sql +++ b/db/routines/vn/procedures/ticket_setProblemTaxDataChecked.sql @@ -14,7 +14,7 @@ BEGIN SELECT t.id ticketFk, IF(c.isTaxDataChecked, FALSE, TRUE) hasProblem FROM ticket t JOIN client c ON c.id = t.clientFk - WHERE t.shipped >= util.midnight() + WHERE t.shipped >= util.VN_CURDATE() AND (c.id = vClientFk OR vClientFk IS NULL); CALL ticket_setProblem('isTaxDataChecked'); From 2e8d28d7959d0bdab9386813812700f36964e4d5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 10 Jun 2024 09:08:26 +0200 Subject: [PATCH 06/10] refactor: refs #7517 Added throw --- db/routines/vn/procedures/buy_afterUpsert.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/routines/vn/procedures/buy_afterUpsert.sql b/db/routines/vn/procedures/buy_afterUpsert.sql index 17e84177c..8af53ddfb 100644 --- a/db/routines/vn/procedures/buy_afterUpsert.sql +++ b/db/routines/vn/procedures/buy_afterUpsert.sql @@ -47,6 +47,9 @@ BEGIN WHERE e.id = vEntryFk; IF vIsMerchandise THEN + IF vWarehouse IS NULL THEN + CALL util.throw('The entry does not have travel'); + END IF; REPLACE itemCost SET itemFk = vItemFk, From ca7d67451b23bc95a586103e0e6f9b5310c5e97d Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 10 Jun 2024 09:09:11 +0200 Subject: [PATCH 07/10] refactor: refs #7517 Minor changes --- db/routines/vn/procedures/buy_afterUpsert.sql | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/buy_afterUpsert.sql b/db/routines/vn/procedures/buy_afterUpsert.sql index 8af53ddfb..76f60d1e5 100644 --- a/db/routines/vn/procedures/buy_afterUpsert.sql +++ b/db/routines/vn/procedures/buy_afterUpsert.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_afterUpsert`(vSelf INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_afterUpsert`( + vSelf INT +) BEGIN /** * Triggered actions when a buy is updated or inserted. @@ -16,7 +18,7 @@ BEGIN DECLARE vIsFeedStock BOOL; DECLARE vWeight DECIMAL(10,2); DECLARE vPacking INT; - + SELECT b.entryFk, b.itemFk, i.packingOut, @@ -51,7 +53,7 @@ BEGIN CALL util.throw('The entry does not have travel'); END IF; - REPLACE itemCost SET + REPLACE itemCost SET itemFk = vItemFk, warehouseFk = vWarehouse, cm3 = buy_getUnitVolume(vSelf), @@ -77,7 +79,7 @@ BEGIN WHERE b.id = vSelf; END IF; - CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck + CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck SELECT vSelf id; CALL buy_checkItem(); END$$ From b4820858c9bc6efc5dd547694b44889ddc40cae9 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 10 Jun 2024 11:32:44 +0200 Subject: [PATCH 08/10] hotfix: ticket 192672 ticketPreviousPreparingList --- db/routines/vn/views/ticketPreviousPreparingList.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/views/ticketPreviousPreparingList.sql b/db/routines/vn/views/ticketPreviousPreparingList.sql index 9c84b8af3..cd18b3a7c 100644 --- a/db/routines/vn/views/ticketPreviousPreparingList.sql +++ b/db/routines/vn/views/ticketPreviousPreparingList.sql @@ -20,7 +20,7 @@ FROM ( `vn`.`saleGroup` `sg` JOIN `vn`.`saleGroupDetail` `sgd` ON(`sgd`.`saleGroupFk` = `sg`.`id`) ) - JOIN `vn`.`sale` `s` ON(`s`.`id` = `sgd`.`saleFk`) + JOIN `vn`.`sale` `s` FORCE INDEX (PRIMARY) ON(`s`.`id` = `sgd`.`saleFk`) ) JOIN `vn`.`ticketState` `tls` ON(`tls`.`ticketFk` = `s`.`ticketFk`) ) From 7579e15fcc483787885911b3a51b5133adfdb19f Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 10 Jun 2024 11:55:40 +0200 Subject: [PATCH 09/10] refactor: refs #7486 Optimized procs --- .../vn/procedures/productionControl.sql | 22 +++++++++++++------ .../vn/procedures/sale_getProblems.sql | 21 +++++++++++------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index b42645d1e..423c06892 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -145,13 +145,19 @@ proc: BEGIN -- Líneas y volumen por ticket UPDATE tmp.productionBuffer pb JOIN ( - SELECT tt.ticketFk, - COUNT(*) `lines`, - SUM(sv.volume) m3, - IFNULL(SUM(IF(sv.isPicked, sv.volume, 0)) / SUM(sv.volume), 0) rate - FROM tmp.productionTicket tt - JOIN saleVolume sv ON sv.ticketFk = tt.ticketFk - GROUP BY tt.ticketFk + SELECT tt.ticketFk, + COUNT(*) `lines`, + SUM(s.quantity * ic.cm3delivery / 1000000) m3, + IFNULL(SUM(IF(s.isPicked, + (s.quantity * ic.cm3delivery / 1000000), + 0)) / SUM(s.quantity * ic.cm3delivery / 1000000), + 0) rate + FROM tmp.productionTicket tt + JOIN sale s ON s.ticketFk = tt.ticketFk + AND s.quantity > 0 + JOIN itemCost ic ON ic.itemFk = s.itemFk + AND ic.warehouseFk = vWarehouseFk + GROUP BY tt.ticketFk ) m ON m.ticketFk = pb.ticketFk SET pb.`lines` = m.`lines`, pb.m3 = m.m3, @@ -218,6 +224,8 @@ proc: BEGIN AND ish.visible GROUP BY ish.itemFk, p.sectorFk; + CREATE INDEX idxItem ON tItemShelvingStock (itemFk); + INSERT INTO tmp.ticketWithPrevia(ticketFk, salesCount) SELECT pb.ticketFk, COUNT(DISTINCT s.id) FROM tmp.productionBuffer pb diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 98926b28b..9944ab0c2 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -64,10 +64,15 @@ BEGIN FROM tmp.sale_getProblems tp JOIN ticket t ON t.id = tp.ticketFk JOIN ( - SELECT t.addressFk, SUM(sv.litros) litros, t.totalWithoutVat + SELECT t.addressFk, + SUM(ROUND(`ic`.`cm3delivery` * `s`.`quantity` / 1000, 0)) litros, + t.totalWithoutVat FROM tmp.ticket_list tl - JOIN saleVolume sv ON sv.ticketFk = tl.ticketFk JOIN ticket t ON t.id = tl.ticketFk + JOIN sale s ON s.ticketFk = t.id + AND s.quantity > 0 + JOIN itemCost ic ON ic.itemFk = s.itemFk + AND ic.warehouseFk = t.warehouseFk JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = util.VN_CURDATE() JOIN agencyMode am ON am.id = t.agencyModeFk @@ -95,12 +100,12 @@ BEGIN FROM ( SELECT COUNT(s.id) nComp, tl.ticketFk, s.id saleFk FROM tmp.ticket_list tl - JOIN vn.sale s ON s.ticketFk = tl.ticketFk - LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id - LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.agencyMode am ON am.id = t.agencyModeFk - JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk + JOIN sale s ON s.ticketFk = tl.ticketFk + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + LEFT JOIN component c ON c.id = sc.componentFk AND c.isRequired + JOIN ticket t ON t.id = tl.ticketFk + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP') AND s.quantity > 0 GROUP BY s.id From 272a34c5f92d59d528a37ca4f32b5b8831004881 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 10 Jun 2024 12:46:26 +0200 Subject: [PATCH 10/10] refactor: refs #7486 Added userFk debug --- db/routines/vn/procedures/collection_new.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index 370b59ae5..fa947ddef 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -49,7 +49,10 @@ BEGIN BEGIN IF vLockName IS NOT NULL THEN DO RELEASE_LOCK(vLockName); - CALL util.debugAdd('releaseLock', vLockName); -- Tmp + CALL util.debugAdd(JSON_OBJECT( + 'type', 'releaseLock', + 'userFk', vUserFk + ), vLockName); -- Tmp END IF; RESIGNAL;