Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄嘉阳
/
iot-platform-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
40b084de
authored
Mar 27, 2024
by
罗志长
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix: 设备上报数据过滤
parent
41ae3a8c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
View file @
40b084de
...
@@ -199,22 +199,35 @@ public class PushCallback implements MqttCallbackExtended {
...
@@ -199,22 +199,35 @@ public class PushCallback implements MqttCallbackExtended {
Long
timestamp
=
device
.
getTimestamp
();
Long
timestamp
=
device
.
getTimestamp
();
long
currentSecond
=
timestamp
/
1000
;
long
currentSecond
=
timestamp
/
1000
;
// 先通过产品名称判断
// 先通过产品名称判断
JSONObject
properties
=
device
.
getProperties
();
if
(
properties
==
null
)
{
return
;
}
if
(
REPORT_PROPERTY
.
equals
(
device
.
getMessageType
())
&&
headers
.
getProductName
().
contains
(
"呼吸"
))
{
if
(
REPORT_PROPERTY
.
equals
(
device
.
getMessageType
())
&&
headers
.
getProductName
().
contains
(
"呼吸"
))
{
if
(!
properties
.
containsKey
(
"hr"
)
||
!
properties
.
containsKey
(
"br"
))
{
return
;
}
cacheBrDeviceData
(
device
,
currentSecond
);
cacheBrDeviceData
(
device
,
currentSecond
);
redisTemplate
.
opsForValue
().
set
(
DEVICE_BR_DATA
+
device
.
getDeviceId
(),
JSON
.
toJSONString
(
device
.
getProperties
()
),
redisTemplate
.
opsForValue
().
set
(
DEVICE_BR_DATA
+
device
.
getDeviceId
(),
JSON
.
toJSONString
(
properties
),
5000
,
TimeUnit
.
MILLISECONDS
);
5000
,
TimeUnit
.
MILLISECONDS
);
}
}
if
(
REPORT_PROPERTY
.
equals
(
device
.
getMessageType
())
&&
headers
.
getProductName
().
contains
(
"空间"
))
{
if
(
REPORT_PROPERTY
.
equals
(
device
.
getMessageType
())
&&
headers
.
getProductName
().
contains
(
"空间"
))
{
if
(!
properties
.
containsKey
(
"personState"
))
{
return
;
}
cacheSpaceFallDeviceData
(
DEVICE_SPACE_TEMP_DATA
,
device
,
currentSecond
);
cacheSpaceFallDeviceData
(
DEVICE_SPACE_TEMP_DATA
,
device
,
currentSecond
);
redisTemplate
.
opsForValue
().
set
(
DEVICE_SPACE_DATA
+
device
.
getDeviceId
(),
JSON
.
toJSONString
(
device
.
getProperties
()
),
redisTemplate
.
opsForValue
().
set
(
DEVICE_SPACE_DATA
+
device
.
getDeviceId
(),
JSON
.
toJSONString
(
properties
),
5000
,
TimeUnit
.
MILLISECONDS
);
5000
,
TimeUnit
.
MILLISECONDS
);
}
}
if
(
REPORT_PROPERTY
.
equals
(
device
.
getMessageType
())
&&
headers
.
getProductName
().
contains
(
"跌倒"
))
{
if
(
REPORT_PROPERTY
.
equals
(
device
.
getMessageType
())
&&
headers
.
getProductName
().
contains
(
"跌倒"
))
{
if
(!
properties
.
containsKey
(
"personState"
))
{
return
;
}
cacheSpaceFallDeviceData
(
DEVICE_FALL_TEMP_DATA
,
device
,
currentSecond
);
cacheSpaceFallDeviceData
(
DEVICE_FALL_TEMP_DATA
,
device
,
currentSecond
);
redisTemplate
.
opsForValue
().
set
(
DEVICE_FALL_DATA
+
device
.
getDeviceId
(),
JSON
.
toJSONString
(
device
.
getProperties
()
),
redisTemplate
.
opsForValue
().
set
(
DEVICE_FALL_DATA
+
device
.
getDeviceId
(),
JSON
.
toJSONString
(
properties
),
5000
,
TimeUnit
.
MILLISECONDS
);
5000
,
TimeUnit
.
MILLISECONDS
);
}
}
String
deviceId
=
device
.
getDeviceId
();
String
deviceId
=
device
.
getDeviceId
();
...
@@ -226,7 +239,6 @@ public class PushCallback implements MqttCallbackExtended {
...
@@ -226,7 +239,6 @@ public class PushCallback implements MqttCallbackExtended {
for
(
HeaderInfo
.
Bind
binding
:
bindings
)
{
for
(
HeaderInfo
.
Bind
binding
:
bindings
)
{
try
{
try
{
String
iot_tenantId
=
binding
.
getId
();
String
iot_tenantId
=
binding
.
getId
();
JSONObject
properties
=
device
.
getProperties
();
// 设备上报到第三方,一分钟一次
// 设备上报到第三方,一分钟一次
reportBrData
(
device
,
iot_tenantId
);
reportBrData
(
device
,
iot_tenantId
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment