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
1284b262
authored
Dec 07, 2023
by
汪志阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
离床异常消息警告
parent
8e1c37cb
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
219 additions
and
14 deletions
db/init/init_data.sql
db/上线后sql/update.sql
server-common/src/main/java/com/makeit/enums/redis/RedisConst.java
server-module/src/main/java/com/makeit/module/controller/wechat/alarm/PlatAlarmRecordWechatController.java
server-service/src/main/java/com/makeit/dto/platform/alarm/PlatAlarmConfigHeartDTOVO.java
server-service/src/main/java/com/makeit/dto/platform/alarm/PlatAlarmConfigOffBedDTOVO.java
server-service/src/main/java/com/makeit/dto/platform/alarm/PlatHealthConfigDTO.java
server-service/src/main/java/com/makeit/enums/report/PlatformTypeEnum.java
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/HeartAlarm.java
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/OffBedAlarm.java
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
server-service/src/main/java/com/makeit/vo/platform/alarm/PlatAlarmRecordVO.java
db/init/init_data.sql
View file @
1284b262
...
@@ -3,7 +3,7 @@ INSERT INTO `saas_user`(`id`, `username`, `account`, `password`, `mobile`, `stat
...
@@ -3,7 +3,7 @@ INSERT INTO `saas_user`(`id`, `username`, `account`, `password`, `mobile`, `stat
INSERT
INTO
`plat_alarm_config`
(
`id`
,
`alarm_type`
,
`status`
,
`org_id`
,
`city_org_id`
,
`district_org_id`
,
`street_org_id`
,
`org_path`
,
`rule_config`
,
`content`
,
`notify_channel`
,
`notify_relation`
,
`notify_way`
,
`notify_user`
,
`description`
,
`create_by`
,
`create_date`
,
`update_by`
,
`update_date`
,
`del_flag`
,
`tenant_id`
,
`content_audit`
)
VALUES
(
'1699667670087065604'
,
'1'
,
'1'
,
'1701542574740770817'
,
NULL
,
NULL
,
NULL
,
NULL
,
'{}'
,
'[#长者姓名]在[#房间名]跌倒,请及时处理!'
,
''
,
'1'
,
'1'
,
NULL
,
NULL
,
'platAdmin02'
,
'2023-09-07 14:15:26'
,
'测试clt'
,
'2023-09-12 17:09:17'
,
'0'
,
'0'
,
NULL
);
INSERT
INTO
`plat_alarm_config`
(
`id`
,
`alarm_type`
,
`status`
,
`org_id`
,
`city_org_id`
,
`district_org_id`
,
`street_org_id`
,
`org_path`
,
`rule_config`
,
`content`
,
`notify_channel`
,
`notify_relation`
,
`notify_way`
,
`notify_user`
,
`description`
,
`create_by`
,
`create_date`
,
`update_by`
,
`update_date`
,
`del_flag`
,
`tenant_id`
,
`content_audit`
)
VALUES
(
'1699667670087065604'
,
'1'
,
'1'
,
'1701542574740770817'
,
NULL
,
NULL
,
NULL
,
NULL
,
'{}'
,
'[#长者姓名]在[#房间名]跌倒,请及时处理!'
,
''
,
'1'
,
'1'
,
NULL
,
NULL
,
'platAdmin02'
,
'2023-09-07 14:15:26'
,
'测试clt'
,
'2023-09-12 17:09:17'
,
'0'
,
'0'
,
NULL
);
INSERT
INTO
`plat_alarm_config`
(
`id`
,
`alarm_type`
,
`status`
,
`org_id`
,
`city_org_id`
,
`district_org_id`
,
`street_org_id`
,
`org_path`
,
`rule_config`
,
`content`
,
`notify_channel`
,
`notify_relation`
,
`notify_way`
,
`notify_user`
,
`description`
,
`create_by`
,
`create_date`
,
`update_by`
,
`update_date`
,
`del_flag`
,
`tenant_id`
,
`content_audit`
)
VALUES
(
'16996678722776842251'
,
'2'
,
'1'
,
'1701542574740770817'
,
NULL
,
NULL
,
NULL
,
NULL
,
'{
\"
respiratoryRateStart
\"
:
\"
10
\"
,
\"
respiratoryRateEnd
\"
:
\"
120
\"
,
\"
duration
\"
:
\"
5
\"
}'
,
'[#长者姓名][#呼吸状态],请及时处理!'
,
''
,
'1'
,
'1'
,
NULL
,
NULL
,
'platAdmin02'
,
'2023-09-07 14:16:14'
,
'platAdmin02'
,
'2023-09-07 14:16:14'
,
'0'
,
'0'
,
NULL
);
INSERT
INTO
`plat_alarm_config`
(
`id`
,
`alarm_type`
,
`status`
,
`org_id`
,
`city_org_id`
,
`district_org_id`
,
`street_org_id`
,
`org_path`
,
`rule_config`
,
`content`
,
`notify_channel`
,
`notify_relation`
,
`notify_way`
,
`notify_user`
,
`description`
,
`create_by`
,
`create_date`
,
`update_by`
,
`update_date`
,
`del_flag`
,
`tenant_id`
,
`content_audit`
)
VALUES
(
'16996678722776842251'
,
'2'
,
'1'
,
'1701542574740770817'
,
NULL
,
NULL
,
NULL
,
NULL
,
'{
\"
respiratoryRateStart
\"
:
\"
10
\"
,
\"
respiratoryRateEnd
\"
:
\"
120
\"
,
\"
duration
\"
:
\"
5
\"
}'
,
'[#长者姓名][#呼吸状态],请及时处理!'
,
''
,
'1'
,
'1'
,
NULL
,
NULL
,
'platAdmin02'
,
'2023-09-07 14:16:14'
,
'platAdmin02'
,
'2023-09-07 14:16:14'
,
'0'
,
'0'
,
NULL
);
INSERT
INTO
`plat_alarm_config`
(
`id`
,
`alarm_type`
,
`status`
,
`org_id`
,
`city_org_id`
,
`district_org_id`
,
`street_org_id`
,
`org_path`
,
`rule_config`
,
`content`
,
`notify_channel`
,
`notify_relation`
,
`notify_way`
,
`notify_user`
,
`description`
,
`create_by`
,
`create_date`
,
`update_by`
,
`update_date`
,
`del_flag`
,
`tenant_id`
,
`content_audit`
)
VALUES
(
'16996680489417687051'
,
'3'
,
'1'
,
'1701542574740770817'
,
NULL
,
NULL
,
NULL
,
NULL
,
'{
\"
heartRateStart
\"
:
\"
60
\"
,
\"
heartRate
e
End
\"
:
\"
90
\"
,
\"
duration
\"
:
\"
5
\"
}'
,
'[#长者姓名][#心率状态],请及时处理!'
,
''
,
'1'
,
'1'
,
NULL
,
NULL
,
'platAdmin02'
,
'2023-09-07 14:16:56'
,
'platAdmin02'
,
'2023-09-07 14:16:56'
,
'0'
,
'0'
,
NULL
);
INSERT
INTO
`plat_alarm_config`
(
`id`
,
`alarm_type`
,
`status`
,
`org_id`
,
`city_org_id`
,
`district_org_id`
,
`street_org_id`
,
`org_path`
,
`rule_config`
,
`content`
,
`notify_channel`
,
`notify_relation`
,
`notify_way`
,
`notify_user`
,
`description`
,
`create_by`
,
`create_date`
,
`update_by`
,
`update_date`
,
`del_flag`
,
`tenant_id`
,
`content_audit`
)
VALUES
(
'16996680489417687051'
,
'3'
,
'1'
,
'1701542574740770817'
,
NULL
,
NULL
,
NULL
,
NULL
,
'{
\"
heartRateStart
\"
:
\"
60
\"
,
\"
heartRateEnd
\"
:
\"
90
\"
,
\"
duration
\"
:
\"
5
\"
}'
,
'[#长者姓名][#心率状态],请及时处理!'
,
''
,
'1'
,
'1'
,
NULL
,
NULL
,
'platAdmin02'
,
'2023-09-07 14:16:56'
,
'platAdmin02'
,
'2023-09-07 14:16:56'
,
'0'
,
'0'
,
NULL
);
INSERT
INTO
`plat_alarm_config`
(
`id`
,
`alarm_type`
,
`status`
,
`org_id`
,
`city_org_id`
,
`district_org_id`
,
`street_org_id`
,
`org_path`
,
`rule_config`
,
`content`
,
`notify_channel`
,
`notify_relation`
,
`notify_way`
,
`notify_user`
,
`description`
,
`create_by`
,
`create_date`
,
`update_by`
,
`update_date`
,
`del_flag`
,
`tenant_id`
,
`content_audit`
)
VALUES
(
'16996682046846648331'
,
'4'
,
'1'
,
'1701542574740770817'
,
NULL
,
NULL
,
NULL
,
NULL
,
'{
\"
averageDuration
\"
:
\"
5
\"
}'
,
'[#长者姓名]在[#上级空间名-房间名]内存在行为异常,请及时处理!'
,
''
,
'1'
,
'1'
,
NULL
,
NULL
,
'platAdmin02'
,
'2023-09-07 14:17:33'
,
'platAdmin02'
,
'2023-09-07 14:17:33'
,
'0'
,
'0'
,
NULL
);
INSERT
INTO
`plat_alarm_config`
(
`id`
,
`alarm_type`
,
`status`
,
`org_id`
,
`city_org_id`
,
`district_org_id`
,
`street_org_id`
,
`org_path`
,
`rule_config`
,
`content`
,
`notify_channel`
,
`notify_relation`
,
`notify_way`
,
`notify_user`
,
`description`
,
`create_by`
,
`create_date`
,
`update_by`
,
`update_date`
,
`del_flag`
,
`tenant_id`
,
`content_audit`
)
VALUES
(
'16996682046846648331'
,
'4'
,
'1'
,
'1701542574740770817'
,
NULL
,
NULL
,
NULL
,
NULL
,
'{
\"
averageDuration
\"
:
\"
5
\"
}'
,
'[#长者姓名]在[#上级空间名-房间名]内存在行为异常,请及时处理!'
,
''
,
'1'
,
'1'
,
NULL
,
NULL
,
'platAdmin02'
,
'2023-09-07 14:17:33'
,
'platAdmin02'
,
'2023-09-07 14:17:33'
,
'0'
,
'0'
,
NULL
);
...
...
db/上线后sql/update.sql
View file @
1284b262
ALTER
TABLE
`plat_device_other`
ALTER
TABLE
`plat_device_other`
...
@@ -61,3 +61,5 @@ ALTER TABLE `plat_alarm_config` modify column alarm_type char(1) comment '告警
...
@@ -61,3 +61,5 @@ ALTER TABLE `plat_alarm_config` modify column alarm_type char(1) comment '告警
INSERT
INTO
`plat_alarm_config`
(
`id`
,
`alarm_type`
,
`status`
,
`org_id`
,
`city_org_id`
,
`district_org_id`
,
`street_org_id`
,
`org_path`
,
`rule_config`
,
`content`
,
`notify_channel`
,
`notify_relation`
,
`notify_way`
,
`notify_user`
,
`description`
,
`create_by`
,
`create_date`
,
`update_by`
,
`update_date`
,
`del_flag`
,
`tenant_id`
,
`content_audit`
)
INSERT
INTO
`plat_alarm_config`
(
`id`
,
`alarm_type`
,
`status`
,
`org_id`
,
`city_org_id`
,
`district_org_id`
,
`street_org_id`
,
`org_path`
,
`rule_config`
,
`content`
,
`notify_channel`
,
`notify_relation`
,
`notify_way`
,
`notify_user`
,
`description`
,
`create_by`
,
`create_date`
,
`update_by`
,
`update_date`
,
`del_flag`
,
`tenant_id`
,
`content_audit`
)
VALUES
(
'16996678722776842252'
,
'5'
,
'1'
,
'1701542574740770817'
,
NULL
,
NULL
,
NULL
,
NULL
,
'{
\"
offBedStart
\"
:
\"
0:00
\"
,
\"
startTimeType
\"
:
\"
1
\"
,
\"
offBedEnd
\"
:
\"
10:00
\"
,
\"
endTimeType
\"
:
\"
2
\"
,
\"
duration
\"
:
\"
5
\"
}'
,
'[#长者姓名]离床时间过长,请及时处理!'
,
''
,
'1'
,
'1'
,
NULL
,
NULL
,
'platAdmin02'
,
NOW
(),
'platAdmin02'
,
NOW
(),
'0'
,
'0'
,
NULL
);
VALUES
(
'16996678722776842252'
,
'5'
,
'1'
,
'1701542574740770817'
,
NULL
,
NULL
,
NULL
,
NULL
,
'{
\"
offBedStart
\"
:
\"
0:00
\"
,
\"
startTimeType
\"
:
\"
1
\"
,
\"
offBedEnd
\"
:
\"
10:00
\"
,
\"
endTimeType
\"
:
\"
2
\"
,
\"
duration
\"
:
\"
5
\"
}'
,
'[#长者姓名]离床时间过长,请及时处理!'
,
''
,
'1'
,
'1'
,
NULL
,
NULL
,
'platAdmin02'
,
NOW
(),
'platAdmin02'
,
NOW
(),
'0'
,
'0'
,
NULL
);
##
离床异常字典
INSERT
INTO
`sys_dictionary`
VALUES
(
'204'
,
'alarm.alarmType.offBed'
,
'离床异常'
,
'5'
,
5
,
''
,
'200'
,
NOW
(),
NOW
(),
'0'
,
NULL
,
NULL
,
NULL
);
server-common/src/main/java/com/makeit/enums/redis/RedisConst.java
View file @
1284b262
...
@@ -96,6 +96,7 @@ public class RedisConst {
...
@@ -96,6 +96,7 @@ public class RedisConst {
public
static
final
String
ALARM_DEVICE_HR_ID
=
"alarm:device:hr:id:"
;
public
static
final
String
ALARM_DEVICE_HR_ID
=
"alarm:device:hr:id:"
;
public
static
final
String
ALARM_DEVICE_FALL_ID
=
"alarm:device:fall:id:"
;
public
static
final
String
ALARM_DEVICE_FALL_ID
=
"alarm:device:fall:id:"
;
public
static
final
String
ALARM_DEVICE_BEHAVIOR_ID
=
"alarm:device:behavior:id:"
;
public
static
final
String
ALARM_DEVICE_BEHAVIOR_ID
=
"alarm:device:behavior:id:"
;
public
static
final
String
ALARM_DEVICE_OFF_BED_ID
=
"alarm:device:off_bed:id:"
;
public
static
final
String
ALARM_CONFIG_ORG_ID
=
"alarm:config:org:id:"
;
public
static
final
String
ALARM_CONFIG_ORG_ID
=
"alarm:config:org:id:"
;
public
static
final
String
PLAT_IOT_DEVICE_PREFIX
=
"plat:iot:device:"
;
public
static
final
String
PLAT_IOT_DEVICE_PREFIX
=
"plat:iot:device:"
;
...
...
server-module/src/main/java/com/makeit/module/controller/wechat/alarm/PlatAlarmRecordWechatController.java
View file @
1284b262
...
@@ -62,7 +62,7 @@ public class PlatAlarmRecordWechatController {
...
@@ -62,7 +62,7 @@ public class PlatAlarmRecordWechatController {
@ApiOperation
(
"已读"
)
@ApiOperation
(
"已读"
)
@PostMapping
(
"read"
)
@PostMapping
(
"read"
)
public
ApiResponseEntity
<
Void
>
read
(
@RequestBody
BaseIdDTO
dto
)
{
public
ApiResponseEntity
<
Void
>
read
(
@RequestBody
BaseIdDTO
dto
)
{
platAlarmRecordService
.
read
(
dto
.
getId
(),
PlatformTypeEnum
.
WECHAT
);
platAlarmRecordService
.
read
(
dto
.
getId
(),
PlatformTypeEnum
.
PC
);
return
ApiResponseUtils
.
success
();
return
ApiResponseUtils
.
success
();
}
}
@ApiOperation
(
"通知家属"
)
@ApiOperation
(
"通知家属"
)
...
...
server-service/src/main/java/com/makeit/dto/platform/alarm/PlatAlarmConfigHeartDTOVO.java
View file @
1284b262
...
@@ -22,7 +22,7 @@ public class PlatAlarmConfigHeartDTOVO {
...
@@ -22,7 +22,7 @@ public class PlatAlarmConfigHeartDTOVO {
private
Integer
heartRateStart
;
private
Integer
heartRateStart
;
@ApiModelProperty
(
"心率正常范围结束"
)
@ApiModelProperty
(
"心率正常范围结束"
)
private
Integer
heartRate
e
End
;
private
Integer
heartRateEnd
;
@ApiModelProperty
(
"异常持续时间"
)
@ApiModelProperty
(
"异常持续时间"
)
private
Integer
duration
;
private
Integer
duration
;
...
...
server-service/src/main/java/com/makeit/dto/platform/alarm/PlatAlarmConfigOffBedDTOVO.java
View file @
1284b262
...
@@ -7,7 +7,7 @@ import lombok.Data;
...
@@ -7,7 +7,7 @@ import lombok.Data;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.time.Local
Date
Time
;
import
java.time.LocalTime
;
/**
/**
* <p>
* <p>
...
@@ -25,7 +25,7 @@ public class PlatAlarmConfigOffBedDTOVO {
...
@@ -25,7 +25,7 @@ public class PlatAlarmConfigOffBedDTOVO {
@ApiModelProperty
(
"离床开始时间"
)
@ApiModelProperty
(
"离床开始时间"
)
@DateTimeFormat
(
pattern
=
"HH:mm"
)
@DateTimeFormat
(
pattern
=
"HH:mm"
)
@JsonFormat
(
pattern
=
"HH:mm"
,
timezone
=
"GMT+8"
)
@JsonFormat
(
pattern
=
"HH:mm"
,
timezone
=
"GMT+8"
)
private
Local
Date
Time
offBedStart
;
private
LocalTime
offBedStart
;
@ApiModelProperty
(
"离床时间类型 :1-当日,2-次日"
)
@ApiModelProperty
(
"离床时间类型 :1-当日,2-次日"
)
private
String
startTimeType
;
private
String
startTimeType
;
...
@@ -33,7 +33,7 @@ public class PlatAlarmConfigOffBedDTOVO {
...
@@ -33,7 +33,7 @@ public class PlatAlarmConfigOffBedDTOVO {
@ApiModelProperty
(
"离床结束时间"
)
@ApiModelProperty
(
"离床结束时间"
)
@DateTimeFormat
(
pattern
=
"HH:mm"
)
@DateTimeFormat
(
pattern
=
"HH:mm"
)
@JsonFormat
(
pattern
=
"HH:mm"
,
timezone
=
"GMT+8"
)
@JsonFormat
(
pattern
=
"HH:mm"
,
timezone
=
"GMT+8"
)
private
Local
Date
Time
offBedEnd
;
private
LocalTime
offBedEnd
;
@ApiModelProperty
(
"离床时间类型 :1-当日,2-次日"
)
@ApiModelProperty
(
"离床时间类型 :1-当日,2-次日"
)
private
String
endTimeType
;
private
String
endTimeType
;
...
...
server-service/src/main/java/com/makeit/dto/platform/alarm/PlatHealthConfigDTO.java
View file @
1284b262
...
@@ -65,7 +65,7 @@ public class PlatHealthConfigDTO {
...
@@ -65,7 +65,7 @@ public class PlatHealthConfigDTO {
if
(
heartConfig
){
if
(
heartConfig
){
PlatAlarmConfigHeartDTOVO
dto
=
new
PlatAlarmConfigHeartDTOVO
();
PlatAlarmConfigHeartDTOVO
dto
=
new
PlatAlarmConfigHeartDTOVO
();
dto
.
setHeartRateStart
(
heartRateStart
);
dto
.
setHeartRateStart
(
heartRateStart
);
dto
.
setHeartRate
e
End
(
heartRateEnd
);
dto
.
setHeartRateEnd
(
heartRateEnd
);
dto
.
setDuration
(
heartDuration
);
dto
.
setDuration
(
heartDuration
);
return
dto
;
return
dto
;
}
}
...
...
server-service/src/main/java/com/makeit/enums/report/PlatformTypeEnum.java
View file @
1284b262
...
@@ -12,8 +12,8 @@ import lombok.Getter;
...
@@ -12,8 +12,8 @@ import lombok.Getter;
@AllArgsConstructor
@AllArgsConstructor
public
enum
PlatformTypeEnum
{
public
enum
PlatformTypeEnum
{
PC
(
"1"
,
"pc端"
),
PC
(
"1"
,
"pc端
、小程序
"
),
WECHAT
(
"2"
,
"
微信
小程序"
);
WECHAT
(
"2"
,
"
子女端
小程序"
);
private
String
code
;
private
String
code
;
private
String
value
;
private
String
value
;
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/HeartAlarm.java
View file @
1284b262
...
@@ -81,7 +81,7 @@ public class HeartAlarm implements IAlarm {
...
@@ -81,7 +81,7 @@ public class HeartAlarm implements IAlarm {
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
String
deviceId
=
platDevice
.
getId
();
String
deviceId
=
platDevice
.
getId
();
Integer
start
=
ruleConfig
.
getHeartRateStart
();
Integer
start
=
ruleConfig
.
getHeartRateStart
();
Integer
end
=
ruleConfig
.
getHeartRate
e
End
();
Integer
end
=
ruleConfig
.
getHeartRateEnd
();
Integer
duration
=
ruleConfig
.
getDuration
();
Integer
duration
=
ruleConfig
.
getDuration
();
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"personState"
));
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"personState"
));
//心率
//心率
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/OffBedAlarm.java
0 → 100644
View file @
1284b262
package
com
.
makeit
.
service
.
platform
.
alarm
.
alarmStrategy
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.makeit.dto.platform.alarm.PlatAlarmCheckDTO
;
import
com.makeit.dto.platform.alarm.PlatAlarmConfigOffBedDTOVO
;
import
com.makeit.entity.platform.alarm.PlatAlarmConfig
;
import
com.makeit.entity.platform.alarm.PlatAlarmRecord
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.entity.platform.elder.PlatElder
;
import
com.makeit.entity.platform.space.PlatRoom
;
import
com.makeit.enums.CommonEnum
;
import
com.makeit.enums.platform.alarm.PlatAlarmConfigEnum
;
import
com.makeit.enums.redis.RedisConst
;
import
com.makeit.module.iot.enums.DeviceInfoContentBreatheEnum
;
import
com.makeit.service.platform.alarm.PlatAlarmRecordService
;
import
com.makeit.utils.AlarmRedisDTO
;
import
com.makeit.utils.data.convert.JsonUtil
;
import
com.makeit.utils.redis.RedisUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
@Component
@Slf4j
public
class
OffBedAlarm
implements
IAlarm
{
@Resource
private
PlatAlarmRecordService
platAlarmRecordService
;
private
final
String
CURRENT_DAY
=
"1"
;
private
final
PlatAlarmConfigEnum
.
AlarmTypeEnum
alarmTypeEnum
=
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
OFF_BED
;
@Override
public
boolean
support
(
String
alarmType
)
{
return
StringUtils
.
equals
(
alarmType
,
alarmTypeEnum
.
getValue
());
}
/**
* 4.离床异常:长者绑定的呼吸心率设备在配置时间段内,检测到长者的离床状态(设备状态无人)持续时间超过配置的离床持续时间,则告警
*
* @param platAlarmCheckDTO
*/
@Override
public
void
checkConfig
(
PlatAlarmCheckDTO
platAlarmCheckDTO
)
{
platAlarmRecordService
.
getElderListByDeviceId
(
platAlarmCheckDTO
);
List
<
PlatElder
>
platElderList
=
platAlarmCheckDTO
.
getPlatElderList
();
if
(
CollectionUtils
.
isEmpty
(
platElderList
))
{
log
.
error
(
"呼吸告警心率设备未关联长者,设备plat_id:"
+
platAlarmCheckDTO
.
getPlatDevice
().
getId
());
return
;
}
PlatAlarmConfig
config
=
platAlarmCheckDTO
.
getPlatAlarmConfig
();
if
(!
"5"
.
equals
(
config
.
getAlarmType
()))
{
log
.
error
(
"呼吸告警配置不存在,config:{}"
,
JSONUtil
.
toJsonStr
(
config
));
return
;
}
if
(
CommonEnum
.
NO
.
getValue
().
equals
(
config
.
getStatus
()))
{
log
.
error
(
"离床告警配置为禁用,告警配置id:"
+
config
.
getId
());
return
;
}
String
ruleConfigStr
=
config
.
getRuleConfig
();
if
(
StringUtils
.
isBlank
(
ruleConfigStr
))
{
log
.
error
(
"离床告警配置未配置,告警配置id:"
+
config
.
getId
());
return
;
}
PlatAlarmConfigOffBedDTOVO
ruleConfig
=
JsonUtil
.
toObj
(
ruleConfigStr
,
PlatAlarmConfigOffBedDTOVO
.
class
);
if
(
ruleConfig
==
null
)
{
log
.
error
(
"离床告警配置解析失败,config:{}"
,
JSONUtil
.
toJsonStr
(
config
));
return
;
}
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
if
(
properties
==
null
)
{
properties
=
new
JSONObject
();
}
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
String
deviceId
=
platDevice
.
getId
();
List
<
LocalDateTime
>
timeRange
=
getOffTimeRange
(
ruleConfig
);
if
(
CollUtil
.
isEmpty
(
timeRange
))
{
log
.
error
(
"离床告警配置时间段解析失败,config:{}"
,
JSONUtil
.
toJsonStr
(
ruleConfig
));
return
;
}
LocalDateTime
startTime
=
timeRange
.
get
(
0
);
LocalDateTime
endTime
=
timeRange
.
get
(
1
);
Integer
duration
=
ruleConfig
.
getDuration
();
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"personState"
));
boolean
isInRange
=
LocalDateTime
.
now
().
isAfter
(
startTime
)
&&
LocalDateTime
.
now
().
isBefore
(
endTime
);
if
(!
DeviceInfoContentBreatheEnum
.
PersonStateEnum
.
NOBODY
.
eq
(
personState
)
||
!
isInRange
)
{
return
;
}
AlarmRedisDTO
alarmRedisDTO
=
RedisUtil
.
get
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
);
if
(
alarmRedisDTO
==
null
)
{
Date
now
=
new
Date
();
long
endLong
=
now
.
getTime
();
alarmRedisDTO
=
new
AlarmRedisDTO
();
alarmRedisDTO
.
setAlarm
(
CommonEnum
.
NO
.
getValue
());
alarmRedisDTO
.
setStart
(
now
);
alarmRedisDTO
.
setStartLong
(
endLong
);
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
,
alarmRedisDTO
);
log
.
error
(
"发现长者设备状态无人,设备plat_id:"
+
deviceId
);
return
;
}
Date
now
=
new
Date
();
long
endLong
=
now
.
getTime
();
Long
startLong
=
alarmRedisDTO
.
getStartLong
();
long
count
=
endLong
-
startLong
;
String
messageType
=
platAlarmCheckDTO
.
getMessageType
();
if
(
count
/
1000
>=
duration
&&
!
StringUtils
.
equals
(
alarmRedisDTO
.
getAlarm
(),
CommonEnum
.
YES
.
getValue
()))
{
// platAlarmCheckDTO.setAbnormalValue(Convert.toStr(br));
alarmRedisDTO
.
setStartLong
(
endLong
);
alarmRedisDTO
.
setStart
(
now
);
alarmRedisDTO
.
setAlarm
(
CommonEnum
.
YES
.
getValue
());
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
,
alarmRedisDTO
);
notice
(
platAlarmCheckDTO
);
}
if
(
StringUtils
.
equalsAnyIgnoreCase
(
messageType
,
"REPORT_PROPERTY"
,
"OFFLINE"
,
"DISCONNECT"
))
{
RedisUtil
.
delete
(
RedisConst
.
ALARM_DEVICE_OFF_BED_ID
+
deviceId
);
}
}
private
List
<
LocalDateTime
>
getOffTimeRange
(
PlatAlarmConfigOffBedDTOVO
ruleConfig
)
{
List
<
LocalDateTime
>
result
=
new
ArrayList
<>();
LocalDate
localDate
=
LocalDate
.
now
();
LocalDateTime
startTime
;
LocalDateTime
endTime
;
if
(
CURRENT_DAY
.
equals
(
ruleConfig
.
getStartTimeType
()))
{
startTime
=
LocalDateTime
.
of
(
localDate
,
ruleConfig
.
getOffBedStart
());
}
else
{
startTime
=
LocalDateTime
.
of
(
localDate
.
plusDays
(
1
),
ruleConfig
.
getOffBedStart
());
}
if
(
CURRENT_DAY
.
equals
(
ruleConfig
.
getEndTimeType
()))
{
endTime
=
LocalDateTime
.
of
(
localDate
,
ruleConfig
.
getOffBedEnd
());
}
else
{
endTime
=
LocalDateTime
.
of
(
localDate
.
plusDays
(
1
),
ruleConfig
.
getOffBedEnd
());
}
result
.
add
(
startTime
);
result
.
add
(
endTime
);
return
result
;
}
@Override
public
void
notice
(
PlatAlarmCheckDTO
platAlarmCheckDTO
)
{
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
platAlarmRecordService
.
getElderListByDeviceId
(
platAlarmCheckDTO
);
List
<
PlatElder
>
platElderList
=
platAlarmCheckDTO
.
getPlatElderList
();
PlatAlarmConfig
config
=
platAlarmCheckDTO
.
getPlatAlarmConfig
();
if
(
CommonEnum
.
NO
.
getValue
().
equals
(
config
.
getStatus
()))
{
log
.
error
(
"离床告警配置为禁用,告警配置id:"
+
config
.
getId
());
return
;
}
if
(
StringUtils
.
isBlank
(
config
.
getRuleConfig
()))
{
log
.
error
(
"离床告警配置未配置,告警配置id:"
+
config
.
getId
());
return
;
}
if
(
CollectionUtils
.
isEmpty
(
platElderList
))
{
log
.
error
(
"离床告警配置未关联长者,设备plat_id:"
+
platDevice
.
getId
());
return
;
}
PlatRoom
platRoom
=
platAlarmCheckDTO
.
getPlatRoom
();
for
(
PlatElder
platElder
:
platElderList
)
{
List
<
String
>
param
=
new
ArrayList
<>();
param
.
add
(
platRoom
.
getName
());
param
.
add
(
platElder
.
getName
());
platAlarmCheckDTO
.
setParam
(
param
);
PlatAlarmRecord
platAlarmRecord
=
platAlarmRecordService
.
convertToPlatAlarmRecord
(
platAlarmCheckDTO
,
platElder
);
platAlarmRecord
.
setElderName
(
platElder
.
getName
());
platAlarmRecord
.
setElderIds
(
platElder
.
getId
());
platAlarmRecordService
.
noticeDeviceAlarm
(
platAlarmCheckDTO
.
getPlatAlarmConfig
(),
platAlarmRecord
);
log
.
error
(
"离床告警配置,发出告警,设备id:"
+
platDevice
.
getId
()
+
", 长者名称:"
+
platElder
.
getName
());
}
}
}
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
View file @
1284b262
...
@@ -147,8 +147,14 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -147,8 +147,14 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}
}
this
.
updateById
(
space
);
this
.
updateById
(
space
);
List
<
String
>
laseSpaceIds
=
recursionLastSpaceIds
(
space
.
getId
(),
new
ArrayList
<>());
List
<
PlatRoom
>
platRoomList
=
platRoomService
.
listBySpaceId
(
space
.
getId
());
if
(
CollUtil
.
isEmpty
(
laseSpaceIds
))
{
return
;
}
List
<
PlatRoom
>
platRoomList
=
platRoomService
.
list
(
Wrappers
.<
PlatRoom
>
lambdaQuery
().
in
(
PlatRoom:
:
getSpaceId
,
laseSpaceIds
));
if
(
CollUtil
.
isEmpty
(
platRoomList
))
{
return
;
}
for
(
PlatRoom
platRoom
:
platRoomList
)
{
for
(
PlatRoom
platRoom
:
platRoomList
)
{
platRoom
.
setSpacePath
(
dto
.
getParentPath
()
+
","
+
space
.
getId
());
platRoom
.
setSpacePath
(
dto
.
getParentPath
()
+
","
+
space
.
getId
());
platRoomService
.
updateById
(
platRoom
);
platRoomService
.
updateById
(
platRoom
);
...
@@ -174,6 +180,17 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -174,6 +180,17 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}
}
}
}
private
List
<
String
>
recursionLastSpaceIds
(
String
spaceId
,
List
<
String
>
result
)
{
List
<
PlatSpace
>
platSpaces
=
this
.
list
(
Wrappers
.<
PlatSpace
>
lambdaQuery
().
eq
(
PlatSpace:
:
getParentId
,
spaceId
));
if
(
CollUtil
.
isNotEmpty
(
platSpaces
))
{
platSpaces
.
forEach
(
p
->
recursionLastSpaceIds
(
p
.
getId
(),
result
));
}
else
{
result
.
add
(
spaceId
);
return
result
;
}
return
result
;
}
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
del
(
String
id
)
{
public
void
del
(
String
id
)
{
...
...
server-service/src/main/java/com/makeit/vo/platform/alarm/PlatAlarmRecordVO.java
View file @
1284b262
...
@@ -30,7 +30,7 @@ public class PlatAlarmRecordVO extends BaseTenantDTO {
...
@@ -30,7 +30,7 @@ public class PlatAlarmRecordVO extends BaseTenantDTO {
@ApiModelProperty
(
value
=
"通知家属 数据字典 1、同步通知 2 可选通知 3 不通知"
)
@ApiModelProperty
(
value
=
"通知家属 数据字典 1、同步通知 2 可选通知 3 不通知"
)
private
String
notifyRelation
;
private
String
notifyRelation
;
@ApiModelProperty
(
value
=
"告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常"
)
@ApiModelProperty
(
value
=
"告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常
,5 离床异常
"
)
private
String
alarmType
;
private
String
alarmType
;
@ApiModelProperty
(
value
=
"告警时间"
)
@ApiModelProperty
(
value
=
"告警时间"
)
...
...
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