Commit 06064c9193f006e535281b7e6f71e5087a52ffd7
1 parent
36abd69f
fix: data component sensor device send command not lssued by the gateway device
Showing
4 changed files
with
25 additions
and
2 deletions
@@ -44,6 +44,7 @@ enum DeviceUrl { | @@ -44,6 +44,7 @@ enum DeviceUrl { | ||
44 | GET_SLAVE_DEVICE = '/device/list/slave', | 44 | GET_SLAVE_DEVICE = '/device/list/slave', |
45 | GET_DEVICE_ATTRIBUTE = '/device/attributes', | 45 | GET_DEVICE_ATTRIBUTE = '/device/attributes', |
46 | GET_DEVICE = '/device/list', | 46 | GET_DEVICE = '/device/list', |
47 | + GET_DEVICE_RELATION = '/device/device/relation', | ||
47 | } | 48 | } |
48 | 49 | ||
49 | /** | 50 | /** |
@@ -224,3 +225,10 @@ export const sendCommandOneway = (params: SendCommandParams) => { | @@ -224,3 +225,10 @@ export const sendCommandOneway = (params: SendCommandParams) => { | ||
224 | { joinPrefix: false } | 225 | { joinPrefix: false } |
225 | ); | 226 | ); |
226 | }; | 227 | }; |
228 | + | ||
229 | +export const getDeviceRelation = (params: { deviceId: string; isSlave: boolean }) => { | ||
230 | + return defHttp.get<string>({ | ||
231 | + url: DeviceUrl.GET_DEVICE_RELATION, | ||
232 | + params, | ||
233 | + }); | ||
234 | +}; |
1 | import { RadioRecord } from '../../../views/visual/board/detail/config/util'; | 1 | import { RadioRecord } from '../../../views/visual/board/detail/config/util'; |
2 | +import { DeviceTypeEnum } from '../../device/model/deviceModel'; | ||
2 | 3 | ||
3 | export interface AddDataBoardParams { | 4 | export interface AddDataBoardParams { |
4 | name: string; | 5 | name: string; |
@@ -86,6 +87,7 @@ export interface DataSource { | @@ -86,6 +87,7 @@ export interface DataSource { | ||
86 | width?: number; | 87 | width?: number; |
87 | height?: number; | 88 | height?: number; |
88 | radio?: RadioRecord; | 89 | radio?: RadioRecord; |
90 | + deviceType?: DeviceTypeEnum; | ||
89 | } | 91 | } |
90 | 92 | ||
91 | export interface DataComponentRecord { | 93 | export interface DataComponentRecord { |
1 | import { DataComponentRecord, DataSource } from '/@/api/dataBoard/model'; | 1 | import { DataComponentRecord, DataSource } from '/@/api/dataBoard/model'; |
2 | +import { DeviceTypeEnum } from '/@/api/device/model/deviceModel'; | ||
2 | 3 | ||
3 | export interface ControlComponentLayout { | 4 | export interface ControlComponentLayout { |
4 | [key: string]: any; | 5 | [key: string]: any; |
@@ -14,6 +15,8 @@ export interface ControlComponentValue { | @@ -14,6 +15,8 @@ export interface ControlComponentValue { | ||
14 | fontColor?: string; | 15 | fontColor?: string; |
15 | slaveDeviceId?: string; | 16 | slaveDeviceId?: string; |
16 | deviceProfileId?: string; | 17 | deviceProfileId?: string; |
18 | + deviceType?: DeviceTypeEnum; | ||
19 | + organizationId?: string; | ||
17 | } | 20 | } |
18 | 21 | ||
19 | export const ControlComponentDefaultConfig: ControlComponentValue = { | 22 | export const ControlComponentDefaultConfig: ControlComponentValue = { |
@@ -34,7 +37,9 @@ export const transformControlConfig = ( | @@ -34,7 +37,9 @@ export const transformControlConfig = ( | ||
34 | attributeRename: dataSourceRecord.attributeRename, | 37 | attributeRename: dataSourceRecord.attributeRename, |
35 | deviceProfileId: dataSourceRecord.deviceProfileId, | 38 | deviceProfileId: dataSourceRecord.deviceProfileId, |
36 | deviceId: dataSourceRecord.deviceId, | 39 | deviceId: dataSourceRecord.deviceId, |
40 | + deviceType: dataSourceRecord.deviceType, | ||
37 | slaveDeviceId: dataSourceRecord.slaveDeviceId, | 41 | slaveDeviceId: dataSourceRecord.slaveDeviceId, |
42 | + organizationId: dataSourceRecord.organizationId, | ||
38 | } as ControlComponentValue, | 43 | } as ControlComponentValue, |
39 | }; | 44 | }; |
40 | }; | 45 | }; |
1 | import { ControlComponentValue } from './control.config'; | 1 | import { ControlComponentValue } from './control.config'; |
2 | import { getDeviceProfile } from '/@/api/alarm/position'; | 2 | import { getDeviceProfile } from '/@/api/alarm/position'; |
3 | -import { sendCommandOneway } from '/@/api/dataBoard'; | 3 | +import { getDeviceRelation, sendCommandOneway } from '/@/api/dataBoard'; |
4 | +import { DeviceTypeEnum } from '/@/api/device/model/deviceModel'; | ||
4 | import { getModelServices } from '/@/api/device/modelOfMatter'; | 5 | import { getModelServices } from '/@/api/device/modelOfMatter'; |
5 | import { useMessage } from '/@/hooks/web/useMessage'; | 6 | import { useMessage } from '/@/hooks/web/useMessage'; |
6 | import { isString } from '/@/utils/is'; | 7 | import { isString } from '/@/utils/is'; |
@@ -9,7 +10,8 @@ const { createMessage } = useMessage(); | @@ -9,7 +10,8 @@ const { createMessage } = useMessage(); | ||
9 | export function useSendCommand() { | 10 | export function useSendCommand() { |
10 | const sendCommand = async (record: ControlComponentValue, value: any) => { | 11 | const sendCommand = async (record: ControlComponentValue, value: any) => { |
11 | if (!record) return; | 12 | if (!record) return; |
12 | - const { deviceId, deviceProfileId, attribute } = record; | 13 | + const { deviceProfileId, attribute, deviceType } = record; |
14 | + let { deviceId } = record; | ||
13 | if (!deviceId) return; | 15 | if (!deviceId) return; |
14 | try { | 16 | try { |
15 | const list = await getDeviceProfile(); | 17 | const list = await getDeviceProfile(); |
@@ -24,6 +26,12 @@ export function useSendCommand() { | @@ -24,6 +26,12 @@ export function useSendCommand() { | ||
24 | const sendCommand = record?.functionJson.inputData?.at(0)?.serviceCommand || ''; | 26 | const sendCommand = record?.functionJson.inputData?.at(0)?.serviceCommand || ''; |
25 | params = isString(sendCommand) ? sendCommand : JSON.stringify(sendCommand); | 27 | params = isString(sendCommand) ? sendCommand : JSON.stringify(sendCommand); |
26 | } | 28 | } |
29 | + if (deviceType === DeviceTypeEnum.SENSOR) { | ||
30 | + deviceId = await getDeviceRelation({ | ||
31 | + deviceId, | ||
32 | + isSlave: deviceType === DeviceTypeEnum.SENSOR, | ||
33 | + }); | ||
34 | + } | ||
27 | await sendCommandOneway({ | 35 | await sendCommandOneway({ |
28 | deviceId, | 36 | deviceId, |
29 | value: { | 37 | value: { |