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
36535723
authored
Sep 22, 2023
by
李小龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fixbug:支持一台设备绑定多个租户
parent
26762860
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
47 additions
and
22 deletions
saas-module/src/main/java/com/makeit/controller/device/SaasDeviceController.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/service/platform/device/PlatDeviceService.java
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
server-service/src/main/java/com/makeit/utils/DeviceCacheUtil.java
server-service/src/main/java/com/makeit/vo/platform/device/PlatDeviceListVO.java
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
saas-module/src/main/java/com/makeit/controller/device/SaasDeviceController.java
View file @
36535723
...
@@ -11,6 +11,7 @@ import com.makeit.entity.platform.device.PlatDevice;
...
@@ -11,6 +11,7 @@ import com.makeit.entity.platform.device.PlatDevice;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.saas.SaasOperationLogService
;
import
com.makeit.service.saas.SaasOperationLogService
;
import
com.makeit.vo.platform.device.PlatDeviceListVO
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -31,7 +32,7 @@ public class SaasDeviceController {
...
@@ -31,7 +32,7 @@ public class SaasDeviceController {
@ApiOperation
(
"列表"
)
@ApiOperation
(
"列表"
)
@PostMapping
(
"page"
)
@PostMapping
(
"page"
)
@TenantIdIgnore
@TenantIdIgnore
public
ApiResponseEntity
<
PageVO
<
PlatDevice
>>
page
(
@RequestBody
PageReqDTO
<
PlatDevice
>
pageReqDTO
)
{
public
ApiResponseEntity
<
PageVO
<
PlatDevice
ListVO
>>
page
(
@RequestBody
PageReqDTO
<
PlatDevice
>
pageReqDTO
)
{
return
ApiResponseUtils
.
success
(
platDeviceService
.
pageSaas
(
pageReqDTO
));
return
ApiResponseUtils
.
success
(
platDeviceService
.
pageSaas
(
pageReqDTO
));
}
}
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/BehaviorAlarm.java
View file @
36535723
...
@@ -76,7 +76,7 @@ public class BehaviorAlarm implements IAlarm {
...
@@ -76,7 +76,7 @@ public class BehaviorAlarm implements IAlarm {
Integer
duration
=
ruleConfig
.
getDuration
();
//分钟
Integer
duration
=
ruleConfig
.
getDuration
();
//分钟
PlatDayDurationRecord
platDayDurationRecord
=
dayDurationUtil
.
get
(
platDevice
.
getOriDeviceId
());
PlatDayDurationRecord
platDayDurationRecord
=
dayDurationUtil
.
get
(
platDevice
.
getOriDeviceId
());
if
(
platDayDurationRecord
==
null
)
{
if
(
platDayDurationRecord
==
null
)
{
log
.
error
(
"行为告警未找到行为异常平均时长,设备id:"
+
platDevice
.
getId
());
log
.
error
(
"行为告警未找到行为异常平均时长,设备
plat_
id:"
+
platDevice
.
getId
());
return
;
return
;
}
}
Long
duration1
=
platDayDurationRecord
.
getDuration
();
Long
duration1
=
platDayDurationRecord
.
getDuration
();
...
@@ -99,13 +99,13 @@ public class BehaviorAlarm implements IAlarm {
...
@@ -99,13 +99,13 @@ public class BehaviorAlarm implements IAlarm {
alarmRedisDTO
.
setStartLong
(
endLong
);
alarmRedisDTO
.
setStartLong
(
endLong
);
alarmRedisDTO
.
setStart
(
now
);
alarmRedisDTO
.
setStart
(
now
);
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_BEHAVIOR_ID
+
deviceId
,
alarmRedisDTO
);
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_BEHAVIOR_ID
+
deviceId
,
alarmRedisDTO
);
log
.
error
(
"空间雷达上报进入房间,设备id:"
+
platDevice
.
getId
());
log
.
error
(
"空间雷达上报进入房间,设备
plat_
id:"
+
platDevice
.
getId
());
return
;
return
;
}
}
long
count
=
endLong
-
startLong
;
long
count
=
endLong
-
startLong
;
//进入空间时间满足告警时长,判断是否已经告警过了
//进入空间时间满足告警时长,判断是否已经告警过了
if
(
count
/
1000
>=
duration
&&
StringUtils
.
equals
(
alarmRedisDTO
.
getAlarm
(),
CommonEnum
.
NO
.
getValue
()))
{
if
(
count
/
1000
>=
duration
&&
StringUtils
.
equals
(
alarmRedisDTO
.
getAlarm
(),
CommonEnum
.
NO
.
getValue
()))
{
log
.
error
(
"空间雷达发出告警,设备id:"
+
platDevice
.
getId
());
log
.
error
(
"空间雷达发出告警,设备
plat_
id:"
+
platDevice
.
getId
());
notice
(
platAlarmCheckDTO
);
notice
(
platAlarmCheckDTO
);
alarmRedisDTO
.
setAlarm
(
CommonEnum
.
YES
.
getValue
());
alarmRedisDTO
.
setAlarm
(
CommonEnum
.
YES
.
getValue
());
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_BEHAVIOR_ID
+
deviceId
,
alarmRedisDTO
);
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_BEHAVIOR_ID
+
deviceId
,
alarmRedisDTO
);
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/BreathAlarm.java
View file @
36535723
...
@@ -85,14 +85,14 @@ public class BreathAlarm implements IAlarm {
...
@@ -85,14 +85,14 @@ public class BreathAlarm implements IAlarm {
alarmRedisDTO
.
setStart
(
now
);
alarmRedisDTO
.
setStart
(
now
);
alarmRedisDTO
.
setStartLong
(
endLong
);
alarmRedisDTO
.
setStartLong
(
endLong
);
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_BR_ID
+
deviceId
,
alarmRedisDTO
);
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_BR_ID
+
deviceId
,
alarmRedisDTO
);
log
.
error
(
"发现长者呼吸异常,设备id:"
+
deviceId
);
log
.
error
(
"发现长者呼吸异常,设备
plat_
id:"
+
deviceId
);
return
;
return
;
}
}
Long
startLong
=
alarmRedisDTO
.
getStartLong
();
Long
startLong
=
alarmRedisDTO
.
getStartLong
();
long
count
=
endLong
-
startLong
;
long
count
=
endLong
-
startLong
;
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
.
error
(
"呼吸已告警,设备id:"
+
platDevice
.
getId
());
log
.
error
(
"呼吸已告警,设备
plat_
id:"
+
platDevice
.
getId
());
return
;
return
;
}
}
fillRemark
(
platAlarmCheckDTO
,
br
,
start
,
end
);
fillRemark
(
platAlarmCheckDTO
,
br
,
start
,
end
);
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/FallAlarm.java
View file @
36535723
...
@@ -66,7 +66,7 @@ public class FallAlarm implements IAlarm {
...
@@ -66,7 +66,7 @@ public class FallAlarm 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
(
"跌倒设备未关联长者,设备id:"
+
platDevice
.
getId
());
log
.
error
(
"跌倒设备未关联长者,设备
plat_
id:"
+
platDevice
.
getId
());
return
;
return
;
}
}
PlatRoom
platRoom
=
platAlarmCheckDTO
.
getPlatRoom
();
PlatRoom
platRoom
=
platAlarmCheckDTO
.
getPlatRoom
();
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/alarmStrategy/HeartAlarm.java
View file @
36535723
...
@@ -75,7 +75,7 @@ public class HeartAlarm implements IAlarm {
...
@@ -75,7 +75,7 @@ public class HeartAlarm implements IAlarm {
alarmRedisDTO
.
setStart
(
now
);
alarmRedisDTO
.
setStart
(
now
);
alarmRedisDTO
.
setStartLong
(
endLong
);
alarmRedisDTO
.
setStartLong
(
endLong
);
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_HR_ID
+
deviceId
,
alarmRedisDTO
);
RedisUtil
.
set
(
RedisConst
.
ALARM_DEVICE_HR_ID
+
deviceId
,
alarmRedisDTO
);
log
.
error
(
"发现长者心率异常,设备id:"
+
deviceId
);
log
.
error
(
"发现长者心率异常,设备i
ot_i
d:"
+
deviceId
);
return
;
return
;
}
}
Long
startLong
=
alarmRedisDTO
.
getStartLong
();
Long
startLong
=
alarmRedisDTO
.
getStartLong
();
...
@@ -84,7 +84,7 @@ public class HeartAlarm implements IAlarm {
...
@@ -84,7 +84,7 @@ public class HeartAlarm implements IAlarm {
//todo 如果每台服务器都能收到上报消息 加redis锁
//todo 如果每台服务器都能收到上报消息 加redis锁
//RLock lock = RedisLockUtil.lock(RedisConst.LOCK_ALARM + deviceId);
//RLock lock = RedisLockUtil.lock(RedisConst.LOCK_ALARM + deviceId);
if
(
StringUtils
.
equals
(
alarmRedisDTO
.
getAlarm
(),
CommonEnum
.
YES
.
getValue
()))
{
if
(
StringUtils
.
equals
(
alarmRedisDTO
.
getAlarm
(),
CommonEnum
.
YES
.
getValue
()))
{
log
.
error
(
"心率已告警,设备id:"
+
platDevice
.
getId
());
log
.
error
(
"心率已告警,设备
plat_
id:"
+
platDevice
.
getId
());
return
;
return
;
}
}
fillRemark
(
platAlarmCheckDTO
,
hr
,
start
,
end
);
fillRemark
(
platAlarmCheckDTO
,
hr
,
start
,
end
);
...
@@ -116,7 +116,7 @@ public class HeartAlarm implements IAlarm {
...
@@ -116,7 +116,7 @@ public class HeartAlarm implements IAlarm {
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
PlatDevice
platDevice
=
platAlarmCheckDTO
.
getPlatDevice
();
List
<
PlatElder
>
platElderList
=
platAlarmCheckDTO
.
getPlatElderList
();
List
<
PlatElder
>
platElderList
=
platAlarmCheckDTO
.
getPlatElderList
();
if
(
CollectionUtils
.
isEmpty
(
platElderList
))
{
if
(
CollectionUtils
.
isEmpty
(
platElderList
))
{
log
.
error
(
"心率设备未关联长者,设备id:"
+
platAlarmCheckDTO
.
getPlatDevice
().
getId
());
log
.
error
(
"心率设备未关联长者,设备
plat_
id:"
+
platAlarmCheckDTO
.
getPlatDevice
().
getId
());
return
;
return
;
}
}
for
(
PlatElder
platElder
:
platElderList
)
{
for
(
PlatElder
platElder
:
platElderList
)
{
...
@@ -128,7 +128,7 @@ public class HeartAlarm implements IAlarm {
...
@@ -128,7 +128,7 @@ public class HeartAlarm implements IAlarm {
platAlarmRecord
.
setElderIds
(
platElder
.
getId
());
platAlarmRecord
.
setElderIds
(
platElder
.
getId
());
platAlarmRecord
.
setElderName
(
platElder
.
getName
());
platAlarmRecord
.
setElderName
(
platElder
.
getName
());
platAlarmRecordService
.
noticeDeviceAlarm
(
platAlarmCheckDTO
.
getPlatAlarmConfig
(),
platAlarmRecord
);
platAlarmRecordService
.
noticeDeviceAlarm
(
platAlarmCheckDTO
.
getPlatAlarmConfig
(),
platAlarmRecord
);
log
.
error
(
"长者心率异常,发出告警,设备id:"
+
platDevice
.
getId
()+
", 长者名称:"
+
platElder
.
getName
());
log
.
error
(
"长者心率异常,发出告警,设备
plat_
id:"
+
platDevice
.
getId
()+
", 长者名称:"
+
platElder
.
getName
());
}
}
}
}
}
}
server-service/src/main/java/com/makeit/service/platform/device/PlatDeviceService.java
View file @
36535723
...
@@ -42,7 +42,7 @@ public interface PlatDeviceService extends IService<PlatDevice> {
...
@@ -42,7 +42,7 @@ public interface PlatDeviceService extends IService<PlatDevice> {
* @param pageReqDTO
* @param pageReqDTO
* @return
* @return
*/
*/
PageVO
<
PlatDevice
>
pageSaas
(
PageReqDTO
<
PlatDevice
>
pageReqDTO
);
PageVO
<
PlatDevice
ListVO
>
pageSaas
(
PageReqDTO
<
PlatDevice
>
pageReqDTO
);
/**
/**
* 设备信息
* 设备信息
...
...
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
View file @
36535723
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.makeit.common.dto.BaseTenantDTO
;
import
com.makeit.common.entity.BaseBusEntity
;
import
com.makeit.common.entity.BaseBusEntity
;
import
com.makeit.common.entity.BaseEntity
;
import
com.makeit.common.entity.BaseEntity
;
import
com.makeit.common.page.PageReqDTO
;
import
com.makeit.common.page.PageReqDTO
;
...
@@ -25,6 +26,7 @@ import com.makeit.module.iot.service.IotDevicePropertiesOperateService;
...
@@ -25,6 +26,7 @@ import com.makeit.module.iot.service.IotDevicePropertiesOperateService;
import
com.makeit.service.platform.auth.PlatOrgService
;
import
com.makeit.service.platform.auth.PlatOrgService
;
import
com.makeit.service.platform.device.PlatDeviceOtherService
;
import
com.makeit.service.platform.device.PlatDeviceOtherService
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.saas.PlatTenantService
;
import
com.makeit.utils.DeviceCacheUtil
;
import
com.makeit.utils.DeviceCacheUtil
;
import
com.makeit.utils.data.convert.BeanDtoVoUtils
;
import
com.makeit.utils.data.convert.BeanDtoVoUtils
;
import
com.makeit.utils.data.convert.PageUtil
;
import
com.makeit.utils.data.convert.PageUtil
;
...
@@ -60,6 +62,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -60,6 +62,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
private
DeviceCacheUtil
deviceCacheUtil
;
private
DeviceCacheUtil
deviceCacheUtil
;
@Autowired
@Autowired
private
IotDevicePropertiesOperateService
devicePropertiesOperateService
;
private
IotDevicePropertiesOperateService
devicePropertiesOperateService
;
@Autowired
private
PlatTenantService
platTenantService
;
@Override
@Override
public
PageVO
<
PlatDeviceListVO
>
page
(
PageReqDTO
<
PlatDeviceQueryDTO
>
pageReqDTO
)
{
public
PageVO
<
PlatDeviceListVO
>
page
(
PageReqDTO
<
PlatDeviceQueryDTO
>
pageReqDTO
)
{
...
@@ -195,12 +199,17 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -195,12 +199,17 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
}
}
@Override
@Override
public
PageVO
<
PlatDevice
>
pageSaas
(
PageReqDTO
<
PlatDevice
>
pageReqDTO
)
{
public
PageVO
<
PlatDevice
ListVO
>
pageSaas
(
PageReqDTO
<
PlatDevice
>
pageReqDTO
)
{
PlatDevice
param
=
pageReqDTO
.
getData
();
PlatDevice
param
=
pageReqDTO
.
getData
();
Page
<
PlatDevice
>
page
=
PageUtil
.
toMpPage
(
pageReqDTO
);
Page
<
PlatDevice
>
page
=
PageUtil
.
toMpPage
(
pageReqDTO
);
LambdaQueryWrapper
<
PlatDevice
>
lambdaQueryWrapper
=
getLambdaQueryWrapper
(
param
);
LambdaQueryWrapper
<
PlatDevice
>
lambdaQueryWrapper
=
getLambdaQueryWrapper
(
param
);
Page
<
PlatDevice
>
devicePage
=
page
(
page
,
lambdaQueryWrapper
);
Page
<
PlatDevice
>
devicePage
=
page
(
page
,
lambdaQueryWrapper
);
return
PageUtil
.
toPageVO
(
devicePage
);
List
<
PlatDevice
>
records
=
devicePage
.
getRecords
();
List
<
PlatDeviceListVO
>
platDeviceListVOS
=
BeanDtoVoUtils
.
listVo
(
records
,
PlatDeviceListVO
.
class
);
JoinUtil
.
join
(
platDeviceListVOS
,
platTenantService
,
BaseTenantDTO:
:
getTenantId
,
BaseEntity:
:
getId
,(
d
,
o
)->{
d
.
setTenantName
(
o
.
getName
());
});
return
PageUtil
.
toPageVO
(
platDeviceListVOS
,
devicePage
);
}
}
@Override
@Override
...
...
server-service/src/main/java/com/makeit/utils/DeviceCacheUtil.java
View file @
36535723
...
@@ -2,10 +2,12 @@ package com.makeit.utils;
...
@@ -2,10 +2,12 @@ package com.makeit.utils;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.entity.saas.PlatTenant
;
import
com.makeit.enums.redis.RedisConst
;
import
com.makeit.enums.redis.RedisConst
;
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.service.platform.device.PlatDeviceService
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.saas.PlatTenantService
;
import
com.makeit.utils.redis.RedisUtil
;
import
com.makeit.utils.redis.RedisUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -21,6 +23,8 @@ public class DeviceCacheUtil implements ApplicationRunner {
...
@@ -21,6 +23,8 @@ public class DeviceCacheUtil implements ApplicationRunner {
@Autowired
@Autowired
private
PlatDeviceService
platDeviceService
;
private
PlatDeviceService
platDeviceService
;
@Autowired
private
PlatTenantService
platTenantService
;
public
List
<
PlatDevice
>
getAll
()
{
public
List
<
PlatDevice
>
getAll
()
{
List
<
PlatDevice
>
list
=
platDeviceService
.
list
(
new
LambdaQueryWrapper
<
PlatDevice
>().
eq
(
PlatDevice:
:
getStatus
,
DeviceState
.
online
.
getValue
()));
List
<
PlatDevice
>
list
=
platDeviceService
.
list
(
new
LambdaQueryWrapper
<
PlatDevice
>().
eq
(
PlatDevice:
:
getStatus
,
DeviceState
.
online
.
getValue
()));
...
@@ -31,19 +35,20 @@ public class DeviceCacheUtil implements ApplicationRunner {
...
@@ -31,19 +35,20 @@ public class DeviceCacheUtil implements ApplicationRunner {
}
}
public
void
put
(
PlatDevice
platDevice
)
{
public
void
put
(
PlatDevice
platDevice
)
{
PlatTenant
platTenant
=
platTenantService
.
getById
(
platDevice
.
getTenantId
());
if
(
StringUtils
.
equals
(
platDevice
.
getStatus
(),
DeviceState
.
online
.
getValue
()))
{
if
(
StringUtils
.
equals
(
platDevice
.
getStatus
(),
DeviceState
.
online
.
getValue
()))
{
RedisUtil
.
set
(
RedisConst
.
PLAT_IOT_DEVICE_PREFIX
+
platDevice
.
getOriDeviceId
(),
platDevice
);
RedisUtil
.
set
(
RedisConst
.
PLAT_IOT_DEVICE_PREFIX
+
platDevice
.
getOriDeviceId
()
+
":"
+
platTenant
.
getIotOrgId
()
,
platDevice
);
}
else
{
}
else
{
RedisUtil
.
delete
(
RedisConst
.
PLAT_IOT_DEVICE_PREFIX
+
platDevice
.
getOriDeviceId
());
RedisUtil
.
delete
(
RedisConst
.
PLAT_IOT_DEVICE_PREFIX
+
platDevice
.
getOriDeviceId
()
+
":"
+
platTenant
.
getIotOrgId
()
);
}
}
}
}
public
PlatDevice
get
(
String
oriDeviceId
)
{
public
PlatDevice
get
(
String
oriDeviceId
AndIotOrgId
)
{
PlatDevice
platDevice
=
RedisUtil
.
get
(
RedisConst
.
PLAT_IOT_DEVICE_PREFIX
+
oriDeviceId
);
PlatDevice
platDevice
=
RedisUtil
.
get
(
RedisConst
.
PLAT_IOT_DEVICE_PREFIX
+
oriDeviceId
AndIotOrgId
);
if
(
platDevice
==
null
){
if
(
platDevice
==
null
){
getAll
();
getAll
();
}
}
return
RedisUtil
.
get
(
RedisConst
.
PLAT_IOT_DEVICE_PREFIX
+
oriDeviceId
);
return
RedisUtil
.
get
(
RedisConst
.
PLAT_IOT_DEVICE_PREFIX
+
oriDeviceId
AndIotOrgId
);
}
}
public
void
putAll
(
Collection
<
PlatDevice
>
platDeviceList
)
{
public
void
putAll
(
Collection
<
PlatDevice
>
platDeviceList
)
{
platDeviceList
.
forEach
(
vo
->
{
platDeviceList
.
forEach
(
vo
->
{
...
...
server-service/src/main/java/com/makeit/vo/platform/device/PlatDeviceListVO.java
View file @
36535723
...
@@ -74,4 +74,7 @@ public class PlatDeviceListVO extends BaseTenantDTO {
...
@@ -74,4 +74,7 @@ public class PlatDeviceListVO extends BaseTenantDTO {
private
LocalDateTime
endDate
;
private
LocalDateTime
endDate
;
private
String
tenantName
;
}
}
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
View file @
36535723
...
@@ -7,6 +7,7 @@ import com.makeit.entity.platform.alarm.PlatAlarmConfig;
...
@@ -7,6 +7,7 @@ import com.makeit.entity.platform.alarm.PlatAlarmConfig;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.module.iot.vo.DeviceInfo
;
import
com.makeit.module.iot.vo.DeviceInfo
;
import
com.makeit.module.iot.vo.HeaderInfo
;
import
com.makeit.service.platform.alarm.alarmStrategy.IAlarm
;
import
com.makeit.service.platform.alarm.alarmStrategy.IAlarm
;
import
com.makeit.utils.AlarmConfigCacheUtil
;
import
com.makeit.utils.AlarmConfigCacheUtil
;
import
com.makeit.utils.DeviceCacheUtil
;
import
com.makeit.utils.DeviceCacheUtil
;
...
@@ -79,6 +80,10 @@ public class PushCallback implements MqttCallback {
...
@@ -79,6 +80,10 @@ public class PushCallback implements MqttCallback {
@TenantIdIgnore
@TenantIdIgnore
@Async
@Async
public
void
checkAlarm
(
DeviceInfo
device
)
{
public
void
checkAlarm
(
DeviceInfo
device
)
{
HeaderInfo
headers
=
device
.
getHeaders
();
List
<
HeaderInfo
.
Bind
>
bindings
=
headers
.
getBindings
();
for
(
HeaderInfo
.
Bind
binding
:
bindings
)
{
String
iot_tenantId
=
binding
.
getId
();
StopWatch
stopWatch
=
new
StopWatch
();
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
(
"checkAlarm-1"
);
stopWatch
.
start
(
"checkAlarm-1"
);
String
deviceId
=
device
.
getDeviceId
();
String
deviceId
=
device
.
getDeviceId
();
...
@@ -86,15 +91,15 @@ public class PushCallback implements MqttCallback {
...
@@ -86,15 +91,15 @@ public class PushCallback implements MqttCallback {
JSONObject
properties
=
device
.
getProperties
();
JSONObject
properties
=
device
.
getProperties
();
//iot设备id
//iot设备id
PlatDevice
platDevice
=
deviceCacheUtil
.
get
(
device
Id
);
PlatDevice
platDevice
=
deviceCacheUtil
.
get
(
deviceId
+
":"
+
iot_tenant
Id
);
if
(
platDevice
==
null
){
if
(
platDevice
==
null
){
logger
.
error
(
"
设备信息异常,设备iot-id:"
+
deviceId
);
logger
.
error
(
"获取
设备信息异常,设备iot-id:"
+
deviceId
);
return
;
return
;
}
}
List
<
PlatAlarmConfig
>
deviceAlarmConfigList
=
alarmConfigCacheUtil
.
getDeviceAlarmConfigMap
(
platDevice
);
List
<
PlatAlarmConfig
>
deviceAlarmConfigList
=
alarmConfigCacheUtil
.
getDeviceAlarmConfigMap
(
platDevice
);
deviceAlarmConfigList
.
removeIf
(
Objects:
:
isNull
);
deviceAlarmConfigList
.
removeIf
(
Objects:
:
isNull
);
if
(
CollectionUtils
.
isEmpty
(
deviceAlarmConfigList
))
{
if
(
CollectionUtils
.
isEmpty
(
deviceAlarmConfigList
))
{
logger
.
error
(
"该设备没有告警配置
:"
+
deviceId
);
logger
.
error
(
"该设备没有告警配置,设备iot-id
:"
+
deviceId
);
return
;
return
;
}
}
for
(
PlatAlarmConfig
config
:
deviceAlarmConfigList
)
{
for
(
PlatAlarmConfig
config
:
deviceAlarmConfigList
)
{
...
@@ -116,6 +121,8 @@ public class PushCallback implements MqttCallback {
...
@@ -116,6 +121,8 @@ public class PushCallback implements MqttCallback {
}
}
stopWatch
.
stop
();
stopWatch
.
stop
();
logger
.
info
(
stopWatch
.
prettyPrint
());
logger
.
info
(
stopWatch
.
prettyPrint
());
}
}
}
...
...
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