From f6130e1d0b32d5f3ae36de73079244a8e17c6118 Mon Sep 17 00:00:00 2001
From: ChenYi <296215406@outlook.com>
Date: Fri, 9 May 2025 17:54:52 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96IoTDB=E9=A9=B1=E5=8A=A8?=
=?UTF-8?q?=EF=BC=8C=E5=AE=9E=E7=8E=B030=E4=B8=AA=E5=AD=97=E6=AE=B5?=
=?UTF-8?q?=E5=AE=9E=E4=BD=93=E7=9A=84270W=E4=BB=BB=E5=8A=A1=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E5=BC=80=E5=8F=91=E7=8E=AF=E5=A2=83=E5=A4=84=E7=90=86?=
=?UTF-8?q?=E5=B9=B3=E5=9D=87=E8=80=97=E6=97=B6=E5=9C=A870=E7=A7=92?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ComplexTypeSourceAnalyzers.cs | 4 +-
.../JiShe.CollectBus.IoTDB/Model/IoTEntity.cs | 23 +
.../Provider/DeviceMetadata.cs | 50 +-
.../Provider/IoTDBProvider.cs | 593 ++++++++----------
.../DataChannels/DataChannelManageService.cs | 14 +-
.../Samples/SampleAppService.cs | 4 +-
.../BasicScheduledMeterReadingService.cs | 67 +-
7 files changed, 378 insertions(+), 377 deletions(-)
diff --git a/modules/JiShe.CollectBus.Analyzers/ComplexTypeSourceAnalyzers.cs b/modules/JiShe.CollectBus.Analyzers/ComplexTypeSourceAnalyzers.cs
index bad9528..ecb9c78 100644
--- a/modules/JiShe.CollectBus.Analyzers/ComplexTypeSourceAnalyzers.cs
+++ b/modules/JiShe.CollectBus.Analyzers/ComplexTypeSourceAnalyzers.cs
@@ -226,7 +226,7 @@ namespace JiShe.CollectBus.IncrementalGenerator
code.AppendLine($" public string EntityName {{get;}} = \"{classSymbol.Name}\";");
// 添加 EntityType 属性
code.AppendLine($" public EntityTypeEnum? EntityType {{ get; }} = {entityTypeValue};");
-
+
foreach (var prop in propList)
{
// 安全类型转换
@@ -573,7 +573,7 @@ namespace JiShe.CollectBus.IncrementalGenerator
$"new EntityMemberInfo(" +
$"\"{prop.Name}.{elementName}\", " +
$"typeof({elementType}), " +
- $"\"{elementDeclaredName}\", " +
+ $"typeof({elementType}).Name, " +//$"\"{elementDeclaredName}\", " +
$"(e) => Get{prop.Name}_{elementName}(({entityType})e), " +
$"(e, v) => Set{prop.Name}_{elementName}(({entityType})e, ({elementType})v))");
}
diff --git a/modules/JiShe.CollectBus.IoTDB/Model/IoTEntity.cs b/modules/JiShe.CollectBus.IoTDB/Model/IoTEntity.cs
index f2d55a5..9df2488 100644
--- a/modules/JiShe.CollectBus.IoTDB/Model/IoTEntity.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Model/IoTEntity.cs
@@ -1,6 +1,7 @@
using JiShe.CollectBus.Common.Attributes;
using JiShe.CollectBus.Common.Consts;
using JiShe.CollectBus.IoTDB.Attributes;
+using Volo.Abp.Domain.Entities;
namespace JiShe.CollectBus.IoTDB.Model
{
@@ -43,5 +44,27 @@ namespace JiShe.CollectBus.IoTDB.Model
/// 时标,也就是业务时间戳,单位毫秒,必须通过DateTimeOffset获取
///
public long Timestamps { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+
+ ///
+ /// 设备路径
+ ///
+ public virtual string DevicePath
+ {
+ get
+ {
+ return $"root.{SystemName.ToLower()}.`{ProjectId}`.`{DeviceType}`.{DataType}.`{DeviceId}`";
+ }
+ set
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ DevicePath = $"root.{SystemName.ToLower()}.`{ProjectId}`.`{DeviceType}`.{DataType}.`{DeviceId}`";
+ }
+ else
+ {
+ DevicePath = value;
+ }
+ }
+ }
}
}
diff --git a/modules/JiShe.CollectBus.IoTDB/Provider/DeviceMetadata.cs b/modules/JiShe.CollectBus.IoTDB/Provider/DeviceMetadata.cs
index f48d218..92c33ee 100644
--- a/modules/JiShe.CollectBus.IoTDB/Provider/DeviceMetadata.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Provider/DeviceMetadata.cs
@@ -6,8 +6,18 @@ namespace JiShe.CollectBus.IoTDB.Provider
///
/// 设备元数据
///
- public class DeviceMetadata
+ public sealed class DeviceMetadata
{
+ ///
+ /// 实体类名称
+ ///
+ public string EntityName { get; set; }
+
+ ///
+ /// 设备表名或树路径,如果实体没有添加TableNameOrTreePath,此处为空
+ ///
+ public string TableNameOrTreePath { get; set; }
+
///
/// 实体类型枚举
///
@@ -31,6 +41,42 @@ namespace JiShe.CollectBus.IoTDB.Provider
///
/// 值类型集合,用于构建Table的值类型,也就是dataTypes参数
///
- public List DataTypes { get; } = new();
+ public List DataTypes { get; set; } = new();
+
+ ///
+ /// 列处理信息集合
+ ///
+ public List Processors { get; } = new List();
+ }
+
+ ///
+ /// 列处理信息结构
+ ///
+ public struct ColumnProcessor
+ {
+ ///
+ /// 列名
+ ///
+ public string ColumnName;
+
+ ///
+ /// 值获取委托
+ ///
+ public Func