1689 lines
52 KiB
JSON
1689 lines
52 KiB
JSON
[
|
|
{
|
|
"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": 450,
|
|
"y": 640,
|
|
"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": 180,
|
|
"y": 640,
|
|
"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": 220,
|
|
"y": 700,
|
|
"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": 320,
|
|
"y": 760,
|
|
"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": 410,
|
|
"y": 700,
|
|
"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": 630,
|
|
"y": 760,
|
|
"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": 700,
|
|
"y": 640,
|
|
"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": 790,
|
|
"y": 700,
|
|
"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\", \"CONSOLIDADO\"] }] },\n Calle: { $ifNull: [\"$Calle1\", { $ifNull: [\"$Calle2\", \"CONSOLIDADO\"] }] },\n Poblacion: { $ifNull: [\"$Poblacion1\", { $ifNull: [\"$Poblacion2\", \"CONSOLIDADO\"] }] },\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\", \"CONSOLIDADO\"] } },\n { $expr: { $ne: [\"$Poblacion\", \"CONSOLIDADO\"] } },\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": 490,
|
|
"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": 680,
|
|
"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": 820,
|
|
"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": "360",
|
|
"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": 860,
|
|
"y": 640,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "c29fc5be5de649c4",
|
|
"type": "inject",
|
|
"z": "1a4b40705122dc91",
|
|
"name": "Activación - Recuperar geoposiciones de CartoCiudad",
|
|
"props": [
|
|
{
|
|
"p": "payload"
|
|
},
|
|
{
|
|
"p": "topic",
|
|
"vt": "str"
|
|
}
|
|
],
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.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": 460,
|
|
"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": 460,
|
|
"wires": [
|
|
[
|
|
"004948a143b907dd"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "004948a143b907dd",
|
|
"type": "mongodb4",
|
|
"z": "1a4b40705122dc91",
|
|
"clientNode": "648a51546e4dadc6",
|
|
"mode": "collection",
|
|
"collection": "",
|
|
"operation": "",
|
|
"output": "toArray",
|
|
"maxTimeMS": "0",
|
|
"handleDocId": false,
|
|
"name": "Consulta",
|
|
"x": 680,
|
|
"y": 460,
|
|
"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": 860,
|
|
"y": 460,
|
|
"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": 500,
|
|
"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": "5",
|
|
"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": [
|
|
[
|
|
"4063e875162c944d"
|
|
],
|
|
[
|
|
"59f364d9feca28e5"
|
|
]
|
|
],
|
|
"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": 655,
|
|
"y": 180,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "59f364d9feca28e5",
|
|
"type": "link out",
|
|
"z": "a796bfad8ab76fe4",
|
|
"name": "OUT - Error",
|
|
"mode": "link",
|
|
"links": [],
|
|
"x": 655,
|
|
"y": 220,
|
|
"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": "true",
|
|
"targetType": "full",
|
|
"statusVal": "",
|
|
"statusType": "auto",
|
|
"x": 930,
|
|
"y": 300,
|
|
"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": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"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 === \"GLORIETA PATINES MADRID\") {\n msg.cambio.calle = \"DE LOS NEVEROS\";\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\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}",
|
|
"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": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"statusVal": "",
|
|
"statusType": "auto",
|
|
"x": 890,
|
|
"y": 780,
|
|
"wires": []
|
|
}
|
|
] |