From 2f2d65bfd67c3880a9fc76e8d0c4718027c86b31 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 16 Mar 2023 10:33:24 +0100 Subject: [PATCH 1/6] =?UTF-8?q?refs=20#5342=20feat:=20a=C3=B1adido=20icono?= =?UTF-8?q?=20en=20los=20tickets=20que=20tengan=20sales=20fragiles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- db/changes/231201/00-sale_getWarnings.sql | 35 +++++++++++++++ db/changes/231201/00-ticket_getWarnings.sql | 36 ++++++++++++++++ .../back/methods/sales-monitor/salesFilter.js | 19 +++++++- modules/monitor/front/index/locale/es.yml | 3 +- .../monitor/front/index/tickets/index.html | 43 +++++++++++-------- 6 files changed, 117 insertions(+), 21 deletions(-) create mode 100644 db/changes/231201/00-sale_getWarnings.sql create mode 100644 db/changes/231201/00-ticket_getWarnings.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index dde790aaa..8f4e45398 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2312.01] - 2023-04-06 ### Added -- +- (Monitor tickets) Muestra un icono al lado de la zona, si es frágil y se envía por agencia ### Changed - diff --git a/db/changes/231201/00-sale_getWarnings.sql b/db/changes/231201/00-sale_getWarnings.sql new file mode 100644 index 000000000..ee2c7b8f2 --- /dev/null +++ b/db/changes/231201/00-sale_getWarnings.sql @@ -0,0 +1,35 @@ +DROP PROCEDURE IF EXISTS `vn`.`sale_getWarnings`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`sale_getWarnings`() +BEGIN +/** + * Calcula las advertencias de cada venta para un conjunto de tickets. + * + * @table tmp.sale_getWarnings(ticketFk) Identificadores de los tickets a calcular + * @return tmp.sale_warnings + */ + + DROP TEMPORARY TABLE IF EXISTS tmp.sale_warnings; + CREATE TEMPORARY TABLE tmp.sale_warnings ( + ticketFk INT(11), + saleFk INT(11), + isFragile INTEGER(1) DEFAULT 0, + PRIMARY KEY (ticketFk, saleFk) + ) ENGINE = MEMORY; + + -- Frágil + INSERT INTO tmp.sale_warnings(ticketFk, saleFk, isFragile) + SELECT tt.ticketFk, s.id, TRUE + FROM tmp.sale_getWarnings tt + LEFT JOIN sale s ON s.ticketFk = tt.ticketFk + LEFT JOIN item i ON i.id = s.itemFk + LEFT JOIN itemType it ON it.id = i.typeFk + LEFT JOIN itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN agencyMode am ON am.id = tt.agencyModeFk + LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + WHERE dm.code IN ('AGENCY', 'DELIVERY') + AND (ic.code = 'plant' OR it.code IN ('ZKA', 'ZKE')); +END$$ +DELIMITER ; diff --git a/db/changes/231201/00-ticket_getWarnings.sql b/db/changes/231201/00-ticket_getWarnings.sql new file mode 100644 index 000000000..0cd420bd3 --- /dev/null +++ b/db/changes/231201/00-ticket_getWarnings.sql @@ -0,0 +1,36 @@ +DROP PROCEDURE IF EXISTS `vn`.`ticket_getWarnings`; + +DELIMITER $$ +$$ +CREATE PROCEDURE `vn`.`ticket_getWarnings`() +BEGIN +/** + * Calcula las adventencias para un conjunto de tickets. + * Agrupados por ticket + * + * @table tmp.sale_getWarnings(ticketFk) Identificadores de los tickets a calcular + * @return tmp.ticket_warnings + */ + CALL sale_getWarnings(); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket_warnings; + CREATE TEMPORARY TABLE tmp.ticket_warnings + (PRIMARY KEY (ticketFk)) + ENGINE = MEMORY + SELECT + sw.ticketFk, + MAX(sw.isFragile) AS isFragile, + 0 AS totalWarnings + FROM tmp.sale_warnings sw + GROUP BY sw.ticketFk; + + UPDATE tmp.ticket_warnings tw + SET tw.totalWarnings = + ( + (tw.isFragile) + ); + + DROP TEMPORARY TABLE + tmp.sale_warnings; +END$$ +DELIMITER ; diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 881fc637a..c9a25b1a1 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -295,11 +295,26 @@ module.exports = Self => { risk = t.debt + t.credit, totalProblems = totalProblems + 1 `); + stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getWarnings'); + stmt = new ParameterizedSQL(` - SELECT t.*, tp.*, - ((tp.risk) + cc.riskTolerance < 0) AS hasHighRisk + CREATE TEMPORARY TABLE tmp.sale_getWarnings + (INDEX (ticketFk, agencyModeFk)) + ENGINE = MEMORY + SELECT f.id ticketFk, f.agencyModeFk + FROM tmp.filter f`); + stmts.push(stmt); + + stmts.push('CALL ticket_getWarnings()'); + + stmt = new ParameterizedSQL(` + SELECT t.*, + tp.*, + ((tp.risk) + cc.riskTolerance < 0) AS hasHighRisk, + tw.* FROM tmp.tickets t LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = t.id + LEFT JOIN tmp.ticket_warnings tw ON tw.ticketFk = t.id JOIN clientConfig cc`); const hasProblems = args.problems; diff --git a/modules/monitor/front/index/locale/es.yml b/modules/monitor/front/index/locale/es.yml index 126528caa..f114a2259 100644 --- a/modules/monitor/front/index/locale/es.yml +++ b/modules/monitor/front/index/locale/es.yml @@ -12,4 +12,5 @@ Theoretical: Teórica Practical: Práctica Preparation: Preparación Auto-refresh: Auto-refresco -Toggle auto-refresh every 2 minutes: Conmuta el refresco automático cada 2 minutos \ No newline at end of file +Toggle auto-refresh every 2 minutes: Conmuta el refresco automático cada 2 minutos +Is fragile: Es frágil diff --git a/modules/monitor/front/index/tickets/index.html b/modules/monitor/front/index/tickets/index.html index b8559154e..539d4b3cb 100644 --- a/modules/monitor/front/index/tickets/index.html +++ b/modules/monitor/front/index/tickets/index.html @@ -19,13 +19,13 @@ Tickets monitor - + - State + Zone @@ -80,7 +81,7 @@ @@ -169,12 +170,20 @@ class="link"> {{ticket.refFk}} - {{ticket.state}} + + + + - Filter by selection - Exclude selection - Remove filter - Remove all filters - Copy value From 23ce51abf07c23fb7b0253d72706bba3bd3e2ce7 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 16 Mar 2023 11:34:57 +0100 Subject: [PATCH 2/6] refs #5342 add changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f4e45398..e7d1da557 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2312.01] - 2023-04-06 ### Added -- (Monitor tickets) Muestra un icono al lado de la zona, si es frágil y se envía por agencia +- (Monitor tickets) Muestra un icono al lado de la zona, si el ticket es frágil y se envía por agencia ### Changed - From d276c7b6116ac2638f31e4f3848354c8358cc4f7 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 22 Mar 2023 10:57:18 +0100 Subject: [PATCH 3/6] refs #5342 unificados proc x_getWarnings --- db/changes/231201/00-itemType_isFragile.sql | 5 +++ db/changes/231201/00-sale_getWarnings.sql | 35 ------------------- db/changes/231201/00-ticket_getWarnings.sql | 30 +++++++++++----- .../back/methods/sales-monitor/salesFilter.js | 3 ++ 4 files changed, 29 insertions(+), 44 deletions(-) create mode 100644 db/changes/231201/00-itemType_isFragile.sql delete mode 100644 db/changes/231201/00-sale_getWarnings.sql diff --git a/db/changes/231201/00-itemType_isFragile.sql b/db/changes/231201/00-itemType_isFragile.sql new file mode 100644 index 000000000..00a74b8b6 --- /dev/null +++ b/db/changes/231201/00-itemType_isFragile.sql @@ -0,0 +1,5 @@ +ALTER TABLE `vn`.`itemType` ADD isFragile tinyint(1) NULL; +ALTER TABLE `vn`.`itemType` MODIFY COLUMN isFragile tinyint(1) DEFAULT 0 NOT NULL; +UPDATE `vn`.`itemType` + SET isFragile = 1 + WHERE code IN ('ZKA', 'ZKE'); diff --git a/db/changes/231201/00-sale_getWarnings.sql b/db/changes/231201/00-sale_getWarnings.sql deleted file mode 100644 index ee2c7b8f2..000000000 --- a/db/changes/231201/00-sale_getWarnings.sql +++ /dev/null @@ -1,35 +0,0 @@ -DROP PROCEDURE IF EXISTS `vn`.`sale_getWarnings`; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`sale_getWarnings`() -BEGIN -/** - * Calcula las advertencias de cada venta para un conjunto de tickets. - * - * @table tmp.sale_getWarnings(ticketFk) Identificadores de los tickets a calcular - * @return tmp.sale_warnings - */ - - DROP TEMPORARY TABLE IF EXISTS tmp.sale_warnings; - CREATE TEMPORARY TABLE tmp.sale_warnings ( - ticketFk INT(11), - saleFk INT(11), - isFragile INTEGER(1) DEFAULT 0, - PRIMARY KEY (ticketFk, saleFk) - ) ENGINE = MEMORY; - - -- Frágil - INSERT INTO tmp.sale_warnings(ticketFk, saleFk, isFragile) - SELECT tt.ticketFk, s.id, TRUE - FROM tmp.sale_getWarnings tt - LEFT JOIN sale s ON s.ticketFk = tt.ticketFk - LEFT JOIN item i ON i.id = s.itemFk - LEFT JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN agencyMode am ON am.id = tt.agencyModeFk - LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE dm.code IN ('AGENCY', 'DELIVERY') - AND (ic.code = 'plant' OR it.code IN ('ZKA', 'ZKE')); -END$$ -DELIMITER ; diff --git a/db/changes/231201/00-ticket_getWarnings.sql b/db/changes/231201/00-ticket_getWarnings.sql index 0cd420bd3..605fe6ad0 100644 --- a/db/changes/231201/00-ticket_getWarnings.sql +++ b/db/changes/231201/00-ticket_getWarnings.sql @@ -11,7 +11,26 @@ BEGIN * @table tmp.sale_getWarnings(ticketFk) Identificadores de los tickets a calcular * @return tmp.ticket_warnings */ - CALL sale_getWarnings(); + DROP TEMPORARY TABLE IF EXISTS tmp.sale_warnings; + CREATE TEMPORARY TABLE tmp.sale_warnings ( + ticketFk INT(11), + saleFk INT(11), + isFragile INTEGER(1) DEFAULT 0, + PRIMARY KEY (ticketFk, saleFk) + ) ENGINE = MEMORY; + + -- Frágil + INSERT INTO tmp.sale_warnings(ticketFk, saleFk, isFragile) + SELECT tt.ticketFk, s.id, TRUE + FROM tmp.sale_getWarnings tt + LEFT JOIN sale s ON s.ticketFk = tt.ticketFk + LEFT JOIN item i ON i.id = s.itemFk + LEFT JOIN itemType it ON it.id = i.typeFk + LEFT JOIN itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN agencyMode am ON am.id = tt.agencyModeFk + LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + WHERE dm.code IN ('AGENCY') + AND (ic.code = 'plant' OR it.isFragile); DROP TEMPORARY TABLE IF EXISTS tmp.ticket_warnings; CREATE TEMPORARY TABLE tmp.ticket_warnings @@ -19,17 +38,10 @@ BEGIN ENGINE = MEMORY SELECT sw.ticketFk, - MAX(sw.isFragile) AS isFragile, - 0 AS totalWarnings + MAX(sw.isFragile) AS isFragile FROM tmp.sale_warnings sw GROUP BY sw.ticketFk; - UPDATE tmp.ticket_warnings tw - SET tw.totalWarnings = - ( - (tw.isFragile) - ); - DROP TEMPORARY TABLE tmp.sale_warnings; END$$ diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index c9a25b1a1..b6ebcc5a2 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -402,6 +402,9 @@ module.exports = Self => { tmp.filter, tmp.ticket_problems, tmp.sale_getProblems, + tmp.sale_warnings, + tmp.sale_getWarnings, + tmp.ticket_warnings, tmp.risk`); const sql = ParameterizedSQL.join(stmts, ';'); From 27bb50ad1278f85876123cec20f6f12b1260a8ce Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 22 Mar 2023 12:17:48 +0100 Subject: [PATCH 4/6] refs #5342 esta tabla ya se borra en el proc --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index b6ebcc5a2..484f3d0b1 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -402,7 +402,6 @@ module.exports = Self => { tmp.filter, tmp.ticket_problems, tmp.sale_getProblems, - tmp.sale_warnings, tmp.sale_getWarnings, tmp.ticket_warnings, tmp.risk`); From 7e37d7f3f1b943009e14206852f6482a0b357642 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 23 Mar 2023 09:25:56 +0100 Subject: [PATCH 5/6] refs #5342 actualido el itemType.isFragile para las 'plants' --- db/changes/231201/00-itemType_isFragile.sql | 11 ++++++++++- db/changes/231201/00-ticket_getWarnings.sql | 3 +-- db/dump/fixtures.sql | 14 +++++++------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/db/changes/231201/00-itemType_isFragile.sql b/db/changes/231201/00-itemType_isFragile.sql index 00a74b8b6..5b25288f3 100644 --- a/db/changes/231201/00-itemType_isFragile.sql +++ b/db/changes/231201/00-itemType_isFragile.sql @@ -1,5 +1,14 @@ ALTER TABLE `vn`.`itemType` ADD isFragile tinyint(1) NULL; ALTER TABLE `vn`.`itemType` MODIFY COLUMN isFragile tinyint(1) DEFAULT 0 NOT NULL; + UPDATE `vn`.`itemType` SET isFragile = 1 - WHERE code IN ('ZKA', 'ZKE'); +WHERE code IN ('ZKA', 'ZKE'); + +UPDATE `vn`.`itemType` + SET isFragile = 1 +WHERE id IN (SELECT it.id + FROM itemCategory ic + JOIN itemType it ON it.categoryFk = ic.id + WHERE ic.code = 'plant'); + diff --git a/db/changes/231201/00-ticket_getWarnings.sql b/db/changes/231201/00-ticket_getWarnings.sql index 605fe6ad0..5253b58ab 100644 --- a/db/changes/231201/00-ticket_getWarnings.sql +++ b/db/changes/231201/00-ticket_getWarnings.sql @@ -26,11 +26,10 @@ BEGIN LEFT JOIN sale s ON s.ticketFk = tt.ticketFk LEFT JOIN item i ON i.id = s.itemFk LEFT JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN agencyMode am ON am.id = tt.agencyModeFk LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk WHERE dm.code IN ('AGENCY') - AND (ic.code = 'plant' OR it.isFragile); + AND it.isFragile; DROP TEMPORARY TABLE IF EXISTS tmp.ticket_warnings; CREATE TEMPORARY TABLE tmp.ticket_warnings diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 2145f8429..f78313cc9 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -838,14 +838,14 @@ INSERT INTO `vn`.`temperature`(`code`, `name`, `description`) ('warm', 'Warm', 'Warm'), ('cool', 'Cool', 'Cool'); -INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`, `workerFk`, `isPackaging`, `temperatureFk`) +INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`, `workerFk`, `isPackaging`, `temperatureFk`, `isFragile`) VALUES - (1, 'CRI', 'Crisantemo', 2, 31, 35, 0, 'cool'), - (2, 'ITG', 'Anthurium', 1, 31, 35, 0, 'cool'), - (3, 'WPN', 'Paniculata', 2, 31, 35, 0, 'cool'), - (4, 'PRT', 'Delivery ports', 3, NULL, 35, 1, 'warm'), - (5, 'CON', 'Container', 3, NULL, 35, 1, 'warm'), - (6, 'ALS', 'Alstroemeria', 1, 31, 16, 0, 'warm'); + (1, 'CRI', 'Crisantemo', 2, 31, 35, 0, 'cool', 0), + (2, 'ITG', 'Anthurium', 1, 31, 35, 0, 'cool', 1), + (3, 'WPN', 'Paniculata', 2, 31, 35, 0, 'cool', 0), + (4, 'PRT', 'Delivery ports', 3, NULL, 35, 1, 'warm', 0), + (5, 'CON', 'Container', 3, NULL, 35, 1, 'warm', 0), + (6, 'ALS', 'Alstroemeria', 1, 31, 16, 0, 'warm', 1); INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`) VALUES From a45308c6a5bb53a94bd6943ddb9f2511f8a62c0b Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 24 Mar 2023 07:58:27 +0100 Subject: [PATCH 6/6] refs #5342 fix: testFront --- modules/claim/front/detail/index.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/claim/front/detail/index.spec.js b/modules/claim/front/detail/index.spec.js index 8f3049339..1ef779fd7 100644 --- a/modules/claim/front/detail/index.spec.js +++ b/modules/claim/front/detail/index.spec.js @@ -22,7 +22,8 @@ describe('claim', () => { controller = $componentController('vnClaimDetail', {$element, $scope}); controller.claim = { ticketFk: 1, - id: 2} + id: 2, + claimStateFk: 2} ; controller.salesToClaim = [{saleFk: 1}, {saleFk: 2}]; controller.salesClaimed = [{id: 1, sale: {}}];