【代码优化】IoT:去除 Simulation 关键字,定义更清晰

This commit is contained in:
YunaiV 2025-01-31 22:47:11 +08:00
parent d27cb80065
commit 7be9c3e80e
2 changed files with 13 additions and 19 deletions

View File

@ -56,16 +56,16 @@ export enum DeviceStateEnum {
OFFLINE = 2 // 离线 OFFLINE = 2 // 离线
} }
// IoT 模拟设备上行数据 Request VO // IoT 设备上行 Request VO
export interface IotDeviceSimulationUpstreamReqVO { export interface IotDeviceUpstreamReqVO {
id: number // 设备编号 id: number // 设备编号
type: string // 消息类型 type: string // 消息类型
identifier: string // 标识符 identifier: string // 标识符
data: any // 请求参数 data: any // 请求参数
} }
// IoT 模拟设备下行数据 Request VO // IoT 设备下行 Request VO
export interface IotDeviceSimulationDownstreamReqVO { export interface IotDeviceDownstreamReqVO {
id: number // 设备编号 id: number // 设备编号
type: string // 消息类型 type: string // 消息类型
identifier: string // 标识符 identifier: string // 标识符
@ -129,14 +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` })
}, },
// 模拟设备上行 // 设备上行
simulationDeviceUpstream: async (data: IotDeviceSimulationUpstreamReqVO) => { upstreamDevice: async (data: IotDeviceUpstreamReqVO) => {
return await request.post({ url: `/iot/device/simulation-upstream`, data }) return await request.post({ url: `/iot/device/upstream`, data })
}, },
// 模拟设备下行 // 设备下行
simulationDeviceDownstream: async (data: IotDeviceSimulationDownstreamReqVO) => { downstreamDevice: async (data: IotDeviceDownstreamReqVO) => {
return await request.post({ url: `/iot/device/simulation-downstream`, data }) return await request.post({ url: `/iot/device/downstream`, data })
}, },
// 获取设备属性最新数据 // 获取设备属性最新数据

View File

@ -100,13 +100,7 @@
</el-table> </el-table>
<!-- TODO @super发送按钮可以放在右侧哈因为我们的 simulateValue 就在最右侧 --> <!-- TODO @super发送按钮可以放在右侧哈因为我们的 simulateValue 就在最右侧 -->
<div class="mt-10px"> <div class="mt-10px">
<el-button <el-button type="primary" @click="handlePropertyReport"> 发送 </el-button>
type="primary"
@click="handlePropertyReport"
v-hasPermi="['iot:device:simulation']"
>
发送
</el-button>
</div> </div>
</ContentWrap> </ContentWrap>
</el-tab-pane> </el-tab-pane>
@ -331,7 +325,7 @@ const handlePropertyReport = async () => {
}) })
try { try {
await DeviceApi.simulationDeviceUpstream({ await DeviceApi.upstreamDevice({
id: props.device.id, id: props.device.id,
type: 'property', type: 'property',
identifier: 'report', identifier: 'report',
@ -375,7 +369,7 @@ const handlePropertyReport = async () => {
/** 处理设备状态 */ /** 处理设备状态 */
const handleDeviceState = async (state: number) => { const handleDeviceState = async (state: number) => {
try { try {
await DeviceApi.simulationDeviceUpstream({ await DeviceApi.upstreamDevice({
id: props.device.id, id: props.device.id,
type: 'state', type: 'state',
identifier: 'report', identifier: 'report',