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
03683200
authored
Feb 04, 2024
by
罗志长
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
feat: 设备上报故障处理
parent
3eb46154
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
5 deletions
server-common/src/main/java/com/makeit/enums/redis/RedisConst.java
server-common/src/main/java/com/makeit/module/iot/service/IotDevicePropertiesOperateService.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-web/src/main/java/com/makeit/mqtt/PushCallback.java
server-common/src/main/java/com/makeit/enums/redis/RedisConst.java
View file @
03683200
...
@@ -109,7 +109,7 @@ public class RedisConst {
...
@@ -109,7 +109,7 @@ public class RedisConst {
public
static
final
String
ALARM_HEALTH_CONFIG_PREFIX
=
"alarm:config:device:id:"
;
public
static
final
String
ALARM_HEALTH_CONFIG_PREFIX
=
"alarm:config:device:id:"
;
public
static
final
String
PLAT_IOT_DEVICE_FAULT_STATE_PREFIX
=
"plat:iot:device:faultState:"
;
...
...
server-common/src/main/java/com/makeit/module/iot/service/IotDevicePropertiesOperateService.java
View file @
03683200
...
@@ -123,4 +123,18 @@ public class IotDevicePropertiesOperateService extends IotCommonService {
...
@@ -123,4 +123,18 @@ public class IotDevicePropertiesOperateService extends IotCommonService {
}
}
return
""
;
return
""
;
}
}
public
boolean
changeDeviceFaultState
(
String
deviceId
,
String
state
)
{
String
url
=
iotUrl
+
DEVICE_PREFIX_URL
+
deviceId
+
"/change/"
+
state
;
HttpRequest
request
=
buildRequest
(
url
,
"{}"
);
try
{
ResponseMessage
responseMessage
=
sendPost
(
url
,
request
);
log
.
info
(
"更改设备故障状态返回信息:{}"
,
responseMessage
.
getMessage
());
return
responseMessage
.
getStatus
()
==
200
;
}
catch
(
IOException
e
)
{
log
.
error
(
"调用:{}接口异常:{}"
,
url
,
e
.
getMessage
());
return
false
;
}
}
}
}
server-service/src/main/java/com/makeit/service/platform/device/PlatDeviceService.java
View file @
03683200
...
@@ -11,6 +11,7 @@ import com.makeit.dto.platform.device.*;
...
@@ -11,6 +11,7 @@ import com.makeit.dto.platform.device.*;
import
com.makeit.dto.saas.device.PlatDeviceEditSaasDTO
;
import
com.makeit.dto.saas.device.PlatDeviceEditSaasDTO
;
import
com.makeit.dto.wechat.device.*
;
import
com.makeit.dto.wechat.device.*
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.module.iot.vo.DeviceInfo
;
import
com.makeit.module.iot.vo.DeviceProperties
;
import
com.makeit.module.iot.vo.DeviceProperties
;
import
com.makeit.shengwang.agora.dto.PlatCallingDeviceDTO
;
import
com.makeit.shengwang.agora.dto.PlatCallingDeviceDTO
;
import
com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO
;
import
com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO
;
...
@@ -99,4 +100,9 @@ public interface PlatDeviceService extends IService<PlatDevice> {
...
@@ -99,4 +100,9 @@ public interface PlatDeviceService extends IService<PlatDevice> {
void
syncIotProperties
(
String
deviceId
,
JSONObject
iotProperties
);
void
syncIotProperties
(
String
deviceId
,
JSONObject
iotProperties
);
List
<
PlatDevice
>
listOffBed
(
String
oriDeviceId
);
List
<
PlatDevice
>
listOffBed
(
String
oriDeviceId
);
/**
* 故障处理
*/
void
handleFault
(
DeviceInfo
deviceInfo
);
}
}
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
View file @
03683200
...
@@ -49,10 +49,7 @@ import com.makeit.module.iot.dto.UserServerInfo;
...
@@ -49,10 +49,7 @@ import com.makeit.module.iot.dto.UserServerInfo;
import
com.makeit.module.iot.service.IotDevicePropertiesOperateService
;
import
com.makeit.module.iot.service.IotDevicePropertiesOperateService
;
import
com.makeit.module.iot.service.IotOrgService
;
import
com.makeit.module.iot.service.IotOrgService
;
import
com.makeit.module.iot.service.IotProductDeviceService
;
import
com.makeit.module.iot.service.IotProductDeviceService
;
import
com.makeit.module.iot.vo.DeviceDetail
;
import
com.makeit.module.iot.vo.*
;
import
com.makeit.module.iot.vo.DeviceInstanceEntity
;
import
com.makeit.module.iot.vo.DeviceProperties
;
import
com.makeit.module.iot.vo.DeviceState
;
import
com.makeit.module.system.service.SysDictionaryCategoryService
;
import
com.makeit.module.system.service.SysDictionaryCategoryService
;
import
com.makeit.module.system.vo.DictionaryVo
;
import
com.makeit.module.system.vo.DictionaryVo
;
import
com.makeit.oss.AliyunOSSRepository
;
import
com.makeit.oss.AliyunOSSRepository
;
...
@@ -1181,4 +1178,34 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -1181,4 +1178,34 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
public
List
<
PlatDevice
>
listOffBed
(
String
oriDeviceId
)
{
public
List
<
PlatDevice
>
listOffBed
(
String
oriDeviceId
)
{
return
list
(
Wrappers
.<
PlatDevice
>
lambdaQuery
().
eq
(
PlatDevice:
:
getOriDeviceId
,
oriDeviceId
));
return
list
(
Wrappers
.<
PlatDevice
>
lambdaQuery
().
eq
(
PlatDevice:
:
getOriDeviceId
,
oriDeviceId
));
}
}
@Override
public
void
handleFault
(
DeviceInfo
deviceInfo
)
{
String
deviceId
=
deviceInfo
.
getDeviceId
();
JSONObject
properties
=
deviceInfo
.
getProperties
();
String
faultState
=
properties
.
getString
(
"radarHitch"
);
boolean
isNormal
=
"normal"
.
equals
(
faultState
);
String
key
=
RedisConst
.
PLAT_IOT_DEVICE_FAULT_STATE_PREFIX
+
deviceId
;
String
value
=
RedisUtil
.
get
(
key
);
if
(!
isNormal
)
{
if
(
StringUtils
.
isBlank
(
value
))
{
boolean
isSuccess
=
devicePropertiesOperateService
.
changeDeviceFaultState
(
deviceId
,
"abnormal"
);
if
(!
isSuccess
)
{
return
;
}
RedisUtil
.
set
(
key
,
faultState
);
log
.
info
(
"handleFault设置故障"
);
}
}
else
{
if
(
StringUtils
.
isNotBlank
(
value
))
{
boolean
isSuccess
=
devicePropertiesOperateService
.
changeDeviceFaultState
(
deviceId
,
"normal"
);
if
(!
isSuccess
)
{
return
;
}
RedisUtil
.
delete
(
key
);
log
.
info
(
"handleFault恢复正常"
);
}
}
}
}
}
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
View file @
03683200
...
@@ -122,6 +122,8 @@ public class PushCallback implements MqttCallbackExtended {
...
@@ -122,6 +122,8 @@ public class PushCallback implements MqttCallbackExtended {
return
;
return
;
}
}
handleFault
(
device
);
CompletableFuture
.
runAsync
(()
->
{
CompletableFuture
.
runAsync
(()
->
{
checkAlarm
(
device
);
checkAlarm
(
device
);
},
taskExecutor
);
},
taskExecutor
);
...
@@ -273,6 +275,18 @@ public class PushCallback implements MqttCallbackExtended {
...
@@ -273,6 +275,18 @@ public class PushCallback implements MqttCallbackExtended {
}
}
/**
/**
* 处理设备故障
*/
public
void
handleFault
(
DeviceInfo
device
)
{
if
(!
REPORT_PROPERTY
.
equals
(
device
.
getMessageType
()))
{
return
;
}
CompletableFuture
.
runAsync
(()
->
{
platDeviceService
.
handleFault
(
device
);
});
}
/**
* 离床预警
* 离床预警
* @param platDevice
* @param platDevice
* @param properties
* @param properties
...
...
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