• DGIOT基于低代码amis配置联动短信告警


    1.png

    [小 迪 导读]:在制造企业工厂、工业化工厂以及机房内,各业主都会选择安装安防监控设备,如:红外探测器,湿度报警,门禁,烟感,监控等报警设备。现如今,dgiot提供短信联动告警服务,让告警及时被送到管理人员手中,不漏发报警信息,不错过一个风险提醒,全面保障/工厂系统的稳定运行,减少隐患。

    整体架构

    2.png

    一、平台告警模板

    1.创建告警低代码

    进入产品详情,点击告警,点击新增

    3.png

    点击设计

    告警模板低代码:

    {
      "type": "page",
      "body": [
        {
          "id": "u:2c72c2d76916",
          "api": {
            "url": "iotapi/sendsms/parse_objectid",
            "data": {
              "tplid": "${tplid}",
              "params": [
                "${updatedAt}",
                "${product_name}",
                "${name}",
                "${devaddr}",
                "${alarm_level}",
                "${alarm_message}"
              ]
            },
            "method": "post",
            "headers": {
              "store": "localStorage",
              "dgiotReplace": "parse_objectid"
            },
            "dataType": "json",
            "requestAdaptor": "console.log('ffds ', ...api.data)\r\nreturn {\r\n    ...api,\r\n    data: {\r\n        tplid: ...api.data.tplid\r\n    }\r\n}"
          },
          "body": [
            {
              "hint": "1519757",
              "name": "tplid",
              "type": "input-text",
              "label": "模板编号",
              "value": "",
              "visible": false,
              "disabled": "",
              "readOnly": true,
              "visibleOn": "",
              "clearValueOnHidden": false
            },
            {
              "mode": "horizontal",
              "name": "alarm_createdAt",
              "size": "md",
              "type": "input-text",
              "label": "告警时间",
              "format": "YYYY-MM-DD HH:mm:ss",
              "maxDate": "",
              "minDate": "",
              "disabled": false,
              "readOnly": true,
              "clearable": false,
              "horizontal": {
                "left": 2,
                "right": 10,
                "leftFixed": "sm"
              },
              "placeholder": "请选择日期时间",
              "validateApi": ""
            },
            {
              "id": "u:55d89cd2eb42",
              "api": "",
              "body": [
                {
                  "hint": "",
                  "mode": "horizontal",
                  "name": "product_name",
                  "size": "md",
                  "type": "input-text",
                  "label": "产品名称",
                  "inline": false,
                  "readOnly": true,
                  "horizontal": {
                    "left": 2,
                    "right": 10,
                    "leftFixed": "sm"
                  },
                  "submitOnChange": false
                }
              ],
              "mode": "inline",
              "type": "form",
              "title": "",
              "target": "alarm_form",
              "initApi": {
                "url": "iotapi/classes/Product/${_productid}",
                "data": null,
                "method": "get",
                "adaptor": "return {\r\n  \"status\":0,\r\n  \"msg\":\"\",\r\n  \"data\":response.data\r\n  }",
                "responseData": {
                  "product_name": "${name}"
                },
                "requestAdaptor": ""
              },
              "className": "m-t-lg m-b-lg",
              "horizontal": {
                "left": 2,
                "right": 10,
                "leftFixed": "normal"
              },
              "submitText": "",
              "wrapWithPanel": false
            },
            {
              "id": "u:55d89cd2eb42",
              "api": "",
              "body": [
                {
                  "hint": "",
                  "mode": "horizontal",
                  "name": "name",
                  "size": "md",
                  "type": "input-text",
                  "label": "设备名称",
                  "inline": false,
                  "readOnly": true,
                  "horizontal": {
                    "left": 2,
                    "right": 10,
                    "leftFixed": "sm"
                  }
                },
                {
                  "id": "u:a656b5747025",
                  "hint": "",
                  "mode": "horizontal",
                  "name": "devaddr",
                  "size": "md",
                  "type": "input-text",
                  "label": "设备地址",
                  "inline": false,
                  "readOnly": true,
                  "horizontal": {
                    "left": 1,
                    "right": 11,
                    "leftFixed": "sm"
                  }
                }
              ],
              "mode": "normal",
              "type": "form",
              "title": "",
              "target": "alarm_form",
              "initApi": {
                "url": "iotapi/classes/Device/${_deviceid}",
                "data": null,
                "method": "get",
                "adaptor": "return {\r\n  \"status\":0,\r\n  \"msg\":\"\",\r\n  \"data\":response.data\r\n  }",
                "responseData": {
                  "name": "${name}",
                  "devaddr": "${devaddr}"
                },
                "requestAdaptor": ""
              },
              "className": "m-b-lg",
              "horizontal": {
                "left": 2,
                "right": 10,
                "leftFixed": "normal"
              },
              "submitText": "",
              "wrapWithPanel": false
            },
            {
              "id": "u:b5d871f9d40f",
              "mode": "horizontal",
              "name": "alarm_level",
              "size": "md",
              "type": "input-text",
              "label": "告警等级",
              "value": "二级告警(自行填写)",
              "horizontal": {
                "left": 2,
                "right": 10,
                "leftFixed": "sm"
              }
            },
            {
              "id": "u:2739169db893",
              "mode": "horizontal",
              "name": "alarm_message",
              "size": "md",
              "type": "input-text",
              "label": "告警信息",
              "value": "温度过高(自行填写)",
              "horizontal": {
                "left": 2,
                "right": 10,
                "leftFixed": "sm"
              }
            },
            {
              "id": "u:cdfa428176ab",
              "hint": "",
              "mode": "horizontal",
              "name": "dgiot_alarmvalue",
              "size": "md",
              "type": "input-text",
              "label": "告警值",
              "readOnly": true,
              "horizontal": {
                "left": 2,
                "right": 10,
                "leftFixed": "sm"
              }
            }
          ],
          "name": "alarm_form",
          "type": "form",
          "rules": [
          ],
          "title": "",
          "initApi": "",
          "submitText": ""
        }
      ],
      "style": {
      },
      "initApi": {
        "url": "/iotapi/classes/Notification/parse_notificationid",
        "method": "get",
        "adaptor": "return {\r\n  \"status\":0,\r\n  \"msg\":\"\",\r\n  \"data\":response.data.content\r\n  }",
        "headers": {
          "store": "localStorage",
          "dgiotReplace": "parse_notificationid"
        },
        "dataType": "json"
      },
      "messages": {
      },
      "initFetch": true
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232

    2.关联物模型,生成告警规则

    点击关联,选择告警产生/告警恢复

    4.png

    配置规则,以下图为例

    5.png

    [小 迪 提醒]
    告警产生后必须告警恢复后,同一个设备才会再次告警,因此需要自行关联告警恢复(等待设备恢复)或者平台点击手动恢复/误报
    6.png

    平台告警配置完成

    二、短信告警模板

    1.填写短信模板前置信息,菜单选择云系统-通知管理,填写信息,点击保存

    7.png

    2.创建低代码

    进入产品详情点击可视化,点击添加

    8.png
    以下图为例:
    9.png

    3.点击设计

    短信告警模板低代码:

    {
      "type": "page",
      "body": [
        {
          "id": "u:258c50b2e0c0",
          "type": "grid",
          "columns": [
            {
              "body": [
                {
                  "id": "u:2c72c2d76916",
                  "api": {
                    "url": "iotapi/classes/Product/parse_objectid",
                    "data": null,
                    "method": "put",
                    "headers": {
                      "store": "localStorage",
                      "dgiotReplace": "parse_objectid"
                    },
                    "dataType": "json",
                    "requestAdaptor": "return {\r\n  ...api,\r\n  data:{\r\n    content:{\r\n      sms:{\r\n        tplid:api.data.tplid,\r\n        params:api.data.params\r\n      }\r\n    }    \r\n  }\r\n}"
                  },
                  "body": [
                    {
                      "mode": "horizontal",
                      "name": "tplid",
                      "size": "lg",
                      "type": "input-text",
                      "label": "模板编号",
                      "readOnly": false,
                      "horizontal": {
                        "left": 2,
                        "right": 10,
                        "leftFixed": "sm"
                      }
                    },
                    {
                      "flat": true,
                      "mode": "inline",
                      "name": "params",
                      "size": "lg",
                      "type": "combo",
                      "items": [
                        {
                          "id": "u:ae0d88f0b31b",
                          "name": "text",
                          "type": "input-text",
                          "label": "短信字段",
                          "options": [
                            {
                              "label": "设备名称",
                              "value": "%DEVICENAME%"
                            },
                            {
                              "label": "设备地址",
                              "value": "%DEVICEADDR%"
                            },
                            {
                              "label": "产品名称",
                              "value": "%PRODUCTNAME%"
                            },
                            {
                              "label": "日期",
                              "value": "%DATE%"
                            },
                            {
                              "label": "用户名称",
                              "value": "%USERNAME%"
                            },
                            {
                              "label": "报警时间",
                              "value": "%TRIGGERTIME%"
                            },
                            {
                              "label": "变量名称",
                              "value": "%DATAPOINTNAME%"
                            },
                            {
                              "label": "当前值",
                              "value": "%NOWVALUE%"
                            }
                          ]
                        }
                      ],
                      "label": "字段顺序",
                      "messages": {
                      },
                      "multiple": true,
                      "className": "",
                      "maxLength": "",
                      "minLength": "",
                      "multiLine": true,
                      "horizontal": {
                        "left": 2,
                        "right": 10,
                        "leftFixed": "sm"
                      },
                      "joinValues": false,
                      "labelClassName": "",
                      "typeSwitchable": true
                    }
                  ],
                  "name": "alarm_form",
                  "type": "form",
                  "title": "告警短信模板",
                  "initApi": "",
                  "multiLine": false
                }
              ]
            },
            {
              "body": [
                {
                  "id": "u:9b96b2b0313b",
                  "body": [
                    {
                      "tpl": "

    字段解释:

    \n

    模板编号:云服务器短信模板编号

    \n

    字段顺序:一条短信字段则是短信模板中的一个变量,按顺序进行添加

    \n

    短信字段:一条短信字段可包括多个参数

    \n

    产品名称:%PRODUCTNAME%

    \n

    设备名称:%DEVICENAME%

    \n

    设备地址:%DEVICEADDR%

    \n

    产品名称:%PRODUCTNAME%

    \n

    日期:%DATE%

    \n

    时间:%DATETIME%

    \n

    用户名称:%USERNAME%

    \n

    报警时间:%TRIGGERTIME%

    \n

    变量名称:%DATAPOINTNAME%

    \n

    当前值:%NOWVALUE%

    \n

    触发描述:%TRIGGERDESCRIPTION%

    \n

    "
    , "type": "tpl", "style": { }, "trigger": [ "hover" ] } ], "type": "tooltip-wrapper", "tooltip": "提示文字" } ] } ] } ], "style": { }, "initApi": { "url": "iotapi/classes/Product/parse_objectid", "method": "get", "adaptor": "return {\r\n \"status\":0,\r\n \"msg\":\"\",\r\n \"data\":response.data.content.sms\r\n }", "headers": { "store": "localStorage", "dgiotReplace": "parse_objectid" }, "dataType": "json" }, "messages": { }, "initFetch": true }
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149

    4.配置短信模板进行提交

    在产品可视化下新创建的告警短信模板点击预览

    10.png

    根据提示配置短信模板,以下图为例:

    11.png

    此例子与dgiot短信字段与腾讯云服务器短信字段的对应关系一文中正文模板的自定义内容顺序一致

    点击提交

    12.png

    三、触发告警

    13.png

    云运维-告警中心
    14.png

    手机接收短信
    15.png

    [小 迪 点评]

    • dgiot平台提供发送短信,指定模板短信通知。
    • 在成本方面dgiot为降低用户使用成本,在短信方面在腾讯云指定配置即可使用。
      想了解更多 dgiot 的具体细节,欢迎大家在GitHub上查看相关源代码。

    想了解更多 dgiot 的具体细节,欢迎大家在GitHub上查看相关源代码。

  • 相关阅读:
    SpringBoot的创建和使用
    设计模式-责任链模式
    为什么C语言执行效率高,运行快?
    解决Flutter启动一直卡在 Running Gradle task ‘assembleDebug‘...
    【二叉树】最大二叉树 II
    SpringBoot和Vue实现导入导出——基于SpringBoot和Vue的后台管理系统项目系列博客(十二)
    一文带你走进“PyQt5”
    C#唯一进程的处理Winform/WPF
    CVE-2021-1732_Windows本地提权漏洞
    MyBatisplus使用报错--Invalid bound statement
  • 原文地址:https://blog.csdn.net/DG_IOT/article/details/126889266