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
81661d91
authored
Dec 18, 2023
by
汪志阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:临界值处理判断
parent
835ab649
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 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 @
81661d91
...
...
@@ -67,7 +67,8 @@ public class OffBedAlarm implements IAlarm {
log
.
error
(
"离床告警配置为禁用,告警配置id:"
+
config
.
getId
());
return
;
}
String
ruleConfigStr
=
config
.
getRuleConfig
();
String
ruleConfigStr
=
"{\"offBedStart\":\"23:07:00\",\"offBedEnd\":\"00:00:00\",\"duration\":\"1\"}"
;
// String ruleConfigStr = config.getRuleConfig();
if
(
StringUtils
.
isBlank
(
ruleConfigStr
))
{
log
.
error
(
"离床告警配置未配置,告警配置id:"
+
config
.
getId
());
return
;
...
...
@@ -88,7 +89,7 @@ public class OffBedAlarm implements IAlarm {
String
deviceId
=
platDevice
.
getId
();
LocalTime
startTime
=
ruleConfig
.
getOffBedStart
();
LocalTime
endTime
=
ruleConfig
.
getOffBedEnd
();
if
(
startTime
==
null
||
endTime
==
null
)
{
if
(
startTime
==
null
||
endTime
==
null
||
startTime
.
equals
(
endTime
)
)
{
log
.
error
(
"离床告警配置时间段解析失败,config:{}"
,
JSONUtil
.
toJsonStr
(
ruleConfig
));
return
;
}
...
...
@@ -122,8 +123,8 @@ public class OffBedAlarm implements IAlarm {
log
.
info
(
"离床告警已发送预警过!"
);
return
;
}
// 是否跨天
boolean
isCrossDay
=
startTime
.
isAfter
(
endTime
);
// 是否跨天
xxx-0:00,未跨天
boolean
isCrossDay
=
startTime
.
isAfter
(
endTime
)
&&
!
endTime
.
equals
(
LocalTime
.
MIN
)
;
if
(
isCrossDay
)
{
log
.
info
(
"离床预警跨天处理:config:{}"
,
config
.
getRuleConfig
());
handleCrossDay
(
alarmRedisDTO
,
ruleConfig
,
platAlarmCheckDTO
,
config
,
deviceId
);
...
...
@@ -195,6 +196,9 @@ public class OffBedAlarm implements IAlarm {
LocalTime
startTime
=
ruleConfig
.
getOffBedStart
();
LocalDateTime
startLocalDteTime
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
startTime
);
LocalTime
endTime
=
ruleConfig
.
getOffBedEnd
();
if
(
LocalTime
.
MIN
.
equals
(
endTime
))
{
endTime
=
LocalTime
.
MAX
;
}
// LocalDateTime endLocalDteTime = LocalDateTime.of(LocalDate.now(), endTime);
Long
firstOffBedLong
=
alarmRedisDTO
.
getStartLong
();
...
...
@@ -335,4 +339,12 @@ public class OffBedAlarm implements IAlarm {
return
Date
.
from
(
zdt
.
toInstant
());
}
public
static
void
main
(
String
[]
args
)
{
LocalTime
of
=
LocalTime
.
of
(
0
,
0
);
LocalTime
of1
=
LocalTime
.
of
(
00
,
00
);
System
.
out
.
println
(
of
.
equals
(
of1
));
System
.
out
.
println
(
LocalTime
.
MIN
);
}
}
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