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
35d8f542
authored
Dec 14, 2023
by
汪志阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:离床预警时间bug修复
parent
5d960feb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 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 @
35d8f542
...
@@ -91,7 +91,7 @@ public class OffBedAlarm implements IAlarm {
...
@@ -91,7 +91,7 @@ public class OffBedAlarm implements IAlarm {
}
}
String
deviceId
=
platDevice
.
getId
();
String
deviceId
=
platDevice
.
getId
();
List
<
LocalDateTime
>
timeRange
=
getOffTimeRange
(
ruleConfig
);
List
<
LocalDateTime
>
timeRange
=
getOffTimeRange
(
ruleConfig
);
if
(
CollUtil
.
isEmpty
(
timeRange
))
{
if
(
CollUtil
.
isEmpty
(
timeRange
)
||
timeRange
.
get
(
0
)
==
null
||
timeRange
.
get
(
1
)
==
null
)
{
log
.
error
(
"离床告警配置时间段解析失败,config:{}"
,
JSONUtil
.
toJsonStr
(
ruleConfig
));
log
.
error
(
"离床告警配置时间段解析失败,config:{}"
,
JSONUtil
.
toJsonStr
(
ruleConfig
));
return
;
return
;
}
}
...
@@ -203,16 +203,27 @@ public class OffBedAlarm implements IAlarm {
...
@@ -203,16 +203,27 @@ public class OffBedAlarm implements IAlarm {
}
}
/**
* 22-4 :昨天22-今天4 22-20:昨天22-今天20 22-23:今天22-23
* @param ruleConfig
* @return
*/
private
List
<
LocalDateTime
>
getOffTimeRange
(
PlatAlarmConfigOffBedDTOVO
ruleConfig
)
{
private
List
<
LocalDateTime
>
getOffTimeRange
(
PlatAlarmConfigOffBedDTOVO
ruleConfig
)
{
List
<
LocalDateTime
>
result
=
new
ArrayList
<>();
List
<
LocalDateTime
>
result
=
new
ArrayList
<>();
LocalTime
offBedStart
=
ruleConfig
.
getOffBedStart
();
LocalTime
offBedEnd
=
ruleConfig
.
getOffBedEnd
();
LocalDate
localDate
=
LocalDate
.
now
();
LocalDate
localDate
=
LocalDate
.
now
();
LocalDateTime
startTime
=
LocalDateTime
.
of
(
localDate
,
ruleConfig
.
getOffBedStart
());
LocalDateTime
startTime
=
null
;
LocalDateTime
endTime
;
LocalDateTime
endTime
=
null
;
boolean
isNextDay
=
ruleConfig
.
getOffBedStart
().
isAfter
(
ruleConfig
.
getOffBedEnd
());
// 22-23:今天22-23
if
(
isNextDay
)
{
if
(
offBedStart
.
isBefore
(
offBedEnd
))
{
endTime
=
LocalDateTime
.
of
(
localDate
.
plusDays
(
1
),
ruleConfig
.
getOffBedEnd
());
startTime
=
LocalDateTime
.
of
(
localDate
,
offBedStart
);
}
else
{
endTime
=
LocalDateTime
.
of
(
localDate
,
offBedEnd
);
endTime
=
LocalDateTime
.
of
(
localDate
,
ruleConfig
.
getOffBedEnd
());
}
// 22-4 :昨天22-今天4
if
(
offBedStart
.
isAfter
(
offBedEnd
))
{
startTime
=
LocalDateTime
.
of
(
localDate
.
plusDays
(-
1
),
offBedStart
);
endTime
=
LocalDateTime
.
of
(
localDate
,
offBedEnd
);
}
}
result
.
add
(
startTime
);
result
.
add
(
startTime
);
result
.
add
(
endTime
);
result
.
add
(
endTime
);
...
...
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