From 541c118dbbe06600f9546eeb3c7b17e8ef369e37 Mon Sep 17 00:00:00 2001
From: ChenYi <296215406@outlook.com>
Date: Thu, 8 May 2025 22:44:01 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DIoTDB=E9=A9=B1=E5=8A=A8?=
=?UTF-8?q?=E9=80=82=E9=85=8D=E5=A2=9E=E9=87=8F=E6=BA=90=E7=A0=81=E7=94=9F?=
=?UTF-8?q?=E6=88=90=E5=99=A8=E4=BB=A5=E5=90=8E=EF=BC=8C=E5=8D=95=E4=BE=A7?=
=?UTF-8?q?=E7=82=B9=E6=A8=A1=E5=BC=8F=E5=A4=B1=E6=95=88=E7=9A=84=E9=97=AE?=
=?UTF-8?q?=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Exceptions/IoTException.cs | 22 +
.../JiShe.CollectBus.IoTDB.csproj | 3 +-
.../Provider/IoTDBProvider.cs | 430 +++++++++++++-----
.../BasicScheduledMeterReadingService.cs | 20 +-
.../Helpers/CommonHelper.cs | 17 +-
.../Pages/Monitor.cshtml | 3 +-
web/JiShe.CollectBus.Host/appsettings.json | 2 +-
7 files changed, 370 insertions(+), 127 deletions(-)
create mode 100644 modules/JiShe.CollectBus.IoTDB/Exceptions/IoTException.cs
diff --git a/modules/JiShe.CollectBus.IoTDB/Exceptions/IoTException.cs b/modules/JiShe.CollectBus.IoTDB/Exceptions/IoTException.cs
new file mode 100644
index 0000000..93bed4f
--- /dev/null
+++ b/modules/JiShe.CollectBus.IoTDB/Exceptions/IoTException.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JiShe.CollectBus.IoTDB.Exceptions
+{
+ ///
+ /// IoTDB异常
+ ///
+ public class IoTException : Exception
+ {
+ public int ErrorCode { get; }
+
+ public IoTException(string message, int errorCode)
+ : base($"{message} (Code: {errorCode})")
+ {
+ ErrorCode = errorCode;
+ }
+ }
+}
diff --git a/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj b/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
index 3911399..78b81e3 100644
--- a/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
+++ b/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
@@ -14,7 +14,6 @@
-
+
diff --git a/modules/JiShe.CollectBus.IoTDB/Provider/IoTDBProvider.cs b/modules/JiShe.CollectBus.IoTDB/Provider/IoTDBProvider.cs
index bacbf61..db86791 100644
--- a/modules/JiShe.CollectBus.IoTDB/Provider/IoTDBProvider.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Provider/IoTDBProvider.cs
@@ -21,6 +21,7 @@ using Microsoft.Extensions.Logging;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities;
using JiShe.CollectBus.Analyzers.Shared;
+using JiShe.CollectBus.IoTDB.Exceptions;
namespace JiShe.CollectBus.IoTDB.Provider
{
@@ -250,128 +251,337 @@ namespace JiShe.CollectBus.IoTDB.Provider
}
}
+ /////
+ ///// 构建Tablet
+ /////
+ /////
+ ///// 表实体
+ ///// 设备元数据
+ /////
+ //private Tablet BuildTablet(IEnumerable entities, DeviceMetadata metadata) where T : IoTEntity
+ //{
+ // var timestamps = new List();
+ // var values = new List>();
+ // var devicePaths = new HashSet();
+ // List tempColumnNames = new List();
+ // tempColumnNames.AddRange(metadata.ColumnNames);
+
+ // var accessor = SourceEntityAccessorFactory.GetAccessor();
+
+ // var memberCache = new Dictionary(); // 缓存优化查询
+ // // 预构建成员缓存(Key: NameOrPath)
+ // foreach (var member in accessor.MemberList)
+ // {
+ // memberCache[member.NameOrPath] = member;
+ // }
+
+ // if (accessor.EntityType == null || metadata.EntityType == null)
+ // {
+ // throw new ArgumentException($"{nameof(BuildTablet)} 构建存储结构{nameof(Tablet)}时 {nameof(T)}的EntityType 没有指定,属于异常情况,-101");
+ // }
+
+ // if (metadata.EntityType != accessor.EntityType)
+ // {
+ // throw new ArgumentException($"{nameof(BuildTablet)} 构建存储结构{nameof(Tablet)}时 {nameof(T)}的EntityType 和{nameof(DeviceMetadata)}的 EntityType 不一致,属于异常情况,-102");
+ // }
+
+ // if (metadata.EntityType == EntityTypeEnum.TreeModel && _runtimeContext.UseTableSessionPool == true)
+ // {
+ // throw new ArgumentException($"{nameof(BuildTablet)} 构建存储结构{nameof(Tablet)}时 tree模型不能使用table模型Session连接,属于异常情况,-103");
+ // }
+ // else if (metadata.EntityType == EntityTypeEnum.TableModel && _runtimeContext.UseTableSessionPool == false)
+ // {
+ // throw new ArgumentException($"{nameof(BuildTablet)} 构建存储结构{nameof(Tablet)}时 table模型不能使用tree模型Session连接,属于异常情况,-104");
+ // }
+
+ // string tableNameOrTreePath = string.Empty;
+ // var tableNameOrTreePathAttribute = typeof(T).GetCustomAttribute();
+ // if (tableNameOrTreePathAttribute != null)
+ // {
+ // tableNameOrTreePath = tableNameOrTreePathAttribute.TableNameOrTreePath;
+ // }
+
+ // foreach (var entity in entities)
+ // {
+ // timestamps.Add(entity.Timestamps);
+ // var rowValues = new List