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
7ab887cd
authored
Dec 18, 2023
by
汪志阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:去除模拟时间代码
parent
f3f9905e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
18 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 @
7ab887cd
...
@@ -93,6 +93,10 @@ public class OffBedAlarm implements IAlarm {
...
@@ -93,6 +93,10 @@ public class OffBedAlarm implements IAlarm {
log
.
error
(
"离床告警配置时间段解析失败,config:{}"
,
JSONUtil
.
toJsonStr
(
ruleConfig
));
log
.
error
(
"离床告警配置时间段解析失败,config:{}"
,
JSONUtil
.
toJsonStr
(
ruleConfig
));
return
;
return
;
}
}
// 00:00 -> 23:59:59999
if
(
LocalTime
.
MIN
.
equals
(
endTime
))
{
ruleConfig
.
setOffBedEnd
(
LocalTime
.
MAX
);
}
log
.
info
(
"离床预警时间范围,begin:{},end:{}"
,
startTime
,
endTime
);
log
.
info
(
"离床预警时间范围,begin:{},end:{}"
,
startTime
,
endTime
);
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"person"
));
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"person"
));
boolean
isOffBed
=
"0"
.
equals
(
personState
);
boolean
isOffBed
=
"0"
.
equals
(
personState
);
...
@@ -148,7 +152,6 @@ public class OffBedAlarm implements IAlarm {
...
@@ -148,7 +152,6 @@ public class OffBedAlarm implements IAlarm {
Long
firstOffBedLong
=
alarmRedisDTO
.
getStartLong
();
Long
firstOffBedLong
=
alarmRedisDTO
.
getStartLong
();
long
currentTimeMillis
=
System
.
currentTimeMillis
();
long
currentTimeMillis
=
System
.
currentTimeMillis
();
// todo 模拟时间
currentTimeMillis
=
currentLong
();
currentTimeMillis
=
currentLong
();
boolean
isOverTime
=
(
currentTimeMillis
-
firstOffBedLong
)
/
1000
>=
duration
*
60
;
boolean
isOverTime
=
(
currentTimeMillis
-
firstOffBedLong
)
/
1000
>=
duration
*
60
;
LocalDateTime
firstOffBedTime
=
LocalDateTime
.
ofInstant
(
Instant
.
ofEpochMilli
(
firstOffBedLong
),
ZoneOffset
.
of
(
"+8"
));
LocalDateTime
firstOffBedTime
=
LocalDateTime
.
ofInstant
(
Instant
.
ofEpochMilli
(
firstOffBedLong
),
ZoneOffset
.
of
(
"+8"
));
...
@@ -165,8 +168,6 @@ public class OffBedAlarm implements IAlarm {
...
@@ -165,8 +168,6 @@ public class OffBedAlarm implements IAlarm {
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
return
;
return
;
}
}
// LocalDateTime now = LocalDateTime.now();
// todo 模拟时间
LocalDateTime
now
=
currentTime
();
LocalDateTime
now
=
currentTime
();
LocalDateTime
startLocalDteTime
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
startTime
);
LocalDateTime
startLocalDteTime
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
startTime
);
if
(!
isInTime
)
{
if
(!
isInTime
)
{
...
@@ -203,7 +204,6 @@ public class OffBedAlarm implements IAlarm {
...
@@ -203,7 +204,6 @@ public class OffBedAlarm implements IAlarm {
Long
firstOffBedLong
=
alarmRedisDTO
.
getStartLong
();
Long
firstOffBedLong
=
alarmRedisDTO
.
getStartLong
();
long
currentTimeMillis
=
System
.
currentTimeMillis
();
long
currentTimeMillis
=
System
.
currentTimeMillis
();
// todo 模拟时间
currentTimeMillis
=
currentLong
();
currentTimeMillis
=
currentLong
();
boolean
isOverTime
=
(
currentTimeMillis
-
firstOffBedLong
)
/
1000
>=
duration
*
60
;
boolean
isOverTime
=
(
currentTimeMillis
-
firstOffBedLong
)
/
1000
>=
duration
*
60
;
LocalDateTime
firstOffBedTime
=
LocalDateTime
.
ofInstant
(
Instant
.
ofEpochMilli
(
firstOffBedLong
),
ZoneOffset
.
of
(
"+8"
));
LocalDateTime
firstOffBedTime
=
LocalDateTime
.
ofInstant
(
Instant
.
ofEpochMilli
(
firstOffBedLong
),
ZoneOffset
.
of
(
"+8"
));
...
@@ -225,8 +225,6 @@ public class OffBedAlarm implements IAlarm {
...
@@ -225,8 +225,6 @@ public class OffBedAlarm implements IAlarm {
return
;
return
;
}
}
// todo 模拟时间
// LocalDateTime now = LocalDateTime.now();
LocalDateTime
now
=
currentTime
();
LocalDateTime
now
=
currentTime
();
LocalTime
localTime
=
LocalTime
.
now
();
LocalTime
localTime
=
LocalTime
.
now
();
if
(!
isInTime
&&
localTime
.
isAfter
(
startTime
)
&&
localTime
.
isBefore
(
endTime
))
{
if
(!
isInTime
&&
localTime
.
isAfter
(
startTime
)
&&
localTime
.
isBefore
(
endTime
))
{
...
@@ -246,7 +244,6 @@ public class OffBedAlarm implements IAlarm {
...
@@ -246,7 +244,6 @@ public class OffBedAlarm implements IAlarm {
}
}
private
void
sendToRedis
(
AlarmRedisDTO
alarmRedisDTO
,
String
deviceId
)
{
private
void
sendToRedis
(
AlarmRedisDTO
alarmRedisDTO
,
String
deviceId
)
{
// todo 模拟时间
Date
now
=
toDate
();
Date
now
=
toDate
();
// Date now = new Date();
// Date now = new Date();
long
endLong
=
now
.
getTime
();
long
endLong
=
now
.
getTime
();
...
@@ -255,7 +252,6 @@ public class OffBedAlarm implements IAlarm {
...
@@ -255,7 +252,6 @@ public class OffBedAlarm implements IAlarm {
alarmRedisDTO
=
new
AlarmRedisDTO
();
alarmRedisDTO
=
new
AlarmRedisDTO
();
alarmRedisDTO
.
setAlarm
(
CommonEnum
.
NO
.
getValue
());
alarmRedisDTO
.
setAlarm
(
CommonEnum
.
NO
.
getValue
());
alarmRedisDTO
.
setStart
(
now
);
alarmRedisDTO
.
setStart
(
now
);
// todo 模拟时间
endLong
=
currentLong
();
endLong
=
currentLong
();
alarmRedisDTO
.
setStartLong
(
endLong
);
alarmRedisDTO
.
setStartLong
(
endLong
);
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
,
alarmRedisDTO
);
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
,
alarmRedisDTO
);
...
@@ -326,7 +322,8 @@ public class OffBedAlarm implements IAlarm {
...
@@ -326,7 +322,8 @@ public class OffBedAlarm implements IAlarm {
}
}
private
LocalDateTime
currentTime
()
{
private
LocalDateTime
currentTime
()
{
return
LocalDateTime
.
now
().
plusHours
(
8
);
// return LocalDateTime.now().plusHours(7);
return
LocalDateTime
.
now
();
}
}
private
LocalDateTime
longToTime
(
Long
longTime
)
{
private
LocalDateTime
longToTime
(
Long
longTime
)
{
...
@@ -338,13 +335,4 @@ public class OffBedAlarm implements IAlarm {
...
@@ -338,13 +335,4 @@ public class OffBedAlarm implements IAlarm {
ZonedDateTime
zdt
=
currentTime
().
atZone
(
zoneId
);
ZonedDateTime
zdt
=
currentTime
().
atZone
(
zoneId
);
return
Date
.
from
(
zdt
.
toInstant
());
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