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
451d718a
authored
Dec 10, 2023
by
汪志阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:修复bug
parent
4ef7b8e9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 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 @
451d718a
...
@@ -13,7 +13,6 @@ import com.makeit.entity.platform.elder.PlatElder;
...
@@ -13,7 +13,6 @@ import com.makeit.entity.platform.elder.PlatElder;
import
com.makeit.enums.CommonEnum
;
import
com.makeit.enums.CommonEnum
;
import
com.makeit.enums.platform.alarm.PlatAlarmConfigEnum
;
import
com.makeit.enums.platform.alarm.PlatAlarmConfigEnum
;
import
com.makeit.enums.redis.RedisConst
;
import
com.makeit.enums.redis.RedisConst
;
import
com.makeit.module.iot.enums.DeviceInfoContentBreatheEnum
;
import
com.makeit.service.platform.alarm.PlatAlarmRecordService
;
import
com.makeit.service.platform.alarm.PlatAlarmRecordService
;
import
com.makeit.utils.AlarmRedisDTO
;
import
com.makeit.utils.AlarmRedisDTO
;
import
com.makeit.utils.data.convert.JsonUtil
;
import
com.makeit.utils.data.convert.JsonUtil
;
...
@@ -56,12 +55,12 @@ public class OffBedAlarm implements IAlarm {
...
@@ -56,12 +55,12 @@ public class OffBedAlarm implements IAlarm {
platAlarmRecordService
.
getElderListByDeviceId
(
platAlarmCheckDTO
);
platAlarmRecordService
.
getElderListByDeviceId
(
platAlarmCheckDTO
);
List
<
PlatElder
>
platElderList
=
platAlarmCheckDTO
.
getPlatElderList
();
List
<
PlatElder
>
platElderList
=
platAlarmCheckDTO
.
getPlatElderList
();
if
(
CollectionUtils
.
isEmpty
(
platElderList
))
{
if
(
CollectionUtils
.
isEmpty
(
platElderList
))
{
log
.
error
(
"
呼吸
告警心率设备未关联长者,设备plat_id:"
+
platAlarmCheckDTO
.
getPlatDevice
().
getId
());
log
.
error
(
"
离床
告警心率设备未关联长者,设备plat_id:"
+
platAlarmCheckDTO
.
getPlatDevice
().
getId
());
return
;
return
;
}
}
PlatAlarmConfig
config
=
platAlarmCheckDTO
.
getPlatAlarmConfig
();
PlatAlarmConfig
config
=
platAlarmCheckDTO
.
getPlatAlarmConfig
();
if
(!
"5"
.
equals
(
config
.
getAlarmType
()))
{
if
(!
"5"
.
equals
(
config
.
getAlarmType
()))
{
log
.
error
(
"
呼吸
告警配置不存在,config:{}"
,
JSONUtil
.
toJsonStr
(
config
));
log
.
error
(
"
离床
告警配置不存在,config:{}"
,
JSONUtil
.
toJsonStr
(
config
));
return
;
return
;
}
}
if
(
CommonEnum
.
NO
.
getValue
().
equals
(
config
.
getStatus
()))
{
if
(
CommonEnum
.
NO
.
getValue
().
equals
(
config
.
getStatus
()))
{
...
@@ -87,7 +86,7 @@ public class OffBedAlarm implements IAlarm {
...
@@ -87,7 +86,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
))
{
log
.
error
(
"离床告警配置时间段解析失败,config:{}"
,
JSONUtil
.
toJsonStr
(
ruleConfig
));
log
.
warn
(
"离床告警配置时间段解析失败,config:{}"
,
JSONUtil
.
toJsonStr
(
ruleConfig
));
return
;
return
;
}
}
LocalDateTime
startTime
=
timeRange
.
get
(
0
);
LocalDateTime
startTime
=
timeRange
.
get
(
0
);
...
@@ -95,7 +94,7 @@ public class OffBedAlarm implements IAlarm {
...
@@ -95,7 +94,7 @@ public class OffBedAlarm implements IAlarm {
Integer
duration
=
ruleConfig
.
getDuration
();
Integer
duration
=
ruleConfig
.
getDuration
();
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"personState"
));
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"personState"
));
boolean
isInRange
=
LocalDateTime
.
now
().
isAfter
(
startTime
)
&&
LocalDateTime
.
now
().
isBefore
(
endTime
);
boolean
isInRange
=
LocalDateTime
.
now
().
isAfter
(
startTime
)
&&
LocalDateTime
.
now
().
isBefore
(
endTime
);
if
(!
DeviceInfoContentBreatheEnum
.
PersonStateEnum
.
NOBODY
.
eq
(
personState
)
||
!
isInRange
)
{
if
(!
"0"
.
equals
(
personState
)
||
!
isInRange
)
{
return
;
return
;
}
}
AlarmRedisDTO
alarmRedisDTO
=
RedisUtil
.
get
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
);
AlarmRedisDTO
alarmRedisDTO
=
RedisUtil
.
get
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
);
...
@@ -107,10 +106,10 @@ public class OffBedAlarm implements IAlarm {
...
@@ -107,10 +106,10 @@ public class OffBedAlarm implements IAlarm {
alarmRedisDTO
.
setStart
(
now
);
alarmRedisDTO
.
setStart
(
now
);
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
);
log
.
info
(
"发现长者设备状态无人,设备plat_id:"
+
deviceId
);
log
.
warn
(
"发现长者设备状态无人,设备plat_id:"
+
deviceId
);
return
;
return
;
}
}
log
.
info
(
"redis获取offbed数据:{}"
,
JSONUtil
.
toJsonStr
(
alarmRedisDTO
));
log
.
warn
(
"redis获取offbed数据:{}"
,
JSONUtil
.
toJsonStr
(
alarmRedisDTO
));
Date
now
=
new
Date
();
Date
now
=
new
Date
();
long
endLong
=
now
.
getTime
();
long
endLong
=
now
.
getTime
();
Long
startLong
=
alarmRedisDTO
.
getStartLong
();
Long
startLong
=
alarmRedisDTO
.
getStartLong
();
...
@@ -118,7 +117,7 @@ public class OffBedAlarm implements IAlarm {
...
@@ -118,7 +117,7 @@ public class OffBedAlarm implements IAlarm {
String
messageType
=
platAlarmCheckDTO
.
getMessageType
();
String
messageType
=
platAlarmCheckDTO
.
getMessageType
();
if
(
count
/
1000
>=
duration
)
{
if
(
count
/
1000
>=
duration
)
{
if
(
StringUtils
.
equals
(
alarmRedisDTO
.
getAlarm
(),
CommonEnum
.
YES
.
getValue
()))
{
if
(
StringUtils
.
equals
(
alarmRedisDTO
.
getAlarm
(),
CommonEnum
.
YES
.
getValue
()))
{
log
.
info
(
"离床告警已告警过,设备plat_id:"
+
deviceId
);
log
.
warn
(
"离床告警已告警过,设备plat_id:"
+
deviceId
);
return
;
return
;
}
}
alarmRedisDTO
.
setStartLong
(
endLong
);
alarmRedisDTO
.
setStartLong
(
endLong
);
...
@@ -127,11 +126,9 @@ public class OffBedAlarm implements IAlarm {
...
@@ -127,11 +126,9 @@ public class OffBedAlarm implements IAlarm {
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
count
));
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
count
));
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
,
alarmRedisDTO
);
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
,
alarmRedisDTO
);
notice
(
platAlarmCheckDTO
);
notice
(
platAlarmCheckDTO
);
}
}
else
if
(
StringUtils
.
equalsAnyIgnoreCase
(
messageType
,
"REPORT_PROPERTY"
,
"OFFLINE"
,
"DISCONNECT"
))
{
log
.
warn
(
"删除redisoffbed预警"
);
if
(
StringUtils
.
equalsAnyIgnoreCase
(
messageType
,
"REPORT_PROPERTY"
,
"OFFLINE"
,
"DISCONNECT"
))
{
RedisUtil
.
delete
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
);
log
.
info
(
"删除redisoffbed预警"
);
// RedisUtil.delete(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId);
}
}
}
}
...
@@ -188,4 +185,8 @@ public class OffBedAlarm implements IAlarm {
...
@@ -188,4 +185,8 @@ public class OffBedAlarm implements IAlarm {
log
.
info
(
"离床告警配置,发出告警,设备id:"
+
platDevice
.
getId
()
+
", 长者名称:"
+
platElder
.
getName
());
log
.
info
(
"离床告警配置,发出告警,设备id:"
+
platDevice
.
getId
()
+
", 长者名称:"
+
platElder
.
getName
());
}
}
}
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
();
}
}
}
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