Commit 91becfd4da85d8cc2fe98299fb65ef8255e8661d

Authored by ww
1 parent 41cb7dbe

perf: device list search devcie attributes usage properites in model of matter

... ... @@ -21,7 +21,7 @@ VITE_PROXY = [["/api","http://222.180.200.114:48080/api"],["/thingskit-drawio","
21 21 # 实时数据的ws地址
22 22 # VITE_WEB_SOCKET = ws://localhost:8080/api/ws/plugins/telemetry?token=
23 23 # VITE_WEB_SOCKET = ws://44.99.141.212:8080/api/ws/plugins/telemetry?token=
24   -VITE_WEB_SOCKET = ws://dev.thingskit.com/api/ws/plugins/telemetry?token=
  24 +VITE_WEB_SOCKET = ws://222.180.200.114:48080/api/ws/plugins/telemetry?token=
25 25 # VITE_WEB_SOCKET = ws://121.37.251.8:8080/api/ws/plugins/telemetry?token=
26 26
27 27 # Delete console
... ...
1 1 import { defHttp } from '/@/utils/http/axios';
2 2 import {
3 3 DeviceModel,
  4 + DeviceModelOfMatterAttrs,
4 5 DeviceProfileModel,
5 6 DeviceProfileQueryParam,
6 7 DeviceQueryParam,
... ... @@ -24,6 +25,8 @@ enum DeviceManagerApi {
24 25
25 26 DEVICE_CREDENTIALS = '/device/credentials',
26 27 COMMAND_ISSUANCE = '/rpc',
  28 +
  29 + DEVICE_ATTR = '/device/attributes',
27 30 }
28 31
29 32 export const devicePage = (params: DeviceQueryParam) => {
... ... @@ -224,3 +227,9 @@ export const commandIssuanceApi = (type, tbDeviceId, data) => {
224 227 }
225 228 );
226 229 };
  230 +
  231 +export const getDeviceAttrs = (profileId: string, id: string) => {
  232 + return defHttp.get<DeviceModelOfMatterAttrs[]>({
  233 + url: `${DeviceManagerApi.DEVICE_ATTR}/${profileId}/${id}`,
  234 + });
  235 +};
... ...
  1 +import { DataType } from './modelOfMatterModel';
1 2 import { BasicPageParams } from '/@/api/model/baseModel';
2 3 import { AlarmStatus } from '/@/views/alarm/log/config/detail.config';
3 4 export enum DeviceState {
... ... @@ -85,3 +86,9 @@ export interface DeviceRecord {
85 86 type: string;
86 87 default: boolean;
87 88 }
  89 +
  90 +export interface DeviceModelOfMatterAttrs {
  91 + name: string;
  92 + identifier: string;
  93 + detail: DataType;
  94 +}
... ...
1 1 <script lang="ts" setup>
2   - import { nextTick, reactive, ref, unref } from 'vue';
  2 + import { nextTick, onUnmounted, reactive, ref, unref } from 'vue';
3 3 import { List, Button, Tooltip, Card } from 'ant-design-vue';
4 4 import { PageWrapper } from '/@/components/Page';
5 5 import { AppstoreOutlined, BarsOutlined } from '@ant-design/icons-vue';
... ... @@ -13,6 +13,9 @@
13 13 import { BasicForm, useForm } from '/@/components/Form';
14 14 import HistoryData from './HistoryData.vue';
15 15 import { BasicModal, useModal } from '/@/components/Modal';
  16 + import { getDeviceAttrs } from '/@/api/device/deviceManager';
  17 + import { DeviceModelOfMatterAttrs } from '/@/api/device/model/deviceModel';
  18 + import { computed } from '@vue/reactivity';
16 19
17 20 interface ReceiveMessage {
18 21 data: {
... ... @@ -27,7 +30,7 @@
27 30 }
28 31
29 32 const props = defineProps<{
30   - deviceDetail: Record<'tbDeviceId', string>;
  33 + deviceDetail: Record<'tbDeviceId' | 'profileId' | 'id', string>;
31 34 }>();
32 35
33 36 const grid = {
... ... @@ -43,16 +46,21 @@
43 46 originData: [] as DataSource[],
44 47 dataSource: [] as DataSource[],
45 48 message: {} as ReceiveMessage['data'],
46   - sendValue: {
  49 + attrKeys: [] as DeviceModelOfMatterAttrs[],
  50 + });
  51 +
  52 + const getSendValue = computed(() => {
  53 + return {
47 54 tsSubCmds: [
48 55 {
49 56 entityType: 'DEVICE',
50   - entityId: props.deviceDetail!.tbDeviceId || 'd2526c70-60a9-11ed-ba9c-6b98bfcc8255',
  57 + entityId: props.deviceDetail!.tbDeviceId,
51 58 scope: 'LATEST_TELEMETRY',
52 59 cmdId: 1,
  60 + keys: socketInfo.attrKeys.map((item) => item.identifier).join(','),
53 61 },
54 62 ],
55   - },
  63 + };
56 64 });
57 65
58 66 const [registerForm, { getFieldsValue }] = useForm({
... ... @@ -115,8 +123,12 @@
115 123 const { createMessage } = useMessage();
116 124
117 125 const { send, close, data } = useWebSocket(socketInfo.origin, {
118   - onConnected() {
119   - send(JSON.stringify(socketInfo.sendValue));
  126 + async onConnected() {
  127 + const { id, profileId } = props.deviceDetail;
  128 + const value = await getDeviceAttrs(profileId, id);
  129 + console.log(value);
  130 + socketInfo.attrKeys = value;
  131 + send(JSON.stringify(unref(getSendValue)));
120 132 },
121 133 async onMessage() {
122 134 try {
... ... @@ -154,6 +166,8 @@
154 166 socketInfo.attr = key;
155 167 openModal(true);
156 168 };
  169 +
  170 + onUnmounted(() => close());
157 171 </script>
158 172
159 173 <template>
... ... @@ -203,9 +217,9 @@
203 217 <template #extra>
204 218 <Button type="link" class="!p-0" @click="handleShowDetail(item)">历史数据</Button>
205 219 </template>
206   - <section>
  220 + <section class="min-h-16 flex flex-col justify-between">
207 221 <div class="flex font-bold text-lg mb-4">
208   - <div>{{ item.value }}</div>
  222 + <div>{{ item.value || '暂无数据' }}</div>
209 223 </div>
210 224 <div class="text-dark-800 text-xs">{{ formatToDateTime(item.time) }}</div>
211 225 </section>
... ...