diff --git a/protocols/JiShe.CollectBus.Protocol.T37612012/Protocol/Dto/AnalysisBaseDto.cs b/protocols/JiShe.CollectBus.Protocol.T37612012/Protocol/Dto/AnalysisBaseDto.cs index 49f9054..645c567 100644 --- a/protocols/JiShe.CollectBus.Protocol.T37612012/Protocol/Dto/AnalysisBaseDto.cs +++ b/protocols/JiShe.CollectBus.Protocol.T37612012/Protocol/Dto/AnalysisBaseDto.cs @@ -8,7 +8,6 @@ namespace JiShe.CollectBus.Protocol.Contracts.Protocol.Dto { public class AnalysisBaseDto { - /// /// 是否有效数据 /// @@ -17,22 +16,22 @@ namespace JiShe.CollectBus.Protocol.Contracts.Protocol.Dto /// /// 数据类型 /// - public string DataType { get; set; } + public string PointDataType { get; set; } = null!; /// /// 错误码信息 /// - public string ErrorCodeMsg { get; set; } + public string? ErrorCodeMsg { get; set; } /// /// 字段名 /// - public string FiledName { get; set; } + public string FiledName { get; set; } = null!; /// /// 字段描述 /// - public string FiledDesc { get; set; } + public string FiledDesc { get; set; } = null!; } public class AnalysisBaseDto : AnalysisBaseDto diff --git a/protocols/JiShe.CollectBus.Protocol.T37612012/Protocol/Dto/UnitDataAnalysis.cs b/protocols/JiShe.CollectBus.Protocol.T37612012/Protocol/Dto/UnitDataAnalysis.cs index 3a03923..d10594b 100644 --- a/protocols/JiShe.CollectBus.Protocol.T37612012/Protocol/Dto/UnitDataAnalysis.cs +++ b/protocols/JiShe.CollectBus.Protocol.T37612012/Protocol/Dto/UnitDataAnalysis.cs @@ -5,7 +5,7 @@ /// /// 集中器地址 /// - public string? Code { get; set; } + public string Code { get; set; } = null!; /// /// AFN功能码 @@ -22,7 +22,16 @@ /// public int Fn { get; set; } - + /// + /// 主站地址 MSA + /// + public int MSA { get; set; } + + /// + /// 响应帧序号 + /// + public int PSEQ { get; set; } + } public class UnitDataAnalysis: UnitDataAnalysis diff --git a/protocols/JiShe.CollectBus.Protocol.T6452007/AnalysisData/AFN_0CH/AFN12_F129_Analysis.cs b/protocols/JiShe.CollectBus.Protocol.T6452007/AnalysisData/AFN_0CH/AFN12_F129_Analysis.cs index e857bcd..6aea2ff 100644 --- a/protocols/JiShe.CollectBus.Protocol.T6452007/AnalysisData/AFN_0CH/AFN12_F129_Analysis.cs +++ b/protocols/JiShe.CollectBus.Protocol.T6452007/AnalysisData/AFN_0CH/AFN12_F129_Analysis.cs @@ -1,4 +1,14 @@ -using JiShe.CollectBus.Common.Enums; +using FreeSql.Internal.CommonProvider; +using JiShe.CollectBus.Common.Consts; +using JiShe.CollectBus.Common.Encrypt; +using JiShe.CollectBus.Common.Enums; +using JiShe.CollectBus.Common.Helpers; +using JiShe.CollectBus.EnergySystems.Entities; +using JiShe.CollectBus.IoTDB.Interface; +using JiShe.CollectBus.IoTDB.Options; +using JiShe.CollectBus.IoTDB.Provider; +using JiShe.CollectBus.IotSystems.Ammeters; +using JiShe.CollectBus.IotSystems.MeterReadingRecords; using JiShe.CollectBus.Protocol.AnalysisData.Appendix; using JiShe.CollectBus.Protocol.Contracts; using JiShe.CollectBus.Protocol.Contracts.Interfaces; @@ -6,6 +16,7 @@ using JiShe.CollectBus.Protocol.Contracts.Models; using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto; using JiShe.CollectBus.Protocol.Dto; using Microsoft.Extensions.Logging; +using NUglify.JavaScript.Syntax; namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH { @@ -16,11 +27,13 @@ namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH { private readonly ILogger _logger; private readonly AnalysisStrategyContext _analysisStrategyContext; + private readonly IIoTDbProvider _dbProvider; - public AFN12_F129_Analysis(ILogger logger, AnalysisStrategyContext analysisStrategyContext) + public AFN12_F129_Analysis(ILogger logger, AnalysisStrategyContext analysisStrategyContext, IIoTDbProvider dbProvider) { _logger = logger; _analysisStrategyContext = analysisStrategyContext; + _dbProvider= dbProvider; } public async Task>> ExecuteAsync(TB3761 input) @@ -29,16 +42,34 @@ namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH { ArgumentNullException.ThrowIfNull(input); ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList); - List datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList); - List list = GenerateFinalResult(2, datas, "正向有功电能示值", input.AFN_FC.AFN, input.DT.Fn); + ArgumentNullException.ThrowIfNull(input.A.A3?.D1_D7); UnitDataAnalysis> unitDataAnalysis = new UnitDataAnalysis> { Code = input.A.Code, AFN = input.AFN_FC.AFN, Fn = input.DT.Fn, Pn = input.DA.Pn, - Data = list + MSA= input.A.A3.D1_D7, + PSEQ= input.SEQ.PSEQ, }; + string taskMark = CommonHelper.GetTaskMark(unitDataAnalysis.AFN, unitDataAnalysis.Fn, unitDataAnalysis.Pn, unitDataAnalysis.MSA, unitDataAnalysis.PSEQ); + string scoreValue = $"{unitDataAnalysis.Code}.{taskMark}".Md5Fun(); + + var conditions = new List(); + conditions.Add(new QueryCondition() + { + Field = "ScoreValue", + Operator = "=", + IsNumber = false, + Value = scoreValue + }); + var taskSendInfo = await _dbProvider.QueryAsync(new IoTDBQueryOptions() { TableNameOrTreePath = DevicePathBuilder.GetTableName(), Conditions = conditions,PageIndex=0,PageSize=1}); + + + + List datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList); + List list = GenerateFinalResult(2, datas, "正向有功电能示值", input.AFN_FC.AFN, input.DT.Fn); + unitDataAnalysis.Data= list; return await Task.FromResult(unitDataAnalysis); } @@ -98,6 +129,13 @@ namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH return list; } - + /// + /// 生成最终结果 + /// + /// + public Task SaveIotDbAsync() + { + + } } } diff --git a/shared/JiShe.CollectBus.Common/Consts/DataFieldConst.cs b/shared/JiShe.CollectBus.Common/Consts/DataFieldConst.cs new file mode 100644 index 0000000..0a1e16a --- /dev/null +++ b/shared/JiShe.CollectBus.Common/Consts/DataFieldConst.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Linq; +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 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 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"; // 当前电压、电流相位角 + + } +} diff --git a/shared/JiShe.CollectBus.Common/Helpers/DataFieldHelper.cs b/shared/JiShe.CollectBus.Common/Helpers/DataFieldHelper.cs new file mode 100644 index 0000000..a9173bb --- /dev/null +++ b/shared/JiShe.CollectBus.Common/Helpers/DataFieldHelper.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JiShe.CollectBus.Common.Helpers +{ + public class DataFieldHelper + { + public static string GetDataField(string dataField) + { + if (string.IsNullOrWhiteSpace(dataField)) + { + return string.Empty; + } + + if (dataField.Contains(".")) + { + return dataField.Split('.')[0]; + } + + return dataField; + } + } +}