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
b4067fd8
authored
Feb 06, 2024
by
汪志阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:离床日志输出
parent
9c792fbc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
55 deletions
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/OffBedAlarm.java
server-web/src/test/java/com/makeit/iotapi/IotDeviceInfoContentFall.java
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/OffBedAlarm.java
View file @
b4067fd8
...
...
@@ -171,11 +171,11 @@ public class OffBedAlarm implements IAlarm {
if
(
isInTime
&&
isOverTime
)
{
// 离床时间为23:00-1:00 持续时间5分钟 ,第一次离床为0:55,满足条件的时间>1:00,不预警
if
(
firstTime
.
isAfter
(
endTimeLimit
)
&&
firstTime
.
isBefore
(
endTime
))
{
log
.
info
(
"deviceId:{},UnCrossDay第一次离床时间,{}+持续时间:{}将超过范围,{}"
,
deviceId
,
firstTime
,
duration
,
endTime
);
//
log.info("deviceId:{},UnCrossDay第一次离床时间,{}+持续时间:{}将超过范围,{}", deviceId, firstTime, duration, endTime);
return
;
}
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
currentTimeMillis
-
firstOffBedLong
));
log
.
info
(
"deviceId:{},cross离床告警离床时间在范围时间内,配置:{}"
,
deviceId
,
config
.
getRuleConfig
());
//
log.info("deviceId:{},cross离床告警离床时间在范围时间内,配置:{}", deviceId, config.getRuleConfig());
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
// platAlarmCheckDTO.setAlarmRecordId(IdWorker.getIdStr(PlatAlarmRecord.class));
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
...
...
@@ -188,15 +188,15 @@ public class OffBedAlarm implements IAlarm {
boolean
noInOverTime
=
mills
>=
duration
*
60
;
if
(
noInOverTime
)
{
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
currentTimeMillis
-
firstOffBedLong
));
log
.
info
(
"deviceId:{}, cross离床告警第一次离床时间在范围前,配置:{}"
,
deviceId
,
config
.
getRuleConfig
());
//
log.info("deviceId:{}, cross离床告警第一次离床时间在范围前,配置:{}", deviceId, config.getRuleConfig());
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
}
else
{
log
.
info
(
"deviceId:{},cross离床告警,第一次离床时间在范围前,未预警,配置:{},"
,
deviceId
,
config
.
getRuleConfig
());
//
log.info("deviceId:{},cross离床告警,第一次离床时间在范围前,未预警,配置:{},", deviceId, config.getRuleConfig());
}
}
else
{
log
.
info
(
"deviceId:{},Cross 未满足预警条件!first:{},config:{}"
,
deviceId
,
firstTime
,
config
.
getRuleConfig
());
//
log.info("deviceId:{},Cross 未满足预警条件!first:{},config:{}", deviceId, firstTime, config.getRuleConfig());
}
}
...
...
@@ -229,12 +229,12 @@ public class OffBedAlarm implements IAlarm {
// 离床时间在范围内
if
(
isInTime
&&
isOverTime
)
{
if
(
firstTime
.
isAfter
(
endTimeLimit
))
{
log
.
info
(
"deviceId:{},UnCrossDay第一次离床时间,{}+持续时间:{}将超过范围,{}"
,
deviceId
,
firstTime
,
duration
,
endTime
);
//
log.info("deviceId:{},UnCrossDay第一次离床时间,{}+持续时间:{}将超过范围,{}", deviceId, firstTime, duration, endTime);
return
;
}
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
currentTimeMillis
-
firstOffBedLong
));
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
log
.
info
(
"deviceId:{},uncross离床告警离床时间在范围时间内,配置:{}"
,
deviceId
,
config
.
getRuleConfig
());
//
log.info("deviceId:{},uncross离床告警离床时间在范围时间内,配置:{}", deviceId, config.getRuleConfig());
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
return
;
}
...
...
@@ -244,26 +244,26 @@ public class OffBedAlarm implements IAlarm {
LocalDateTime
dateTime
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
startTime
);
long
mills
=
Duration
.
between
(
dateTime
,
currentTime
()).
toMillis
()
/
1000
;
if
(
mills
>=
86400
)
{
log
.
info
(
"uncross离床告警第一次离床时间在范围前,跨天了:mills:{}"
,
mills
);
//
log.info("uncross离床告警第一次离床时间在范围前,跨天了:mills:{}", mills);
mills
=
mills
-
86400
;
}
if
(
mills
<=
-
86400
)
{
log
.
info
(
"uncross离床告警第一次离床时间在范围前,跨天了:mills:{}"
,
mills
);
//
log.info("uncross离床告警第一次离床时间在范围前,跨天了:mills:{}", mills);
mills
=
mills
+
86400
;
}
boolean
noInOverTime
=
mills
>=
duration
*
60
;
if
(
noInOverTime
)
{
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
currentTimeMillis
-
firstOffBedLong
));
log
.
info
(
"deviceId:{},uncross离床告警第一次离床时间在范围前,配置:{},date:{},mills:{},first:{}"
,
deviceId
,
config
.
getRuleConfig
(),
dateTime
,
mills
,
firstTime
);
//
log.info("deviceId:{},uncross离床告警第一次离床时间在范围前,配置:{},date:{},mills:{},first:{}",
//
deviceId, config.getRuleConfig(),dateTime,mills,firstTime);
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
}
else
{
log
.
info
(
"deviceId:{},uncross离床告警第一次离床时间在范围前,未预警,配置:{},间隔:{},first:{}"
,
deviceId
,
config
.
getRuleConfig
(),
mills
,
firstTime
);
//
log.info("deviceId:{},uncross离床告警第一次离床时间在范围前,未预警,配置:{},间隔:{},first:{}",
//
deviceId, config.getRuleConfig(), mills, firstTime);
}
}
else
{
log
.
info
(
"deviceId:{},UnCrossDay 未满足预警条件!fis:{},config:{}"
,
deviceId
,
firstTime
,
config
.
getRuleConfig
());
//
log.info("deviceId:{},UnCrossDay 未满足预警条件!fis:{},config:{}", deviceId, firstTime, config.getRuleConfig());
}
}
...
...
@@ -289,13 +289,13 @@ public class OffBedAlarm implements IAlarm {
LocalDateTime
firstOffBedTime
=
longToTime
(
alarmRedisDTO
.
getStartLong
());
String
remark
=
"第一次离床时间:"
+
firstOffBedTime
+
",config:"
+
platAlarmConfig
.
getRuleConfig
()
+
",当前时间:"
+
currentTime
();
platAlarmCheckDTO
.
setRemark
(
remark
);
notice
(
platAlarmCheckDTO
);
alarmRedisDTO
.
setStart
(
new
Date
());
alarmRedisDTO
.
setAlarm
(
CommonEnum
.
YES
.
getValue
());
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
,
alarmRedisDTO
);
log
.
info
(
"deviceId:{},离床告警推送离床消息,第一次上报时间:{},开始上报时间:{},是否上报:{},上报的config:{}"
,
deviceId
,
longToTime
(
alarmRedisDTO
.
getStartLong
()),
alarmRedisDTO
.
getStart
(),
alarmRedisDTO
.
getAlarm
()
,
platAlarmConfig
.
getRuleConfig
());
notice
(
platAlarmCheckDTO
);
// log.info("deviceId:{},离床告警推送离床消息,第一次上报时间:{},开始上报时间:{},是否上报:{},上报的config:{}", deviceId,
// longToTime(alarmRedisDTO.getStartLong()), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm()
// , platAlarmConfig.getRuleConfig());
}
@Override
...
...
@@ -317,8 +317,7 @@ public class OffBedAlarm implements IAlarm {
return
;
}
// PlatRoom platRoom = platAlarmCheckDTO.getPlatRoom();
log
.
info
(
"离床告警配置,发出告警,设备id:{},长者名称:{},config_id:{},configL{}"
,
platDevice
.
getId
(),
JSONUtil
.
toJsonStr
(
platElderList
),
config
.
getId
(),
config
.
getRuleConfig
());
log
.
info
(
"离床告警配置,发出告警,设备id:{},长者名称:{},,config{}"
,
platDevice
.
getId
(),
JSONUtil
.
toJsonStr
(
platElderList
),
config
.
getRuleConfig
());
platElderList
=
platElderList
.
stream
().
distinct
().
collect
(
Collectors
.
toList
());
for
(
PlatElder
platElder
:
platElderList
)
{
List
<
String
>
param
=
new
ArrayList
<>();
...
...
@@ -329,9 +328,11 @@ public class OffBedAlarm implements IAlarm {
platAlarmRecord
.
setElderName
(
platElder
.
getName
());
platAlarmRecord
.
setElderIds
(
platElder
.
getId
());
platAlarmRecord
.
setRemark
(
platAlarmCheckDTO
.
getRemark
());
platAlarmRecordService
.
noticeDeviceAlarm
(
platAlarmCheckDTO
.
getPlatAlarmConfig
(),
platAlarmRecord
);
log
.
info
(
"离床告警配置,发出告警,设备id:"
+
platDevice
.
getId
()
+
", 长者名称:"
+
platElder
.
getName
()
+
"config_id:"
+
config
.
getId
()
+
"--"
+
config
.
getRuleConfig
());
try
{
platAlarmRecordService
.
noticeDeviceAlarm
(
platAlarmCheckDTO
.
getPlatAlarmConfig
(),
platAlarmRecord
);
}
catch
(
Exception
e
)
{
log
.
error
(
"离床通知异常:{}"
,
e
.
getMessage
());
}
}
}
...
...
server-web/src/test/java/com/makeit/iotapi/IotDeviceInfoContentFall.java
View file @
b4067fd8
package
com
.
makeit
.
iotapi
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.makeit.dto.platform.alarm.PlatAlarmCheckDTO
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.module.admin.vo.plat.PlatTenantVO
;
import
com.makeit.module.iot.service.IotOrgService
;
import
com.makeit.module.iot.service.IotProductDeviceService
;
import
com.makeit.module.iot.service.IotTokenService
;
import
com.makeit.service.platform.alarm.alarmStrategy.OffBedAlarm
;
import
com.makeit.service.platform.elder.PlatElderSleepService
;
import
com.makeit.utils.redis.RedisUtil
;
import
org.junit.jupiter.api.Test
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
...
...
@@ -28,13 +21,6 @@ public class IotDeviceInfoContentFall {
private
IotOrgService
iotOrgService
;
@Autowired
private
IotProductDeviceService
iotProductDeviceService
;
@Autowired
private
OffBedAlarm
offBedAlarm
;
@Autowired
private
PlatElderSleepService
platElderSleepService
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
IotDeviceInfoContentFall
.
class
);
@Test
...
...
@@ -95,24 +81,6 @@ public class IotDeviceInfoContentFall {
iotOrgService
.
updateIotOrgInfo
(
"1698964909267415040"
,
"lxl2234"
);
}
@Test
void
offBedAlarm
()
{
PlatAlarmCheckDTO
platAlarmCheckDTO
=
new
PlatAlarmCheckDTO
();
PlatDevice
platDevice
=
new
PlatDevice
();
platDevice
.
setOrgId
(
"1712384736845950978"
);
platDevice
.
setId
(
"1732609639364812811"
);
platAlarmCheckDTO
.
setPlatDevice
(
platDevice
);
JSONObject
properties
=
JSON
.
parseObject
(
"{\n"
+
" \"person\": 0,\n"
+
" \"personState\": 0,\n"
+
" \"distance\": 50,\n"
+
" \"hr\": 80,\n"
+
" \"br\": 20,\n"
+
" \"bodymove\": 50,\n}"
);
platAlarmCheckDTO
.
setProperties
(
properties
);
offBedAlarm
.
checkConfig
(
platAlarmCheckDTO
);
}
@Test
void
getRedis
()
{
...
...
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