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
9d66a9a5
Commit
9d66a9a5
authored
Nov 09, 2023
by
YG8999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mqtt服务修改
parent
02ef6b7c
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
155 additions
and
4 deletions
+155
-4
application-dev.yml
share-admin/src/main/resources/application-dev.yml
+1
-0
application-prod.yml
share-admin/src/main/resources/application-prod.yml
+2
-0
application-test.yml
share-admin/src/main/resources/application-test.yml
+1
-0
DeviceType.java
...e-common/src/main/java/share/common/enums/DeviceType.java
+38
-0
MqttConfig.java
...mework/src/main/java/share/framework/mqtt/MqttConfig.java
+6
-0
pom.xml
share-front/pom.xml
+1
-0
DeviceOpService.java
...ront/src/main/java/share/web/service/DeviceOpService.java
+96
-0
application-dev.yml
share-front/src/main/resources/application-dev.yml
+5
-4
application-prod.yml
share-front/src/main/resources/application-prod.yml
+1
-0
application-test.yml
share-front/src/main/resources/application-test.yml
+1
-0
DeviceParamVo.java
...m/src/main/java/share/system/domain/vo/DeviceParamVo.java
+3
-0
No files found.
share-admin/src/main/resources/application-dev.yml
View file @
9d66a9a5
...
...
@@ -140,6 +140,7 @@ spring:
password
:
"
Mqtt@2023cj"
defaultTopic
:
"
ydlink/#"
completion-timeout
:
15000
is-subscribe-topic
:
true
# token配置
token
:
...
...
share-admin/src/main/resources/application-prod.yml
View file @
9d66a9a5
...
...
@@ -137,6 +137,8 @@ spring:
password
:
"
Mqtt@2023cj"
defaultTopic
:
"
ydlink/#"
completion-timeout
:
15000
is-subscribe-topic
:
true
# token配置
token
:
# 令牌自定义标识
...
...
share-admin/src/main/resources/application-test.yml
View file @
9d66a9a5
...
...
@@ -137,6 +137,7 @@ spring:
password
:
"
Mqtt@2023cj"
defaultTopic
:
"
ydlink/#"
completion-timeout
:
15000
is-subscribe-topic
:
true
# token配置
token
:
...
...
share-common/src/main/java/share/common/enums/DeviceType.java
0 → 100644
View file @
9d66a9a5
package
share
.
common
.
enums
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @className: share.common.enums.MqttOpenType
* @description: 设备类型
* @author: lwj
* @create: 2023-11-04 15:35
*/
public
enum
DeviceType
{
DEVICE_CCEE
(
"CCEE"
,
"门锁"
),
DEVICE_0001
(
"0001"
,
"取电开关"
),
DEVICE_GATEWAY
(
"7"
,
"网关"
)
;
private
String
code
;
private
String
name
;
DeviceType
(
String
code
,
String
name
)
{
this
.
code
=
code
;
this
.
name
=
name
;
}
//code转字符串1,2,3,4
public
static
String
getCodeList
()
{
List
<
String
>
list
=
Arrays
.
stream
(
DeviceType
.
values
()).
map
(
DeviceType:
:
getCode
).
collect
(
Collectors
.
toList
());
return
String
.
join
(
","
,
list
);
}
public
String
getCode
()
{
return
code
;
}
public
String
getName
()
{
return
name
;
}
}
share-framework/src/main/java/share/framework/mqtt/MqttConfig.java
View file @
9d66a9a5
...
...
@@ -56,6 +56,9 @@ public class MqttConfig {
@Value
(
"${spring.mqtt.defaultTopic}"
)
private
String
defaultTopic
;
@Value
(
"${spring.mqtt.is-subscribe-topic}"
)
private
boolean
isSubscribeTopic
;
private
SnowFlakeUtil
snowFlakeUtil
=
new
SnowFlakeUtil
(
0
,
0
);
@Resource
...
...
@@ -163,8 +166,11 @@ public class MqttConfig {
@ServiceActivator
(
inputChannel
=
"mqttInputChannel"
)
public
MessageHandler
handler
()
{
return
message
->
{
// mqtt订阅消息由share_admin服务端处理
if
(
isSubscribeTopic
)
{
//接收到的消息由这个处理器进行处理
mqttMessageHandler
.
handleMessage
(
message
);
}
};
}
...
...
share-front/pom.xml
View file @
9d66a9a5
...
...
@@ -62,6 +62,7 @@
<artifactId>
spring-boot-maven-plugin
</artifactId>
<version>
2.5.15
</version>
<configuration>
<includeSystemScope>
true
</includeSystemScope>
<fork>
true
</fork>
<!-- 如果没有该配置,devtools不会生效 -->
</configuration>
<executions>
...
...
share-front/src/main/java/share/web/service/DeviceOpService.java
0 → 100644
View file @
9d66a9a5
package
share
.
web
.
service
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
share.common.enums.DeviceType
;
import
share.framework.mqtt.MqttGatewayComponent
;
import
share.system.domain.Device
;
import
share.system.domain.SRoom
;
import
share.system.domain.vo.DeviceParamVo
;
import
share.system.domain.vo.MqttxVo
;
import
share.system.mapper.DeviceMapper
;
import
share.system.mapper.SRoomMapper
;
import
share.system.service.DeviceLogService
;
import
share.system.service.MqttxService
;
import
java.util.List
;
/**
* @className: share.web.service.DeviceOpService
* @description: 设备操作接口
* @author: lwj
* @create: 2023-11-09 10:38
*/
@Service
public
class
DeviceOpService
{
@Autowired
private
MqttGatewayComponent
mqttGatewayComponent
;
@Autowired
private
SRoomMapper
roomMapper
;
@Autowired
private
MqttxService
mqttxService
;
@Autowired
private
DeviceLogService
deviceLogService
;
@Autowired
private
DeviceMapper
deviceMapper
;
/**
* 小程序订单开门
* @param deviceParam
*/
public
void
openDoor
(
DeviceParamVo
deviceParam
)
{
SRoom
room
=
roomMapper
.
selectSRoomById
(
deviceParam
.
getRoomId
());
if
(
room
!=
null
)
{
Device
param
=
new
Device
();
param
.
setRoomId
(
room
.
getId
());
List
<
Device
>
list
=
deviceMapper
.
selectDeviceList
(
param
);
for
(
Device
device
:
list
)
{
if
(
DeviceType
.
DEVICE_CCEE
.
getCode
().
equals
(
device
.
getDevType
()))
{
// 门锁
this
.
deviceOpInit
(
device
.
getDevId
(),
deviceParam
.
getPhone
(),
"10"
);
}
if
(
DeviceType
.
DEVICE_0001
.
getCode
().
equals
(
device
.
getDevType
()))
{
// 取电开关
this
.
deviceOpInit
(
device
.
getDevId
(),
deviceParam
.
getPhone
(),
"20"
);
}
}
}
}
/**
* 小程序订单开门
* @param roomId 房间id
* @param phone 操作用户
*/
public
void
openDoor
(
Long
roomId
,
String
phone
)
{
SRoom
room
=
roomMapper
.
selectSRoomById
(
roomId
);
if
(
room
!=
null
)
{
Device
param
=
new
Device
();
param
.
setRoomId
(
room
.
getId
());
List
<
Device
>
list
=
deviceMapper
.
selectDeviceList
(
param
);
for
(
Device
device
:
list
)
{
if
(
DeviceType
.
DEVICE_CCEE
.
getCode
().
equals
(
device
.
getDevType
()))
{
// 门锁
this
.
deviceOpInit
(
device
.
getDevId
(),
phone
,
"10"
);
}
if
(
DeviceType
.
DEVICE_0001
.
getCode
().
equals
(
device
.
getDevType
()))
{
// 取电开关
this
.
deviceOpInit
(
device
.
getDevId
(),
phone
,
"20"
);
}
}
}
}
private
void
deviceOpInit
(
String
devId
,
String
phone
,
String
opType
)
{
// 获取mqtt的topic、payload
MqttxVo
mqttxVo
=
mqttxService
.
openOrCloseDevice
(
devId
,
phone
,
opType
);
// 发送mqtt消息
mqttGatewayComponent
.
sendToMqtt
(
mqttxVo
.
getTopic
(),
0
,
mqttxVo
.
getPayload
());
// 写日志记录
deviceLogService
.
addDeviceLog
(
mqttxVo
);
}
}
share-front/src/main/resources/application-dev.yml
View file @
9d66a9a5
...
...
@@ -9,7 +9,7 @@ ruoyi:
# 实例演示开关
demoEnabled
:
true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
profile
:
/
home/gxpt
/uploadPath
profile
:
/
Users/workspace
/uploadPath
# 获取ip地址开关
addressEnabled
:
false
# 验证码类型 math 数字计算 char 字符验证
...
...
@@ -60,9 +60,9 @@ spring:
druid
:
# 主库数据源
master
:
url
:
jdbc:mysql://12
7.0.0.1:3306/xz
db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
url
:
jdbc:mysql://12
9.211.46.84:3306/share
db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
username
:
root
password
:
1234
password
:
whxz2019
# 从库数据源
slave
:
# 从数据源开关/默认关闭
...
...
@@ -122,7 +122,7 @@ spring:
# 数据库索引
database
:
0
# 密码
password
:
password
:
123456
# 连接超时时间
timeout
:
10s
lettuce
:
...
...
@@ -142,6 +142,7 @@ spring:
password
:
"
Mqtt@2023cj"
defaultTopic
:
"
ydlink/#"
completion-timeout
:
15000
is-subscribe-topic
:
false
# token配置
token
:
...
...
share-front/src/main/resources/application-prod.yml
View file @
9d66a9a5
...
...
@@ -142,6 +142,7 @@ spring:
password
:
"
Mqtt@2023cj"
defaultTopic
:
"
ydlink/#"
completion-timeout
:
15000
is-subscribe-topic
:
false
# token配置
token
:
...
...
share-front/src/main/resources/application-test.yml
View file @
9d66a9a5
...
...
@@ -142,6 +142,7 @@ spring:
password
:
"
Mqtt@2023cj"
defaultTopic
:
"
ydlink/#"
completion-timeout
:
15000
is-subscribe-topic
:
false
# token配置
token
:
...
...
share-system/src/main/java/share/system/domain/vo/DeviceParamVo.java
View file @
9d66a9a5
...
...
@@ -25,4 +25,7 @@ public class DeviceParamVo extends BaseEntity {
/** 操作用户 */
private
String
phone
;
/** 开门房间ID */
private
Long
roomId
;
}
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