From c24c12673430809fe62f5d437e31e978518b5455 Mon Sep 17 00:00:00 2001 From: nelo Date: Tue, 13 Jun 2017 08:44:40 +0200 Subject: [PATCH] fake son de tickets my model tiene el meted raw sql --- services/client/common/models/my-model.js | 10 +- .../common/methods/ticket/list-fake.json | 1012 +++++++++++++++++ .../production/common/methods/ticket/list.js | 44 + services/production/common/models/Ticket.json | 10 +- services/production/common/models/my-model.js | 10 +- services/production/common/models/state.json | 30 + .../common/models/ticket-state.json | 47 + services/production/common/models/ticket.js | 9 + services/production/server/model-config.json | 35 +- services/service/models/my-model.js | 10 +- 10 files changed, 1205 insertions(+), 12 deletions(-) create mode 100644 services/production/common/methods/ticket/list-fake.json create mode 100644 services/production/common/methods/ticket/list.js create mode 100644 services/production/common/models/state.json create mode 100644 services/production/common/models/ticket-state.json create mode 100644 services/production/common/models/ticket.js diff --git a/services/client/common/models/my-model.js b/services/client/common/models/my-model.js index 009b025f3..4d98e7f62 100644 --- a/services/client/common/models/my-model.js +++ b/services/client/common/models/my-model.js @@ -1,5 +1,6 @@ module.exports = function(self) { + self.setup = function() { self.super_.setup.call(this); @@ -25,7 +26,14 @@ module.exports = function(self) { for(let method in disableMethods) { //this.disableRemoteMethod(method, disableMethods[method]); } - } + + }; + + self.rawSql = function(query, params, cb) { + this.dataSource.connector.execute(query, params, function(error, response) { + cb(error, response); + }); + }; self.installMethod = function(methodName, filterCb) { this.remoteMethod(methodName, { diff --git a/services/production/common/methods/ticket/list-fake.json b/services/production/common/methods/ticket/list-fake.json new file mode 100644 index 000000000..34c5e714e --- /dev/null +++ b/services/production/common/methods/ticket/list-fake.json @@ -0,0 +1,1012 @@ +[ + { + "Ticket": 1532629, + "Agency": "REC_MADRID", + "Worker": "LOLI LOZANO RAEZ", + "Hout": 20, + "State": "OK", + "Lines": 2, + "m3": 0.03, + "Boxes": 0 + }, + { + "Ticket": 1532645, + "Agency": "CORREOSEXPRESS", + "Worker": "COMPUTER SYSTEM", + "Hout": 17, + "State": "Libre", + "Lines": 9, + "m3": 0.21, + "Boxes": 0 + }, + { + "Ticket": 1532656, + "Agency": "ZONA 32", + "Worker": "COMPUTER SYSTEM", + "Hout": 19, + "State": "Libre", + "Lines": 35, + "m3": 0.42, + "Boxes": 0 + }, + { + "Ticket": 1532690, + "Agency": "MRW 24h", + "Worker": "MARIA JOSE LAMELA FELIPE", + "Hout": 17, + "State": "OK", + "Lines": 4, + "m3": 0.21, + "Boxes": 0 + }, + { + "Ticket": 1532729, + "Agency": "ZONA 25", + "Worker": "COMPUTER SYSTEM", + "Hout": 20, + "State": "Libre", + "Lines": 17, + "m3": 0.45, + "Boxes": 0 + }, + { + "Ticket": 1532742, + "Agency": "CORREOSEXPRESS", + "Worker": "DEMBA SAKHO", + "Hout": 17, + "State": "Encajado", + "Lines": 13, + "m3": 0.27, + "Boxes": 0 + }, + { + "Ticket": 1532792, + "Agency": "ZONA 25", + "Worker": "JUAN BAUTISTA PASTOR REDONDO", + "Hout": 20, + "State": "OK", + "Lines": 10, + "m3": 0.26, + "Boxes": 0 + }, + { + "Ticket": 1532803, + "Agency": "ZONA 31", + "Worker": "COMPUTER SYSTEM", + "Hout": 19, + "State": "Libre", + "Lines": 12, + "m3": 0.49, + "Boxes": 0 + }, + { + "Ticket": 1532812, + "Agency": "ZELERIS", + "Worker": "JULIA LLOPIS CASTELL", + "Hout": 17, + "State": "Arreglar", + "Lines": 19, + "m3": 0.67, + "Boxes": 0 + }, + { + "Ticket": 1532879, + "Agency": "ZONA 20", + "Worker": "MARIA JOSE LAMELA FELIPE", + "Hout": 20, + "State": "OK", + "Lines": 1, + "m3": 0.41, + "Boxes": 0 + }, + { + "Ticket": 1532880, + "Agency": "ZONA 20", + "Worker": "COMPUTER SYSTEM", + "Hout": 20, + "State": "Libre", + "Lines": 8, + "m3": 0.08, + "Boxes": 0 + }, + { + "Ticket": 1532923, + "Agency": "ZONA 20", + "Worker": "JESUS DANIEL VALLES PEREZ", + "Hout": 20, + "State": "OK", + "Lines": 30, + "m3": 0.63, + "Boxes": 1 + }, + { + "Ticket": 1532995, + "Agency": "ZONA 20", + "Worker": "DANIEL YAREHAM PALOMO", + "Hout": 20, + "State": "Arreglar", + "Lines": 54, + "m3": 1.62, + "Boxes": 0 + }, + { + "Ticket": 1533009, + "Agency": "ZONA 25", + "Worker": "MARIA JOSE LAMELA FELIPE", + "Hout": 20, + "State": "Sin Acabar", + "Lines": 38, + "m3": 0.78, + "Boxes": 0 + }, + { + "Ticket": 1533051, + "Agency": "MRW 24h", + "Worker": "MARIA JOSE LAMELA FELIPE", + "Hout": 17, + "State": "Sin Acabar", + "Lines": 19, + "m3": 0.91, + "Boxes": 2 + }, + { + "Ticket": 1533064, + "Agency": "MRW 24h", + "Worker": "JOSE JAVIER ECHEVARRIA", + "Hout": 17, + "State": "OK", + "Lines": 11, + "m3": 0.22, + "Boxes": 0 + }, + { + "Ticket": 1533102, + "Agency": "MRW 24h", + "Worker": "LOLI LOZANO RAEZ", + "Hout": 17, + "State": "OK", + "Lines": 9, + "m3": 0.35, + "Boxes": 0 + }, + { + "Ticket": 1533151, + "Agency": "ZONA 32", + "Worker": "COMPUTER SYSTEM", + "Hout": 19, + "State": "Libre", + "Lines": 7, + "m3": 0.05, + "Boxes": 0 + }, + { + "Ticket": 1533182, + "Agency": "ZONA 25", + "Worker": "CARLOS LOPEZ AMORES", + "Hout": 20, + "State": "OK", + "Lines": 20, + "m3": 0.26, + "Boxes": 0 + }, + { + "Ticket": 1533257, + "Agency": "MRW 24h", + "Worker": "MARIA JOSE LAMELA FELIPE", + "Hout": 17, + "State": "OK", + "Lines": 14, + "m3": 0.07, + "Boxes": 0 + }, + { + "Ticket": 1533279, + "Agency": "ZONA 46", + "Worker": "RICARD SENDRA", + "Hout": 15, + "State": "Impreso", + "Lines": 50, + "m3": 1.05, + "Boxes": 2 + }, + { + "Ticket": 1533284, + "Agency": "ZONA 20", + "Worker": "MARIA JOSE LAMELA FELIPE", + "Hout": 20, + "State": "OK", + "Lines": 18, + "m3": 0.21, + "Boxes": 0 + }, + { + "Ticket": 1533314, + "Agency": "MRW 24h", + "Worker": "MARIA JOSE LAMELA FELIPE", + "Hout": 17, + "State": "OK", + "Lines": 3, + "m3": 0.05, + "Boxes": 0 + }, + { + "Ticket": 1533316, + "Agency": "ZONA 25", + "Worker": "LOLI LOZANO RAEZ", + "Hout": 20, + "State": "OK", + "Lines": 17, + "m3": 0.49, + "Boxes": 0 + }, + { + "Ticket": 1533319, + "Agency": "ZONA 25", + "Worker": "ELENA BASCUÑANA TORNERO", + "Hout": 20, + "State": "OK", + "Lines": 2, + "m3": 0.04, + "Boxes": 0 + }, + { + "Ticket": 1533327, + "Agency": "ZONA 25", + "Worker": "FRAN NATEK ECHEVARRIA", + "Hout": 20, + "State": "OK", + "Lines": 13, + "m3": 0.32, + "Boxes": 0 + }, + { + "Ticket": 1533339, + "Agency": "ZONA 20", + "Worker": "ELENA BASCUÑANA TORNERO", + "Hout": 20, + "State": "OK", + "Lines": 9, + "m3": 0.17, + "Boxes": 0 + }, + { + "Ticket": 1533340, + "Agency": "ZONA 25", + "Worker": "JULIA LLOPIS CASTELL", + "Hout": 20, + "State": "Arreglar", + "Lines": 48, + "m3": 1.59, + "Boxes": 4.5 + }, + { + "Ticket": 1533345, + "Agency": "ZONA 31", + "Worker": "COMPUTER SYSTEM", + "Hout": 19, + "State": "Libre", + "Lines": 56, + "m3": 0.79, + "Boxes": 0 + }, + { + "Ticket": 1533349, + "Agency": "ZONA 20", + "Worker": "COMPUTER SYSTEM", + "Hout": 20, + "State": "Libre", + "Lines": 12, + "m3": 0.34, + "Boxes": 0 + }, + { + "Ticket": 1533353, + "Agency": "ZONA 11", + "Worker": "COMPUTER SYSTEM", + "Hout": 21, + "State": "Libre", + "Lines": 10, + "m3": 0.08, + "Boxes": 0 + }, + { + "Ticket": 1533359, + "Agency": "ZONA 20", + "Worker": "CARLOS LOPEZ AMORES", + "Hout": 20, + "State": "OK", + "Lines": 9, + "m3": 0.52, + "Boxes": 0 + }, + { + "Ticket": 1533369, + "Agency": "INTEGRA2", + "Worker": "CARLOS LOPEZ AMORES", + "Hout": 17, + "State": "OK", + "Lines": 7, + "m3": 0.1, + "Boxes": 0 + }, + { + "Ticket": 1533392, + "Agency": "ZONA 25", + "Worker": "COMPUTER SYSTEM", + "Hout": 20, + "State": "Libre", + "Lines": 16, + "m3": 0.35, + "Boxes": 0 + }, + { + "Ticket": 1533403, + "Agency": "ZONA 31", + "Worker": "Mª CARMEN SERRANO BAU", + "Hout": 19, + "State": "OK", + "Lines": 1, + "m3": 2.04, + "Boxes": 0 + }, + { + "Ticket": 1533412, + "Agency": "ZELERIS", + "Worker": "CARLOS BORRAS MARTINEZ", + "Hout": 17, + "State": "OK", + "Lines": 5, + "m3": 0.04, + "Boxes": 0 + }, + { + "Ticket": 1533425, + "Agency": "INTEGRA2", + "Worker": "CARLOS LOPEZ AMORES", + "Hout": 17, + "State": "OK", + "Lines": 11, + "m3": 0.14, + "Boxes": 0 + }, + { + "Ticket": 1533429, + "Agency": "ZONA 25", + "Worker": "DANIEL YAREHAM PALOMO", + "Hout": 20, + "State": "OK", + "Lines": 43, + "m3": 0.6, + "Boxes": 0 + }, + { + "Ticket": 1533438, + "Agency": "ZELERIS", + "Worker": "MIGUEL ANGEL LORITE", + "Hout": 17, + "State": "Preparación", + "Lines": 10, + "m3": 0.17, + "Boxes": 0 + }, + { + "Ticket": 1533482, + "Agency": "ZONA 25", + "Worker": "MARIA JOSE LAMELA FELIPE", + "Hout": 20, + "State": "Sin Acabar", + "Lines": 30, + "m3": 0.42, + "Boxes": 0 + }, + { + "Ticket": 1533486, + "Agency": "DHL", + "Worker": "JOSE JAVIER ECHEVARRIA", + "Hout": 17, + "State": "OK", + "Lines": 28, + "m3": 0.25, + "Boxes": 0 + }, + { + "Ticket": 1533495, + "Agency": "REC_VILASSAR", + "Worker": "COMPUTER SYSTEM", + "Hout": 19, + "State": "Libre", + "Lines": 16, + "m3": 0.08, + "Boxes": 0 + }, + { + "Ticket": 1533507, + "Agency": "MRW 24h", + "Worker": "MARIA JOSE LAMELA FELIPE", + "Hout": 17, + "State": "OK", + "Lines": 16, + "m3": 0.39, + "Boxes": 0 + }, + { + "Ticket": 1533557, + "Agency": "ZONA 11", + "Worker": "MARIA JOSE LAMELA FELIPE", + "Hout": 21, + "State": "OK", + "Lines": 50, + "m3": 1.16, + "Boxes": 0 + }, + { + "Ticket": 1533566, + "Agency": "ZONA 10", + "Worker": "MARIA JOSE LAMELA FELIPE", + "Hout": 23, + "State": "Sin Acabar", + "Lines": 14, + "m3": 0.18, + "Boxes": 0 + }, + { + "Ticket": 1533570, + "Agency": "MRW 24h", + "Worker": "MARIA JOSE LAMELA FELIPE", + "Hout": 17, + "State": "OK", + "Lines": 13, + "m3": 0.17, + "Boxes": 0 + }, + { + "Ticket": 1533580, + "Agency": "ZELERIS_10", + "Worker": "DEMBA SAKHO", + "Hout": 17, + "State": "Encajado", + "Lines": 4, + "m3": 0.13, + "Boxes": 0 + }, + { + "Ticket": 1533584, + "Agency": "ZONA 20", + "Worker": "JESUS DANIEL VALLES PEREZ", + "Hout": 20, + "State": "OK", + "Lines": 20, + "m3": 0.67, + "Boxes": 0 + }, + { + "Ticket": 1533585, + "Agency": "ZELERIS_10", + "Worker": "FRAN NATEK ECHEVARRIA", + "Hout": 17, + "State": "Sin Acabar", + "Lines": 1, + "m3": 0.01, + "Boxes": 0 + }, + { + "Ticket": 1533591, + "Agency": "ZONA 46", + "Worker": "JUANLU GALLETERO", + "Hout": 15, + "State": "Revisado", + "Lines": 16, + "m3": 0.3, + "Boxes": 0 + }, + { + "Ticket": 1533641, + "Agency": "ZONA 25", + "Worker": "COMPUTER SYSTEM", + "Hout": 20, + "State": "Libre", + "Lines": 28, + "m3": 0.75, + "Boxes": 0 + }, + { + "Ticket": 1533685, + "Agency": "ZONA 20", + "Worker": "Mª CARMEN SERRANO BAU", + "Hout": 20, + "State": "OK", + "Lines": 39, + "m3": 0.78, + "Boxes": 1 + }, + { + "Ticket": 1533688, + "Agency": "ZONA 20", + "Worker": "COMPUTER SYSTEM", + "Hout": 20, + "State": "Libre", + "Lines": 7, + "m3": 0.19, + "Boxes": 0 + }, + { + "Ticket": 1533795, + "Agency": "ZONA 25", + "Worker": "MANOLI PULIDO", + "Hout": 20, + "State": "OK", + "Lines": 16, + "m3": 0.3, + "Boxes": 0 + }, + { + "Ticket": 1533797, + "Agency": "ZONA 25", + "Worker": "COMPUTER SYSTEM", + "Hout": 20, + "State": "Libre", + "Lines": 20, + "m3": 0.33, + "Boxes": 0 + }, + { + "Ticket": 1533807, + "Agency": "ZONA 25", + "Worker": "ESDENKA CALERO PEREZ", + "Hout": 20, + "State": "Arreglar", + "Lines": 16, + "m3": 0.14, + "Boxes": 0 + }, + { + "Ticket": 1533815, + "Agency": "ZELERIS_10", + "Worker": "RODRIGO HALABI ROCHA", + "Hout": 17, + "State": "OK", + "Lines": 15, + "m3": 0.2, + "Boxes": 0 + }, + { + "Ticket": 1533849, + "Agency": "MRW 24h", + "Worker": "JUAN CARLOS LORENZO SANCHEZ", + "Hout": 17, + "State": "OK", + "Lines": 18, + "m3": 0.25, + "Boxes": 0 + }, + { + "Ticket": 1533852, + "Agency": "MRW 24h", + "Worker": "DANIEL YAREHAM PALOMO", + "Hout": 17, + "State": "OK", + "Lines": 17, + "m3": 0.68, + "Boxes": 0 + }, + { + "Ticket": 1533854, + "Agency": "ZONA 20", + "Worker": "MANOLI PULIDO", + "Hout": 20, + "State": "OK", + "Lines": 11, + "m3": 0.13, + "Boxes": 0 + }, + { + "Ticket": 1533863, + "Agency": "ZELERIS_10", + "Worker": "DEMBA SAKHO", + "Hout": 17, + "State": "Encajado", + "Lines": 6, + "m3": 0.16, + "Boxes": 0 + }, + { + "Ticket": 1533882, + "Agency": "ZONA 20", + "Worker": "MARIA JOSE LAMELA FELIPE", + "Hout": 20, + "State": "OK", + "Lines": 9, + "m3": 0.44, + "Boxes": 0 + }, + { + "Ticket": 1533889, + "Agency": "MRW 24h", + "Worker": "ELENA BASCUÑANA TORNERO", + "Hout": 17, + "State": "OK", + "Lines": 10, + "m3": 0.5, + "Boxes": 0 + }, + { + "Ticket": 1533893, + "Agency": "ZONA 32", + "Worker": "COMPUTER SYSTEM", + "Hout": 19, + "State": "Libre", + "Lines": 2, + "m3": 0.13, + "Boxes": 0 + }, + { + "Ticket": 1533915, + "Agency": "CORREOSEXPRESS", + "Worker": "JUAN BAUTISTA PASTOR REDONDO", + "Hout": 17, + "State": "OK", + "Lines": 9, + "m3": 0.36, + "Boxes": 0 + }, + { + "Ticket": 1533919, + "Agency": "ZONA 20", + "Worker": "JULIA LLOPIS CASTELL", + "Hout": 20, + "State": "Arreglar", + "Lines": 16, + "m3": 0.23, + "Boxes": 0 + }, + { + "Ticket": 1533983, + "Agency": "ZONA 11", + "Worker": "MANOLI PULIDO", + "Hout": 21, + "State": "OK", + "Lines": 30, + "m3": 1.92, + "Boxes": 0 + }, + { + "Ticket": 1533992, + "Agency": "ZONA 25", + "Worker": "COMPUTER SYSTEM", + "Hout": 20, + "State": "Libre", + "Lines": 32, + "m3": 0.23, + "Boxes": 0 + }, + { + "Ticket": 1534032, + "Agency": "MRW 24h", + "Worker": "JESUS DANIEL VALLES PEREZ", + "Hout": 17, + "State": "Sin Acabar", + "Lines": 4, + "m3": 0.04, + "Boxes": 0 + }, + { + "Ticket": 1534033, + "Agency": "ZONA 31", + "Worker": "COMPUTER SYSTEM", + "Hout": 19, + "State": "Libre", + "Lines": 14, + "m3": 0.65, + "Boxes": 0 + }, + { + "Ticket": 1534055, + "Agency": "ZONA 32", + "Worker": "COMPUTER SYSTEM", + "Hout": 19, + "State": "Libre", + "Lines": 42, + "m3": 1.09, + "Boxes": 0 + }, + { + "Ticket": 1534076, + "Agency": "REC_VILASSAR", + "Worker": "CRISTINA SANCHEZ BARRUGUER", + "Hout": 19, + "State": "OK", + "Lines": 4, + "m3": 0.03, + "Boxes": 0 + }, + { + "Ticket": 1534101, + "Agency": "CORREOSEXPRESS", + "Worker": "JESUS DANIEL VALLES PEREZ", + "Hout": 17, + "State": "Sin Acabar", + "Lines": 1, + "m3": 0.02, + "Boxes": 0 + }, + { + "Ticket": 1534186, + "Agency": "ZONA 32", + "Worker": "COMPUTER SYSTEM", + "Hout": 19, + "State": "Libre", + "Lines": 16, + "m3": 0.4, + "Boxes": 0 + }, + { + "Ticket": 1534187, + "Agency": "ZONA 46", + "Worker": "MIGUEL ANGEL LORITE", + "Hout": 15, + "State": "Preparado", + "Lines": 3, + "m3": 0.17, + "Boxes": 0 + }, + { + "Ticket": 1534212, + "Agency": "ZELERIS_10", + "Worker": "RODRIGO HALABI ROCHA", + "Hout": 17, + "State": "Bloqueado", + "Lines": 2, + "m3": 0.07, + "Boxes": 0 + }, + { + "Ticket": 1534223, + "Agency": "ZONA 10", + "Worker": "JESUS DANIEL VALLES PEREZ", + "Hout": 23, + "State": "Sin Acabar", + "Lines": 4, + "m3": 0.05, + "Boxes": 0 + }, + { + "Ticket": 1534236, + "Agency": "REC_MADRID", + "Worker": "COMPUTER SYSTEM", + "Hout": 20, + "State": "Libre", + "Lines": 5, + "m3": 0.04, + "Boxes": 0 + }, + { + "Ticket": 1534240, + "Agency": "ZONA 46", + "Worker": "MARIA JOSE LAMELA FELIPE", + "Hout": 15, + "State": "OK", + "Lines": 47, + "m3": 0.91, + "Boxes": 1 + }, + { + "Ticket": 1534252, + "Agency": "VIAEXPRESS Interdia", + "Worker": "DEMBA SAKHO", + "Hout": 12, + "State": "Encajado", + "Lines": 2, + "m3": 0.02, + "Boxes": 0 + }, + { + "Ticket": 1534258, + "Agency": "ZONA 20", + "Worker": "DANIEL YAREHAM PALOMO", + "Hout": 20, + "State": "OK", + "Lines": 5, + "m3": 0.18, + "Boxes": 0 + }, + { + "Ticket": 1534261, + "Agency": "REC_VILASSAR", + "Worker": "COMPUTER SYSTEM", + "Hout": 19, + "State": "Libre", + "Lines": 5, + "m3": 0.18, + "Boxes": 0 + }, + { + "Ticket": 1534264, + "Agency": "ZONA 20", + "Worker": "JOSE VICENTE DOMINGO SANCHEZ", + "Hout": 20, + "State": "Sin Acabar", + "Lines": 2, + "m3": 0.37, + "Boxes": 2 + }, + { + "Ticket": 1534300, + "Agency": "ZONA 20", + "Worker": "RODRIGO HALABI ROCHA", + "Hout": 20, + "State": "Sin Acabar", + "Lines": 1, + "m3": 0.02, + "Boxes": 0 + }, + { + "Ticket": 1534302, + "Agency": "ZONA 25", + "Worker": "LOLI LOZANO RAEZ", + "Hout": 20, + "State": "OK", + "Lines": 19, + "m3": 1.11, + "Boxes": 0 + }, + { + "Ticket": 1534311, + "Agency": "ZONA 32", + "Worker": "JULIA LLOPIS CASTELL", + "Hout": 19, + "State": "Arreglar", + "Lines": 43, + "m3": 0.8, + "Boxes": 0 + }, + { + "Ticket": 1534315, + "Agency": "ZONA 20", + "Worker": "DANIEL YAREHAM PALOMO", + "Hout": 20, + "State": "Asignado", + "Lines": 6, + "m3": 0.34, + "Boxes": 0 + }, + { + "Ticket": 1534327, + "Agency": "ZONA 43", + "Worker": "COMPUTER SYSTEM", + "Hout": 14, + "State": "Libre", + "Lines": 23, + "m3": 0.41, + "Boxes": 0 + }, + { + "Ticket": 1534354, + "Agency": "ZONA 46", + "Worker": "MARIA DEL MAR GIRBES FERRUS", + "Hout": 15, + "State": "Asignado", + "Lines": 23, + "m3": 1.67, + "Boxes": 0 + }, + { + "Ticket": 1534359, + "Agency": "ZELERIS", + "Worker": "JULIA LLOPIS CASTELL", + "Hout": 17, + "State": "Arreglar", + "Lines": 3, + "m3": 0.06, + "Boxes": 0 + }, + { + "Ticket": 1534366, + "Agency": "REC_SILLA", + "Worker": "COMPUTER SYSTEM", + "Hout": 23, + "State": "Libre", + "Lines": 23, + "m3": 0.4, + "Boxes": 0 + }, + { + "Ticket": 1534385, + "Agency": "ZELERIS", + "Worker": "CARLOS LOPEZ AMORES", + "Hout": 17, + "State": "OK", + "Lines": 4, + "m3": 0.12, + "Boxes": 0 + }, + { + "Ticket": 1534397, + "Agency": "ZONA 20", + "Worker": "JUAN CARLOS LORENZO SANCHEZ", + "Hout": 20, + "State": "OK", + "Lines": 14, + "m3": 0.21, + "Boxes": 0 + }, + { + "Ticket": 1534428, + "Agency": "ZELERIS", + "Worker": "FRAN NATEK ECHEVARRIA", + "Hout": 17, + "State": "OK", + "Lines": 9, + "m3": 0.3, + "Boxes": 0 + }, + { + "Ticket": 1534467, + "Agency": "MRW 24h", + "Worker": "COMPUTER SYSTEM", + "Hout": 17, + "State": "Libre", + "Lines": 15, + "m3": 0.12, + "Boxes": 0 + }, + { + "Ticket": 1534477, + "Agency": "ZONA 11", + "Worker": "CRISTINA SANCHEZ BARRUGUER", + "Hout": 21, + "State": "OK", + "Lines": 8, + "m3": 0.09, + "Boxes": 0 + }, + { + "Ticket": 1534490, + "Agency": "ZONA 43", + "Worker": "JULIA LLOPIS CASTELL", + "Hout": 14, + "State": "Arreglar", + "Lines": 38, + "m3": 1.15, + "Boxes": 0 + }, + { + "Ticket": 1534500, + "Agency": "ZONA 20", + "Worker": "CARLOS LOPEZ AMORES", + "Hout": 20, + "State": "OK", + "Lines": 10, + "m3": 0.35, + "Boxes": 0 + }, + { + "Ticket": 1534504, + "Agency": "ZONA 20", + "Worker": "LOLI LOZANO RAEZ", + "Hout": 20, + "State": "OK", + "Lines": 18, + "m3": 0.18, + "Boxes": 0 + }, + { + "Ticket": 1534505, + "Agency": "ZONA 20", + "Worker": "JUAN BAUTISTA PASTOR REDONDO", + "Hout": 20, + "State": "OK", + "Lines": 5, + "m3": 0.23, + "Boxes": 0 + }, + { + "Ticket": 1534533, + "Agency": "ZONA 45", + "Worker": "DANIEL YAREHAM PALOMO", + "Hout": 24, + "State": "OK", + "Lines": 2, + "m3": 0.25, + "Boxes": 2 + } +] \ No newline at end of file diff --git a/services/production/common/methods/ticket/list.js b/services/production/common/methods/ticket/list.js new file mode 100644 index 000000000..79dad23b9 --- /dev/null +++ b/services/production/common/methods/ticket/list.js @@ -0,0 +1,44 @@ +var json = require("./list-fake.json"); + +module.exports = function(Ticket) { + Ticket.remoteMethod('list', { + description: 'List tickets for production', + /*accepts: { + arg: 'id', + type: 'number', + required: true, + description: 'Model id', + http: {source: 'path'} + },*/ + returns: { + arg: 'tickets', + type: 'object' + }, + http: { + verb: 'get', + path: '/list' + } + }); + + Ticket.list = function(cb) { + //list(); + return fake(cb); + }; + + var fake = function(cb){ + cb(null, json); + } + + var list = function(){ + var params = [1, 0]; + + var query = "CALL production_control_source(?, ?)" + + var cb = function(error, res){ + if(error) console.log(error); + else console.log(res); + }; + + Ticket.rawSql(query, params, cb); + } +} \ No newline at end of file diff --git a/services/production/common/models/Ticket.json b/services/production/common/models/Ticket.json index 16d5e07a5..4ae89da10 100644 --- a/services/production/common/models/Ticket.json +++ b/services/production/common/models/Ticket.json @@ -1,8 +1,14 @@ { "name": "Ticket", - "base": "PersistedModel", + "base": "MyModel", "validateUpsert": true, - "properties": {}, + "properties": { + "id": { + "id": true, + "type": "Number", + "forceId": false + } + }, "acls": [ { "accessType": "*", diff --git a/services/production/common/models/my-model.js b/services/production/common/models/my-model.js index 009b025f3..4d98e7f62 100644 --- a/services/production/common/models/my-model.js +++ b/services/production/common/models/my-model.js @@ -1,5 +1,6 @@ module.exports = function(self) { + self.setup = function() { self.super_.setup.call(this); @@ -25,7 +26,14 @@ module.exports = function(self) { for(let method in disableMethods) { //this.disableRemoteMethod(method, disableMethods[method]); } - } + + }; + + self.rawSql = function(query, params, cb) { + this.dataSource.connector.execute(query, params, function(error, response) { + cb(error, response); + }); + }; self.installMethod = function(methodName, filterCb) { this.remoteMethod(methodName, { diff --git a/services/production/common/models/state.json b/services/production/common/models/state.json new file mode 100644 index 000000000..97e2eecf3 --- /dev/null +++ b/services/production/common/models/state.json @@ -0,0 +1,30 @@ +{ + "name": "State", + "base": "MyModel", + "validateUpsert": true, + "properties": { + "id": { + "id": true, + "type": "Number", + "forceId": false + }, + "name": { + "type": "String", + "required": false + } + }, + "acls": [ + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "DENY" + }, + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "root", + "permission": "ALLOW" + } + ] +} diff --git a/services/production/common/models/ticket-state.json b/services/production/common/models/ticket-state.json new file mode 100644 index 000000000..5f919ff2a --- /dev/null +++ b/services/production/common/models/ticket-state.json @@ -0,0 +1,47 @@ +{ + "name": "TicketState", + "base": "MyModel", + "validateUpsert": true, + "properties": { + "id": { + "id": true, + "type": "Number", + "forceId": false + }, + "updated": { + "type": "Date", + "required": false + } + }, + "relations": { + "ticket": { + "type": "belongsTo", + "model": "Ticket", + "foreignKey": "ticketFk" + }, + "state": { + "type": "belongsTo", + "model": "State", + "foreignKey": "stateFk" + }, + "employee": { + "type": "belongsTo", + "model": "Employee", + "foreignKey": "employeeFk" + } + }, + "acls": [ + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "DENY" + }, + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "root", + "permission": "ALLOW" + } + ] +} diff --git a/services/production/common/models/ticket.js b/services/production/common/models/ticket.js new file mode 100644 index 000000000..ab62f6309 --- /dev/null +++ b/services/production/common/models/ticket.js @@ -0,0 +1,9 @@ +var app = require('../../server/server'); + +module.exports = function(Ticket) { + var models = app.models; + + // Methods + + require('../methods/ticket/list.js')(Ticket); +}; \ No newline at end of file diff --git a/services/production/server/model-config.json b/services/production/server/model-config.json index 8a1204120..7f29155b0 100644 --- a/services/production/server/model-config.json +++ b/services/production/server/model-config.json @@ -13,23 +13,44 @@ "./mixins" ] }, - "User": { - "dataSource": "db" + "user": { + "dataSource": "auth" }, "AccessToken": { - "dataSource": "db", - "public": false + "dataSource": "auth", + "relations": { + "user": { + "type": "belongsTo", + "model": "user", + "foreignKey": "userId" + } + } }, "ACL": { - "dataSource": "db", + "dataSource": "auth", "public": false }, "RoleMapping": { - "dataSource": "db", + "dataSource": "auth", "public": false }, "Role": { - "dataSource": "db", + "dataSource": "auth", "public": false + }, + "Account": { + "dataSource": "auth" + }, + "Ticket": { + "dataSource": "vn", + "public": true + }, + "State":{ + "dataSource": "vn", + "public": true + }, + "TicketState":{ + "dataSource": "vn", + "public": true } } diff --git a/services/service/models/my-model.js b/services/service/models/my-model.js index 009b025f3..4d98e7f62 100644 --- a/services/service/models/my-model.js +++ b/services/service/models/my-model.js @@ -1,5 +1,6 @@ module.exports = function(self) { + self.setup = function() { self.super_.setup.call(this); @@ -25,7 +26,14 @@ module.exports = function(self) { for(let method in disableMethods) { //this.disableRemoteMethod(method, disableMethods[method]); } - } + + }; + + self.rawSql = function(query, params, cb) { + this.dataSource.connector.execute(query, params, function(error, response) { + cb(error, response); + }); + }; self.installMethod = function(methodName, filterCb) { this.remoteMethod(methodName, {