Skip to content

Commit d27cb80

Browse files
committed
【代码优化】IoT:重构设备 upstream 为 message,包括上行 + 下行
1 parent c830c2b commit d27cb80

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/api/iot/device/device/index.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,16 @@ export enum DeviceStateEnum {
5656
OFFLINE = 2 // 离线
5757
}
5858

59-
// IoT 模拟设备上报数据 Request VO
60-
export interface IotDeviceSimulationReportReqVO {
59+
// IoT 模拟设备上行数据 Request VO
60+
export interface IotDeviceSimulationUpstreamReqVO {
61+
id: number // 设备编号
62+
type: string // 消息类型
63+
identifier: string // 标识符
64+
data: any // 请求参数
65+
}
66+
67+
// IoT 模拟设备下行数据 Request VO
68+
export interface IotDeviceSimulationDownstreamReqVO {
6169
id: number // 设备编号
6270
type: string // 消息类型
6371
identifier: string // 标识符
@@ -121,9 +129,14 @@ export const DeviceApi = {
121129
return await request.download({ url: `/iot/device/get-import-template` })
122130
},
123131

124-
// 模拟设备上报
125-
simulationReportDevice: async (data: IotDeviceSimulationReportReqVO) => {
126-
return await request.post({ url: `/iot/device/simulation-report`, data })
132+
// 模拟设备上行
133+
simulationDeviceUpstream: async (data: IotDeviceSimulationUpstreamReqVO) => {
134+
return await request.post({ url: `/iot/device/simulation-upstream`, data })
135+
},
136+
137+
// 模拟设备下行
138+
simulationDeviceDownstream: async (data: IotDeviceSimulationDownstreamReqVO) => {
139+
return await request.post({ url: `/iot/device/simulation-downstream`, data })
127140
},
128141

129142
// 获取设备属性最新数据

src/views/iot/device/device/detail/DeviceDetailsSimulator.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<el-button
104104
type="primary"
105105
@click="handlePropertyReport"
106-
v-hasPermi="['iot:device:simulation-report']"
106+
v-hasPermi="['iot:device:simulation']"
107107
>
108108
发送
109109
</el-button>
@@ -331,7 +331,7 @@ const handlePropertyReport = async () => {
331331
})
332332
333333
try {
334-
await DeviceApi.simulationReportDevice({
334+
await DeviceApi.simulationDeviceUpstream({
335335
id: props.device.id,
336336
type: 'property',
337337
identifier: 'report',
@@ -375,7 +375,7 @@ const handlePropertyReport = async () => {
375375
/** 处理设备状态 */
376376
const handleDeviceState = async (state: number) => {
377377
try {
378-
await DeviceApi.simulationReportDevice({
378+
await DeviceApi.simulationDeviceUpstream({
379379
id: props.device.id,
380380
type: 'state',
381381
identifier: 'report',

0 commit comments

Comments
 (0)