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