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
887b4201
authored
Nov 02, 2023
by
huangjy
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
parents
44fd317b
c88ffadf
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
98 additions
and
12 deletions
README.md
server-service/src/main/java/com/makeit/dto/platform/alarm/PlatAlarmCheckDTO.java
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/BehaviorAlarm.java
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/BreathAlarm.java
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/FallAlarm.java
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/HeartAlarm.java
server-service/src/main/java/com/makeit/utils/DayDurationUtil.java
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
README.md
View file @
887b4201
...
@@ -12,3 +12,70 @@ server-api 提供外部接口
...
@@ -12,3 +12,70 @@ server-api 提供外部接口
server-service 存放业务service、mapper、entity
server-service 存放业务service、mapper、entity
server-common 通用模块 包含通用entity、service、mapper类等
server-common 通用模块 包含通用entity、service、mapper类等
DeviceInfo(
deviceId=407A00233900002,
timestamp=1698908455958,
messageType=REPORT_PROPERTY,
headers=HeaderInfo(deviceName=空间人感雷达测试-3,
productName=空间人感雷达,
productId=1701238458321530880,
_uid=GouO1cQWTrqGfyI6VW8MET9OgePzAj6T,
creatorId=1199596756811550720,
traceparent=00-dd6cff5f8d3944eb111d4cb0e9d68643-2525d125317f2158-01,
bindings=
[
HeaderInfo.Bind(id=1700040815264198656,
type=org),
HeaderInfo.Bind(id=1703950733042053120,
type=org),
HeaderInfo.Bind(id=1701223487902642176,
type=org)]),
properties={"mode":1,
"distance":471,
"personState":1,
"radarHitch":"normal",
"angle":0,
"mount":0})
{
"headers": {
"bindings":
[
{
"id": "1712384736656117760",
"type": "org"
}
],
"serverId": "jetlinks-platform:8844",
"deviceName": "测试跌倒设备clt",
"productName": "跌倒监测雷达",
"connectTime": 1698909870220,
"from": "session",
"productId": "1701240238501588992",
"_uid": "GouPFld7CTch9ushBlCUlXVZ-eRIKI99",
"creatorId": "1199596756811550720"
},
"messageType": "OFFLINE",
"deviceId": "1712376995246002176",
"timestamp": 1698912687995
}
{
"headers": {
"bindings":
[
{
"id": "1712384736656117760",
"type": "org"
}
],
"deviceName": "测试跌倒设备clt",
"productName": "跌倒监测雷达",
"productId": "1701240238501588992",
"_uid": "GouPO1KjVin2L3QiLnP0Y_woBBef55ZE",
"creatorId": "1199596756811550720",
"traceparent": "00-3d6664e9f3772492d9460bfc6bda7e75-d9817e2f1126ab11-01"
},
"messageType": "DISCONNECT",
"messageId": "1720000758644310016",
"deviceId": "1712376995246002176",
"timestamp": 1698915111586
}
\ No newline at end of file
server-service/src/main/java/com/makeit/dto/platform/alarm/PlatAlarmCheckDTO.java
View file @
887b4201
...
@@ -30,6 +30,8 @@ public class PlatAlarmCheckDTO {
...
@@ -30,6 +30,8 @@ public class PlatAlarmCheckDTO {
private
String
remark
;
private
String
remark
;
//异常值
//异常值
private
String
abnormalValue
;
private
String
abnormalValue
;
//设备状态
private
String
messageType
;
}
}
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/BehaviorAlarm.java
View file @
887b4201
...
@@ -59,11 +59,17 @@ public class BehaviorAlarm implements IAlarm {
...
@@ -59,11 +59,17 @@ public class BehaviorAlarm implements IAlarm {
*/
*/
@Override
@Override
public
void
checkConfig
(
PlatAlarmCheckDTO
platAlarmCheckDTO
)
{
public
void
checkConfig
(
PlatAlarmCheckDTO
platAlarmCheckDTO
)
{
String
messageType
=
platAlarmCheckDTO
.
getMessageType
();
PlatAlarmConfig
config
=
platAlarmCheckDTO
.
getPlatAlarmConfig
();
PlatAlarmConfig
config
=
platAlarmCheckDTO
.
getPlatAlarmConfig
();
String
ruleConfigStr
=
config
.
getRuleConfig
();
String
ruleConfigStr
=
config
.
getRuleConfig
();
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
String
deviceId
=
platDevice
.
getId
();
String
deviceId
=
platDevice
.
getId
();
if
(
properties
==
null
){
properties
=
new
JSONObject
();
}
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"personState"
));
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"personState"
));
PlatAlarmConfigBehaviorDTOVO
ruleConfig
=
JsonUtil
.
toObj
(
ruleConfigStr
,
PlatAlarmConfigBehaviorDTOVO
.
class
);
PlatAlarmConfigBehaviorDTOVO
ruleConfig
=
JsonUtil
.
toObj
(
ruleConfigStr
,
PlatAlarmConfigBehaviorDTOVO
.
class
);
Integer
duration
=
ruleConfig
.
getAverageDuration
();
//分钟
Integer
duration
=
ruleConfig
.
getAverageDuration
();
//分钟
...
@@ -93,7 +99,7 @@ public class BehaviorAlarm implements IAlarm {
...
@@ -93,7 +99,7 @@ public class BehaviorAlarm implements IAlarm {
alarmRedisDTO
=
new
AlarmRedisDTO
();
alarmRedisDTO
=
new
AlarmRedisDTO
();
}
}
//有人
//有人
if
(!
personStateList
.
contains
(
personState
))
{
if
(!
personStateList
.
contains
(
personState
)
&&
StringUtils
.
equalsAnyIgnoreCase
(
messageType
,
"REPORT_PROPERTY"
)
)
{
//第一次进入空间
//第一次进入空间
Long
startLong
=
alarmRedisDTO
.
getStartLong
();
Long
startLong
=
alarmRedisDTO
.
getStartLong
();
if
(
startLong
==
null
)
{
if
(
startLong
==
null
)
{
...
@@ -115,7 +121,7 @@ public class BehaviorAlarm implements IAlarm {
...
@@ -115,7 +121,7 @@ public class BehaviorAlarm implements IAlarm {
}
}
}
}
}
else
{
//没人
}
else
if
(
StringUtils
.
equalsAnyIgnoreCase
(
messageType
,
"REPORT_PROPERTY"
,
"OFFLINE"
,
"DISCONNECT"
))
{
//没人
// 是否有第一次进入记录,有则保存db
// 是否有第一次进入记录,有则保存db
Long
startLong
=
alarmRedisDTO
.
getStartLong
();
Long
startLong
=
alarmRedisDTO
.
getStartLong
();
if
(
startLong
==
null
)
{
if
(
startLong
==
null
)
{
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/BreathAlarm.java
View file @
887b4201
...
@@ -54,6 +54,7 @@ public class BreathAlarm implements IAlarm {
...
@@ -54,6 +54,7 @@ public class BreathAlarm implements IAlarm {
*/
*/
@Override
@Override
public
void
checkConfig
(
PlatAlarmCheckDTO
platAlarmCheckDTO
)
{
public
void
checkConfig
(
PlatAlarmCheckDTO
platAlarmCheckDTO
)
{
String
messageType
=
platAlarmCheckDTO
.
getMessageType
();
//todo 获取老人健康的阈值
//todo 获取老人健康的阈值
platAlarmRecordService
.
getElderListByDeviceId
(
platAlarmCheckDTO
);
platAlarmRecordService
.
getElderListByDeviceId
(
platAlarmCheckDTO
);
List
<
PlatElder
>
platElderList
=
platAlarmCheckDTO
.
getPlatElderList
();
List
<
PlatElder
>
platElderList
=
platAlarmCheckDTO
.
getPlatElderList
();
...
@@ -84,6 +85,9 @@ public class BreathAlarm implements IAlarm {
...
@@ -84,6 +85,9 @@ public class BreathAlarm implements IAlarm {
Integer
end
=
ruleConfig
.
getRespiratoryRateEnd
();
Integer
end
=
ruleConfig
.
getRespiratoryRateEnd
();
Integer
duration
=
ruleConfig
.
getDuration
();
Integer
duration
=
ruleConfig
.
getDuration
();
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
if
(
properties
==
null
){
properties
=
new
JSONObject
();
}
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
String
deviceId
=
platDevice
.
getId
();
String
deviceId
=
platDevice
.
getId
();
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"personState"
));
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"personState"
));
...
@@ -135,7 +139,7 @@ public class BreathAlarm implements IAlarm {
...
@@ -135,7 +139,7 @@ public class BreathAlarm implements IAlarm {
notice
(
platAlarmCheckDTO
);
notice
(
platAlarmCheckDTO
);
}
}
}
else
{
}
else
if
(
StringUtils
.
equalsAnyIgnoreCase
(
messageType
,
"REPORT_PROPERTY"
,
"OFFLINE"
,
"DISCONNECT"
))
{
RedisUtil
.
delete
(
RedisConst
.
ALARM_DEVICE_BR_ID
+
deviceId
);
RedisUtil
.
delete
(
RedisConst
.
ALARM_DEVICE_BR_ID
+
deviceId
);
}
}
}
}
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/FallAlarm.java
View file @
887b4201
...
@@ -64,6 +64,9 @@ public class FallAlarm implements IAlarm {
...
@@ -64,6 +64,9 @@ public class FallAlarm implements IAlarm {
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
String
deviceId
=
platDevice
.
getId
();
String
deviceId
=
platDevice
.
getId
();
if
(
properties
==
null
){
properties
=
new
JSONObject
();
}
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"personState"
));
String
personState
=
Convert
.
toStr
(
properties
.
get
(
"personState"
));
//记录停留时长
//记录停留时长
...
@@ -98,6 +101,7 @@ public class FallAlarm implements IAlarm {
...
@@ -98,6 +101,7 @@ public class FallAlarm implements IAlarm {
PlatAlarmConfig
config
=
alarmConfigCacheUtil
.
get
(
platDevice
.
getOrgId
(),
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
BEHAVIOR
.
getValue
());
PlatAlarmConfig
config
=
alarmConfigCacheUtil
.
get
(
platDevice
.
getOrgId
(),
PlatAlarmConfigEnum
.
AlarmTypeEnum
.
BEHAVIOR
.
getValue
());
String
ruleConfigStr
=
config
.
getRuleConfig
();
String
ruleConfigStr
=
config
.
getRuleConfig
();
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
String
messageType
=
platAlarmCheckDTO
.
getMessageType
();
String
deviceId
=
platDevice
.
getId
();
String
deviceId
=
platDevice
.
getId
();
if
(
StringUtils
.
isBlank
(
ruleConfigStr
))
{
if
(
StringUtils
.
isBlank
(
ruleConfigStr
))
{
...
@@ -134,7 +138,7 @@ public class FallAlarm implements IAlarm {
...
@@ -134,7 +138,7 @@ public class FallAlarm implements IAlarm {
alarmRedisDTO
=
new
AlarmRedisDTO
();
alarmRedisDTO
=
new
AlarmRedisDTO
();
}
}
//有人
//有人
if
(!
personStateList
.
contains
(
person
))
{
if
(!
personStateList
.
contains
(
person
)
&&
StringUtils
.
equalsAnyIgnoreCase
(
messageType
,
"REPORT_PROPERTY"
)
)
{
//第一次进入空间
//第一次进入空间
Long
startLong
=
alarmRedisDTO
.
getStartLong
();
Long
startLong
=
alarmRedisDTO
.
getStartLong
();
if
(
startLong
==
null
)
{
if
(
startLong
==
null
)
{
...
@@ -156,7 +160,7 @@ public class FallAlarm implements IAlarm {
...
@@ -156,7 +160,7 @@ public class FallAlarm implements IAlarm {
return
;
return
;
}
}
}
}
}
else
{
//没人
}
else
if
(
StringUtils
.
equalsAnyIgnoreCase
(
messageType
,
"REPORT_PROPERTY"
,
"OFFLINE"
,
"DISCONNECT"
))
{
//没人
// 是否有第一次进入记录,有则保存db
// 是否有第一次进入记录,有则保存db
Long
startLong
=
alarmRedisDTO
.
getStartLong
();
Long
startLong
=
alarmRedisDTO
.
getStartLong
();
if
(
startLong
==
null
)
{
if
(
startLong
==
null
)
{
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/HeartAlarm.java
View file @
887b4201
...
@@ -54,6 +54,7 @@ public class HeartAlarm implements IAlarm {
...
@@ -54,6 +54,7 @@ public class HeartAlarm implements IAlarm {
return
;
return
;
}
}
PlatAlarmConfig
config
=
platAlarmCheckDTO
.
getPlatAlarmConfig
();
PlatAlarmConfig
config
=
platAlarmCheckDTO
.
getPlatAlarmConfig
();
String
messageType
=
platAlarmCheckDTO
.
getMessageType
();
if
(
CommonEnum
.
NO
.
getValue
().
equals
(
config
.
getStatus
()))
{
if
(
CommonEnum
.
NO
.
getValue
().
equals
(
config
.
getStatus
()))
{
log
.
error
(
"呼吸告警配置为禁用,告警配置id:"
+
config
.
getId
());
log
.
error
(
"呼吸告警配置为禁用,告警配置id:"
+
config
.
getId
());
return
;
return
;
...
@@ -74,6 +75,9 @@ public class HeartAlarm implements IAlarm {
...
@@ -74,6 +75,9 @@ public class HeartAlarm implements IAlarm {
}
}
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
JSONObject
properties
=
platAlarmCheckDTO
.
getProperties
();
if
(
properties
==
null
){
properties
=
new
JSONObject
();
}
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
String
deviceId
=
platDevice
.
getId
();
String
deviceId
=
platDevice
.
getId
();
Integer
start
=
ruleConfig
.
getHeartRateStart
();
Integer
start
=
ruleConfig
.
getHeartRateStart
();
...
@@ -126,7 +130,7 @@ public class HeartAlarm implements IAlarm {
...
@@ -126,7 +130,7 @@ public class HeartAlarm implements IAlarm {
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_HR_ID
+
deviceId
,
alarmRedisDTO
);
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_HR_ID
+
deviceId
,
alarmRedisDTO
);
notice
(
platAlarmCheckDTO
);
notice
(
platAlarmCheckDTO
);
}
}
}
else
{
}
else
if
(
StringUtils
.
equalsAnyIgnoreCase
(
messageType
,
"REPORT_PROPERTY"
,
"OFFLINE"
,
"DISCONNECT"
))
{
RedisUtil
.
delete
(
RedisConst
.
ALARM_DEVICE_HR_ID
+
deviceId
);
RedisUtil
.
delete
(
RedisConst
.
ALARM_DEVICE_HR_ID
+
deviceId
);
}
}
...
...
server-service/src/main/java/com/makeit/utils/DayDurationUtil.java
View file @
887b4201
...
@@ -40,7 +40,8 @@ public class DayDurationUtil implements ApplicationRunner {
...
@@ -40,7 +40,8 @@ public class DayDurationUtil implements ApplicationRunner {
return
;
return
;
}
}
Map
<
String
,
List
<
PlatDayDurationRecord
>>
deviceIdMap
=
platDayDurationRecords
.
stream
().
collect
(
Collectors
.
groupingBy
(
PlatDayDurationRecord:
:
getDeviceId
));
Map
<
String
,
List
<
PlatDayDurationRecord
>>
deviceIdMap
=
platDayDurationRecords
.
stream
().
collect
(
Collectors
.
groupingBy
(
PlatDayDurationRecord:
:
getDeviceId
));
deviceIdMap
.
entrySet
().
stream
().
map
(
vo
->
{
//七天都得有数据
deviceIdMap
.
entrySet
().
stream
().
filter
(
vo
->
vo
.
getValue
().
size
()>=
7
).
map
(
vo
->
{
List
<
PlatDayDurationRecord
>
value
=
vo
.
getValue
();
List
<
PlatDayDurationRecord
>
value
=
vo
.
getValue
();
int
size
=
value
.
size
();
int
size
=
value
.
size
();
int
mid
=
size
/
2
;
int
mid
=
size
/
2
;
...
...
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
View file @
887b4201
...
@@ -4,13 +4,9 @@ import com.alibaba.fastjson.JSON;
...
@@ -4,13 +4,9 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.makeit.common.entity.BaseBusEntity
;
import
com.makeit.common.entity.BaseEntity
;
import
com.makeit.dto.platform.alarm.PlatAlarmCheckDTO
;
import
com.makeit.dto.platform.alarm.PlatAlarmCheckDTO
;
import
com.makeit.entity.platform.alarm.PlatAlarmConfig
;
import
com.makeit.entity.platform.alarm.PlatAlarmConfig
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.entity.saas.PlatTenant
;
import
com.makeit.enums.CommonEnum
;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.module.iot.enums.DeviceState
;
import
com.makeit.module.iot.enums.DeviceState
;
import
com.makeit.module.iot.vo.DeviceInfo
;
import
com.makeit.module.iot.vo.DeviceInfo
;
...
@@ -38,7 +34,6 @@ import org.springframework.util.StopWatch;
...
@@ -38,7 +34,6 @@ import org.springframework.util.StopWatch;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
@Component
@Component
...
@@ -157,6 +152,8 @@ public class PushCallback implements MqttCallback {
...
@@ -157,6 +152,8 @@ public class PushCallback implements MqttCallback {
platAlarmCheckDTO
.
setPlatDevice
(
platDevice
);
platAlarmCheckDTO
.
setPlatDevice
(
platDevice
);
//iot上报数据
//iot上报数据
platAlarmCheckDTO
.
setProperties
(
properties
);
platAlarmCheckDTO
.
setProperties
(
properties
);
//设备状态
platAlarmCheckDTO
.
setMessageType
(
messageType
);
alarm
.
checkConfig
(
platAlarmCheckDTO
);
alarm
.
checkConfig
(
platAlarmCheckDTO
);
}
}
}
}
...
...
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