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
8705a55d
authored
Dec 12, 2023
by
汪志阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:离床时间跨天处理
parent
1e0979e1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
8 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 @
8705a55d
...
...
@@ -95,9 +95,8 @@ public class OffBedAlarm implements IAlarm {
return
;
}
LocalDateTime
startTime
=
timeRange
.
get
(
0
);
LocalDateTime
endTime
=
timeRange
.
get
(
1
);
LocalDateTime
endTime
=
"1"
.
equals
(
ruleConfig
.
getEndTimeType
())
?
timeRange
.
get
(
1
).
plusDays
(
1
)
:
timeRange
.
get
(
1
);
Integer
duration
=
ruleConfig
.
getDuration
();
boolean
isNextDay
=
"1"
.
equals
(
ruleConfig
.
getEndTimeType
());
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"person"
));
boolean
isOffBed
=
"0"
.
equals
(
personState
);
// 1-有人 0-无人
...
...
@@ -138,9 +137,6 @@ public class OffBedAlarm implements IAlarm {
return
;
}
}
if
(
isNextDay
)
{
endTime
=
endTime
.
plusDays
(
1
);
}
LocalDateTime
validEndTime
=
endTime
.
plusMinutes
(
duration
);
// 离床时间在范围时间内(小于范围结束时间-持续分钟)
boolean
isOffBedValid
=
firstOffBedTime
.
isAfter
(
startTime
)
&&
firstOffBedTime
.
isBefore
(
validEndTime
);
...
...
@@ -193,9 +189,11 @@ public class OffBedAlarm implements IAlarm {
}
public
static
void
main
(
String
[]
args
)
{
LocalDateTime
startTime
=
LocalDateTime
.
of
(
2023
,
12
,
12
,
15
,
43
);
System
.
out
.
println
(
startTime
);
System
.
out
.
println
(
startTime
.
plusDays
(
1
));
LocalDateTime
startTime
=
LocalDateTime
.
of
(
2023
,
12
,
12
,
23
,
59
);
long
second
=
startTime
.
toInstant
(
ZoneOffset
.
of
(
"+8"
)).
toEpochMilli
();
LocalDateTime
firstOffBedTime
=
LocalDateTime
.
ofInstant
(
Instant
.
ofEpochMilli
(
second
),
ZoneOffset
.
of
(
"+8"
));
System
.
out
.
println
(
second
);
System
.
out
.
println
(
firstOffBedTime
);
}
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