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
1e0979e1
authored
Dec 12, 2023
by
汪志阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:离床时间跨天处理
parent
204b709d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 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 @
1e0979e1
...
@@ -79,6 +79,10 @@ public class OffBedAlarm implements IAlarm {
...
@@ -79,6 +79,10 @@ public class OffBedAlarm implements IAlarm {
log
.
error
(
"离床告警配置解析失败,config:{}"
,
JSONUtil
.
toJsonStr
(
config
));
log
.
error
(
"离床告警配置解析失败,config:{}"
,
JSONUtil
.
toJsonStr
(
config
));
return
;
return
;
}
}
if
(!
"0"
.
equals
(
ruleConfig
.
getStartTimeType
())
||
ruleConfig
.
getOffBedStart
().
isAfter
(
ruleConfig
.
getOffBedEnd
()))
{
return
;
}
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
if
(
properties
==
null
)
{
if
(
properties
==
null
)
{
properties
=
new
JSONObject
();
properties
=
new
JSONObject
();
...
@@ -93,6 +97,7 @@ public class OffBedAlarm implements IAlarm {
...
@@ -93,6 +97,7 @@ public class OffBedAlarm implements IAlarm {
LocalDateTime
startTime
=
timeRange
.
get
(
0
);
LocalDateTime
startTime
=
timeRange
.
get
(
0
);
LocalDateTime
endTime
=
timeRange
.
get
(
1
);
LocalDateTime
endTime
=
timeRange
.
get
(
1
);
Integer
duration
=
ruleConfig
.
getDuration
();
Integer
duration
=
ruleConfig
.
getDuration
();
boolean
isNextDay
=
"1"
.
equals
(
ruleConfig
.
getEndTimeType
());
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"person"
));
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"person"
));
boolean
isOffBed
=
"0"
.
equals
(
personState
);
boolean
isOffBed
=
"0"
.
equals
(
personState
);
// 1-有人 0-无人
// 1-有人 0-无人
...
@@ -133,7 +138,9 @@ public class OffBedAlarm implements IAlarm {
...
@@ -133,7 +138,9 @@ public class OffBedAlarm implements IAlarm {
return
;
return
;
}
}
}
}
if
(
isNextDay
)
{
endTime
=
endTime
.
plusDays
(
1
);
}
LocalDateTime
validEndTime
=
endTime
.
plusMinutes
(
duration
);
LocalDateTime
validEndTime
=
endTime
.
plusMinutes
(
duration
);
// 离床时间在范围时间内(小于范围结束时间-持续分钟)
// 离床时间在范围时间内(小于范围结束时间-持续分钟)
boolean
isOffBedValid
=
firstOffBedTime
.
isAfter
(
startTime
)
&&
firstOffBedTime
.
isBefore
(
validEndTime
);
boolean
isOffBedValid
=
firstOffBedTime
.
isAfter
(
startTime
)
&&
firstOffBedTime
.
isBefore
(
validEndTime
);
...
@@ -187,9 +194,8 @@ public class OffBedAlarm implements IAlarm {
...
@@ -187,9 +194,8 @@ public class OffBedAlarm implements IAlarm {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
LocalDateTime
startTime
=
LocalDateTime
.
of
(
2023
,
12
,
12
,
15
,
43
);
LocalDateTime
startTime
=
LocalDateTime
.
of
(
2023
,
12
,
12
,
15
,
43
);
boolean
over
=
(
Math
.
abs
(
Duration
.
between
(
LocalDateTime
.
now
(),
startTime
).
toMillis
()))
/
1000
>=
2
*
60
;
System
.
out
.
println
(
startTime
);
System
.
out
.
println
(
over
);
System
.
out
.
println
(
startTime
.
plusDays
(
1
));
System
.
out
.
println
(
Duration
.
between
(
LocalDateTime
.
now
(),
startTime
).
toMillis
());
}
}
private
void
sendToRedis
(
AlarmRedisDTO
alarmRedisDTO
,
String
deviceId
)
{
private
void
sendToRedis
(
AlarmRedisDTO
alarmRedisDTO
,
String
deviceId
)
{
...
...
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