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
687c91fb
authored
Dec 12, 2023
by
汪志阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:bug处理
parent
2ad734d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/OffBedAlarm.java
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/OffBedAlarm.java
View file @
687c91fb
...
...
@@ -99,14 +99,14 @@ public class OffBedAlarm implements IAlarm {
log
.
info
(
"离床config:{}"
,
JSONUtil
.
toJsonStr
(
properties
));
AlarmRedisDTO
alarmRedisDTO
=
RedisUtil
.
get
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
);
if
(!
isOffBed
&&
alarmRedisDTO
!=
null
)
{
log
.
warn
(
"离床有人状态下,删除redis!"
);
log
.
info
(
"离床有人状态下,删除redis!"
);
RedisUtil
.
delete
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
);
return
;
}
// 设备无人,在范围内上报存储redis,超过离床持续时间,则预警
String
messageType
=
platAlarmCheckDTO
.
getMessageType
();
if
(
StringUtils
.
equalsAnyIgnoreCase
(
messageType
,
"OFFLINE"
,
"DISCONNECT"
))
{
log
.
warn
(
"设备下线,删除redis off_bed 预警"
);
log
.
info
(
"设备下线,删除redis off_bed 预警"
);
RedisUtil
.
delete
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
);
}
if
(
isOffBed
)
{
...
...
@@ -119,6 +119,10 @@ public class OffBedAlarm implements IAlarm {
boolean
isOverTime
=
(
localDateLong
-
firstOffBedLong
)
/
1000
>=
duration
*
60
;
LocalDateTime
firstOffBedTime
=
LocalDateTime
.
ofInstant
(
Instant
.
ofEpochMilli
(
firstOffBedLong
),
ZoneOffset
.
of
(
"+8"
));
log
.
info
(
"第一次离床时间为:"
+
firstOffBedTime
);
if
(
"1"
.
equals
(
alarmRedisDTO
.
getAlarm
()))
{
log
.
info
(
"离床预警已发送预警过!"
);
return
;
}
// 第一次离床时间在范围前,则已范围开始时间起始算
if
(
firstOffBedTime
.
isBefore
(
startTime
))
{
boolean
over
=
(
Duration
.
between
(
LocalDateTime
.
now
(),
startTime
).
toMillis
())
/
1000
>=
duration
*
60
;
...
...
@@ -142,7 +146,7 @@ public class OffBedAlarm implements IAlarm {
}
if
(
firstOffBedTime
.
isAfter
(
endTime
))
{
log
.
warn
(
"离床时间超出时间范围!"
);
log
.
info
(
"离床时间超出时间范围!"
);
}
}
...
...
@@ -191,7 +195,7 @@ public class OffBedAlarm implements IAlarm {
alarmRedisDTO
.
setStart
(
now
);
alarmRedisDTO
.
setStartLong
(
endLong
);
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
,
alarmRedisDTO
);
log
.
warn
(
"离床设备存储redis,第一次上报时间:{},开始上报时间:{},是否上报:{}"
,
log
.
info
(
"离床设备存储redis,第一次上报时间:{},开始上报时间:{},是否上报:{}"
,
getDateTime
(
alarmRedisDTO
.
getStartLong
()),
alarmRedisDTO
.
getStart
(),
alarmRedisDTO
.
getAlarm
());
}
else
{
alarmRedisDTO
.
setStart
(
now
);
...
...
@@ -206,7 +210,7 @@ public class OffBedAlarm implements IAlarm {
alarmRedisDTO
.
setStart
(
new
Date
());
alarmRedisDTO
.
setAlarm
(
CommonEnum
.
YES
.
getValue
());
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
,
alarmRedisDTO
);
log
.
warn
(
"推送离床消息,第一次上报时间:{},开始上报时间:{},是否上报:{}"
,
log
.
info
(
"推送离床消息,第一次上报时间:{},开始上报时间:{},是否上报:{}"
,
getDateTime
(
alarmRedisDTO
.
getStartLong
()),
alarmRedisDTO
.
getStart
(),
alarmRedisDTO
.
getAlarm
());
}
...
...
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