Files
SQL_to_Postgis/flows.json

4890 lines
129 KiB
JSON

[
{
"id": "1a4b40705122dc91",
"type": "tab",
"label": "ETL",
"disabled": false,
"info": "",
"env": []
},
{
"id": "6e1ee0f06e75580d",
"type": "tab",
"label": "Cartociudad",
"disabled": false,
"info": "",
"env": []
},
{
"id": "e3a070490bfdc383",
"type": "tab",
"label": "Mongo a PostGIS",
"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": "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",
"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": "mongodb",
"protocol": "mongodb",
"hostname": "10.10.5.33",
"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": "15fe39abe7f560b2",
"type": "ui-base",
"name": "My Dashboard",
"path": "/dashboard",
"appIcon": "",
"includeClientData": true,
"acceptsClientConfig": [
"ui-notification",
"ui-control"
],
"showPathInSidebar": false,
"headerContent": "page",
"navigationStyle": "default",
"titleBarStyle": "default",
"showReconnectNotification": true,
"notificationDisplayTime": 1,
"showDisconnectNotification": true,
"allowInstall": false
},
{
"id": "423c5b5820f88c05",
"type": "ui-theme",
"name": "Default Theme",
"colors": {
"surface": "#ffffff",
"primary": "#0094CE",
"bgPage": "#eeeeee",
"groupBg": "#ffffff",
"groupOutline": "#cccccc"
},
"sizes": {
"density": "default",
"pagePadding": "12px",
"groupGap": "12px",
"groupBorderRadius": "4px",
"widgetGap": "12px"
}
},
{
"id": "d5367e576f526ae9",
"type": "ui-page",
"name": "Gestor manual de posicionamiento",
"ui": "15fe39abe7f560b2",
"path": "/page1",
"icon": "home",
"layout": "grid",
"theme": "423c5b5820f88c05",
"breakpoints": [
{
"name": "Default",
"px": "0",
"cols": "3"
},
{
"name": "Tablet",
"px": "576",
"cols": "6"
},
{
"name": "Small Desktop",
"px": "768",
"cols": "9"
},
{
"name": "Desktop",
"px": "1024",
"cols": "12"
}
],
"order": 1,
"className": "",
"visible": "true",
"disabled": "false"
},
{
"id": "2365cb156242b3e6",
"type": "ui-group",
"name": "Renombrar",
"page": "d5367e576f526ae9",
"width": 6,
"height": 1,
"order": 2,
"showTitle": true,
"className": "",
"visible": "true",
"disabled": "false",
"groupType": "default"
},
{
"id": "29e5d13e29bfbb4b",
"type": "ui-group",
"name": "Validar",
"page": "d5367e576f526ae9",
"width": 6,
"height": 1,
"order": 1,
"showTitle": true,
"className": "",
"visible": "true",
"disabled": "false",
"groupType": "default"
},
{
"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": "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": "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": "683191909606de5f",
"type": "inject",
"z": "1a4b40705122dc91",
"g": "eefff18186897436",
"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",
"g": "eefff18186897436",
"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",
"g": "eefff18186897436",
"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",
"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,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 530,
"y": 280,
"wires": [
[
"c8a4cd4a752e245e"
]
]
},
{
"id": "0f7838df86c0daa7",
"type": "inject",
"z": "1a4b40705122dc91",
"g": "eefff18186897436",
"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",
"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,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 530,
"y": 340,
"wires": [
[
"0fc524aa3713e49b"
]
]
},
{
"id": "0fc524aa3713e49b",
"type": "mongodb4",
"z": "1a4b40705122dc91",
"g": "eefff18186897436",
"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",
"g": "eefff18186897436",
"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",
"g": "eefff18186897436",
"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",
"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,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 530,
"y": 400,
"wires": [
[
"693f1f1fcfc09699"
]
]
},
{
"id": "693f1f1fcfc09699",
"type": "mongodb4",
"z": "1a4b40705122dc91",
"g": "eefff18186897436",
"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",
"g": "eefff18186897436",
"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",
"g": "88cb3b1f39d6754c",
"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": "100",
"tot": "num"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[{ \"geocodingProcesado\": { \"$ne\": true } }, { \"limit\" : msg.limit }]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 720,
"y": 860,
"wires": [
[
"4af6fd0defd481ea"
]
]
},
{
"id": "4af6fd0defd481ea",
"type": "mongodb4",
"z": "1a4b40705122dc91",
"g": "88cb3b1f39d6754c",
"clientNode": "648a51546e4dadc6",
"mode": "collection",
"collection": "",
"operation": "",
"output": "toArray",
"maxTimeMS": "0",
"handleDocId": false,
"name": "",
"x": 930,
"y": 860,
"wires": [
[
"4644d386e752575d"
]
]
},
{
"id": "c29fc5be5de649c4",
"type": "inject",
"z": "1a4b40705122dc91",
"g": "88cb3b1f39d6754c",
"name": "Activación - Recuperar geoposiciones de CartoCiudad",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "1",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 260,
"y": 860,
"wires": [
[
"4250b98e85f30aa3"
]
]
},
{
"id": "4644d386e752575d",
"type": "link out",
"z": "1a4b40705122dc91",
"g": "88cb3b1f39d6754c",
"name": "link out 1",
"mode": "link",
"links": [
"ec0a560685f299d8"
],
"x": 1035,
"y": 860,
"wires": []
},
{
"id": "c6894593daa8fcf0",
"type": "inject",
"z": "1a4b40705122dc91",
"g": "eefff18186897436",
"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": 480,
"wires": [
[
"d66163bb05e6f12e",
"8081ba55b8146814"
]
]
},
{
"id": "d66163bb05e6f12e",
"type": "change",
"z": "1a4b40705122dc91",
"g": "eefff18186897436",
"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": 500,
"y": 480,
"wires": [
[
"004948a143b907dd"
]
]
},
{
"id": "004948a143b907dd",
"type": "mongodb4",
"z": "1a4b40705122dc91",
"g": "eefff18186897436",
"clientNode": "648a51546e4dadc6",
"mode": "collection",
"collection": "",
"operation": "",
"output": "toArray",
"maxTimeMS": "0",
"handleDocId": false,
"name": "Consulta",
"x": 720,
"y": 480,
"wires": [
[
"bb5ad864c986b15f"
]
]
},
{
"id": "bb5ad864c986b15f",
"type": "debug",
"z": "1a4b40705122dc91",
"g": "eefff18186897436",
"name": "Resultado (4 cambios)",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 900,
"y": 480,
"wires": []
},
{
"id": "8081ba55b8146814",
"type": "change",
"z": "1a4b40705122dc91",
"g": "eefff18186897436",
"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": 490,
"y": 520,
"wires": [
[
"004948a143b907dd"
]
]
},
{
"id": "5e1954f3ba4bce4b",
"type": "link in",
"z": "1a4b40705122dc91",
"g": "88cb3b1f39d6754c",
"name": "link in 3",
"links": [
"3105cb58919fe886"
],
"x": 565,
"y": 760,
"wires": [
[
"664bb290fa751036"
]
]
},
{
"id": "7b7214ea354e3b74",
"type": "inject",
"z": "1a4b40705122dc91",
"g": "88cb3b1f39d6754c",
"name": "Activación - Recuperar geoposiciones de CartoCiudad tratamiento rapido",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "1",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 320,
"y": 800,
"wires": [
[
"664bb290fa751036"
]
]
},
{
"id": "664bb290fa751036",
"type": "change",
"z": "1a4b40705122dc91",
"g": "88cb3b1f39d6754c",
"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": "10",
"tot": "num"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[{ \"cartociudad\": { \"$exists\": false } }, { \"limit\" : msg.limit }]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 720,
"y": 800,
"wires": [
[
"ae75d79916e0a333"
]
]
},
{
"id": "ae75d79916e0a333",
"type": "mongodb4",
"z": "1a4b40705122dc91",
"g": "88cb3b1f39d6754c",
"clientNode": "648a51546e4dadc6",
"mode": "collection",
"collection": "",
"operation": "",
"output": "toArray",
"maxTimeMS": "0",
"handleDocId": false,
"name": "",
"x": 930,
"y": 800,
"wires": [
[
"d1035ff8c39cd84c"
]
]
},
{
"id": "d1035ff8c39cd84c",
"type": "link out",
"z": "1a4b40705122dc91",
"g": "88cb3b1f39d6754c",
"name": "Limpieza Rápida",
"mode": "link",
"links": [
"a66d44720bfed89d"
],
"x": 1035,
"y": 800,
"wires": []
},
{
"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": [
[
"95b1dd4f471bf039"
]
]
},
{
"id": "95b1dd4f471bf039",
"type": "mongodb4",
"z": "1a4b40705122dc91",
"g": "eefff18186897436",
"clientNode": "648a51546e4dadc6",
"mode": "collection",
"collection": "",
"operation": "",
"output": "toArray",
"maxTimeMS": "0",
"handleDocId": false,
"name": "",
"x": 990,
"y": 620,
"wires": [
[
"2d79b1d9949e3dd0"
]
]
},
{
"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": [
[
"95b1dd4f471bf039"
]
]
},
{
"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": "6e1ee0f06e75580d",
"g": "586a685b7e78517c",
"name": "Entrada Cartociudad 2",
"links": [
"d1035ff8c39cd84c"
],
"x": 165,
"y": 60,
"wires": [
[
"88517c37afc36dd8"
]
]
},
{
"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": "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": 400,
"y": 60,
"wires": [
[
"65d4baca6edf0fbd"
]
]
},
{
"id": "65d4baca6edf0fbd",
"type": "change",
"z": "6e1ee0f06e75580d",
"g": "586a685b7e78517c",
"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": 450,
"y": 120,
"wires": [
[
"c106948998237652"
]
]
},
{
"id": "c106948998237652",
"type": "change",
"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": [
{
"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 }}]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 430,
"y": 200,
"wires": [
[
"d4531a5b62fccd5a"
]
]
},
{
"id": "d4531a5b62fccd5a",
"type": "mongodb4",
"z": "6e1ee0f06e75580d",
"g": "586a685b7e78517c",
"clientNode": "648a51546e4dadc6",
"mode": "collection",
"collection": "",
"operation": "",
"output": "toArray",
"maxTimeMS": "0",
"handleDocId": false,
"name": "",
"x": 690,
"y": 200,
"wires": [
[
"c6d1ee72149ef4da"
]
]
},
{
"id": "c6d1ee72149ef4da",
"type": "switch",
"z": "6e1ee0f06e75580d",
"g": "586a685b7e78517c",
"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": 200,
"y": 260,
"wires": [
[
"fe421b6180fe2f15"
],
[
"f04f31bb7e647ab7"
]
],
"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": "f04f31bb7e647ab7",
"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\": 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"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 570,
"y": 380,
"wires": [
[
"f98d50aac4fce670"
]
]
},
{
"id": "f98d50aac4fce670",
"type": "mongodb4",
"z": "6e1ee0f06e75580d",
"g": "586a685b7e78517c",
"clientNode": "648a51546e4dadc6",
"mode": "collection",
"collection": "",
"operation": "",
"output": "toArray",
"maxTimeMS": "0",
"handleDocId": false,
"name": "",
"x": 870,
"y": 380,
"wires": [
[
"385b936f30611065"
]
]
},
{
"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": [
[
"d6db349d1646634d"
],
[
"3bb66c22727588c3"
]
],
"outputLabels": [
"NO",
"SI"
]
},
{
"id": "841cb88a7b666a63",
"type": "comment",
"z": "6e1ee0f06e75580d",
"g": "586a685b7e78517c",
"name": "Si existe la calle",
"info": "",
"x": 480,
"y": 460,
"wires": []
},
{
"id": "a23bb95e94319218",
"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 {\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": 960,
"y": 480,
"wires": [
[
"041c57934c647e2c"
]
]
},
{
"id": "041c57934c647e2c",
"type": "debug",
"z": "6e1ee0f06e75580d",
"g": "586a685b7e78517c",
"name": "IGUALES - VALIDADO",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1300,
"y": 480,
"wires": []
},
{
"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": "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": 360,
"y": 860,
"wires": [
[
"c91b4ba4c01b3d11"
],
[
"3f24b62573b3963b",
"c3ce306882f3d6ab"
]
],
"outputLabels": [
"NO ",
"SI"
]
},
{
"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": "6e1ee0f06e75580d",
"g": "586a685b7e78517c",
"clientNode": "648a51546e4dadc6",
"mode": "collection",
"collection": "",
"operation": "",
"output": "toArray",
"maxTimeMS": "0",
"handleDocId": false,
"name": "",
"x": 1250,
"y": 840,
"wires": [
[
"08ef481b73ada20e"
]
]
},
{
"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": "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 },\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": 940,
"y": 900,
"wires": [
[
"ac3e7005ee6ca8b4"
]
]
},
{
"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": "6e1ee0f06e75580d",
"g": "586a685b7e78517c",
"clientNode": "648a51546e4dadc6",
"mode": "collection",
"collection": "",
"operation": "",
"output": "toArray",
"maxTimeMS": "0",
"handleDocId": false,
"name": "",
"x": 1250,
"y": 720,
"wires": [
[
"711cd5bb325a7107"
]
]
},
{
"id": "711cd5bb325a7107",
"type": "debug",
"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,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1010,
"y": 1220,
"wires": []
},
{
"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": "6e1ee0f06e75580d",
"g": "6d889597e60bf596",
"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": 1030,
"y": 1100,
"wires": [
[
"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": "6e1ee0f06e75580d",
"g": "6d889597e60bf596",
"group": "2365cb156242b3e6",
"name": "consulta_calle",
"label": "consulta_calle",
"order": 2,
"width": 0,
"height": 0,
"topic": "topic",
"topicType": "msg",
"mode": "text",
"tooltip": "",
"delay": 300,
"passthru": false,
"sendOnDelay": false,
"sendOnBlur": true,
"sendOnEnter": true,
"className": "",
"clearable": false,
"sendOnClear": false,
"icon": "",
"iconPosition": "left",
"iconInnerPosition": "inside",
"x": 760,
"y": 1420,
"wires": [
[
"3d08fca02fbfdc13"
]
]
},
{
"id": "13a8bf685ef1303b",
"type": "ui-text-input",
"z": "6e1ee0f06e75580d",
"g": "6d889597e60bf596",
"group": "2365cb156242b3e6",
"name": "tipocalle",
"label": "tipocalle",
"order": 3,
"width": 0,
"height": 0,
"topic": "topic",
"topicType": "msg",
"mode": "text",
"tooltip": "",
"delay": 300,
"passthru": true,
"sendOnDelay": false,
"sendOnBlur": true,
"sendOnEnter": true,
"className": "",
"clearable": false,
"sendOnClear": false,
"icon": "",
"iconPosition": "left",
"iconInnerPosition": "inside",
"x": 740,
"y": 1460,
"wires": [
[
"a403b6e0d3b62351"
]
]
},
{
"id": "5a4e60652aab552c",
"type": "ui-text-input",
"z": "6e1ee0f06e75580d",
"g": "6d889597e60bf596",
"group": "2365cb156242b3e6",
"name": "calle",
"label": "calle",
"order": 4,
"width": 0,
"height": 0,
"topic": "topic",
"topicType": "msg",
"mode": "text",
"tooltip": "",
"delay": 300,
"passthru": true,
"sendOnDelay": false,
"sendOnBlur": true,
"sendOnEnter": true,
"className": "",
"clearable": false,
"sendOnClear": false,
"icon": "",
"iconPosition": "left",
"iconInnerPosition": "inside",
"x": 730,
"y": 1500,
"wires": [
[
"2bb29b85114ff2c3"
]
]
},
{
"id": "a97aaad7209e3953",
"type": "ui-text-input",
"z": "6e1ee0f06e75580d",
"g": "6d889597e60bf596",
"group": "2365cb156242b3e6",
"name": "numero_retirada",
"label": "numero_retirada",
"order": 5,
"width": 0,
"height": 0,
"topic": "topic",
"topicType": "msg",
"mode": "text",
"tooltip": "",
"delay": 300,
"passthru": true,
"sendOnDelay": false,
"sendOnBlur": true,
"sendOnEnter": true,
"className": "",
"clearable": false,
"sendOnClear": false,
"icon": "",
"iconPosition": "left",
"iconInnerPosition": "inside",
"x": 760,
"y": 1540,
"wires": [
[
"eae675ed8219e086"
]
]
},
{
"id": "2e1a6699fd10a0d0",
"type": "ui-text-input",
"z": "6e1ee0f06e75580d",
"g": "6d889597e60bf596",
"group": "2365cb156242b3e6",
"name": "extra_calle",
"label": "extra_calle",
"order": 6,
"width": 0,
"height": 0,
"topic": "topic",
"topicType": "msg",
"mode": "text",
"tooltip": "",
"delay": 300,
"passthru": true,
"sendOnDelay": false,
"sendOnBlur": true,
"sendOnEnter": true,
"className": "",
"clearable": false,
"sendOnClear": false,
"icon": "",
"iconPosition": "left",
"iconInnerPosition": "inside",
"x": 750,
"y": 1580,
"wires": [
[
"bc7269f08c168a0b"
]
]
},
{
"id": "3d08fca02fbfdc13",
"type": "change",
"z": "6e1ee0f06e75580d",
"g": "6d889597e60bf596",
"name": "",
"rules": [
{
"t": "set",
"p": "consulta_calle",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 980,
"y": 1420,
"wires": [
[]
]
},
{
"id": "a403b6e0d3b62351",
"type": "change",
"z": "6e1ee0f06e75580d",
"g": "6d889597e60bf596",
"name": "",
"rules": [
{
"t": "set",
"p": "tipovia",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 960,
"y": 1460,
"wires": [
[]
]
},
{
"id": "2bb29b85114ff2c3",
"type": "change",
"z": "6e1ee0f06e75580d",
"g": "6d889597e60bf596",
"name": "",
"rules": [
{
"t": "set",
"p": "calle",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 950,
"y": 1500,
"wires": [
[]
]
},
{
"id": "eae675ed8219e086",
"type": "change",
"z": "6e1ee0f06e75580d",
"g": "6d889597e60bf596",
"name": "",
"rules": [
{
"t": "set",
"p": "numero_retirada",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 990,
"y": 1540,
"wires": [
[]
]
},
{
"id": "bc7269f08c168a0b",
"type": "change",
"z": "6e1ee0f06e75580d",
"g": "6d889597e60bf596",
"name": "",
"rules": [
{
"t": "set",
"p": "extra_calle",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 970,
"y": 1580,
"wires": [
[]
]
},
{
"id": "5c95290ed28a98cc",
"type": "change",
"z": "6e1ee0f06e75580d",
"g": "6d889597e60bf596",
"name": "Pongo consulta calle",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "consulta_calle",
"tot": "msg"
},
{
"t": "set",
"p": "referencia_geocache",
"pt": "flow",
"to": "referencia_geocache",
"tot": "msg"
},
{
"t": "set",
"p": "tipovia_original",
"pt": "flow",
"to": "msg.direccion.TipoVia",
"tot": "msg"
},
{
"t": "set",
"p": "calle_original",
"pt": "flow",
"to": "direccion.Calle",
"tot": "msg"
},
{
"t": "set",
"p": "numero_retirada_original",
"pt": "flow",
"to": "direccion.numero_retirada",
"tot": "msg"
},
{
"t": "set",
"p": "poblacion_original",
"pt": "flow",
"to": "direccion.Poblacion",
"tot": "msg"
},
{
"t": "set",
"p": "cp_original",
"pt": "flow",
"to": "direccion.CP",
"tot": "msg"
},
{
"t": "set",
"p": "ultima_validacion",
"pt": "flow",
"to": "msg",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 560,
"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": "6e1ee0f06e75580d",
"g": "6d889597e60bf596",
"name": "Trigger Renombrar",
"rules": [
{
"t": "set",
"p": "trigger",
"pt": "msg",
"to": "true",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 230,
"y": 1460,
"wires": [
[
"1dfe62e8c32543ee"
]
]
},
{
"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": "f8a18d468d34e722",
"type": "change",
"z": "6e1ee0f06e75580d",
"g": "6d889597e60bf596",
"name": "Preparamos los datos a guardar",
"rules": [
{
"t": "set",
"p": "guardar",
"pt": "msg",
"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"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 580,
"y": 1460,
"wires": [
[
"13a8bf685ef1303b"
]
]
},
{
"id": "e6c3dc27360afac1",
"type": "change",
"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": "insertOne",
"tot": "str"
},
{
"t": "set",
"p": "collection",
"pt": "msg",
"to": "consulta_calle",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"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"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 580,
"y": 1800,
"wires": [
[
"71e6a918e85cbd07"
]
]
},
{
"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": "6e1ee0f06e75580d",
"g": "6d889597e60bf596",
"clientNode": "648a51546e4dadc6",
"mode": "collection",
"collection": "",
"operation": "",
"output": "toArray",
"maxTimeMS": "0",
"handleDocId": false,
"name": "",
"x": 910,
"y": 1740,
"wires": [
[
"1799f293511ddb1e"
]
]
},
{
"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": "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": [
[
"530155acd87e9af4"
]
]
},
{
"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"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 120,
"wires": [
[
"acae736839e9942c"
]
]
},
{
"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": 370,
"y": 60,
"wires": [
[
"67d9948a4ea561d0"
]
]
},
{
"id": "bf5deb0295df1e6d",
"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": 60,
"wires": [
[
"73ca61629ca36cdb"
]
]
},
{
"id": "67d9948a4ea561d0",
"type": "debug",
"z": "e3a070490bfdc383",
"g": "d31dc5ca65fdaec9",
"name": "BORRADO TABLA GEOSERVICES",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 680,
"y": 60,
"wires": []
},
{
"id": "9a2c00a3d18bf2e5",
"type": "debug",
"z": "e3a070490bfdc383",
"g": "d31dc5ca65fdaec9",
"name": "CREACION TABLA GEOSERVICES",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 690,
"y": 120,
"wires": []
},
{
"id": "476541d607d59b6d",
"type": "function",
"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": 210,
"y": 520,
"wires": [
[
"18055db6bd0e0c9e"
]
]
},
{
"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": "6a8444fa71237276",
"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": 180,
"wires": [
[
"ead3b611059e050e"
]
]
},
{
"id": "87a50279e182879c",
"type": "change",
"z": "e3a070490bfdc383",
"g": "4de20a7676e67ad3",
"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": "10000",
"tot": "num"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"latitud\": { \"$ne\": null },\t \"_id\": { \"$gt\": msg.ultimo_id }\t },\t { \"limit\": msg.limit }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 560,
"y": 460,
"wires": [
[
"a5da07eb95be391c"
]
]
},
{
"id": "038afe42a8815a88",
"type": "change",
"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",
"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": "1",
"tot": "num"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"latitud\": { \"$ne\": null },\t \"_id\": { \"$gt\": msg.ultimo_id }\t },\t { \"limit\": msg.limit }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 580,
"y": 400,
"wires": [
[
"a5da07eb95be391c"
]
]
},
{
"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": "e3a070490bfdc383",
"g": "d31dc5ca65fdaec9",
"name": "MAXIMOS CONEXIONES",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 750,
"y": 240,
"wires": []
},
{
"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": "e3a070490bfdc383",
"g": "7bdac83e314d285e",
"name": "CONSULTAS",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 800,
"y": 680,
"wires": []
},
{
"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": "e3a070490bfdc383",
"g": "4de20a7676e67ad3",
"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": 580,
"y": 520,
"wires": [
[
"4aa92b63a45c740c"
]
]
}
]