Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pseer
gxpt_ht
Commits
a7c1e71d
Commit
a7c1e71d
authored
Mar 20, 2024
by
YG8999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定时修改设备密码
parent
e936015d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
13 deletions
+24
-13
MqttOpType.java
...e-common/src/main/java/share/common/enums/MqttOpType.java
+2
-1
MqttxServiceImpl.java
...main/java/share/system/service/impl/MqttxServiceImpl.java
+22
-12
No files found.
share-common/src/main/java/share/common/enums/MqttOpType.java
View file @
a7c1e71d
...
...
@@ -17,7 +17,8 @@ public enum MqttOpType {
PASSWORD
(
"password"
,
"远程下发密码"
),
IDCARD
(
"iccard"
,
"远程下发卡片"
),
CONFIG
(
"config"
,
"配置从设备"
),
VOICE
(
"voice"
,
"远程语音播报"
)
VOICE
(
"voice"
,
"远程语音播报"
),
LOCKRSSI
(
"lockrssi"
,
"设备信息上报"
),
;
private
String
code
;
private
String
name
;
...
...
share-system/src/main/java/share/system/service/impl/MqttxServiceImpl.java
View file @
a7c1e71d
...
...
@@ -150,12 +150,21 @@ public class MqttxServiceImpl implements MqttxService {
boolean
isSuccess
=
false
;
System
.
out
.
println
(
"cespayload: "
+
payload
);
if
(
topic
.
endsWith
(
MqttReportType
.
getTopicStr
(
"batch_report"
)))
{
// 修改设备状态、电量、信号值
isSuccess
=
this
.
updateDevice
(
topic
,
payload
);
JSONObject
json
=
JSONUtil
.
parseObj
(
payload
);
if
(
json
.
size
()
>
0
)
{
// 网关devId
String
op
=
json
.
getStr
(
"op"
);
if
(
MqttOpType
.
LOCKRSSI
.
getCode
().
equals
(
op
))
{
// 修改设备状态、电量、信号值
isSuccess
=
this
.
updateDevice
(
topic
,
payload
);
}
else
if
(
MqttOpType
.
PASSWORD
.
getCode
().
equals
(
op
)
||
MqttOpType
.
IDCARD
.
getCode
().
equals
(
op
))
{
isSuccess
=
this
.
updateDeviceLog
(
topic
,
payload
,
2
);
}
}
}
else
if
(
topic
.
endsWith
(
MqttReportType
.
getTopicStr
(
"execute_response"
)))
{
isSuccess
=
this
.
updateDeviceLog
(
topic
,
payload
);
isSuccess
=
this
.
updateDeviceLog
(
topic
,
payload
,
1
);
}
else
if
(
topic
.
endsWith
(
MqttReportType
.
getTopicStr
(
"property_set_response"
)))
{
isSuccess
=
this
.
updateDeviceLog
(
topic
,
payload
);
isSuccess
=
this
.
updateDeviceLog
(
topic
,
payload
,
1
);
}
return
isSuccess
;
}
...
...
@@ -256,11 +265,11 @@ public class MqttxServiceImpl implements MqttxService {
MqttxVo
mqttxVo
=
null
;
if
(
OpTypeEnum
.
OP_DEVICE_PASSWORD
.
getCode
().
equals
(
opType
))
{
// 密码设置
mqttxVo
=
this
.
setOpenPasswordInit
(
devId
,
phone
,
MqttOpType
.
PASSWORD
.
getCode
(),
param
,
startTime
,
endTime
,
mqttxVo
=
this
.
setOpenPasswordInit
(
devId
,
param
,
startTime
,
endTime
,
phone
,
MqttOpType
.
PASSWORD
.
getCode
()
,
MqttConstants
.
MQTT_DESCRIBE_DEVICE_PASSWORD
);
}
else
if
(
OpTypeEnum
.
OP_DEVICE_ICCARD
.
getCode
().
equals
(
opType
))
{
// 卡片设置
mqttxVo
=
this
.
setOpenPasswordInit
(
devId
,
phone
,
MqttOpType
.
IDCARD
.
getCode
(),
param
,
startTime
,
endTime
,
mqttxVo
=
this
.
setOpenPasswordInit
(
devId
,
param
,
startTime
,
endTime
,
phone
,
MqttOpType
.
IDCARD
.
getCode
()
,
MqttConstants
.
MQTT_DESCRIBE_DEVICE_IDCARD
);
}
return
mqttxVo
;
...
...
@@ -336,11 +345,11 @@ public class MqttxServiceImpl implements MqttxService {
MqttxVo
mqttxVo
=
null
;
if
(
OpTypeEnum
.
OP_DEVICE_PASSWORD
.
getCode
().
equals
(
opType
))
{
// 密码设置
mqttxVo
=
this
.
deleteOpenPasswordInit
(
devId
,
phone
,
MqttOpType
.
PASSWORD
.
getCode
(),
param
,
startTime
,
endTime
,
mqttxVo
=
this
.
deleteOpenPasswordInit
(
devId
,
param
,
startTime
,
endTime
,
phone
,
MqttOpType
.
PASSWORD
.
getCode
()
,
MqttConstants
.
MQTT_DESCRIBE_DEVICE_PASSWORD
);
}
else
if
(
OpTypeEnum
.
OP_DEVICE_ICCARD
.
getCode
().
equals
(
opType
))
{
// 卡片设置
mqttxVo
=
this
.
deleteOpenPasswordInit
(
devId
,
phone
,
MqttOpType
.
IDCARD
.
getCode
(),
param
,
startTime
,
endTime
,
mqttxVo
=
this
.
deleteOpenPasswordInit
(
devId
,
param
,
startTime
,
endTime
,
phone
,
MqttOpType
.
IDCARD
.
getCode
()
,
MqttConstants
.
MQTT_DESCRIBE_DEVICE_IDCARD
);
}
return
mqttxVo
;
...
...
@@ -662,17 +671,18 @@ public class MqttxServiceImpl implements MqttxService {
/**
* 存储返回mqtt信息
* @param topic
* @param payload
* @param topic 消息主题
* @param payload 回复消息内容
* @param resultCode 返回消息状态位置
* @return
*/
private
boolean
updateDeviceLog
(
String
topic
,
String
payload
)
{
private
boolean
updateDeviceLog
(
String
topic
,
String
payload
,
Integer
resultCode
)
{
JSONObject
json
=
JSONUtil
.
parseObj
(
payload
);
if
(
json
.
size
()
>
0
)
{
JSONArray
array
=
json
.
getJSONArray
(
"params"
);
if
(
array
!=
null
&&
array
.
size
()
>
0
)
{
String
seq
=
json
.
getStr
(
"seq"
);
String
result
=
array
.
getStr
(
1
);
String
result
=
array
.
getStr
(
resultCode
);
DeviceLog
deviceLog
=
deviceLogMapper
.
selectDeviceLogOneBySeqMax
(
seq
);
// 状态10代表网关接到消息响应,不做处理;另外还会有一条操作结果响应数据
if
(
deviceLog
!=
null
&&
!
"10"
.
equals
(
result
))
{
...
...
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