From 5b1c393cc0f84c97a69bcab180c8e4ba2bc54614 Mon Sep 17 00:00:00 2001 From: zenghongyao <873884283@qq.com> Date: Sun, 27 Apr 2025 17:23:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AFN_0CH/AFN12_F149_Analysis.cs | 4 +- .../AFN_0DH/AFN13_F11_Analysis.cs | 4 +- .../AFN_0DH/AFN13_F190_Analysis.cs | 4 +- .../AFN_0DH/AFN13_F193_Analysis.cs | 2 +- .../AFN_0DH/AFN13_F195_Analysis.cs | 2 +- .../AFN_0DH/AFN13_F19_Analysis.cs | 2 +- .../AnalysisData/AFN_0DH/AFN13_F3_Analysis.cs | 2 +- .../AnalysisData/AFN_0DH/AFN13_F4_Analysis.cs | 2 +- .../Protocol3761Extensions.cs | 4 +- .../Consts/DataFieldConst.cs | 182 ------------------ .../Consts/T37612012PacketItemCodeConst.cs | 117 +++++++++++ .../Helpers/DataFieldHelper.cs | 60 +++++- 12 files changed, 189 insertions(+), 196 deletions(-) delete mode 100644 shared/JiShe.CollectBus.Common/Consts/DataFieldConst.cs diff --git a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0CH/AFN12_F149_Analysis.cs b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0CH/AFN12_F149_Analysis.cs index 07480f0..faf6c34 100644 --- a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0CH/AFN12_F149_Analysis.cs +++ b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0CH/AFN12_F149_Analysis.cs @@ -1,6 +1,6 @@ -using JiShe.CollectBus.Common.Consts; -using JiShe.CollectBus.Common.Enums; +using JiShe.CollectBus.Common.Enums; using JiShe.CollectBus.Common.Extensions; +using JiShe.CollectBus.Common.Helpers; using JiShe.CollectBus.IotSystems.Ammeters; using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto; using JiShe.CollectBus.Protocol.Dto; diff --git a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F11_Analysis.cs b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F11_Analysis.cs index 495f0dc..e3493eb 100644 --- a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F11_Analysis.cs +++ b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F11_Analysis.cs @@ -1,6 +1,6 @@ -using JiShe.CollectBus.Common.Consts; -using JiShe.CollectBus.Common.Enums; +using JiShe.CollectBus.Common.Enums; using JiShe.CollectBus.Common.Extensions; +using JiShe.CollectBus.Common.Helpers; using JiShe.CollectBus.IotSystems.Ammeters; using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto; using JiShe.CollectBus.Protocol.Dto; diff --git a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F190_Analysis.cs b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F190_Analysis.cs index 956eb11..07f091a 100644 --- a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F190_Analysis.cs +++ b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F190_Analysis.cs @@ -1,6 +1,6 @@ -using JiShe.CollectBus.Common.Consts; -using JiShe.CollectBus.Common.Enums; +using JiShe.CollectBus.Common.Enums; using JiShe.CollectBus.Common.Extensions; +using JiShe.CollectBus.Common.Helpers; using JiShe.CollectBus.IotSystems.Ammeters; using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto; using JiShe.CollectBus.Protocol.Dto; diff --git a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F193_Analysis.cs b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F193_Analysis.cs index 2e0c48d..e1fa0c3 100644 --- a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F193_Analysis.cs +++ b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F193_Analysis.cs @@ -8,7 +8,7 @@ using Microsoft.Extensions.Logging; using JiShe.CollectBus.Protocol.T37612012.Appendix; using JiShe.CollectBus.Common.Extensions; using JiShe.CollectBus.IotSystems.Ammeters; -using JiShe.CollectBus.Common.Consts; +using JiShe.CollectBus.Common.Helpers; namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH { diff --git a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F195_Analysis.cs b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F195_Analysis.cs index c7ffe04..927ac96 100644 --- a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F195_Analysis.cs +++ b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F195_Analysis.cs @@ -7,8 +7,8 @@ using JiShe.CollectBus.Protocol3761; using Microsoft.Extensions.Logging; using JiShe.CollectBus.Protocol.T37612012.Appendix; using JiShe.CollectBus.Common.Extensions; -using JiShe.CollectBus.Common.Consts; using JiShe.CollectBus.IotSystems.Ammeters; +using JiShe.CollectBus.Common.Helpers; namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH { diff --git a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F19_Analysis.cs b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F19_Analysis.cs index 5cda5b3..c9fc150 100644 --- a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F19_Analysis.cs +++ b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F19_Analysis.cs @@ -8,8 +8,8 @@ using Microsoft.Extensions.Logging; using JiShe.CollectBus.Protocol.T37612012.Appendix; using System.Data; using JiShe.CollectBus.Common.Extensions; -using JiShe.CollectBus.Common.Consts; using JiShe.CollectBus.IotSystems.Ammeters; +using JiShe.CollectBus.Common.Helpers; namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH { diff --git a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F3_Analysis.cs b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F3_Analysis.cs index f53b936..f8b2f6d 100644 --- a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F3_Analysis.cs +++ b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F3_Analysis.cs @@ -10,7 +10,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix; using JiShe.CollectBus.Common.Extensions; using Volo.Abp.Domain.Entities; using JiShe.CollectBus.IotSystems.Ammeters; -using JiShe.CollectBus.Common.Consts; +using JiShe.CollectBus.Common.Helpers; namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH { diff --git a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F4_Analysis.cs b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F4_Analysis.cs index 7af6f21..9ed6acd 100644 --- a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F4_Analysis.cs +++ b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_0DH/AFN13_F4_Analysis.cs @@ -9,7 +9,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix; using JiShe.CollectBus.Common.Extensions; using AutoMapper.Internal.Mappers; using JiShe.CollectBus.IotSystems.Ammeters; -using JiShe.CollectBus.Common.Consts; +using JiShe.CollectBus.Common.Helpers; namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH { diff --git a/protocols/JiShe.CollectBus.Protocol.T37612012/Protocol3761Extensions.cs b/protocols/JiShe.CollectBus.Protocol.T37612012/Protocol3761Extensions.cs index 2045a06..f9e0d61 100644 --- a/protocols/JiShe.CollectBus.Protocol.T37612012/Protocol3761Extensions.cs +++ b/protocols/JiShe.CollectBus.Protocol.T37612012/Protocol3761Extensions.cs @@ -1,6 +1,6 @@ -using JiShe.CollectBus.Common.Consts; -using JiShe.CollectBus.Common.Enums; +using JiShe.CollectBus.Common.Enums; using JiShe.CollectBus.Common.Extensions; +using JiShe.CollectBus.Common.Helpers; using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto; using NUglify.JavaScript.Syntax; using System.Text.RegularExpressions; diff --git a/shared/JiShe.CollectBus.Common/Consts/DataFieldConst.cs b/shared/JiShe.CollectBus.Common/Consts/DataFieldConst.cs deleted file mode 100644 index 9cde24b..0000000 --- a/shared/JiShe.CollectBus.Common/Consts/DataFieldConst.cs +++ /dev/null @@ -1,182 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace JiShe.CollectBus.Common.Consts -{ - /// - /// 数据保存字段常量 - /// - public class DataFieldConst - { - public const string ZYGDN = "ZYGDN"; - public const string ZWGDN = "ZWGDN"; - public const string FYGDN = "FYGDN"; - public const string FWGDN = "FWGDN"; - - public const string ZYGDNSZ = "ZYGDNSZ"; - public const string ZWGDNSZ = "ZWGDNSZ"; - public const string FYGDNSZ = "FYGDNSZ"; - public const string FWGDNSZ = "FWGDNSZ"; - - public const string WGDN1 = "WGDN1"; - public const string WGDN2 = "WGDN2"; - public const string WGDN3 = "WGDN3"; - public const string WGDN4 = "WGDN4"; - - public const string WGDNSZ1 = "WGDNSZ1"; - public const string WGDNSZ2 = "WGDNSZ2"; - public const string WGDNSZ3 = "WGDNSZ3"; - public const string WGDNSZ4 = "WGDNSZ4"; - - public const string YGGL = "YGGL"; - public const string AYGGL = "AYGGL"; - public const string BYGGL = "BYGGL"; - public const string CYGGL = "CYGGL"; - - public const string WGGL = "WGGL"; - public const string AWGGL = "AWGGL"; - public const string BWGGL = "BWGGL"; - public const string CWGGL = "CWGGL"; - - public const string GLYS = "GLYS"; - public const string AGLYS = "AGLYS"; - public const string BGLYS = "BGLYS"; - public const string CGLYS = "CGLYS"; - - public const string ADY = "ADY"; - public const string BDY = "BDY"; - public const string CDY = "CDY"; - - public const string ADL = "ADL"; - public const string BDL = "BDL"; - public const string CDL = "CDL"; - public const string LXDL = "LXDL"; - - public const string PowerGridFrequency = "PowerGridFrequency"; - - public const string Ua = "Ua"; - public const string Ub = "Ub"; - public const string Uc = "Uc"; - - public const string Ia = "Ia"; - public const string Ib = "Ib"; - public const string Ic = "Ic"; - - } - - public class ConstGatherDataType - { - public const string ZYGDN = "0D_97"; //正向有功总电能量 - public const string ZWGDN = "0D_98"; //正向无功总电能量曲线 - public const string FYGDN = "0D_99"; //反向有功总电能量曲线 - public const string FWGDN = "0D_100"; //反向无功总电能量曲线 - - public const string ZYGDNSZ = "0D_101"; //正向有功总电能示值曲线 - public const string ZWGDNSZ = "0D_102"; //正向无功总电能示值曲线 - public const string FYGDNSZ = "0D_103"; //反向有功总电能示值曲线 - public const string FWGDNSZ = "0D_104"; //反向无功总电能示值曲线 - - public const string WGDNSZ1 = "0D_145"; //一象限无功总电能示值曲线 - public const string WGDNSZ4 = "0D_146"; //四象限无功总电能示值曲线 - public const string WGDNSZ2 = "0D_147"; //二象限无功总电能示值曲线 - public const string WGDNSZ3 = "0D_148"; //三象限无功总电能示值曲线 - - public const string YGGL = "0D_81"; //有功功率曲线 - public const string AYGGL = "0D_82"; //A相有功功率曲线 - public const string BYGGL = "0D_83"; //B相有功功率曲线 - public const string CYGGL = "0D_84"; //C相有功功率曲线 - - public const string WGGL = "0D_85"; //无功功率曲线 - public const string AWGGL = "0D_86"; //A相无功功率曲线 - public const string BWGGL = "0D_87"; //B相无功功率曲线 - public const string CWGGL = "0D_88"; //C相无功功率曲线 - - public const string GLYS = "0D_105"; // 功率因数曲线 - public const string AGLYS = "0D_106"; // A相功率因数曲线 - public const string BGLYS = "0D_107"; // B相功率因数曲线 - public const string CGLYS = "0D_108"; // C相功率因数曲线 - - public const string ADY = "0D_89"; //A相电压曲线 - public const string BDY = "0D_90"; //B相电压曲线 - public const string CDY = "0D_91"; //C相电压曲线 - - public const string ADL = "0D_92"; //A相电流曲线 - public const string BDL = "0D_93"; //B相电流曲线 - public const string CDL = "0D_94"; //C相电流曲线 - public const string LXDL = "0D_95"; // 零序电流 - - public const string PowerGridFrequency = "10_97"; //电网频率 - - public const string Ua = "0C_49_Uab_Ua"; // 当前电压、电流相位角 - public const string Ub = "0C_49_Ub"; // 当前电压、电流相位角 - public const string Uc = "0C_49_Ucb_Uc"; // 当前电压、电流相位角 - public const string Ia = "0C_49_Ia"; // 当前电压、电流相位角 - public const string Ib = "0C_49_Ib"; // 当前电压、电流相位角 - public const string Ic = "0C_49_Ic"; // 当前电压、电流相位角 - - } - - - public static class DataFieldHelper - { - /// - /// 数据字段映射 - /// - public static Dictionary DataFieldDic = new Dictionary(); - - /// - /// 创建数据字段映射 - /// - /// - public static Dictionary CreateDataFieldMapping() - { - if (DataFieldDic.Count > 0) - return DataFieldDic; - var dataFieldMapping = new Dictionary(); - Type dataType = typeof(ConstGatherDataType); - Type fieldType = typeof(DataFieldConst); - - foreach (FieldInfo gatherField in dataType.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)) - { - if (gatherField.IsLiteral && !gatherField.IsInitOnly) - { - // 获取ConstGatherDataType的字段值作为key - string key = (string)gatherField.GetValue(null)!; - - // 查找DataFieldConst中同名字段 - FieldInfo dataField = fieldType.GetField(gatherField.Name, - BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)!; - - if (dataField != null) - { - string value = (string)dataField.GetValue(null)!; - dataFieldMapping[key] = value; - } - } - } - - return dataFieldMapping; - } - - /// - /// 根据采集数据类型获取数据字段 - /// 返回null表示 无效字段 - /// - /// - /// - public static string? GetDataFieldByGatherDataType(this string gatherDataType) - { - if (CreateDataFieldMapping().TryGetValue(gatherDataType, out string? column)) - { - return column; - } - return null; - } - - - } -} diff --git a/shared/JiShe.CollectBus.Common/Consts/T37612012PacketItemCodeConst.cs b/shared/JiShe.CollectBus.Common/Consts/T37612012PacketItemCodeConst.cs index 6d15e19..e797e69 100644 --- a/shared/JiShe.CollectBus.Common/Consts/T37612012PacketItemCodeConst.cs +++ b/shared/JiShe.CollectBus.Common/Consts/T37612012PacketItemCodeConst.cs @@ -36,5 +36,122 @@ namespace JiShe.CollectBus.Common.Consts #endregion #endregion + + #region 数据解析 + + /// + /// 数据保存字段常量 + /// + public class DataFieldConst + { + public const string ZYGDN = "ZYGDN"; + public const string ZWGDN = "ZWGDN"; + public const string FYGDN = "FYGDN"; + public const string FWGDN = "FWGDN"; + + public const string ZYGDNSZ = "ZYGDNSZ"; + public const string ZWGDNSZ = "ZWGDNSZ"; + public const string FYGDNSZ = "FYGDNSZ"; + public const string FWGDNSZ = "FWGDNSZ"; + + public const string WGDN1 = "WGDN1"; + public const string WGDN2 = "WGDN2"; + public const string WGDN3 = "WGDN3"; + public const string WGDN4 = "WGDN4"; + + public const string WGDNSZ1 = "WGDNSZ1"; + public const string WGDNSZ2 = "WGDNSZ2"; + public const string WGDNSZ3 = "WGDNSZ3"; + public const string WGDNSZ4 = "WGDNSZ4"; + + public const string YGGL = "YGGL"; + public const string AYGGL = "AYGGL"; + public const string BYGGL = "BYGGL"; + public const string CYGGL = "CYGGL"; + + public const string WGGL = "WGGL"; + public const string AWGGL = "AWGGL"; + public const string BWGGL = "BWGGL"; + public const string CWGGL = "CWGGL"; + + public const string GLYS = "GLYS"; + public const string AGLYS = "AGLYS"; + public const string BGLYS = "BGLYS"; + public const string CGLYS = "CGLYS"; + + public const string ADY = "ADY"; + public const string BDY = "BDY"; + public const string CDY = "CDY"; + + public const string ADL = "ADL"; + public const string BDL = "BDL"; + public const string CDL = "CDL"; + public const string LXDL = "LXDL"; + + public const string PowerGridFrequency = "PowerGridFrequency"; + + public const string Ua = "Ua"; + public const string Ub = "Ub"; + public const string Uc = "Uc"; + + public const string Ia = "Ia"; + public const string Ib = "Ib"; + public const string Ic = "Ic"; + + } + + public class ConstGatherDataType + { + public const string ZYGDN = "0D_97"; //正向有功总电能量 + public const string ZWGDN = "0D_98"; //正向无功总电能量曲线 + public const string FYGDN = "0D_99"; //反向有功总电能量曲线 + public const string FWGDN = "0D_100"; //反向无功总电能量曲线 + + public const string ZYGDNSZ = "0D_101"; //正向有功总电能示值曲线 + public const string ZWGDNSZ = "0D_102"; //正向无功总电能示值曲线 + public const string FYGDNSZ = "0D_103"; //反向有功总电能示值曲线 + public const string FWGDNSZ = "0D_104"; //反向无功总电能示值曲线 + + public const string WGDNSZ1 = "0D_145"; //一象限无功总电能示值曲线 + public const string WGDNSZ4 = "0D_146"; //四象限无功总电能示值曲线 + public const string WGDNSZ2 = "0D_147"; //二象限无功总电能示值曲线 + public const string WGDNSZ3 = "0D_148"; //三象限无功总电能示值曲线 + + public const string YGGL = "0D_81"; //有功功率曲线 + public const string AYGGL = "0D_82"; //A相有功功率曲线 + public const string BYGGL = "0D_83"; //B相有功功率曲线 + public const string CYGGL = "0D_84"; //C相有功功率曲线 + + public const string WGGL = "0D_85"; //无功功率曲线 + public const string AWGGL = "0D_86"; //A相无功功率曲线 + public const string BWGGL = "0D_87"; //B相无功功率曲线 + public const string CWGGL = "0D_88"; //C相无功功率曲线 + + public const string GLYS = "0D_105"; // 功率因数曲线 + public const string AGLYS = "0D_106"; // A相功率因数曲线 + public const string BGLYS = "0D_107"; // B相功率因数曲线 + public const string CGLYS = "0D_108"; // C相功率因数曲线 + + public const string ADY = "0D_89"; //A相电压曲线 + public const string BDY = "0D_90"; //B相电压曲线 + public const string CDY = "0D_91"; //C相电压曲线 + + public const string ADL = "0D_92"; //A相电流曲线 + public const string BDL = "0D_93"; //B相电流曲线 + public const string CDL = "0D_94"; //C相电流曲线 + public const string LXDL = "0D_95"; // 零序电流 + + public const string PowerGridFrequency = "10_97"; //电网频率 + + public const string Ua = "0C_49_Uab_Ua"; // 当前电压、电流相位角 + public const string Ub = "0C_49_Ub"; // 当前电压、电流相位角 + public const string Uc = "0C_49_Ucb_Uc"; // 当前电压、电流相位角 + public const string Ia = "0C_49_Ia"; // 当前电压、电流相位角 + public const string Ib = "0C_49_Ib"; // 当前电压、电流相位角 + public const string Ic = "0C_49_Ic"; // 当前电压、电流相位角 + + } + + #endregion } } diff --git a/shared/JiShe.CollectBus.Common/Helpers/DataFieldHelper.cs b/shared/JiShe.CollectBus.Common/Helpers/DataFieldHelper.cs index a9173bb..bcf0bcc 100644 --- a/shared/JiShe.CollectBus.Common/Helpers/DataFieldHelper.cs +++ b/shared/JiShe.CollectBus.Common/Helpers/DataFieldHelper.cs @@ -1,12 +1,14 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; +using static JiShe.CollectBus.Common.Consts.T37612012PacketItemCodeConst; namespace JiShe.CollectBus.Common.Helpers { - public class DataFieldHelper + public static class DataFieldHelper { public static string GetDataField(string dataField) { @@ -22,5 +24,61 @@ namespace JiShe.CollectBus.Common.Helpers return dataField; } + + /// + /// 数据字段映射 + /// + public static Dictionary DataFieldDic = new Dictionary(); + + /// + /// 创建数据字段映射 + /// + /// + public static Dictionary CreateDataFieldMapping() + { + if (DataFieldDic.Count > 0) + return DataFieldDic; + var dataFieldMapping = new Dictionary(); + Type dataType = typeof(ConstGatherDataType); + Type fieldType = typeof(DataFieldConst); + + foreach (FieldInfo gatherField in dataType.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)) + { + if (gatherField.IsLiteral && !gatherField.IsInitOnly) + { + // 获取ConstGatherDataType的字段值作为key + string key = (string)gatherField.GetValue(null)!; + + // 查找DataFieldConst中同名字段 + FieldInfo dataField = fieldType.GetField(gatherField.Name, + BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)!; + + if (dataField != null) + { + string value = (string)dataField.GetValue(null)!; + dataFieldMapping[key] = value; + } + } + } + + return dataFieldMapping; + } + + /// + /// 根据采集数据类型获取数据字段 + /// 返回null表示 无效字段 + /// + /// + /// + public static string? GetDataFieldByGatherDataType(this string gatherDataType) + { + if (CreateDataFieldMapping().TryGetValue(gatherDataType, out string? column)) + { + return column; + } + return null; + } + + } }