[ { "id": "1a4b40705122dc91", "type": "tab", "label": "ETL", "disabled": false, "info": "", "env": [] }, { "id": "a796bfad8ab76fe4", "type": "tab", "label": "Cartociudad", "disabled": false, "info": "", "env": [] }, { "id": "a3043505f409dd12", "type": "group", "z": "1a4b40705122dc91", "name": "ETL - Exportación", "style": { "stroke": "#000000", "fill": "#ffffbf", "label": true, "label-position": "n", "color": "#000000" }, "nodes": [ "da1a19e474be7c21", "5750be6f324be5da", "40b5904a3022e5eb", "4ef62ad77f7d4652", "2a46f606e21ec6b3", "08e53863f9d0559f", "6eb9b5543808fedb" ], "x": 14, "y": 19, "w": 892, "h": 202 }, { "id": "db09bd514ed7c061", "type": "MSSQL-CN", "tdsVersion": "7_3_B", "name": "Gruassql", "server": "10.5.14.245", "port": "1433", "encyption": false, "trustServerCertificate": true, "database": "madrid_movilidad", "useUTC": true, "connectTimeout": "15000", "requestTimeout": "15000", "cancelTimeout": "5000", "pool": "5", "parseJSON": false, "enableArithAbort": true, "readOnlyIntent": false }, { "id": "748b5921246ec468", "type": "postgreSQLConfig", "name": "PostGIS", "host": "10.10.5.32", "hostFieldType": "str", "port": 5432, "portFieldType": "num", "database": "postgres", "databaseFieldType": "str", "ssl": "false", "sslFieldType": "bool", "applicationName": "", "applicationNameType": "str", "max": "500", "maxFieldType": "num", "idle": "10000", "idleFieldType": "num", "connectionTimeout": "30000", "connectionTimeoutFieldType": "num", "user": "postgres", "userFieldType": "str", "password": "tfmuocdfcarvajal", "passwordFieldType": "str" }, { "id": "648a51546e4dadc6", "type": "mongodb4-client", "name": "localhost", "protocol": "mongodb", "hostname": "10.10.11.211", "port": "27017", "dbName": "Volcado", "appName": "", "authSource": "", "authMechanism": "DEFAULT", "tls": false, "tlsCAFile": "", "tlsCertificateKeyFile": "", "tlsInsecure": false, "connectTimeoutMS": "30000", "socketTimeoutMS": "0", "minPoolSize": "0", "maxPoolSize": "100", "maxIdleTimeMS": "0", "uri": "", "advanced": "{}", "uriTabActive": "tab-uri-simple" }, { "id": "da1a19e474be7c21", "type": "MSSQL", "z": "1a4b40705122dc91", "g": "a3043505f409dd12", "mssqlCN": "db09bd514ed7c061", "name": "GruasSQL - Query Servicios", "outField": "payload", "returnType": 0, "throwErrors": 1, "query": "", "modeOpt": "queryMode", "modeOptType": "query", "queryOpt": "query", "queryOptType": "msg", "paramsOpt": "", "paramsOptType": "none", "rows": "rows", "rowsType": "msg", "parseMustache": true, "params": [], "x": 700, "y": 120, "wires": [ [ "6eb9b5543808fedb" ] ] }, { "id": "5750be6f324be5da", "type": "function", "z": "1a4b40705122dc91", "g": "a3043505f409dd12", "name": "Query para la exportación de datos de SQL", "func": "msg.query =`\nSELECT \n s.id AS id_servicio,\n s.id_vehiculo,\n v.matricula,\n v.fecha_entrada,\n s.fecha AS fecha_servicio,\n g.codigo_grua,\n ts.nombre AS TipoServicio,\n s.id_ubicacion_origen,\n altechs.latitud,\n altechs.longitud,\n altechs.calleRetirada_descripcion AS altech_calleRetirada_descripcion,\n altechs.calleRetirada_numero AS altech_calleRetirada_numero,\n s.id_calle_retirada,\n s.numero_retirada,\n via1.tipo AS TipoVia1,\n cp1.nombre AS Calle1,\n poblac1.poblacion AS Poblacion1,\n cp1.cp as cp1,\n via2.tipo AS TipoVia2,\n cp2.nombre AS Calle2,\n poblac2.poblacion AS Poblacion2,\n cp2.cp as cp2\nFROM Vista_UnionServicios s\nLEFT JOIN Vista_UnionVehiculos v ON v.id = s.id_vehiculo\nLEFT JOIN AltechAltaServicio altechs ON altechs.idVehiculo = s.id_vehiculo\nLEFT JOIN TC_Tipos_Servicio ts ON ts.id = s.id_tipo\nLEFT JOIN TC_Gruas g ON g.id_grua = s.id_grua\nLEFT JOIN CodPostal cp1 ON s.id_calle_retirada = cp1.id\nLEFT JOIN CodPostal_t cp2 ON s.id_calle_retirada2 = cp2.id\nLEFT JOIN codvia via1 ON via1.id = cp1.id_tipovia\nLEFT JOIN codvia via2 ON via2.id = cp2.id_tipo_v\nLEFT JOIN codpob poblac1 ON poblac1.id = cp1.id_pobl\nLEFT JOIN codpob_t poblac2 ON poblac2.id = cp2.id_pobl\nWHERE YEAR(s.fecha) = ${msg.payload}\nORDER BY s.fecha\n`;\n\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 390, "y": 120, "wires": [ [ "da1a19e474be7c21" ] ] }, { "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": 880, "wires": [ [ "535b18bcfc71f9cd" ] ], "info": "Sin limitación - 33095\r\nPosicion no nula - 31943" }, { "id": "40b5904a3022e5eb", "type": "function", "z": "1a4b40705122dc91", "g": "a3043505f409dd12", "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) * 10000);\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": 130, "y": 120, "wires": [ [ "5750be6f324be5da" ] ] }, { "id": "4ef62ad77f7d4652", "type": "inject", "z": "1a4b40705122dc91", "g": "a3043505f409dd12", "name": "Activación - Exportación de los datos de SQL", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 230, "y": 60, "wires": [ [ "40b5904a3022e5eb" ] ] }, { "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": 880, "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": 940, "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": 1000, "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": 940, "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": 1000, "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": 880, "wires": [] }, { "id": "2a46f606e21ec6b3", "type": "debug", "z": "1a4b40705122dc91", "g": "a3043505f409dd12", "name": "Debug inserción Mongo", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 750, "y": 180, "wires": [] }, { "id": "08e53863f9d0559f", "type": "mongodb4", "z": "1a4b40705122dc91", "g": "a3043505f409dd12", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", "operation": "", "output": "toArray", "maxTimeMS": "0", "handleDocId": false, "name": "Importación Mongo", "x": 530, "y": 180, "wires": [ [ "2a46f606e21ec6b3" ] ] }, { "id": "6eb9b5543808fedb", "type": "function", "z": "1a4b40705122dc91", "g": "a3043505f409dd12", "name": "Añadimos valores para la importación a mongo", "func": "let msg_new = {};\nmsg_new.payload = [msg.payload];\nmsg_new.collection = \"servicios_sin_filtrar\";\nmsg_new.operation = \"insertMany\";\n\nreturn msg_new;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 240, "y": 180, "wires": [ [ "08e53863f9d0559f" ] ] }, { "id": "acae736839e9942c", "type": "postgresql", "z": "1a4b40705122dc91", "name": "", "query": "SELECT * FROM ;", "postgreSQLConfig": "748b5921246ec468", "split": false, "rowsPerMsg": 1, "outputs": 1, "x": 770, "y": 940, "wires": [ [] ] }, { "id": "683191909606de5f", "type": "inject", "z": "1a4b40705122dc91", "name": "Activación - Consulta valores sin geoposición", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 230, "y": 280, "wires": [ [ "b8576a74c9e3cc75" ] ] }, { "id": "c8a4cd4a752e245e", "type": "mongodb4", "z": "1a4b40705122dc91", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", "operation": "", "output": "toArray", "maxTimeMS": "0", "handleDocId": false, "name": "Consulta", "x": 720, "y": 280, "wires": [ [ "3f28cc2972ec801e" ] ] }, { "id": "3f28cc2972ec801e", "type": "debug", "z": "1a4b40705122dc91", "name": "Resultado", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 860, "y": 280, "wires": [] }, { "id": "b8576a74c9e3cc75", "type": "function", "z": "1a4b40705122dc91", "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, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 530, "y": 280, "wires": [ [ "c8a4cd4a752e245e" ] ] }, { "id": "0f7838df86c0daa7", "type": "inject", "z": "1a4b40705122dc91", "name": "Activación - Consolidación calles (Coalescing)", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 230, "y": 340, "wires": [ [ "75602bbc0592e19f" ] ] }, { "id": "75602bbc0592e19f", "type": "function", "z": "1a4b40705122dc91", "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, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 530, "y": 340, "wires": [ [ "0fc524aa3713e49b" ] ] }, { "id": "0fc524aa3713e49b", "type": "mongodb4", "z": "1a4b40705122dc91", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", "operation": "", "output": "toArray", "maxTimeMS": "0", "handleDocId": false, "name": "Consulta", "x": 720, "y": 340, "wires": [ [ "3b087174de36c2d9" ] ] }, { "id": "3b087174de36c2d9", "type": "debug", "z": "1a4b40705122dc91", "name": "Resultado", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 860, "y": 340, "wires": [] }, { "id": "2c04e52c4cba3c98", "type": "inject", "z": "1a4b40705122dc91", "name": "Activación - Eliminar servicios sin calle", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 210, "y": 400, "wires": [ [ "df02d3cd352aff6f" ] ] }, { "id": "df02d3cd352aff6f", "type": "function", "z": "1a4b40705122dc91", "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, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 530, "y": 400, "wires": [ [ "693f1f1fcfc09699" ] ] }, { "id": "693f1f1fcfc09699", "type": "mongodb4", "z": "1a4b40705122dc91", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", "operation": "", "output": "toArray", "maxTimeMS": "0", "handleDocId": false, "name": "Consulta", "x": 720, "y": 400, "wires": [ [ "9cc523b662f53ded" ] ] }, { "id": "9cc523b662f53ded", "type": "debug", "z": "1a4b40705122dc91", "name": "Resultado", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 860, "y": 400, "wires": [] }, { "id": "4250b98e85f30aa3", "type": "change", "z": "1a4b40705122dc91", "name": "Preparación de la Consulta", "rules": [ { "t": "set", "p": "operation", "pt": "msg", "to": "find", "tot": "str" }, { "t": "set", "p": "collection", "pt": "msg", "to": "servicios_consolidado_calle_filtrado", "tot": "str" }, { "t": "set", "p": "limit", "pt": "msg", "to": "500", "tot": "num" }, { "t": "set", "p": "payload", "pt": "msg", "to": "[{ \"geocodingProcesado\": { \"$ne\": true } }, { \"limit\" : msg.limit }]", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 620, "y": 580, "wires": [ [ "4af6fd0defd481ea" ] ] }, { "id": "4af6fd0defd481ea", "type": "mongodb4", "z": "1a4b40705122dc91", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", "operation": "", "output": "toArray", "maxTimeMS": "0", "handleDocId": false, "name": "", "x": 830, "y": 580, "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": 880, "wires": [] }, { "id": "c29fc5be5de649c4", "type": "inject", "z": "1a4b40705122dc91", "name": "Activación - Recuperar geoposiciones de CartoCiudad", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": true, "onceDelay": "1", "topic": "", "payload": "", "payloadType": "date", "x": 260, "y": 580, "wires": [ [ "4250b98e85f30aa3" ] ] }, { "id": "4644d386e752575d", "type": "link out", "z": "1a4b40705122dc91", "name": "link out 1", "mode": "link", "links": [ "ec0a560685f299d8" ], "x": 935, "y": 580, "wires": [] }, { "id": "c6894593daa8fcf0", "type": "inject", "z": "1a4b40705122dc91", "name": "Activación - Normalizaciones", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 180, "y": 660, "wires": [ [ "d66163bb05e6f12e", "8081ba55b8146814" ] ] }, { "id": "d66163bb05e6f12e", "type": "change", "z": "1a4b40705122dc91", "name": "numero_retirada de \"SN \" a \"SN\"", "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 \"numero_retirada\": \"SN \"\t },\t {\t \"$set\": {\t \"numero_retirada\": \"SN\"\t } \t }\t]", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 460, "y": 660, "wires": [ [ "004948a143b907dd" ] ] }, { "id": "004948a143b907dd", "type": "mongodb4", "z": "1a4b40705122dc91", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", "operation": "", "output": "toArray", "maxTimeMS": "0", "handleDocId": false, "name": "Consulta", "x": 720, "y": 660, "wires": [ [ "bb5ad864c986b15f" ] ] }, { "id": "bb5ad864c986b15f", "type": "debug", "z": "1a4b40705122dc91", "name": "Resultado (4 cambios)", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 900, "y": 660, "wires": [] }, { "id": "8081ba55b8146814", "type": "change", "z": "1a4b40705122dc91", "name": "numero_retirada de \"SQ\" a \"SN\"", "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 \"numero_retirada\": \"SQ\"\t },\t {\t \"$set\": {\t \"numero_retirada\": \"SN\"\t } \t }\t]", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 450, "y": 700, "wires": [ [ "004948a143b907dd" ] ] }, { "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": 310, "y": 300, "wires": [ [ "c58559633003fc35" ] ] }, { "id": "c58559633003fc35", "type": "http request", "z": "a796bfad8ab76fe4", "name": "", "method": "use", "ret": "txt", "paytoqs": "ignore", "url": "", "tls": "", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [], "x": 230, "y": 340, "wires": [ [ "c2879b84c754c37d" ] ] }, { "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": 420, "y": 340, "wires": [ [ "3a02a4797e73bfe2" ] ] }, { "id": "ec0a560685f299d8", "type": "link in", "z": "a796bfad8ab76fe4", "name": "link in 1", "links": [ "4644d386e752575d" ], "x": 165, "y": 20, "wires": [ [ "5621fbd41709d68e" ] ] }, { "id": "1c10577fa4beb771", "type": "delay", "z": "a796bfad8ab76fe4", "name": "", "pauseType": "rate", "timeout": "5", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "2", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "allowrate": false, "outputs": 1, "x": 400, "y": 20, "wires": [ [ "d3881558e6fef33f" ] ] }, { "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", "type": "change", "z": "a796bfad8ab76fe4", "name": "Generamos las referencias y la consulta de la 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 = \"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": 390, "y": 80, "wires": [ [ "3112772543b09bd9" ] ] }, { "id": "3112772543b09bd9", "type": "change", "z": "a796bfad8ab76fe4", "name": "Guardamos la dirección y creamos la consulta en el cache", "rules": [ { "t": "set", "p": "direccion", "pt": "msg", "to": "payload", "tot": "msg" }, { "t": "set", "p": "operation", "pt": "msg", "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 } }, { \"limit\" : msg.limit }]", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 410, "y": 140, "wires": [ [ "67310a0b495f77a2" ] ] }, { "id": "67310a0b495f77a2", "type": "mongodb4", "z": "a796bfad8ab76fe4", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", "operation": "", "output": "toArray", "maxTimeMS": "0", "handleDocId": false, "name": "", "x": 270, "y": 200, "wires": [ [ "304f30478bb9e954" ] ] }, { "id": "304f30478bb9e954", "type": "switch", "z": "a796bfad8ab76fe4", "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": 480, "y": 200, "wires": [ [ "b176ccfcb67d19a0" ], [ "2432622b4a8371d9" ] ], "outputLabels": [ "NO", "SI" ] }, { "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": 620, "y": 340, "wires": [ [ "74306aa17eeb2b5e", "0b0d1db5adb29e98" ], [ "25a80352d25475a2" ] ], "outputLabels": [ "NO", "SI" ] }, { "id": "2c1d536a860b099e", "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": "{ \"referencia_geocache\": referencia_geocache, \"lat\": payload.lat, \"lon\": payload.lon}", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 370, "y": 460, "wires": [ [ "aa8980407983e089" ] ] }, { "id": "aa8980407983e089", "type": "mongodb4", "z": "a796bfad8ab76fe4", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", "operation": "", "output": "toArray", "maxTimeMS": "0", "handleDocId": false, "name": "", "x": 690, "y": 460, "wires": [ [] ] }, { "id": "a37d6875203d3cef", "type": "mongodb4", "z": "a796bfad8ab76fe4", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", "operation": "", "output": "toArray", "maxTimeMS": "0", "handleDocId": false, "name": "", "x": 690, "y": 540, "wires": [ [] ] }, { "id": "ee3b382fec9125f9", "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": 380, "y": 540, "wires": [ [ "a37d6875203d3cef" ] ] }, { "id": "4063e875162c944d", "type": "link out", "z": "a796bfad8ab76fe4", "name": "OUT - Procesar", "mode": "link", "links": [ "717811bdd780a620" ], "x": 835, "y": 200, "wires": [] }, { "id": "717811bdd780a620", "type": "link in", "z": "a796bfad8ab76fe4", "name": "IN - Procesar", "links": [ "4063e875162c944d" ], "x": 105, "y": 300, "wires": [ [ "1fd044cbc45e1620" ] ] }, { "id": "25a80352d25475a2", "type": "link out", "z": "a796bfad8ab76fe4", "name": "OUT - Actualizar servicios", "mode": "link", "links": [ "a5b95491428a914b" ], "x": 755, "y": 380, "wires": [] }, { "id": "a5b95491428a914b", "type": "link in", "z": "a796bfad8ab76fe4", "name": "IN - Actualizar servicios", "links": [ "25a80352d25475a2" ], "x": 105, "y": 500, "wires": [ [ "ee3b382fec9125f9", "2c1d536a860b099e" ] ] }, { "id": "74306aa17eeb2b5e", "type": "debug", "z": "a796bfad8ab76fe4", "name": "Error de datos de cartociudad", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "consulta_calle", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 890, "y": 340, "wires": [] }, { "id": "96d63073d4c3043e", "type": "change", "z": "a796bfad8ab76fe4", "name": "Actualizamos los datos de la calle afectada por la memoria histórica", "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 \"Calle\": msg.cambio.calle\t } \t }\t]", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 640, "y": 660, "wires": [ [ "5be9c850777e19f4" ] ] }, { "id": "5be9c850777e19f4", "type": "mongodb4", "z": "a796bfad8ab76fe4", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", "operation": "", "output": "toArray", "maxTimeMS": "0", "handleDocId": false, "name": "", "x": 970, "y": 660, "wires": [ [ "61bddcdd604826da" ] ] }, { "id": "0b0d1db5adb29e98", "type": "link out", "z": "a796bfad8ab76fe4", "name": "OUT - Fallos para Arreglar", "mode": "link", "links": [ "37f1c5b138623383", "e795e6d956e3180e" ], "x": 755, "y": 300, "wires": [] }, { "id": "37f1c5b138623383", "type": "link in", "z": "a796bfad8ab76fe4", "name": "IN - Memoria Historica", "links": [ "0b0d1db5adb29e98" ], "x": 105, "y": 660, "wires": [ [ "92e5a359bb49899f" ] ] }, { "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\n", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 260, "y": 660, "wires": [ [ "96d63073d4c3043e" ] ] }, { "id": "63bf04cd67af12fd", "type": "function", "z": "a796bfad8ab76fe4", "name": "Calles con Mala codificación", "func": "msg.cambio = msg.cambio || {};\n\n// Es una campa de recogida de vehículos de renting\nif (msg.consulta_calle === \"CAMINO SALOBRAL MADRID\") {\n msg.cambio.tipovia = \"Carretera\"\n msg.cambio.calle = \"Estación de Contenedores\";\n msg.cambio.numero_retirada = \"4\"\n return msg;\n}\n\n// Quitamos el kilometro\nif (msg.consulta_calle === \"CARRETERA VILLAVERDE KM 4.8 GETAFE\") {\n msg.cambio.numero_retirada = \"4\"\n return msg;\n}\n\n// Añadimos el codigo postal para que lo localice\nif (msg.consulta_calle === \"GLORIETA SANDRO PERTINI MADRID\") {\n msg.cambio.extra_calle = \"28043\"\n return msg;\n}\n\n// La plaza de Ciudad lineal no tiene carto, se cambia por alcala\nif (msg.consulta_calle === \"PLAZA CIUDAD LINEAL MADRID\") {\n msg.cambio.tipovia = \"CALLE\"\n msg.cambio.calle = \"ALCALA\";\n msg.cambio.numero_retirada = \"423\"\n return msg;\n}\n\n// Error de nombre\nif (msg.consulta_calle === \"CAMINO CABESTREROS 9 MADRID\") {\n msg.cambio.tipovia = \"CALLE\";\n msg.cambio.calle = \"CABESTREROS\";\n return msg;\n}\n\n// Error de nombre\nif (msg.consulta_calle === \"PLAZA CORREGIDOR CONDE DE MACEDA Y TABOADA MADRID\") {\n msg.cambio.calle = \"PICO DE LOS ARTILLEROS\";\n msg.cambio.tipovia = \"CALLE\"\n msg.cambio.calle = \"PICO DE LOS ARTILLEROS\";\n msg.cambio.numero_retirada = \"150\"\n return msg;\n}\n\n// Error de nombre\nif (msg.consulta_calle === \"AVENIDA AMERICA 2 FUENLABRADA\") {\n msg.cambio.numero_retirada = \"SN\"\n msg.cambio.extra_calle = \"2\"\n return msg;\n}\n\nif (msg.consulta_calle === \"AVENIDA AMERICA FUENLABRADA\") {\n msg.cambio.numero_retirada = \"SN\"\n msg.cambio.extra_calle = \"2\"\n return msg;\n}\n\n// Mala condificación\nif (msg.consulta_calle === \"CALLE TACONA COMISARÍA MADRID\") {\n msg.cambio.numero_retirada = \"33\"\n return msg;\n}\n\n// Mala condificación\nif (msg.consulta_calle === \"CALLE DOCTOR TOLOSA LATOUR FAROLA 62 MADRID\") {\n msg.cambio.numero_retirada = \"62\"\n return msg;\n}\n\n// Mala condificación\nif (msg.consulta_calle === \"PLAZA BARICHARA 4 MADRID\") {\n msg.cambio.tipovia = \"CALLE\"\n return msg;\n}\n\n// Mala condificación\nif (msg.consulta_calle === \"CALLE QUINTANAORTUÑO MADRID\") {\n msg.cambio.calle = \"QUINTANAPALLA\"\n return msg;\n}\n\n// Mala condificación\nif (msg.consulta_calle === \"CALLE GABRIEL MIRO 1 MADRID\") {\n msg.cambio.tipovia = \"PLAZA\"\n return msg;\n}\n\nif (msg.consulta_calle === \"CAMINO CABESTROS 9 MADRID\") {\n msg.cambio.tipovia = \"CALLE\";\n msg.cambio.calle = \"CABESTREROS\";\n return msg;\n}\n\nif (msg.consulta_calle === \"CALLE BENIMAMET FRENTE 6 MADRID\") {\n msg.cambio.tipovia = \"CALLE\";\n msg.cambio.numero_retirada = \"6\";\n return msg;\n}\n\nif (msg.consulta_calle === \"GLORIETA DE LOS NEVEROS MADRID\") {\n msg.cambio.tipovia = \"CALLE\";\n msg.cambio.calle = \"PUERTA DEL ANGEL\";\n msg.cambio.numero_retirada = \"10\";\n return msg;\n}\n\nif (msg.consulta_calle === \"PASEO GENERAL SAGARDIA RAMOS 21 MADRID\") {\n msg.cambio.tipovia = \"PLAZA\";\n return msg;\n}\n\nif (msg.consulta_calle === \"CALLE LUSCINDA FTE 7 MADRID\") {\n msg.cambio.numero_retirada = \"7\";\n return msg;\n}\n\nif (msg.consulta_calle === \"CAMINO LEÑEROS MADRID\") {\n msg.cambio.tipovia = \"CALLE\";\n return msg;\n}\n\nif (msg.consulta_calle === \"CALLE SANTIAGO RUISEÑOR MADRID\") {\n msg.cambio.tipovia = \"SANTIAGO RUSIÑOL\";\n return msg;\n}\n\n\nif (msg.consulta_calle === \"CALLE PARQUE FERIAL JUAN CARLOS I MADRID\") {\n msg.cambio.tipovia = \"VIA\";\n msg.cambio.calle = \"DUBLIN\";\n msg.cambio.numero_retirada = \"6\";\n return msg;\n}", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 260, "y": 720, "wires": [ [ "ddc2820a375bb8f6" ] ] }, { "id": "ddc2820a375bb8f6", "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\": 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 \"TipoVia\": msg.cambio.tipovia,\t \"Calle\": msg.cambio.calle,\t \"numero_retirada\": msg.cambio.numero_retirada,\t \"extra_calle\": msg.cambio.extra_calle\t }\t }\t]", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 680, "y": 720, "wires": [ [ "c9dfd4a858aeb687" ] ] }, { "id": "c9dfd4a858aeb687", "type": "mongodb4", "z": "a796bfad8ab76fe4", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", "operation": "", "output": "toArray", "maxTimeMS": "0", "handleDocId": false, "name": "", "x": 970, "y": 720, "wires": [ [ "61bddcdd604826da" ] ] }, { "id": "e795e6d956e3180e", "type": "link in", "z": "a796bfad8ab76fe4", "name": "IN - Mala codificación", "links": [ "0b0d1db5adb29e98" ], "x": 105, "y": 720, "wires": [ [ "63bf04cd67af12fd" ] ] }, { "id": "61bddcdd604826da", "type": "debug", "z": "a796bfad8ab76fe4", "name": "Información de servicios procesados", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1230, "y": 720, "wires": [] }, { "id": "a1f0210367ec78c3", "type": "debug", "z": "a796bfad8ab76fe4", "name": "debug 1", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1360, "y": 260, "wires": [] }, { "id": "b176ccfcb67d19a0", "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 ) {\n return [msg, null]\n} else {\n return [null, msg]\n}\n\n", "outputs": 2, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 720, "y": 180, "wires": [ [ "fa2e9116677470ca" ], [ "4063e875162c944d" ] ] }, { "id": "fa2e9116677470ca", "type": "change", "z": "a796bfad8ab76fe4", "name": "Peparamos el identificador de calle a borrar", "rules": [ { "t": "set", "p": "operation", "pt": "msg", "to": "deleteOne", "tot": "str" }, { "t": "set", "p": "collection", "pt": "msg", "to": "servicios_consolidado_calle_filtrado", "tot": "str" }, { "t": "set", "p": "payload", "pt": "msg", "to": "[\t {\t \"_id\": direccion._id\t }\t]", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 990, "y": 160, "wires": [ [ "4eee84ac85459806" ] ] }, { "id": "4eee84ac85459806", "type": "mongodb4", "z": "a796bfad8ab76fe4", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", "operation": "", "output": "toArray", "maxTimeMS": "0", "handleDocId": false, "name": "", "x": 1250, "y": 160, "wires": [ [ "61bddcdd604826da" ] ] }, { "id": "2432622b4a8371d9", "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\": 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]", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 900, "y": 260, "wires": [ [ "f33442e9c3fb97aa" ] ] }, { "id": "f33442e9c3fb97aa", "type": "mongodb4", "z": "a796bfad8ab76fe4", "clientNode": "648a51546e4dadc6", "mode": "collection", "collection": "", "operation": "", "output": "toArray", "maxTimeMS": "0", "handleDocId": false, "name": "", "x": 1210, "y": 260, "wires": [ [ "a1f0210367ec78c3" ] ] } ]