调整代码
This commit is contained in:
parent
966172ea0f
commit
5b1c393cc0
@ -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.Extensions;
|
||||||
|
using JiShe.CollectBus.Common.Helpers;
|
||||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||||
using JiShe.CollectBus.Protocol.Dto;
|
using JiShe.CollectBus.Protocol.Dto;
|
||||||
|
|||||||
@ -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.Extensions;
|
||||||
|
using JiShe.CollectBus.Common.Helpers;
|
||||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||||
using JiShe.CollectBus.Protocol.Dto;
|
using JiShe.CollectBus.Protocol.Dto;
|
||||||
|
|||||||
@ -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.Extensions;
|
||||||
|
using JiShe.CollectBus.Common.Helpers;
|
||||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||||
using JiShe.CollectBus.Protocol.Dto;
|
using JiShe.CollectBus.Protocol.Dto;
|
||||||
|
|||||||
@ -8,7 +8,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||||
using JiShe.CollectBus.Common.Extensions;
|
using JiShe.CollectBus.Common.Extensions;
|
||||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||||
using JiShe.CollectBus.Common.Consts;
|
using JiShe.CollectBus.Common.Helpers;
|
||||||
|
|
||||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||||
{
|
{
|
||||||
|
|||||||
@ -7,8 +7,8 @@ using JiShe.CollectBus.Protocol3761;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||||
using JiShe.CollectBus.Common.Extensions;
|
using JiShe.CollectBus.Common.Extensions;
|
||||||
using JiShe.CollectBus.Common.Consts;
|
|
||||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||||
|
using JiShe.CollectBus.Common.Helpers;
|
||||||
|
|
||||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,8 +8,8 @@ using Microsoft.Extensions.Logging;
|
|||||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using JiShe.CollectBus.Common.Extensions;
|
using JiShe.CollectBus.Common.Extensions;
|
||||||
using JiShe.CollectBus.Common.Consts;
|
|
||||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||||
|
using JiShe.CollectBus.Common.Helpers;
|
||||||
|
|
||||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||||
{
|
{
|
||||||
|
|||||||
@ -10,7 +10,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
|||||||
using JiShe.CollectBus.Common.Extensions;
|
using JiShe.CollectBus.Common.Extensions;
|
||||||
using Volo.Abp.Domain.Entities;
|
using Volo.Abp.Domain.Entities;
|
||||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||||
using JiShe.CollectBus.Common.Consts;
|
using JiShe.CollectBus.Common.Helpers;
|
||||||
|
|
||||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,7 +9,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
|||||||
using JiShe.CollectBus.Common.Extensions;
|
using JiShe.CollectBus.Common.Extensions;
|
||||||
using AutoMapper.Internal.Mappers;
|
using AutoMapper.Internal.Mappers;
|
||||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||||
using JiShe.CollectBus.Common.Consts;
|
using JiShe.CollectBus.Common.Helpers;
|
||||||
|
|
||||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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.Extensions;
|
||||||
|
using JiShe.CollectBus.Common.Helpers;
|
||||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||||
using NUglify.JavaScript.Syntax;
|
using NUglify.JavaScript.Syntax;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|||||||
@ -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
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 数据保存字段常量
|
|
||||||
/// </summary>
|
|
||||||
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
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 数据字段映射
|
|
||||||
/// </summary>
|
|
||||||
public static Dictionary<string, string> DataFieldDic = new Dictionary<string, string>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 创建数据字段映射
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static Dictionary<string, string> CreateDataFieldMapping()
|
|
||||||
{
|
|
||||||
if (DataFieldDic.Count > 0)
|
|
||||||
return DataFieldDic;
|
|
||||||
var dataFieldMapping = new Dictionary<string, string>();
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 根据采集数据类型获取数据字段
|
|
||||||
/// 返回null表示 无效字段
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="docDataType"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static string? GetDataFieldByGatherDataType(this string gatherDataType)
|
|
||||||
{
|
|
||||||
if (CreateDataFieldMapping().TryGetValue(gatherDataType, out string? column))
|
|
||||||
{
|
|
||||||
return column;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -36,5 +36,122 @@ namespace JiShe.CollectBus.Common.Consts
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 数据解析
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据保存字段常量
|
||||||
|
/// </summary>
|
||||||
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using static JiShe.CollectBus.Common.Consts.T37612012PacketItemCodeConst;
|
||||||
|
|
||||||
namespace JiShe.CollectBus.Common.Helpers
|
namespace JiShe.CollectBus.Common.Helpers
|
||||||
{
|
{
|
||||||
public class DataFieldHelper
|
public static class DataFieldHelper
|
||||||
{
|
{
|
||||||
public static string GetDataField(string dataField)
|
public static string GetDataField(string dataField)
|
||||||
{
|
{
|
||||||
@ -22,5 +24,61 @@ namespace JiShe.CollectBus.Common.Helpers
|
|||||||
|
|
||||||
return dataField;
|
return dataField;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据字段映射
|
||||||
|
/// </summary>
|
||||||
|
public static Dictionary<string, string> DataFieldDic = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建数据字段映射
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Dictionary<string, string> CreateDataFieldMapping()
|
||||||
|
{
|
||||||
|
if (DataFieldDic.Count > 0)
|
||||||
|
return DataFieldDic;
|
||||||
|
var dataFieldMapping = new Dictionary<string, string>();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据采集数据类型获取数据字段
|
||||||
|
/// 返回null表示 无效字段
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="docDataType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string? GetDataFieldByGatherDataType(this string gatherDataType)
|
||||||
|
{
|
||||||
|
if (CreateDataFieldMapping().TryGetValue(gatherDataType, out string? column))
|
||||||
|
{
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user