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
7aeedc74
authored
Dec 19, 2023
by
汪志阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:离床日志输出
parent
0e334a27
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
26 deletions
server-service/src/main/java/com/makeit/mapper/platform/alarm/PlatAlarmConfigMapper.java
server-service/src/main/java/com/makeit/service/platform/alarm/PlatAlarmConfigService.java
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/OffBedAlarm.java
server-service/src/main/java/com/makeit/service/platform/alarm/impl/PlatAlarmConfigServiceImpl.java
server-service/src/main/resources/mappers/PlatAlarmConfigMapper.xml
server-service/src/main/java/com/makeit/mapper/platform/alarm/PlatAlarmConfigMapper.java
View file @
7aeedc74
...
...
@@ -23,5 +23,5 @@ public interface PlatAlarmConfigMapper extends BaseMapper<PlatAlarmConfig> {
*/
List
<
PlatHealthConfigDTO
>
getHealthConfigList
();
List
<
PlatAlarmConfig
>
listOffBed
(
@Param
(
"
orgDeviceId"
)
String
orgD
eviceId
);
List
<
PlatAlarmConfig
>
listOffBed
(
@Param
(
"
deviceId"
)
String
d
eviceId
);
}
server-service/src/main/java/com/makeit/service/platform/alarm/PlatAlarmConfigService.java
View file @
7aeedc74
...
...
@@ -43,5 +43,5 @@ public interface PlatAlarmConfigService extends IService<PlatAlarmConfig> {
void
initData
();
List
<
PlatAlarmConfig
>
listOfBed
(
String
org
Id
);
List
<
PlatAlarmConfig
>
listOfBed
(
String
device
Id
);
}
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/OffBedAlarm.java
View file @
7aeedc74
...
...
@@ -65,7 +65,7 @@ public class OffBedAlarm implements IAlarm {
// PlatAlarmConfig config = alarmConfigCacheUtil.get(platDevice.getOrgId(), PlatAlarmConfigEnum.AlarmTypeEnum.OFF_BED.getValue());
// PlatAlarmConfig platAlarmConfig = platAlarmCheckDTO.getPlatAlarmConfig();
List
<
PlatAlarmConfig
>
configList
=
platAlarmConfigService
.
listOfBed
(
platDevice
.
getId
());
if
(
CollUtil
.
isNotEmpty
(
configList
))
{
if
(
CollUtil
.
isNotEmpty
(
configList
))
{
configList
.
forEach
(
c
->
{
log
.
info
(
"离床告警dto,org_config:{},设备id:{}"
,
c
.
getRuleConfig
(),
platDevice
.
getId
());
offBedCheckAlarm
(
c
,
platAlarmCheckDTO
,
platDevice
);
...
...
@@ -119,14 +119,13 @@ public class OffBedAlarm implements IAlarm {
// 1-有人 0-无人
AlarmRedisDTO
alarmRedisDTO
=
RedisUtil
.
get
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
);
if
(!
isOffBed
&&
alarmRedisDTO
!=
null
)
{
log
.
info
(
"
离床告警有人状态下,删除redis,deviceId:{}
"
,
deviceId
);
log
.
info
(
"
deviceId:{},离床告警有人状态下,删除redis
"
,
deviceId
);
RedisUtil
.
delete
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
);
return
;
}
// 设备无人,在范围内上报存储redis,超过离床持续时间,则预警
String
messageType
=
platAlarmCheckDTO
.
getMessageType
();
if
(
StringUtils
.
equalsAnyIgnoreCase
(
messageType
,
"OFFLINE"
,
"DISCONNECT"
))
{
log
.
info
(
"
离床告警设备下线,删除redis off_bed 预警,deviceId:{}
"
,
deviceId
);
log
.
info
(
"
deviceId:{},离床告警设备下线,删除redis off_bed 预警
"
,
deviceId
);
RedisUtil
.
delete
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
);
}
if
(
isOffBed
)
{
...
...
@@ -136,7 +135,7 @@ public class OffBedAlarm implements IAlarm {
alarmRedisDTO
=
RedisUtil
.
get
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
);
if
(
"1"
.
equals
(
alarmRedisDTO
.
getAlarm
()))
{
log
.
info
(
"
离床告警已发送预警过,第一次遇见时间:{}"
,
longToTime
(
alarmRedisDTO
.
getStartLong
()));
log
.
info
(
"
deviceId:{},离床告警已发送预警过,第一次离床时间:{}"
,
deviceId
,
longToTime
(
alarmRedisDTO
.
getStartLong
()));
return
;
}
// 是否跨天 xxx-0:00,未跨天
...
...
@@ -162,7 +161,7 @@ public class OffBedAlarm implements IAlarm {
PlatAlarmCheckDTO
platAlarmCheckDTO
,
PlatAlarmConfig
config
,
String
deviceId
)
{
log
.
info
(
"
cross_config:{},第一次离床时间:{}"
,
config
.
getRuleConfig
(),
longToTime
(
alarmRedisDTO
.
getStartLong
()));
log
.
info
(
"
deviceId:{},cross_config:{},第一次离床时间:{}"
,
deviceId
,
config
.
getRuleConfig
(),
longToTime
(
alarmRedisDTO
.
getStartLong
()));
Integer
duration
=
ruleConfig
.
getDuration
();
LocalTime
startTime
=
ruleConfig
.
getOffBedStart
();
LocalTime
endTime
=
ruleConfig
.
getOffBedEnd
();
...
...
@@ -177,7 +176,7 @@ public class OffBedAlarm implements IAlarm {
// 离床时间在范围内
if
(
isInTime
&&
isOverTime
)
{
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
currentTimeMillis
-
firstOffBedLong
));
log
.
info
(
"
cross离床告警离床时间在范围时间内,配置:{}"
,
config
.
getRuleConfig
());
log
.
info
(
"
deviceId:{},cross离床告警离床时间在范围时间内,配置:{}"
,
deviceId
,
config
.
getRuleConfig
());
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
return
;
...
...
@@ -189,15 +188,15 @@ public class OffBedAlarm implements IAlarm {
boolean
noInOverTime
=
mills
>=
duration
*
60
;
if
(
noInOverTime
)
{
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
currentTimeMillis
-
firstOffBedLong
));
log
.
info
(
"
cross离床告警第一次离床时间在范围前,配置:{}"
,
config
.
getRuleConfig
());
log
.
info
(
"
deviceId:{}, cross离床告警第一次离床时间在范围前,配置:{}"
,
deviceId
,
config
.
getRuleConfig
());
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
}
else
{
log
.
info
(
"
cross离床告警,第一次离床时间在范围前,未预警,配置:{},时间持续:{},start:{}"
,
config
.
getRuleConfig
(),
mills
,
startLocalDteTime
);
log
.
info
(
"
deviceId:{},cross离床告警,第一次离床时间在范围前,未预警,配置:{},时间持续:{},start:{}"
,
deviceId
,
config
.
getRuleConfig
(),
mills
,
startLocalDteTime
);
}
}
else
{
log
.
info
(
"
handleCrossDay 未满足预警条件!fisrttime:{},config:{}"
,
firstTime
,
config
.
getRuleConfig
());
log
.
info
(
"
deviceId:{},Cross 未满足预警条件!first:{},config:{}"
,
deviceId
,
firstTime
,
config
.
getRuleConfig
());
}
}
...
...
@@ -215,7 +214,7 @@ public class OffBedAlarm implements IAlarm {
PlatAlarmCheckDTO
platAlarmCheckDTO
,
PlatAlarmConfig
config
,
String
deviceId
)
{
log
.
info
(
"
uncross_config:{},第一次离床时间:{}"
,
config
.
getRuleConfig
(),
longToTime
(
alarmRedisDTO
.
getStartLong
()));
log
.
info
(
"
deviceId:{},uncross_config:{},第一次离床时间:{}"
,
deviceId
,
config
.
getRuleConfig
(),
longToTime
(
alarmRedisDTO
.
getStartLong
()));
Integer
duration
=
ruleConfig
.
getDuration
();
LocalTime
startTime
=
ruleConfig
.
getOffBedStart
();
LocalDateTime
startLocalDteTime
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
startTime
);
...
...
@@ -232,31 +231,31 @@ public class OffBedAlarm implements IAlarm {
// 离床时间在范围内
if
(
isInTime
&&
isOverTime
)
{
if
(
firstTime
.
isAfter
(
endTimeLimit
))
{
log
.
info
(
"
handleUnCrossDay第一次离床时间,{}+持续时间:{}将超过范围,{}"
,
firstTime
,
duration
,
endTime
);
log
.
info
(
"
deviceId:{},UnCrossDay第一次离床时间,{}+持续时间:{}将超过范围,{}"
,
deviceId
,
firstTime
,
duration
,
endTime
);
return
;
}
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
currentTimeMillis
-
firstOffBedLong
));
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
log
.
info
(
"
uncross离床告警离床时间在范围时间内,配置:{}"
,
config
.
getRuleConfig
());
log
.
info
(
"
deviceId:{},uncross离床告警离床时间在范围时间内,配置:{}"
,
deviceId
,
config
.
getRuleConfig
());
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
return
;
}
LocalDateTime
now
=
currentTime
();
LocalTime
localTime
=
LocalTime
.
now
().
plusHours
(
12
);
LocalTime
localTime
=
LocalTime
.
now
().
plusHours
(
9
);
if
(!
isInTime
&&
localTime
.
isAfter
(
startTime
)
&&
localTime
.
isBefore
(
endTime
))
{
long
mills
=
Duration
.
between
(
startLocalDteTime
,
now
).
toMillis
()
/
1000
;
boolean
noInOverTime
=
mills
>=
duration
*
60
;
if
(
noInOverTime
)
{
platAlarmCheckDTO
.
setAbnormalValue
(
String
.
valueOf
(
currentTimeMillis
-
firstOffBedLong
));
log
.
info
(
"
uncross离床告警第一次离床时间在范围前,配置:{}"
,
config
.
getRuleConfig
());
log
.
info
(
"
deviceId:{},uncross离床告警第一次离床时间在范围前,配置:{}"
,
deviceId
,
config
.
getRuleConfig
());
platAlarmCheckDTO
.
setPlatAlarmConfig
(
config
);
noticeAlarm
(
alarmRedisDTO
,
platAlarmCheckDTO
,
deviceId
);
}
else
{
log
.
info
(
"
uncross离床告警第一次离床时间在范围前,未预警,配置:{},时间持续:{},start:{}"
,
config
.
getRuleConfig
(),
mills
,
startLocalDteTime
);
log
.
info
(
"
deviceId:{},uncross离床告警第一次离床时间在范围前,未预警,配置:{},时间持续:{},start:{}"
,
deviceId
,
config
.
getRuleConfig
(),
mills
,
startLocalDteTime
);
}
}
else
{
log
.
info
(
"
handleUnCrossDay 未满足预警条件!fisrttime:{},config:{}"
,
firstTime
,
config
.
getRuleConfig
());
log
.
info
(
"
deviceId:{},UnCrossDay 未满足预警条件!fis:{},config:{}"
,
deviceId
,
firstTime
,
config
.
getRuleConfig
());
}
}
...
...
@@ -277,14 +276,14 @@ public class OffBedAlarm implements IAlarm {
private
void
noticeAlarm
(
AlarmRedisDTO
alarmRedisDTO
,
PlatAlarmCheckDTO
platAlarmCheckDTO
,
String
deviceId
)
{
PlatAlarmConfig
platAlarmConfig
=
platAlarmCheckDTO
.
getPlatAlarmConfig
();
LocalDateTime
firstOffBedTime
=
LocalDateTime
.
ofInstant
(
Instant
.
ofEpochMilli
(
alarmRedisDTO
.
getStartLong
()),
ZoneOffset
.
of
(
"+8"
));
String
remark
=
"第一次离床时间:"
+
firstOffBedTime
+
",config:"
+
platAlarmConfig
.
getRuleConfig
()
+
",当前时间:"
+
LocalDateTime
.
now
();
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
(
"
离床告警推送离床消息,第一次上报时间:{},开始上报时间:{},是否上报:{},上报的config:{}"
,
log
.
info
(
"
deviceId:{},离床告警推送离床消息,第一次上报时间:{},开始上报时间:{},是否上报:{},上报的config:{}"
,
deviceId
,
longToTime
(
alarmRedisDTO
.
getStartLong
()),
alarmRedisDTO
.
getStart
(),
alarmRedisDTO
.
getAlarm
()
,
platAlarmConfig
.
getRuleConfig
());
}
...
...
@@ -328,7 +327,7 @@ public class OffBedAlarm implements IAlarm {
}
private
LocalDateTime
currentTime
()
{
return
LocalDateTime
.
now
().
plusHours
(
12
);
return
LocalDateTime
.
now
().
plusHours
(
9
);
// return LocalDateTime.now();
}
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/impl/PlatAlarmConfigServiceImpl.java
View file @
7aeedc74
...
...
@@ -262,7 +262,7 @@ public class PlatAlarmConfigServiceImpl extends ServiceImpl<PlatAlarmConfigMappe
@Override
@TenantIdIgnore
public
List
<
PlatAlarmConfig
>
listOfBed
(
String
orgD
eviceId
)
{
return
configMapper
.
listOffBed
(
orgD
eviceId
);
public
List
<
PlatAlarmConfig
>
listOfBed
(
String
d
eviceId
)
{
return
configMapper
.
listOffBed
(
d
eviceId
);
}
}
server-service/src/main/resources/mappers/PlatAlarmConfigMapper.xml
View file @
7aeedc74
...
...
@@ -27,7 +27,7 @@
select *
from plat_alarm_config
where org_id in (
select org_id from plat_device where id = #{
orgD
eviceId} and del_flag = 0)
select org_id from plat_device where id = #{
d
eviceId} and del_flag = 0)
and alarm_type = 5 and tenant_id != 0
</select>
</mapper>
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