diff --git a/flows.json b/flows.json index 396d0ca..6c8c4b4 100644 --- a/flows.json +++ b/flows.json @@ -8,7 +8,7 @@ "env": [] }, { - "id": "a796bfad8ab76fe4", + "id": "6e1ee0f06e75580d", "type": "tab", "label": "Cartociudad", "disabled": false, @@ -16,9 +16,9 @@ "env": [] }, { - "id": "6e1ee0f06e75580d", + "id": "e3a070490bfdc383", "type": "tab", - "label": "Cartociudad Rapido", + "label": "Mongo a PostGIS", "disabled": false, "info": "", "env": [] @@ -49,6 +49,294 @@ "w": 892, "h": 202 }, + { + "id": "eefff18186897436", + "type": "group", + "z": "1a4b40705122dc91", + "name": "Preparación de la base de datos", + "style": { + "stroke": "#000000", + "fill": "#e3f3d3", + "label": true, + "label-position": "n", + "color": "#000000" + }, + "nodes": [ + "683191909606de5f", + "c8a4cd4a752e245e", + "3f28cc2972ec801e", + "b8576a74c9e3cc75", + "0f7838df86c0daa7", + "75602bbc0592e19f", + "0fc524aa3713e49b", + "3b087174de36c2d9", + "2c04e52c4cba3c98", + "df02d3cd352aff6f", + "693f1f1fcfc09699", + "9cc523b662f53ded", + "c6894593daa8fcf0", + "d66163bb05e6f12e", + "004948a143b907dd", + "bb5ad864c986b15f", + "8081ba55b8146814", + "23d65be42ea9f363", + "95b1dd4f471bf039", + "2d79b1d9949e3dd0", + "2acf20aca58388d4", + "ea53485fdadb8112", + "dea96ba82c481e46" + ], + "x": 14, + "y": 239, + "w": 1252, + "h": 462 + }, + { + "id": "88cb3b1f39d6754c", + "type": "group", + "z": "1a4b40705122dc91", + "name": "Uso de Cartociudad", + "style": { + "stroke": "#000000", + "fill": "#bfdbef", + "label": true, + "label-position": "n", + "color": "#000000" + }, + "nodes": [ + "4250b98e85f30aa3", + "4af6fd0defd481ea", + "c29fc5be5de649c4", + "4644d386e752575d", + "5e1954f3ba4bce4b", + "7b7214ea354e3b74", + "664bb290fa751036", + "ae75d79916e0a333", + "d1035ff8c39cd84c" + ], + "x": 14, + "y": 719, + "w": 1062, + "h": 182 + }, + { + "id": "6d889597e60bf596", + "type": "group", + "z": "6e1ee0f06e75580d", + "name": "Parte visual y manual", + "style": { + "stroke": "#000000", + "fill": "#dbcbe7", + "label": true, + "label-position": "n", + "color": "#000000" + }, + "nodes": [ + "99e57e3e0c9feda3", + "c91b4ba4c01b3d11", + "374eb1d0ce2a0c27", + "843fbe4881603a6c", + "dc1aec7696d95a97", + "faacde234e5acc0e", + "abccb8a853c9f234", + "426c5e09624cff47", + "5af76acc28d81750", + "0d6f32bdc24ffd32", + "9036e7960a287e16", + "2561ac2b1923a696", + "13d7d425e81f0131", + "3105cb58919fe886", + "7434c61d8243add8", + "0d774be337e70e35", + "1614e3503117cf11", + "2ef3fe5fe0abdfb5", + "c800da6f27161aeb", + "76d0610e0cf4a848", + "13a8bf685ef1303b", + "5a4e60652aab552c", + "a97aaad7209e3953", + "2e1a6699fd10a0d0", + "3d08fca02fbfdc13", + "a403b6e0d3b62351", + "2bb29b85114ff2c3", + "eae675ed8219e086", + "bc7269f08c168a0b", + "5c95290ed28a98cc", + "1dfe62e8c32543ee", + "3dbbc9b098e37e96", + "71e6a918e85cbd07", + "ee0c6a9d7d1aa05c", + "2b215b7870143e56", + "f8a18d468d34e722", + "8c63476ce9eb94ea", + "e6c3dc27360afac1", + "383a4d93dbc6cf7e", + "19765558436e83d7", + "1799f293511ddb1e", + "bdad16849cfd6e20", + "94ebcb167b5c4a7d", + "d82fe4f6536306f7", + "897720eb56636e2d", + "da84256af9053a56", + "de380c0ed70e4d7a", + "d4f93dfa22423d32", + "8d13b3eb6e30802a", + "2ddb1cf2b28f0f2e", + "9cd726efb2695f64" + ], + "x": 54, + "y": 959, + "w": 1732, + "h": 882 + }, + { + "id": "586a685b7e78517c", + "type": "group", + "z": "6e1ee0f06e75580d", + "name": "Parte Automática y cacheada", + "style": { + "stroke": "#000000", + "fill": "#bfc7d7", + "label": true, + "label-position": "n", + "color": "#000000" + }, + "nodes": [ + "a66d44720bfed89d", + "3bb66c22727588c3", + "88517c37afc36dd8", + "022364dc0148870e", + "65d4baca6edf0fbd", + "c106948998237652", + "45144d8953fb168a", + "d4531a5b62fccd5a", + "c6d1ee72149ef4da", + "ff1fa52c7fb6436d", + "f04f31bb7e647ab7", + "2142cf292ba4dece", + "1be09b79f432c626", + "a5cf9bb1543ccbdf", + "fe421b6180fe2f15", + "f98d50aac4fce670", + "385b936f30611065", + "841cb88a7b666a63", + "a23bb95e94319218", + "041c57934c647e2c", + "fd8b53ea98c67e93", + "4d69a180d5f58f10", + "d6db349d1646634d", + "007603e6138d3767", + "1eb4a654a71a42b1", + "ea87880ca13d9dcb", + "6c45fdd52d5b4bd3", + "98b02584803dbcbb", + "3f24b62573b3963b", + "78c4804a3d71aca2", + "ac3e7005ee6ca8b4", + "c3ce306882f3d6ab", + "08ef481b73ada20e", + "27fbbc6c04034efc", + "9c7e15d6d339c983", + "819f4993eed99959", + "711cd5bb325a7107", + "530155acd87e9af4", + "f7f14145281f4584", + "c14692403d35c94d", + "f7070a1689337f95" + ], + "x": 54, + "y": 19, + "w": 1612, + "h": 922 + }, + { + "id": "d31dc5ca65fdaec9", + "type": "group", + "z": "e3a070490bfdc383", + "name": "Preparación de la base de datos", + "style": { + "stroke": "#000000", + "fill": "#ffffbf", + "label": true, + "label-position": "n", + "color": "#000000" + }, + "nodes": [ + "acae736839e9942c", + "5d7ccd027be25185", + "73ca61629ca36cdb", + "bf5deb0295df1e6d", + "67d9948a4ea561d0", + "9a2c00a3d18bf2e5", + "ead3b611059e050e", + "e2c241981eb9d22d", + "6a8444fa71237276", + "5f0c5f162625d887", + "8873bca38bac80d8", + "ef69861ea0631cf5" + ], + "x": 54, + "y": 19, + "w": 852, + "h": 262 + }, + { + "id": "4de20a7676e67ad3", + "type": "group", + "z": "e3a070490bfdc383", + "name": "Migración de mongo a postgis con geoposición", + "style": { + "stroke": "#000000", + "fill": "#ffbfbf", + "label": true, + "label-position": "n", + "color": "#000000" + }, + "nodes": [ + "a5da07eb95be391c", + "e6f2786536d9be1b", + "2f3bd996544abba2", + "476541d607d59b6d", + "3004fd9c1a92c8e1", + "87a50279e182879c", + "038afe42a8815a88", + "7762d2d91d6e863e", + "a10c4585f88c77cd", + "b2e8c6b462cf2f7d", + "7fb03d67431947cc", + "18055db6bd0e0c9e", + "4aa92b63a45c740c", + "182765735c8a1a54" + ], + "x": 54, + "y": 299, + "w": 892, + "h": 322 + }, + { + "id": "7bdac83e314d285e", + "type": "group", + "z": "e3a070490bfdc383", + "name": "Consultas bbdd postgis", + "style": { + "stroke": "#000000", + "fill": "#bfdbef", + "label": true, + "label-position": "n", + "color": "#000000" + }, + "nodes": [ + "9253b85aa1fceedf", + "c6996972638e189e", + "b76b66ac4b8871d6", + "10f31f95a520c2c2", + "95219fda1586a59b" + ], + "x": 54, + "y": 639, + "w": 872, + "h": 142 + }, { "id": "db09bd514ed7c061", "type": "MSSQL-CN", @@ -159,7 +447,7 @@ { "id": "d5367e576f526ae9", "type": "ui-page", - "name": "Page 1", + "name": "Gestor manual de posicionamiento", "ui": "15fe39abe7f560b2", "path": "/page1", "icon": "home", @@ -168,23 +456,23 @@ "breakpoints": [ { "name": "Default", - "px": 0, - "cols": 3 + "px": "0", + "cols": "3" }, { "name": "Tablet", - "px": 576, - "cols": 6 + "px": "576", + "cols": "6" }, { "name": "Small Desktop", - "px": 768, - "cols": 9 + "px": "768", + "cols": "9" }, { "name": "Desktop", - "px": 1024, - "cols": 12 + "px": "1024", + "cols": "12" } ], "order": 1, @@ -195,15 +483,15 @@ { "id": "2365cb156242b3e6", "type": "ui-group", - "name": "Group 1", + "name": "Renombrar", "page": "d5367e576f526ae9", "width": 6, "height": 1, "order": 2, "showTitle": true, "className": "", - "visible": true, - "disabled": false, + "visible": "true", + "disabled": "false", "groupType": "default" }, { @@ -270,27 +558,6 @@ ] ] }, - { - "id": "d647c9286ddb06ce", - "type": "function", - "z": "1a4b40705122dc91", - "name": "Primer filtrado de valores y guarda en disco", - "func": "const servicios_fecha = \"servicios_\" + msg.payload;\nflow.set(servicios_fecha, msg.result, \"file\");\nreturn msg;", - "outputs": 1, - "timeout": 0, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 430, - "y": 1000, - "wires": [ - [ - "535b18bcfc71f9cd" - ] - ], - "info": "Sin limitación - 33095\r\nPosicion no nula - 31943" - }, { "id": "40b5904a3022e5eb", "type": "function", @@ -342,125 +609,6 @@ ] ] }, - { - "id": "101adc2199c9c4ef", - "type": "function", - "z": "1a4b40705122dc91", - "name": "Filtrado", - "func": "// Filtrar el array para eliminar elementos donde Calle2 sea \"SIN DETERMINAR\"\nif (Array.isArray(msg.result)) {\n msg.result = msg.result.filter(item => item.Calle2 !== \"SIN DETERMINAR\"\n && item.Calle2 !== \"SIN CALLE\"\n && item.Calle2 !== \"MEDIODIA 2\"\n && item.Calle2 !== \"COMISARIA SAN BLAS - VICALVARO\"\n && item.Calle2 !== \"PASEO IMPERIAL\"\n && item.Calle2 !== \"No Codificada\"\n && item.Calle2 !== \"COMISARIA HORTALEZA\"\n && item.Calle2 !== \"CENTRO\"\n && item.Calle2 !== \"MEDIODIA 3\"\n && item.Calle2 !== \"MEDIODIA 3\"\n && item.Calle2 !== \"COLON\"\n && item.Calle2 !== \"BARCELO\"\n && item.Calle2 !== \"EL RECUERDO\"\n && item.Calle2 !== null);\n} else {\n // Si no es un array, mantener el result original\n node.warn(\"El result no es un array, no se puede filtrar\");\n}\n\nreturn msg;", - "outputs": 1, - "timeout": 0, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 160, - "y": 1000, - "wires": [ - [ - "d647c9286ddb06ce" - ] - ] - }, - { - "id": "9a78cfa134973f38", - "type": "inject", - "z": "1a4b40705122dc91", - "name": "Recuperamos Servicios", - "props": [ - { - "p": "payload" - } - ], - "repeat": "", - "crontab": "", - "once": false, - "onceDelay": 0.1, - "topic": "", - "payload": "", - "payloadType": "date", - "x": 200, - "y": 1060, - "wires": [ - [ - "a5d5ef751185e3e9" - ] - ] - }, - { - "id": "3acef3e43d0415d4", - "type": "function", - "z": "1a4b40705122dc91", - "name": "Recuperar servicios y calcular número por año", - "func": "// Recuperar en contexto persistente\nconst servicios_fecha = \"servicios_\" + msg.payload;\nmsg.servicios = flow.get(servicios_fecha, \"file\");\nmsg.resultado = {}\nmsg.resultado.fecha = msg.payload\nmsg.resultado.servicios = msg.servicios.length;\n\nreturn msg", - "outputs": 1, - "timeout": 0, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 300, - "y": 1120, - "wires": [ - [ - "495d54abe840ccc9" - ] - ] - }, - { - "id": "a5d5ef751185e3e9", - "type": "function", - "z": "1a4b40705122dc91", - "name": "2005 - 2025", - "func": "const start = 2005;\nconst end = 2025;\n\nfor (let year = start; year <= end; year++) {\n setTimeout(() => {\n node.send({ payload: year });\n }, (year - start) * 2000);\n};\n\n// No devolvemos msg porque los mensajes ya se envían con setTimeout\nreturn null;", - "outputs": 1, - "timeout": 0, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 390, - "y": 1060, - "wires": [ - [ - "3acef3e43d0415d4" - ] - ] - }, - { - "id": "495d54abe840ccc9", - "type": "debug", - "z": "1a4b40705122dc91", - "name": "Primer cálculo de valores", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "resultado", - "targetType": "msg", - "statusVal": "", - "statusType": "auto", - "x": 610, - "y": 1120, - "wires": [] - }, - { - "id": "535b18bcfc71f9cd", - "type": "debug", - "z": "1a4b40705122dc91", - "name": "debug 3", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "payload", - "targetType": "msg", - "statusVal": "", - "statusType": "auto", - "x": 680, - "y": 1000, - "wires": [] - }, { "id": "2a46f606e21ec6b3", "type": "debug", @@ -521,26 +669,11 @@ ] ] }, - { - "id": "acae736839e9942c", - "type": "postgresql", - "z": "1a4b40705122dc91", - "name": "", - "query": "SELECT * FROM ;", - "postgreSQLConfig": "748b5921246ec468", - "split": false, - "rowsPerMsg": 1, - "outputs": 1, - "x": 770, - "y": 1060, - "wires": [ - [] - ] - }, { "id": "683191909606de5f", "type": "inject", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "name": "Activación - Consulta valores sin geoposición", "props": [ { @@ -570,6 +703,7 @@ "id": "c8a4cd4a752e245e", "type": "mongodb4", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", @@ -590,6 +724,7 @@ "id": "3f28cc2972ec801e", "type": "debug", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "name": "Resultado", "active": true, "tosidebar": true, @@ -607,6 +742,7 @@ "id": "b8576a74c9e3cc75", "type": "function", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "name": "Prepación de la Consulta", "func": "// aggregation pipeline\nconst pipeline = [{\"$group\": {\n \"_id\": { \"year\": { \"$year\": \"$fecha_servicio\" } },\n \"totalRegistros\": { \"$sum\": 1 },\n \"latitudNoNull\": {\n \"$sum\": {\n \"$cond\": [{ \"$ne\": [\"$latitud\", null] }, 1, 0]\n }\n },\n \"longitudNoNull\": {\n \"$sum\": {\n \"$cond\": [{ \"$ne\": [\"$longitud\", null] }, 1, 0]\n }\n }\n }},\n {\n \"$sort\": { \"_id.year\": 1 }\n }];\n// optional: aggregate options\nconst options = {\n allowDiskUse: true\n};\n// payload for mongodb4 node\nmsg.collection = \"servicios_sin_filtrar\";\nmsg.operation = \"aggregate\";\nmsg.payload = [pipeline, options];\nreturn msg;", "outputs": 1, @@ -627,6 +763,7 @@ "id": "0f7838df86c0daa7", "type": "inject", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "name": "Activación - Consolidación calles (Coalescing)", "props": [ { @@ -656,6 +793,7 @@ "id": "75602bbc0592e19f", "type": "function", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "name": "Prepación de la Consulta", "func": "// aggregation pipeline\nconst pipeline = [\n {\n $addFields: {\n TipoVia: { $ifNull: [\"$TipoVia1\", { $ifNull: [\"$TipoVia2\", \"CALLE\"] }] },\n Calle: { $ifNull: [\"$Calle1\", { $ifNull: [\"$Calle2\", \"SIN DATOS\"] }] },\n Poblacion: { $ifNull: [\"$Poblacion1\", { $ifNull: [\"$Poblacion2\", \"MADRID\"] }] },\n CP: { $ifNull: [\"$cp1\", { $ifNull: [\"$cp2\", \"00000\"] }] }\n }\n },\n {\n $project: {\n TipoVia1: 0,\n TipoVia2: 0,\n Calle1: 0,\n Calle2: 0,\n Poblacion1: 0,\n Poblacion2: 0,\n cp1: 0,\n cp2: 0\n }\n },\n {\n $out: \"servicios_consolidado_calle\" // guarda el resultado en otra colección\n }\n ];\n// optional: aggregate options\nconst options = {\n allowDiskUse: true\n};\n// payload for mongodb4 node\nmsg.collection = \"servicios_sin_filtrar\";\nmsg.operation = \"aggregate\";\nmsg.payload = [pipeline, options];\nreturn msg;", "outputs": 1, @@ -676,6 +814,7 @@ "id": "0fc524aa3713e49b", "type": "mongodb4", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", @@ -696,6 +835,7 @@ "id": "3b087174de36c2d9", "type": "debug", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "name": "Resultado", "active": true, "tosidebar": true, @@ -713,6 +853,7 @@ "id": "2c04e52c4cba3c98", "type": "inject", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "name": "Activación - Eliminar servicios sin calle", "props": [ { @@ -742,6 +883,7 @@ "id": "df02d3cd352aff6f", "type": "function", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "name": "Prepación de la Consulta", "func": "// aggregation pipeline\nconst pipeline = [\n {\n $match: {\n $and: [\n { $expr: { $ne: [\"$Calle\", \"SIN DATOS\"] } },\n ]\n }\n },\n {\n $out: \"servicios_consolidado_calle_filtrado\" // guarda el resultado en otra colección\n }\n ];\n// optional: aggregate options\nconst options = {\n allowDiskUse: true\n};\n// payload for mongodb4 node\nmsg.collection = \"servicios_consolidado_calle\";\nmsg.operation = \"aggregate\";\nmsg.payload = [pipeline, options];\nreturn msg;", "outputs": 1, @@ -762,6 +904,7 @@ "id": "693f1f1fcfc09699", "type": "mongodb4", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", @@ -782,6 +925,7 @@ "id": "9cc523b662f53ded", "type": "debug", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "name": "Resultado", "active": true, "tosidebar": true, @@ -799,6 +943,7 @@ "id": "4250b98e85f30aa3", "type": "change", "z": "1a4b40705122dc91", + "g": "88cb3b1f39d6754c", "name": "Preparación de la Consulta", "rules": [ { @@ -835,8 +980,8 @@ "from": "", "to": "", "reg": false, - "x": 620, - "y": 700, + "x": 720, + "y": 860, "wires": [ [ "4af6fd0defd481ea" @@ -847,6 +992,7 @@ "id": "4af6fd0defd481ea", "type": "mongodb4", "z": "1a4b40705122dc91", + "g": "88cb3b1f39d6754c", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", @@ -855,35 +1001,19 @@ "maxTimeMS": "0", "handleDocId": false, "name": "", - "x": 830, - "y": 700, + "x": 930, + "y": 860, "wires": [ [ "4644d386e752575d" ] ] }, - { - "id": "b8fbe1c9e468142d", - "type": "debug", - "z": "1a4b40705122dc91", - "name": "Resultado", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 840, - "y": 1000, - "wires": [] - }, { "id": "c29fc5be5de649c4", "type": "inject", "z": "1a4b40705122dc91", + "g": "88cb3b1f39d6754c", "name": "Activación - Recuperar geoposiciones de CartoCiudad", "props": [ { @@ -902,7 +1032,7 @@ "payload": "", "payloadType": "date", "x": 260, - "y": 700, + "y": 860, "wires": [ [ "4250b98e85f30aa3" @@ -913,19 +1043,21 @@ "id": "4644d386e752575d", "type": "link out", "z": "1a4b40705122dc91", + "g": "88cb3b1f39d6754c", "name": "link out 1", "mode": "link", "links": [ "ec0a560685f299d8" ], - "x": 935, - "y": 700, + "x": 1035, + "y": 860, "wires": [] }, { "id": "c6894593daa8fcf0", "type": "inject", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "name": "Activación - Normalizaciones", "props": [ { @@ -956,6 +1088,7 @@ "id": "d66163bb05e6f12e", "type": "change", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "name": "numero_retirada de \"SN \" a \"SN\"", "rules": [ { @@ -997,6 +1130,7 @@ "id": "004948a143b907dd", "type": "mongodb4", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", @@ -1017,6 +1151,7 @@ "id": "bb5ad864c986b15f", "type": "debug", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "name": "Resultado (4 cambios)", "active": true, "tosidebar": true, @@ -1034,6 +1169,7 @@ "id": "8081ba55b8146814", "type": "change", "z": "1a4b40705122dc91", + "g": "eefff18186897436", "name": "numero_retirada de \"SQ\" a \"SN\"", "rules": [ { @@ -1075,16 +1211,16 @@ "id": "5e1954f3ba4bce4b", "type": "link in", "z": "1a4b40705122dc91", + "g": "88cb3b1f39d6754c", "name": "link in 3", "links": [ - "0c8361e1ffd8995c", "3105cb58919fe886" ], - "x": 445, - "y": 660, + "x": 565, + "y": 760, "wires": [ [ - "4250b98e85f30aa3" + "664bb290fa751036" ] ] }, @@ -1092,6 +1228,7 @@ "id": "7b7214ea354e3b74", "type": "inject", "z": "1a4b40705122dc91", + "g": "88cb3b1f39d6754c", "name": "Activación - Recuperar geoposiciones de CartoCiudad tratamiento rapido", "props": [ { @@ -1121,6 +1258,7 @@ "id": "664bb290fa751036", "type": "change", "z": "1a4b40705122dc91", + "g": "88cb3b1f39d6754c", "name": "Preparación de la Consulta", "rules": [ { @@ -1141,7 +1279,7 @@ "t": "set", "p": "limit", "pt": "msg", - "to": "1", + "to": "10", "tot": "num" }, { @@ -1169,6 +1307,7 @@ "id": "ae75d79916e0a333", "type": "mongodb4", "z": "1a4b40705122dc91", + "g": "88cb3b1f39d6754c", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", @@ -1189,6 +1328,7 @@ "id": "d1035ff8c39cd84c", "type": "link out", "z": "1a4b40705122dc91", + "g": "88cb3b1f39d6754c", "name": "Limpieza Rápida", "mode": "link", "links": [ @@ -1199,89 +1339,290 @@ "wires": [] }, { - "id": "1fd044cbc45e1620", - "type": "function", - "z": "a796bfad8ab76fe4", - "name": "Generamos la consulta a Cartociudad", - "func": "// msg.payload debe contener la dirección, ej. \"Calle Gran Vía 28, Madrid\"\nconst direccion = msg.consulta_calle;\nconst encoded = encodeURIComponent(direccion);\n\nmsg.original = msg.payload\n// API de CartoCiudad (gratuita España)\nmsg.method = \"GET\";\nmsg.url = `https://www.cartociudad.es/geocoder/api/geocoder/findJsonp?q=${encoded}`;\nreturn msg;\n", - "outputs": 1, - "timeout": 0, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 590, - "y": 860, + "id": "23d65be42ea9f363", + "type": "change", + "z": "1a4b40705122dc91", + "g": "eefff18186897436", + "name": "Eliminamos los TipoServicios que no vamos a tratar - Servicios varios", + "rules": [ + { + "t": "set", + "p": "operation", + "pt": "msg", + "to": "deleteMany", + "tot": "str" + }, + { + "t": "set", + "p": "collection", + "pt": "msg", + "to": "servicios_consolidado_calle_filtrado", + "tot": "str" + }, + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "[\t {\t \"TipoServicio\": \"Servicios varios\" \t }\t]", + "tot": "jsonata" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 610, + "y": 580, "wires": [ [ - "c58559633003fc35" + "95b1dd4f471bf039" ] ] }, { - "id": "c58559633003fc35", - "type": "http request", - "z": "a796bfad8ab76fe4", + "id": "95b1dd4f471bf039", + "type": "mongodb4", + "z": "1a4b40705122dc91", + "g": "eefff18186897436", + "clientNode": "648a51546e4dadc6", + "mode": "collection", + "collection": "", + "operation": "", + "output": "toArray", + "maxTimeMS": "0", + "handleDocId": false, "name": "", - "method": "use", - "ret": "txt", - "paytoqs": "ignore", - "url": "", - "tls": "", - "persist": false, - "proxy": "", - "insecureHTTPParser": false, - "authType": "", - "senderr": false, - "headers": [], - "x": 830, - "y": 860, + "x": 990, + "y": 620, "wires": [ [ - "c2879b84c754c37d" + "2d79b1d9949e3dd0" ] ] }, { - "id": "c2879b84c754c37d", - "type": "function", - "z": "a796bfad8ab76fe4", - "name": "Filtramos el resultado", - "func": "// Limpia la respuesta JSONP (callback(...))\nlet text = msg.payload.trim();\n\n// Detecta y elimina el formato \"callback(...)\" o \"callback123(...)\" u otros\ntext = text.replace(/^[a-zA-Z0-9_]+\\(/, '').replace(/\\);?$/, '');\n\nlet data;\ntry {\n data = JSON.parse(text);\n} catch (e) {\n node.error(\"Error al parsear JSON de CartoCiudad: \" + e.message);\n msg.payload = { error: \"Formato no válido de respuesta CartoCiudad\" };\n return msg;\n}\n\n// La API devuelve un solo objeto, no un array\nif (data && data.lat && data.lng) {\n msg.payload = {\n lat: data.lat,\n lon: data.lng,\n address: data.address || \"\",\n postalCode: data.postalCode || \"\",\n muni: data.muni || \"\",\n province: data.province || \"\",\n source: \"CartoCiudad\",\n raw: data\n };\n} else {\n msg.payload = { error: \"No se encontraron coordenadas en CartoCiudad\" };\n}\nreturn msg;\n", - "outputs": 1, - "timeout": 0, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 1020, - "y": 860, + "id": "2d79b1d9949e3dd0", + "type": "debug", + "z": "1a4b40705122dc91", + "g": "eefff18186897436", + "name": "BORRADOS", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "statusVal": "", + "statusType": "auto", + "x": 1150, + "y": 620, + "wires": [] + }, + { + "id": "2acf20aca58388d4", + "type": "change", + "z": "1a4b40705122dc91", + "g": "eefff18186897436", + "name": "Eliminamos los TipoServicios que no vamos a tratar - Traslado", + "rules": [ + { + "t": "set", + "p": "operation", + "pt": "msg", + "to": "deleteMany", + "tot": "str" + }, + { + "t": "set", + "p": "collection", + "pt": "msg", + "to": "servicios_consolidado_calle_filtrado", + "tot": "str" + }, + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "[\t {\t \"TipoServicio\": \"Traslado\" \t }\t]", + "tot": "jsonata" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 590, + "y": 620, "wires": [ [ - "3a02a4797e73bfe2" + "95b1dd4f471bf039" ] ] }, { - "id": "ec0a560685f299d8", + "id": "ea53485fdadb8112", + "type": "change", + "z": "1a4b40705122dc91", + "g": "eefff18186897436", + "name": "Eliminamos los TipoServicios que no vamos a tratar - Traslado Voluntario", + "rules": [ + { + "t": "set", + "p": "operation", + "pt": "msg", + "to": "deleteMany", + "tot": "str" + }, + { + "t": "set", + "p": "collection", + "pt": "msg", + "to": "servicios_consolidado_calle_filtrado", + "tot": "str" + }, + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "[\t {\t \"TipoServicio\": \"Traslado Voluntario\" \t }\t]", + "tot": "jsonata" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 620, + "y": 660, + "wires": [ + [ + "95b1dd4f471bf039" + ] + ] + }, + { + "id": "dea96ba82c481e46", + "type": "inject", + "z": "1a4b40705122dc91", + "g": "eefff18186897436", + "name": "Activación - Borrados", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 160, + "y": 580, + "wires": [ + [ + "23d65be42ea9f363", + "2acf20aca58388d4", + "ea53485fdadb8112" + ] + ] + }, + { + "id": "a66d44720bfed89d", "type": "link in", - "z": "a796bfad8ab76fe4", - "name": "link in 1", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Entrada Cartociudad 2", "links": [ - "4644d386e752575d" + "d1035ff8c39cd84c" ], "x": 165, - "y": 20, + "y": 60, "wires": [ [ - "5621fbd41709d68e" + "88517c37afc36dd8" ] ] }, { - "id": "1c10577fa4beb771", + "id": "3bb66c22727588c3", + "type": "switch", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Accion que se hace según la consulta", + "property": "payload[0].accion", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "validado", + "vt": "str" + }, + { + "t": "eq", + "v": "renombrar", + "vt": "str" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 3, + "x": 550, + "y": 520, + "wires": [ + [ + "a23bb95e94319218" + ], + [ + "c14692403d35c94d" + ], + [ + "fd8b53ea98c67e93" + ] + ], + "outputLabels": [ + "Se actuliza el valor de la calle", + "", + "Se estudia" + ] + }, + { + "id": "88517c37afc36dd8", + "type": "split", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "", + "splt": "\\n", + "spltType": "str", + "arraySplt": 1, + "arraySpltType": "len", + "stream": false, + "addname": "", + "property": "payload", + "x": 250, + "y": 60, + "wires": [ + [ + "022364dc0148870e" + ] + ] + }, + { + "id": "022364dc0148870e", "type": "delay", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", "name": "", "pauseType": "rate", "timeout": "5", @@ -1296,37 +1637,18 @@ "allowrate": false, "outputs": 1, "x": 400, - "y": 20, + "y": 60, "wires": [ [ - "d3881558e6fef33f" + "65d4baca6edf0fbd" ] ] }, { - "id": "5621fbd41709d68e", - "type": "split", - "z": "a796bfad8ab76fe4", - "name": "", - "splt": "\\n", - "spltType": "str", - "arraySplt": 1, - "arraySpltType": "len", - "stream": false, - "addname": "", - "property": "payload", - "x": 250, - "y": 20, - "wires": [ - [ - "1c10577fa4beb771" - ] - ] - }, - { - "id": "d3881558e6fef33f", + "id": "65d4baca6edf0fbd", "type": "change", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", "name": "Generamos referencia_geocache y consulta_calle", "rules": [ { @@ -1349,18 +1671,47 @@ "from": "", "to": "", "reg": false, - "x": 390, - "y": 80, + "x": 450, + "y": 120, "wires": [ [ - "065d8956ac11a589" + "c106948998237652" ] ] }, { - "id": "3112772543b09bd9", + "id": "c106948998237652", "type": "change", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Copiamos la dirección en dirección para consultas posteriores", + "rules": [ + { + "t": "set", + "p": "direccion", + "pt": "msg", + "to": "payload", + "tot": "msg" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 490, + "y": 160, + "wires": [ + [ + "45144d8953fb168a" + ] + ] + }, + { + "id": "45144d8953fb168a", + "type": "change", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", "name": "Creamos la consulta de referencia_geocache", "rules": [ { @@ -1390,18 +1741,19 @@ "from": "", "to": "", "reg": false, - "x": 370, - "y": 160, + "x": 430, + "y": 200, "wires": [ [ - "67310a0b495f77a2" + "d4531a5b62fccd5a" ] ] }, { - "id": "67310a0b495f77a2", + "id": "d4531a5b62fccd5a", "type": "mongodb4", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", @@ -1410,18 +1762,19 @@ "maxTimeMS": "0", "handleDocId": false, "name": "", - "x": 630, - "y": 160, + "x": 690, + "y": 200, "wires": [ [ - "304f30478bb9e954" + "c6d1ee72149ef4da" ] ] }, { - "id": "304f30478bb9e954", + "id": "c6d1ee72149ef4da", "type": "switch", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", "name": "Existe la calle en el cache?", "property": "$count(payload)", "propertyType": "jsonata", @@ -1438,14 +1791,14 @@ "checkall": "true", "repair": false, "outputs": 2, - "x": 840, - "y": 160, + "x": 200, + "y": 260, "wires": [ [ - "039fe8c413696211" + "fe421b6180fe2f15" ], [ - "ea5fca57029b791a" + "f04f31bb7e647ab7" ] ], "outputLabels": [ @@ -1454,65 +1807,134 @@ ] }, { - "id": "3a02a4797e73bfe2", - "type": "switch", - "z": "a796bfad8ab76fe4", - "name": "Existen datos?", - "property": "payload.lat", - "propertyType": "msg", - "rules": [ - { - "t": "istype", - "v": "undefined", - "vt": "undefined" - }, - { - "t": "else" - } - ], - "checkall": "true", - "repair": false, - "outputs": 2, - "x": 1220, - "y": 860, - "wires": [ - [ - "b5d1699d2f623f08" - ], - [ - "5d8fed0824f5d590" - ] - ], - "outputLabels": [ - "NO", - "SI" - ] + "id": "ff1fa52c7fb6436d", + "type": "comment", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Si existe la referencia se actualiza", + "info": "", + "x": 500, + "y": 260, + "wires": [] }, { - "id": "2c1d536a860b099e", + "id": "f04f31bb7e647ab7", "type": "change", - "z": "a796bfad8ab76fe4", - "name": "Guardamos lo datos de la referencia de cache en mongo", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Actualizamos los datos de todas las calles que sean iguales", "rules": [ { "t": "set", "p": "operation", "pt": "msg", - "to": "insertOne", + "to": "updateMany", "tot": "str" }, { "t": "set", "p": "collection", "pt": "msg", - "to": "geocache", + "to": "servicios_consolidado_calle_filtrado", "tot": "str" }, { "t": "set", "p": "payload", "pt": "msg", - "to": "{\t \"referencia_geocache\": referencia_geocache,\t \"lat\": actualizar.lat,\t \"lon\": actualizar.lon,\t \"address\": actualizar.address,\t \"muni\": actualizar.muni,\t \"province\": actualizar.province,\t \"accion\" : \"validado\"\t}", + "to": "[\t {\t \"TipoVia\": direccion.TipoVia,\t \"Calle\": direccion.Calle\t },\t {\t \"$set\": {\t \"latitud\": payload[0].lat,\t \"longitud\": payload[0].lon,\t \"geocodingProcesado\": true\t } \t }\t]", + "tot": "jsonata" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 580, + "y": 300, + "wires": [ + [ + "2142cf292ba4dece" + ] + ] + }, + { + "id": "2142cf292ba4dece", + "type": "mongodb4", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "clientNode": "648a51546e4dadc6", + "mode": "collection", + "collection": "", + "operation": "", + "output": "toArray", + "maxTimeMS": "0", + "handleDocId": false, + "name": "", + "x": 890, + "y": 300, + "wires": [ + [ + "1be09b79f432c626" + ] + ] + }, + { + "id": "1be09b79f432c626", + "type": "debug", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "CACHE", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "statusVal": "", + "statusType": "auto", + "x": 1040, + "y": 300, + "wires": [] + }, + { + "id": "a5cf9bb1543ccbdf", + "type": "comment", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "No existe la referencia", + "info": "", + "x": 460, + "y": 340, + "wires": [] + }, + { + "id": "fe421b6180fe2f15", + "type": "change", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Buscarmos la calle en la base de datos de consulta_calle", + "rules": [ + { + "t": "set", + "p": "operation", + "pt": "msg", + "to": "find", + "tot": "str" + }, + { + "t": "set", + "p": "collection", + "pt": "msg", + "to": "consulta_calle", + "tot": "str" + }, + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "[{ \"consulta_calle\": { \"$eq\": msg.consulta_calle }}]", "tot": "jsonata" } ], @@ -1522,17 +1944,18 @@ "to": "", "reg": false, "x": 570, - "y": 1380, + "y": 380, "wires": [ [ - "aa8980407983e089" + "f98d50aac4fce670" ] ] }, { - "id": "aa8980407983e089", + "id": "f98d50aac4fce670", "type": "mongodb4", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", @@ -1541,38 +1964,66 @@ "maxTimeMS": "0", "handleDocId": false, "name": "", - "x": 890, - "y": 1380, + "x": 870, + "y": 380, "wires": [ [ - "22e91d97b48287ac" + "385b936f30611065" ] ] }, { - "id": "a37d6875203d3cef", - "type": "mongodb4", - "z": "a796bfad8ab76fe4", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 890, - "y": 1440, + "id": "385b936f30611065", + "type": "switch", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Existe la calle en consulta_calle?", + "property": "$count(payload)", + "propertyType": "jsonata", + "rules": [ + { + "t": "eq", + "v": "0", + "vt": "num" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 220, + "y": 480, "wires": [ [ - "183f81d1ad8abb3f" + "d6db349d1646634d" + ], + [ + "3bb66c22727588c3" ] + ], + "outputLabels": [ + "NO", + "SI" ] }, { - "id": "ee3b382fec9125f9", + "id": "841cb88a7b666a63", + "type": "comment", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Si existe la calle", + "info": "", + "x": 480, + "y": 460, + "wires": [] + }, + { + "id": "a23bb95e94319218", "type": "change", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", "name": "Actualizamos los datos de todas las calles que sean iguales", "rules": [ { @@ -1602,37 +2053,20 @@ "from": "", "to": "", "reg": false, - "x": 580, - "y": 1440, + "x": 960, + "y": 480, "wires": [ [ - "a37d6875203d3cef" + "041c57934c647e2c" ] ] }, { - "id": "92e5a359bb49899f", - "type": "function", - "z": "a796bfad8ab76fe4", - "name": "Calles con Memoria Histórica", - "func": "// Referencia : https://www.elmundo.es/madrid/2016/07/21/5791123146163fd3028b45a3.html\n\nmsg.cambio = msg.cambio || {};\n\n// Internet\nif (msg.consulta_calle === \"CALLE JOSE LUIS DE ARRESE MADRID\") {\n msg.cambio.calle = \"POETA BLAS DE OTERO\";\n return msg;\n}\n// 12\nif (msg.consulta_calle === \"CALLE CAPITAN CORTES MADRID\") {\n msg.cambio.calle = \"MANUEL CHAVES NOGALES\";\n return msg;\n}\n\n// \nif (msg.consulta_calle === \"CALLE GENERAL ROMERO BASART 27 MADRID\") {\n msg.cambio.calle = \"BLAS CABRERA\";\n return msg;\n}\n\nif (msg.consulta_calle === \"CALLE GENERAL ORGAZ 1 MADRID\") {\n msg.cambio.calle = \"FORTUNATA Y JACINTA\";\n return msg;\n}\n\nif (msg.consulta_calle === \"CALLE GENERAL SALIQUET MADRID\") {\n msg.cambio.calle = \"SOLEDAD CAZORLA\";\n return msg;\n}\n\nif (msg.consulta_calle === \"CALLE COMANDANTE ZORITA 2 MADRID\") {\n msg.cambio.calle = \"AVIADOR ZORITA\";\n return msg;\n}\n\nif (msg.consulta_calle === \"PLAZA FERNANDEZ LADREDA 2 MADRID\") {\n msg.cambio.calle = \"ELIPTICA\";\n return msg;\n}\n\nif (msg.consulta_calle === \"PLAZA FERNANDEZ LADREDA MADRID\") {\n msg.cambio.calle = \"ELIPTICA\";\n return msg;\n}\n\nif (msg.consulta_calle === \"GLORIETA PATINES MADRID\") {\n msg.cambio.calle = \"DE LOS NEVEROS\";\n return msg;\n}\n\nif (msg.consulta_calle === \"PLAZA HERMANOS FALCO Y ALVAREZ DE TOLEDO 13 MADRID\") {\n msg.cambio.calle = \"MAYOR DE BARAJAS\";\n return msg;\n}\n\nif (msg.consulta_calle === \"CALLE CAPITAN CORTES MADRID\") {\n msg.cambio.calle = \"MANUEL CHAVES NOGALES\";\n return msg;\n}\n\nif (msg.consulta_calle === \"CALLE GENERAL SALIQUET MADRID\") {\n msg.cambio.calle = \"SOLEDAD CAZORLA\";\n return msg;\n}\n\nif (msg.consulta_calle === \"PLAZA HERMANOS FALCO Y ALVAREZ DE TOLEDO 13 MADRID\") {\n msg.cambio.calle = \"MAYOR DE BARAJAS\";\n return msg;\n}\n\nif (msg.consulta_calle === \"PLAZA GENERAL SAGARDIA RAMOS 21 MADRID\") {\n msg.cambio.calle = \"PASEO DE LA MAESTRA MARIA SANCHEZ ARBOS\";\n return msg;\n}\n\nif (msg.consulta_calle === \"CALLE GARCIA MORATO MADRID\") {\n msg.cambio.calle = \"ROBERT CAPA\";\n return msg;\n}\n\nif (msg.consulta_calle === \"CALLE GENERAL YAGUE 5 MADRID\") {\n msg.cambio.calle = \"SAN GERMAN\";\n return msg;\n}\n\nif (msg.consulta_calle === \"CALLE GENERAL GARCIA DE LA HERRANZ MADRID\") {\n msg.cambio.calle = \"DE LA COOPERACION\";\n return msg;\n}\n\nif (msg.consulta_calle === \"CALLE GENERAL VARELA 3 MADRID\") {\n msg.cambio.calle = \"JULIÁN BESTEIRO\";\n return msg;\n}\n\nif (msg.consulta_calle === \"AVENIDA GENERAL FANJUL 2 MADRID\") {\n msg.cambio.calle = \"DE LAS AGUILAS\";\n return msg;\n}\n\nif (msg.consulta_calle === \"PLAZA HERMANOS FALCO Y ALVAREZ DE TOLEDO 15 MADRID\") {\n msg.cambio.calle = \"MAYOR DE BARAJAS\";\n return msg;\n}\n\nif (msg.consulta_calle === \"PASAJE GENERAL MOLA 4 MADRID\") {\n msg.cambio.calle = \"ENRIQUE RUANO\";\n return msg;\n}\n\nif (msg.consulta_calle === \"PASEO DOCTOR VALLEJO NAJERA 44 MADRID\" ||\n msg.consulta_calle === \"PASEO JUAN ANTONIO VALLEJO NAJERA BOTAS 44 MADRID\") {\n msg.cambio.calle = \"JUAN ANTONIO VALLEJO-NAJERA BOTAS\";\n return msg;\n}\n\nif (msg.consulta_calle === \"CALLE GENERAL ROMERO BASART 86 MADRID\") {\n msg.cambio.calle = \"BLAS CABRERA\";\n return msg;\n}", - "outputs": 1, - "timeout": 0, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 1000, - "y": 2280, - "wires": [ - [] - ] - }, - { - "id": "a1f0210367ec78c3", + "id": "041c57934c647e2c", "type": "debug", - "z": "a796bfad8ab76fe4", - "name": "CACHE", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "IGUALES - VALIDADO", "active": false, "tosidebar": true, "console": false, @@ -1641,33 +2075,244 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 940, - "y": 260, + "x": 1300, + "y": 480, "wires": [] }, { - "id": "b176ccfcb67d19a0", + "id": "fd8b53ea98c67e93", + "type": "debug", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "PROBLEMA NO DETECTADO", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "statusVal": "", + "statusType": "auto", + "x": 870, + "y": 560, + "wires": [] + }, + { + "id": "4d69a180d5f58f10", + "type": "comment", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "No existe la calle", + "info": "", + "x": 160, + "y": 640, + "wires": [] + }, + { + "id": "d6db349d1646634d", + "type": "delay", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "", + "pauseType": "rate", + "timeout": "5", + "timeoutUnits": "seconds", + "rate": "1", + "nbRateUnits": "1", + "rateUnits": "second", + "randomFirst": "1", + "randomLast": "5", + "randomUnits": "seconds", + "drop": false, + "allowrate": false, + "outputs": 1, + "x": 160, + "y": 680, + "wires": [ + [ + "007603e6138d3767" + ] + ] + }, + { + "id": "007603e6138d3767", "type": "function", - "z": "a796bfad8ab76fe4", - "name": "Calles a eliminar", - "func": "// Registro a eliminar sino procesamos\nif (msg.consulta_calle === \"CALLE SIN DETERMINAR MADRID\" ||\n msg.consulta_calle === \"BASE MEDIODIA 3 MADRID\" ||\n msg.consulta_calle === \"BASE COLON MADRID\" ||\n msg.consulta_calle === \"BASE MEDIODIA 2 1 MADRID\" ||\n msg.consulta_calle === \"CALLE No Codificada MADRID\" ||\n msg.consulta_calle === \"ACCESO POBLADO DE LAS BARRANQUILLAS sn MADRID\" ||\n msg.consulta_calle === \"BASE BARCELO MADRID\" ||\n msg.consulta_calle === \"EDIFICIO JUZGADO MADRID\" ||\n msg.consulta_calle === \"CALLE CAÑADA REAL GALIANA PARC 12 MADRID\" ||\n msg.consulta_calle === \"CALLE CAÑADA REAL GALIANA PARC. 127 MADRID\" ||\n msg.consulta_calle === \"CALLE No Codificada S / N MADRID\" ||\n msg.consulta_calle === \"CALLE No Codificada 8,400 MADRID\" ||\n msg.consulta_calle === \"CALLE No Codificada KM 12700 MADRID\" ||\n msg.consulta_calle === \"CALLE No Codificada KM 2.400 MADRID\" ||\n msg.consulta_calle === \"CALLE No Codificada - MADRID\" ||\n msg.consulta_calle === \"CALLE No Codificada S/N MADRID\" ||\n msg.consulta_calle === \"CALLE No Codificada FAROLA4 MADRID\" ||\n msg.consulta_calle === \"CALLE No Codificada 12500 MADRID\" ||\n msg.consulta_calle === \"CALLE No Codificada 6, 800 MADRID\" ||\n msg.consulta_calle === \"CALLE No Codificada 6, 500 MADRID\" ||\n msg.consulta_calle === \"CALLE No Codificada 6,800 MADRID\" ||\n msg.consulta_calle === \"CALLE No Codificada 6,500 MADRID\" ||\n msg.consulta_calle === \"CARRETERA A-3 ACCESO A VALDEMINGOMEZ MADRID\" ||\n msg.consulta_calle === \"CALLE No Codificada 2.200 MADRID\" ||\n msg.consulta_calle === \"CALLE No Codificada FAROLA 2 MADRID\" ||\n msg.consulta_calle === \"CALLE CAÑADA REAL GALIANA FAR. 31 MADRID\" ||\n msg.consulta_calle === \"ZONA COMISARIA HORTALEZA MADRID\" ||\n msg.consulta_calle === \"PASO PARTICULAR ELVIRA GOYA 12 MADRID\" ||\n msg.consulta_calle === \"PASO PARTICULAR ELVIRA GOYA 38 MADRID\" ||\n msg.consulta_calle === \"ACCESO AEROPUERTO DE BARAJAS T2 SALIDAS MADRID\" ||\n msg.consulta_calle === \"ACCESO CALZADA 1 PK 880 MADRID\" ||\n msg.consulta_calle === \"BASE ESCUADRON MADRID\" ||\n msg.consulta_calle === \"BASE VELAZQUEZ MADRID\" ||\n msg.consulta_calle === \"PASEO PINOS MADRID\" ||\n msg.consulta_calle === \"CALLE HERMANOS FERNANDEZ SHAW MADRID\"\n ) {\n return [msg, null]\n} else {\n return [null, msg]\n}\n\n", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Generamos la consulta a Cartociudad", + "func": "// msg.payload debe contener la dirección, ej. \"Calle Gran Vía 28, Madrid\"\nconst direccion = msg.consulta_calle;\nconst encoded = encodeURIComponent(direccion);\n\nmsg.original = msg.payload\n// API de CartoCiudad (gratuita España)\nmsg.method = \"GET\";\nmsg.url = `https://www.cartociudad.es/geocoder/api/geocoder/findJsonp?q=${encoded}`;\nreturn msg;\n", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 410, + "y": 680, + "wires": [ + [ + "1eb4a654a71a42b1" + ] + ] + }, + { + "id": "1eb4a654a71a42b1", + "type": "http request", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "", + "method": "use", + "ret": "txt", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": false, + "proxy": "", + "insecureHTTPParser": false, + "authType": "", + "senderr": false, + "headers": [], + "x": 650, + "y": 680, + "wires": [ + [ + "ea87880ca13d9dcb" + ] + ] + }, + { + "id": "ea87880ca13d9dcb", + "type": "function", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Filtramos el resultado", + "func": "// Limpia la respuesta JSONP (callback(...))\nlet text = msg.payload.trim();\n\n// Detecta y elimina el formato \"callback(...)\" o \"callback123(...)\" u otros\ntext = text.replace(/^[a-zA-Z0-9_]+\\(/, '').replace(/\\);?$/, '');\n\nlet data;\ntry {\n data = JSON.parse(text);\n} catch (e) {\n node.error(\"Error al parsear JSON de CartoCiudad: \" + e.message);\n msg.payload = { error: \"Formato no válido de respuesta CartoCiudad\" };\n return msg;\n}\n\n// La API devuelve un solo objeto, no un array\nif (data && data.lat && data.lng) {\n msg.payload = {\n lat: data.lat,\n lon: data.lng,\n address: data.address || \"\",\n postalCode: data.postalCode || \"\",\n muni: data.muni || \"\",\n province: data.province || \"\",\n source: \"CartoCiudad\",\n raw: data\n };\n} else {\n msg.payload = { error: \"No se encontraron coordenadas en CartoCiudad\" };\n}\nreturn msg;\n", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 360, + "y": 740, + "wires": [ + [ + "6c45fdd52d5b4bd3" + ] + ] + }, + { + "id": "6c45fdd52d5b4bd3", + "type": "switch", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Existen datos?", + "property": "payload.lat", + "propertyType": "msg", + "rules": [ + { + "t": "istype", + "v": "undefined", + "vt": "undefined" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 560, + "y": 740, + "wires": [ + [ + "9c7e15d6d339c983" + ], + [ + "98b02584803dbcbb" + ] + ], + "outputLabels": [ + "NO", + "SI" + ] + }, + { + "id": "98b02584803dbcbb", + "type": "function", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Eliminamos los que son coincidentes para no tener que tratarlos manualmente", + "func": "// Función para normalizar texto (elimina acentos y convierte a mayúsculas)\nfunction normalizarTexto(texto) {\n return texto.toString()\n .normalize(\"NFD\")\n .replace(/[\\u0300-\\u036f]/g, \"\")\n .toUpperCase()\n .trim();\n}\n\n// Comparación con normalización de address y province\nconst addressCoincide = normalizarTexto(msg.payload.address) === normalizarTexto(msg.direccion.Calle);\nconst provinceCoincide = normalizarTexto(msg.payload.province) === normalizarTexto(msg.direccion.Poblacion);\n\nif (addressCoincide && provinceCoincide) {\n return [null, msg]; // Salida 2 - coinciden\n} else {\n return [msg, null]; // Salida 1 - no coinciden\n}", "outputs": 2, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 960, - "y": 2240, + "x": 360, + "y": 860, "wires": [ - [], - [] + [ + "c91b4ba4c01b3d11" + ], + [ + "3f24b62573b3963b", + "c3ce306882f3d6ab" + ] + ], + "outputLabels": [ + "NO ", + "SI" ] }, { - "id": "4eee84ac85459806", + "id": "3f24b62573b3963b", + "type": "change", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Guardamos lo datos de la referencia de cache en mongo", + "rules": [ + { + "t": "set", + "p": "operation", + "pt": "msg", + "to": "insertOne", + "tot": "str" + }, + { + "t": "set", + "p": "collection", + "pt": "msg", + "to": "geocache", + "tot": "str" + }, + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "{\t \"referencia_geocache\": referencia_geocache,\t \"lat\": payload.lat,\t \"lon\": payload.lon,\t \"address\": payload.address,\t \"muni\": payload.muni,\t \"province\": payload.province\t}", + "tot": "jsonata" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 930, + "y": 840, + "wires": [ + [ + "78c4804a3d71aca2" + ] + ] + }, + { + "id": "78c4804a3d71aca2", "type": "mongodb4", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", @@ -1676,18 +2321,40 @@ "maxTimeMS": "0", "handleDocId": false, "name": "", - "x": 830, - "y": 1620, + "x": 1250, + "y": 840, "wires": [ [ - "237facc4aaef9d97" + "08ef481b73ada20e" ] ] }, { - "id": "2432622b4a8371d9", + "id": "ac3e7005ee6ca8b4", + "type": "mongodb4", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "clientNode": "648a51546e4dadc6", + "mode": "collection", + "collection": "", + "operation": "", + "output": "toArray", + "maxTimeMS": "0", + "handleDocId": false, + "name": "", + "x": 1250, + "y": 900, + "wires": [ + [ + "27fbbc6c04034efc" + ] + ] + }, + { + "id": "c3ce306882f3d6ab", "type": "change", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", "name": "Actualizamos los datos de todas las calles que sean iguales", "rules": [ { @@ -1708,7 +2375,7 @@ "t": "set", "p": "payload", "pt": "msg", - "to": "[\t {\t \"TipoVia\": direccion.TipoVia,\t \"Calle\": direccion.Calle,\t \"numero_retirada\": direccion.numero_retirada,\t \"Poblacion\": direccion.Poblacion,\t \"CP\": direccion.CP \t\t },\t {\t \"$set\": {\t \"latitud\": payload[0].lat,\t \"longitud\": payload[0].lon,\t \"geocodingProcesado\": true\t } \t }\t]", + "to": "[\t {\t \"TipoVia\": msg.direccion.TipoVia,\t \"Calle\": msg.direccion.Calle\t },\t {\t \"$set\": {\t \"latitud\": msg.payload.lat,\t \"longitud\": msg.payload.lon,\t \"geocodingProcesado\": true,\t \"cartociudad\": \"validado\"\t } \t }\t]", "tot": "jsonata" } ], @@ -1717,18 +2384,97 @@ "from": "", "to": "", "reg": false, - "x": 480, - "y": 260, + "x": 940, + "y": 900, "wires": [ [ - "f33442e9c3fb97aa" + "ac3e7005ee6ca8b4" ] ] }, { - "id": "f33442e9c3fb97aa", + "id": "08ef481b73ada20e", + "type": "debug", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "GUARDA geocache", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "statusVal": "", + "statusType": "auto", + "x": 1440, + "y": 840, + "wires": [] + }, + { + "id": "27fbbc6c04034efc", + "type": "debug", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "ACTUALIZA Calles", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "statusVal": "", + "statusType": "auto", + "x": 1430, + "y": 900, + "wires": [] + }, + { + "id": "9c7e15d6d339c983", + "type": "change", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Actualizamos los datos de todas las calles que sean iguales", + "rules": [ + { + "t": "set", + "p": "operation", + "pt": "msg", + "to": "updateMany", + "tot": "str" + }, + { + "t": "set", + "p": "collection", + "pt": "msg", + "to": "servicios_consolidado_calle_filtrado", + "tot": "str" + }, + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "[\t {\t \"TipoVia\": msg.direccion.TipoVia,\t \"Calle\": msg.direccion.Calle,\t \"numero_retirada\": msg.direccion.numero_retirada,\t \"Poblacion\": msg.direccion.Poblacion,\t \"CP\": msg.direccion.CP\t },\t {\t \"$set\": {\t \"cartociudad\": \"no-coincidente\"\t } \t }\t]", + "tot": "jsonata" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 940, + "y": 720, + "wires": [ + [ + "819f4993eed99959" + ] + ] + }, + { + "id": "819f4993eed99959", "type": "mongodb4", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", @@ -1737,19 +2483,377 @@ "maxTimeMS": "0", "handleDocId": false, "name": "", - "x": 790, - "y": 260, + "x": 1250, + "y": 720, "wires": [ [ - "a1f0210367ec78c3" + "711cd5bb325a7107" ] ] }, { - "id": "385c8170afd1861c", + "id": "711cd5bb325a7107", "type": "debug", - "z": "a796bfad8ab76fe4", - "name": "ACTUALIZADOS", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Pone no coincidente en cartociudad", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "statusVal": "", + "statusType": "auto", + "x": 1480, + "y": 720, + "wires": [] + }, + { + "id": "99e57e3e0c9feda3", + "type": "change", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Trigger Validar", + "rules": [ + { + "t": "set", + "p": "trigger", + "pt": "msg", + "to": "true", + "tot": "bool" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 220, + "y": 1120, + "wires": [ + [ + "c91b4ba4c01b3d11" + ] + ] + }, + { + "id": "c91b4ba4c01b3d11", + "type": "simple-queue", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Validar", + "firstMessageBypass": false, + "bypassInterval": "0", + "x": 190, + "y": 1080, + "wires": [ + [ + "374eb1d0ce2a0c27" + ] + ] + }, + { + "id": "374eb1d0ce2a0c27", + "type": "change", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Genera resultado_cartociudad", + "rules": [ + { + "t": "set", + "p": "resultado_cartociudad", + "pt": "msg", + "to": "payload.address& \" \" &payload.raw.portalNumber& \" \" &payload.muni& \" \" &payload.province& \" \" &payload.postalCode", + "tot": "jsonata" + }, + { + "t": "set", + "p": "actualizar", + "pt": "msg", + "to": "payload", + "tot": "msg" + }, + { + "t": "set", + "p": "validando_direccion", + "pt": "flow", + "to": "msg", + "tot": "jsonata" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 390, + "y": 1080, + "wires": [ + [ + "dc1aec7696d95a97", + "843fbe4881603a6c", + "faacde234e5acc0e", + "abccb8a853c9f234", + "426c5e09624cff47" + ] + ] + }, + { + "id": "843fbe4881603a6c", + "type": "ui-text", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "group": "29e5d13e29bfbb4b", + "order": 3, + "width": 0, + "height": 0, + "name": "consulta_calle", + "label": "Consulta Calle: ", + "format": "{{msg.payload}}", + "layout": "row-left", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "consulta_calle", + "valueType": "msg", + "x": 700, + "y": 1000, + "wires": [] + }, + { + "id": "dc1aec7696d95a97", + "type": "ui-text", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "group": "29e5d13e29bfbb4b", + "order": 4, + "width": 0, + "height": 0, + "name": "resultado_cartociudad", + "label": "Resultado Cartociudad: ", + "format": "{{msg.payload}}", + "layout": "row-left", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "resultado_cartociudad", + "valueType": "msg", + "x": 720, + "y": 1040, + "wires": [] + }, + { + "id": "faacde234e5acc0e", + "type": "ui-button", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "group": "29e5d13e29bfbb4b", + "name": "Validar", + "label": "Validar", + "order": 5, + "width": 0, + "height": 0, + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "", + "iconPosition": "left", + "payload": "validando_direccion", + "payloadType": "flow", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 670, + "y": 1140, + "wires": [ + [ + "7434c61d8243add8", + "2ef3fe5fe0abdfb5", + "8d13b3eb6e30802a" + ] + ] + }, + { + "id": "abccb8a853c9f234", + "type": "ui-button", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "group": "29e5d13e29bfbb4b", + "name": "Eliminar", + "label": "Eliminar", + "order": 7, + "width": 0, + "height": 0, + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "", + "iconPosition": "left", + "payload": "validando_direccion", + "payloadType": "flow", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 680, + "y": 1220, + "wires": [ + [ + "2561ac2b1923a696", + "8d13b3eb6e30802a" + ] + ] + }, + { + "id": "426c5e09624cff47", + "type": "ui-button", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "group": "29e5d13e29bfbb4b", + "name": "Renombrar", + "label": "Renombrar", + "order": 6, + "width": 0, + "height": 0, + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "", + "iconPosition": "left", + "payload": "validando_direccion", + "payloadType": "flow", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 690, + "y": 1300, + "wires": [ + [ + "1dfe62e8c32543ee", + "8d13b3eb6e30802a" + ] + ] + }, + { + "id": "5af76acc28d81750", + "type": "ui-button", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "group": "29e5d13e29bfbb4b", + "name": "Liberar", + "label": "Liberar", + "order": 8, + "width": 0, + "height": 0, + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "", + "iconPosition": "left", + "payload": "", + "payloadType": "date", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 680, + "y": 1260, + "wires": [ + [ + "8d13b3eb6e30802a" + ] + ] + }, + { + "id": "0d6f32bdc24ffd32", + "type": "link in", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "IN - Trigger Validar", + "links": [ + "8d13b3eb6e30802a" + ], + "x": 105, + "y": 1120, + "wires": [ + [ + "99e57e3e0c9feda3" + ] + ] + }, + { + "id": "9036e7960a287e16", + "type": "debug", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "VALIDAR - Número", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload.modifiedCount", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 1530, + "y": 1160, + "wires": [] + }, + { + "id": "2561ac2b1923a696", + "type": "debug", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "ELIMINAR - Mostrar para generar el borrado", "active": true, "tosidebar": true, "console": false, @@ -1758,15 +2862,48 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 1530, - "y": 2980, + "x": 1010, + "y": 1220, "wires": [] }, { - "id": "ae0ccf49a164192f", + "id": "13d7d425e81f0131", + "type": "debug", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "RENOMBRAR", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "statusVal": "", + "statusType": "auto", + "x": 1080, + "y": 1800, + "wires": [] + }, + { + "id": "3105cb58919fe886", + "type": "link out", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "link out 2", + "mode": "link", + "links": [ + "5e1954f3ba4bce4b" + ], + "x": 335, + "y": 1040, + "wires": [] + }, + { + "id": "7434c61d8243add8", "type": "change", - "z": "a796bfad8ab76fe4", - "name": "Insertar", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Guardamos lo datos de la referencia de cache en mongo", "rules": [ { "t": "set", @@ -1779,14 +2916,14 @@ "t": "set", "p": "collection", "pt": "msg", - "to": "consulta_calle", + "to": "geocache", "tot": "str" }, { "t": "set", "p": "payload", "pt": "msg", - "to": "{\t \"consulta_calle\": $flowContext(\"consulta_calle\"),\t \"tipovia\": $flowContext(\"tipovia\"),\t \"calle\": $flowContext(\"calle\"),\t \"numero_retirada\": $flowContext(\"numero_retirada\"),\t \"extra_calle\": $flowContext(\"extra_calle\"),\t \"accion\": \"validado\"\t}", + "to": "{\t \"referencia_geocache\": referencia_geocache,\t \"lat\": payload.lat,\t \"lon\": payload.lon,\t \"address\": payload.address,\t \"muni\": payload.muni,\t \"province\": payload.province\t}", "tot": "jsonata" } ], @@ -1795,18 +2932,121 @@ "from": "", "to": "", "reg": false, - "x": 920, - "y": 2940, + "x": 1030, + "y": 1100, "wires": [ [ - "cf7d08b21478be85" + "0d774be337e70e35" ] ] }, + { + "id": "0d774be337e70e35", + "type": "mongodb4", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "clientNode": "648a51546e4dadc6", + "mode": "collection", + "collection": "", + "operation": "", + "output": "toArray", + "maxTimeMS": "0", + "handleDocId": false, + "name": "", + "x": 1350, + "y": 1100, + "wires": [ + [ + "c800da6f27161aeb" + ] + ] + }, + { + "id": "1614e3503117cf11", + "type": "mongodb4", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "clientNode": "648a51546e4dadc6", + "mode": "collection", + "collection": "", + "operation": "", + "output": "toArray", + "maxTimeMS": "0", + "handleDocId": false, + "name": "", + "x": 1350, + "y": 1160, + "wires": [ + [ + "9036e7960a287e16" + ] + ] + }, + { + "id": "2ef3fe5fe0abdfb5", + "type": "change", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Actualizamos los datos de todas las calles que sean iguales", + "rules": [ + { + "t": "set", + "p": "operation", + "pt": "msg", + "to": "updateMany", + "tot": "str" + }, + { + "t": "set", + "p": "collection", + "pt": "msg", + "to": "servicios_consolidado_calle_filtrado", + "tot": "str" + }, + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "[\t {\t \"TipoVia\": msg.direccion.TipoVia,\t \"Calle\": msg.direccion.Calle\t },\t {\t \"$set\": {\t \"latitud\": msg.payload.lat,\t \"longitud\": msg.payload.lon,\t \"geocodingProcesado\": true,\t \"cartociudad\": \"validado\"\t } \t }\t]", + "tot": "jsonata" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 1040, + "y": 1160, + "wires": [ + [ + "1614e3503117cf11" + ] + ] + }, + { + "id": "c800da6f27161aeb", + "type": "debug", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "VALIDAR INSERCCION GEOCACHE", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "statusVal": "", + "statusType": "auto", + "x": 1590, + "y": 1100, + "wires": [] + }, { "id": "76d0610e0cf4a848", "type": "ui-text-input", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", "group": "2365cb156242b3e6", "name": "consulta_calle", "label": "consulta_calle", @@ -1828,8 +3068,8 @@ "icon": "", "iconPosition": "left", "iconInnerPosition": "inside", - "x": 780, - "y": 2340, + "x": 760, + "y": 1420, "wires": [ [ "3d08fca02fbfdc13" @@ -1839,7 +3079,8 @@ { "id": "13a8bf685ef1303b", "type": "ui-text-input", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", "group": "2365cb156242b3e6", "name": "tipocalle", "label": "tipocalle", @@ -1851,7 +3092,7 @@ "mode": "text", "tooltip": "", "delay": 300, - "passthru": false, + "passthru": true, "sendOnDelay": false, "sendOnBlur": true, "sendOnEnter": true, @@ -1861,8 +3102,8 @@ "icon": "", "iconPosition": "left", "iconInnerPosition": "inside", - "x": 760, - "y": 2380, + "x": 740, + "y": 1460, "wires": [ [ "a403b6e0d3b62351" @@ -1872,7 +3113,8 @@ { "id": "5a4e60652aab552c", "type": "ui-text-input", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", "group": "2365cb156242b3e6", "name": "calle", "label": "calle", @@ -1894,8 +3136,8 @@ "icon": "", "iconPosition": "left", "iconInnerPosition": "inside", - "x": 750, - "y": 2420, + "x": 730, + "y": 1500, "wires": [ [ "2bb29b85114ff2c3" @@ -1905,7 +3147,8 @@ { "id": "a97aaad7209e3953", "type": "ui-text-input", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", "group": "2365cb156242b3e6", "name": "numero_retirada", "label": "numero_retirada", @@ -1927,8 +3170,8 @@ "icon": "", "iconPosition": "left", "iconInnerPosition": "inside", - "x": 780, - "y": 2460, + "x": 760, + "y": 1540, "wires": [ [ "eae675ed8219e086" @@ -1938,7 +3181,8 @@ { "id": "2e1a6699fd10a0d0", "type": "ui-text-input", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", "group": "2365cb156242b3e6", "name": "extra_calle", "label": "extra_calle", @@ -1960,58 +3204,19 @@ "icon": "", "iconPosition": "left", "iconInnerPosition": "inside", - "x": 770, - "y": 2500, + "x": 750, + "y": 1580, "wires": [ [ "bc7269f08c168a0b" ] ] }, - { - "id": "3dbbc9b098e37e96", - "type": "ui-button", - "z": "a796bfad8ab76fe4", - "group": "2365cb156242b3e6", - "name": "Insertar datos", - "label": "Insertar Datos", - "order": 7, - "width": 0, - "height": 0, - "emulateClick": false, - "tooltip": "", - "color": "", - "bgcolor": "", - "className": "", - "icon": "", - "iconPosition": "left", - "payload": "ultima_validacion", - "payloadType": "flow", - "topic": "topic", - "topicType": "msg", - "buttonColor": "", - "textColor": "", - "iconColor": "", - "enableClick": true, - "enablePointerdown": false, - "pointerdownPayload": "", - "pointerdownPayloadType": "str", - "enablePointerup": false, - "pointerupPayload": "", - "pointerupPayloadType": "str", - "x": 360, - "y": 2680, - "wires": [ - [ - "ee0c6a9d7d1aa05c", - "a75d78af573442dc" - ] - ] - }, { "id": "3d08fca02fbfdc13", "type": "change", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", "name": "", "rules": [ { @@ -2027,8 +3232,8 @@ "from": "", "to": "", "reg": false, - "x": 1000, - "y": 2340, + "x": 980, + "y": 1420, "wires": [ [] ] @@ -2036,7 +3241,8 @@ { "id": "a403b6e0d3b62351", "type": "change", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", "name": "", "rules": [ { @@ -2052,8 +3258,8 @@ "from": "", "to": "", "reg": false, - "x": 980, - "y": 2380, + "x": 960, + "y": 1460, "wires": [ [] ] @@ -2061,7 +3267,8 @@ { "id": "2bb29b85114ff2c3", "type": "change", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", "name": "", "rules": [ { @@ -2077,8 +3284,8 @@ "from": "", "to": "", "reg": false, - "x": 970, - "y": 2420, + "x": 950, + "y": 1500, "wires": [ [] ] @@ -2086,7 +3293,8 @@ { "id": "eae675ed8219e086", "type": "change", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", "name": "", "rules": [ { @@ -2102,8 +3310,8 @@ "from": "", "to": "", "reg": false, - "x": 1010, - "y": 2460, + "x": 990, + "y": 1540, "wires": [ [] ] @@ -2111,7 +3319,8 @@ { "id": "bc7269f08c168a0b", "type": "change", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", "name": "", "rules": [ { @@ -2127,329 +3336,8 @@ "from": "", "to": "", "reg": false, - "x": 990, - "y": 2500, - "wires": [ - [] - ] - }, - { - "id": "cf7d08b21478be85", - "type": "mongodb4", - "z": "a796bfad8ab76fe4", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 1070, - "y": 2940, - "wires": [ - [ - "f521d21d39f94c81" - ] - ] - }, - { - "id": "65929efb1b36beb0", - "type": "change", - "z": "a796bfad8ab76fe4", - "name": "Buscar", - "rules": [ - { - "t": "set", - "p": "operation", - "pt": "msg", - "to": "findOne", - "tot": "str" - }, - { - "t": "set", - "p": "collection", - "pt": "msg", - "to": "consulta_calle", - "tot": "str" - }, - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "[{ \"consulta_calle\": { \"$eq\": $flowContext(\"consulta_calle\") }}]", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 460, - "y": 2960, - "wires": [ - [ - "acf35447afb95d83" - ] - ] - }, - { - "id": "acf35447afb95d83", - "type": "mongodb4", - "z": "a796bfad8ab76fe4", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 610, - "y": 2960, - "wires": [ - [ - "d004b5eb8f81d4f5" - ] - ] - }, - { - "id": "d004b5eb8f81d4f5", - "type": "switch", - "z": "a796bfad8ab76fe4", - "name": "¿Existe?", - "property": "payload", - "propertyType": "msg", - "rules": [ - { - "t": "null" - }, - { - "t": "else" - } - ], - "checkall": "true", - "repair": false, - "outputs": 2, - "x": 760, - "y": 2960, - "wires": [ - [ - "ae0ccf49a164192f" - ], - [ - "376d12f46845ec84", - "a91e0f85d9f57fb2" - ] - ], - "outputLabels": [ - "NO", - "SI" - ] - }, - { - "id": "376d12f46845ec84", - "type": "change", - "z": "a796bfad8ab76fe4", - "name": "Actualizamos los datos de las calles mal codificadas", - "rules": [ - { - "t": "set", - "p": "operation", - "pt": "msg", - "to": "updateMany", - "tot": "str" - }, - { - "t": "set", - "p": "collection", - "pt": "msg", - "to": "servicios_consolidado_calle_filtrado", - "tot": "str" - }, - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "[\t {\t \"TipoVia\": $flowContext(\"tipovia_original\"),\t \"Calle\": $flowContext(\"calle_original\"),\t \"numero_retirada\": $flowContext(\"numero_retirada_original\"),\t \"Poblacion\": $flowContext(\"poblacion_original\"),\t \"CP\": $flowContext(\"cp_original\")\t },\t {\t \"$set\": {\t \"TipoVia\": $flowContext(\"tipovia\"),\t \"Calle\": $flowContext(\"calle\"),\t \"numero_retirada\": $flowContext(\"numero_retirada\"),\t \"extra_calle\": $flowContext(\"extra_calle\"),\t \"geocodingProcesado\": \"false\"\t }\t }\t]", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 1060, - "y": 2980, - "wires": [ - [ - "54cfdd34c936f6b8" - ] - ] - }, - { - "id": "11f1b5cccc45d206", - "type": "change", - "z": "a796bfad8ab76fe4", - "name": "Actualizamos la consulta_calle", - "rules": [ - { - "t": "set", - "p": "operation", - "pt": "msg", - "to": "updateMany", - "tot": "str" - }, - { - "t": "set", - "p": "collection", - "pt": "msg", - "to": "consulta_calle", - "tot": "str" - }, - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "[\t {\t \"consulta_calle\": $flowContext(\"consulta_calle\")\t },\t {\t \"$set\": {\t \"tipovia\": $flowContext(\"tipovia\"),\t \"calle\": $flowContext(\"calle\"),\t \"numero_retirada\": $flowContext(\"numero_retirada\"),\t \"extra_calle\": $flowContext(\"extra_calle\")\t }\t }\t]", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 990, - "y": 3100, - "wires": [ - [ - "397b758c268fcfe3" - ] - ] - }, - { - "id": "54cfdd34c936f6b8", - "type": "mongodb4", - "z": "a796bfad8ab76fe4", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 1350, - "y": 2980, - "wires": [ - [ - "385c8170afd1861c" - ] - ] - }, - { - "id": "397b758c268fcfe3", - "type": "mongodb4", - "z": "a796bfad8ab76fe4", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 1210, - "y": 3100, - "wires": [ - [ - "01486ff2b815efdc" - ] - ] - }, - { - "id": "929680815ce51af8", - "type": "mongodb4", - "z": "a796bfad8ab76fe4", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 1370, - "y": 3040, - "wires": [ - [ - "be21eaa7c3594803" - ] - ] - }, - { - "id": "a91e0f85d9f57fb2", - "type": "change", - "z": "a796bfad8ab76fe4", - "name": "Borramos los datos de la referencia de cache en mongo", - "rules": [ - { - "t": "set", - "p": "operation", - "pt": "msg", - "to": "deleteMany", - "tot": "str" - }, - { - "t": "set", - "p": "collection", - "pt": "msg", - "to": "geocache", - "tot": "str" - }, - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "[{ \"referencia_geocache\": { \"$eq\": $flowContext(\"referencia_geocache\") }}]", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 1070, - "y": 3040, - "wires": [ - [ - "929680815ce51af8" - ] - ] - }, - { - "id": "d6116b226cfad9d6", - "type": "trigger", - "z": "a796bfad8ab76fe4", - "name": "", - "op1": "", - "op2": "0", - "op1type": "pay", - "op2type": "str", - "duration": "0", - "extend": false, - "overrideDelay": false, - "units": "ms", - "reset": "", - "bytopic": "all", - "topic": "topic", - "outputs": 1, - "x": 770, - "y": 2280, + "x": 970, + "y": 1580, "wires": [ [] ] @@ -2457,7 +3345,8 @@ { "id": "5c95290ed28a98cc", "type": "change", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", "name": "Pongo consulta calle", "rules": [ { @@ -2523,18 +3412,101 @@ "to": "", "reg": false, "x": 560, - "y": 2340, + "y": 1420, "wires": [ [ "76d0610e0cf4a848" ] ] }, + { + "id": "1dfe62e8c32543ee", + "type": "simple-queue", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Renombrar", + "firstMessageBypass": false, + "bypassInterval": "0", + "x": 210, + "y": 1420, + "wires": [ + [ + "5c95290ed28a98cc", + "8c63476ce9eb94ea", + "e6c3dc27360afac1", + "383a4d93dbc6cf7e", + "19765558436e83d7" + ] + ] + }, + { + "id": "3dbbc9b098e37e96", + "type": "ui-button", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "group": "2365cb156242b3e6", + "name": "Renombrar", + "label": "Renombrar", + "order": 7, + "width": 0, + "height": 0, + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "", + "iconPosition": "left", + "payload": "ultima_validacion", + "payloadType": "flow", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 750, + "y": 1680, + "wires": [ + [ + "f8a18d468d34e722", + "9cd726efb2695f64" + ] + ] + }, + { + "id": "71e6a918e85cbd07", + "type": "mongodb4", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "clientNode": "648a51546e4dadc6", + "mode": "collection", + "collection": "", + "operation": "", + "output": "toArray", + "maxTimeMS": "0", + "handleDocId": false, + "name": "", + "x": 910, + "y": 1800, + "wires": [ + [ + "13d7d425e81f0131" + ] + ] + }, { "id": "ee0c6a9d7d1aa05c", "type": "change", - "z": "a796bfad8ab76fe4", - "name": "", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Trigger Renombrar", "rules": [ { "t": "set", @@ -2549,42 +3521,136 @@ "from": "", "to": "", "reg": false, - "x": 380, - "y": 2620, + "x": 230, + "y": 1460, "wires": [ [ - "0579fe31ed7de68e" + "1dfe62e8c32543ee" ] ] }, { - "id": "237facc4aaef9d97", - "type": "debug", - "z": "a796bfad8ab76fe4", - "name": "BORRADO CACHE", - "active": false, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1020, - "y": 1620, - "wires": [] + "id": "2b215b7870143e56", + "type": "ui-button", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "group": "2365cb156242b3e6", + "name": "Liberar", + "label": "Liberar", + "order": 8, + "width": 0, + "height": 0, + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "", + "iconPosition": "left", + "payload": "", + "payloadType": "date", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 740, + "y": 1640, + "wires": [ + [ + "9cd726efb2695f64" + ] + ] }, { - "id": "065d8956ac11a589", + "id": "f8a18d468d34e722", "type": "change", - "z": "a796bfad8ab76fe4", - "name": "Copiamos la dirección en dirección para consultas posteriores", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Preparamos los datos a guardar", "rules": [ { "t": "set", - "p": "direccion", + "p": "guardar", "pt": "msg", - "to": "payload", + "to": "{}", + "tot": "json" + }, + { + "t": "set", + "p": "guardar.consulta_calle", + "pt": "msg", + "to": "$flowContext(\"ultima_validacion.consulta_calle\")", + "tot": "jsonata" + }, + { + "t": "set", + "p": "guardar.TipoVia", + "pt": "msg", + "to": "$uppercase($flowContext(\"tipovia\"))", + "tot": "jsonata" + }, + { + "t": "set", + "p": "guardar.calle", + "pt": "msg", + "to": "$uppercase($flowContext(\"calle\"))", + "tot": "jsonata" + }, + { + "t": "set", + "p": "guardar.numero_retirada", + "pt": "msg", + "to": "$flowContext(\"numero_retirada\")", + "tot": "jsonata" + }, + { + "t": "set", + "p": "guardar.extra_calle", + "pt": "msg", + "to": "$uppercase($flowContext(\"extra_calle\"))", + "tot": "jsonata" + }, + { + "t": "set", + "p": "guardar.accion", + "pt": "msg", + "to": "renombrar", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 270, + "y": 1740, + "wires": [ + [ + "bdad16849cfd6e20" + ] + ] + }, + { + "id": "8c63476ce9eb94ea", + "type": "change", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Pongo TipoVia", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "msg.direccion.TipoVia", "tot": "msg" } ], @@ -2593,118 +3659,110 @@ "from": "", "to": "", "reg": false, - "x": 430, - "y": 120, + "x": 580, + "y": 1460, "wires": [ [ - "3112772543b09bd9" + "13a8bf685ef1303b" ] ] }, { - "id": "039fe8c413696211", - "type": "link out", - "z": "a796bfad8ab76fe4", - "name": "OUT - Consulta referencia_geocache - No existe", - "mode": "link", - "links": [ - "362dad96d3acb433" - ], - "x": 995, - "y": 140, - "wires": [] - }, - { - "id": "ea5fca57029b791a", - "type": "link out", - "z": "a796bfad8ab76fe4", - "name": "OUT - Consulta referencia_geocache - Si existe", - "mode": "link", - "links": [ - "8e600a2622518a91" - ], - "x": 995, - "y": 180, - "wires": [] - }, - { - "id": "8e600a2622518a91", - "type": "link in", - "z": "a796bfad8ab76fe4", - "name": "IN - Consulta referencia_geocache - Si existe", - "links": [ - "ea5fca57029b791a" - ], - "x": 215, - "y": 260, - "wires": [ - [ - "2432622b4a8371d9" - ] - ] - }, - { - "id": "a2728ad52fcd926b", - "type": "debug", - "z": "a796bfad8ab76fe4", - "name": "IGUALES - VALIDADO", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1160, - "y": 540, - "wires": [] - }, - { - "id": "4320d2d03e53a85c", - "type": "comment", - "z": "a796bfad8ab76fe4", - "name": "Si existe la referencia se actualiza", - "info": "", - "x": 340, - "y": 220, - "wires": [] - }, - { - "id": "45cf835dcdbd1a3a", - "type": "comment", - "z": "a796bfad8ab76fe4", - "name": "No existe la referencia", - "info": "", - "x": 300, - "y": 380, - "wires": [] - }, - { - "id": "7e1ef1bd33f94522", - "type": "link in", - "z": "a796bfad8ab76fe4", - "name": "IN - Consulta referencia_geocache - No existe", - "links": [], - "x": 215, - "y": 420, - "wires": [ - [ - "203e1085c0c47c13" - ] - ] - }, - { - "id": "203e1085c0c47c13", + "id": "e6c3dc27360afac1", "type": "change", - "z": "a796bfad8ab76fe4", - "name": "Buscarmos la calle en la base de datos de consulta_calle", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Pongo calle", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "direccion.Calle", + "tot": "msg" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 590, + "y": 1500, + "wires": [ + [ + "5a4e60652aab552c" + ] + ] + }, + { + "id": "383a4d93dbc6cf7e", + "type": "change", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Pongo numero_retirada", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "direccion.numero_retirada", + "tot": "msg" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 550, + "y": 1540, + "wires": [ + [ + "a97aaad7209e3953" + ] + ] + }, + { + "id": "19765558436e83d7", + "type": "change", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Pongo extra_calle", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 570, + "y": 1580, + "wires": [ + [ + "2e1a6699fd10a0d0" + ] + ] + }, + { + "id": "1799f293511ddb1e", + "type": "change", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Guardamos lo datos para el renombrado", "rules": [ { "t": "set", "p": "operation", "pt": "msg", - "to": "find", + "to": "insertOne", "tot": "str" }, { @@ -2718,7 +3776,7 @@ "t": "set", "p": "payload", "pt": "msg", - "to": "[{ \"consulta_calle \": { \"$eq\": msg.consulta_calle }}]", + "to": "{\t \"consulta_calle\": guardar.consulta_calle,\t \"TipoVia\": guardar.TipoVia,\t \"calle\": guardar.calle,\t \"numero_retirada\": guardar.numero_retirada,\t \"accion\": guardar.accion\t}", "tot": "jsonata" } ], @@ -2727,18 +3785,61 @@ "from": "", "to": "", "reg": false, - "x": 470, - "y": 420, + "x": 580, + "y": 1800, "wires": [ [ - "87e7bd9dc902fc8d" + "71e6a918e85cbd07" ] ] }, { - "id": "87e7bd9dc902fc8d", + "id": "bdad16849cfd6e20", + "type": "change", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Borramos si hubiera alguna referencia mal codificada", + "rules": [ + { + "t": "set", + "p": "operation", + "pt": "msg", + "to": "deleteMany", + "tot": "str" + }, + { + "t": "set", + "p": "collection", + "pt": "msg", + "to": "consulta_calle", + "tot": "str" + }, + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "[{ \"consulta_calle\": { \"$eq\": guardar.consulta_calle }}]", + "tot": "jsonata" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 620, + "y": 1740, + "wires": [ + [ + "94ebcb167b5c4a7d" + ] + ] + }, + { + "id": "94ebcb167b5c4a7d", "type": "mongodb4", - "z": "a796bfad8ab76fe4", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", @@ -2747,133 +3848,370 @@ "maxTimeMS": "0", "handleDocId": false, "name": "", - "x": 770, - "y": 420, + "x": 910, + "y": 1740, "wires": [ [ - "5fc42487deb4834e" + "1799f293511ddb1e" ] ] }, { - "id": "5fc42487deb4834e", - "type": "switch", - "z": "a796bfad8ab76fe4", - "name": "Existe la calle en consulta_calle?", - "property": "$count(payload)", - "propertyType": "jsonata", - "rules": [ - { - "t": "eq", - "v": "0", - "vt": "num" - }, - { - "t": "else" - } - ], - "checkall": "true", - "repair": false, - "outputs": 2, - "x": 1000, - "y": 420, - "wires": [ - [ - "ed849af6a3bc7f94" - ], - [ - "3ef05c3f5e8cf598" - ] - ], - "outputLabels": [ - "NO", - "SI" - ] - }, - { - "id": "ed849af6a3bc7f94", - "type": "link out", - "z": "a796bfad8ab76fe4", - "name": "OUT - Consulta consulta_calle - No existe", - "mode": "link", - "links": [ - "362dad96d3acb433" - ], - "x": 1185, - "y": 400, - "wires": [] - }, - { - "id": "3ef05c3f5e8cf598", - "type": "link out", - "z": "a796bfad8ab76fe4", - "name": "OUT - Consulta consulta_calle - Si existe", - "mode": "link", - "links": [ - "34d799f171e47da5" - ], - "x": 1185, - "y": 440, - "wires": [] - }, - { - "id": "34d799f171e47da5", - "type": "link in", - "z": "a796bfad8ab76fe4", - "name": "IN - Consulta consulta_calle - Si existe", - "links": [ - "3ef05c3f5e8cf598" - ], - "x": 215, - "y": 580, - "wires": [ - [ - "ea176a490b716f31" - ] - ] - }, - { - "id": "fa5477b702141436", - "type": "comment", - "z": "a796bfad8ab76fe4", - "name": "Si existe la calle", - "info": "", - "x": 280, + "id": "530155acd87e9af4", + "type": "debug", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "RENOMBRAR - VALIDADO", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload.modifiedCount", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 1480, "y": 520, "wires": [] }, { - "id": "8a3bbd2c812a3210", - "type": "comment", - "z": "a796bfad8ab76fe4", - "name": "No existe la calle", - "info": "", - "x": 280, - "y": 800, - "wires": [] - }, - { - "id": "362dad96d3acb433", - "type": "link in", - "z": "a796bfad8ab76fe4", - "name": "IN - Consulta consulta_calle - No existe", - "links": [ - "ed849af6a3bc7f94", - "039fe8c413696211" - ], - "x": 215, - "y": 860, + "id": "f7f14145281f4584", + "type": "mongodb4", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "clientNode": "648a51546e4dadc6", + "mode": "collection", + "collection": "", + "operation": "", + "output": "toArray", + "maxTimeMS": "0", + "handleDocId": false, + "name": "", + "x": 1270, + "y": 520, "wires": [ [ - "f824743db6a45636" + "530155acd87e9af4" ] ] }, { - "id": "8fea8c90dd9194ec", - "type": "inject", - "z": "a796bfad8ab76fe4", + "id": "c14692403d35c94d", + "type": "change", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Actualizamos los datos de todas las calles que sean iguales", + "rules": [ + { + "t": "set", + "p": "operation", + "pt": "msg", + "to": "updateMany", + "tot": "str" + }, + { + "t": "set", + "p": "collection", + "pt": "msg", + "to": "servicios_consolidado_calle_filtrado", + "tot": "str" + }, + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "[\t {\t \"TipoVia\": $exists(direccion.TipoVia) ? direccion.TipoVia : undefined,\t \"Calle\": $exists(direccion.Calle) ? direccion.Calle : undefined,\t \"numero_retirada\": $exists(direccion.numero_retirada) ? direccion.numero_retirada : undefined,\t \"Poblacion\": $exists(direccion.poblacion) ? direccion.poblacion : undefined,\t \"CP\": $exists(direccion.CP) ? direccion.CP : undefined\t },\t {\t \"$set\": {\t \"TipoVia\": $exists(payload[0].TipoVia) ? payload[0].TipoVia : undefined,\t \"Calle\": $exists(payload[0].calle) ? payload[0].calle : undefined,\t \"numero_retirada\": $exists(payload[0].numero_retirada) ? payload[0].numero_retirada : undefined,\t \"cartociudad\": \"renombrado\"\t }\t }\t]\t", + "tot": "jsonata" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 960, + "y": 520, + "wires": [ + [ + "f7f14145281f4584" + ] + ] + }, + { + "id": "d82fe4f6536306f7", + "type": "status", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Estado validar", + "scope": [ + "c91b4ba4c01b3d11" + ], + "x": 150, + "y": 1580, + "wires": [ + [ + "da84256af9053a56" + ] + ] + }, + { + "id": "897720eb56636e2d", + "type": "status", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "Estado renombrar", + "scope": [ + "1dfe62e8c32543ee" + ], + "x": 170, + "y": 1620, + "wires": [ + [ + "de380c0ed70e4d7a" + ] + ] + }, + { + "id": "da84256af9053a56", + "type": "ui-text", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "group": "29e5d13e29bfbb4b", + "order": 1, + "width": 0, + "height": 0, + "name": "Validar", + "label": "Pendientes: ", + "format": "{{msg.payload}}", + "layout": "row-spread", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "status.text", + "valueType": "msg", + "x": 330, + "y": 1580, + "wires": [] + }, + { + "id": "de380c0ed70e4d7a", + "type": "ui-text", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "group": "2365cb156242b3e6", + "order": 1, + "width": 0, + "height": 0, + "name": "Renombrar", + "label": "Pendientes:", + "format": "{{msg.payload}}", + "layout": "row-left", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "status.text", + "valueType": "msg", + "x": 350, + "y": 1620, + "wires": [] + }, + { + "id": "d4f93dfa22423d32", + "type": "ui-button", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "group": "29e5d13e29bfbb4b", + "name": "Activar consulta", + "label": "Activación", + "order": 2, + "width": 0, + "height": 0, + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "", + "iconPosition": "left", + "payload": "", + "payloadType": "date", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 220, + "y": 1040, + "wires": [ + [ + "3105cb58919fe886" + ] + ] + }, + { + "id": "f7070a1689337f95", + "type": "comment", + "z": "6e1ee0f06e75580d", + "g": "586a685b7e78517c", + "name": "Parte Automática", + "info": "", + "x": 160, + "y": 820, + "wires": [] + }, + { + "id": "8d13b3eb6e30802a", + "type": "link out", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "OUT - Trigger Validar", + "mode": "link", + "links": [ + "0d6f32bdc24ffd32" + ], + "x": 855, + "y": 1260, + "wires": [] + }, + { + "id": "2ddb1cf2b28f0f2e", + "type": "link in", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "IN - Trigger Renombrar", + "links": [ + "9cd726efb2695f64" + ], + "x": 105, + "y": 1460, + "wires": [ + [ + "ee0c6a9d7d1aa05c" + ] + ] + }, + { + "id": "9cd726efb2695f64", + "type": "link out", + "z": "6e1ee0f06e75580d", + "g": "6d889597e60bf596", + "name": "OUT - Trigger Renombrar", + "mode": "link", + "links": [ + "2ddb1cf2b28f0f2e" + ], + "x": 875, + "y": 1640, + "wires": [] + }, + { + "id": "acae736839e9942c", + "type": "postgresql", + "z": "e3a070490bfdc383", + "g": "d31dc5ca65fdaec9", + "name": "Creación de la tabla de servicios_geo", + "query": "CREATE TABLE servicios_geo (\n id SERIAL PRIMARY KEY,\n id_servicio TEXT,\n fecha_entrada TIMESTAMP,\n fecha_servicio TIMESTAMP,\n codigo_grua TEXT,\n tipo_servicio TEXT,\n geom GEOMETRY(Point, 4326)\n);", + "postgreSQLConfig": "748b5921246ec468", + "split": false, + "rowsPerMsg": 1, + "outputs": 1, + "x": 370, + "y": 120, + "wires": [ + [ + "9a2c00a3d18bf2e5" + ] + ] + }, + { + "id": "a5da07eb95be391c", + "type": "mongodb4", + "z": "e3a070490bfdc383", + "g": "4de20a7676e67ad3", + "clientNode": "648a51546e4dadc6", + "mode": "collection", + "collection": "", + "operation": "", + "output": "forEach", + "maxTimeMS": "0", + "handleDocId": true, "name": "", + "x": 850, + "y": 460, + "wires": [ + [ + "476541d607d59b6d" + ] + ] + }, + { + "id": "e6f2786536d9be1b", + "type": "debug", + "z": "e3a070490bfdc383", + "g": "4de20a7676e67ad3", + "name": "INSERCIÓN", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "statusVal": "", + "statusType": "auto", + "x": 810, + "y": 580, + "wires": [] + }, + { + "id": "2f3bd996544abba2", + "type": "inject", + "z": "e3a070490bfdc383", + "g": "4de20a7676e67ad3", + "name": "Activar Migración datos todos los demas", + "props": [ + { + "p": "payload" + }, + { + "p": "ultimo_id", + "v": "ultimo_id", + "vt": "flow" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 260, + "y": 460, + "wires": [ + [ + "87a50279e182879c" + ] + ] + }, + { + "id": "5d7ccd027be25185", + "type": "inject", + "z": "e3a070490bfdc383", + "g": "d31dc5ca65fdaec9", + "name": "Activar", "props": [ { "p": "payload" @@ -2886,975 +4224,73 @@ "repeat": "", "crontab": "", "once": false, - "onceDelay": "1", + "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", - "x": 710, - "y": 800, + "x": 150, + "y": 120, "wires": [ [ - "3105cb58919fe886" + "acae736839e9942c" ] ] }, { - "id": "3105cb58919fe886", - "type": "link out", - "z": "a796bfad8ab76fe4", - "name": "link out 2", - "mode": "link", - "links": [ - "5e1954f3ba4bce4b" - ], - "x": 835, - "y": 800, - "wires": [] - }, - { - "id": "ea176a490b716f31", - "type": "switch", - "z": "a796bfad8ab76fe4", - "name": "Accion que se hace según la consulta", - "property": "payload.accion", - "propertyType": "msg", - "rules": [ - { - "t": "eq", - "v": "validado", - "vt": "str" - }, - { - "t": "eq", - "v": "eliminar", - "vt": "str" - }, - { - "t": "else" - } - ], - "checkall": "true", - "repair": false, - "outputs": 3, - "x": 410, - "y": 580, - "wires": [ - [ - "1f77c5f90a3ffb63" - ], - [ - "a5a82ce094a9262a" - ], - [ - "22cab22ef894585c" - ] - ], - "outputLabels": [ - "Se actuliza el valor de la calle", - "Se borra la calle", - "Se estudia" - ] - }, - { - "id": "1f77c5f90a3ffb63", - "type": "change", - "z": "a796bfad8ab76fe4", - "name": "Actualizamos los datos de todas las calles que sean iguales", - "rules": [ - { - "t": "set", - "p": "operation", - "pt": "msg", - "to": "updateMany", - "tot": "str" - }, - { - "t": "set", - "p": "collection", - "pt": "msg", - "to": "servicios_consolidado_calle_filtrado", - "tot": "str" - }, - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "[\t {\t \"TipoVia\": msg.direccion.TipoVia,\t \"Calle\": msg.direccion.Calle,\t \"numero_retirada\": msg.direccion.numero_retirada,\t \"Poblacion\": msg.direccion.Poblacion,\t \"CP\": msg.direccion.CP \t\t },\t {\t \"$set\": {\t \"latitud\": msg.payload.lat,\t \"longitud\": msg.payload.lon,\t \"geocodingProcesado\": true\t } \t }\t]", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 820, - "y": 540, - "wires": [ - [ - "a2728ad52fcd926b" - ] - ] - }, - { - "id": "a5a82ce094a9262a", - "type": "debug", - "z": "a796bfad8ab76fe4", - "name": "ELIMINAR", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1130, - "y": 580, - "wires": [] - }, - { - "id": "22cab22ef894585c", - "type": "debug", - "z": "a796bfad8ab76fe4", - "name": "TRATAR", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1120, - "y": 620, - "wires": [] - }, - { - "id": "f824743db6a45636", - "type": "delay", - "z": "a796bfad8ab76fe4", - "name": "", - "pauseType": "rate", - "timeout": "5", - "timeoutUnits": "seconds", - "rate": "1", - "nbRateUnits": "1", - "rateUnits": "second", - "randomFirst": "1", - "randomLast": "5", - "randomUnits": "seconds", - "drop": false, - "allowrate": false, + "id": "73ca61629ca36cdb", + "type": "postgresql", + "z": "e3a070490bfdc383", + "g": "d31dc5ca65fdaec9", + "name": "Borrado de la tabla de servicios_geo", + "query": "DROP TABLE IF EXISTS servicios_geo;", + "postgreSQLConfig": "748b5921246ec468", + "split": false, + "rowsPerMsg": 1, "outputs": 1, - "x": 340, - "y": 860, + "x": 370, + "y": 60, "wires": [ [ - "1fd044cbc45e1620" + "67d9948a4ea561d0" ] ] }, { - "id": "5d8fed0824f5d590", - "type": "link out", - "z": "a796bfad8ab76fe4", - "name": "OUT - Catociudad con datos", - "mode": "link", - "links": [ - "267efedbc42eb1dc" - ], - "x": 1345, - "y": 880, - "wires": [] - }, - { - "id": "b5d1699d2f623f08", - "type": "link out", - "z": "a796bfad8ab76fe4", - "name": "OUT - Cartociudad sin datos", - "mode": "link", - "links": [ - "629bb3d5189f7e53", - "37f1c5b138623383" - ], - "x": 1345, - "y": 840, - "wires": [] - }, - { - "id": "407bef05d919bd52", - "type": "comment", - "z": "a796bfad8ab76fe4", - "name": "Cartociudad con datos", - "info": "", - "x": 300, - "y": 940, - "wires": [] - }, - { - "id": "412a0aa8b5a7a677", - "type": "comment", - "z": "a796bfad8ab76fe4", - "name": "Cartociudad sin datos", - "info": "", - "x": 480, - "y": 2240, - "wires": [] - }, - { - "id": "267efedbc42eb1dc", - "type": "link in", - "z": "a796bfad8ab76fe4", - "name": "IN - Cartociudad con datos", - "links": [ - "5d8fed0824f5d590" - ], - "x": 215, - "y": 980, - "wires": [ - [ - "8f57171dbb68e9cc" - ] - ] - }, - { - "id": "629bb3d5189f7e53", - "type": "link in", - "z": "a796bfad8ab76fe4", - "name": "IN - Cartociudad sin datos", - "links": [ - "b5d1699d2f623f08", - "f9145f1a463f19ec" - ], - "x": 405, - "y": 2280, - "wires": [ - [ - "0579fe31ed7de68e" - ] - ] - }, - { - "id": "dcc5a797823a45a1", - "type": "ui-text", - "z": "a796bfad8ab76fe4", - "group": "29e5d13e29bfbb4b", - "order": 1, - "width": 0, - "height": 0, - "name": "consulta_calle", - "label": "Consulta Calle: ", - "format": "{{msg.payload}}", - "layout": "row-left", - "style": false, - "font": "", - "fontSize": 16, - "color": "#717171", - "wrapText": false, - "className": "", - "value": "consulta_calle", - "valueType": "msg", - "x": 900, - "y": 1060, - "wires": [] - }, - { - "id": "d0df21d0eea0830f", - "type": "change", - "z": "a796bfad8ab76fe4", - "name": "Genera resultado_cartociudad", - "rules": [ + "id": "bf5deb0295df1e6d", + "type": "inject", + "z": "e3a070490bfdc383", + "g": "d31dc5ca65fdaec9", + "name": "Activar", + "props": [ { - "t": "set", - "p": "resultado_cartociudad", - "pt": "msg", - "to": "payload.address& \" \" &payload.raw.portalNumber& \" \" &payload.muni& \" \" &payload.province& \" \" &payload.postalCode", - "tot": "jsonata" + "p": "payload" }, { - "t": "set", - "p": "actualizar", - "pt": "msg", - "to": "payload", - "tot": "msg" - }, - { - "t": "set", - "p": "validando_direccion", - "pt": "flow", - "to": "msg", - "tot": "jsonata" + "p": "topic", + "vt": "str" } ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 650, - "y": 1100, - "wires": [ - [ - "4255d678e6b1a913", - "dcc5a797823a45a1", - "bec1c77eb24511de", - "5ebdb2911c7f8cec", - "3dd3ba5f79fbf5a7" - ] - ] - }, - { - "id": "4255d678e6b1a913", - "type": "ui-text", - "z": "a796bfad8ab76fe4", - "group": "29e5d13e29bfbb4b", - "order": 12, - "width": 0, - "height": 0, - "name": "resultado_cartociudad", - "label": "Resultado Cartociudad: ", - "format": "{{msg.payload}}", - "layout": "row-left", - "style": false, - "font": "", - "fontSize": 16, - "color": "#717171", - "wrapText": false, - "className": "", - "value": "resultado_cartociudad", - "valueType": "msg", - "x": 920, - "y": 1100, - "wires": [] - }, - { - "id": "bec1c77eb24511de", - "type": "ui-button", - "z": "a796bfad8ab76fe4", - "group": "29e5d13e29bfbb4b", - "name": "Validar", - "label": "Validar", - "order": 11, - "width": 0, - "height": 0, - "emulateClick": false, - "tooltip": "", - "color": "", - "bgcolor": "", - "className": "", - "icon": "", - "iconPosition": "left", - "payload": "validando_direccion", - "payloadType": "flow", - "topic": "topic", - "topicType": "msg", - "buttonColor": "", - "textColor": "", - "iconColor": "", - "enableClick": true, - "enablePointerdown": false, - "pointerdownPayload": "", - "pointerdownPayloadType": "str", - "enablePointerup": false, - "pointerupPayload": "", - "pointerupPayloadType": "str", - "x": 870, - "y": 1140, - "wires": [ - [ - "36c4d29cd8bb931c" - ] - ] - }, - { - "id": "5ebdb2911c7f8cec", - "type": "ui-button", - "z": "a796bfad8ab76fe4", - "group": "29e5d13e29bfbb4b", - "name": "Eliminar", - "label": "Eliminar", - "order": 9, - "width": 0, - "height": 0, - "emulateClick": false, - "tooltip": "", - "color": "", - "bgcolor": "", - "className": "", - "icon": "", - "iconPosition": "left", - "payload": "validando_direccion", - "payloadType": "flow", - "topic": "topic", - "topicType": "msg", - "buttonColor": "", - "textColor": "", - "iconColor": "", - "enableClick": true, - "enablePointerdown": false, - "pointerdownPayload": "", - "pointerdownPayloadType": "str", - "enablePointerup": false, - "pointerupPayload": "", - "pointerupPayloadType": "str", - "x": 880, - "y": 1180, - "wires": [ - [ - "282609e0a8a595e7" - ] - ] - }, - { - "id": "931dfde533b77924", - "type": "change", - "z": "a796bfad8ab76fe4", - "name": "reset", - "rules": [ - { - "t": "set", - "p": "trigger", - "pt": "msg", - "to": "true", - "tot": "bool" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 330, - "y": 1160, - "wires": [ - [ - "1d6863142aee9387" - ] - ] - }, - { - "id": "36c4d29cd8bb931c", - "type": "link out", - "z": "a796bfad8ab76fe4", - "name": "OUT - Validado", - "mode": "link", - "links": [ - "9e2a81ef52b0c2d2", - "0f4165650f826238" - ], - "x": 955, - "y": 1140, - "wires": [] - }, - { - "id": "9e2a81ef52b0c2d2", - "type": "link in", - "z": "a796bfad8ab76fe4", - "name": "IN - Validado", - "links": [ - "36c4d29cd8bb931c", - "c1a6d3e32d669058" - ], - "x": 285, - "y": 1420, - "wires": [ - [ - "2c1d536a860b099e", - "ee3b382fec9125f9" - ] - ] - }, - { - "id": "22e91d97b48287ac", - "type": "debug", - "z": "a796bfad8ab76fe4", - "name": "GUARDA geocache", - "active": false, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1080, - "y": 1380, - "wires": [] - }, - { - "id": "183f81d1ad8abb3f", - "type": "debug", - "z": "a796bfad8ab76fe4", - "name": "ACTUALIZA Calles", - "active": false, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1070, - "y": 1440, - "wires": [] - }, - { - "id": "f521d21d39f94c81", - "type": "debug", - "z": "a796bfad8ab76fe4", - "name": "INSERTADO EN SIN DATOS", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1280, - "y": 2940, - "wires": [] - }, - { - "id": "be21eaa7c3594803", - "type": "debug", - "z": "a796bfad8ab76fe4", - "name": "BORRADOS", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1530, - "y": 3040, - "wires": [] - }, - { - "id": "01486ff2b815efdc", - "type": "debug", - "z": "a796bfad8ab76fe4", - "name": "CONSULTA CALLE", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1390, - "y": 3100, - "wires": [] - }, - { - "id": "45bf0a36274043c1", - "type": "debug", - "z": "a796bfad8ab76fe4", - "name": "ELIMINAR CALLES", - "active": false, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1020, - "y": 1580, - "wires": [] - }, - { - "id": "a75d78af573442dc", - "type": "change", - "z": "a796bfad8ab76fe4", - "name": "Actualizamos los datos de las calles mal codificadas", - "rules": [ - { - "t": "set", - "p": "operation", - "pt": "msg", - "to": "updateMany", - "tot": "str" - }, - { - "t": "set", - "p": "collection", - "pt": "msg", - "to": "servicios_consolidado_calle_filtrado", - "tot": "str" - }, - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "[\t {\t \"TipoVia\": $uppercase($flowContext(\"tipovia_original\")),\t \"Calle\": $uppercase($flowContext(\"calle_original\")),\t \"numero_retirada\": $flowContext(\"numero_retirada_original\"),\t \"Poblacion\": $uppercase($flowContext(\"poblacion_original\")),\t \"CP\": $flowContext(\"cp_original\")\t },\t {\t \"$set\": {\t \"TipoVia\": $uppercase($flowContext(\"tipovia\")),\t \"Calle\": $uppercase($flowContext(\"calle\")),\t \"numero_retirada\": $flowContext(\"numero_retirada\"),\t \"extra_calle\": $uppercase($flowContext(\"extra_calle\")),\t \"geocodingProcesado\": \"false\"\t }\t }\t]", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 680, - "y": 2680, - "wires": [ - [ - "71e6a918e85cbd07", - "94f0347ee6f32d6b" - ] - ] - }, - { - "id": "71e6a918e85cbd07", - "type": "mongodb4", - "z": "a796bfad8ab76fe4", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 970, - "y": 2680, - "wires": [ - [ - "19418aad3da76453" - ] - ] - }, - { - "id": "19418aad3da76453", - "type": "debug", - "z": "a796bfad8ab76fe4", - "name": "ACTUALIZADOS", - "active": false, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1150, - "y": 2680, - "wires": [] - }, - { - "id": "282609e0a8a595e7", - "type": "link out", - "z": "a796bfad8ab76fe4", - "name": "OUT - Cartociudad Eliminar", - "mode": "link", - "links": [ - "c741abf63475207c", - "0f4165650f826238" - ], - "x": 975, - "y": 1180, - "wires": [] - }, - { - "id": "c741abf63475207c", - "type": "link in", - "z": "a796bfad8ab76fe4", - "name": "IN - Eliminar", - "links": [ - "282609e0a8a595e7" - ], - "x": 225, - "y": 1580, - "wires": [ - [ - "e2ddb79b71bb9c44", - "4a449c21d82898f9" - ] - ] - }, - { - "id": "e2ddb79b71bb9c44", - "type": "change", - "z": "a796bfad8ab76fe4", - "name": "Actualizamos los datos de todas las calles que sean iguales", - "rules": [ - { - "t": "set", - "p": "operation", - "pt": "msg", - "to": "deleteMany", - "tot": "str" - }, - { - "t": "set", - "p": "collection", - "pt": "msg", - "to": "servicios_consolidado_calle_filtrado", - "tot": "str" - }, - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "[\t {\t \"TipoVia\": msg.direccion.TipoVia,\t \"Calle\": msg.direccion.Calle,\t \"numero_retirada\": msg.direccion.numero_retirada,\t \"Poblacion\": msg.direccion.Poblacion,\t \"CP\": msg.direccion.CP\t }\t]", - "tot": "jsonata" - }, - { - "t": "set", - "p": "consulta_realizada", - "pt": "msg", - "to": "payload", - "tot": "msg" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 520, - "y": 1580, - "wires": [ - [ - "2246878e7d3d7af2" - ] - ] - }, - { - "id": "2246878e7d3d7af2", - "type": "mongodb4", - "z": "a796bfad8ab76fe4", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 830, - "y": 1580, - "wires": [ - [ - "45bf0a36274043c1" - ] - ] - }, - { - "id": "4a449c21d82898f9", - "type": "change", - "z": "a796bfad8ab76fe4", - "name": "Guardamos lo datos de la referencia de cache en mongo", - "rules": [ - { - "t": "set", - "p": "operation", - "pt": "msg", - "to": "insertOne", - "tot": "str" - }, - { - "t": "set", - "p": "collection", - "pt": "msg", - "to": "geocache", - "tot": "str" - }, - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "{\t \"referencia_geocache\": referencia_geocache,\t \"accion\" : \"eliminar\"\t}", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 510, - "y": 1620, - "wires": [ - [ - "4eee84ac85459806" - ] - ] - }, - { - "id": "3dd3ba5f79fbf5a7", - "type": "ui-button", - "z": "a796bfad8ab76fe4", - "group": "29e5d13e29bfbb4b", - "name": "Tratar", - "label": "Tratar", - "order": 10, - "width": 0, - "height": 0, - "emulateClick": false, - "tooltip": "", - "color": "", - "bgcolor": "", - "className": "", - "icon": "", - "iconPosition": "left", - "payload": "validando_direccion", - "payloadType": "flow", - "topic": "topic", - "topicType": "msg", - "buttonColor": "", - "textColor": "", - "iconColor": "", - "enableClick": true, - "enablePointerdown": false, - "pointerdownPayload": "", - "pointerdownPayloadType": "str", - "enablePointerup": false, - "pointerupPayload": "", - "pointerupPayloadType": "str", - "x": 870, - "y": 1220, - "wires": [ - [ - "f9145f1a463f19ec" - ] - ] - }, - { - "id": "f9145f1a463f19ec", - "type": "link out", - "z": "a796bfad8ab76fe4", - "name": "link out 3", - "mode": "link", - "links": [ - "629bb3d5189f7e53", - "0f4165650f826238" - ], - "x": 975, - "y": 1220, - "wires": [] - }, - { - "id": "41c4984165a1b830", - "type": "ui-button", - "z": "a796bfad8ab76fe4", - "group": "29e5d13e29bfbb4b", - "name": "Liberar", - "label": "Liberar", - "order": 8, - "width": 0, - "height": 0, - "emulateClick": false, - "tooltip": "", - "color": "", - "bgcolor": "", - "className": "", - "icon": "", - "iconPosition": "left", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", "payload": "", "payloadType": "date", - "topic": "topic", - "topicType": "msg", - "buttonColor": "", - "textColor": "", - "iconColor": "", - "enableClick": true, - "enablePointerdown": false, - "pointerdownPayload": "", - "pointerdownPayloadType": "str", - "enablePointerup": false, - "pointerupPayload": "", - "pointerupPayloadType": "str", - "x": 880, - "y": 1260, + "x": 150, + "y": 60, "wires": [ [ - "3341669b8aca5958" + "73ca61629ca36cdb" ] ] }, { - "id": "3341669b8aca5958", - "type": "link out", - "z": "a796bfad8ab76fe4", - "name": "OUT - Liberar", - "mode": "link", - "links": [ - "0f4165650f826238" - ], - "x": 975, - "y": 1260, - "wires": [] - }, - { - "id": "0f4165650f826238", - "type": "link in", - "z": "a796bfad8ab76fe4", - "name": "IN - Liberar siguiente", - "links": [ - "36c4d29cd8bb931c", - "282609e0a8a595e7", - "f9145f1a463f19ec", - "3341669b8aca5958" - ], - "x": 235, - "y": 1160, - "wires": [ - [ - "931dfde533b77924" - ] - ] - }, - { - "id": "2b215b7870143e56", - "type": "ui-button", - "z": "a796bfad8ab76fe4", - "group": "2365cb156242b3e6", - "name": "Mostrar", - "label": "Mostrar", - "order": 8, - "width": 0, - "height": 0, - "emulateClick": false, - "tooltip": "", - "color": "", - "bgcolor": "", - "className": "", - "icon": "", - "iconPosition": "left", - "payload": "ultima_validacion", - "payloadType": "flow", - "topic": "topic", - "topicType": "msg", - "buttonColor": "", - "textColor": "", - "iconColor": "", - "enableClick": true, - "enablePointerdown": false, - "pointerdownPayload": "", - "pointerdownPayloadType": "str", - "enablePointerup": false, - "pointerupPayload": "", - "pointerupPayloadType": "str", - "x": 340, - "y": 2800, - "wires": [ - [ - "fbc6b6e11099f864", - "ee0c6a9d7d1aa05c" - ] - ] - }, - { - "id": "fbc6b6e11099f864", + "id": "67d9948a4ea561d0", "type": "debug", - "z": "a796bfad8ab76fe4", - "name": "Mostrar datos", + "z": "e3a070490bfdc383", + "g": "d31dc5ca65fdaec9", + "name": "BORRADO TABLA GEOSERVICES", "active": true, "tosidebar": true, "console": false, @@ -3863,117 +4299,17 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 540, - "y": 2800, + "x": 680, + "y": 60, "wires": [] }, { - "id": "f399ed6d081a0343", - "type": "ui-button", - "z": "a796bfad8ab76fe4", - "group": "2365cb156242b3e6", - "name": "Borrar", - "label": "Borrar", - "order": 1, - "width": 0, - "height": 0, - "emulateClick": false, - "tooltip": "", - "color": "", - "bgcolor": "", - "className": "", - "icon": "", - "iconPosition": "left", - "payload": "ultima_validacion", - "payloadType": "flow", - "topic": "topic", - "topicType": "msg", - "buttonColor": "", - "textColor": "", - "iconColor": "", - "enableClick": true, - "enablePointerdown": false, - "pointerdownPayload": "", - "pointerdownPayloadType": "str", - "enablePointerup": false, - "pointerupPayload": "", - "pointerupPayloadType": "str", - "x": 330, - "y": 2860, - "wires": [ - [ - "ee0c6a9d7d1aa05c", - "23d65be42ea9f363" - ] - ] - }, - { - "id": "23d65be42ea9f363", - "type": "change", - "z": "a796bfad8ab76fe4", - "name": "Borramos los datos de las calles mal codificadas", - "rules": [ - { - "t": "set", - "p": "operation", - "pt": "msg", - "to": "deleteMany", - "tot": "str" - }, - { - "t": "set", - "p": "collection", - "pt": "msg", - "to": "servicios_consolidado_calle_filtrado", - "tot": "str" - }, - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "[\t {\t \"TipoVia\": payload.direccion.TipoVia,\t \"Calle\": payload.direccion.Calle,\t \"numero_retirada\": payload.direccion.numero_retirada,\t \"Poblacion\": payload.direccion.Poblacion,\t \"CP\": payload.direccion.CP \t }\t]", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 640, - "y": 2860, - "wires": [ - [ - "95b1dd4f471bf039" - ] - ] - }, - { - "id": "95b1dd4f471bf039", - "type": "mongodb4", - "z": "a796bfad8ab76fe4", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 970, - "y": 2860, - "wires": [ - [ - "2d79b1d9949e3dd0" - ] - ] - }, - { - "id": "2d79b1d9949e3dd0", + "id": "9a2c00a3d18bf2e5", "type": "debug", - "z": "a796bfad8ab76fe4", - "name": "BORRADOS", - "active": false, + "z": "e3a070490bfdc383", + "g": "d31dc5ca65fdaec9", + "name": "CREACION TABLA GEOSERVICES", + "active": true, "tosidebar": true, "console": false, "tostatus": false, @@ -3981,287 +4317,123 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 1150, - "y": 2860, + "x": 690, + "y": 120, "wires": [] }, { - "id": "94f0347ee6f32d6b", - "type": "file", - "z": "a796bfad8ab76fe4", - "name": "", - "filename": "actualizacion_direcciones", - "filenameType": "str", - "appendNewline": true, - "createDir": false, - "overwriteFile": "false", - "encoding": "none", - "x": 1010, - "y": 2640, - "wires": [ - [] - ] - }, - { - "id": "0579fe31ed7de68e", - "type": "simple-queue", - "z": "a796bfad8ab76fe4", - "name": "", - "firstMessageBypass": false, - "bypassInterval": "0", - "x": 250, - "y": 1020, - "wires": [ - [ - "5c95290ed28a98cc" - ] - ] - }, - { - "id": "1d6863142aee9387", - "type": "simple-queue", - "z": "a796bfad8ab76fe4", - "name": "", - "firstMessageBypass": false, - "bypassInterval": "0", - "x": 450, - "y": 1020, - "wires": [ - [ - "d0df21d0eea0830f" - ] - ] - }, - { - "id": "356eeecb9e7fc0e3", - "type": "trigger", - "z": "a796bfad8ab76fe4", - "name": "Solo uno a tratar a la vez", - "op1": "", - "op2": "0", - "op1type": "pay", - "op2type": "str", - "duration": "0", - "extend": false, - "overrideDelay": false, - "units": "ms", - "reset": "", - "bytopic": "all", - "topic": "topic", - "outputs": 1, - "x": 670, - "y": 1060, - "wires": [ - [] - ] - }, - { - "id": "8f57171dbb68e9cc", + "id": "476541d607d59b6d", "type": "function", - "z": "a796bfad8ab76fe4", - "name": "Eliminamos los que son coincidentes para no tener que tratarlos manualmente", - "func": "// Función para normalizar texto (elimina acentos y convierte a mayúsculas)\nfunction normalizarTexto(texto) {\n return texto.toString()\n .normalize(\"NFD\")\n .replace(/[\\u0300-\\u036f]/g, \"\")\n .toUpperCase()\n .trim();\n}\n\n// Comparación con normalización de address y province\nconst addressCoincide = normalizarTexto(msg.payload.address) === normalizarTexto(msg.direccion.Calle);\nconst provinceCoincide = normalizarTexto(msg.payload.province) === normalizarTexto(msg.direccion.Poblacion);\n\nif (addressCoincide && provinceCoincide) {\n return [null, msg]; // Salida 2 - coinciden\n} else {\n return [msg, null]; // Salida 1 - no coinciden\n}", - "outputs": 2, + "z": "e3a070490bfdc383", + "g": "4de20a7676e67ad3", + "name": "Reducción de los datos", + "func": "// Guardamos el _id para la paginación\nflow.set(\"ultimo_id\", msg.payload._id)\n\n// Reducimos la cantidad de datos\nmsg.payload = {\n id_servicio: msg.payload.id_servicio,\n fecha_entrada: msg.payload.fecha_entrada,\n fecha_servicio: msg.payload.fecha_servicio,\n codigo_grua: msg.payload.codigo_grua,\n tipo_servicio: msg.payload.TipoServicio,\n lat: msg.payload.latitud,\n lon: msg.payload.longitud\n};\n\n// Preparamos la inserción en la base de datos\nmsg.valores = [msg.payload.id_servicio,\n msg.payload.fecha_entrada, \n msg.payload.fecha_servicio,\n msg.payload.codigo_grua, \n msg.payload.tipo_servicio,\n msg.payload.lat,\n msg.payload.lon,\n ]\n\nreturn msg;\n", + "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 540, - "y": 980, + "x": 210, + "y": 520, "wires": [ [ - "1d6863142aee9387" - ], - [ - "c1a6d3e32d669058" + "18055db6bd0e0c9e" ] ] }, { - "id": "c1a6d3e32d669058", - "type": "link out", - "z": "a796bfad8ab76fe4", - "name": "link out 4", - "mode": "link", - "links": [ - "9e2a81ef52b0c2d2" - ], - "x": 895, - "y": 1020, + "id": "3004fd9c1a92c8e1", + "type": "postgresql", + "z": "e3a070490bfdc383", + "g": "4de20a7676e67ad3", + "name": "Insertar datos", + "query": "{{{msg.query}}}", + "postgreSQLConfig": "748b5921246ec468", + "split": false, + "rowsPerMsg": 1, + "outputs": 1, + "x": 180, + "y": 580, + "wires": [ + [ + "7fb03d67431947cc" + ] + ] + }, + { + "id": "ead3b611059e050e", + "type": "postgresql", + "z": "e3a070490bfdc383", + "g": "d31dc5ca65fdaec9", + "name": "Forzamos que no se inserten duplicados", + "query": "ALTER TABLE servicios_geo\nADD CONSTRAINT servicios_geo_id_servicio_uk UNIQUE (id_servicio);", + "postgreSQLConfig": "748b5921246ec468", + "split": false, + "rowsPerMsg": 1, + "outputs": 1, + "x": 380, + "y": 180, + "wires": [ + [ + "e2c241981eb9d22d" + ] + ] + }, + { + "id": "e2c241981eb9d22d", + "type": "debug", + "z": "e3a070490bfdc383", + "g": "d31dc5ca65fdaec9", + "name": "CREACION DEL INDICE", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "statusVal": "", + "statusType": "auto", + "x": 670, + "y": 180, "wires": [] }, { - "id": "a66d44720bfed89d", - "type": "link in", - "z": "6e1ee0f06e75580d", - "name": "Entrada Cartociudad 2", - "links": [ - "d1035ff8c39cd84c" - ], - "x": 205, - "y": 40, - "wires": [ - [ - "88517c37afc36dd8" - ] - ] - }, - { - "id": "3bb66c22727588c3", - "type": "switch", - "z": "6e1ee0f06e75580d", - "name": "Accion que se hace según la consulta", - "property": "payload.accion", - "propertyType": "msg", - "rules": [ + "id": "6a8444fa71237276", + "type": "inject", + "z": "e3a070490bfdc383", + "g": "d31dc5ca65fdaec9", + "name": "Activar", + "props": [ { - "t": "eq", - "v": "validado", + "p": "payload" + }, + { + "p": "topic", "vt": "str" - }, - { - "t": "eq", - "v": "eliminar", - "vt": "str" - }, - { - "t": "else" } ], - "checkall": "true", - "repair": false, - "outputs": 3, - "x": 530, - "y": 500, + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 150, + "y": 180, "wires": [ [ - "a23bb95e94319218" - ], - [ - "3e23306582382edc" - ], - [ - "fd8b53ea98c67e93" - ] - ], - "outputLabels": [ - "Se actuliza el valor de la calle", - "Se borra la calle", - "Se estudia" - ] - }, - { - "id": "88517c37afc36dd8", - "type": "split", - "z": "6e1ee0f06e75580d", - "name": "", - "splt": "\\n", - "spltType": "str", - "arraySplt": 1, - "arraySpltType": "len", - "stream": false, - "addname": "", - "property": "payload", - "x": 290, - "y": 40, - "wires": [ - [ - "022364dc0148870e" + "ead3b611059e050e" ] ] }, { - "id": "022364dc0148870e", - "type": "delay", - "z": "6e1ee0f06e75580d", - "name": "", - "pauseType": "rate", - "timeout": "5", - "timeoutUnits": "seconds", - "rate": "1", - "nbRateUnits": "1", - "rateUnits": "second", - "randomFirst": "1", - "randomLast": "5", - "randomUnits": "seconds", - "drop": false, - "allowrate": false, - "outputs": 1, - "x": 440, - "y": 40, - "wires": [ - [ - "65d4baca6edf0fbd" - ] - ] - }, - { - "id": "65d4baca6edf0fbd", + "id": "87a50279e182879c", "type": "change", - "z": "6e1ee0f06e75580d", - "name": "Generamos referencia_geocache y consulta_calle", - "rules": [ - { - "t": "set", - "p": "referencia_geocache", - "pt": "msg", - "to": "$join(\t $filter(\t [\t payload.TipoVia,\t payload.Calle,\t payload.numero_retirada,\t payload.Poblacion,\t payload.CP\t ],\t function($v){ $v != null and $v != \"\" }\t ),\t \",\"\t)", - "tot": "jsonata" - }, - { - "t": "set", - "p": "consulta_calle", - "pt": "msg", - "to": "$join(\t $filter(\t [\t payload.TipoVia,\t payload.Calle,\t (payload.numero_retirada = \"sn\" or payload.numero_retirada = \"SN\" or payload.numero_retirada = \"0\") ? undefined : payload.numero_retirada,\t payload.Poblacion,\t payload.extra_calle\t ],\t function($v){ $v != null and $v != \"\" }\t ),\t \" \"\t)", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 430, - "y": 100, - "wires": [ - [ - "c106948998237652" - ] - ] - }, - { - "id": "c106948998237652", - "type": "change", - "z": "6e1ee0f06e75580d", - "name": "Copiamos la dirección en dirección para consultas posteriores", - "rules": [ - { - "t": "set", - "p": "direccion", - "pt": "msg", - "to": "payload", - "tot": "msg" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 470, - "y": 140, - "wires": [ - [ - "45144d8953fb168a" - ] - ] - }, - { - "id": "45144d8953fb168a", - "type": "change", - "z": "6e1ee0f06e75580d", - "name": "Creamos la consulta de referencia_geocache", + "z": "e3a070490bfdc383", + "g": "4de20a7676e67ad3", + "name": "Preparación de la Consulta", "rules": [ { "t": "set", @@ -4270,112 +4442,6 @@ "to": "find", "tot": "str" }, - { - "t": "set", - "p": "collection", - "pt": "msg", - "to": "geocache", - "tot": "str" - }, - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "[{ \"referencia_geocache\": { \"$eq\": msg.referencia_geocache }}]", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 410, - "y": 180, - "wires": [ - [ - "d4531a5b62fccd5a" - ] - ] - }, - { - "id": "d4531a5b62fccd5a", - "type": "mongodb4", - "z": "6e1ee0f06e75580d", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 670, - "y": 180, - "wires": [ - [ - "c6d1ee72149ef4da" - ] - ] - }, - { - "id": "c6d1ee72149ef4da", - "type": "switch", - "z": "6e1ee0f06e75580d", - "name": "Existe la calle en el cache?", - "property": "$count(payload)", - "propertyType": "jsonata", - "rules": [ - { - "t": "eq", - "v": "0", - "vt": "num" - }, - { - "t": "else" - } - ], - "checkall": "true", - "repair": false, - "outputs": 2, - "x": 180, - "y": 240, - "wires": [ - [ - "fe421b6180fe2f15" - ], - [ - "f04f31bb7e647ab7" - ] - ], - "outputLabels": [ - "NO", - "SI" - ] - }, - { - "id": "ff1fa52c7fb6436d", - "type": "comment", - "z": "6e1ee0f06e75580d", - "name": "Si existe la referencia se actualiza", - "info": "", - "x": 480, - "y": 240, - "wires": [] - }, - { - "id": "f04f31bb7e647ab7", - "type": "change", - "z": "6e1ee0f06e75580d", - "name": "Actualizamos los datos de todas las calles que sean iguales", - "rules": [ - { - "t": "set", - "p": "operation", - "pt": "msg", - "to": "updateMany", - "tot": "str" - }, { "t": "set", "p": "collection", @@ -4383,11 +4449,18 @@ "to": "servicios_consolidado_calle_filtrado", "tot": "str" }, + { + "t": "set", + "p": "limit", + "pt": "msg", + "to": "10000", + "tot": "num" + }, { "t": "set", "p": "payload", "pt": "msg", - "to": "[\t {\t \"TipoVia\": direccion.TipoVia,\t \"Calle\": direccion.Calle\t },\t {\t \"$set\": {\t \"latitud\": payload[0].lat,\t \"longitud\": payload[0].lon,\t \"geocodingProcesado\": true\t } \t }\t]", + "to": "[\t {\t \"latitud\": { \"$ne\": null },\t \"_id\": { \"$gt\": msg.ultimo_id }\t },\t { \"limit\": msg.limit }\t]", "tot": "jsonata" } ], @@ -4397,65 +4470,76 @@ "to": "", "reg": false, "x": 560, - "y": 280, + "y": 460, "wires": [ [ - "2142cf292ba4dece" + "a5da07eb95be391c" ] ] }, { - "id": "2142cf292ba4dece", - "type": "mongodb4", - "z": "6e1ee0f06e75580d", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 870, - "y": 280, - "wires": [ - [ - "1be09b79f432c626" - ] - ] - }, - { - "id": "1be09b79f432c626", - "type": "debug", - "z": "6e1ee0f06e75580d", - "name": "CACHE", - "active": false, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1020, - "y": 280, - "wires": [] - }, - { - "id": "a5cf9bb1543ccbdf", - "type": "comment", - "z": "6e1ee0f06e75580d", - "name": "No existe la referencia", - "info": "", - "x": 440, - "y": 320, - "wires": [] - }, - { - "id": "fe421b6180fe2f15", + "id": "038afe42a8815a88", "type": "change", - "z": "6e1ee0f06e75580d", - "name": "Buscarmos la calle en la base de datos de consulta_calle", + "z": "e3a070490bfdc383", + "g": "4de20a7676e67ad3", + "name": "", + "rules": [ + { + "t": "set", + "p": "ultimo_id", + "pt": "flow", + "to": "payload", + "tot": "msg" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 570, + "y": 340, + "wires": [ + [] + ] + }, + { + "id": "7762d2d91d6e863e", + "type": "inject", + "z": "e3a070490bfdc383", + "g": "4de20a7676e67ad3", + "name": "Activar Migración datos primer documento", + "props": [ + { + "p": "payload" + }, + { + "p": "ultimo_id", + "v": "ultimo_id", + "vt": "flow" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": "1", + "topic": "", + "payload": "", + "payloadType": "date", + "x": 260, + "y": 400, + "wires": [ + [ + "a10c4585f88c77cd" + ] + ] + }, + { + "id": "a10c4585f88c77cd", + "type": "change", + "z": "e3a070490bfdc383", + "g": "4de20a7676e67ad3", + "name": "Preparación de la Consulta", "rules": [ { "t": "set", @@ -4464,112 +4548,6 @@ "to": "find", "tot": "str" }, - { - "t": "set", - "p": "collection", - "pt": "msg", - "to": "consulta_calle", - "tot": "str" - }, - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "[{ \"consulta_calle \": { \"$eq\": msg.consulta_calle }}]", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 550, - "y": 360, - "wires": [ - [ - "f98d50aac4fce670" - ] - ] - }, - { - "id": "f98d50aac4fce670", - "type": "mongodb4", - "z": "6e1ee0f06e75580d", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 850, - "y": 360, - "wires": [ - [ - "385b936f30611065" - ] - ] - }, - { - "id": "385b936f30611065", - "type": "switch", - "z": "6e1ee0f06e75580d", - "name": "Existe la calle en consulta_calle?", - "property": "$count(payload)", - "propertyType": "jsonata", - "rules": [ - { - "t": "eq", - "v": "0", - "vt": "num" - }, - { - "t": "else" - } - ], - "checkall": "true", - "repair": false, - "outputs": 2, - "x": 200, - "y": 460, - "wires": [ - [ - "d6db349d1646634d" - ], - [ - "3bb66c22727588c3" - ] - ], - "outputLabels": [ - "NO", - "SI" - ] - }, - { - "id": "841cb88a7b666a63", - "type": "comment", - "z": "6e1ee0f06e75580d", - "name": "Si existe la calle", - "info": "", - "x": 460, - "y": 440, - "wires": [] - }, - { - "id": "a23bb95e94319218", - "type": "change", - "z": "6e1ee0f06e75580d", - "name": "Actualizamos los datos de todas las calles que sean iguales", - "rules": [ - { - "t": "set", - "p": "operation", - "pt": "msg", - "to": "updateMany", - "tot": "str" - }, { "t": "set", "p": "collection", @@ -4577,11 +4555,18 @@ "to": "servicios_consolidado_calle_filtrado", "tot": "str" }, + { + "t": "set", + "p": "limit", + "pt": "msg", + "to": "1", + "tot": "num" + }, { "t": "set", "p": "payload", "pt": "msg", - "to": "[\t {\t \"TipoVia\": msg.direccion.TipoVia,\t \"Calle\": msg.direccion.Calle,\t \"numero_retirada\": msg.direccion.numero_retirada,\t \"Poblacion\": msg.direccion.Poblacion,\t \"CP\": msg.direccion.CP \t\t },\t {\t \"$set\": {\t \"latitud\": msg.payload.lat,\t \"longitud\": msg.payload.lon,\t \"geocodingProcesado\": true\t } \t }\t]", + "to": "[\t {\t \"latitud\": { \"$ne\": null },\t \"_id\": { \"$gt\": msg.ultimo_id }\t },\t { \"limit\": msg.limit }\t]", "tot": "jsonata" } ], @@ -4590,19 +4575,121 @@ "from": "", "to": "", "reg": false, - "x": 940, - "y": 460, + "x": 580, + "y": 400, "wires": [ [ - "041c57934c647e2c" + "a5da07eb95be391c" ] ] }, { - "id": "041c57934c647e2c", + "id": "b2e8c6b462cf2f7d", + "type": "inject", + "z": "e3a070490bfdc383", + "g": "4de20a7676e67ad3", + "name": "Incializamos el primer documento de mongo", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": "0.5", + "topic": "", + "payload": "000000000000000000000000", + "payloadType": "str", + "x": 270, + "y": 340, + "wires": [ + [ + "038afe42a8815a88" + ] + ] + }, + { + "id": "7fb03d67431947cc", + "type": "switch", + "z": "e3a070490bfdc383", + "g": "4de20a7676e67ad3", + "name": "Filtramos los mensajes de los ya insertados", + "property": "pgsql.rowCount", + "propertyType": "msg", + "rules": [ + { + "t": "neq", + "v": "0", + "vt": "num" + } + ], + "checkall": "true", + "repair": false, + "outputs": 1, + "x": 510, + "y": 580, + "wires": [ + [ + "e6f2786536d9be1b" + ] + ] + }, + { + "id": "5f0c5f162625d887", + "type": "inject", + "z": "e3a070490bfdc383", + "g": "d31dc5ca65fdaec9", + "name": "Activar", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 150, + "y": 240, + "wires": [ + [ + "8873bca38bac80d8" + ] + ] + }, + { + "id": "8873bca38bac80d8", + "type": "postgresql", + "z": "e3a070490bfdc383", + "g": "d31dc5ca65fdaec9", + "name": "Incrementamos el número de conexiones simultaneas", + "query": "ALTER SYSTEM SET max_connections = 1000", + "postgreSQLConfig": "748b5921246ec468", + "split": false, + "rowsPerMsg": 1, + "outputs": 1, + "x": 420, + "y": 240, + "wires": [ + [ + "ef69861ea0631cf5" + ] + ] + }, + { + "id": "ef69861ea0631cf5", "type": "debug", - "z": "6e1ee0f06e75580d", - "name": "IGUALES - VALIDADO", + "z": "e3a070490bfdc383", + "g": "d31dc5ca65fdaec9", + "name": "MAXIMOS CONEXIONES", "active": true, "tosidebar": true, "console": false, @@ -4611,15 +4698,112 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 1280, - "y": 460, + "x": 750, + "y": 240, "wires": [] }, { - "id": "3e23306582382edc", + "id": "18055db6bd0e0c9e", + "type": "join", + "z": "e3a070490bfdc383", + "g": "4de20a7676e67ad3", + "name": "", + "mode": "custom", + "build": "array", + "property": "valores", + "propertyType": "msg", + "key": "topic", + "joiner": "\\n", + "joinerType": "str", + "useparts": false, + "accumulate": false, + "timeout": "", + "count": "5000", + "reduceRight": false, + "reduceExp": "", + "reduceInit": "", + "reduceInitType": "", + "reduceFixup": "", + "x": 400, + "y": 520, + "wires": [ + [ + "182765735c8a1a54" + ] + ] + }, + { + "id": "4aa92b63a45c740c", + "type": "function", + "z": "e3a070490bfdc383", + "g": "4de20a7676e67ad3", + "name": "Preparamos el insert masivo", + "func": "let paramsArray = msg.valores;\n\nconst formatDate = d => {\n let date = new Date(d);\n return `'${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}'`;\n}\n\n// Generamos el VALUES para cada fila\nlet values = paramsArray.map(p => {\n return `('${p[0]}', ${formatDate(p[1])}, ${formatDate(p[2])}, '${p[3]}', '${p[4]}', ST_SetSRID(ST_Point('${p[5]}', '${p[6]}'), 4326))`;\n}).filter(v => v !== null);\n\nmsg.query = `\nINSERT INTO servicios_geo (\n id_servicio,\n fecha_entrada,\n fecha_servicio,\n codigo_grua,\n tipo_servicio,\n geom\n)\nVALUES\n${values.join(\",\\n\")}\nON CONFLICT (id_servicio) DO NOTHING;\n`;\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 800, + "y": 520, + "wires": [ + [ + "3004fd9c1a92c8e1" + ] + ] + }, + { + "id": "9253b85aa1fceedf", + "type": "inject", + "z": "e3a070490bfdc383", + "g": "7bdac83e314d285e", + "name": "Consulta 10 Valores", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 190, + "y": 680, + "wires": [ + [ + "c6996972638e189e" + ] + ] + }, + { + "id": "c6996972638e189e", + "type": "postgresql", + "z": "e3a070490bfdc383", + "g": "7bdac83e314d285e", + "name": "10 Valores", + "query": "SELECT *\nFROM servicios_geo\nLIMIT 10;", + "postgreSQLConfig": "748b5921246ec468", + "split": false, + "rowsPerMsg": 1, + "outputs": 1, + "x": 510, + "y": 680, + "wires": [ + [ + "b76b66ac4b8871d6" + ] + ] + }, + { + "id": "b76b66ac4b8871d6", "type": "debug", - "z": "6e1ee0f06e75580d", - "name": "ELIMINAR", + "z": "e3a070490bfdc383", + "g": "7bdac83e314d285e", + "name": "CONSULTAS", "active": true, "tosidebar": true, "console": false, @@ -4628,41 +4812,60 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 790, - "y": 500, - "wires": [] - }, - { - "id": "fd8b53ea98c67e93", - "type": "debug", - "z": "6e1ee0f06e75580d", - "name": "TRATAR", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 780, - "y": 540, - "wires": [] - }, - { - "id": "4d69a180d5f58f10", - "type": "comment", - "z": "6e1ee0f06e75580d", - "name": "No existe la calle", - "info": "", - "x": 140, + "x": 800, "y": 680, "wires": [] }, { - "id": "d6db349d1646634d", + "id": "10f31f95a520c2c2", + "type": "postgresql", + "z": "e3a070490bfdc383", + "g": "7bdac83e314d285e", + "name": "Totales", + "query": "SELECT COUNT(*) FROM servicios_geo;", + "postgreSQLConfig": "748b5921246ec468", + "split": false, + "rowsPerMsg": 1, + "outputs": 1, + "x": 500, + "y": 740, + "wires": [ + [ + "b76b66ac4b8871d6" + ] + ] + }, + { + "id": "95219fda1586a59b", + "type": "inject", + "z": "e3a070490bfdc383", + "g": "7bdac83e314d285e", + "name": "Consulta Número de registros", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 220, + "y": 740, + "wires": [ + [ + "10f31f95a520c2c2" + ] + ] + }, + { + "id": "182765735c8a1a54", "type": "delay", - "z": "6e1ee0f06e75580d", + "z": "e3a070490bfdc383", + "g": "4de20a7676e67ad3", "name": "", "pauseType": "rate", "timeout": "5", @@ -4676,747 +4879,11 @@ "drop": false, "allowrate": false, "outputs": 1, - "x": 140, - "y": 720, + "x": 580, + "y": 520, "wires": [ [ - "007603e6138d3767" - ] - ] - }, - { - "id": "007603e6138d3767", - "type": "function", - "z": "6e1ee0f06e75580d", - "name": "Generamos la consulta a Cartociudad", - "func": "// msg.payload debe contener la dirección, ej. \"Calle Gran Vía 28, Madrid\"\nconst direccion = msg.consulta_calle;\nconst encoded = encodeURIComponent(direccion);\n\nmsg.original = msg.payload\n// API de CartoCiudad (gratuita España)\nmsg.method = \"GET\";\nmsg.url = `https://www.cartociudad.es/geocoder/api/geocoder/findJsonp?q=${encoded}`;\nreturn msg;\n", - "outputs": 1, - "timeout": 0, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 390, - "y": 720, - "wires": [ - [ - "1eb4a654a71a42b1" - ] - ] - }, - { - "id": "1eb4a654a71a42b1", - "type": "http request", - "z": "6e1ee0f06e75580d", - "name": "", - "method": "use", - "ret": "txt", - "paytoqs": "ignore", - "url": "", - "tls": "", - "persist": false, - "proxy": "", - "insecureHTTPParser": false, - "authType": "", - "senderr": false, - "headers": [], - "x": 630, - "y": 720, - "wires": [ - [ - "ea87880ca13d9dcb" - ] - ] - }, - { - "id": "ea87880ca13d9dcb", - "type": "function", - "z": "6e1ee0f06e75580d", - "name": "Filtramos el resultado", - "func": "// Limpia la respuesta JSONP (callback(...))\nlet text = msg.payload.trim();\n\n// Detecta y elimina el formato \"callback(...)\" o \"callback123(...)\" u otros\ntext = text.replace(/^[a-zA-Z0-9_]+\\(/, '').replace(/\\);?$/, '');\n\nlet data;\ntry {\n data = JSON.parse(text);\n} catch (e) {\n node.error(\"Error al parsear JSON de CartoCiudad: \" + e.message);\n msg.payload = { error: \"Formato no válido de respuesta CartoCiudad\" };\n return msg;\n}\n\n// La API devuelve un solo objeto, no un array\nif (data && data.lat && data.lng) {\n msg.payload = {\n lat: data.lat,\n lon: data.lng,\n address: data.address || \"\",\n postalCode: data.postalCode || \"\",\n muni: data.muni || \"\",\n province: data.province || \"\",\n source: \"CartoCiudad\",\n raw: data\n };\n} else {\n msg.payload = { error: \"No se encontraron coordenadas en CartoCiudad\" };\n}\nreturn msg;\n", - "outputs": 1, - "timeout": 0, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 820, - "y": 720, - "wires": [ - [ - "6c45fdd52d5b4bd3" - ] - ] - }, - { - "id": "6c45fdd52d5b4bd3", - "type": "switch", - "z": "6e1ee0f06e75580d", - "name": "Existen datos?", - "property": "payload.lat", - "propertyType": "msg", - "rules": [ - { - "t": "istype", - "v": "undefined", - "vt": "undefined" - }, - { - "t": "else" - } - ], - "checkall": "true", - "repair": false, - "outputs": 2, - "x": 1020, - "y": 720, - "wires": [ - [ - "9c7e15d6d339c983" - ], - [ - "98b02584803dbcbb" - ] - ], - "outputLabels": [ - "NO", - "SI" - ] - }, - { - "id": "98b02584803dbcbb", - "type": "function", - "z": "6e1ee0f06e75580d", - "name": "Eliminamos los que son coincidentes para no tener que tratarlos manualmente", - "func": "// Función para normalizar texto (elimina acentos y convierte a mayúsculas)\nfunction normalizarTexto(texto) {\n return texto.toString()\n .normalize(\"NFD\")\n .replace(/[\\u0300-\\u036f]/g, \"\")\n .toUpperCase()\n .trim();\n}\n\n// Comparación con normalización de address y province\nconst addressCoincide = normalizarTexto(msg.payload.address) === normalizarTexto(msg.direccion.Calle);\nconst provinceCoincide = normalizarTexto(msg.payload.province) === normalizarTexto(msg.direccion.Poblacion);\n\nif (addressCoincide && provinceCoincide) {\n return [null, msg]; // Salida 2 - coinciden\n} else {\n return [msg, null]; // Salida 1 - no coinciden\n}", - "outputs": 2, - "timeout": 0, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 520, - "y": 840, - "wires": [ - [ - "5eccd6a9a750b549" - ], - [ - "3f24b62573b3963b", - "c3ce306882f3d6ab" - ] - ], - "outputLabels": [ - "NO ", - "SI" - ] - }, - { - "id": "3f24b62573b3963b", - "type": "change", - "z": "6e1ee0f06e75580d", - "name": "Guardamos lo datos de la referencia de cache en mongo", - "rules": [ - { - "t": "set", - "p": "operation", - "pt": "msg", - "to": "insertOne", - "tot": "str" - }, - { - "t": "set", - "p": "collection", - "pt": "msg", - "to": "geocache", - "tot": "str" - }, - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "{\t \"referencia_geocache\": referencia_geocache,\t \"lat\": payload.lat,\t \"lon\": payload.lon,\t \"address\": payload.address,\t \"muni\": payload.muni,\t \"province\": payload.province\t}", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 1110, - "y": 860, - "wires": [ - [ - "78c4804a3d71aca2" - ] - ] - }, - { - "id": "78c4804a3d71aca2", - "type": "mongodb4", - "z": "6e1ee0f06e75580d", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 1430, - "y": 860, - "wires": [ - [ - "08ef481b73ada20e" - ] - ] - }, - { - "id": "ac3e7005ee6ca8b4", - "type": "mongodb4", - "z": "6e1ee0f06e75580d", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 1430, - "y": 920, - "wires": [ - [ - "27fbbc6c04034efc" - ] - ] - }, - { - "id": "c3ce306882f3d6ab", - "type": "change", - "z": "6e1ee0f06e75580d", - "name": "Actualizamos los datos de todas las calles que sean iguales", - "rules": [ - { - "t": "set", - "p": "operation", - "pt": "msg", - "to": "updateMany", - "tot": "str" - }, - { - "t": "set", - "p": "collection", - "pt": "msg", - "to": "servicios_consolidado_calle_filtrado", - "tot": "str" - }, - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "[\t {\t \"TipoVia\": msg.direccion.TipoVia,\t \"Calle\": msg.direccion.Calle\t },\t {\t \"$set\": {\t \"latitud\": msg.payload.lat,\t \"longitud\": msg.payload.lon,\t \"geocodingProcesado\": true,\t \"cartociudad\": \"coincidente\"\t } \t }\t]", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 1120, - "y": 920, - "wires": [ - [ - "ac3e7005ee6ca8b4" - ] - ] - }, - { - "id": "08ef481b73ada20e", - "type": "debug", - "z": "6e1ee0f06e75580d", - "name": "GUARDA geocache", - "active": false, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1620, - "y": 860, - "wires": [] - }, - { - "id": "27fbbc6c04034efc", - "type": "debug", - "z": "6e1ee0f06e75580d", - "name": "ACTUALIZA Calles", - "active": false, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1610, - "y": 920, - "wires": [] - }, - { - "id": "5eccd6a9a750b549", - "type": "change", - "z": "6e1ee0f06e75580d", - "name": "Actualizamos los datos de todas las calles que sean iguales", - "rules": [ - { - "t": "set", - "p": "operation", - "pt": "msg", - "to": "updateMany", - "tot": "str" - }, - { - "t": "set", - "p": "collection", - "pt": "msg", - "to": "servicios_consolidado_calle_filtrado", - "tot": "str" - }, - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "[\t {\t \"TipoVia\": msg.direccion.TipoVia,\t \"Calle\": msg.direccion.Calle,\t \"numero_retirada\": msg.direccion.numero_retirada,\t \"Poblacion\": msg.direccion.Poblacion,\t \"CP\": msg.direccion.CP\t },\t {\t \"$set\": {\t \"cartociudad\": \"no-coincidente\"\t } \t }\t]", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 1120, - "y": 800, - "wires": [ - [ - "31a9908c794f385c" - ] - ] - }, - { - "id": "31a9908c794f385c", - "type": "mongodb4", - "z": "6e1ee0f06e75580d", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 1430, - "y": 800, - "wires": [ - [ - "1fac0a438c4df552" - ] - ] - }, - { - "id": "1fac0a438c4df552", - "type": "debug", - "z": "6e1ee0f06e75580d", - "name": "Pone no coincidente en cartociudad", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1660, - "y": 800, - "wires": [] - }, - { - "id": "9c7e15d6d339c983", - "type": "change", - "z": "6e1ee0f06e75580d", - "name": "Actualizamos los datos de todas las calles que sean iguales", - "rules": [ - { - "t": "set", - "p": "operation", - "pt": "msg", - "to": "updateMany", - "tot": "str" - }, - { - "t": "set", - "p": "collection", - "pt": "msg", - "to": "servicios_consolidado_calle_filtrado", - "tot": "str" - }, - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "[\t {\t \"TipoVia\": msg.direccion.TipoVia,\t \"Calle\": msg.direccion.Calle,\t \"numero_retirada\": msg.direccion.numero_retirada,\t \"Poblacion\": msg.direccion.Poblacion,\t \"CP\": msg.direccion.CP\t },\t {\t \"$set\": {\t \"cartociudad\": \"no-coincidente\"\t } \t }\t]", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 1360, - "y": 700, - "wires": [ - [ - "819f4993eed99959" - ] - ] - }, - { - "id": "819f4993eed99959", - "type": "mongodb4", - "z": "6e1ee0f06e75580d", - "clientNode": "648a51546e4dadc6", - "mode": "collection", - "collection": "", - "operation": "", - "output": "toArray", - "maxTimeMS": "0", - "handleDocId": false, - "name": "", - "x": 1670, - "y": 700, - "wires": [ - [ - "711cd5bb325a7107" - ] - ] - }, - { - "id": "711cd5bb325a7107", - "type": "debug", - "z": "6e1ee0f06e75580d", - "name": "Pone no coincidente en cartociudad", - "active": false, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1900, - "y": 700, - "wires": [] - }, - { - "id": "99e57e3e0c9feda3", - "type": "change", - "z": "6e1ee0f06e75580d", - "name": "reset", - "rules": [ - { - "t": "set", - "p": "trigger", - "pt": "msg", - "to": "true", - "tot": "bool" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 590, - "y": 1080, - "wires": [ - [ - "c91b4ba4c01b3d11" - ] - ] - }, - { - "id": "c91b4ba4c01b3d11", - "type": "simple-queue", - "z": "6e1ee0f06e75580d", - "name": "", - "firstMessageBypass": false, - "bypassInterval": "0", - "x": 610, - "y": 1040, - "wires": [ - [ - "374eb1d0ce2a0c27" - ] - ] - }, - { - "id": "374eb1d0ce2a0c27", - "type": "change", - "z": "6e1ee0f06e75580d", - "name": "Genera resultado_cartociudad", - "rules": [ - { - "t": "set", - "p": "resultado_cartociudad", - "pt": "msg", - "to": "payload.address& \" \" &payload.raw.portalNumber& \" \" &payload.muni& \" \" &payload.province& \" \" &payload.postalCode", - "tot": "jsonata" - }, - { - "t": "set", - "p": "actualizar", - "pt": "msg", - "to": "payload", - "tot": "msg" - }, - { - "t": "set", - "p": "validando_direccion", - "pt": "flow", - "to": "msg", - "tot": "jsonata" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 830, - "y": 1040, - "wires": [ - [ - "dc1aec7696d95a97", - "843fbe4881603a6c", - "faacde234e5acc0e", - "abccb8a853c9f234", - "426c5e09624cff47" - ] - ] - }, - { - "id": "843fbe4881603a6c", - "type": "ui-text", - "z": "6e1ee0f06e75580d", - "group": "29e5d13e29bfbb4b", - "order": 2, - "width": 0, - "height": 0, - "name": "consulta_calle", - "label": "Consulta Calle: ", - "format": "{{msg.payload}}", - "layout": "row-left", - "style": false, - "font": "", - "fontSize": 16, - "color": "#717171", - "wrapText": false, - "className": "", - "value": "consulta_calle", - "valueType": "msg", - "x": 1080, - "y": 1040, - "wires": [] - }, - { - "id": "dc1aec7696d95a97", - "type": "ui-text", - "z": "6e1ee0f06e75580d", - "group": "29e5d13e29bfbb4b", - "order": 3, - "width": 0, - "height": 0, - "name": "resultado_cartociudad", - "label": "Resultado Cartociudad: ", - "format": "{{msg.payload}}", - "layout": "row-left", - "style": false, - "font": "", - "fontSize": 16, - "color": "#717171", - "wrapText": false, - "className": "", - "value": "resultado_cartociudad", - "valueType": "msg", - "x": 1100, - "y": 1080, - "wires": [] - }, - { - "id": "faacde234e5acc0e", - "type": "ui-button", - "z": "6e1ee0f06e75580d", - "group": "29e5d13e29bfbb4b", - "name": "Validar", - "label": "Validar", - "order": 4, - "width": 0, - "height": 0, - "emulateClick": false, - "tooltip": "", - "color": "", - "bgcolor": "", - "className": "", - "icon": "", - "iconPosition": "left", - "payload": "validando_direccion", - "payloadType": "flow", - "topic": "topic", - "topicType": "msg", - "buttonColor": "", - "textColor": "", - "iconColor": "", - "enableClick": true, - "enablePointerdown": false, - "pointerdownPayload": "", - "pointerdownPayloadType": "str", - "enablePointerup": false, - "pointerupPayload": "", - "pointerupPayloadType": "str", - "x": 1050, - "y": 1120, - "wires": [ - [] - ] - }, - { - "id": "abccb8a853c9f234", - "type": "ui-button", - "z": "6e1ee0f06e75580d", - "group": "29e5d13e29bfbb4b", - "name": "Eliminar", - "label": "Eliminar", - "order": 6, - "width": 0, - "height": 0, - "emulateClick": false, - "tooltip": "", - "color": "", - "bgcolor": "", - "className": "", - "icon": "", - "iconPosition": "left", - "payload": "validando_direccion", - "payloadType": "flow", - "topic": "topic", - "topicType": "msg", - "buttonColor": "", - "textColor": "", - "iconColor": "", - "enableClick": true, - "enablePointerdown": false, - "pointerdownPayload": "", - "pointerdownPayloadType": "str", - "enablePointerup": false, - "pointerupPayload": "", - "pointerupPayloadType": "str", - "x": 1060, - "y": 1160, - "wires": [ - [] - ] - }, - { - "id": "426c5e09624cff47", - "type": "ui-button", - "z": "6e1ee0f06e75580d", - "group": "29e5d13e29bfbb4b", - "name": "Tratar", - "label": "Tratar", - "order": 5, - "width": 0, - "height": 0, - "emulateClick": false, - "tooltip": "", - "color": "", - "bgcolor": "", - "className": "", - "icon": "", - "iconPosition": "left", - "payload": "validando_direccion", - "payloadType": "flow", - "topic": "topic", - "topicType": "msg", - "buttonColor": "", - "textColor": "", - "iconColor": "", - "enableClick": true, - "enablePointerdown": false, - "pointerdownPayload": "", - "pointerdownPayloadType": "str", - "enablePointerup": false, - "pointerupPayload": "", - "pointerupPayloadType": "str", - "x": 1050, - "y": 1200, - "wires": [ - [] - ] - }, - { - "id": "5af76acc28d81750", - "type": "ui-button", - "z": "6e1ee0f06e75580d", - "group": "29e5d13e29bfbb4b", - "name": "Liberar", - "label": "Liberar", - "order": 7, - "width": 0, - "height": 0, - "emulateClick": false, - "tooltip": "", - "color": "", - "bgcolor": "", - "className": "", - "icon": "", - "iconPosition": "left", - "payload": "", - "payloadType": "date", - "topic": "topic", - "topicType": "msg", - "buttonColor": "", - "textColor": "", - "iconColor": "", - "enableClick": true, - "enablePointerdown": false, - "pointerdownPayload": "", - "pointerdownPayloadType": "str", - "enablePointerup": false, - "pointerupPayload": "", - "pointerupPayloadType": "str", - "x": 1060, - "y": 1240, - "wires": [ - [] - ] - }, - { - "id": "0d6f32bdc24ffd32", - "type": "link in", - "z": "6e1ee0f06e75580d", - "name": "link in 2", - "links": [], - "x": 505, - "y": 1080, - "wires": [ - [ - "99e57e3e0c9feda3" + "4aa92b63a45c740c" ] ] } diff --git a/flows_cred.json b/flows_cred.json index 4b9a0b5..561b227 100644 --- a/flows_cred.json +++ b/flows_cred.json @@ -1,3 +1,3 @@ { - "$": "641bf374ff8390650b5f4c357f38db8fGkqji6Zj3U+gA3NLqrgOt171kyGZGWvclVDvlKxvLEsLfjn/ZZO9k2Ssjn+RC8WbixGMPUEYA+gRpphzwWapIXM2s+7bXuA9rFBcOULlDfCIqvmIZoR2F3LO85zn035uzFLuJnJ70vx+0c5swss8avrqk+NWKze4caDkIR/lYepjgpMPl4z2cM7K2qJ7RWKuIov7" + "$": "7d6b4df600c2bc915ab6db77bf1035d1Hd6qj5XHzQ5PYu4d3NKHaMQLsMs5Xargt0i2/Foze2SyfPeRnV9bIwqINsfGj0+0O8KaLb+slDjPAXhkWKR+nR3uZz1xwj563ftCvCZom9GaGWeEBkUn0CVHxvP9bqnsv9DZ+nw9yjZmoMYoF7GD0+g5aMrrrsTrmeX6f8o=" } \ No newline at end of file