Commit 038da2bb6cb3d1c4d866a0a4a7fc1dc7cd01206f
Merge branch 'main_dev' into 'main'
fix: 修复双向命令下发时判断设备在线取值错误 See merge request yunteng/thingskit-scada!170
Showing
3 changed files
with
9 additions
and
3 deletions
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 | import { CommandWayEnum } from '@/enums/commandEnum' | 2 | import { CommandWayEnum } from '@/enums/commandEnum' |
3 | import type { DeviceTypeEnum } from '@/enums/datasource' | 3 | import type { DeviceTypeEnum } from '@/enums/datasource' |
4 | import { isShareMode } from '@/utils/env' | 4 | import { isShareMode } from '@/utils/env' |
@@ -113,7 +113,7 @@ export const genModbusCommand = (data: GenModbusCommandType) => { | @@ -113,7 +113,7 @@ export const genModbusCommand = (data: GenModbusCommandType) => { | ||
113 | 113 | ||
114 | // 获取设备状态,在线 or 离线时间 entityId:设备id | 114 | // 获取设备状态,在线 or 离线时间 entityId:设备id |
115 | export const getDeviceActiveTime = (entityId: string) => { | 115 | export const getDeviceActiveTime = (entityId: string) => { |
116 | - return defHttp.get( | 116 | + return defHttp.get<DeviceActiveType[]>( |
117 | { | 117 | { |
118 | url: `/plugins/telemetry/DEVICE/${entityId}/values/attributes?keys=active`, | 118 | url: `/plugins/telemetry/DEVICE/${entityId}/values/attributes?keys=active`, |
119 | }, | 119 | }, |
@@ -183,3 +183,9 @@ export interface DeviceAttributeItemType { | @@ -183,3 +183,9 @@ export interface DeviceAttributeItemType { | ||
183 | value: boolean | 183 | value: boolean |
184 | lastUpdateTs: number | 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,7 +192,7 @@ const handleSubmit = async () => { | ||
192 | } | 192 | } |
193 | if (serviceInfo.callType === 'SYNC') { // 服务命令调用方式 是同步 需要调用设备是否在线才能下发 | 193 | if (serviceInfo.callType === 'SYNC') { // 服务命令调用方式 是同步 需要调用设备是否在线才能下发 |
194 | const res = await getDeviceActiveTime(dataSourceJson.value.deviceId) | 194 | const res = await getDeviceActiveTime(dataSourceJson.value.deviceId) |
195 | - const { value } = res | 195 | + const { value } = res?.[0] || {} |
196 | if (!value) { | 196 | if (!value) { |
197 | createMessage.error('当前设备不在线') | 197 | createMessage.error('当前设备不在线') |
198 | return | 198 | return |