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
98ae7d20
authored
Nov 09, 2023
by
huangjy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:redis
只缓存上报的数据
parent
befb142a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
View file @
98ae7d20
...
...
@@ -43,6 +43,8 @@ public class PushCallback implements MqttCallback {
public
static
final
String
DEVICE_BR_DATA
=
"device:brhr:data:"
;
public
static
final
String
DEVICE_SPACE_DATA
=
"device:space:data:"
;
public
static
final
String
DEVICE_FALL_DATA
=
"device:fall:data:"
;
public
static
final
String
REPORT_PROPERTY
=
"REPORT_PROPERTY"
;
@Autowired
private
MqttConfig
mqttConfig
;
...
...
@@ -101,15 +103,15 @@ public class PushCallback implements MqttCallback {
HeaderInfo
headers
=
device
.
getHeaders
();
List
<
HeaderInfo
.
Bind
>
bindings
=
headers
.
getBindings
();
// TODO 先这样判断
if
(
headers
.
getProductName
().
contains
(
"呼吸"
))
{
if
(
REPORT_PROPERTY
.
equals
(
device
.
getMessageType
())
&&
headers
.
getProductName
().
contains
(
"呼吸"
))
{
redisTemplate
.
opsForValue
().
set
(
DEVICE_BR_DATA
+
device
.
getDeviceId
(),
JSON
.
toJSONString
(
device
.
getProperties
()),
1000
,
TimeUnit
.
MILLISECONDS
);
}
if
(
headers
.
getProductName
().
contains
(
"空间"
))
{
if
(
REPORT_PROPERTY
.
equals
(
device
.
getMessageType
())
&&
headers
.
getProductName
().
contains
(
"空间"
))
{
redisTemplate
.
opsForValue
().
set
(
DEVICE_SPACE_DATA
+
device
.
getDeviceId
(),
JSON
.
toJSONString
(
device
.
getProperties
()),
1000
,
TimeUnit
.
MILLISECONDS
);
}
if
(
headers
.
getProductName
().
contains
(
"跌倒"
))
{
if
(
REPORT_PROPERTY
.
equals
(
device
.
getMessageType
())
&&
headers
.
getProductName
().
contains
(
"跌倒"
))
{
redisTemplate
.
opsForValue
().
set
(
DEVICE_FALL_DATA
+
device
.
getDeviceId
(),
JSON
.
toJSONString
(
device
.
getProperties
()),
1000
,
TimeUnit
.
MILLISECONDS
);
}
...
...
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