From 18eabfb04267be896fa05aa3a33ec14c8a3b3281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=B5=A9=E6=B5=A9?= <1036606149@qq.com> Date: Thu, 10 Oct 2024 21:02:55 +0800 Subject: [PATCH 001/120] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E3=80=91IOT=EF=BC=9A=E6=9E=9A=E4=B8=BE=E5=92=8C?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=E5=88=B0=E5=89=AA=E8=B4=B4=E6=9D=BF=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/iot/product/index.ts | 6 ++++++ src/api/iot/thinkmodelfunction/index.ts | 13 ++++++++++++ .../iot/device/detail/DeviceDetailsHeader.vue | 16 +++++++------- .../iot/device/detail/DeviceDetailsInfo.vue | 9 +++++--- src/views/iot/product/ProductForm.vue | 16 +++++++++----- .../product/detail/ProductDetailsHeader.vue | 11 ++++++---- .../product/detail/ThinkModelFunctionForm.vue | 21 ++++++++++++------- 7 files changed, 63 insertions(+), 29 deletions(-) diff --git a/src/api/iot/product/index.ts b/src/api/iot/product/index.ts index 1ffa490d5..19c827cfb 100644 --- a/src/api/iot/product/index.ts +++ b/src/api/iot/product/index.ts @@ -18,6 +18,12 @@ export interface ProductVO { createTime: Date // 创建时间 } +// IOT 数据校验级别枚举类 +export enum ValidateTypeEnum { + WEAK = 0, // 弱校验 + NONE = 1 // 免校验 +} + // IoT 产品 API export const ProductApi = { // 查询产品分页 diff --git a/src/api/iot/thinkmodelfunction/index.ts b/src/api/iot/thinkmodelfunction/index.ts index bd2e2d0f0..1fce81376 100644 --- a/src/api/iot/thinkmodelfunction/index.ts +++ b/src/api/iot/thinkmodelfunction/index.ts @@ -14,6 +14,19 @@ export interface ThinkModelFunctionVO { service: string // 服务 } +// IOT 产品功能(物模型)类型枚举类 +export enum ProductFunctionTypeEnum { + PROPERTY = 1, // 属性 + SERVICE = 2, // 服务 + EVENT = 3 // 事件 +} + +// IOT 产品功能(物模型)访问模式枚举类 +export enum ProductFunctionAccessModeEnum { + READ_WRITE = 'rw', // 读写 + READ_ONLY = 'r' // 只读 +} + // IoT 产品物模型 API export const ThinkModelFunctionApi = { // 查询产品物模型分页 diff --git a/src/views/iot/device/detail/DeviceDetailsHeader.vue b/src/views/iot/device/detail/DeviceDetailsHeader.vue index 62960529d..f051bd874 100644 --- a/src/views/iot/device/detail/DeviceDetailsHeader.vue +++ b/src/views/iot/device/detail/DeviceDetailsHeader.vue @@ -53,16 +53,14 @@ const openForm = (type: string, id?: number) => { const { product, device } = defineProps<{ product: ProductVO; device: DeviceVO }>() const emit = defineEmits(['refresh']) -/** - * 将文本复制到剪贴板 - * - * @param text 需要复制的文本 - */ -const copyToClipboard = (text: string) => { - // TODO @haohao:可以考虑用 await 异步转同步哈 - navigator.clipboard.writeText(text).then(() => { +/** 复制到剪贴板方法 */ +const copyToClipboard = async (text: string) => { + try { + await navigator.clipboard.writeText(text) message.success('复制成功') - }) + } catch (error) { + message.error('复制失败') + } } /** diff --git a/src/views/iot/device/detail/DeviceDetailsInfo.vue b/src/views/iot/device/detail/DeviceDetailsInfo.vue index 59b9d2542..968fc8d5a 100644 --- a/src/views/iot/device/detail/DeviceDetailsInfo.vue +++ b/src/views/iot/device/detail/DeviceDetailsInfo.vue @@ -100,10 +100,13 @@ const mqttParams = ref({ }) // 定义 MQTT 参数对象 /** 复制到剪贴板方法 */ -const copyToClipboard = (text: string) => { - navigator.clipboard.writeText(text).then(() => { +const copyToClipboard = async (text: string) => { + try { + await navigator.clipboard.writeText(text) message.success('复制成功') - }) + } catch (error) { + message.error('复制失败') + } } /** 打开 MQTT 参数弹框的方法 */ diff --git a/src/views/iot/product/ProductForm.vue b/src/views/iot/product/ProductForm.vue index 75d6efcc0..ed522e8de 100644 --- a/src/views/iot/product/ProductForm.vue +++ b/src/views/iot/product/ProductForm.vue @@ -100,7 +100,7 @@ + \ No newline at end of file From 9ea45b3d1421a5cbaf7fdee7b33c7d37a5624fbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=B5=A9=E6=B5=A9?= <1036606149@qq.com> Date: Sun, 3 Nov 2024 00:15:44 +0800 Subject: [PATCH 003/120] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E3=80=91IOT=EF=BC=9A=E8=AE=BE=E5=A4=87=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/iot/device/index.ts | 18 +++ src/api/iot/product/index.ts | 8 +- .../iot/device/detail/DeviceDataDetail.vue | 28 ++++ .../iot/device/detail/DeviceDetailsModel.vue | 132 ++++++++++++++++++ src/views/iot/device/detail/index.vue | 10 +- src/views/iot/product/ProductForm.vue | 2 - .../iot/product/detail/ThinkModelFunction.vue | 2 + .../product/detail/ThinkModelFunctionForm.vue | 6 +- 8 files changed, 198 insertions(+), 8 deletions(-) create mode 100644 src/views/iot/device/detail/DeviceDataDetail.vue create mode 100644 src/views/iot/device/detail/DeviceDetailsModel.vue diff --git a/src/api/iot/device/index.ts b/src/api/iot/device/index.ts index 903874b75..9bc82c4fd 100644 --- a/src/api/iot/device/index.ts +++ b/src/api/iot/device/index.ts @@ -35,6 +35,19 @@ export interface DeviceUpdateStatusVO { status: number // 设备状态 } +// IoT 设备数据 VO +export interface DeviceDataVO { + deviceId: number // 设备编号 + thinkModelFunctionId: number // 物模型编号 + productKey: string // 产品标识 + deviceName: string // 设备名称 + identifier: string // 属性标识符 + name: string // 属性名称 + dataType: string // 数据类型 + updateTime: Date // 更新时间 + value: string // 最新值 +} + // 设备 API export const DeviceApi = { // 查询设备分页 @@ -70,5 +83,10 @@ export const DeviceApi = { // 获取设备数量 getDeviceCount: async (productId: number) => { return await request.get({ url: `/iot/device/count?productId=` + productId }) + }, + + // 获取设备属性最新数据 + getDevicePropertiesLatestData: async (params: any) => { + return await request.get({ url: `/iot/device/data/latest-data`, params }) } } diff --git a/src/api/iot/product/index.ts b/src/api/iot/product/index.ts index 19c827cfb..047dc716e 100644 --- a/src/api/iot/product/index.ts +++ b/src/api/iot/product/index.ts @@ -23,6 +23,12 @@ export enum ValidateTypeEnum { WEAK = 0, // 弱校验 NONE = 1 // 免校验 } +// IOT 产品设备类型枚举类 0: 直连设备, 1: 网关子设备, 2: 网关设备 +export enum DeviceTypeEnum { + DEVICE = 0, // 直连设备 + GATEWAY_SUB = 1, // 网关子设备 + GATEWAY = 2 // 网关设备 +} // IoT 产品 API export const ProductApi = { @@ -63,6 +69,6 @@ export const ProductApi = { // 查询产品(精简)列表 getSimpleProductList() { - return request.get({ url: '/iot/product/list-all-simple' }) + return request.get({ url: '/iot/product/simple-list' }) } } diff --git a/src/views/iot/device/detail/DeviceDataDetail.vue b/src/views/iot/device/detail/DeviceDataDetail.vue new file mode 100644 index 000000000..b4df6484c --- /dev/null +++ b/src/views/iot/device/detail/DeviceDataDetail.vue @@ -0,0 +1,28 @@ + + diff --git a/src/views/iot/device/detail/DeviceDetailsModel.vue b/src/views/iot/device/detail/DeviceDetailsModel.vue new file mode 100644 index 000000000..40c1a89a2 --- /dev/null +++ b/src/views/iot/device/detail/DeviceDetailsModel.vue @@ -0,0 +1,132 @@ + + diff --git a/src/views/iot/device/detail/index.vue b/src/views/iot/device/detail/index.vue index 2db16bbcb..be6eec79d 100644 --- a/src/views/iot/device/detail/index.vue +++ b/src/views/iot/device/detail/index.vue @@ -11,17 +11,21 @@ - - + + + + + \ No newline at end of file + From 5243f5849f06d5aaead38de3c5917926d68a93dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=B5=A9=E6=B5=A9?= <1036606149@qq.com> Date: Tue, 5 Nov 2024 23:25:47 +0800 Subject: [PATCH 004/120] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E3=80=91IOT=EF=BC=9A=E8=AE=BE=E5=A4=87=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E6=95=B0=E6=8D=AE=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/iot/device/index.ts | 11 ++ .../iot/device/detail/DeviceDataDetail.vue | 107 ++++++++++++++++-- 2 files changed, 109 insertions(+), 9 deletions(-) diff --git a/src/api/iot/device/index.ts b/src/api/iot/device/index.ts index 9bc82c4fd..5f788ec99 100644 --- a/src/api/iot/device/index.ts +++ b/src/api/iot/device/index.ts @@ -48,6 +48,12 @@ export interface DeviceDataVO { value: string // 最新值 } +// IoT 设备数据 VO +export interface DeviceHistoryDataVO { + time: number // 时间 + data: string // 数据 +} + // 设备 API export const DeviceApi = { // 查询设备分页 @@ -88,5 +94,10 @@ export const DeviceApi = { // 获取设备属性最新数据 getDevicePropertiesLatestData: async (params: any) => { return await request.get({ url: `/iot/device/data/latest-data`, params }) + }, + + // 获取设备属性历史数据 + getDevicePropertiesHistoryData: async (params: any) => { + return await request.get({ url: `/iot/device/data/history-data`, params }) } } diff --git a/src/views/iot/device/detail/DeviceDataDetail.vue b/src/views/iot/device/detail/DeviceDataDetail.vue index b4df6484c..b4a25800c 100644 --- a/src/views/iot/device/detail/DeviceDataDetail.vue +++ b/src/views/iot/device/detail/DeviceDataDetail.vue @@ -1,28 +1,117 @@ From d256d70d92faaa8a21739febba57da7656d8b38c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=B5=A9=E6=B5=A9?= <1036606149@qq.com> Date: Sun, 10 Nov 2024 20:23:32 +0800 Subject: [PATCH 005/120] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E3=80=91IOT=EF=BC=9A=E8=AE=BE=E5=A4=87=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E6=95=B0=E6=8D=AE=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/iot/device/index.ts | 4 ++-- src/views/iot/device/detail/DeviceDetailsModel.vue | 9 +++++---- src/views/iot/device/detail/index.vue | 14 ++++++-------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/api/iot/device/index.ts b/src/api/iot/device/index.ts index 5f788ec99..4f61d56df 100644 --- a/src/api/iot/device/index.ts +++ b/src/api/iot/device/index.ts @@ -93,11 +93,11 @@ export const DeviceApi = { // 获取设备属性最新数据 getDevicePropertiesLatestData: async (params: any) => { - return await request.get({ url: `/iot/device/data/latest-data`, params }) + return await request.get({ url: `/iot/device/data/latest`, params }) }, // 获取设备属性历史数据 getDevicePropertiesHistoryData: async (params: any) => { - return await request.get({ url: `/iot/device/data/history-data`, params }) + return await request.get({ url: `/iot/device/data/history`, params }) } } diff --git a/src/views/iot/device/detail/DeviceDetailsModel.vue b/src/views/iot/device/detail/DeviceDetailsModel.vue index 40c1a89a2..9af72bb11 100644 --- a/src/views/iot/device/detail/DeviceDetailsModel.vue +++ b/src/views/iot/device/detail/DeviceDetailsModel.vue @@ -1,7 +1,7 @@ From 68f13accd383884f22ec7ecd52d969d06c484bfc Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 7 Dec 2024 20:48:28 +0800 Subject: [PATCH 010/120] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E3=80=91IoT=EF=BC=9A=E4=BA=A7=E5=93=81=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/iot/product/product/index.vue | 69 +++++++++++++++++++++---- 1 file changed, 59 insertions(+), 10 deletions(-) diff --git a/src/views/iot/product/product/index.vue b/src/views/iot/product/product/index.vue index 23395bc8e..c02c785e2 100644 --- a/src/views/iot/product/product/index.vue +++ b/src/views/iot/product/product/index.vue @@ -37,6 +37,15 @@ > 新增 + + 导出 + @@ -44,17 +53,36 @@ - - - + + + + + + + + - - - + ('card') // 视图模式状态 /** 查询列表 */ const getList = async () => { From 1ce8233159beffacae4be0ac64344db8964c4815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=B5=A9=E6=B5=A9?= <1036606149@qq.com> Date: Mon, 9 Dec 2024 21:12:20 +0800 Subject: [PATCH 012/120] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E3=80=91IoT=EF=BC=9A=E4=BA=A7=E5=93=81=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=A2=9E=E5=8A=A0=20picUrl=20=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=EF=BC=9B=E8=B0=83=E6=95=B4=E7=9B=B8=E5=85=B3=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/iot/product/product/index.ts | 1 + src/router/modules/remaining.ts | 2 +- src/views/iot/device/DeviceForm.vue | 2 +- src/views/iot/device/detail/DeviceDataDetail.vue | 2 +- src/views/iot/device/detail/DeviceDetailsHeader.vue | 2 +- src/views/iot/device/detail/DeviceDetailsInfo.vue | 2 +- src/views/iot/device/detail/DeviceDetailsModel.vue | 2 +- src/views/iot/device/detail/index.vue | 2 +- src/views/iot/device/index.vue | 2 +- 9 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/api/iot/product/product/index.ts b/src/api/iot/product/product/index.ts index 0fa58d54f..e9dfdcaf5 100644 --- a/src/api/iot/product/product/index.ts +++ b/src/api/iot/product/product/index.ts @@ -17,6 +17,7 @@ export interface ProductVO { dataFormat: number // 数据格式 deviceCount: number // 设备数量 createTime: Date // 创建时间 + picUrl: string // 产品图片 URL } // IOT 数据校验级别枚举类 diff --git a/src/router/modules/remaining.ts b/src/router/modules/remaining.ts index 5fcb73cdf..335f52703 100644 --- a/src/router/modules/remaining.ts +++ b/src/router/modules/remaining.ts @@ -618,7 +618,7 @@ const remainingRouter: AppRouteRecordRaw[] = [ }, children: [ { - path: 'product/detail/:id', + path: 'product/product/detail/:id', name: 'IoTProductDetail', meta: { title: '产品详情', diff --git a/src/views/iot/device/DeviceForm.vue b/src/views/iot/device/DeviceForm.vue index cb0260125..95eff822f 100644 --- a/src/views/iot/device/DeviceForm.vue +++ b/src/views/iot/device/DeviceForm.vue @@ -41,7 +41,7 @@ + + diff --git a/src/views/iot/product/product/detail/ThingModel/ThingModelDataType.vue b/src/views/iot/product/product/detail/ThingModel/ThingModelDataType.vue new file mode 100644 index 000000000..206d8909d --- /dev/null +++ b/src/views/iot/product/product/detail/ThingModel/ThingModelDataType.vue @@ -0,0 +1,29 @@ + + + + + diff --git a/src/views/iot/product/product/detail/ThinkModelFunctionForm.vue b/src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue similarity index 72% rename from src/views/iot/product/product/detail/ThinkModelFunctionForm.vue rename to src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue index 963d86b29..a2beb91f9 100644 --- a/src/views/iot/product/product/detail/ThinkModelFunctionForm.vue +++ b/src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue @@ -1,17 +1,17 @@ - + + diff --git a/src/views/iot/product/product/detail/ThinkModelFunction.vue b/src/views/iot/product/product/detail/ThingModel/index.vue similarity index 73% rename from src/views/iot/product/product/detail/ThinkModelFunction.vue rename to src/views/iot/product/product/detail/ThingModel/index.vue index 4f10ad068..286fe12d8 100644 --- a/src/views/iot/product/product/detail/ThinkModelFunction.vue +++ b/src/views/iot/product/product/detail/ThingModel/index.vue @@ -2,18 +2,18 @@ - 搜索 - 重置 - - 添加功能 + + + 搜索 + + + + 重置 + + + + 添加功能 - - + + - - - - - + + + + + - - - diff --git a/src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue b/src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue index a2beb91f9..d551cd4d5 100644 --- a/src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue +++ b/src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue @@ -18,28 +18,17 @@ - + - - - - + - + 读写 只读 - + @@ -51,10 +40,9 @@ + + diff --git a/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue new file mode 100644 index 000000000..db0a58b21 --- /dev/null +++ b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue @@ -0,0 +1,26 @@ + + + + + diff --git a/src/views/iot/product/product/detail/ThingModel/ThingModelNumberTypeDataSpecs.vue b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelNumberTypeDataSpecs.vue similarity index 72% rename from src/views/iot/product/product/detail/ThingModel/ThingModelNumberTypeDataSpecs.vue rename to src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelNumberTypeDataSpecs.vue index 65bd1fc9c..7de57631f 100644 --- a/src/views/iot/product/product/detail/ThingModel/ThingModelNumberTypeDataSpecs.vue +++ b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelNumberTypeDataSpecs.vue @@ -30,23 +30,13 @@ diff --git a/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue index db0a58b21..7b977ae6b 100644 --- a/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue +++ b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue @@ -1,26 +1,41 @@ diff --git a/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelNumberTypeDataSpecs.vue b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelNumberTypeDataSpecs.vue index 7de57631f..3920a0f55 100644 --- a/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelNumberTypeDataSpecs.vue +++ b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelNumberTypeDataSpecs.vue @@ -1,17 +1,17 @@ diff --git a/src/views/iot/device/group/index.vue b/src/views/iot/device/group/index.vue index 0646fc727..ea2e4bea7 100644 --- a/src/views/iot/device/group/index.vue +++ b/src/views/iot/device/group/index.vue @@ -61,6 +61,7 @@ :formatter="dateFormatter" width="180px" /> + - + @@ -127,6 +136,15 @@ + + + diff --git a/src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue b/src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue index 78a39695c..f3d55d495 100644 --- a/src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue +++ b/src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue @@ -22,8 +22,8 @@ @@ -39,11 +39,12 @@ import { ProductVO } from '@/api/iot/product/product' import ThingModelDataSpecs from './ThingModelDataSpecs.vue' import { ProductFunctionTypeEnum, - ThinkModelFunctionApi, - ThingModelData + ThingModelData, + ThinkModelFunctionApi } from '@/api/iot/thinkmodelfunction' import { IOT_PROVIDE_KEY } from '@/views/iot/utils/constants' import { DataSpecsDataType } from './config' +import { cloneDeep } from 'lodash-es' defineOptions({ name: 'IoTProductThingModelForm' }) @@ -58,12 +59,15 @@ const formLoading = ref(false) const formType = ref('') const formData = ref({ type: ProductFunctionTypeEnum.PROPERTY, + dataType: DataSpecsDataType.INT, property: { dataType: DataSpecsDataType.INT, - dataSpecsList: [], - dataSpecs: {} + dataSpecs: { + dataType: DataSpecsDataType.INT + } } }) +// TODO puhui999: 表单校验待完善 const formRules = reactive({ name: [ { required: true, message: '功能名称不能为空', trigger: 'blur' }, @@ -114,7 +118,7 @@ const open = async (type: string, id?: number) => { if (id) { formLoading.value = true try { - formData.value = await ThinkModelFunctionApi.getThinkModelFunction(id) + formData.value = await ThinkModelFunctionApi.getProductThingModel(id) } finally { formLoading.value = false } @@ -128,14 +132,19 @@ const submitForm = async () => { await formRef.value.validate() formLoading.value = true try { - const data = formData.value as unknown as ThingModelData + const data = cloneDeep(formData.value) as ThingModelData + // 信息补全 data.productId = product!.value.id data.productKey = product!.value.productKey + data.description = data.property.description + data.dataType = data.property.dataType + data.property.identifier = data.identifier + data.property.name = data.name if (formType.value === 'create') { - await ThinkModelFunctionApi.createThinkModelFunction(data) + await ThinkModelFunctionApi.createProductThingModel(data) message.success(t('common.createSuccess')) } else { - await ThinkModelFunctionApi.updateThinkModelFunction(data) + await ThinkModelFunctionApi.updateProductThingModel(data) message.success(t('common.updateSuccess')) } } finally { @@ -149,10 +158,12 @@ const submitForm = async () => { const resetForm = () => { formData.value = { type: ProductFunctionTypeEnum.PROPERTY, + dataType: DataSpecsDataType.INT, property: { dataType: DataSpecsDataType.INT, - dataSpecsList: [], - dataSpecs: {} + dataSpecs: { + dataType: DataSpecsDataType.INT + } } } formRef.value?.resetFields() diff --git a/src/views/iot/product/product/detail/ThingModel/config.ts b/src/views/iot/product/product/detail/ThingModel/config.ts index cd9d059d7..eb6519602 100644 --- a/src/views/iot/product/product/detail/ThingModel/config.ts +++ b/src/views/iot/product/product/detail/ThingModel/config.ts @@ -43,3 +43,8 @@ export const dataTypeOptions = [ { value: DataSpecsDataType.STRUCT, label: 'struct (结构体)' }, { value: DataSpecsDataType.ARRAY, label: 'array (数组)' } ] + +/** 获得物体模型数据类型配置项名称 */ +export const getDataTypeOptionsLabel = (value: string) => { + return dataTypeOptions.find((option) => option.value === value)?.label +} diff --git a/src/views/iot/product/product/detail/ThingModel/index.vue b/src/views/iot/product/product/detail/ThingModel/index.vue index 286fe12d8..41cbb39d5 100644 --- a/src/views/iot/product/product/detail/ThingModel/index.vue +++ b/src/views/iot/product/product/detail/ThingModel/index.vue @@ -32,7 +32,12 @@ 重置 - + 添加功能 @@ -49,12 +54,21 @@ - - + + + + + + - + From 12abcddb1237ccc01e0a8989b567cc4d849c0a57 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Tue, 17 Dec 2024 14:13:49 +0800 Subject: [PATCH 039/120] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E3=80=91IOT:=20=E4=BA=A7=E5=93=81=E7=89=A9=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B-=E6=9E=9A=E4=B8=BE=E5=9E=8B=E7=9A=84=20dataSpecs=20?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E8=A7=84=E5=88=99=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataSpecs/ThingModelEnumTypeDataSpecs.vue | 120 +++++++++++++++++- 1 file changed, 115 insertions(+), 5 deletions(-) diff --git a/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue index 0c67358a3..6d24bdb5e 100644 --- a/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue +++ b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue @@ -1,5 +1,9 @@ + + +
发送 @@ -98,11 +98,6 @@ - - - @@ -112,6 +107,11 @@ prop="specs" :show-overflow-tooltip="true" /> + + +
发送 @@ -142,11 +142,6 @@ - - - @@ -156,6 +151,11 @@ prop="specs" :show-overflow-tooltip="true" /> + + +
获取 @@ -189,7 +189,7 @@ diff --git a/src/views/iot/device/device/detail/index.vue b/src/views/iot/device/device/detail/index.vue index 8e3425900..1c7e7c45f 100644 --- a/src/views/iot/device/device/detail/index.vue +++ b/src/views/iot/device/device/detail/index.vue @@ -17,11 +17,16 @@ - + + - - + + @@ -34,6 +39,7 @@ import DeviceDetailsInfo from './DeviceDetailsInfo.vue' import DeviceDetailsModel from './DeviceDetailsModel.vue' import DeviceDetailsLog from './DeviceDetailsLog.vue' import DeviceDetailsSimulator from './DeviceDetailsSimulator.vue' + defineOptions({ name: 'IoTDeviceDetail' }) const route = useRoute() From 3d65f1c599a507ab17ed4b1fdd08ff2fa3efec80 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 28 Jan 2025 04:55:48 +0800 Subject: [PATCH 064/120] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E3=80=91Bpm=EF=BC=9A=E8=AE=BE=E5=A4=87=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/iot/device/device/index.ts | 22 ++--- .../device/device/detail/DeviceDetailsLog.vue | 2 +- .../device/detail/DeviceDetailsSimulator.vue | 94 ++++++++++--------- 3 files changed, 61 insertions(+), 57 deletions(-) diff --git a/src/api/iot/device/device/index.ts b/src/api/iot/device/device/index.ts index fae8100a5..d1b35c1c7 100644 --- a/src/api/iot/device/device/index.ts +++ b/src/api/iot/device/device/index.ts @@ -63,15 +63,12 @@ export enum DeviceStatusEnum { DISABLED = 3 // 已禁用 } -// IoT 模拟设备数据 -// TODO @super:DeviceSimulatorDataReqVO -export interface SimulatorDataVO { - productKey: string - deviceKey: string - type: string - subType: string - reportTime: number // 时间戳 - content: string // 存储 JSON 字符串 +// IoT 模拟设备上报数据 Request VO +export interface IotDeviceSimulationReportReqVO { + id: number // 设备编号 + type: string // 消息类型 + identifier: string // 标识符 + data: object // 请求参数 } // 设备 API @@ -146,11 +143,12 @@ export const DeviceApi = { return await request.download({ url: `/iot/device/get-import-template` }) }, - // 模拟设备 - simulatorDevice: async (data: SimulatorDataVO) => { + // 模拟设备上报 + simulationReportDevice: async (data: IotDeviceSimulationReportReqVO) => { // TODO @super:/iot/device/simulator - return await request.post({ url: `/iot/device/data/simulator`, data }) + return await request.post({ url: `/iot/device/simulation-report`, data }) }, + // 查询设备日志分页 getDeviceLogPage: async (params: any) => { // TODO @super:/iot/log-page 或者 /iot/log/page diff --git a/src/views/iot/device/device/detail/DeviceDetailsLog.vue b/src/views/iot/device/device/detail/DeviceDetailsLog.vue index 2ffcd5de8..ab1a2641a 100644 --- a/src/views/iot/device/device/detail/DeviceDetailsLog.vue +++ b/src/views/iot/device/device/detail/DeviceDetailsLog.vue @@ -52,7 +52,7 @@ import { DeviceApi } from '@/api/iot/device/device' import { formatDate } from '@/utils/formatTime' const props = defineProps<{ - deviceKey: number + deviceKey: string }>() //TODO:后续看看使用什么查询条件 目前后端是留了时间范围 type subType diff --git a/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue b/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue index 9aee66fc1..b84adf15b 100644 --- a/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue +++ b/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue @@ -1,6 +1,5 @@