Commit 75ede56f567f403970a73ff37aced3ed01475563

Authored by ww
1 parent 24dd3e99

fix: 修复双向命令下发时判断设备在线取值错误

1   -import type { DeviceAttributeItemType, DeviceItemType, DeviceProfileItemType, OrganizationItemType, RpcCommandType, SendValue, ThingsModel, ThingsModelItemType } from './model'
  1 +import type { DeviceActiveType, DeviceAttributeItemType, DeviceItemType, DeviceProfileItemType, OrganizationItemType, RpcCommandType, SendValue, ThingsModel, ThingsModelItemType } from './model'
2 2 import { CommandWayEnum } from '@/enums/commandEnum'
3 3 import type { DeviceTypeEnum } from '@/enums/datasource'
4 4 import { isShareMode } from '@/utils/env'
... ... @@ -113,7 +113,7 @@ export const genModbusCommand = (data: GenModbusCommandType) => {
113 113
114 114 // 获取设备状态,在线 or 离线时间 entityId:设备id
115 115 export const getDeviceActiveTime = (entityId: string) => {
116   - return defHttp.get(
  116 + return defHttp.get<DeviceActiveType[]>(
117 117 {
118 118 url: `/plugins/telemetry/DEVICE/${entityId}/values/attributes?keys=active`,
119 119 },
... ...
... ... @@ -183,3 +183,9 @@ export interface DeviceAttributeItemType {
183 183 value: boolean
184 184 lastUpdateTs: number
185 185 }
  186 +
  187 +export interface DeviceActiveType {
  188 + key: string
  189 + lastUpdateTs: number
  190 + value: boolean
  191 +}
... ...
... ... @@ -192,7 +192,7 @@ const handleSubmit = async () => {
192 192 }
193 193 if (serviceInfo.callType === 'SYNC') { // 服务命令调用方式 是同步 需要调用设备是否在线才能下发
194 194 const res = await getDeviceActiveTime(dataSourceJson.value.deviceId)
195   - const { value } = res
  195 + const { value } = res?.[0] || {}
196 196 if (!value) {
197 197 createMessage.error('当前设备不在线')
198 198 return
... ...