Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d27cb800
authored
Jan 30, 2025
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【代码优化】IoT:重构设备 upstream 为 message,包括上行 + 下行
parent
c830c2b9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
8 deletions
+21
-8
src/api/iot/device/device/index.ts
+18
-5
src/views/iot/device/device/detail/DeviceDetailsSimulator.vue
+3
-3
No files found.
src/api/iot/device/device/index.ts
View file @
d27cb800
...
@@ -56,8 +56,16 @@ export enum DeviceStateEnum {
...
@@ -56,8 +56,16 @@ export enum DeviceStateEnum {
OFFLINE
=
2
// 离线
OFFLINE
=
2
// 离线
}
}
// IoT 模拟设备上报数据 Request VO
// IoT 模拟设备上行数据 Request VO
export
interface
IotDeviceSimulationReportReqVO
{
export
interface
IotDeviceSimulationUpstreamReqVO
{
id
:
number
// 设备编号
type
:
string
// 消息类型
identifier
:
string
// 标识符
data
:
any
// 请求参数
}
// IoT 模拟设备下行数据 Request VO
export
interface
IotDeviceSimulationDownstreamReqVO
{
id
:
number
// 设备编号
id
:
number
// 设备编号
type
:
string
// 消息类型
type
:
string
// 消息类型
identifier
:
string
// 标识符
identifier
:
string
// 标识符
...
@@ -121,9 +129,14 @@ export const DeviceApi = {
...
@@ -121,9 +129,14 @@ export const DeviceApi = {
return
await
request
.
download
({
url
:
`/iot/device/get-import-template`
})
return
await
request
.
download
({
url
:
`/iot/device/get-import-template`
})
},
},
// 模拟设备上报
// 模拟设备上行
simulationReportDevice
:
async
(
data
:
IotDeviceSimulationReportReqVO
)
=>
{
simulationDeviceUpstream
:
async
(
data
:
IotDeviceSimulationUpstreamReqVO
)
=>
{
return
await
request
.
post
({
url
:
`/iot/device/simulation-report`
,
data
})
return
await
request
.
post
({
url
:
`/iot/device/simulation-upstream`
,
data
})
},
// 模拟设备下行
simulationDeviceDownstream
:
async
(
data
:
IotDeviceSimulationDownstreamReqVO
)
=>
{
return
await
request
.
post
({
url
:
`/iot/device/simulation-downstream`
,
data
})
},
},
// 获取设备属性最新数据
// 获取设备属性最新数据
...
...
src/views/iot/device/device/detail/DeviceDetailsSimulator.vue
View file @
d27cb800
...
@@ -103,7 +103,7 @@
...
@@ -103,7 +103,7 @@
<
el
-
button
<
el
-
button
type
=
"primary"
type
=
"primary"
@
click
=
"handlePropertyReport"
@
click
=
"handlePropertyReport"
v
-
hasPermi
=
"['iot:device:simulation
-report
']"
v
-
hasPermi
=
"['iot:device:simulation']"
>
>
发送
发送
<
/el-button
>
<
/el-button
>
...
@@ -331,7 +331,7 @@ const handlePropertyReport = async () => {
...
@@ -331,7 +331,7 @@ const handlePropertyReport = async () => {
}
)
}
)
try
{
try
{
await
DeviceApi
.
simulation
ReportDevice
({
await
DeviceApi
.
simulation
DeviceUpstream
({
id
:
props
.
device
.
id
,
id
:
props
.
device
.
id
,
type
:
'property'
,
type
:
'property'
,
identifier
:
'report'
,
identifier
:
'report'
,
...
@@ -375,7 +375,7 @@ const handlePropertyReport = async () => {
...
@@ -375,7 +375,7 @@ const handlePropertyReport = async () => {
/** 处理设备状态 */
/** 处理设备状态 */
const
handleDeviceState
=
async
(
state
:
number
)
=>
{
const
handleDeviceState
=
async
(
state
:
number
)
=>
{
try
{
try
{
await
DeviceApi
.
simulation
ReportDevice
({
await
DeviceApi
.
simulation
DeviceUpstream
({
id
:
props
.
device
.
id
,
id
:
props
.
device
.
id
,
type
:
'state'
,
type
:
'state'
,
identifier
:
'report'
,
identifier
:
'report'
,
...
...
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