From ae18a52a89604054445e2c188ca19bcd13060855 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 22 Jul 2024 06:41:02 +0200 Subject: [PATCH 1/4] fix: refs #7129 fix filter --- modules/route/back/methods/route/filter.js | 78 +++++++++++----------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/modules/route/back/methods/route/filter.js b/modules/route/back/methods/route/filter.js index 5b13a9004..89cee84c0 100644 --- a/modules/route/back/methods/route/filter.js +++ b/modules/route/back/methods/route/filter.js @@ -91,25 +91,23 @@ module.exports = Self => { let where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': - return {'r.id': value}; + return {'id': value}; case 'from': - return {'r.created': {gte: value}}; + return {'created': {gte: value}}; case 'to': - return {'r.created': {lte: value}}; + return {'created': {lte: value}}; case 'm3': - return {'r.m3': value}; + return {'m3': value}; case 'description': - return {'r.description': {like: `%${value}%`}}; + return {'description': {like: `%${value}%`}}; case 'warehouseFk': - param = `v.${param}`; + param = `${param}`; return {[param]: value}; - case 'workerFk': - case 'vehicleFk': case 'agencyModeFk': - param = `r.${param}`; + param = `${param}`; return {[param]: value}; case 'isOk': - return {'r.isOk': value}; + return {'isOk': value}; } }); @@ -119,34 +117,38 @@ module.exports = Self => { let stmt; stmt = new ParameterizedSQL( - `SELECT - r.id, - r.workerFk, - r.created, - r.vehicleFk, - r.agencyModeFk, - r.time, - r.isOk, - r.kmStart, - r.kmEnd, - r.started, - r.finished, - r.gestdocFk, - r.cost, - r.m3, - r.description, - am.name agencyName, - u.name AS workerUserName, - v.numberPlate AS vehiclePlateNumber, - Date_format(r.time, '%H:%i') hour, - eu.email - FROM route r - LEFT JOIN agencyMode am ON am.id = r.agencyModeFk - LEFT JOIN agency a ON a.id = am.agencyFk - LEFT JOIN vehicle v ON v.id = r.vehicleFk - LEFT JOIN worker w ON w.id = r.workerFk - LEFT JOIN account.user u ON u.id = w.id - LEFT JOIN account.emailUser eu ON eu.userFk = r.workerFk` + `SELECT * + FROM( + SELECT + r.id, + r.workerFk, + r.created, + r.vehicleFk, + r.agencyModeFk, + r.time, + r.isOk, + r.kmStart, + r.kmEnd, + r.started, + r.finished, + r.gestdocFk, + r.cost, + r.m3, + r.description, + am.name agencyName, + u.name workerUserName, + v.numberPlate vehiclePlateNumber, + Date_format(r.time, '%H:%i') hour, + eu.email, + v.warehouseFk + FROM route r + LEFT JOIN agencyMode am ON am.id = r.agencyModeFk + LEFT JOIN agency a ON a.id = am.agencyFk + LEFT JOIN vehicle v ON v.id = r.vehicleFk + LEFT JOIN worker w ON w.id = r.workerFk + LEFT JOIN account.user u ON u.id = w.id + LEFT JOIN account.emailUser eu ON eu.userFk = r.workerFk + ) sub` ); stmt.merge(conn.makeSuffix(filter)); From c3d3a21b23d900ce8ceff3db21c878185844334f Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 22 Jul 2024 09:12:24 +0200 Subject: [PATCH 2/4] feat: refs #7129 add fields --- modules/route/back/methods/route/cmrs.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/route/back/methods/route/cmrs.js b/modules/route/back/methods/route/cmrs.js index 0c25cbca5..6f271a4cf 100644 --- a/modules/route/back/methods/route/cmrs.js +++ b/modules/route/back/methods/route/cmrs.js @@ -91,11 +91,13 @@ module.exports = Self => { SELECT t.cmrFk, t.id ticketFk, t.routeFk, - co.name country, + co.id countryFk, + co.name countryName, t.clientFk, IF(sub.id, TRUE, FALSE) hasCmrDms, DATE(t.shipped) shipped, - t.warehouseFk + t.warehouseFk, + w.name warehouseName FROM ticket t JOIN ticketState ts ON ts.ticketFk = t.id JOIN state s ON s.id = ts.stateFk From c18765f22f658d7f4f1216076db6dd5ac2d01061 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 22 Jul 2024 09:18:37 +0200 Subject: [PATCH 3/4] fix: refs #7129 fix return --- modules/route/back/methods/route/filter.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/route/back/methods/route/filter.js b/modules/route/back/methods/route/filter.js index 89cee84c0..8f90fc532 100644 --- a/modules/route/back/methods/route/filter.js +++ b/modules/route/back/methods/route/filter.js @@ -101,10 +101,8 @@ module.exports = Self => { case 'description': return {'description': {like: `%${value}%`}}; case 'warehouseFk': - param = `${param}`; return {[param]: value}; case 'agencyModeFk': - param = `${param}`; return {[param]: value}; case 'isOk': return {'isOk': value}; From b73eceb1c8341ad2f93b945ace10f74bca7de099 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 22 Jul 2024 13:33:51 +0200 Subject: [PATCH 4/4] fix: refs #7129 fix backFilters --- modules/route/back/methods/route/filter.js | 9 ++++----- modules/route/back/methods/route/getByWorker.js | 14 +++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/modules/route/back/methods/route/filter.js b/modules/route/back/methods/route/filter.js index 8f90fc532..925927cc8 100644 --- a/modules/route/back/methods/route/filter.js +++ b/modules/route/back/methods/route/filter.js @@ -96,16 +96,15 @@ module.exports = Self => { return {'created': {gte: value}}; case 'to': return {'created': {lte: value}}; - case 'm3': - return {'m3': value}; case 'description': return {'description': {like: `%${value}%`}}; + case 'isOk': + case 'm3': case 'warehouseFk': - return {[param]: value}; + case 'workerFk': + case 'vehicleFk': case 'agencyModeFk': return {[param]: value}; - case 'isOk': - return {'isOk': value}; } }); diff --git a/modules/route/back/methods/route/getByWorker.js b/modules/route/back/methods/route/getByWorker.js index 9243cfbfb..5d1881c20 100644 --- a/modules/route/back/methods/route/getByWorker.js +++ b/modules/route/back/methods/route/getByWorker.js @@ -28,11 +28,11 @@ module.exports = Self => { if (canViewAll) { const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions); filterGrant = { - where: {'a.warehouseFk': userConfig.warehouseFk} + where: {'warehouseFk': userConfig.warehouseFk} }; } else { filterGrant = { - where: {'r.workerFk': userId} + where: {'workerFk': userId} }; } @@ -46,16 +46,16 @@ module.exports = Self => { and: [ { or: [ - {'r.created': currentDate}, - {'r.created': nextDay} + {'created': currentDate}, + {'created': nextDay} ] } ] }, order: [ - 'r.created ASC', - 'r.time ASC', - 'am.name ASC' + 'created ASC', + 'time ASC', + 'agencyName ASC' ] };