From cab0e1ed08176f31068cf1c2f2730aed732eb11e Mon Sep 17 00:00:00 2001
From: ChenYi <296215406@outlook.com>
Date: Mon, 28 Apr 2025 09:53:45 +0800
Subject: [PATCH 1/8] =?UTF-8?q?=E5=A2=9E=E9=87=8F=E6=BA=90=E7=A0=81?=
=?UTF-8?q?=E7=94=9F=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
JiShe.CollectBus.sln | 7 +
.../JiShe.CollectBus.IoTDB.csproj | 13 +-
.../Model/TableModelSingleMeasuringEntity.cs | 2 +
.../JiShe.CollectBus.Domain.csproj | 2 +-
.../JiShe.CollectBus.Common.csproj | 2 +-
.../ComplexTypeSourceGenerator.cs | 187 ++++++++++++++++++
.../GenerateAccessorsAttribute.cs | 16 ++
.../JiShe.CollectBus.SourceExtend.csproj | 12 ++
8 files changed, 233 insertions(+), 8 deletions(-)
create mode 100644 shared/JiShe.CollectBus.SourceExtend/ComplexTypeSourceGenerator.cs
create mode 100644 shared/JiShe.CollectBus.SourceExtend/GenerateAccessorsAttribute.cs
create mode 100644 shared/JiShe.CollectBus.SourceExtend/JiShe.CollectBus.SourceExtend.csproj
diff --git a/JiShe.CollectBus.sln b/JiShe.CollectBus.sln
index 1ecb18c..2e5826f 100644
--- a/JiShe.CollectBus.sln
+++ b/JiShe.CollectBus.sln
@@ -62,6 +62,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.Docs", "0.Docs", "{D8346C
readme.md = readme.md
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.SourceExtend", "shared\JiShe.CollectBus.SourceExtend\JiShe.CollectBus.SourceExtend.csproj", "{A34A4EA6-AEB0-4199-8E3A-6F042DBB51D9}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -148,6 +150,10 @@ Global
{75B7D419-C261-577D-58D6-AA3ACED9129F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75B7D419-C261-577D-58D6-AA3ACED9129F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75B7D419-C261-577D-58D6-AA3ACED9129F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A34A4EA6-AEB0-4199-8E3A-6F042DBB51D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A34A4EA6-AEB0-4199-8E3A-6F042DBB51D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A34A4EA6-AEB0-4199-8E3A-6F042DBB51D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A34A4EA6-AEB0-4199-8E3A-6F042DBB51D9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -173,6 +179,7 @@ Global
{8A61DF78-069B-40B5-8811-614E2960443E} = {3C3F9DB2-EC97-4464-B49F-BF1A0C2B46DC}
{E27377CC-E2D3-4237-060F-96EA214D3129} = {3C3F9DB2-EC97-4464-B49F-BF1A0C2B46DC}
{75B7D419-C261-577D-58D6-AA3ACED9129F} = {3C3F9DB2-EC97-4464-B49F-BF1A0C2B46DC}
+ {A34A4EA6-AEB0-4199-8E3A-6F042DBB51D9} = {EBF7C01F-9B4F-48E6-8418-2CBFDA51EB0B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4324B3B4-B60B-4E3C-91D8-59576B4E26DD}
diff --git a/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj b/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
index 8cc4b33..afd5a8a 100644
--- a/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
+++ b/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
@@ -1,15 +1,16 @@
-
- net8.0
- enable
- enable
-
+
+ net8.0
+ enable
+ enable
+
-
+
+
diff --git a/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs b/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs
index 4308dae..d48f766 100644
--- a/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using JiShe.CollectBus.Common.Attributes;
using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
using JiShe.CollectBus.IoTDB.Provider;
@@ -13,6 +14,7 @@ namespace JiShe.CollectBus.IoTDB.Model
/// Table模型单项数据实体
///
[EntityType(EntityTypeEnum.TableModel)]
+ [GenerateAccessors]
public class TableModelSingleMeasuringEntity : IoTEntity
{
///
diff --git a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
index a60ffe1..1914993 100644
--- a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
+++ b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
@@ -23,7 +23,7 @@
-
+
diff --git a/shared/JiShe.CollectBus.Common/JiShe.CollectBus.Common.csproj b/shared/JiShe.CollectBus.Common/JiShe.CollectBus.Common.csproj
index 05645ef..fdb6bfd 100644
--- a/shared/JiShe.CollectBus.Common/JiShe.CollectBus.Common.csproj
+++ b/shared/JiShe.CollectBus.Common/JiShe.CollectBus.Common.csproj
@@ -17,7 +17,7 @@
-
+
diff --git a/shared/JiShe.CollectBus.SourceExtend/ComplexTypeSourceGenerator.cs b/shared/JiShe.CollectBus.SourceExtend/ComplexTypeSourceGenerator.cs
new file mode 100644
index 0000000..352cd4a
--- /dev/null
+++ b/shared/JiShe.CollectBus.SourceExtend/ComplexTypeSourceGenerator.cs
@@ -0,0 +1,187 @@
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Text;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JiShe.CollectBus.SourceExtend
+{
+ ///
+ /// 复杂类型源生成器
+ ///
+ [Generator]
+ public sealed class PropertyAccessorGenerator : IIncrementalGenerator
+ {
+ private const string AttributeName = "GenerateAccessors";
+
+ public void Initialize(IncrementalGeneratorInitializationContext context)
+ {
+ // 步骤1:筛选带有 [GenerateAccessors] 的类
+ var classDeclarations = context.SyntaxProvider
+ .CreateSyntaxProvider(
+ predicate: static (s, _) => IsClassWithAttribute(s),
+ transform: static (ctx, _) => GetClassDeclaration(ctx))
+ .Where(static c => c is not null);
+
+ // 步骤2:编译符号并生成代码
+ var compilationAndClasses = context.CompilationProvider.Combine(classDeclarations.Collect());
+
+ context.RegisterSourceOutput(compilationAndClasses, (spc, source) =>
+ GenerateCode(source.Left, source.Right!, spc));
+ }
+
+ private static bool IsClassWithAttribute(SyntaxNode node)
+ {
+ return node is ClassDeclarationSyntax { AttributeLists.Count: > 0 };
+ }
+
+ private static ClassDeclarationSyntax? GetClassDeclaration(GeneratorSyntaxContext context)
+ {
+ var classDecl = (ClassDeclarationSyntax)context.Node;
+ foreach (var attributeList in classDecl.AttributeLists)
+ {
+ foreach (var attribute in attributeList.Attributes)
+ {
+ var symbol = context.SemanticModel.GetSymbolInfo(attribute).Symbol;
+ if (symbol?.ContainingType.ToDisplayString() == $"{nameof(PropertyAccessorGenerator)}.{AttributeName}")
+ {
+ return classDecl;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static void GenerateCode(
+ Compilation compilation,
+ IEnumerable classes,
+ SourceProductionContext context)
+ {
+ var processedTypes = new HashSet(SymbolEqualityComparer.Default);
+
+ foreach (var classDecl in classes.Distinct())
+ {
+ var model = compilation.GetSemanticModel(classDecl.SyntaxTree);
+ var classSymbol = model.GetDeclaredSymbol(classDecl)!;
+
+ if (!processedTypes.Add(classSymbol)) continue;
+
+ var code = BuildAccessorsForType(classSymbol, compilation, processedTypes);
+ context.AddSource($"{classSymbol.Name}Accessors.g.cs", code);
+ }
+ }
+
+ private static string BuildAccessorsForType(
+ INamedTypeSymbol classSymbol,
+ Compilation compilation,
+ HashSet processedTypes)
+ {
+ var code = new StringBuilder();
+ code.AppendLine("// ");
+ code.AppendLine("#nullable enable");
+ code.AppendLine();
+ code.AppendLine($"namespace {classSymbol.ContainingNamespace.ToDisplayString()};");
+ code.AppendLine();
+
+ // 处理泛型参数
+ var genericParams = classSymbol.IsGenericType
+ ? $"<{string.Join(", ", classSymbol.TypeParameters.Select(t => t.Name))}>"
+ : "";
+
+ code.AppendLine($"public static class {classSymbol.Name}Accessors{genericParams}");
+ code.AppendLine("{");
+
+ foreach (var prop in classSymbol.GetMembers().OfType())
+ {
+ if (prop.IsIndexer) continue;
+
+ GeneratePropertyAccessors(prop, code, compilation, processedTypes);
+ }
+
+ code.AppendLine("}");
+ return code.ToString();
+ }
+
+ private static void GeneratePropertyAccessors(
+ IPropertySymbol prop,
+ StringBuilder code,
+ Compilation compilation,
+ HashSet processedTypes)
+ {
+ var propType = prop.Type;
+ var parentType = prop.ContainingType.ToDisplayString();
+
+ // 处理元组类型
+ if (propType.IsTupleType && propType is INamedTypeSymbol tupleType)
+ {
+ GenerateTupleAccessors(prop, tupleType, code);
+ }
+ else if (propType is INamedTypeSymbol namedType)
+ {
+ GenerateStandardAccessors(prop, namedType, code);
+ ProcessNestedType(namedType, compilation, processedTypes);
+ }
+ }
+
+ private static void GenerateTupleAccessors(IPropertySymbol prop, INamedTypeSymbol tupleType, StringBuilder code)
+ {
+ var elements = tupleType.TupleElements;
+ var parentType = prop.ContainingType.ToDisplayString();
+
+ for (int i = 0; i < elements.Length; i++)
+ {
+ var element = elements[i];
+ var elementType = element.Type.ToDisplayString();
+ var elementName = element.CorrespondingTupleField?.Name ?? $"Item{i + 1}";
+
+ code.AppendLine($" public static {elementType} Get{prop.Name}_{elementName}({parentType} obj)");
+ code.AppendLine($" => obj.{prop.Name}.{elementName};");
+
+ if (prop.SetMethod != null)
+ {
+ var assignments = elements.Select((e, idx) =>
+ idx == i ? "value" : $"obj.{prop.Name}.{e.Name}");
+
+ code.AppendLine($" public static void Set{prop.Name}_{elementName}({parentType} obj, {elementType} value)");
+ code.AppendLine($" => obj.{prop.Name} = ({string.Join(", ", assignments)});");
+ }
+ }
+ }
+
+ private static void GenerateStandardAccessors(IPropertySymbol prop, INamedTypeSymbol propType, StringBuilder code)
+ {
+ var typeName = propType.ToDisplayString();
+ var parentType = prop.ContainingType.ToDisplayString();
+
+ code.AppendLine($" public static {typeName} Get{prop.Name}({parentType} obj)");
+ code.AppendLine($" => obj.{prop.Name};");
+
+ if (prop.SetMethod != null)
+ {
+ code.AppendLine($" public static void Set{prop.Name}({parentType} obj, {typeName} value)");
+ code.AppendLine($" => obj.{prop.Name} = value;");
+ }
+ }
+
+ private static void ProcessNestedType(INamedTypeSymbol typeSymbol, Compilation compilation, HashSet processedTypes)
+ {
+ if (ShouldGenerateForType(typeSymbol) && processedTypes.Add(typeSymbol))
+ {
+ var code = BuildAccessorsForType(typeSymbol, compilation, processedTypes);
+ // 注意:实际项目中需要通过 SourceProductionContext 添加源代码
+ }
+ }
+
+ private static bool ShouldGenerateForType(INamedTypeSymbol typeSymbol)
+ {
+ return !typeSymbol.IsTupleType &&
+ !typeSymbol.IsAnonymousType &&
+ !typeSymbol.IsNativeIntegerType &&
+ typeSymbol.DeclaredAccessibility == Accessibility.Public &&
+ !typeSymbol.Name.StartsWith("<");
+ }
+ }
+}
\ No newline at end of file
diff --git a/shared/JiShe.CollectBus.SourceExtend/GenerateAccessorsAttribute.cs b/shared/JiShe.CollectBus.SourceExtend/GenerateAccessorsAttribute.cs
new file mode 100644
index 0000000..b739a54
--- /dev/null
+++ b/shared/JiShe.CollectBus.SourceExtend/GenerateAccessorsAttribute.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JiShe.CollectBus.SourceExtend
+{
+ ///
+ /// 标记需要生成源码的类
+ ///
+ [AttributeUsage(AttributeTargets.Class)]
+ public class GenerateAccessorsAttribute : Attribute
+ {
+ }
+}
diff --git a/shared/JiShe.CollectBus.SourceExtend/JiShe.CollectBus.SourceExtend.csproj b/shared/JiShe.CollectBus.SourceExtend/JiShe.CollectBus.SourceExtend.csproj
new file mode 100644
index 0000000..a06bde8
--- /dev/null
+++ b/shared/JiShe.CollectBus.SourceExtend/JiShe.CollectBus.SourceExtend.csproj
@@ -0,0 +1,12 @@
+
+
+
+ netstandard2.1
+ 12.0
+ enable
+ true
+
+
+
+
+
From 021153a319a533d51baf42d2d420b6385f7a6223 Mon Sep 17 00:00:00 2001
From: ChenYi <296215406@outlook.com>
Date: Mon, 28 Apr 2025 14:07:51 +0800
Subject: [PATCH 2/8] =?UTF-8?q?=E6=BA=90=E7=A0=81=E7=94=9F=E6=88=90?=
=?UTF-8?q?=E5=99=A8=E5=BA=94=E7=94=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
JiShe.CollectBus.sln | 12 +-
.../JiShe.CollectBus.IoTDB.csproj | 3 +-
.../Model/TableModelSingleMeasuringEntity.cs | 8 +-
.../Model/TreeModelSingleMeasuringEntity.cs | 10 +-
.../JiShe.CollectBus.Application.csproj | 2 +
.../Samples/SampleAppService.cs | 1 +
.../Ammeters/ElectricityMeterTreeModel.cs | 6 +-
.../MeterReadingTelemetryPacketInfo.cs | 11 +-
.../JiShe.CollectBus.Domain.csproj | 2 +-
.../Attributes}/GenerateAccessorsAttribute.cs | 6 +-
.../JiShe.CollectBus.Common.csproj | 3 +-
.../Models/ServerApplicationOptions.cs | 16 +-
.../ComplexTypeSourceGenerator.cs | 223 ++++++++++++++++++
...She.CollectBus.IncrementalGenerator.csproj | 14 ++
.../ComplexTypeSourceGenerator.cs | 187 ---------------
.../JiShe.CollectBus.SourceExtend.csproj | 12 -
.../JiShe.CollectBus.Host.csproj | 8 +-
17 files changed, 272 insertions(+), 252 deletions(-)
rename shared/{JiShe.CollectBus.SourceExtend => JiShe.CollectBus.Common/Attributes}/GenerateAccessorsAttribute.cs (59%)
create mode 100644 shared/JiShe.CollectBus.IncrementalGenerator/ComplexTypeSourceGenerator.cs
create mode 100644 shared/JiShe.CollectBus.IncrementalGenerator/JiShe.CollectBus.IncrementalGenerator.csproj
delete mode 100644 shared/JiShe.CollectBus.SourceExtend/ComplexTypeSourceGenerator.cs
delete mode 100644 shared/JiShe.CollectBus.SourceExtend/JiShe.CollectBus.SourceExtend.csproj
diff --git a/JiShe.CollectBus.sln b/JiShe.CollectBus.sln
index 2e5826f..0232b6d 100644
--- a/JiShe.CollectBus.sln
+++ b/JiShe.CollectBus.sln
@@ -62,7 +62,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.Docs", "0.Docs", "{D8346C
readme.md = readme.md
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.SourceExtend", "shared\JiShe.CollectBus.SourceExtend\JiShe.CollectBus.SourceExtend.csproj", "{A34A4EA6-AEB0-4199-8E3A-6F042DBB51D9}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.IncrementalGenerator", "shared\JiShe.CollectBus.IncrementalGenerator\JiShe.CollectBus.IncrementalGenerator.csproj", "{828D20BC-454E-0467-B29D-429B25F1E0CA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -150,10 +150,10 @@ Global
{75B7D419-C261-577D-58D6-AA3ACED9129F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75B7D419-C261-577D-58D6-AA3ACED9129F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75B7D419-C261-577D-58D6-AA3ACED9129F}.Release|Any CPU.Build.0 = Release|Any CPU
- {A34A4EA6-AEB0-4199-8E3A-6F042DBB51D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A34A4EA6-AEB0-4199-8E3A-6F042DBB51D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A34A4EA6-AEB0-4199-8E3A-6F042DBB51D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A34A4EA6-AEB0-4199-8E3A-6F042DBB51D9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {828D20BC-454E-0467-B29D-429B25F1E0CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {828D20BC-454E-0467-B29D-429B25F1E0CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {828D20BC-454E-0467-B29D-429B25F1E0CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {828D20BC-454E-0467-B29D-429B25F1E0CA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -179,7 +179,7 @@ Global
{8A61DF78-069B-40B5-8811-614E2960443E} = {3C3F9DB2-EC97-4464-B49F-BF1A0C2B46DC}
{E27377CC-E2D3-4237-060F-96EA214D3129} = {3C3F9DB2-EC97-4464-B49F-BF1A0C2B46DC}
{75B7D419-C261-577D-58D6-AA3ACED9129F} = {3C3F9DB2-EC97-4464-B49F-BF1A0C2B46DC}
- {A34A4EA6-AEB0-4199-8E3A-6F042DBB51D9} = {EBF7C01F-9B4F-48E6-8418-2CBFDA51EB0B}
+ {828D20BC-454E-0467-B29D-429B25F1E0CA} = {EBF7C01F-9B4F-48E6-8418-2CBFDA51EB0B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4324B3B4-B60B-4E3C-91D8-59576B4E26DD}
diff --git a/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj b/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
index afd5a8a..0e8250e 100644
--- a/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
+++ b/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
@@ -3,7 +3,7 @@
net8.0
enable
- enable
+ enable
@@ -11,6 +11,5 @@
-
diff --git a/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs b/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs
index d48f766..3350172 100644
--- a/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs
@@ -1,12 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using JiShe.CollectBus.Common.Attributes;
+using JiShe.CollectBus.Common;
using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
-using JiShe.CollectBus.IoTDB.Provider;
namespace JiShe.CollectBus.IoTDB.Model
{
diff --git a/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs b/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs
index 9b3609c..2a3273b 100644
--- a/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs
@@ -1,11 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using JiShe.CollectBus.Common;
using JiShe.CollectBus.IoTDB.Attribute;
-using JiShe.CollectBus.IoTDB.Enums;
-using JiShe.CollectBus.IoTDB.Provider;
+using JiShe.CollectBus.IoTDB.Enums;
namespace JiShe.CollectBus.IoTDB.Model
{
@@ -13,6 +8,7 @@ namespace JiShe.CollectBus.IoTDB.Model
/// Tree模型单项数据实体
///
[EntityType(EntityTypeEnum.TreeModel)]
+ [GenerateAccessors]
public class TreeModelSingleMeasuringEntity : IoTEntity
{
///
diff --git a/services/JiShe.CollectBus.Application/JiShe.CollectBus.Application.csproj b/services/JiShe.CollectBus.Application/JiShe.CollectBus.Application.csproj
index aefe5e4..b43d994 100644
--- a/services/JiShe.CollectBus.Application/JiShe.CollectBus.Application.csproj
+++ b/services/JiShe.CollectBus.Application/JiShe.CollectBus.Application.csproj
@@ -30,6 +30,8 @@
+
+
diff --git a/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs b/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs
index 31a3494..6392b83 100644
--- a/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs
+++ b/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs
@@ -66,6 +66,7 @@ public class SampleAppService : CollectBusAppService, ISampleAppService, IKafkaS
IssuedMessageHexString = "messageHexString",
Timestamps = testTime// DateTimeOffset.UtcNow.ToUnixTimeNanoseconds()//testTime.GetDateTimeOffset().ToUnixTimeNanoseconds(),
};
+
await _iotDBProvider.InsertAsync(meter);
}
diff --git a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs
index 7fe7ebc..a9ddc93 100644
--- a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs
+++ b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs
@@ -1,10 +1,12 @@
-using JiShe.CollectBus.IoTDB.Attribute;
+using JiShe.CollectBus.Common;
+using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
-using JiShe.CollectBus.IoTDB.Model;
+using JiShe.CollectBus.IoTDB.Model;
namespace JiShe.CollectBus.Ammeters
{
[EntityType(EntityTypeEnum.TreeModel)]
+ [GenerateAccessors]
public class ElectricityMeterTreeModel : IoTEntity
{
[ATTRIBUTEColumn]
diff --git a/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs b/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs
index 1b5c954..552084f 100644
--- a/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs
+++ b/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs
@@ -1,16 +1,8 @@
-using JiShe.CollectBus.Common.Encrypt;
-using JiShe.CollectBus.Common.Enums;
-using JiShe.CollectBus.Common.Models;
+using JiShe.CollectBus.Common;
using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
using JiShe.CollectBus.IoTDB.Model;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Volo.Abp.Domain.Entities;
-using Volo.Abp.Domain.Entities.Auditing;
namespace JiShe.CollectBus.IotSystems.MeterReadingRecords
{
@@ -18,6 +10,7 @@ namespace JiShe.CollectBus.IotSystems.MeterReadingRecords
/// 抄读任务数据
///
[EntityType(EntityTypeEnum.TableModel)]
+ [GenerateAccessors]
public class MeterReadingTelemetryPacketInfo : IoTEntity
{
///
diff --git a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
index 1914993..44b8a3e 100644
--- a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
+++ b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
@@ -25,7 +25,7 @@
-
+
diff --git a/shared/JiShe.CollectBus.SourceExtend/GenerateAccessorsAttribute.cs b/shared/JiShe.CollectBus.Common/Attributes/GenerateAccessorsAttribute.cs
similarity index 59%
rename from shared/JiShe.CollectBus.SourceExtend/GenerateAccessorsAttribute.cs
rename to shared/JiShe.CollectBus.Common/Attributes/GenerateAccessorsAttribute.cs
index b739a54..4912185 100644
--- a/shared/JiShe.CollectBus.SourceExtend/GenerateAccessorsAttribute.cs
+++ b/shared/JiShe.CollectBus.Common/Attributes/GenerateAccessorsAttribute.cs
@@ -1,10 +1,6 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-namespace JiShe.CollectBus.SourceExtend
+namespace JiShe.CollectBus.Common
{
///
/// 标记需要生成源码的类
diff --git a/shared/JiShe.CollectBus.Common/JiShe.CollectBus.Common.csproj b/shared/JiShe.CollectBus.Common/JiShe.CollectBus.Common.csproj
index fdb6bfd..6cf0246 100644
--- a/shared/JiShe.CollectBus.Common/JiShe.CollectBus.Common.csproj
+++ b/shared/JiShe.CollectBus.Common/JiShe.CollectBus.Common.csproj
@@ -25,8 +25,7 @@
-
-
+
diff --git a/shared/JiShe.CollectBus.Common/Models/ServerApplicationOptions.cs b/shared/JiShe.CollectBus.Common/Models/ServerApplicationOptions.cs
index 2eb92c5..525b5a2 100644
--- a/shared/JiShe.CollectBus.Common/Models/ServerApplicationOptions.cs
+++ b/shared/JiShe.CollectBus.Common/Models/ServerApplicationOptions.cs
@@ -8,12 +8,12 @@
///
/// 服务器标识
///
- public required string ServerTagName { get; set; }
+ public string ServerTagName { get; set; }
///
/// 系统类型
///
- public required string SystemType { get; set; }
+ public string SystemType { get; set; }
///
/// 首次采集时间
@@ -23,31 +23,31 @@
///
/// 自动验证时间
///
- public required string AutomaticVerificationTime { get; set; }
+ public string AutomaticVerificationTime { get; set; }
///
/// 自动获取终端版时间
///
- public required string AutomaticTerminalVersionTime { get; set; }
+ public string AutomaticTerminalVersionTime { get; set; }
///
/// 自动获取远程通信模块(SIM)版本时间
///
- public required string AutomaticTelematicsModuleTime { get; set; }
+ public string AutomaticTelematicsModuleTime { get; set; }
///
/// 日冻结抄读时间
///
- public required string AutomaticDayFreezeTime { get; set; }
+ public string AutomaticDayFreezeTime { get; set; }
///
/// 月冻结抄读时间
///
- public required string AutomaticMonthFreezeTime { get; set; }
+ public string AutomaticMonthFreezeTime { get; set; }
///
/// 默认协议插件
///
- public required string DefaultProtocolPlugin { get; set; }
+ public string DefaultProtocolPlugin { get; set; }
}
}
diff --git a/shared/JiShe.CollectBus.IncrementalGenerator/ComplexTypeSourceGenerator.cs b/shared/JiShe.CollectBus.IncrementalGenerator/ComplexTypeSourceGenerator.cs
new file mode 100644
index 0000000..1530a2c
--- /dev/null
+++ b/shared/JiShe.CollectBus.IncrementalGenerator/ComplexTypeSourceGenerator.cs
@@ -0,0 +1,223 @@
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Text;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JiShe.CollectBus.IncrementalGenerator
+{
+ ///
+ /// 复杂类型源生成器
+ ///
+ [Generator(LanguageNames.CSharp)]
+ public class ComplexTypeSourceGenerator : IIncrementalGenerator
+ {
+ private const string AttributeFullName = "JiShe.CollectBus.Common.GenerateAccessorsAttribute";
+
+ public void Initialize(IncrementalGeneratorInitializationContext context)
+ {
+
+ Debugger.Launch();
+
+ context.RegisterPostInitializationOutput(ctx =>
+ {
+ ctx.AddSource("DebugInit.g.cs", "// Generator initialized");
+ });
+
+ // 步骤1:筛选带有 [GenerateAccessors] 的类
+ var classDeclarations = context.SyntaxProvider
+ .CreateSyntaxProvider(
+ predicate: static (s, _) => IsClassWithAttribute(s),
+ transform: static (ctx, _) => GetClassDeclaration(ctx))
+ .Where(static c => c is not null);
+
+ // 步骤2:合并编译信息
+ var compilationAndClasses = context.CompilationProvider.Combine(classDeclarations.Collect());
+
+ context.RegisterSourceOutput(compilationAndClasses, (spc, source) =>
+ GenerateCode(source.Left, source.Right!, spc));
+ }
+
+ private static bool IsClassWithAttribute(SyntaxNode node) => node is ClassDeclarationSyntax cds && cds.AttributeLists.Count > 0;
+
+ //private static ClassDeclarationSyntax? GetClassDeclaration(GeneratorSyntaxContext context)
+ //{
+ // var classDecl = (ClassDeclarationSyntax)context.Node;
+ // foreach (var attributeList in classDecl.AttributeLists)
+ // {
+ // foreach (var attribute in attributeList.Attributes)
+ // {
+ // var symbol = context.SemanticModel.GetSymbolInfo(attribute).Symbol;
+ // if (symbol is IMethodSymbol ctor)
+ // {
+ // string sdd = ctor.ContainingType.Name;
+ // var attributeType = context.SemanticModel.Compilation.GetTypeByMetadataName(AttributeFullName);
+ // if (ctor.ContainingType?.OriginalDefinition?.Equals(attributeType, SymbolEqualityComparer.Default) == true)
+ // {
+ // return classDecl;
+ // }
+ // }
+
+ // }
+ // }
+ // return null;
+ //}
+
+ private static ClassDeclarationSyntax? GetClassDeclaration(GeneratorSyntaxContext context)
+ {
+ var classDecl = (ClassDeclarationSyntax)context.Node;
+ var attributeType = context.SemanticModel.Compilation.GetTypeByMetadataName(AttributeFullName);
+
+ foreach (var attribute in classDecl.AttributeLists.SelectMany(al => al.Attributes))
+ {
+ var symbol = context.SemanticModel.GetSymbolInfo(attribute).Symbol;
+ if (symbol is IMethodSymbol ctor &&
+ ctor.ContainingType?.OriginalDefinition?.Equals(attributeType, SymbolEqualityComparer.Default) == true)
+ {
+ return classDecl;
+ }
+ }
+ return null;
+ }
+
+ private static void GenerateCode(
+ Compilation compilation,
+ IEnumerable classes,
+ SourceProductionContext context)
+ {
+ var processedTypes = new HashSet(SymbolEqualityComparer.Default);
+
+
+ foreach (var classDecl in classes.Distinct())
+ {
+ var model = compilation.GetSemanticModel(classDecl.SyntaxTree);
+ var classSymbol = model.GetDeclaredSymbol(classDecl) as INamedTypeSymbol;
+
+ if (classSymbol == null || !processedTypes.Add(classSymbol)) continue;
+
+ context.ReportDiagnostic(Diagnostic.Create(
+ new DiagnosticDescriptor(
+ "PA001",
+ "Generated Accessors",
+ $"Generating accessors for {classSymbol.Name}",
+ "Performance",
+ DiagnosticSeverity.Info,
+ true),
+ Location.None));
+
+ context.ReportDiagnostic(Diagnostic.Create(
+ new DiagnosticDescriptor("PA002", "Class Found",
+ $"Processing class: {classSymbol.Name}", "Debug", DiagnosticSeverity.Warning, true),
+ Location.None));
+
+ var code = BuildAccessorsForType(classSymbol, compilation, processedTypes);
+ context.AddSource($"{classSymbol.Name}Extension.g.cs", SourceText.From(code, Encoding.UTF8));
+ }
+ }
+
+ private static string BuildAccessorsForType(
+ INamedTypeSymbol classSymbol,
+ Compilation compilation,
+ HashSet processedTypes)
+ {
+ var code = new StringBuilder();
+ code.AppendLine("// ");
+ code.AppendLine("#nullable enable");
+ code.AppendLine($"namespace {classSymbol.ContainingNamespace.ToDisplayString()};");
+ code.AppendLine();
+
+ code.AppendLine($"public static class {classSymbol.Name}Extension{GetGenericParams(classSymbol)}");
+ code.AppendLine("{");
+
+ foreach (var prop in classSymbol.GetMembers().OfType())
+ {
+ if (prop.IsIndexer) continue;
+
+ GeneratePropertyAccessors(prop, code, compilation, processedTypes);
+ }
+
+ code.AppendLine("}");
+ return code.ToString();
+ }
+
+ private static string GetGenericParams(INamedTypeSymbol symbol)
+ => symbol.IsGenericType ? $"<{string.Join(", ", symbol.TypeParameters.Select(t => t.Name))}>" : "";
+
+ private static void GeneratePropertyAccessors(
+ IPropertySymbol prop,
+ StringBuilder code,
+ Compilation compilation,
+ HashSet processedTypes)
+ {
+ // 关键修复点1:安全类型转换
+ if (prop.Type is not ITypeSymbol propType) return;
+
+ code.AppendLine($" // Processing property: {prop.Name}");
+
+ // 处理元组类型
+ if (propType is INamedTypeSymbol { IsTupleType: true } tupleType)
+ {
+ GenerateTupleAccessors(prop, tupleType, code);
+ }
+ else if (propType is INamedTypeSymbol namedType)
+ {
+ GenerateStandardAccessors(prop, namedType, code);
+ ProcessNestedType(namedType, compilation, processedTypes);
+ }
+ }
+
+ private static void GenerateTupleAccessors(IPropertySymbol prop, INamedTypeSymbol tupleType, StringBuilder code)
+ {
+ var elements = tupleType.TupleElements;
+ var parentType = prop.ContainingType.ToDisplayString();
+
+ for (int i = 0; i < elements.Length; i++)
+ {
+ var element = elements[i];
+ if (element.Type is not ITypeSymbol elementType) continue;
+
+ var elementName = element.CorrespondingTupleField?.Name ?? $"Item{i + 1}";
+ code.AppendLine($" public static {elementType.ToDisplayString()} Get{prop.Name}_{elementName}({parentType} obj) => obj.{prop.Name}.{elementName};");
+
+ if (prop.SetMethod != null)
+ {
+ var assignments = elements.Select((e, idx) =>
+ idx == i ? "value" : $"obj.{prop.Name}.{e.Name}");
+ code.AppendLine($" public static void Set{prop.Name}_{elementName}({parentType} obj, {elementType.ToDisplayString()} value) => obj.{prop.Name} = ({string.Join(", ", assignments)});");
+ }
+ }
+ }
+
+ private static void GenerateStandardAccessors(IPropertySymbol prop, INamedTypeSymbol propType, StringBuilder code)
+ {
+ var parentType = prop.ContainingType.ToDisplayString();
+ code.AppendLine($" public static {propType.ToDisplayString()} Get{prop.Name}({parentType} obj) => obj.{prop.Name};");
+
+ if (prop.SetMethod != null)
+ {
+ code.AppendLine($" public static void Set{prop.Name}({parentType} obj, {propType.ToDisplayString()} value) => obj.{prop.Name} = value;");
+ }
+ }
+
+ private static void ProcessNestedType(ITypeSymbol typeSymbol, Compilation compilation, HashSet processedTypes)
+ {
+ if (typeSymbol is not INamedTypeSymbol namedType) return;
+ if (!ShouldProcessNestedType(namedType)) return;
+ if (!processedTypes.Add(namedType)) return;
+
+ var code = BuildAccessorsForType(namedType, compilation, processedTypes);
+ }
+
+ private static bool ShouldProcessNestedType(INamedTypeSymbol symbol)
+ {
+ return symbol.DeclaredAccessibility == Accessibility.Public &&
+ !symbol.IsTupleType &&
+ !symbol.IsAnonymousType &&
+ !symbol.IsImplicitlyDeclared &&
+ !symbol.Name.StartsWith("<");
+ }
+ }
+}
\ No newline at end of file
diff --git a/shared/JiShe.CollectBus.IncrementalGenerator/JiShe.CollectBus.IncrementalGenerator.csproj b/shared/JiShe.CollectBus.IncrementalGenerator/JiShe.CollectBus.IncrementalGenerator.csproj
new file mode 100644
index 0000000..c36ce2b
--- /dev/null
+++ b/shared/JiShe.CollectBus.IncrementalGenerator/JiShe.CollectBus.IncrementalGenerator.csproj
@@ -0,0 +1,14 @@
+
+
+
+ enable
+ netstandard2.0
+
+ true
+ latest
+
+
+
+
+
+
diff --git a/shared/JiShe.CollectBus.SourceExtend/ComplexTypeSourceGenerator.cs b/shared/JiShe.CollectBus.SourceExtend/ComplexTypeSourceGenerator.cs
deleted file mode 100644
index 352cd4a..0000000
--- a/shared/JiShe.CollectBus.SourceExtend/ComplexTypeSourceGenerator.cs
+++ /dev/null
@@ -1,187 +0,0 @@
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Text;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace JiShe.CollectBus.SourceExtend
-{
- ///
- /// 复杂类型源生成器
- ///
- [Generator]
- public sealed class PropertyAccessorGenerator : IIncrementalGenerator
- {
- private const string AttributeName = "GenerateAccessors";
-
- public void Initialize(IncrementalGeneratorInitializationContext context)
- {
- // 步骤1:筛选带有 [GenerateAccessors] 的类
- var classDeclarations = context.SyntaxProvider
- .CreateSyntaxProvider(
- predicate: static (s, _) => IsClassWithAttribute(s),
- transform: static (ctx, _) => GetClassDeclaration(ctx))
- .Where(static c => c is not null);
-
- // 步骤2:编译符号并生成代码
- var compilationAndClasses = context.CompilationProvider.Combine(classDeclarations.Collect());
-
- context.RegisterSourceOutput(compilationAndClasses, (spc, source) =>
- GenerateCode(source.Left, source.Right!, spc));
- }
-
- private static bool IsClassWithAttribute(SyntaxNode node)
- {
- return node is ClassDeclarationSyntax { AttributeLists.Count: > 0 };
- }
-
- private static ClassDeclarationSyntax? GetClassDeclaration(GeneratorSyntaxContext context)
- {
- var classDecl = (ClassDeclarationSyntax)context.Node;
- foreach (var attributeList in classDecl.AttributeLists)
- {
- foreach (var attribute in attributeList.Attributes)
- {
- var symbol = context.SemanticModel.GetSymbolInfo(attribute).Symbol;
- if (symbol?.ContainingType.ToDisplayString() == $"{nameof(PropertyAccessorGenerator)}.{AttributeName}")
- {
- return classDecl;
- }
- }
- }
- return null;
- }
-
- private static void GenerateCode(
- Compilation compilation,
- IEnumerable classes,
- SourceProductionContext context)
- {
- var processedTypes = new HashSet(SymbolEqualityComparer.Default);
-
- foreach (var classDecl in classes.Distinct())
- {
- var model = compilation.GetSemanticModel(classDecl.SyntaxTree);
- var classSymbol = model.GetDeclaredSymbol(classDecl)!;
-
- if (!processedTypes.Add(classSymbol)) continue;
-
- var code = BuildAccessorsForType(classSymbol, compilation, processedTypes);
- context.AddSource($"{classSymbol.Name}Accessors.g.cs", code);
- }
- }
-
- private static string BuildAccessorsForType(
- INamedTypeSymbol classSymbol,
- Compilation compilation,
- HashSet processedTypes)
- {
- var code = new StringBuilder();
- code.AppendLine("// ");
- code.AppendLine("#nullable enable");
- code.AppendLine();
- code.AppendLine($"namespace {classSymbol.ContainingNamespace.ToDisplayString()};");
- code.AppendLine();
-
- // 处理泛型参数
- var genericParams = classSymbol.IsGenericType
- ? $"<{string.Join(", ", classSymbol.TypeParameters.Select(t => t.Name))}>"
- : "";
-
- code.AppendLine($"public static class {classSymbol.Name}Accessors{genericParams}");
- code.AppendLine("{");
-
- foreach (var prop in classSymbol.GetMembers().OfType())
- {
- if (prop.IsIndexer) continue;
-
- GeneratePropertyAccessors(prop, code, compilation, processedTypes);
- }
-
- code.AppendLine("}");
- return code.ToString();
- }
-
- private static void GeneratePropertyAccessors(
- IPropertySymbol prop,
- StringBuilder code,
- Compilation compilation,
- HashSet processedTypes)
- {
- var propType = prop.Type;
- var parentType = prop.ContainingType.ToDisplayString();
-
- // 处理元组类型
- if (propType.IsTupleType && propType is INamedTypeSymbol tupleType)
- {
- GenerateTupleAccessors(prop, tupleType, code);
- }
- else if (propType is INamedTypeSymbol namedType)
- {
- GenerateStandardAccessors(prop, namedType, code);
- ProcessNestedType(namedType, compilation, processedTypes);
- }
- }
-
- private static void GenerateTupleAccessors(IPropertySymbol prop, INamedTypeSymbol tupleType, StringBuilder code)
- {
- var elements = tupleType.TupleElements;
- var parentType = prop.ContainingType.ToDisplayString();
-
- for (int i = 0; i < elements.Length; i++)
- {
- var element = elements[i];
- var elementType = element.Type.ToDisplayString();
- var elementName = element.CorrespondingTupleField?.Name ?? $"Item{i + 1}";
-
- code.AppendLine($" public static {elementType} Get{prop.Name}_{elementName}({parentType} obj)");
- code.AppendLine($" => obj.{prop.Name}.{elementName};");
-
- if (prop.SetMethod != null)
- {
- var assignments = elements.Select((e, idx) =>
- idx == i ? "value" : $"obj.{prop.Name}.{e.Name}");
-
- code.AppendLine($" public static void Set{prop.Name}_{elementName}({parentType} obj, {elementType} value)");
- code.AppendLine($" => obj.{prop.Name} = ({string.Join(", ", assignments)});");
- }
- }
- }
-
- private static void GenerateStandardAccessors(IPropertySymbol prop, INamedTypeSymbol propType, StringBuilder code)
- {
- var typeName = propType.ToDisplayString();
- var parentType = prop.ContainingType.ToDisplayString();
-
- code.AppendLine($" public static {typeName} Get{prop.Name}({parentType} obj)");
- code.AppendLine($" => obj.{prop.Name};");
-
- if (prop.SetMethod != null)
- {
- code.AppendLine($" public static void Set{prop.Name}({parentType} obj, {typeName} value)");
- code.AppendLine($" => obj.{prop.Name} = value;");
- }
- }
-
- private static void ProcessNestedType(INamedTypeSymbol typeSymbol, Compilation compilation, HashSet processedTypes)
- {
- if (ShouldGenerateForType(typeSymbol) && processedTypes.Add(typeSymbol))
- {
- var code = BuildAccessorsForType(typeSymbol, compilation, processedTypes);
- // 注意:实际项目中需要通过 SourceProductionContext 添加源代码
- }
- }
-
- private static bool ShouldGenerateForType(INamedTypeSymbol typeSymbol)
- {
- return !typeSymbol.IsTupleType &&
- !typeSymbol.IsAnonymousType &&
- !typeSymbol.IsNativeIntegerType &&
- typeSymbol.DeclaredAccessibility == Accessibility.Public &&
- !typeSymbol.Name.StartsWith("<");
- }
- }
-}
\ No newline at end of file
diff --git a/shared/JiShe.CollectBus.SourceExtend/JiShe.CollectBus.SourceExtend.csproj b/shared/JiShe.CollectBus.SourceExtend/JiShe.CollectBus.SourceExtend.csproj
deleted file mode 100644
index a06bde8..0000000
--- a/shared/JiShe.CollectBus.SourceExtend/JiShe.CollectBus.SourceExtend.csproj
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
- netstandard2.1
- 12.0
- enable
- true
-
-
-
-
-
diff --git a/web/JiShe.CollectBus.Host/JiShe.CollectBus.Host.csproj b/web/JiShe.CollectBus.Host/JiShe.CollectBus.Host.csproj
index 4ebd67d..5501841 100644
--- a/web/JiShe.CollectBus.Host/JiShe.CollectBus.Host.csproj
+++ b/web/JiShe.CollectBus.Host/JiShe.CollectBus.Host.csproj
@@ -5,7 +5,7 @@
enable
enable
True
-
+
@@ -55,9 +55,9 @@
-
-
-
+
+
+
From d18f60f9a799a298a240133db36b89c2c1a4267d Mon Sep 17 00:00:00 2001
From: ChenYi <296215406@outlook.com>
Date: Mon, 28 Apr 2025 16:37:31 +0800
Subject: [PATCH 3/8] =?UTF-8?q?=E8=A7=A3=E5=86=B3IoTDB=E5=86=99=E5=85=A5?=
=?UTF-8?q?=E9=80=9F=E5=BA=A6=E8=BF=87=E6=85=A2=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../JiShe.CollectBus.IoTDB.csproj | 2 +
.../JiShe.CollectBus.IoTDB/Model/IoTEntity.cs | 5 +-
.../Options/IoTDBOptions.cs | 2 +-
.../Provider/SessionPoolAdapter.cs | 2 +-
.../Provider/TableSessionPoolAdapter.cs | 2 +-
.../CollectBusApplicationModule.cs | 19 +++--
.../JiShe.CollectBus.Application.csproj | 5 +-
.../BasicScheduledMeterReadingService.cs | 79 +++++++++----------
...nergySystemScheduledMeterReadingService.cs | 4 +-
.../MeterReadingTelemetryPacketInfo.cs | 7 +-
.../JiShe.CollectBus.Domain.csproj | 4 +-
.../ComplexTypeSourceGenerator.cs | 62 ++++++++-------
...She.CollectBus.IncrementalGenerator.csproj | 21 ++++-
web/JiShe.CollectBus.Host/appsettings.json | 10 +--
14 files changed, 127 insertions(+), 97 deletions(-)
diff --git a/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj b/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
index 0e8250e..c24a807 100644
--- a/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
+++ b/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
@@ -11,5 +11,7 @@
+
+
diff --git a/modules/JiShe.CollectBus.IoTDB/Model/IoTEntity.cs b/modules/JiShe.CollectBus.IoTDB/Model/IoTEntity.cs
index a079bd4..48bc248 100644
--- a/modules/JiShe.CollectBus.IoTDB/Model/IoTEntity.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Model/IoTEntity.cs
@@ -1,9 +1,10 @@
-using JiShe.CollectBus.IoTDB.Attribute;
+using JiShe.CollectBus.Common.Attributes;
+using JiShe.CollectBus.IoTDB.Attribute;
namespace JiShe.CollectBus.IoTDB.Model
{
///
- /// IoT实体基类,此类适用于多个数据测点记录场景,单个测点请使用子类 SingleMeasuring
+ /// IoT实体基类,此类适用于多个数据测点记录场景,单个测点请使用子类 SingleMeasuring,新增字段只能现有字段末尾添加,否则会导致数据写入失败。
///
public abstract class IoTEntity
{
diff --git a/modules/JiShe.CollectBus.IoTDB/Options/IoTDBOptions.cs b/modules/JiShe.CollectBus.IoTDB/Options/IoTDBOptions.cs
index 251e48b..68b2770 100644
--- a/modules/JiShe.CollectBus.IoTDB/Options/IoTDBOptions.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Options/IoTDBOptions.cs
@@ -26,7 +26,7 @@
///
/// 连接池大小
///
- public int PoolSize { get; set; } = 2;
+ public int PoolSize { get; set; } = 8;
///
/// 查询时,每次查询的数据量,默认1024
diff --git a/modules/JiShe.CollectBus.IoTDB/Provider/SessionPoolAdapter.cs b/modules/JiShe.CollectBus.IoTDB/Provider/SessionPoolAdapter.cs
index ee71cf1..26ea4c7 100644
--- a/modules/JiShe.CollectBus.IoTDB/Provider/SessionPoolAdapter.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Provider/SessionPoolAdapter.cs
@@ -70,7 +70,7 @@ namespace JiShe.CollectBus.IoTDB.Provider
var result = await _sessionPool.InsertAlignedTabletAsync(tablet);
if (result != 0)
{
- throw new Exception($"{nameof(SessionPoolAdapter)} Tree模型数据入库没有成功,返回结果为:{result}");
+ throw new Exception($"{nameof(SessionPoolAdapter)} Tree模型数据入库没有成功,返回结果为:{result},请检查IoTEntity继承子类属性索引是否有变动。");
}
//await CloseAsync();
return result;
diff --git a/modules/JiShe.CollectBus.IoTDB/Provider/TableSessionPoolAdapter.cs b/modules/JiShe.CollectBus.IoTDB/Provider/TableSessionPoolAdapter.cs
index dc4f0ee..8edb112 100644
--- a/modules/JiShe.CollectBus.IoTDB/Provider/TableSessionPoolAdapter.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Provider/TableSessionPoolAdapter.cs
@@ -68,7 +68,7 @@ namespace JiShe.CollectBus.IoTDB.Provider
var result = await _sessionPool.InsertAsync(tablet);
if (result != 0)
{
- throw new Exception($"{nameof(TableSessionPoolAdapter)} table模型数据入库没有成功,返回结果为:{result}");
+ throw new Exception($"{nameof(TableSessionPoolAdapter)} table模型数据入库没有成功,返回结果为:{result},请检查IoTEntity继承子类属性索引是否有变动。");
}
//await CloseAsync();
diff --git a/services/JiShe.CollectBus.Application/CollectBusApplicationModule.cs b/services/JiShe.CollectBus.Application/CollectBusApplicationModule.cs
index ce2e5aa..8b3da38 100644
--- a/services/JiShe.CollectBus.Application/CollectBusApplicationModule.cs
+++ b/services/JiShe.CollectBus.Application/CollectBusApplicationModule.cs
@@ -66,12 +66,17 @@ public class CollectBusApplicationModule : AbpModule
.ToList();
foreach (var type in types) await context.AddBackgroundWorkerAsync(type);
- Task.Run(() =>
- {
- //默认初始化表计信息
- var dbContext = context.ServiceProvider.GetRequiredService();
- dbContext.InitAmmeterCacheData();
- //await dbContext.InitWatermeterCacheData();
- }).ConfigureAwait(false);
+ //Task.Run(() =>
+ //{
+ // //默认初始化表计信息
+ // var dbContext = context.ServiceProvider.GetRequiredService();
+ // dbContext.InitAmmeterCacheData();
+ // //await dbContext.InitWatermeterCacheData();
+ //}).ConfigureAwait(false);
+
+
+ //默认初始化表计信息
+ var dbContext = context.ServiceProvider.GetRequiredService();
+ _= dbContext.InitAmmeterCacheData();
}
}
\ No newline at end of file
diff --git a/services/JiShe.CollectBus.Application/JiShe.CollectBus.Application.csproj b/services/JiShe.CollectBus.Application/JiShe.CollectBus.Application.csproj
index b43d994..b9d899c 100644
--- a/services/JiShe.CollectBus.Application/JiShe.CollectBus.Application.csproj
+++ b/services/JiShe.CollectBus.Application/JiShe.CollectBus.Application.csproj
@@ -23,15 +23,14 @@
-
+
-
-
+
diff --git a/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs b/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs
index 5a7ef51..0b5f28a 100644
--- a/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs
+++ b/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs
@@ -286,52 +286,51 @@ namespace JiShe.CollectBus.ScheduledMeterReading
public virtual async Task InitAmmeterCacheData(string gatherCode = "")
{
//此处代码不要删除
- //#if DEBUG
- // var timeDensity = "15";
- // var redisCacheMeterInfoHashKeyTemp = $"{string.Format(RedisConst.CacheMeterInfoHashKey, SystemType, "JiSheCollectBus2", MeterTypeEnum.Ammeter, timeDensity)}";
- // var redisCacheMeterInfoSetIndexKeyTemp = $"{string.Format(RedisConst.CacheMeterInfoSetIndexKey, SystemType, "JiSheCollectBus2", MeterTypeEnum.Ammeter, timeDensity)}";
- // var redisCacheMeterInfoZSetScoresIndexKeyTemp = $"{string.Format(RedisConst.CacheMeterInfoZSetScoresIndexKey, SystemType, "JiSheCollectBus2", MeterTypeEnum.Ammeter, timeDensity)}";
+#if DEBUG
+ var timeDensity = "15";
+ var redisCacheMeterInfoHashKeyTemp = $"{string.Format(RedisConst.CacheMeterInfoHashKey, SystemType, "JiSheCollectBus2", MeterTypeEnum.Ammeter, timeDensity)}";
+ var redisCacheMeterInfoSetIndexKeyTemp = $"{string.Format(RedisConst.CacheMeterInfoSetIndexKey, SystemType, "JiSheCollectBus2", MeterTypeEnum.Ammeter, timeDensity)}";
+ var redisCacheMeterInfoZSetScoresIndexKeyTemp = $"{string.Format(RedisConst.CacheMeterInfoZSetScoresIndexKey, SystemType, "JiSheCollectBus2", MeterTypeEnum.Ammeter, timeDensity)}";
- // List meterInfos = new List();
- // List focusAddressDataLista = new List();
- // var timer1 = Stopwatch.StartNew();
+ List meterInfos = new List();
+ List focusAddressDataLista = new List();
+ var timer1 = Stopwatch.StartNew();
- // var allIds = new HashSet();
- // decimal? score = null;
- // string member = null;
+ var allIds = new HashSet();
+ decimal? score = null;
+ string member = null;
- // while (true)
- // {
- // var page = await _redisDataCacheService.GetAllPagedData(
- // redisCacheMeterInfoHashKeyTemp,
- // redisCacheMeterInfoZSetScoresIndexKeyTemp,
- // pageSize: 1000,
- // lastScore: score,
- // lastMember: member);
+ while (true)
+ {
+ var page = await _redisDataCacheService.GetAllPagedData(
+ redisCacheMeterInfoHashKeyTemp,
+ redisCacheMeterInfoZSetScoresIndexKeyTemp,
+ pageSize: 1000,
+ lastScore: score,
+ lastMember: member);
- // meterInfos.AddRange(page.Items);
- // focusAddressDataLista.AddRange(page.Items.Select(d => d.FocusAddress));
- // foreach (var item in page.Items)
- // {
- // if (!allIds.Add(item.MemberId))
- // {
- // _logger.LogError($"{item.MemberId}Duplicate data found!");
- // }
- // }
- // if (!page.HasNext) break;
- // score = page.NextScore;
- // member = page.NextMember;
- // }
+ meterInfos.AddRange(page.Items);
+ focusAddressDataLista.AddRange(page.Items.Select(d => d.FocusAddress));
+ foreach (var item in page.Items)
+ {
+ if (!allIds.Add(item.MemberId))
+ {
+ _logger.LogError($"{item.MemberId}Duplicate data found!");
+ }
+ }
+ if (!page.HasNext) break;
+ score = page.NextScore;
+ member = page.NextMember;
+ }
- // timer1.Stop();
- // _logger.LogError($"读取数据总共花费时间{timer1.ElapsedMilliseconds}毫秒");
- // DeviceGroupBalanceControl.InitializeCache(focusAddressDataLista, _kafkaOptions.NumPartitions);
- // return;
- //#else
- // var meterInfos = await GetAmmeterInfoList(gatherCode);
- //#endif
- var meterInfos = await GetAmmeterInfoList(gatherCode);
+ timer1.Stop();
+ _logger.LogError($"读取数据总共花费时间{timer1.ElapsedMilliseconds}毫秒");
+ DeviceGroupBalanceControl.InitializeCache(focusAddressDataLista, _kafkaOptions.NumPartitions);
+ return;
+#else
+ var meterInfos = await GetAmmeterInfoList(gatherCode);
+#endif
if (meterInfos == null || meterInfos.Count <= 0)
{
throw new NullReferenceException($"{nameof(InitAmmeterCacheData)} 初始化电表缓存数据时,电表数据为空");
diff --git a/services/JiShe.CollectBus.Application/ScheduledMeterReading/EnergySystemScheduledMeterReadingService.cs b/services/JiShe.CollectBus.Application/ScheduledMeterReading/EnergySystemScheduledMeterReadingService.cs
index b0b6bba..883537c 100644
--- a/services/JiShe.CollectBus.Application/ScheduledMeterReading/EnergySystemScheduledMeterReadingService.cs
+++ b/services/JiShe.CollectBus.Application/ScheduledMeterReading/EnergySystemScheduledMeterReadingService.cs
@@ -35,6 +35,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
//[Route($"/energy/app/scheduled")]
public class EnergySystemScheduledMeterReadingService : BasicScheduledMeterReadingService
{
+ string systemType = string.Empty;
string serverTagName = string.Empty;
private readonly ILogger _logger;
private readonly IIoTDbProvider _dbProvider;
@@ -59,12 +60,13 @@ namespace JiShe.CollectBus.ScheduledMeterReading
applicationOptions)
{
serverTagName = applicationOptions.Value.ServerTagName;
+ systemType = applicationOptions.Value.SystemType;
_dbProvider = dbProvider;
_logger = logger;
_protocolService = protocolService;
}
- public sealed override string SystemType => SystemTypeConst.Energy;
+ public sealed override string SystemType => systemType;
public sealed override string ServerTagName => serverTagName;
diff --git a/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs b/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs
index 552084f..4d406b8 100644
--- a/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs
+++ b/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs
@@ -1,4 +1,5 @@
using JiShe.CollectBus.Common;
+using JiShe.CollectBus.Common.Attributes;
using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
using JiShe.CollectBus.IoTDB.Model;
@@ -18,7 +19,7 @@ namespace JiShe.CollectBus.IotSystems.MeterReadingRecords
///
[FIELDColumn]
public string ScoreValue { get; set; }
-
+
///
/// 是否手动操作
///
@@ -89,6 +90,7 @@ namespace JiShe.CollectBus.IotSystems.MeterReadingRecords
///
/// 抄读计量点
///
+ [FIELDColumn]
public int Pn { get; set; }
///
@@ -107,6 +109,7 @@ namespace JiShe.CollectBus.IotSystems.MeterReadingRecords
///
/// 帧序列域 SEQ
///
+ [FIELDColumn]
public int Seq { get; set; }
///
@@ -125,7 +128,7 @@ namespace JiShe.CollectBus.IotSystems.MeterReadingRecords
/// 发送次数
///
[FIELDColumn]
- public int SendNum { get; set; }
+ public int? SendNum { get; set; }
///
/// 下次发送时间
diff --git a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
index 44b8a3e..d7804a6 100644
--- a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
+++ b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
@@ -23,8 +23,10 @@
-
+
+
+
diff --git a/shared/JiShe.CollectBus.IncrementalGenerator/ComplexTypeSourceGenerator.cs b/shared/JiShe.CollectBus.IncrementalGenerator/ComplexTypeSourceGenerator.cs
index 1530a2c..6b0982e 100644
--- a/shared/JiShe.CollectBus.IncrementalGenerator/ComplexTypeSourceGenerator.cs
+++ b/shared/JiShe.CollectBus.IncrementalGenerator/ComplexTypeSourceGenerator.cs
@@ -20,12 +20,13 @@ namespace JiShe.CollectBus.IncrementalGenerator
public void Initialize(IncrementalGeneratorInitializationContext context)
{
- Debugger.Launch();
+ //Debugger.Launch();
context.RegisterPostInitializationOutput(ctx =>
{
ctx.AddSource("DebugInit.g.cs", "// Generator initialized");
});
+
// 步骤1:筛选带有 [GenerateAccessors] 的类
var classDeclarations = context.SyntaxProvider
@@ -42,29 +43,7 @@ namespace JiShe.CollectBus.IncrementalGenerator
}
private static bool IsClassWithAttribute(SyntaxNode node) => node is ClassDeclarationSyntax cds && cds.AttributeLists.Count > 0;
-
- //private static ClassDeclarationSyntax? GetClassDeclaration(GeneratorSyntaxContext context)
- //{
- // var classDecl = (ClassDeclarationSyntax)context.Node;
- // foreach (var attributeList in classDecl.AttributeLists)
- // {
- // foreach (var attribute in attributeList.Attributes)
- // {
- // var symbol = context.SemanticModel.GetSymbolInfo(attribute).Symbol;
- // if (symbol is IMethodSymbol ctor)
- // {
- // string sdd = ctor.ContainingType.Name;
- // var attributeType = context.SemanticModel.Compilation.GetTypeByMetadataName(AttributeFullName);
- // if (ctor.ContainingType?.OriginalDefinition?.Equals(attributeType, SymbolEqualityComparer.Default) == true)
- // {
- // return classDecl;
- // }
- // }
-
- // }
- // }
- // return null;
- //}
+
private static ClassDeclarationSyntax? GetClassDeclaration(GeneratorSyntaxContext context)
{
@@ -75,7 +54,7 @@ namespace JiShe.CollectBus.IncrementalGenerator
{
var symbol = context.SemanticModel.GetSymbolInfo(attribute).Symbol;
if (symbol is IMethodSymbol ctor &&
- ctor.ContainingType?.OriginalDefinition?.Equals(attributeType, SymbolEqualityComparer.Default) == true)
+ SymbolEqualityComparer.Default.Equals(ctor.ContainingType, attributeType))
{
return classDecl;
}
@@ -89,14 +68,28 @@ namespace JiShe.CollectBus.IncrementalGenerator
SourceProductionContext context)
{
var processedTypes = new HashSet(SymbolEqualityComparer.Default);
-
+
+ if (!classes.Any())
+ {
+ context.ReportDiagnostic(Diagnostic.Create(
+ new DiagnosticDescriptor("GEN002", "No Targets",
+ "No classes with [GenerateAccessors] found", "Debug", DiagnosticSeverity.Warning, true),
+ Location.None));
+ }
foreach (var classDecl in classes.Distinct())
{
var model = compilation.GetSemanticModel(classDecl.SyntaxTree);
var classSymbol = model.GetDeclaredSymbol(classDecl) as INamedTypeSymbol;
- if (classSymbol == null || !processedTypes.Add(classSymbol)) continue;
+ if (classSymbol == null || !processedTypes.Add(classSymbol))
+ {
+ context.ReportDiagnostic(Diagnostic.Create(
+ new DiagnosticDescriptor("GEN003", "Invalid Symbol",
+ $"Class symbol is null for {classDecl.Identifier.Text}", "Error", DiagnosticSeverity.Error, true),
+ Location.None));
+ continue;
+ }
context.ReportDiagnostic(Diagnostic.Create(
new DiagnosticDescriptor(
@@ -114,6 +107,9 @@ namespace JiShe.CollectBus.IncrementalGenerator
Location.None));
var code = BuildAccessorsForType(classSymbol, compilation, processedTypes);
+
+ System.Diagnostics.Debug.WriteLine($"Generated code for {classSymbol.Name}:\n{code}"); // 调试输出
+
context.AddSource($"{classSymbol.Name}Extension.g.cs", SourceText.From(code, Encoding.UTF8));
}
}
@@ -124,6 +120,8 @@ namespace JiShe.CollectBus.IncrementalGenerator
HashSet processedTypes)
{
var code = new StringBuilder();
+ code.AppendLine("#pragma warning disable CS0419 // 禁用警告");
+ code.AppendLine("// Generated code for " + classSymbol.Name);
code.AppendLine("// ");
code.AppendLine("#nullable enable");
code.AppendLine($"namespace {classSymbol.ContainingNamespace.ToDisplayString()};");
@@ -143,8 +141,14 @@ namespace JiShe.CollectBus.IncrementalGenerator
return code.ToString();
}
- private static string GetGenericParams(INamedTypeSymbol symbol)
- => symbol.IsGenericType ? $"<{string.Join(", ", symbol.TypeParameters.Select(t => t.Name))}>" : "";
+ //private static string GetGenericParams(INamedTypeSymbol symbol)
+ // => symbol.IsGenericType ? $"<{string.Join(", ", symbol.TypeParameters.Select(t => t.Name))}>" : "";
+ public static string GetGenericParams(INamedTypeSymbol symbol)
+ {
+ if (!symbol.IsGenericType) return "";
+ var parameters = symbol.TypeParameters.Select(t => t.Name);
+ return $"<{string.Join(", ", parameters)}>";
+ }
private static void GeneratePropertyAccessors(
IPropertySymbol prop,
diff --git a/shared/JiShe.CollectBus.IncrementalGenerator/JiShe.CollectBus.IncrementalGenerator.csproj b/shared/JiShe.CollectBus.IncrementalGenerator/JiShe.CollectBus.IncrementalGenerator.csproj
index c36ce2b..533676e 100644
--- a/shared/JiShe.CollectBus.IncrementalGenerator/JiShe.CollectBus.IncrementalGenerator.csproj
+++ b/shared/JiShe.CollectBus.IncrementalGenerator/JiShe.CollectBus.IncrementalGenerator.csproj
@@ -1,14 +1,27 @@
- enable
- netstandard2.0
-
- true
+ net8.0
+ true
+ true
+ false
+ bin
+ false
latest
+ true
+ true
+
+ Generated
+ enable
+
+
+
+ true
+ all
+
diff --git a/web/JiShe.CollectBus.Host/appsettings.json b/web/JiShe.CollectBus.Host/appsettings.json
index e8b49d2..f0effb4 100644
--- a/web/JiShe.CollectBus.Host/appsettings.json
+++ b/web/JiShe.CollectBus.Host/appsettings.json
@@ -5,7 +5,7 @@
"Serilog.Sinks.File"
],
"MinimumLevel": {
- "Default": "Warning",
+ "Default": "Information",
"Override": {
"Microsoft": "Warning",
"Volo.Abp": "Warning",
@@ -87,7 +87,7 @@
"UserName": "root",
"Password": "root",
"ClusterList": [ "192.168.1.9:6667" ],
- "PoolSize": 2,
+ "PoolSize": 32,
"DataBaseName": "energy",
"OpenDebugMode": true,
"UseTableSessionPoolByDefault": false
@@ -142,9 +142,9 @@
}
},
"ServerApplicationOptions": {
- "ServerTagName": "JiSheCollectBus100",
- "SystemType": null,
- "FirstCollectionTime": "2025-04-22 16:07:00",
+ "ServerTagName": "JiSheCollectBus4",
+ "SystemType": "Energy",
+ "FirstCollectionTime": "2025-04-28 15:07:00",
"AutomaticVerificationTime": "16:07:00",
"AutomaticTerminalVersionTime": "17:07:00",
"AutomaticTelematicsModuleTime": "17:30:00",
From 1c1ad56408b11edabfd4af1a2209a0119ba807ac Mon Sep 17 00:00:00 2001
From: ChenYi <296215406@outlook.com>
Date: Mon, 28 Apr 2025 17:01:28 +0800
Subject: [PATCH 4/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../JiShe.CollectBus.Domain.csproj | 4 +-
.../JiShe.CollectBus.Domain.Shared.csproj | 56 +++++++++----------
2 files changed, 28 insertions(+), 32 deletions(-)
diff --git a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
index d7804a6..8976bb5 100644
--- a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
+++ b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
@@ -1,7 +1,5 @@
-
-
-
+
net8.0
enable
diff --git a/shared/JiShe.CollectBus.Domain.Shared/JiShe.CollectBus.Domain.Shared.csproj b/shared/JiShe.CollectBus.Domain.Shared/JiShe.CollectBus.Domain.Shared.csproj
index 874b688..d513989 100644
--- a/shared/JiShe.CollectBus.Domain.Shared/JiShe.CollectBus.Domain.Shared.csproj
+++ b/shared/JiShe.CollectBus.Domain.Shared/JiShe.CollectBus.Domain.Shared.csproj
@@ -1,38 +1,36 @@
-
+
+ net8.0
+ enable
+ JiShe.CollectBus
+ true
+
-
- net8.0
- enable
- JiShe.CollectBus
- true
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
From 0b2f2447c5fc1d7351805ec782d06115288e199e Mon Sep 17 00:00:00 2001
From: ChenYi <296215406@outlook.com>
Date: Mon, 28 Apr 2025 17:45:00 +0800
Subject: [PATCH 5/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Samples/SampleAppService.cs | 2 +-
.../Ammeters/ElectricityMeter.cs | 2 +
...eadingTelemetryPacketInfoExtensionddd.g.cs | 110 ++++++++++++++++++
.../ComplexTypeSourceGenerator.cs | 39 ++++++-
4 files changed, 148 insertions(+), 5 deletions(-)
create mode 100644 services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfoExtensionddd.g.cs
diff --git a/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs b/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs
index 6392b83..a96080d 100644
--- a/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs
+++ b/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs
@@ -66,7 +66,7 @@ public class SampleAppService : CollectBusAppService, ISampleAppService, IKafkaS
IssuedMessageHexString = "messageHexString",
Timestamps = testTime// DateTimeOffset.UtcNow.ToUnixTimeNanoseconds()//testTime.GetDateTimeOffset().ToUnixTimeNanoseconds(),
};
-
+ //ElectricityMeterTreeModelExtension
await _iotDBProvider.InsertAsync(meter);
}
diff --git a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs
index ee132d3..186b200 100644
--- a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs
+++ b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using JiShe.CollectBus.Common;
using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
using JiShe.CollectBus.IoTDB.Model;
@@ -10,6 +11,7 @@ using JiShe.CollectBus.IoTDB.Model;
namespace JiShe.CollectBus.Ammeters
{
[EntityType(EntityTypeEnum.TableModel)]
+ [GenerateAccessors]
public class ElectricityMeter : IoTEntity
{
[ATTRIBUTEColumn]
diff --git a/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfoExtensionddd.g.cs b/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfoExtensionddd.g.cs
new file mode 100644
index 0000000..8319b3a
--- /dev/null
+++ b/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfoExtensionddd.g.cs
@@ -0,0 +1,110 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JiShe.CollectBus.IotSystems.MeterReadingRecords;
+
+public static class MeterReadingTelemetryPacketInfoExtension
+{
+ // Processing property: ScoreValue
+ public static string GetScoreValue(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.ScoreValue;
+ public static void SetScoreValue(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.ScoreValue = value;
+ // Processing property: ManualOrNot
+ public static bool GetManualOrNot(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.ManualOrNot;
+ public static void SetManualOrNot(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, bool value) => obj.ManualOrNot = value;
+ // Processing property: TaskMark
+ public static string GetTaskMark(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.TaskMark;
+ public static void SetTaskMark(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.TaskMark = value;
+ // Processing property: IsTimeout
+ public static bool GetIsTimeout(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.IsTimeout;
+ public static void SetIsTimeout(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, bool value) => obj.IsTimeout = value;
+ // Processing property: PendingCopyReadTime
+ public static System.DateTime GetPendingCopyReadTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.PendingCopyReadTime;
+ public static void SetPendingCopyReadTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, System.DateTime value) => obj.PendingCopyReadTime = value;
+ // Processing property: FocusId
+ public static int GetFocusId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.FocusId;
+ public static void SetFocusId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.FocusId = value;
+ // Processing property: FocusAddress
+ public static string GetFocusAddress(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.FocusAddress;
+ public static void SetFocusAddress(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.FocusAddress = value;
+ // Processing property: MeterId
+ public static int GetMeterId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.MeterId;
+ public static void SetMeterId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.MeterId = value;
+ // Processing property: MeterAddress
+ public static string GetMeterAddress(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.MeterAddress;
+ public static void SetMeterAddress(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.MeterAddress = value;
+ // Processing property: DatabaseBusiID
+ public static int GetDatabaseBusiID(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.DatabaseBusiID;
+ public static void SetDatabaseBusiID(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.DatabaseBusiID = value;
+ // Processing property: AFN
+ public static int GetAFN(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.AFN;
+ public static void SetAFN(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.AFN = value;
+ // Processing property: Fn
+ public static int GetFn(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.Fn;
+ public static void SetFn(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.Fn = value;
+ // Processing property: Pn
+ public static int GetPn(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.Pn;
+ public static void SetPn(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.Pn = value;
+ // Processing property: ItemCode
+ public static string GetItemCode(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.ItemCode;
+ public static void SetItemCode(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.ItemCode = value;
+ // Processing property: SubItemCode
+ public static string GetSubItemCode(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.SubItemCode;
+ public static void SetSubItemCode(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.SubItemCode = value;
+ // Processing property: Seq
+ public static int GetSeq(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.Seq;
+ public static void SetSeq(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.Seq = value;
+ // Processing property: MSA
+ public static int GetMSA(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.MSA;
+ public static void SetMSA(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.MSA = value;
+ // Processing property: IsSend
+ public static bool GetIsSend(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.IsSend;
+ public static void SetIsSend(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, bool value) => obj.IsSend = value;
+ // Processing property: SendNum
+ public static int? GetSendNum(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.SendNum;
+ public static void SetSendNum(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int? value) => obj.SendNum = value;
+ // Processing property: NextSendTime
+ public static System.DateTime? GetNextSendTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.NextSendTime;
+ public static void SetNextSendTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, System.DateTime? value) => obj.NextSendTime = value;
+ // Processing property: CreationTime
+ public static System.DateTime GetCreationTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.CreationTime;
+ public static void SetCreationTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, System.DateTime value) => obj.CreationTime = value;
+ // Processing property: IssuedMessageHexString
+ public static string GetIssuedMessageHexString(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.IssuedMessageHexString;
+ public static void SetIssuedMessageHexString(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.IssuedMessageHexString = value;
+ // Processing property: IssuedMessageId
+ public static string GetIssuedMessageId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.IssuedMessageId;
+ public static void SetIssuedMessageId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.IssuedMessageId = value;
+ // Processing property: ReceivedMessageHexString
+ public static string? GetReceivedMessageHexString(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.ReceivedMessageHexString;
+ public static void SetReceivedMessageHexString(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string? value) => obj.ReceivedMessageHexString = value;
+ // Processing property: ReceivedTime
+ public static System.DateTime? GetReceivedTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.ReceivedTime;
+ public static void SetReceivedTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, System.DateTime? value) => obj.ReceivedTime = value;
+ // Processing property: ReceivedMessageId
+ public static string GetReceivedMessageId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.ReceivedMessageId;
+ public static void SetReceivedMessageId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.ReceivedMessageId = value;
+ // Processing property: ReceivedRemark
+ public static string GetReceivedRemark(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.ReceivedRemark;
+ public static void SetReceivedRemark(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.ReceivedRemark = value;
+ // Processing property: IsReceived
+ public static bool GetIsReceived(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.IsReceived;
+ public static void SetIsReceived(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, bool value) => obj.IsReceived = value;
+ // Processing property: SystemName
+ public static string GetSystemName(JiShe.CollectBus.IoTDB.Model.IoTEntity obj) => obj.SystemName;
+ public static void SetSystemName(JiShe.CollectBus.IoTDB.Model.IoTEntity obj, string value) => obj.SystemName = value;
+ // Processing property: ProjectId
+ public static string GetProjectId(JiShe.CollectBus.IoTDB.Model.IoTEntity obj) => obj.ProjectId;
+ public static void SetProjectId(JiShe.CollectBus.IoTDB.Model.IoTEntity obj, string value) => obj.ProjectId = value;
+ // Processing property: DeviceType
+ public static string GetDeviceType(JiShe.CollectBus.IoTDB.Model.IoTEntity obj) => obj.DeviceType;
+ public static void SetDeviceType(JiShe.CollectBus.IoTDB.Model.IoTEntity obj, string value) => obj.DeviceType = value;
+ // Processing property: DeviceId
+ public static string GetDeviceId(JiShe.CollectBus.IoTDB.Model.IoTEntity obj) => obj.DeviceId;
+ public static void SetDeviceId(JiShe.CollectBus.IoTDB.Model.IoTEntity obj, string value) => obj.DeviceId = value;
+ // Processing property: Timestamps
+ public static long GetTimestamps(JiShe.CollectBus.IoTDB.Model.IoTEntity obj) => obj.Timestamps;
+ public static void SetTimestamps(JiShe.CollectBus.IoTDB.Model.IoTEntity obj, long value) => obj.Timestamps = value;
+}
diff --git a/shared/JiShe.CollectBus.IncrementalGenerator/ComplexTypeSourceGenerator.cs b/shared/JiShe.CollectBus.IncrementalGenerator/ComplexTypeSourceGenerator.cs
index 6b0982e..8d2b472 100644
--- a/shared/JiShe.CollectBus.IncrementalGenerator/ComplexTypeSourceGenerator.cs
+++ b/shared/JiShe.CollectBus.IncrementalGenerator/ComplexTypeSourceGenerator.cs
@@ -20,7 +20,7 @@ namespace JiShe.CollectBus.IncrementalGenerator
public void Initialize(IncrementalGeneratorInitializationContext context)
{
- //Debugger.Launch();
+ Debugger.Launch();
context.RegisterPostInitializationOutput(ctx =>
{
@@ -62,6 +62,24 @@ namespace JiShe.CollectBus.IncrementalGenerator
return null;
}
+ ///
+ /// 递归获取所有层级的属性
+ ///
+ ///
+ ///
+ private static IEnumerable GetAllPropertiesInHierarchy(INamedTypeSymbol classSymbol)
+ {
+ var currentSymbol = classSymbol;
+ while (currentSymbol != null)
+ {
+ foreach (var prop in currentSymbol.GetMembers().OfType())
+ {
+ yield return prop;
+ }
+ currentSymbol = currentSymbol.BaseType; // 向上遍历基类
+ }
+ }
+
private static void GenerateCode(
Compilation compilation,
IEnumerable classes,
@@ -101,6 +119,13 @@ namespace JiShe.CollectBus.IncrementalGenerator
true),
Location.None));
+ // 新增:输出继承链信息
+ context.ReportDiagnostic(Diagnostic.Create(
+ new DiagnosticDescriptor("HIERARCHY", "Class Hierarchy",
+ $"Processing class: {classSymbol.Name}, BaseType: {classSymbol.BaseType?.Name}",
+ "Debug", DiagnosticSeverity.Info, true),
+ Location.None));
+
context.ReportDiagnostic(Diagnostic.Create(
new DiagnosticDescriptor("PA002", "Class Found",
$"Processing class: {classSymbol.Name}", "Debug", DiagnosticSeverity.Warning, true),
@@ -110,7 +135,7 @@ namespace JiShe.CollectBus.IncrementalGenerator
System.Diagnostics.Debug.WriteLine($"Generated code for {classSymbol.Name}:\n{code}"); // 调试输出
- context.AddSource($"{classSymbol.Name}Extension.g.cs", SourceText.From(code, Encoding.UTF8));
+ context.AddSource($"{classSymbol.ContainingNamespace}_{classSymbol.Name}Extension.g.cs", code);
}
}
@@ -130,10 +155,16 @@ namespace JiShe.CollectBus.IncrementalGenerator
code.AppendLine($"public static class {classSymbol.Name}Extension{GetGenericParams(classSymbol)}");
code.AppendLine("{");
- foreach (var prop in classSymbol.GetMembers().OfType())
+ //foreach (var prop in classSymbol.GetMembers().OfType())
+ //{
+ // if (prop.IsIndexer) continue;
+
+ // GeneratePropertyAccessors(prop, code, compilation, processedTypes);
+ //}
+
+ foreach (var prop in GetAllPropertiesInHierarchy(classSymbol))
{
if (prop.IsIndexer) continue;
-
GeneratePropertyAccessors(prop, code, compilation, processedTypes);
}
From 5c19d02fddf54cd199463f4836e711d655e74e08 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E7=9B=8A?=
Date: Mon, 28 Apr 2025 22:35:19 +0800
Subject: [PATCH 6/8] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=BA=90=E7=A0=81?=
=?UTF-8?q?=E7=94=9F=E6=88=90=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
JiShe.CollectBus.sln | 19 ++-
.../JiShe.CollectBus.IoTDB.csproj | 7 +-
.../Model/TableModelSingleMeasuringEntity.cs | 2 +-
.../Model/TreeModelSingleMeasuringEntity.cs | 4 +-
.../Samples/SampleAppService.cs | 2 +-
.../Ammeters/ElectricityMeter.cs | 7 +-
.../Ammeters/ElectricityMeterTreeModel.cs | 4 +-
.../MeterReadingTelemetryPacketInfo.cs | 3 +-
...eadingTelemetryPacketInfoExtensionddd.g.cs | 110 ------------------
.../JiShe.CollectBus.Domain.csproj | 9 +-
.../GenerateAccessorsAttribute.cs | 2 +-
...She.CollectBus.Analyzers.Attributes.csproj | 7 ++
.../ComplexTypeSourceGenerator.cs | 14 +--
.../JiShe.CollectBus.Analyzers.csproj} | 10 +-
14 files changed, 47 insertions(+), 153 deletions(-)
delete mode 100644 services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfoExtensionddd.g.cs
rename shared/{JiShe.CollectBus.Common/Attributes => JiShe.CollectBus.Analyzers.Attributes}/GenerateAccessorsAttribute.cs (81%)
create mode 100644 shared/JiShe.CollectBus.Analyzers.Attributes/JiShe.CollectBus.Analyzers.Attributes.csproj
rename shared/{JiShe.CollectBus.IncrementalGenerator => JiShe.CollectBus.Analyzers}/ComplexTypeSourceGenerator.cs (96%)
rename shared/{JiShe.CollectBus.IncrementalGenerator/JiShe.CollectBus.IncrementalGenerator.csproj => JiShe.CollectBus.Analyzers/JiShe.CollectBus.Analyzers.csproj} (64%)
diff --git a/JiShe.CollectBus.sln b/JiShe.CollectBus.sln
index 0232b6d..246eb6b 100644
--- a/JiShe.CollectBus.sln
+++ b/JiShe.CollectBus.sln
@@ -62,7 +62,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.Docs", "0.Docs", "{D8346C
readme.md = readme.md
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.IncrementalGenerator", "shared\JiShe.CollectBus.IncrementalGenerator\JiShe.CollectBus.IncrementalGenerator.csproj", "{828D20BC-454E-0467-B29D-429B25F1E0CA}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.Analyzers.Attributes", "shared\JiShe.CollectBus.Analyzers.Attributes\JiShe.CollectBus.Analyzers.Attributes.csproj", "{D834B28F-E336-4E05-A5DD-DAF68E3342AA}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.Analyzers", "shared\JiShe.CollectBus.Analyzers\JiShe.CollectBus.Analyzers.csproj", "{00DF55EE-82CF-B5AA-F8C7-0E5B823FBC24}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -150,10 +152,14 @@ Global
{75B7D419-C261-577D-58D6-AA3ACED9129F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75B7D419-C261-577D-58D6-AA3ACED9129F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75B7D419-C261-577D-58D6-AA3ACED9129F}.Release|Any CPU.Build.0 = Release|Any CPU
- {828D20BC-454E-0467-B29D-429B25F1E0CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {828D20BC-454E-0467-B29D-429B25F1E0CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {828D20BC-454E-0467-B29D-429B25F1E0CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {828D20BC-454E-0467-B29D-429B25F1E0CA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D834B28F-E336-4E05-A5DD-DAF68E3342AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D834B28F-E336-4E05-A5DD-DAF68E3342AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D834B28F-E336-4E05-A5DD-DAF68E3342AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D834B28F-E336-4E05-A5DD-DAF68E3342AA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {00DF55EE-82CF-B5AA-F8C7-0E5B823FBC24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {00DF55EE-82CF-B5AA-F8C7-0E5B823FBC24}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {00DF55EE-82CF-B5AA-F8C7-0E5B823FBC24}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {00DF55EE-82CF-B5AA-F8C7-0E5B823FBC24}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -179,7 +185,8 @@ Global
{8A61DF78-069B-40B5-8811-614E2960443E} = {3C3F9DB2-EC97-4464-B49F-BF1A0C2B46DC}
{E27377CC-E2D3-4237-060F-96EA214D3129} = {3C3F9DB2-EC97-4464-B49F-BF1A0C2B46DC}
{75B7D419-C261-577D-58D6-AA3ACED9129F} = {3C3F9DB2-EC97-4464-B49F-BF1A0C2B46DC}
- {828D20BC-454E-0467-B29D-429B25F1E0CA} = {EBF7C01F-9B4F-48E6-8418-2CBFDA51EB0B}
+ {D834B28F-E336-4E05-A5DD-DAF68E3342AA} = {EBF7C01F-9B4F-48E6-8418-2CBFDA51EB0B}
+ {00DF55EE-82CF-B5AA-F8C7-0E5B823FBC24} = {EBF7C01F-9B4F-48E6-8418-2CBFDA51EB0B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4324B3B4-B60B-4E3C-91D8-59576B4E26DD}
diff --git a/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj b/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
index c24a807..d8e8b6f 100644
--- a/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
+++ b/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
@@ -10,8 +10,11 @@
+
+
+
+
+
-
-
diff --git a/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs b/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs
index 3350172..8f04e08 100644
--- a/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs
@@ -1,4 +1,4 @@
-using JiShe.CollectBus.Common;
+using JiShe.CollectBus.Analyzers.Attributes;
using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
diff --git a/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs b/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs
index 2a3273b..dbf239b 100644
--- a/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs
@@ -1,6 +1,6 @@
-using JiShe.CollectBus.Common;
+using JiShe.CollectBus.Analyzers.Attributes;
using JiShe.CollectBus.IoTDB.Attribute;
-using JiShe.CollectBus.IoTDB.Enums;
+using JiShe.CollectBus.IoTDB.Enums;
namespace JiShe.CollectBus.IoTDB.Model
{
diff --git a/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs b/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs
index a96080d..a3c4cd4 100644
--- a/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs
+++ b/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs
@@ -66,7 +66,7 @@ public class SampleAppService : CollectBusAppService, ISampleAppService, IKafkaS
IssuedMessageHexString = "messageHexString",
Timestamps = testTime// DateTimeOffset.UtcNow.ToUnixTimeNanoseconds()//testTime.GetDateTimeOffset().ToUnixTimeNanoseconds(),
};
- //ElectricityMeterTreeModelExtension
+ //ElectricityMeterExtension.get
await _iotDBProvider.InsertAsync(meter);
}
diff --git a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs
index 186b200..2f298dd 100644
--- a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs
+++ b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using JiShe.CollectBus.Common;
+using JiShe.CollectBus.Analyzers.Attributes;
using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
using JiShe.CollectBus.IoTDB.Model;
diff --git a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs
index a9ddc93..59d060f 100644
--- a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs
+++ b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs
@@ -1,7 +1,7 @@
-using JiShe.CollectBus.Common;
+using JiShe.CollectBus.Analyzers.Attributes;
using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
-using JiShe.CollectBus.IoTDB.Model;
+using JiShe.CollectBus.IoTDB.Model;
namespace JiShe.CollectBus.Ammeters
{
diff --git a/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs b/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs
index 4d406b8..8829abd 100644
--- a/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs
+++ b/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs
@@ -1,5 +1,4 @@
-using JiShe.CollectBus.Common;
-using JiShe.CollectBus.Common.Attributes;
+using JiShe.CollectBus.Analyzers.Attributes;
using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
using JiShe.CollectBus.IoTDB.Model;
diff --git a/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfoExtensionddd.g.cs b/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfoExtensionddd.g.cs
deleted file mode 100644
index 8319b3a..0000000
--- a/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfoExtensionddd.g.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace JiShe.CollectBus.IotSystems.MeterReadingRecords;
-
-public static class MeterReadingTelemetryPacketInfoExtension
-{
- // Processing property: ScoreValue
- public static string GetScoreValue(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.ScoreValue;
- public static void SetScoreValue(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.ScoreValue = value;
- // Processing property: ManualOrNot
- public static bool GetManualOrNot(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.ManualOrNot;
- public static void SetManualOrNot(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, bool value) => obj.ManualOrNot = value;
- // Processing property: TaskMark
- public static string GetTaskMark(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.TaskMark;
- public static void SetTaskMark(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.TaskMark = value;
- // Processing property: IsTimeout
- public static bool GetIsTimeout(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.IsTimeout;
- public static void SetIsTimeout(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, bool value) => obj.IsTimeout = value;
- // Processing property: PendingCopyReadTime
- public static System.DateTime GetPendingCopyReadTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.PendingCopyReadTime;
- public static void SetPendingCopyReadTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, System.DateTime value) => obj.PendingCopyReadTime = value;
- // Processing property: FocusId
- public static int GetFocusId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.FocusId;
- public static void SetFocusId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.FocusId = value;
- // Processing property: FocusAddress
- public static string GetFocusAddress(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.FocusAddress;
- public static void SetFocusAddress(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.FocusAddress = value;
- // Processing property: MeterId
- public static int GetMeterId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.MeterId;
- public static void SetMeterId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.MeterId = value;
- // Processing property: MeterAddress
- public static string GetMeterAddress(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.MeterAddress;
- public static void SetMeterAddress(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.MeterAddress = value;
- // Processing property: DatabaseBusiID
- public static int GetDatabaseBusiID(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.DatabaseBusiID;
- public static void SetDatabaseBusiID(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.DatabaseBusiID = value;
- // Processing property: AFN
- public static int GetAFN(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.AFN;
- public static void SetAFN(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.AFN = value;
- // Processing property: Fn
- public static int GetFn(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.Fn;
- public static void SetFn(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.Fn = value;
- // Processing property: Pn
- public static int GetPn(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.Pn;
- public static void SetPn(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.Pn = value;
- // Processing property: ItemCode
- public static string GetItemCode(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.ItemCode;
- public static void SetItemCode(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.ItemCode = value;
- // Processing property: SubItemCode
- public static string GetSubItemCode(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.SubItemCode;
- public static void SetSubItemCode(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.SubItemCode = value;
- // Processing property: Seq
- public static int GetSeq(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.Seq;
- public static void SetSeq(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.Seq = value;
- // Processing property: MSA
- public static int GetMSA(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.MSA;
- public static void SetMSA(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int value) => obj.MSA = value;
- // Processing property: IsSend
- public static bool GetIsSend(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.IsSend;
- public static void SetIsSend(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, bool value) => obj.IsSend = value;
- // Processing property: SendNum
- public static int? GetSendNum(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.SendNum;
- public static void SetSendNum(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, int? value) => obj.SendNum = value;
- // Processing property: NextSendTime
- public static System.DateTime? GetNextSendTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.NextSendTime;
- public static void SetNextSendTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, System.DateTime? value) => obj.NextSendTime = value;
- // Processing property: CreationTime
- public static System.DateTime GetCreationTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.CreationTime;
- public static void SetCreationTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, System.DateTime value) => obj.CreationTime = value;
- // Processing property: IssuedMessageHexString
- public static string GetIssuedMessageHexString(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.IssuedMessageHexString;
- public static void SetIssuedMessageHexString(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.IssuedMessageHexString = value;
- // Processing property: IssuedMessageId
- public static string GetIssuedMessageId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.IssuedMessageId;
- public static void SetIssuedMessageId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.IssuedMessageId = value;
- // Processing property: ReceivedMessageHexString
- public static string? GetReceivedMessageHexString(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.ReceivedMessageHexString;
- public static void SetReceivedMessageHexString(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string? value) => obj.ReceivedMessageHexString = value;
- // Processing property: ReceivedTime
- public static System.DateTime? GetReceivedTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.ReceivedTime;
- public static void SetReceivedTime(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, System.DateTime? value) => obj.ReceivedTime = value;
- // Processing property: ReceivedMessageId
- public static string GetReceivedMessageId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.ReceivedMessageId;
- public static void SetReceivedMessageId(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.ReceivedMessageId = value;
- // Processing property: ReceivedRemark
- public static string GetReceivedRemark(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.ReceivedRemark;
- public static void SetReceivedRemark(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, string value) => obj.ReceivedRemark = value;
- // Processing property: IsReceived
- public static bool GetIsReceived(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj) => obj.IsReceived;
- public static void SetIsReceived(JiShe.CollectBus.IotSystems.MeterReadingRecords.MeterReadingTelemetryPacketInfo obj, bool value) => obj.IsReceived = value;
- // Processing property: SystemName
- public static string GetSystemName(JiShe.CollectBus.IoTDB.Model.IoTEntity obj) => obj.SystemName;
- public static void SetSystemName(JiShe.CollectBus.IoTDB.Model.IoTEntity obj, string value) => obj.SystemName = value;
- // Processing property: ProjectId
- public static string GetProjectId(JiShe.CollectBus.IoTDB.Model.IoTEntity obj) => obj.ProjectId;
- public static void SetProjectId(JiShe.CollectBus.IoTDB.Model.IoTEntity obj, string value) => obj.ProjectId = value;
- // Processing property: DeviceType
- public static string GetDeviceType(JiShe.CollectBus.IoTDB.Model.IoTEntity obj) => obj.DeviceType;
- public static void SetDeviceType(JiShe.CollectBus.IoTDB.Model.IoTEntity obj, string value) => obj.DeviceType = value;
- // Processing property: DeviceId
- public static string GetDeviceId(JiShe.CollectBus.IoTDB.Model.IoTEntity obj) => obj.DeviceId;
- public static void SetDeviceId(JiShe.CollectBus.IoTDB.Model.IoTEntity obj, string value) => obj.DeviceId = value;
- // Processing property: Timestamps
- public static long GetTimestamps(JiShe.CollectBus.IoTDB.Model.IoTEntity obj) => obj.Timestamps;
- public static void SetTimestamps(JiShe.CollectBus.IoTDB.Model.IoTEntity obj, long value) => obj.Timestamps = value;
-}
diff --git a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
index 8976bb5..424d07c 100644
--- a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
+++ b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
@@ -20,11 +20,14 @@
-
+
-
-
+
+
+
+
+
diff --git a/shared/JiShe.CollectBus.Common/Attributes/GenerateAccessorsAttribute.cs b/shared/JiShe.CollectBus.Analyzers.Attributes/GenerateAccessorsAttribute.cs
similarity index 81%
rename from shared/JiShe.CollectBus.Common/Attributes/GenerateAccessorsAttribute.cs
rename to shared/JiShe.CollectBus.Analyzers.Attributes/GenerateAccessorsAttribute.cs
index 4912185..f2c9270 100644
--- a/shared/JiShe.CollectBus.Common/Attributes/GenerateAccessorsAttribute.cs
+++ b/shared/JiShe.CollectBus.Analyzers.Attributes/GenerateAccessorsAttribute.cs
@@ -1,6 +1,6 @@
using System;
-namespace JiShe.CollectBus.Common
+namespace JiShe.CollectBus.Analyzers.Attributes
{
///
/// 标记需要生成源码的类
diff --git a/shared/JiShe.CollectBus.Analyzers.Attributes/JiShe.CollectBus.Analyzers.Attributes.csproj b/shared/JiShe.CollectBus.Analyzers.Attributes/JiShe.CollectBus.Analyzers.Attributes.csproj
new file mode 100644
index 0000000..3ae7562
--- /dev/null
+++ b/shared/JiShe.CollectBus.Analyzers.Attributes/JiShe.CollectBus.Analyzers.Attributes.csproj
@@ -0,0 +1,7 @@
+
+
+
+ netstandard2.0
+
+
+
diff --git a/shared/JiShe.CollectBus.IncrementalGenerator/ComplexTypeSourceGenerator.cs b/shared/JiShe.CollectBus.Analyzers/ComplexTypeSourceGenerator.cs
similarity index 96%
rename from shared/JiShe.CollectBus.IncrementalGenerator/ComplexTypeSourceGenerator.cs
rename to shared/JiShe.CollectBus.Analyzers/ComplexTypeSourceGenerator.cs
index 8d2b472..ee3a896 100644
--- a/shared/JiShe.CollectBus.IncrementalGenerator/ComplexTypeSourceGenerator.cs
+++ b/shared/JiShe.CollectBus.Analyzers/ComplexTypeSourceGenerator.cs
@@ -1,11 +1,9 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Text;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
-using System.Threading.Tasks;
namespace JiShe.CollectBus.IncrementalGenerator
{
@@ -15,18 +13,16 @@ namespace JiShe.CollectBus.IncrementalGenerator
[Generator(LanguageNames.CSharp)]
public class ComplexTypeSourceGenerator : IIncrementalGenerator
{
- private const string AttributeFullName = "JiShe.CollectBus.Common.GenerateAccessorsAttribute";
+ private const string AttributeFullName = "JiShe.CollectBus.Analyzers.Attributes.GenerateAccessorsAttribute";
public void Initialize(IncrementalGeneratorInitializationContext context)
{
-
- Debugger.Launch();
+ //Debugger.Launch();
context.RegisterPostInitializationOutput(ctx =>
{
- ctx.AddSource("DebugInit.g.cs", "// Generator initialized");
+ ctx.AddSource("GeneratorInit.g.cs", "// Initialization Marker");
});
-
// 步骤1:筛选带有 [GenerateAccessors] 的类
var classDeclarations = context.SyntaxProvider
@@ -45,7 +41,7 @@ namespace JiShe.CollectBus.IncrementalGenerator
private static bool IsClassWithAttribute(SyntaxNode node) => node is ClassDeclarationSyntax cds && cds.AttributeLists.Count > 0;
- private static ClassDeclarationSyntax? GetClassDeclaration(GeneratorSyntaxContext context)
+ private static ClassDeclarationSyntax GetClassDeclaration(GeneratorSyntaxContext context)
{
var classDecl = (ClassDeclarationSyntax)context.Node;
var attributeType = context.SemanticModel.Compilation.GetTypeByMetadataName(AttributeFullName);
@@ -135,7 +131,7 @@ namespace JiShe.CollectBus.IncrementalGenerator
System.Diagnostics.Debug.WriteLine($"Generated code for {classSymbol.Name}:\n{code}"); // 调试输出
- context.AddSource($"{classSymbol.ContainingNamespace}_{classSymbol.Name}Extension.g.cs", code);
+ context.AddSource($"{classSymbol.Name}Extension.g.cs", code);
}
}
diff --git a/shared/JiShe.CollectBus.IncrementalGenerator/JiShe.CollectBus.IncrementalGenerator.csproj b/shared/JiShe.CollectBus.Analyzers/JiShe.CollectBus.Analyzers.csproj
similarity index 64%
rename from shared/JiShe.CollectBus.IncrementalGenerator/JiShe.CollectBus.IncrementalGenerator.csproj
rename to shared/JiShe.CollectBus.Analyzers/JiShe.CollectBus.Analyzers.csproj
index 533676e..2ce4399 100644
--- a/shared/JiShe.CollectBus.IncrementalGenerator/JiShe.CollectBus.IncrementalGenerator.csproj
+++ b/shared/JiShe.CollectBus.Analyzers/JiShe.CollectBus.Analyzers.csproj
@@ -1,7 +1,7 @@
- net8.0
+ netstandard2.0
true
true
false
@@ -10,18 +10,12 @@
latest
true
true
-
- Generated
- enable
-
- true
- all
-
+
From 083a28f7afc996ae996ea1ad4c5545082adc4922 Mon Sep 17 00:00:00 2001
From: ChenYi <296215406@outlook.com>
Date: Tue, 29 Apr 2025 09:14:58 +0800
Subject: [PATCH 7/8] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=BA=90=E7=A0=81?=
=?UTF-8?q?=E7=94=9F=E6=88=90=E5=99=A8=E7=BB=93=E6=9E=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
JiShe.CollectBus.sln | 24 +++++++++----------
.../ComplexTypeSourceAnalyzers.cs | 4 ++--
.../ISourceAnalyzersProvider.cs | 10 ++++++++
.../JiShe.CollectBus.Analyzers.csproj | 2 +-
.../JiShe.CollectBus.IoTDB.csproj | 8 +++----
.../Model/TableModelSingleMeasuringEntity.cs | 2 +-
.../Model/TreeModelSingleMeasuringEntity.cs | 2 +-
.../Samples/SampleAppService.cs | 2 +-
.../Ammeters/ElectricityMeter.cs | 2 +-
.../Ammeters/ElectricityMeterTreeModel.cs | 2 +-
.../MeterReadingTelemetryPacketInfo.cs | 2 +-
.../JiShe.CollectBus.Domain.csproj | 16 ++++++-------
.../GenerateAccessorsAttribute.cs | 2 +-
.../JiShe.CollectBus.Analyzers.Shared.csproj} | 0
.../JiShe.CollectBus.Domain.Shared.csproj | 2 ++
15 files changed, 46 insertions(+), 34 deletions(-)
rename shared/JiShe.CollectBus.Analyzers/ComplexTypeSourceGenerator.cs => modules/JiShe.CollectBus.Analyzers/ComplexTypeSourceAnalyzers.cs (98%)
create mode 100644 modules/JiShe.CollectBus.Analyzers/ISourceAnalyzersProvider.cs
rename {shared => modules}/JiShe.CollectBus.Analyzers/JiShe.CollectBus.Analyzers.csproj (86%)
rename shared/{JiShe.CollectBus.Analyzers.Attributes => JiShe.CollectBus.Analyzers.Shared}/GenerateAccessorsAttribute.cs (81%)
rename shared/{JiShe.CollectBus.Analyzers.Attributes/JiShe.CollectBus.Analyzers.Attributes.csproj => JiShe.CollectBus.Analyzers.Shared/JiShe.CollectBus.Analyzers.Shared.csproj} (100%)
diff --git a/JiShe.CollectBus.sln b/JiShe.CollectBus.sln
index 246eb6b..f02dd6e 100644
--- a/JiShe.CollectBus.sln
+++ b/JiShe.CollectBus.sln
@@ -62,9 +62,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.Docs", "0.Docs", "{D8346C
readme.md = readme.md
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.Analyzers.Attributes", "shared\JiShe.CollectBus.Analyzers.Attributes\JiShe.CollectBus.Analyzers.Attributes.csproj", "{D834B28F-E336-4E05-A5DD-DAF68E3342AA}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.Analyzers.Shared", "shared\JiShe.CollectBus.Analyzers.Shared\JiShe.CollectBus.Analyzers.Shared.csproj", "{DD68F314-BC66-5601-B094-B1A7BE93F4E0}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.Analyzers", "shared\JiShe.CollectBus.Analyzers\JiShe.CollectBus.Analyzers.csproj", "{00DF55EE-82CF-B5AA-F8C7-0E5B823FBC24}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.Analyzers", "modules\JiShe.CollectBus.Analyzers\JiShe.CollectBus.Analyzers.csproj", "{EB97C7BB-1E4A-CBA4-04C1-22DBF48A253A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -152,14 +152,14 @@ Global
{75B7D419-C261-577D-58D6-AA3ACED9129F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75B7D419-C261-577D-58D6-AA3ACED9129F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75B7D419-C261-577D-58D6-AA3ACED9129F}.Release|Any CPU.Build.0 = Release|Any CPU
- {D834B28F-E336-4E05-A5DD-DAF68E3342AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D834B28F-E336-4E05-A5DD-DAF68E3342AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D834B28F-E336-4E05-A5DD-DAF68E3342AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D834B28F-E336-4E05-A5DD-DAF68E3342AA}.Release|Any CPU.Build.0 = Release|Any CPU
- {00DF55EE-82CF-B5AA-F8C7-0E5B823FBC24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {00DF55EE-82CF-B5AA-F8C7-0E5B823FBC24}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {00DF55EE-82CF-B5AA-F8C7-0E5B823FBC24}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {00DF55EE-82CF-B5AA-F8C7-0E5B823FBC24}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DD68F314-BC66-5601-B094-B1A7BE93F4E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DD68F314-BC66-5601-B094-B1A7BE93F4E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DD68F314-BC66-5601-B094-B1A7BE93F4E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DD68F314-BC66-5601-B094-B1A7BE93F4E0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EB97C7BB-1E4A-CBA4-04C1-22DBF48A253A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EB97C7BB-1E4A-CBA4-04C1-22DBF48A253A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EB97C7BB-1E4A-CBA4-04C1-22DBF48A253A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EB97C7BB-1E4A-CBA4-04C1-22DBF48A253A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -185,8 +185,8 @@ Global
{8A61DF78-069B-40B5-8811-614E2960443E} = {3C3F9DB2-EC97-4464-B49F-BF1A0C2B46DC}
{E27377CC-E2D3-4237-060F-96EA214D3129} = {3C3F9DB2-EC97-4464-B49F-BF1A0C2B46DC}
{75B7D419-C261-577D-58D6-AA3ACED9129F} = {3C3F9DB2-EC97-4464-B49F-BF1A0C2B46DC}
- {D834B28F-E336-4E05-A5DD-DAF68E3342AA} = {EBF7C01F-9B4F-48E6-8418-2CBFDA51EB0B}
- {00DF55EE-82CF-B5AA-F8C7-0E5B823FBC24} = {EBF7C01F-9B4F-48E6-8418-2CBFDA51EB0B}
+ {DD68F314-BC66-5601-B094-B1A7BE93F4E0} = {EBF7C01F-9B4F-48E6-8418-2CBFDA51EB0B}
+ {EB97C7BB-1E4A-CBA4-04C1-22DBF48A253A} = {2E0FE301-34C3-4561-9CAE-C7A9E65AEE59}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4324B3B4-B60B-4E3C-91D8-59576B4E26DD}
diff --git a/shared/JiShe.CollectBus.Analyzers/ComplexTypeSourceGenerator.cs b/modules/JiShe.CollectBus.Analyzers/ComplexTypeSourceAnalyzers.cs
similarity index 98%
rename from shared/JiShe.CollectBus.Analyzers/ComplexTypeSourceGenerator.cs
rename to modules/JiShe.CollectBus.Analyzers/ComplexTypeSourceAnalyzers.cs
index ee3a896..44ab9d5 100644
--- a/shared/JiShe.CollectBus.Analyzers/ComplexTypeSourceGenerator.cs
+++ b/modules/JiShe.CollectBus.Analyzers/ComplexTypeSourceAnalyzers.cs
@@ -11,9 +11,9 @@ namespace JiShe.CollectBus.IncrementalGenerator
/// 复杂类型源生成器
///
[Generator(LanguageNames.CSharp)]
- public class ComplexTypeSourceGenerator : IIncrementalGenerator
+ public class ComplexTypeSourceAnalyzers : IIncrementalGenerator
{
- private const string AttributeFullName = "JiShe.CollectBus.Analyzers.Attributes.GenerateAccessorsAttribute";
+ private const string AttributeFullName = "JiShe.CollectBus.Analyzers.Shared.GenerateAccessorsAttribute";
public void Initialize(IncrementalGeneratorInitializationContext context)
{
diff --git a/modules/JiShe.CollectBus.Analyzers/ISourceAnalyzersProvider.cs b/modules/JiShe.CollectBus.Analyzers/ISourceAnalyzersProvider.cs
new file mode 100644
index 0000000..ed2ce4e
--- /dev/null
+++ b/modules/JiShe.CollectBus.Analyzers/ISourceAnalyzersProvider.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace JiShe.CollectBus.Analyzers
+{
+ internal class ISourceAnalyzersProvider
+ {
+ }
+}
diff --git a/shared/JiShe.CollectBus.Analyzers/JiShe.CollectBus.Analyzers.csproj b/modules/JiShe.CollectBus.Analyzers/JiShe.CollectBus.Analyzers.csproj
similarity index 86%
rename from shared/JiShe.CollectBus.Analyzers/JiShe.CollectBus.Analyzers.csproj
rename to modules/JiShe.CollectBus.Analyzers/JiShe.CollectBus.Analyzers.csproj
index 2ce4399..7e7fab1 100644
--- a/shared/JiShe.CollectBus.Analyzers/JiShe.CollectBus.Analyzers.csproj
+++ b/modules/JiShe.CollectBus.Analyzers/JiShe.CollectBus.Analyzers.csproj
@@ -16,6 +16,6 @@
-
+
diff --git a/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj b/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
index d8e8b6f..3911399 100644
--- a/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
+++ b/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj
@@ -10,11 +10,11 @@
-
-
-
-
+
+
+
diff --git a/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs b/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs
index 8f04e08..ed3824d 100644
--- a/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs
@@ -1,4 +1,4 @@
-using JiShe.CollectBus.Analyzers.Attributes;
+using JiShe.CollectBus.Analyzers.Shared;
using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
diff --git a/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs b/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs
index dbf239b..c6b1418 100644
--- a/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs
@@ -1,4 +1,4 @@
-using JiShe.CollectBus.Analyzers.Attributes;
+using JiShe.CollectBus.Analyzers.Shared;
using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
diff --git a/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs b/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs
index a3c4cd4..ea2415e 100644
--- a/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs
+++ b/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs
@@ -66,7 +66,7 @@ public class SampleAppService : CollectBusAppService, ISampleAppService, IKafkaS
IssuedMessageHexString = "messageHexString",
Timestamps = testTime// DateTimeOffset.UtcNow.ToUnixTimeNanoseconds()//testTime.GetDateTimeOffset().ToUnixTimeNanoseconds(),
};
- //ElectricityMeterExtension.get
+ //ElectricityMeterTreeModelExtension.GetCurrent()
await _iotDBProvider.InsertAsync(meter);
}
diff --git a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs
index 2f298dd..db833f6 100644
--- a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs
+++ b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs
@@ -1,4 +1,4 @@
-using JiShe.CollectBus.Analyzers.Attributes;
+using JiShe.CollectBus.Analyzers.Shared;
using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
using JiShe.CollectBus.IoTDB.Model;
diff --git a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs
index 59d060f..f02fcb1 100644
--- a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs
+++ b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs
@@ -1,4 +1,4 @@
-using JiShe.CollectBus.Analyzers.Attributes;
+using JiShe.CollectBus.Analyzers.Shared;
using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
using JiShe.CollectBus.IoTDB.Model;
diff --git a/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs b/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs
index 8829abd..f0c1721 100644
--- a/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs
+++ b/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs
@@ -1,4 +1,4 @@
-using JiShe.CollectBus.Analyzers.Attributes;
+using JiShe.CollectBus.Analyzers.Shared;
using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
using JiShe.CollectBus.IoTDB.Model;
diff --git a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
index 424d07c..f8880ec 100644
--- a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
+++ b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
@@ -1,6 +1,8 @@
-
-
+
+
+
+
net8.0
enable
JiShe.CollectBus
@@ -20,14 +22,12 @@
-
+
+
-
-
-
-
-
+
diff --git a/shared/JiShe.CollectBus.Analyzers.Attributes/GenerateAccessorsAttribute.cs b/shared/JiShe.CollectBus.Analyzers.Shared/GenerateAccessorsAttribute.cs
similarity index 81%
rename from shared/JiShe.CollectBus.Analyzers.Attributes/GenerateAccessorsAttribute.cs
rename to shared/JiShe.CollectBus.Analyzers.Shared/GenerateAccessorsAttribute.cs
index f2c9270..10b5d79 100644
--- a/shared/JiShe.CollectBus.Analyzers.Attributes/GenerateAccessorsAttribute.cs
+++ b/shared/JiShe.CollectBus.Analyzers.Shared/GenerateAccessorsAttribute.cs
@@ -1,6 +1,6 @@
using System;
-namespace JiShe.CollectBus.Analyzers.Attributes
+namespace JiShe.CollectBus.Analyzers.Shared
{
///
/// 标记需要生成源码的类
diff --git a/shared/JiShe.CollectBus.Analyzers.Attributes/JiShe.CollectBus.Analyzers.Attributes.csproj b/shared/JiShe.CollectBus.Analyzers.Shared/JiShe.CollectBus.Analyzers.Shared.csproj
similarity index 100%
rename from shared/JiShe.CollectBus.Analyzers.Attributes/JiShe.CollectBus.Analyzers.Attributes.csproj
rename to shared/JiShe.CollectBus.Analyzers.Shared/JiShe.CollectBus.Analyzers.Shared.csproj
diff --git a/shared/JiShe.CollectBus.Domain.Shared/JiShe.CollectBus.Domain.Shared.csproj b/shared/JiShe.CollectBus.Domain.Shared/JiShe.CollectBus.Domain.Shared.csproj
index d513989..5453712 100644
--- a/shared/JiShe.CollectBus.Domain.Shared/JiShe.CollectBus.Domain.Shared.csproj
+++ b/shared/JiShe.CollectBus.Domain.Shared/JiShe.CollectBus.Domain.Shared.csproj
@@ -1,5 +1,7 @@
+
+
net8.0
enable
From f457e140f62d993625e03fd2f26544ea96d50cee Mon Sep 17 00:00:00 2001
From: ChenYi <296215406@outlook.com>
Date: Tue, 29 Apr 2025 10:02:10 +0800
Subject: [PATCH 8/8] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=B7=BB=E5=8A=A0?=
=?UTF-8?q?=E7=B1=BB=E5=9E=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ComplexTypeSourceAnalyzers.cs | 2 +-
.../ISourceAnalyzersProvider.cs | 10 ---
.../Model/TableModelSingleMeasuringEntity.cs | 2 +-
.../Model/TreeModelSingleMeasuringEntity.cs | 2 +-
.../IScheduledMeterReadingService.cs | 2 +-
.../BasicScheduledMeterReadingService.cs | 37 +++++----
.../Ammeters/ElectricityMeter.cs | 2 +-
.../Ammeters/ElectricityMeterTreeModel.cs | 2 +-
.../MeterReadingTelemetryPacketInfo.cs | 14 ++--
.../ISourceAnalyzersProvider.cs | 40 ++++++++++
...tribute.cs => SourceAnalyzersAttribute.cs} | 2 +-
.../Enums/TelemetryPacketTypeEnum.cs | 75 +++++++++++++++++++
12 files changed, 153 insertions(+), 37 deletions(-)
delete mode 100644 modules/JiShe.CollectBus.Analyzers/ISourceAnalyzersProvider.cs
create mode 100644 shared/JiShe.CollectBus.Analyzers.Shared/ISourceAnalyzersProvider.cs
rename shared/JiShe.CollectBus.Analyzers.Shared/{GenerateAccessorsAttribute.cs => SourceAnalyzersAttribute.cs} (78%)
create mode 100644 shared/JiShe.CollectBus.Common/Enums/TelemetryPacketTypeEnum.cs
diff --git a/modules/JiShe.CollectBus.Analyzers/ComplexTypeSourceAnalyzers.cs b/modules/JiShe.CollectBus.Analyzers/ComplexTypeSourceAnalyzers.cs
index 44ab9d5..20951e5 100644
--- a/modules/JiShe.CollectBus.Analyzers/ComplexTypeSourceAnalyzers.cs
+++ b/modules/JiShe.CollectBus.Analyzers/ComplexTypeSourceAnalyzers.cs
@@ -13,7 +13,7 @@ namespace JiShe.CollectBus.IncrementalGenerator
[Generator(LanguageNames.CSharp)]
public class ComplexTypeSourceAnalyzers : IIncrementalGenerator
{
- private const string AttributeFullName = "JiShe.CollectBus.Analyzers.Shared.GenerateAccessorsAttribute";
+ private const string AttributeFullName = "JiShe.CollectBus.Analyzers.Shared.SourceAnalyzersAttribute";
public void Initialize(IncrementalGeneratorInitializationContext context)
{
diff --git a/modules/JiShe.CollectBus.Analyzers/ISourceAnalyzersProvider.cs b/modules/JiShe.CollectBus.Analyzers/ISourceAnalyzersProvider.cs
deleted file mode 100644
index ed2ce4e..0000000
--- a/modules/JiShe.CollectBus.Analyzers/ISourceAnalyzersProvider.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace JiShe.CollectBus.Analyzers
-{
- internal class ISourceAnalyzersProvider
- {
- }
-}
diff --git a/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs b/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs
index ed3824d..966f226 100644
--- a/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Model/TableModelSingleMeasuringEntity.cs
@@ -8,7 +8,7 @@ namespace JiShe.CollectBus.IoTDB.Model
/// Table模型单项数据实体
///
[EntityType(EntityTypeEnum.TableModel)]
- [GenerateAccessors]
+ [SourceAnalyzers]
public class TableModelSingleMeasuringEntity : IoTEntity
{
///
diff --git a/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs b/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs
index c6b1418..719c3c3 100644
--- a/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs
+++ b/modules/JiShe.CollectBus.IoTDB/Model/TreeModelSingleMeasuringEntity.cs
@@ -8,7 +8,7 @@ namespace JiShe.CollectBus.IoTDB.Model
/// Tree模型单项数据实体
///
[EntityType(EntityTypeEnum.TreeModel)]
- [GenerateAccessors]
+ [SourceAnalyzers]
public class TreeModelSingleMeasuringEntity : IoTEntity
{
///
diff --git a/services/JiShe.CollectBus.Application.Contracts/ScheduledMeterReading/IScheduledMeterReadingService.cs b/services/JiShe.CollectBus.Application.Contracts/ScheduledMeterReading/IScheduledMeterReadingService.cs
index 1a06897..4dde0be 100644
--- a/services/JiShe.CollectBus.Application.Contracts/ScheduledMeterReading/IScheduledMeterReadingService.cs
+++ b/services/JiShe.CollectBus.Application.Contracts/ScheduledMeterReading/IScheduledMeterReadingService.cs
@@ -124,7 +124,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
/// 水表数据采集
///
///
- Task WatermeterScheduledMeterAutoReading();
+ Task WatermeterScheduledMeterAutoReadding();
#endregion
diff --git a/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs b/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs
index 0b5f28a..f9ad966 100644
--- a/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs
+++ b/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs
@@ -709,7 +709,8 @@ namespace JiShe.CollectBus.ScheduledMeterReading
itemCode: tempItem,
subItemCode: null,
pendingCopyReadTime: currentTime,
- creationTime: currentTime);
+ creationTime: currentTime,
+ packetType: (TelemetryPacketTypeEnum)timeDensity);
taskList.Add(meterReadingRecords);
}
@@ -791,7 +792,8 @@ namespace JiShe.CollectBus.ScheduledMeterReading
itemCode: itemCode,
subItemCode: subItemCode,
pendingCopyReadTime: currentTime,
- creationTime: currentTime);
+ creationTime: currentTime,
+ packetType: TelemetryPacketTypeEnum.AmmeterAutomaticVerificationTime);
taskList.Add(meterReadingRecords);
if (taskList == null || taskList.Count <= 0)
@@ -855,7 +857,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
_logger.LogError($"{nameof(AmmeterScheduledAutoValveControl)} 定时阀控运行时间{currentTime}没有找到对应的协议组件,-105");
return;
}
-
+
foreach (var item in DayFreezeCodes)
{
ProtocolBuildResponse builderResponse = await protocolPlugin.BuildAsync(new ProtocolBuildRequest()
@@ -872,10 +874,11 @@ namespace JiShe.CollectBus.ScheduledMeterReading
itemCode: item,
subItemCode: null,
pendingCopyReadTime: currentTime,
- creationTime: currentTime);
+ creationTime: currentTime,
+ packetType: TelemetryPacketTypeEnum.AmmeterDayFreeze);
taskList.Add(meterReadingRecords);
}
-
+
if (taskList == null || taskList.Count <= 0)
{
@@ -895,7 +898,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
_ = KafkaProducerIssuedMessageAction(ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, data, groupIndex);
}
);
-
+
}
catch (Exception)
{
@@ -954,7 +957,8 @@ namespace JiShe.CollectBus.ScheduledMeterReading
itemCode: item,
subItemCode: null,
pendingCopyReadTime: currentTime,
- creationTime: currentTime);
+ creationTime: currentTime,
+ packetType: TelemetryPacketTypeEnum.AmmeterMonthFreeze);
taskList.Add(meterReadingRecords);
}
@@ -1097,7 +1101,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
/// 水表数据采集
///
///
- public virtual async Task WatermeterScheduledMeterAutoReading()
+ public virtual async Task WatermeterScheduledMeterAutoReadding()
{
//获取缓存中的水表信息
int timeDensity = 60;//水表目前只有一个采集频率 60分钟
@@ -1129,7 +1133,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
Conditions = conditions,
});
- _logger.LogInformation($"{nameof(WatermeterScheduledMeterAutoReading)} {timeDensity}分钟采集水表数据处理完成");
+ _logger.LogInformation($"{nameof(WatermeterScheduledMeterAutoReadding)} {timeDensity}分钟采集水表数据处理完成");
}
///
@@ -1214,7 +1218,8 @@ namespace JiShe.CollectBus.ScheduledMeterReading
DeviceId = $"{watermeter.MeterId}",
Timestamps = DateTimeOffset.Now.ToUnixTimeNanoseconds(),
DatabaseBusiID = watermeter.DatabaseBusiID,
- PendingCopyReadTime = timestamps,
+ PacketType = (int)TelemetryPacketTypeEnum.WatermeterAutoReadding,
+ PendingCopyReadTime = timestamps,
CreationTime = currentTime,
MeterAddress = watermeter.MeterAddress,
AFN = builderResponse.AFn,
@@ -1298,7 +1303,8 @@ namespace JiShe.CollectBus.ScheduledMeterReading
itemCode: itemCode,
subItemCode: null,
pendingCopyReadTime: currentTime,
- creationTime: currentTime);
+ creationTime: currentTime,
+ packetType: TelemetryPacketTypeEnum.TerminalVersion);
taskList.Add(meterReadingRecords);
if (taskList == null || taskList.Count <= 0)
@@ -1376,7 +1382,8 @@ namespace JiShe.CollectBus.ScheduledMeterReading
itemCode: itemCode,
subItemCode: null,
pendingCopyReadTime: currentTime,
- creationTime: currentTime);
+ creationTime: currentTime,
+ packetType: TelemetryPacketTypeEnum.TelematicsModule);
taskList.Add(meterReadingRecords);
if (taskList == null || taskList.Count <= 0)
@@ -1560,8 +1567,9 @@ namespace JiShe.CollectBus.ScheduledMeterReading
/// 端到端采集项编码
/// 待采集时间,定时采集频率才是特殊情况,其他默认当前时间戳
/// 数据创建时间戳
+ /// 数据包类型
///
- protected MeterReadingTelemetryPacketInfo CreateAmmeterPacketInfo(AmmeterInfo ammeterInfo, long timestamps, ProtocolBuildResponse builderResponse, string itemCode, string subItemCode, DateTime pendingCopyReadTime, DateTime creationTime)
+ protected MeterReadingTelemetryPacketInfo CreateAmmeterPacketInfo(AmmeterInfo ammeterInfo, long timestamps, ProtocolBuildResponse builderResponse, string itemCode, string subItemCode, DateTime pendingCopyReadTime, DateTime creationTime, TelemetryPacketTypeEnum packetType)
{
string taskMark = CommonHelper.GetTaskMark(builderResponse.AFn, builderResponse.Fn, ammeterInfo.MeteringCode, builderResponse.MSA, builderResponse.Seq);
return new MeterReadingTelemetryPacketInfo()
@@ -1575,10 +1583,13 @@ namespace JiShe.CollectBus.ScheduledMeterReading
PendingCopyReadTime = pendingCopyReadTime,
CreationTime = creationTime,
MeterAddress = ammeterInfo.AmmerterAddress,
+ PacketType = (int)packetType,
AFN = builderResponse.AFn,
Fn = builderResponse.Fn,
Seq = builderResponse.Seq,
MSA = builderResponse.MSA,
+ FocusId = ammeterInfo.FocusId,
+ FocusAddress = ammeterInfo.FocusAddress,
ItemCode = itemCode,
SubItemCode = subItemCode,
TaskMark = taskMark,
diff --git a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs
index db833f6..9ba3c94 100644
--- a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs
+++ b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs
@@ -6,7 +6,7 @@ using JiShe.CollectBus.IoTDB.Model;
namespace JiShe.CollectBus.Ammeters
{
[EntityType(EntityTypeEnum.TableModel)]
- [GenerateAccessors]
+ [SourceAnalyzers]
public class ElectricityMeter : IoTEntity
{
[ATTRIBUTEColumn]
diff --git a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs
index f02fcb1..1f11198 100644
--- a/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs
+++ b/services/JiShe.CollectBus.Domain/Ammeters/ElectricityMeterTreeModel.cs
@@ -6,7 +6,7 @@ using JiShe.CollectBus.IoTDB.Model;
namespace JiShe.CollectBus.Ammeters
{
[EntityType(EntityTypeEnum.TreeModel)]
- [GenerateAccessors]
+ [SourceAnalyzers]
public class ElectricityMeterTreeModel : IoTEntity
{
[ATTRIBUTEColumn]
diff --git a/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs b/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs
index f0c1721..4b61e99 100644
--- a/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs
+++ b/services/JiShe.CollectBus.Domain/IotSystems/MeterReadingRecords/MeterReadingTelemetryPacketInfo.cs
@@ -10,7 +10,7 @@ namespace JiShe.CollectBus.IotSystems.MeterReadingRecords
/// 抄读任务数据
///
[EntityType(EntityTypeEnum.TableModel)]
- [GenerateAccessors]
+ [SourceAnalyzers]
public class MeterReadingTelemetryPacketInfo : IoTEntity
{
///
@@ -19,6 +19,12 @@ namespace JiShe.CollectBus.IotSystems.MeterReadingRecords
[FIELDColumn]
public string ScoreValue { get; set; }
+ ///
+ /// 数据包类型
+ ///
+ [FIELDColumn]
+ public int PacketType { get; set; }
+
///
/// 是否手动操作
///
@@ -55,12 +61,6 @@ namespace JiShe.CollectBus.IotSystems.MeterReadingRecords
///
[FIELDColumn]
public string FocusAddress { get; set; }
-
- ///
- /// 表Id
- ///
- [FIELDColumn]
- public int MeterId { get; set; }
///
/// 表地址
diff --git a/shared/JiShe.CollectBus.Analyzers.Shared/ISourceAnalyzersProvider.cs b/shared/JiShe.CollectBus.Analyzers.Shared/ISourceAnalyzersProvider.cs
new file mode 100644
index 0000000..905f0ef
--- /dev/null
+++ b/shared/JiShe.CollectBus.Analyzers.Shared/ISourceAnalyzersProvider.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace JiShe.CollectBus.Analyzers
+{
+ public interface ISourceAnalyzersProvider
+ {
+ ///
+ /// 获取属性值
+ ///
+ ///
+ ///
+ ///
+ object GetPropertyValue(T entity, string propertyName);
+
+ ///
+ /// 设置属性值
+ ///
+ ///
+ ///
+ ///
+ void SetPropertyValue(T entity, string propertyName, object value);
+
+ ///
+ /// 判断是否是元组属性
+ ///
+ ///
+ ///
+ bool IsTupleProperty(string propertyName);
+
+ ///
+ /// 获取元组属性值
+ ///
+ ///
+ ///
+ ///
+ (object Item1, object Item2) GetTupleParts(T entity, string tuplePropertyName);
+ }
+}
diff --git a/shared/JiShe.CollectBus.Analyzers.Shared/GenerateAccessorsAttribute.cs b/shared/JiShe.CollectBus.Analyzers.Shared/SourceAnalyzersAttribute.cs
similarity index 78%
rename from shared/JiShe.CollectBus.Analyzers.Shared/GenerateAccessorsAttribute.cs
rename to shared/JiShe.CollectBus.Analyzers.Shared/SourceAnalyzersAttribute.cs
index 10b5d79..0b33a6a 100644
--- a/shared/JiShe.CollectBus.Analyzers.Shared/GenerateAccessorsAttribute.cs
+++ b/shared/JiShe.CollectBus.Analyzers.Shared/SourceAnalyzersAttribute.cs
@@ -6,7 +6,7 @@ namespace JiShe.CollectBus.Analyzers.Shared
/// 标记需要生成源码的类
///
[AttributeUsage(AttributeTargets.Class)]
- public class GenerateAccessorsAttribute : Attribute
+ public class SourceAnalyzersAttribute : Attribute
{
}
}
diff --git a/shared/JiShe.CollectBus.Common/Enums/TelemetryPacketTypeEnum.cs b/shared/JiShe.CollectBus.Common/Enums/TelemetryPacketTypeEnum.cs
new file mode 100644
index 0000000..837392b
--- /dev/null
+++ b/shared/JiShe.CollectBus.Common/Enums/TelemetryPacketTypeEnum.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JiShe.CollectBus.Common.Enums
+{
+ ///
+ /// 遥测数据包类型枚举
+ ///
+ public enum TelemetryPacketTypeEnum
+ {
+ ///
+ /// 1分钟密度
+ ///
+ [Description("1分钟密度")]
+ AmmeterOneMinute = 1,
+
+ ///
+ /// 5分钟密度
+ ///
+ [Description("5分钟密度")]
+ AmmeterMeterFiveMinute = 5,
+
+ ///
+ /// 15分钟密度
+ ///
+ [Description("15分钟密度")]
+ AmmeterFifteenMinute = 15,
+
+ ///
+ /// 自动校时
+ ///
+ [Description("自动校时")]
+ AmmeterAutomaticVerificationTime = 16,
+
+ ///
+ /// 日冻结
+ ///
+ [Description("日冻结")]
+ AmmeterDayFreeze = 17,
+
+ ///
+ /// 月冻结
+ ///
+ [Description("月冻结")]
+ AmmeterMonthFreeze = 18,
+
+ ///
+ /// 自动阀控
+ ///
+ [Description("自动阀控")]
+ AmmeterAutoValveControl = 19,
+
+ ///
+ /// 集中器终端版本
+ ///
+ [Description("集中器终端版本")]
+ TerminalVersion = 20,
+
+ ///
+ /// 集中器通信模块SIM
+ ///
+ [Description("集中器通信模块SIM")]
+ TelematicsModule = 21,
+
+ ///
+ /// 水表抄读
+ ///
+ [Description("水表抄读")]
+ WatermeterAutoReadding = 22,
+ }
+}