创建规则对接收到的报文数据进行业务过滤,报文有各种结构的,下面对各种结构报文sql过滤使用进行说明
下面sql规则统一对temperature大于20的数据进行过滤
1:单层结构报文
{
"temperature": 35,
"humidity": 66
}
sql写法如下
select * from zjrg where temperature>20 and isNull(temperature) = FALSE
2:双层结构报文
{
"dl": {
"temperature": 100,
"humidity": 0
}
}
sql写法如下
select * from zjrg where dl.temperature>20 and isNull(dl.temperature) = FALSE
3:多层数组类型报文结构
{
"deviceValueE": [
{
"da": "plc_pump1",
"dl": {
"temperature": 100,
"humidity": 65
}
},
{
"da": "plc_pump2",
"dl": {
"temperature": 0,
"humidity": 66
}
}
],
"ts": "2022-07-07 16:50:42"
}
sql写法如下
select * from zjrg where deviceValueE[0].dl.temperature>20 and isNull(deviceValueE[0].dl.temperature) = FALSE