|
发表于 2024-8-2 08:48:42
|
显示全部楼层
这样对吗?
if(msg.payload.header.type == 'ys.alarm'){
try {
let channelName = msg.payload.body.channelName;
let alarmTime = msg.payload.body.alarmTime;
let alarmType = msg.payload.body.alarmType;
let alarmCode = msg.payload.body.alarmId.slice(-5);
let alarmName = global.get('getAlarmByCode')(alarmCode).alarmName;
let pic_id = msg.payload.body.pictureList[0].id;
let pic_url = msg.payload.body.pictureList[0].url;
let message;
//message = '<img src="' + pic_url + '" />';
//message += '<br />图片ID ' + pic_id;
message = '设备名称 ' + channelName + '\n';
message += '警告时间 ' + alarmTime + '\n';
message += '警告代码 ' + alarmCode + '\n';
message += '警告类型 ' + alarmType + '\n';
message += '警告名称 ' + alarmName + '\n';
message += '推送时间 ' + global.get("formatDate")();
msg.payload = {
"touser": '@all',
"toparty": "PartyID1|PartyID2",
"totag": "TagID1 | TagID2",
"msgtype": "news",
"agentid": "1000888",
"news": {
"articles": [
{
"title": "警告信息:",
"description": message,
"url": pic_url,
"picurl": pic_url
}
]
},
"safe": 0
}
return [msg, null];
} catch (error) {
return;
};
}
|
|