From bb1695eac69b8449280bdc30a7108c2174c6dfd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 30 Sep 2024 16:39:55 +0200 Subject: [PATCH] fix: refs #7965 UnifyProblems --- .../vn/procedures/ticket_getProblems.sql | 18 +++++++++++++++++- modules/ticket/back/methods/ticket/filter.js | 5 +---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/ticket_getProblems.sql b/db/routines/vn/procedures/ticket_getProblems.sql index c5a1532ff..e58d49a5a 100644 --- a/db/routines/vn/procedures/ticket_getProblems.sql +++ b/db/routines/vn/procedures/ticket_getProblems.sql @@ -55,7 +55,8 @@ BEGIN SUM(IFNULL(ts.hasItemDelay,0)) hasItemDelay, SUM(IFNULL(ts.hasItemLost,0)) hasItemLost, IF(FIND_IN_SET('hasComponentLack', s.problem), TRUE, FALSE) hasComponentLack, - SUM(IFNULL(ts.hasRounding,0)) hasRounding + SUM(IFNULL(ts.hasRounding,0)) hasRounding, + 0 totalProblems FROM tmp.ticket tt JOIN ticket t ON t.id = tt.ticketFk JOIN client c ON c.id = t.clientFk @@ -64,5 +65,20 @@ BEGIN LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = util.VN_CURDATE() GROUP BY t.id; + + UPDATE tmp.ticketProblems + SET totalProblems = ( + (isFreezed) + + (hasHighRisk) + + (hasTicketRequest) + + (!isTaxDataChecked) + + (hasComponentLack) + + (hasItemDelay IS NOT NULL) + + (isTooLittle) + + (hasItemLost IS NOT NULL) + + (hasRounding IS NOT NULL) + + (hasItemShortage IS NOT NULL) + + (isVip) + ); END$$ DELIMITER ; diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index eccec735f..257121307 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -325,20 +325,17 @@ module.exports = Self => { let condition; let hasProblem; - let range; let hasWhere; switch (args.problems) { case true: condition = `or`; hasProblem = true; - range = {neq: null}; hasWhere = true; break; case false: condition = `and`; hasProblem = null; - range = null; hasWhere = true; break; } @@ -347,7 +344,7 @@ module.exports = Self => { {'tp.isFreezed': hasProblem}, {'tp.hasRisk': hasProblem}, {'tp.hasTicketRequest': hasProblem}, - {'tp.hasItemShortage': range}, + {'tp.hasItemShortage': hasProblem}, {'tp.hasRounding': hasProblem} ]};