Commit 06064c9193f006e535281b7e6f71e5087a52ffd7

Authored by ww
1 parent 36abd69f

fix: data component sensor device send command not lssued by the gateway device

... ... @@ -44,6 +44,7 @@ enum DeviceUrl {
44 44 GET_SLAVE_DEVICE = '/device/list/slave',
45 45 GET_DEVICE_ATTRIBUTE = '/device/attributes',
46 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 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 1 import { RadioRecord } from '../../../views/visual/board/detail/config/util';
  2 +import { DeviceTypeEnum } from '../../device/model/deviceModel';
2 3
3 4 export interface AddDataBoardParams {
4 5 name: string;
... ... @@ -86,6 +87,7 @@ export interface DataSource {
86 87 width?: number;
87 88 height?: number;
88 89 radio?: RadioRecord;
  90 + deviceType?: DeviceTypeEnum;
89 91 }
90 92
91 93 export interface DataComponentRecord {
... ...
1 1 import { DataComponentRecord, DataSource } from '/@/api/dataBoard/model';
  2 +import { DeviceTypeEnum } from '/@/api/device/model/deviceModel';
2 3
3 4 export interface ControlComponentLayout {
4 5 [key: string]: any;
... ... @@ -14,6 +15,8 @@ export interface ControlComponentValue {
14 15 fontColor?: string;
15 16 slaveDeviceId?: string;
16 17 deviceProfileId?: string;
  18 + deviceType?: DeviceTypeEnum;
  19 + organizationId?: string;
17 20 }
18 21
19 22 export const ControlComponentDefaultConfig: ControlComponentValue = {
... ... @@ -34,7 +37,9 @@ export const transformControlConfig = (
34 37 attributeRename: dataSourceRecord.attributeRename,
35 38 deviceProfileId: dataSourceRecord.deviceProfileId,
36 39 deviceId: dataSourceRecord.deviceId,
  40 + deviceType: dataSourceRecord.deviceType,
37 41 slaveDeviceId: dataSourceRecord.slaveDeviceId,
  42 + organizationId: dataSourceRecord.organizationId,
38 43 } as ControlComponentValue,
39 44 };
40 45 };
... ...
1 1 import { ControlComponentValue } from './control.config';
2 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 5 import { getModelServices } from '/@/api/device/modelOfMatter';
5 6 import { useMessage } from '/@/hooks/web/useMessage';
6 7 import { isString } from '/@/utils/is';
... ... @@ -9,7 +10,8 @@ const { createMessage } = useMessage();
9 10 export function useSendCommand() {
10 11 const sendCommand = async (record: ControlComponentValue, value: any) => {
11 12 if (!record) return;
12   - const { deviceId, deviceProfileId, attribute } = record;
  13 + const { deviceProfileId, attribute, deviceType } = record;
  14 + let { deviceId } = record;
13 15 if (!deviceId) return;
14 16 try {
15 17 const list = await getDeviceProfile();
... ... @@ -24,6 +26,12 @@ export function useSendCommand() {
24 26 const sendCommand = record?.functionJson.inputData?.at(0)?.serviceCommand || '';
25 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 35 await sendCommandOneway({
28 36 deviceId,
29 37 value: {
... ...