修改代码
This commit is contained in:
parent
1c1ad56408
commit
0b2f2447c5
@ -66,7 +66,7 @@ public class SampleAppService : CollectBusAppService, ISampleAppService, IKafkaS
|
|||||||
IssuedMessageHexString = "messageHexString",
|
IssuedMessageHexString = "messageHexString",
|
||||||
Timestamps = testTime// DateTimeOffset.UtcNow.ToUnixTimeNanoseconds()//testTime.GetDateTimeOffset().ToUnixTimeNanoseconds(),
|
Timestamps = testTime// DateTimeOffset.UtcNow.ToUnixTimeNanoseconds()//testTime.GetDateTimeOffset().ToUnixTimeNanoseconds(),
|
||||||
};
|
};
|
||||||
|
//ElectricityMeterTreeModelExtension
|
||||||
await _iotDBProvider.InsertAsync(meter);
|
await _iotDBProvider.InsertAsync(meter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using JiShe.CollectBus.Common;
|
||||||
using JiShe.CollectBus.IoTDB.Attribute;
|
using JiShe.CollectBus.IoTDB.Attribute;
|
||||||
using JiShe.CollectBus.IoTDB.Enums;
|
using JiShe.CollectBus.IoTDB.Enums;
|
||||||
using JiShe.CollectBus.IoTDB.Model;
|
using JiShe.CollectBus.IoTDB.Model;
|
||||||
@ -10,6 +11,7 @@ using JiShe.CollectBus.IoTDB.Model;
|
|||||||
namespace JiShe.CollectBus.Ammeters
|
namespace JiShe.CollectBus.Ammeters
|
||||||
{
|
{
|
||||||
[EntityType(EntityTypeEnum.TableModel)]
|
[EntityType(EntityTypeEnum.TableModel)]
|
||||||
|
[GenerateAccessors]
|
||||||
public class ElectricityMeter : IoTEntity
|
public class ElectricityMeter : IoTEntity
|
||||||
{
|
{
|
||||||
[ATTRIBUTEColumn]
|
[ATTRIBUTEColumn]
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
@ -20,7 +20,7 @@ namespace JiShe.CollectBus.IncrementalGenerator
|
|||||||
public void Initialize(IncrementalGeneratorInitializationContext context)
|
public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Debugger.Launch();
|
Debugger.Launch();
|
||||||
|
|
||||||
context.RegisterPostInitializationOutput(ctx =>
|
context.RegisterPostInitializationOutput(ctx =>
|
||||||
{
|
{
|
||||||
@ -62,6 +62,24 @@ namespace JiShe.CollectBus.IncrementalGenerator
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 递归获取所有层级的属性
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="classSymbol"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static IEnumerable<IPropertySymbol> GetAllPropertiesInHierarchy(INamedTypeSymbol classSymbol)
|
||||||
|
{
|
||||||
|
var currentSymbol = classSymbol;
|
||||||
|
while (currentSymbol != null)
|
||||||
|
{
|
||||||
|
foreach (var prop in currentSymbol.GetMembers().OfType<IPropertySymbol>())
|
||||||
|
{
|
||||||
|
yield return prop;
|
||||||
|
}
|
||||||
|
currentSymbol = currentSymbol.BaseType; // 向上遍历基类
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void GenerateCode(
|
private static void GenerateCode(
|
||||||
Compilation compilation,
|
Compilation compilation,
|
||||||
IEnumerable<ClassDeclarationSyntax> classes,
|
IEnumerable<ClassDeclarationSyntax> classes,
|
||||||
@ -101,6 +119,13 @@ namespace JiShe.CollectBus.IncrementalGenerator
|
|||||||
true),
|
true),
|
||||||
Location.None));
|
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(
|
context.ReportDiagnostic(Diagnostic.Create(
|
||||||
new DiagnosticDescriptor("PA002", "Class Found",
|
new DiagnosticDescriptor("PA002", "Class Found",
|
||||||
$"Processing class: {classSymbol.Name}", "Debug", DiagnosticSeverity.Warning, true),
|
$"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}"); // 调试输出
|
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($"public static class {classSymbol.Name}Extension{GetGenericParams(classSymbol)}");
|
||||||
code.AppendLine("{");
|
code.AppendLine("{");
|
||||||
|
|
||||||
foreach (var prop in classSymbol.GetMembers().OfType<IPropertySymbol>())
|
//foreach (var prop in classSymbol.GetMembers().OfType<IPropertySymbol>())
|
||||||
|
//{
|
||||||
|
// if (prop.IsIndexer) continue;
|
||||||
|
|
||||||
|
// GeneratePropertyAccessors(prop, code, compilation, processedTypes);
|
||||||
|
//}
|
||||||
|
|
||||||
|
foreach (var prop in GetAllPropertiesInHierarchy(classSymbol))
|
||||||
{
|
{
|
||||||
if (prop.IsIndexer) continue;
|
if (prop.IsIndexer) continue;
|
||||||
|
|
||||||
GeneratePropertyAccessors(prop, code, compilation, processedTypes);
|
GeneratePropertyAccessors(prop, code, compilation, processedTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user