Node-Red / flows.json
WuGuan's picture
Update flows.json
32a85e5 verified
[
{
"id": "fa36f2aea8694548",
"type": "tab",
"label": "流程 1",
"disabled": false,
"locked": true,
"info": "",
"env": []
},
{
"id": "7b954761b0d0c71d",
"type": "group",
"z": "fa36f2aea8694548",
"name": "天气预警",
"style": {
"label": true
},
"nodes": [
"f4826d0f354203d0",
"b649fa1a86929334",
"28ad21785d1d88ea",
"40f4dade103f33fb",
"d1a634b0775075f7"
],
"x": 34,
"y": 81.5,
"w": 912,
"h": 157
},
{
"id": "249a6593b77d86f9",
"type": "group",
"z": "fa36f2aea8694548",
"name": "停车计时",
"style": {
"label": true
},
"nodes": [
"3669dccf88588c53",
"1c6ca2674ef8a478",
"21747cce1c8e8b69",
"9a1af788832a1aea",
"0bcf5485bc36326e"
],
"x": 34,
"y": 279,
"w": 812,
"h": 82
},
{
"id": "d1a03a3787fecadc",
"type": "group",
"z": "fa36f2aea8694548",
"name": "ACQ",
"style": {
"label": true
},
"nodes": [
"9d78ce6e52ba16d5",
"af54b1e122b3b1be",
"74761521d6f20043",
"24a1438ad0c242f3",
"077de3e016c84c2b"
],
"x": 34,
"y": 439,
"w": 852,
"h": 82
},
{
"id": "d30d422ba83d2888",
"type": "mqtt-broker",
"name": "",
"broker": "https://dsm.727283671.xyz:18833",
"port": "18833",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": 60,
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
},
{
"id": "2be99c2fa62e6f44",
"type": "inject",
"z": "fa36f2aea8694548",
"name": "POST到",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "00 00 * * *",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "object",
"payloadType": "date",
"x": 140,
"y": 40,
"wires": [
[
"bfdbf3a6d111494f"
]
]
},
{
"id": "bfdbf3a6d111494f",
"type": "http request",
"z": "fa36f2aea8694548",
"name": "HuggingFace",
"method": "POST",
"ret": "txt",
"paytoqs": "ignore",
"url": "https://push.727283671.xyz:4443/HuggingFace",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 330,
"y": 40,
"wires": [
[]
]
},
{
"id": "f4826d0f354203d0",
"type": "weather",
"z": "fa36f2aea8694548",
"g": "7b954761b0d0c71d",
"name": "银川",
"longitude": "106.183878",
"latitude": "38.499847",
"x": 290,
"y": 160,
"wires": [
[
"40f4dade103f33fb"
],
[],
[],
[],
[],
[],
[]
]
},
{
"id": "b649fa1a86929334",
"type": "inject",
"z": "fa36f2aea8694548",
"g": "7b954761b0d0c71d",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "60",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 140,
"y": 180,
"wires": [
[
"f4826d0f354203d0"
]
]
},
{
"id": "28ad21785d1d88ea",
"type": "function",
"z": "fa36f2aea8694548",
"g": "7b954761b0d0c71d",
"name": "预警信息筛选",
"func": "\n\n// 检查预警数据有效性 \nif (!msg.payload.alerts || msg.payload.alerts.length === 0) {\n node.warn(\" 预警信息为空\");\n return null;\n}\n \ntry {\n // 解构赋值提取预警数据(含默认值)\n const { type = \"未知\", level = \"\", detail = \"暂无详细内容\" } = msg.payload.alerts[0] || {};\n \n // 重构 payload \n msg.payload = {\n title: `${type}${level}预警`,\n message: detail.replace(/\\n/g, \" \") // 去除换行符 \n };\n \n // 添加固定头部 \n msg.headers = {\n \"X-Title\": \"Weather_alerts\",\n \"X-Priority\": \"3\", // 根据目标服务调整优先级 \n \"tags\": \"house\"\n };\n \n return msg;\n} catch (error) {\n node.error(\" 预警数据处理失败:\", error);\n return null;\n}",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 580,
"y": 140,
"wires": [
[
"d1a634b0775075f7"
]
]
},
{
"id": "3669dccf88588c53",
"type": "http request",
"z": "fa36f2aea8694548",
"g": "249a6593b77d86f9",
"name": "顺泊停车",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "https://yinchuan.ttpark.cn/MobileServer/general/order/calFee?parkID=0&plate=%E5%AE%81A0B7K2&plateColor=1&autoCancel=1&appServletRequestType=openid&payAppID=106&sceneType=9&wxlite_token=f69f798ac2a7e29fed0aa77c19b5e365",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 280,
"y": 320,
"wires": [
[
"21747cce1c8e8b69"
]
]
},
{
"id": "1c6ca2674ef8a478",
"type": "inject",
"z": "fa36f2aea8694548",
"g": "249a6593b77d86f9",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "150",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 140,
"y": 320,
"wires": [
[
"3669dccf88588c53"
]
]
},
{
"id": "21747cce1c8e8b69",
"type": "json",
"z": "fa36f2aea8694548",
"g": "249a6593b77d86f9",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 410,
"y": 320,
"wires": [
[
"9a1af788832a1aea"
]
]
},
{
"id": "9d78ce6e52ba16d5",
"type": "http request",
"z": "fa36f2aea8694548",
"g": "d1a03a3787fecadc",
"name": "",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "https://api.zhileit.com/api/v1/web/bg/scpCarOwnerInfo/getShopBySwsKeyNew?cwsName=null&coordinate=106.18224662045463%2C38.49661166683154&pageSize=50&pageIndex=1",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [
{
"keyType": "other",
"keyValue": "CWS_BELONGING_KEY",
"valueType": "other",
"valueValue": "75C642B47E0276CDDDA9A0BCA1BE65EB"
}
],
"x": 280,
"y": 480,
"wires": [
[
"74761521d6f20043"
]
]
},
{
"id": "af54b1e122b3b1be",
"type": "inject",
"z": "fa36f2aea8694548",
"g": "d1a03a3787fecadc",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "300",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 140,
"y": 480,
"wires": [
[
"9d78ce6e52ba16d5"
]
]
},
{
"id": "74761521d6f20043",
"type": "json",
"z": "fa36f2aea8694548",
"g": "d1a03a3787fecadc",
"name": "",
"property": "payload",
"action": "",
"pretty": true,
"x": 410,
"y": 480,
"wires": [
[
"24a1438ad0c242f3"
]
]
},
{
"id": "9a1af788832a1aea",
"type": "function",
"z": "fa36f2aea8694548",
"g": "249a6593b77d86f9",
"name": "提取信息",
"func": "// 检查 msg.payload 和 msg.payload.data 是否存在\nif (!msg.payload || !msg.payload.data) {\n // 可以根据实际情况进行处理,这里舍弃信息\n return;\n}\n// 检查 orderList 是否存在且长度大于 0\nif (!msg.payload.data.orderList || msg.payload.data.orderList.length === 0) {\n // 可以根据实际情况进行处理,这里舍弃信息\n return;\n}\nvar plate = msg.payload.data.plate;\nvar images = msg.payload.data.orderList[0].imageURLs\nvar intime = msg.payload.data.orderList[0].inTime\nvar parkingTime = msg.payload.data.orderList[0].parkingTime\nvar amountPayable = msg.payload.data.orderList[0].amountPayable\n\n// 假设从 msg.payload 中获取分钟数 \nconst minutes = parkingTime; \n \n// 计算小时数 \nconst hours = Math.floor(minutes / 60); \n \n// 计算剩余分钟数 \nconst remainingMinutes = minutes % 60; \n \n// 格式化输出 \nconst formattedTime = `${hours} 小时 ${remainingMinutes} 分钟`; \n \n// 指定时长 (3小时25分钟)\nconst targetTime = \"205\"; \n \nlet tips; \nif (parkingTime >= 0 && parkingTime <= 5) { \n tips = \"A\"; \n} else if (parkingTime >= 25 && parkingTime <= 30) { \n tips = \"B\"; \n} else if (parkingTime >= 205 && parkingTime <= 210) { \n tips = \"C\"; \n} else if (parkingTime >= 325 && parkingTime <= 330) { \n tips = \"D\"; \n} else if (parkingTime >= 385 ) { \n tips = \"E\"; \n} else { \n // 不在上述范围的情况,可按需设置默认提示 \n tips = \"F\"; \n} \n\nmsg.payload = {\n plate: plate,\n imaUrl: images, // 入场照片\n intime: intime,\n parkingTime: formattedTime,\n tips: tips,\n amountPayable: amountPayable\n};\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 560,
"y": 320,
"wires": [
[
"0bcf5485bc36326e"
]
]
},
{
"id": "24a1438ad0c242f3",
"type": "function",
"z": "fa36f2aea8694548",
"g": "d1a03a3787fecadc",
"name": "提取信息",
"func": "// 从 context 中获取历史数据,如果不存在则初始化为空数组 \nvar historyData = context.get('historyData') || []; \nvar data = msg.payload.data.list; \nvar extractedData = []; \nvar changedData = []; \n \n// 提取所需数据 \nfor (var i = 0; i < data.length; i++) { \n var item = data[i]; \n var newItem = { \n name: item.cws_name, \n address: item.cws_address, \n sum_count: item.swi_sum_count, \n using_count: item.swi_using_count\n }; \n\n // 有数据时添加 cwoiInTime 相关项\n if (item.swi_using_info && item.swi_using_info.length > 0) {\n newItem.cwoiInTime1 = item.swi_using_info[0].cwoiInTime;\n }\n if (item.swi_using_info && item.swi_using_info.length > 1) {\n newItem.cwoiInTime2 = item.swi_using_info[1].cwoiInTime;\n }\n if (item.swi_using_info && item.swi_using_info.length > 2) {\n newItem.cwoiInTime3 = item.swi_using_info[2].cwoiInTime;\n }\n\n extractedData.push(newItem); \n} \n \n// 对比新数据和历史数据,找出发生变化的数据 \nfor (var j = 0; j < extractedData.length; j++) { \n var isChanged = true; \n for (var k = 0; k < historyData.length; k++) { \n if (extractedData[j].name === historyData[k].name) { \n // 假设 name 是唯一标识,对比其他属性 \n if ( \n extractedData[j].address === historyData[k].address && \n extractedData[j].sum_count === historyData[k].sum_count && \n extractedData[j].using_count === historyData[k].using_count && \n extractedData[j].cwoiInTime1 === historyData[k].cwoiInTime1 && \n extractedData[j].cwoiInTime2 === historyData[k].cwoiInTime2 && \n extractedData[j].cwoiInTime3 === historyData[k].cwoiInTime3 \n ) { \n isChanged = false; \n break; \n } \n } \n } \n if (isChanged) { \n changedData.push(extractedData[j]); \n } \n} \n \n// 更新历史数据 \ncontext.set('historyData', extractedData); \n \n// 将发生变化的数据赋值给 msg.payload \nmsg.payload = changedData; \nreturn msg; ",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 560,
"y": 480,
"wires": [
[
"077de3e016c84c2b"
]
]
},
{
"id": "40f4dade103f33fb",
"type": "rbe",
"z": "fa36f2aea8694548",
"g": "7b954761b0d0c71d",
"name": "",
"func": "rbe",
"gap": "",
"start": "",
"inout": "out",
"septopics": true,
"property": "payload.alerts[0].pubTime",
"topi": "topic",
"x": 430,
"y": 140,
"wires": [
[
"28ad21785d1d88ea"
]
]
},
{
"id": "077de3e016c84c2b",
"type": "mqtt out",
"z": "fa36f2aea8694548",
"g": "d1a03a3787fecadc",
"name": "",
"topic": "MQTT/ACQdata",
"qos": "2",
"retain": "false",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "d30d422ba83d2888",
"x": 780,
"y": 480,
"wires": []
},
{
"id": "0bcf5485bc36326e",
"type": "mqtt out",
"z": "fa36f2aea8694548",
"g": "249a6593b77d86f9",
"name": "",
"topic": "MQTT/Parking",
"qos": "2",
"retain": "false",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "d30d422ba83d2888",
"x": 740,
"y": 320,
"wires": []
},
{
"id": "d1a634b0775075f7",
"type": "mqtt out",
"z": "fa36f2aea8694548",
"g": "7b954761b0d0c71d",
"name": "",
"topic": "MQTT/Weather_alerts",
"qos": "2",
"retain": "false",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "d30d422ba83d2888",
"x": 820,
"y": 140,
"wires": []
}
]