|
|
@@ -1,4 +1,8 @@
|
|
|
-import { addDevice, addSubDevice, delDevice, delDeviceMul, delDeviceTag, getDeviceById, getDeviceCount, getDeviceList, getDeviceTag, getSubDeviceList, updateDeviceLabel } from '@/api/iot/device'
|
|
|
+import {
|
|
|
+ addDevice, addSubDevice, delDevice, delDeviceMul, delDeviceTag,
|
|
|
+ getDeviceById, getDeviceCount, getDeviceList, getDeviceMsgList, addDeviceMsg, getDeviceTag, getSubDeviceList, updateDeviceLabel
|
|
|
+} from '@/api/iot/device'
|
|
|
+import { DeviceMsgEnum } from '@/enum/common'
|
|
|
import { message } from 'ant-design-vue'
|
|
|
|
|
|
export class DeviceContriller {
|
|
|
@@ -24,6 +28,14 @@ export class DeviceContriller {
|
|
|
['DISABLED', { color: 'grey', name: '禁止连接', key: 'DISABLED' }]
|
|
|
])
|
|
|
|
|
|
+ static deviceMag = new Map([
|
|
|
+ [DeviceMsgEnum.QUEUED, { name: '队列中', key: DeviceMsgEnum.QUEUED }],
|
|
|
+ [DeviceMsgEnum.SENT, { name: '已发送', key: DeviceMsgEnum.SENT }],
|
|
|
+ [DeviceMsgEnum.DELIVERED, { name: '设备收到', key: DeviceMsgEnum.DELIVERED }],
|
|
|
+ [DeviceMsgEnum.TIMEOUT, { name: '超时', key: DeviceMsgEnum.TIMEOUT }],
|
|
|
+ [DeviceMsgEnum.FAILED, { name: '失败', key: DeviceMsgEnum.FAILED }]
|
|
|
+ ])
|
|
|
+
|
|
|
static async page (params: IOT.API.DEVICE.QueryPamars) {
|
|
|
const { data: _data, sum } = await getDeviceList(params)
|
|
|
const data = _data.map(item => {
|
|
|
@@ -57,10 +69,12 @@ export class DeviceContriller {
|
|
|
return data
|
|
|
}
|
|
|
|
|
|
+ /** 分页获取子设备列表 */
|
|
|
static async pageSub (id: string, params: IOT.API.DEVICE.QueryPamars) {
|
|
|
return await getSubDeviceList(id, params)
|
|
|
}
|
|
|
|
|
|
+ /** 新增子设备 */
|
|
|
static async postSub (data: IOT.API.DEVICE.SubBodyParams) {
|
|
|
await addSubDevice(data)
|
|
|
message.success('新增成功')
|
|
|
@@ -79,6 +93,7 @@ export class DeviceContriller {
|
|
|
await updateDeviceLabel(data)
|
|
|
}
|
|
|
|
|
|
+ /** 设备统计 */
|
|
|
static async statistics (params: {modelId: string}) {
|
|
|
const { data } = await getDeviceCount(params)
|
|
|
|
|
|
@@ -91,4 +106,15 @@ export class DeviceContriller {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ /** 消息下发 获取列表 */
|
|
|
+ static async listDeviceMsg (params: {deviceId: string}) {
|
|
|
+ const { data } = await getDeviceMsgList(params)
|
|
|
+ return data
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 消息下发 下发消息 */
|
|
|
+ static async addDeviceMsg (data: {deviceId: string, msgPayload: string, msgLabel: string, topic: string}) {
|
|
|
+ return await addDeviceMsg(data)
|
|
|
+ }
|
|
|
}
|