【新增】 IOT 设备管理

This commit is contained in:
安浩浩
2024-09-21 09:15:27 +08:00
parent 85c0da5aec
commit b69a784e86
9 changed files with 477 additions and 7 deletions

View File

@ -0,0 +1,63 @@
import request from '@/config/axios'
// IoT 设备 VO
export interface DeviceVO {
id: number // 设备 ID主键自增
deviceKey: string // 设备唯一标识符,全局唯一,用于识别设备
deviceName: string // 设备名称,在产品内唯一,用于标识设备
productId: number // 产品 ID关联 iot_product 表的 id
productKey: string // 产品 Key关联 iot_product 表的 product_key
deviceType: number // 设备类型0 - 直连设备1 - 网关子设备2 - 网关设备
nickname: string // 设备备注名称,供用户自定义备注
gatewayId: number // 网关设备 ID子设备需要关联的网关设备 ID
status: number // 设备状态0 - 未激活1 - 在线2 - 离线3 - 已禁用
statusLastUpdateTime: Date // 设备状态最后更新时间
lastOnlineTime: Date // 最后上线时间
lastOfflineTime: Date // 最后离线时间
activeTime: Date // 设备激活时间
ip: string // 设备的 IP 地址
firmwareVersion: string // 设备的固件版本
deviceSecret: string // 设备密钥,用于设备认证,需安全存储
mqttClientId: string // MQTT 客户端 ID
mqttUsername: string // MQTT 用户名
mqttPassword: string // MQTT 密码
authType: string // 认证类型(如一机一密、动态注册)
latitude: number // 设备位置的纬度,范围 -90.000000 ~ 90.000000
longitude: number // 设备位置的经度,范围 -180.000000 ~ 180.000000
areaId: number // 地区编码,符合国家地区编码标准,关联地区表
address: string // 设备详细地址
serialNumber: string // 设备序列号
}
// IoT 设备 API
export const DeviceApi = {
// 查询IoT 设备分页
getDevicePage: async (params: any) => {
return await request.get({ url: `/iot/device/page`, params })
},
// 查询IoT 设备详情
getDevice: async (id: number) => {
return await request.get({ url: `/iot/device/get?id=` + id })
},
// 新增IoT 设备
createDevice: async (data: DeviceVO) => {
return await request.post({ url: `/iot/device/create`, data })
},
// 修改IoT 设备
updateDevice: async (data: DeviceVO) => {
return await request.put({ url: `/iot/device/update`, data })
},
// 删除IoT 设备
deleteDevice: async (id: number) => {
return await request.delete({ url: `/iot/device/delete?id=` + id })
},
// 导出IoT 设备 Excel
exportDevice: async (params) => {
return await request.download({ url: `/iot/device/export-excel`, params })
}
}

View File

@ -51,5 +51,10 @@ export const ProductApi = {
// 更新产品状态
updateProductStatus: async (id: number, status: number) => {
return await request.put({ url: `/iot/product/update-status?id=` + id + `&status=` + status })
},
// 查询产品(精简)列表
getSimpleProductList() {
return request.get({ url: '/iot/product/list-all-simple' })
}
}