Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
glinfo-api
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
林业通
glinfo-api
Commits
7bbd06b7
提交
7bbd06b7
authored
5月 18, 2022
作者:
linzhenjie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mqtt订阅修改
上级
eda1077f
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
7 行删除
+14
-7
MqttService.java
...a/tech/glinfo/enbao/modules/mqtt/service/MqttService.java
+14
-7
没有找到文件。
appapi/src/main/java/tech/glinfo/enbao/modules/mqtt/service/MqttService.java
浏览文件 @
7bbd06b7
...
...
@@ -19,10 +19,7 @@ import tech.glinfo.enbao.modules.sh.service.ShProductService;
import
javax.annotation.Resource
;
import
javax.jms.Topic
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
@Slf4j
@Service
...
...
@@ -55,9 +52,11 @@ public class MqttService {
for
(
ShInstructionParsingEntity
cmd
:
cmds
)
{
String
hex
=
msg
.
substring
(
length
,
length
+
cmd
.
getLength
());
String
hex1
;
if
(
cmd
.
getType
()
==
1
||
cmd
.
getType
()
==
2
)
{
if
(
cmd
.
getType
()
==
1
)
{
//整数
hex1
=
String
.
valueOf
(
Integer
.
valueOf
(
hex
,
16
));
}
else
{
}
else
if
(
cmd
.
getType
()
==
2
)
{
//字符串
hex1
=
hex
;
}
else
{
//有符号整数
hex1
=
ByteUtils
.
signHex2IntString
(
hex
);
}
map
.
put
(
cmd
.
getName
(),
hex1
);
...
...
@@ -80,7 +79,7 @@ public class MqttService {
ShDeviceEntity
shDevice
=
new
ShDeviceEntity
();
shDevice
.
setUserId
(
Integer
.
valueOf
(
userId
[
0
]));
shDevice
.
setOnlineStatus
(
2
);
//在线
shDevice
.
setMac
(
mac
);
shDevice
.
setMac
(
"GL"
+
mac
);
shDevice
.
setFamilyId
(
Integer
.
valueOf
(
userId
[
1
]));
shDevice
.
setNumbering
(
topics
[
1
]);
shDevice
.
setName
(
product
.
getName
());
...
...
@@ -100,6 +99,14 @@ public class MqttService {
mapList
.
add
(
map1
);
jmsTemplate
.
convertAndSend
(
socketioTopic
,
JSON
.
toJSONString
(
new
MapUtils
().
put
(
"deviceId"
,
"onlineStatus"
).
put
(
"list"
,
mapList
)));
}
//更新设备状态为在线
new
Thread
(()
->
{
ShDeviceEntity
deviceEntity
=
new
ShDeviceEntity
();
deviceEntity
.
setId
(
device
.
getId
());
deviceEntity
.
setOnlineStatus
(
2
);
deviceEntity
.
setOnlineTime
(
new
Date
());
otherShDeviceService
.
updateById
(
deviceEntity
);
}).
start
();
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论