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
092fd478
authored
Sep 26, 2023
by
李小龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:
parent
a20399eb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
39 deletions
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/BehaviorAlarm.java
server-service/src/main/java/com/makeit/service/platform/alarm/impl/PlatAlarmRecordServiceImpl.java
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/BehaviorAlarm.java
View file @
092fd478
...
...
@@ -155,11 +155,11 @@ public class BehaviorAlarm implements IAlarm {
log
.
error
(
"未关联长者,设备id:"
+
platDevice
.
getId
());
return
;
}
PlatRoom
platRoom
=
platAlarmCheckDTO
.
getPlatRoom
();
List
<
PlatElder
>
platElderList
=
platAlarmCheckDTO
.
getPlatElderList
();
if
(
CollectionUtils
.
isNotEmpty
(
platElderList
)){
platAlarmRecordService
.
getElderListByDeviceId
(
platAlarmCheckDTO
);
platElderList
=
platAlarmCheckDTO
.
getPlatElderList
();
}
for
(
PlatElder
platElder
:
platElderList
)
{
PlatDayDurationRecord
durationRecord
=
new
PlatDayDurationRecord
();
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/impl/PlatAlarmRecordServiceImpl.java
View file @
092fd478
...
...
@@ -269,7 +269,8 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
}
else
{
String
notifyUser
=
alarmConfig
.
getNotifyUser
();
if
(
StringUtils
.
isBlank
(
notifyUser
)){
throw
new
BusinessException
(
"告警内部人员未配置,告警配置id:"
+
alarmConfig
.
getId
());
log
.
error
(
"告警内部人员未配置,告警配置id:"
+
alarmConfig
.
getId
());
return
;
}
String
[]
userArray
=
notifyUser
.
split
(
","
);
List
<
PlatUser
>
platUsers
=
platUserService
.
listByIds
(
Arrays
.
asList
(
userArray
));
...
...
@@ -277,7 +278,8 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
}
platUserList
.
removeIf
(
Objects:
:
isNull
);
if
(
CollectionUtils
.
isEmpty
(
platUserList
))
{
throw
new
BusinessException
(
"通知工作人员时,找不到人员数据;"
+
"orgId:"
+
alarmConfig
.
getOrgId
()
+
",tenantId:"
+
alarmConfig
.
getTenantId
()
+
"alarmConfigId:"
+
alarmConfig
.
getId
());
log
.
error
(
"通知工作人员时,找不到人员数据;"
+
"orgId:"
+
alarmConfig
.
getOrgId
()
+
",tenantId:"
+
alarmConfig
.
getTenantId
()
+
"alarmConfigId:"
+
alarmConfig
.
getId
());
return
;
}
List
<
SendTypeEnum
>
notifyChannelList
=
Arrays
.
asList
(
SendTypeEnum
.
SMS
,
SendTypeEnum
.
VOICE_SMS
,
SendTypeEnum
.
MAIL
);
Set
<
String
>
phoneSet
=
platUserList
.
stream
().
map
(
PlatUser:
:
getMobile
).
collect
(
Collectors
.
toSet
());
...
...
@@ -364,7 +366,8 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
//todo 要支持 设备绑定多个空间
List
<
PlatRoomBedDevice
>
platRoomBedDeviceList
=
platRoomBedDeviceService
.
list
(
roomBedDeviceLambdaQueryWrapper
);
if
(
CollectionUtils
.
isNotEmpty
(
platRoomBedDeviceList
)){
throw
new
BusinessException
(
"设备没绑定房间:"
+
platDevice
.
getId
());
log
.
error
(
"设备没绑定房间:"
+
platDevice
.
getId
());
return
;
}
platRoomBedDeviceList
.
forEach
(
platRoomBedDevice
->
{
...
...
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
View file @
092fd478
...
...
@@ -83,44 +83,48 @@ public class PushCallback implements MqttCallback {
HeaderInfo
headers
=
device
.
getHeaders
();
List
<
HeaderInfo
.
Bind
>
bindings
=
headers
.
getBindings
();
for
(
HeaderInfo
.
Bind
binding
:
bindings
)
{
String
iot_tenantId
=
binding
.
getId
();
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
(
"checkAlarm-1"
);
String
deviceId
=
device
.
getDeviceId
();
JSONObject
properties
=
device
.
getProperties
();
//iot设备id
PlatDevice
platDevice
=
deviceCacheUtil
.
get
(
deviceId
+
":"
+
iot_tenantId
);
if
(
platDevice
==
null
){
logger
.
error
(
"获取设备信息异常,设备iot-id:"
+
deviceId
);
return
;
}
List
<
PlatAlarmConfig
>
deviceAlarmConfigList
=
alarmConfigCacheUtil
.
getDeviceAlarmConfigMap
(
platDevice
);
deviceAlarmConfigList
.
removeIf
(
Objects:
:
isNull
);
if
(
CollectionUtils
.
isEmpty
(
deviceAlarmConfigList
))
{
logger
.
error
(
"该设备没有告警配置,设备iot-id:"
+
deviceId
);
return
;
}
for
(
PlatAlarmConfig
config
:
deviceAlarmConfigList
)
{
String
alarmType
=
config
.
getAlarmType
();
PlatAlarmCheckDTO
platAlarmCheckDTO
=
new
PlatAlarmCheckDTO
();
//告警配置
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
//设备信息
platAlarmCheckDTO
.
setPlatDevice
(
platDevice
);
//iot上报数据
platAlarmCheckDTO
.
setProperties
(
properties
);
for
(
IAlarm
alarm
:
alarmList
)
{
if
(
alarm
.
support
(
alarmType
))
{
alarm
.
checkConfig
(
platAlarmCheckDTO
);
try
{
String
iot_tenantId
=
binding
.
getId
();
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
(
"checkAlarm-1"
);
String
deviceId
=
device
.
getDeviceId
();
JSONObject
properties
=
device
.
getProperties
();
//iot设备id
PlatDevice
platDevice
=
deviceCacheUtil
.
get
(
deviceId
+
":"
+
iot_tenantId
);
if
(
platDevice
==
null
)
{
logger
.
error
(
"获取设备信息异常,设备iot-id:"
+
deviceId
);
return
;
}
List
<
PlatAlarmConfig
>
deviceAlarmConfigList
=
alarmConfigCacheUtil
.
getDeviceAlarmConfigMap
(
platDevice
);
deviceAlarmConfigList
.
removeIf
(
Objects:
:
isNull
);
if
(
CollectionUtils
.
isEmpty
(
deviceAlarmConfigList
))
{
logger
.
error
(
"该设备没有告警配置,设备iot-id:"
+
deviceId
);
return
;
}
for
(
PlatAlarmConfig
config
:
deviceAlarmConfigList
)
{
String
alarmType
=
config
.
getAlarmType
();
PlatAlarmCheckDTO
platAlarmCheckDTO
=
new
PlatAlarmCheckDTO
();
//告警配置
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
//设备信息
platAlarmCheckDTO
.
setPlatDevice
(
platDevice
);
//iot上报数据
platAlarmCheckDTO
.
setProperties
(
properties
);
for
(
IAlarm
alarm
:
alarmList
)
{
if
(
alarm
.
support
(
alarmType
))
{
alarm
.
checkConfig
(
platAlarmCheckDTO
);
}
}
}
stopWatch
.
stop
();
logger
.
info
(
stopWatch
.
prettyPrint
());
}
catch
(
Exception
e
){
logger
.
error
(
"告警异常pushCallback:"
,
e
);
}
stopWatch
.
stop
();
logger
.
info
(
stopWatch
.
prettyPrint
());
}
...
...
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