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
6ff94ce3
authored
Jan 17, 2024
by
罗志长
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
feat: 独立部署设备消息过滤
parent
95bb3a10
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
0 deletions
server-common/src/main/java/com/makeit/enums/redis/RedisConst.java
server-service/src/main/java/com/makeit/utils/DeviceCacheUtil.java
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
server-common/src/main/java/com/makeit/enums/redis/RedisConst.java
View file @
6ff94ce3
...
...
@@ -101,6 +101,8 @@ public class RedisConst {
public
static
final
String
ALARM_CONFIG_ORG_ID
=
"alarm:config:org:id:"
;
public
static
final
String
PLAT_IOT_DEVICE_PREFIX
=
"plat:iot:device:"
;
public
static
final
String
PLAT_OWN_IOT_DEVICE_ID
=
"plat:own:iot:device:id:"
;
public
static
final
String
ELDER_DAY_DURATION_PREFIX
=
"plat:day:duration:device:"
;
public
static
final
String
LOCK_ALARM
=
"lock:alarm:device:id:"
;
...
...
server-service/src/main/java/com/makeit/utils/DeviceCacheUtil.java
View file @
6ff94ce3
...
...
@@ -43,11 +43,16 @@ public class DeviceCacheUtil implements ApplicationRunner {
PlatTenant
platTenant
=
platTenantService
.
getById
(
platDevice
.
getTenantId
());
if
(
StringUtils
.
equals
(
platDevice
.
getStatus
(),
DeviceState
.
online
.
getValue
()))
{
RedisUtil
.
set
(
RedisConst
.
PLAT_IOT_DEVICE_PREFIX
+
platDevice
.
getOriDeviceId
()+
":"
+
platTenant
.
getIotOrgId
(),
platDevice
);
RedisUtil
.
set
(
RedisConst
.
PLAT_OWN_IOT_DEVICE_ID
+
platDevice
.
getOriDeviceId
(),
platDevice
);
}
else
{
String
key
=
RedisConst
.
PLAT_IOT_DEVICE_PREFIX
+
platDevice
.
getOriDeviceId
()+
":"
+
platTenant
.
getIotOrgId
();
if
(
RedisUtil
.
exist
(
key
)){
RedisUtil
.
delete
(
RedisConst
.
PLAT_IOT_DEVICE_PREFIX
+
platDevice
.
getOriDeviceId
()+
":"
+
platTenant
.
getIotOrgId
());
}
String
key1
=
RedisConst
.
PLAT_OWN_IOT_DEVICE_ID
+
platDevice
.
getOriDeviceId
();
if
(
RedisUtil
.
exist
(
key1
)){
RedisUtil
.
delete
(
key1
);
}
}
}
...
...
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
View file @
6ff94ce3
...
...
@@ -115,6 +115,12 @@ public class PushCallback implements MqttCallbackExtended {
// 解析数据
DeviceInfo
device
=
JSON
.
parseObject
(
payload
,
DeviceInfo
.
class
);
// 独立部署的服务过滤出平台自己的设备消息
String
key
=
RedisConst
.
PLAT_OWN_IOT_DEVICE_ID
+
device
.
getDeviceId
();
if
(!
RedisUtil
.
exist
(
key
))
{
return
;
}
syncProperties
(
device
);
checkAlarm
(
device
);
...
...
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