添加接受OCH、ODH、10H等数据解析
This commit is contained in:
parent
825e7d5f18
commit
314d96dd59
@ -3,7 +3,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_00H
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_00H
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.1.3.1 F1:全部确认:对收到报文中的全部数据单元标识进行确认
|
||||
|
||||
@ -3,7 +3,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_00H
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_00H
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.1.3.2 F2:全部否认
|
||||
|
||||
@ -6,7 +6,7 @@ using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_09H
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_09H
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.9.1.2 F1:终端版本信息
|
||||
|
||||
@ -5,7 +5,7 @@ using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_09H
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_09H
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.9.2.4.9 F9:远程通信模块版本信息(只读解析SIM卡号)
|
||||
|
||||
@ -5,7 +5,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0AH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0AH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.10.1.3.1 F10:终端电能表/交流采样装置配置参数
|
||||
|
||||
@ -7,7 +7,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0AH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0AH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.5.1.3.53 F66:定时上报 2 类数据任务设置
|
||||
|
||||
@ -3,7 +3,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0AH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0AH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.5.1.3.55 F68:定时上报 2 类数据任务启动/停止设置
|
||||
|
||||
@ -4,7 +4,7 @@ using JiShe.CollectBus.IoTDB.Interface;
|
||||
using JiShe.CollectBus.IoTDB.Options;
|
||||
using JiShe.CollectBus.IoTDB.Provider;
|
||||
using JiShe.CollectBus.IotSystems.MeterReadingRecords;
|
||||
using JiShe.CollectBus.Protocol.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
@ -12,7 +12,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.12.2.4.85 F129:当前正向有功电能示值(总、费率1~M)
|
||||
@ -122,14 +122,5 @@ namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 生成最终结果
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public Task<bool> SaveIotDbAsync()
|
||||
//{
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using JiShe.CollectBus.Protocol.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
@ -6,7 +6,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.12.2.4.86 F130:当前正向无功(组合无功 1)电能示值(总、费率 1~M)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using JiShe.CollectBus.Protocol.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
@ -6,7 +6,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.12.2.4.87 F131:当前反向有功电能示值(总、费率 1~M)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using JiShe.CollectBus.Protocol.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
@ -6,7 +6,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.12.2.4.88 F132:当前反向无功(组合无功 2)电能示值(总、费率 1~M)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
@ -7,7 +7,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.12.2.4.101 F145:当月正向有功最大需量及发生时间(总、费率 1~M)
|
||||
|
||||
@ -1,48 +1,70 @@
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.12.2.4.105 F149:上月(上一结算日)正向有功最大需量及发生时间(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN12_F149_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<AFN12_F149_AnalysisDto>>
|
||||
public class AFN12_F149_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN12_F149_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
|
||||
public AFN12_F149_Analysis(ILogger<AFN12_F149_Analysis> logger, AnalysisStrategyContext analysisStrategyContext)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN12_F149_Analysis(ILogger<AFN12_F149_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage= dataStorage;
|
||||
}
|
||||
|
||||
|
||||
public async Task<UnitDataAnalysis<AFN12_F149_AnalysisDto>> ExecuteAsync(TB3761 input)
|
||||
public async Task<UnitDataAnalysis<AnalysisBaseDto<decimal>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
List<string> datas = await AnalysisDataUnit(input.UnitData.HexMessageList);
|
||||
AFN12_F149_AnalysisDto data = GenerateFinalResult(2, datas, "上月(上一结算日)正向有功最大需量及发生时间");
|
||||
AnalysisBaseDto<decimal> data = GenerateFinalResult(2, datas, "上月(上一结算日)正向有功最大需量及发生时间");
|
||||
data.DataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
UnitDataAnalysis<AFN12_F149_AnalysisDto> unitDataAnalysis = new UnitDataAnalysis<AFN12_F149_AnalysisDto>
|
||||
data.FiledDesc = "上月(上一结算日)正向有功最大需量及发生时间";
|
||||
data.FiledName = data.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
Code = input.A?.Code,
|
||||
AFN = input.AFN_FC?.AFN ?? 0,
|
||||
Fn = input.DT?.Fn ?? 0,
|
||||
Pn = input.DA?.Pn ?? 0,
|
||||
Data = data
|
||||
data.ProjectId = ammeterInfo.ProjectID;
|
||||
data.MeterId = ammeterInfo.MeterId;
|
||||
data.DatabaseBusiID=ammeterInfo.DatabaseBusiID;
|
||||
data.MeterAddress= ammeterInfo.AmmerterAddress;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<decimal>> unitDataAnalysis = new UnitDataAnalysis<AnalysisBaseDto<decimal>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA=input.A.A3!.D1_D7!,
|
||||
PSEQ=input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage=input.BaseHexMessage.HexMessageString,
|
||||
MessageId=input.MessageId,
|
||||
TimeDensity=1,
|
||||
DensityUnit = DensityUnit.Month
|
||||
};
|
||||
|
||||
await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -83,33 +105,38 @@ namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH
|
||||
}
|
||||
return values;
|
||||
}
|
||||
public AFN12_F149_AnalysisDto GenerateFinalResult(int index, List<string> data, string remark = "")
|
||||
public AnalysisBaseDto<decimal> GenerateFinalResult(int index, List<string> data, string remark = "")
|
||||
{
|
||||
AFN12_F149_AnalysisDto dto = new AFN12_F149_AnalysisDto();
|
||||
AnalysisBaseDto<decimal> dto = new AnalysisBaseDto<decimal>();
|
||||
|
||||
var errorCodeInfo = data[2].CheckErrorCode();
|
||||
if (errorCodeInfo != null)
|
||||
{
|
||||
dto.ValidData = false;
|
||||
dto.ErrorCodeMsg= errorCodeInfo.Item2;
|
||||
}
|
||||
decimal.TryParse(data[2], out decimal value);
|
||||
dto.DataValue = value;
|
||||
|
||||
dto.MeterType= MeterTypeEnum.Ammeter;
|
||||
//TODO:最大需量发生时间
|
||||
errorCodeInfo = data[3].CheckErrorCode();
|
||||
if (data[3].Length != 8 && errorCodeInfo != null)
|
||||
dto.ValidData = false;
|
||||
else
|
||||
dto.TimeSpan = $"{DateTime.Now.Year}-{data[3].Substring(0, 2)}-{data[3].Substring(2, 2)} {data[3].Substring(4, 2)}:{data[3].Substring(6, 2)}:00";
|
||||
{
|
||||
string timeSpan = $"{DateTime.Now.Year}-{data[3].Substring(0, 2)}-{data[3].Substring(2, 2)} {data[3].Substring(4, 2)}:{data[3].Substring(6, 2)}:00";
|
||||
|
||||
|
||||
//TODO:时间标
|
||||
if (!DateTime.TryParse(dto.TimeSpan, out DateTime readingDate))
|
||||
dto.ValidData = false;
|
||||
dto.ReadingDate = readingDate;
|
||||
//TODO:时间标
|
||||
if (!DateTime.TryParse(timeSpan, out DateTime dataTime))
|
||||
dto.ValidData = false;
|
||||
dto.DataTime = dataTime;
|
||||
}
|
||||
if (DateTime.Now.Month.Equals(1))//如果为1月份,则日期减去1年
|
||||
{
|
||||
dto.ReadingDate = dto.ReadingDate.AddYears(-1);
|
||||
dto.TimeSpan = dto.ReadingDate.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
dto.DataTime = dto.DataTime.AddYears(-1);
|
||||
dto.TimeSpan= dto.DataTime;
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 水表抄读取
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
@ -7,7 +7,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.12.2.4.22 F25:当前三相及总有/无功功率、功率因数,三相电压、电流、零序电流、视在功率
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
@ -7,7 +7,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.12.2.4.1 F2:终端日历时钟
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using JiShe.CollectBus.Protocol.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
@ -6,7 +6,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.12.2.4.30 F33:当前正向有/无功电能示值、一/四象限无功电能示值(总、费率 1~M,1≤M≤12)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
@ -7,7 +7,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.12.2.4.46 F49:当前电压、电流相位角
|
||||
|
||||
@ -0,0 +1,101 @@
|
||||
using IdentityModel;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.78 F100:测量点反向无功总电能量曲线
|
||||
/// </summary>
|
||||
public class AFN13_F100_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F100_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F100_Analysis(ILogger<AFN13_F100_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "反向无功总电能量");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_100解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A13), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.79 F101:测量点正向有功总电能示值曲线
|
||||
/// </summary>
|
||||
public class AFN13_F101_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F101_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F101_Analysis(ILogger<AFN13_F101_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "正向有功总电能示值");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_101解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.80 F102:测量点正向无功总电能示值曲线
|
||||
/// </summary>
|
||||
public class AFN13_F102_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F102_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F102_Analysis(ILogger<AFN13_F102_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "正向无功总电能示值");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_102解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.81 F103:测量点反向有功总电能示值曲线
|
||||
/// </summary>
|
||||
public class AFN13_F103_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F103_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F103_Analysis(ILogger<AFN13_F103_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "反向有功总电能示值");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_103解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.82 F104:测量点反向无功总电能示值曲线
|
||||
/// </summary>
|
||||
public class AFN13_F104_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F104_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F104_Analysis(ILogger<AFN13_F104_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "反向无功总电能示值");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_104解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.Protocol.T37612012;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.83 F105:测量点功率因数曲线
|
||||
/// </summary>
|
||||
public class AFN13_F105_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F105_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F105_Analysis(ILogger<AFN13_F105_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "功率因数");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_105解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 2), 2);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A5), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.Protocol.T37612012;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.84 F106:测量点 A相功率因数曲线
|
||||
/// </summary>
|
||||
public class AFN13_F106_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F106_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F106_Analysis(ILogger<AFN13_F106_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "A相功率因数");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_106解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 2), 2);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A5), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.84 F107:测量点 B相功率因数曲线
|
||||
/// </summary>
|
||||
public class AFN13_F107_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F107_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F107_Analysis(ILogger<AFN13_F107_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "B相功率因数");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_107解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 2), 2);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A5), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.84 F108:测量点 C相功率因数曲线
|
||||
/// </summary>
|
||||
public class AFN13_F108_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F108_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F108_Analysis(ILogger<AFN13_F108_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "C相功率因数");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_107解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 2), 2);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A5), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,149 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Data;
|
||||
using System.Diagnostics.Metrics;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.11 F11:抄表日冻结电能表正向有/无功最大需量及发生时间(总、费率 1~M,1≤M≤12)
|
||||
/// </summary>
|
||||
public class AFN13_F11_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F11_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F11_Analysis(ILogger<AFN13_F11_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
List<AnalysisBaseDto<decimal>> data = GenerateFinalResult(datas,3, dataType, "抄表日冻结电能表正向有功最大需量及发生时间");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_11解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.Add(hexMessageList.GetReadTime(4, 3));//日冻结类数据时标 Td_d
|
||||
values.Add(hexMessageList.GetReadTime(7, 5));//终端抄表时间
|
||||
int ratingCount = hexMessageList.GetRatingCount(12, 1);//费率数 M(1≤M≤12)
|
||||
values.Add(ratingCount.ToString());
|
||||
int handlerNum = 13;
|
||||
values.AddRange(await GetDataAsync<decimal>(hexMessageList.GetRange(handlerNum, 3 * (ratingCount + 1)), ratingCount, 3, nameof(Appendix_A23)));//正向有功总最大需量
|
||||
handlerNum += 3 * (ratingCount + 1);//12
|
||||
values.AddRange(await GetDataAsync<string>(hexMessageList.GetRange(handlerNum, 4 * (ratingCount + 1)), ratingCount, 4, nameof(Appendix_A17)));//正向有功总最大需量发生时间
|
||||
handlerNum += 4 * (ratingCount + 1);//28
|
||||
values.AddRange(await GetDataAsync<decimal>(hexMessageList.GetRange(handlerNum, 3 * (ratingCount + 1)), ratingCount, 3, nameof(Appendix_A23)));//正向无功总最大需量
|
||||
handlerNum += 3 * (ratingCount + 1);//48
|
||||
values.AddRange(await GetDataAsync<string>(hexMessageList.GetRange(handlerNum, 4 * (ratingCount + 1)), ratingCount, 4, nameof(Appendix_A17)));//正向无功总最大需量发生时间
|
||||
handlerNum += 4 * (ratingCount + 1);
|
||||
return values;
|
||||
}
|
||||
|
||||
private async Task<List<string>> GetDataAsync<T>(List<string> data, int ratingCount, int len, string appendixName)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = data.GetRange(0 + (i * len), len);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, T>(nameof(Appendix_A5), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
public List<AnalysisBaseDto<decimal>> GenerateFinalResult(List<string> data, int index, string dataType, string remark = "")
|
||||
{
|
||||
List<AnalysisBaseDto<decimal>> list = new List<AnalysisBaseDto<decimal>>();
|
||||
int fCount = Convert.ToInt32(data[2]) + 1;
|
||||
for (int i = 1; i <= 2; i++)
|
||||
{
|
||||
AnalysisBaseDto<decimal> meter = new AnalysisBaseDto<decimal>
|
||||
{
|
||||
MeterType = MeterTypeEnum.Ammeter
|
||||
};
|
||||
int startIndex = i == 1 ? 3 : (3 + i * fCount);
|
||||
|
||||
decimal value = 0;
|
||||
var errorCode = data[startIndex].CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
{
|
||||
meter.ValidData = false;
|
||||
meter.ErrorCodeMsg = errorCode.Item2;
|
||||
}
|
||||
else
|
||||
decimal.TryParse(data[startIndex], out value);
|
||||
|
||||
meter.DataValue = value;
|
||||
string timeSpan = $"{DateTime.Now.Year}-{data[startIndex + fCount].Substring(0, 2)}-{data[startIndex + fCount].Substring(2, 2)} {data[startIndex + fCount].Substring(4, 2)}:{data[startIndex + fCount].Substring(6, 2)}:00";
|
||||
DateTime readingDate = DateTime.Now;
|
||||
if (DateTime.TryParse(timeSpan, out readingDate))
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
meter.DataType = i == 1 ? dataType : $"{dataType}_{ i - 1}";
|
||||
remark = i == 1 ? remark : remark.Replace("有功", "无功");
|
||||
list.Add(meter);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.104 F145:测量点一象限无功总电能示值曲线
|
||||
/// </summary>
|
||||
public class AFN13_F145_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F145_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F145_Analysis(ILogger<AFN13_F145_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "一象限无功电能示值");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_145解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.105 F146:测量点四象限无功总电能示值曲线
|
||||
/// </summary>
|
||||
public class AFN13_F146_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F146_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F146_Analysis(ILogger<AFN13_F146_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "四象限无功电能示值");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_146解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.106 F147:测量点二象限无功总电能示值曲线
|
||||
/// </summary>
|
||||
public class AFN13_F147_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F147_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F147_Analysis(ILogger<AFN13_F147_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "二象限无功电能示值");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_147解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.107 F148:测量点三象限无功总电能示值曲线
|
||||
/// </summary>
|
||||
public class AFN13_F148_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F148_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F148_Analysis(ILogger<AFN13_F148_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "三象限无功电能示值");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_148解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,100 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using System;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.116 F161:日冻结正向有功电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F161_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F161_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F161_Analysis(ILogger<AFN13_F161_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-{datas[0].Substring(6, 2)} 00:00:00";
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_d(3, dataType,timeSpan, "正向有功总电能示值").IsValidData(new List<string>() { "0D_161", "0D_161_1", "0D_161_2", "0D_161_3", "0D_161_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_161解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 3),
|
||||
hexMessageList.GetReadTime(7, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(12, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(13 + (i * 5), 5);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A14), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.117 F162:日冻结正向无功(组合无功 1)电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F162_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F162_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F162_Analysis(ILogger<AFN13_F162_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-{datas[0].Substring(6, 2)} 00:00:00";
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_d(3, dataType, timeSpan, "正向无功(组合无功 1)电能示值").IsValidData(new List<string>() { "0D_162", "0D_162_1", "0D_162_2", "0D_162_3", "0D_162_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_162解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 3),
|
||||
hexMessageList.GetReadTime(7, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(12, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(13 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.118 F163:日冻结反向有功电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F163_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F163_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F163_Analysis(ILogger<AFN13_F163_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-{datas[0].Substring(6, 2)} 00:00:00";
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_d(3, dataType, timeSpan, "反向有功总电能示值").IsValidData(new List<string>() { "0D_163", "0D_163_1", "0D_163_2", "0D_163_3", "0D_163_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_163解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 3),
|
||||
hexMessageList.GetReadTime(7, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(12, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(13 + (i * 5), 5);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A14), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.119 F164:日冻结反向无功(组合无功 1)电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F164_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F164_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F164_Analysis(ILogger<AFN13_F164_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-{datas[0].Substring(6, 2)} 00:00:00";
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_d(3, dataType, timeSpan, "日冻结反向无功(组合无功 1)电能示值").IsValidData(new List<string>() { "0D_164", "0D_164_1", "0D_164_2", "0D_164_3", "0D_164_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_164解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 3),
|
||||
hexMessageList.GetReadTime(7, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(12, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(13 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.120 F165:日冻结一象限无功电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F165_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F165_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F165_Analysis(ILogger<AFN13_F165_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-{datas[0].Substring(6, 2)} 00:00:00";
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_d(3, dataType, timeSpan, "日冻结一象限无功电能示值").IsValidData(new List<string>() { "0D_165", "0D_165_1", "0D_165_2", "0D_165_3", "0D_165_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_165解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 3),
|
||||
hexMessageList.GetReadTime(7, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(12, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(13 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.121 F166:日冻结二象限无功电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F166_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F166_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F166_Analysis(ILogger<AFN13_F166_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-{datas[0].Substring(6, 2)} 00:00:00";
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_d(3, dataType, timeSpan, "日冻结二象限无功电能示值").IsValidData(new List<string>() { "0D_166", "0D_166_1", "0D_166_2", "0D_166_3", "0D_166_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_166解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 3),
|
||||
hexMessageList.GetReadTime(7, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(12, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(13 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.122 F167:日冻结三象限无功电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F167_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F167_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F167_Analysis(ILogger<AFN13_F167_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-{datas[0].Substring(6, 2)} 00:00:00";
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_d(3, dataType, timeSpan, "日冻结三象限无功电能示值").IsValidData(new List<string>() { "0D_167", "0D_167_1", "0D_167_2", "0D_167_3", "0D_167_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_167解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 3),
|
||||
hexMessageList.GetReadTime(7, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(12, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(13 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.123 F168:日冻结四象限无功电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F168_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F168_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F168_Analysis(ILogger<AFN13_F168_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-{datas[0].Substring(6, 2)} 00:00:00";
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_d(3, dataType, timeSpan, "日冻结四象限无功电能示值").IsValidData(new List<string>() { "0D_168", "0D_168_1", "0D_168_2", "0D_168_3", "0D_168_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_168解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 3),
|
||||
hexMessageList.GetReadTime(7, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(12, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(13 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.132 F177:月冻结正向有功电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F177_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F177_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F177_Analysis(ILogger<AFN13_F177_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-01 00:00:00";
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_m(3, dataType, timeSpan, "月冻结正向有功电能示值").IsValidData(new List<string>() { "0D_177", "0D_177_1", "0D_177_2", "0D_177_3", "0D_177_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_177解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 2),
|
||||
hexMessageList.GetReadTime(6, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(11, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(12 + (i * 5), 5);
|
||||
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A14), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// F178:月冻结正向无功(组合无功 1)电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F178_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F178_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F178_Analysis(ILogger<AFN13_F178_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-01 00:00:00";
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_m(3, dataType, timeSpan, "月冻结正向无功(组合无功 1)电能示值").IsValidData(new List<string>() { "0D_178", "0D_178_1", "0D_178_2", "0D_178_3", "0D_178_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_178解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 2),
|
||||
hexMessageList.GetReadTime(6, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(11, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(12 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.134 F179:月冻结反向有功电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F179_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F179_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F179_Analysis(ILogger<AFN13_F179_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-01 00:00:00";
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_m(3, dataType, timeSpan, "反向有功总电能示值").IsValidData(new List<string>() { "0D_179", "0D_179_1", "0D_179_2", "0D_179_3", "0D_179_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_179解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 2),
|
||||
hexMessageList.GetReadTime(6, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(11, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(12 + (i * 5), 5);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A14), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.135 F180:月冻结反向无功(组合无功 1)电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F180_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F180_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F180_Analysis(ILogger<AFN13_F180_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-01 00:00:00";
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_m(3, dataType, timeSpan, "月冻结反向无功(组合无功 1)电能示值").IsValidData(new List<string>() { "0D_180", "0D_180_1", "0D_180_2", "0D_180_3", "0D_180_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_180解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 2),
|
||||
hexMessageList.GetReadTime(6, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(11, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(12 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.136 F181:月冻结一象限无功电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F181_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F181_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F181_Analysis(ILogger<AFN13_F181_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-01 00:00:00";
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_m(3, dataType, timeSpan, "月冻结一象限无功电能示值(总、费率 1~M)").IsValidData(new List<string>() { "0D_181", "0D_181_1", "0D_181_2", "0D_181_3", "0D_181_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_181解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 2),
|
||||
hexMessageList.GetReadTime(6, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(11, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(12 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.137 F182:月冻结二象限无功电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F182_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F182_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F182_Analysis(ILogger<AFN13_F182_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-01 00:00:00";
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_m(3, dataType, timeSpan, "月冻结二象限无功电能示值(总、费率 1~M)").IsValidData(new List<string>() { "0D_182", "0D_182_1", "0D_182_2", "0D_182_3", "0D_182_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_182解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 2),
|
||||
hexMessageList.GetReadTime(6, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(11, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(12 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.138 F183:月冻结三象限无功电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F183_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F183_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F183_Analysis(ILogger<AFN13_F183_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-01 00:00:00";
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_m(3, dataType, timeSpan, "月冻结三象限无功电能示值(总、费率 1~M)").IsValidData(new List<string>() { "0D_183", "0D_183_1", "0D_183_2", "0D_183_3", "0D_183_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_183解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 2),
|
||||
hexMessageList.GetReadTime(6, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(11, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(12 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.139 F184:月冻结四象限无功电能示值(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F184_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F184_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F184_Analysis(ILogger<AFN13_F184_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-01 00:00:00";
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_m(3, dataType, timeSpan, "月冻结四象限无功电能示值(总、费率 1~M)").IsValidData(new List<string>() { "0D_184", "0D_184_1", "0D_184_2", "0D_184_3", "0D_184_4" });
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_184解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 2),
|
||||
hexMessageList.GetReadTime(6, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(11, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(12 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A11), arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,107 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.144 F189:抄表日冻结正向有功最大需量及发生时间(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F189_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F189_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F189_Analysis(ILogger<AFN13_F189_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string timeSpan = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-{datas[0].Substring(6, 2)} 00:00:00";
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_d(3, dataType, timeSpan, "抄表日冻结正向有功最大需量及发生时间");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_189解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.Add(hexMessageList.GetReadTime(4, 3));
|
||||
values.Add(hexMessageList.GetReadTime(7, 5));
|
||||
int ratingCount = hexMessageList.GetRatingCount(12, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
int handlerNum = 13;
|
||||
values.AddRange(await GetDataAsync<decimal>(hexMessageList.GetRange(handlerNum, 3), ratingCount, 3, nameof(Appendix_A23)));//正向有功总最大需量
|
||||
handlerNum += 3;
|
||||
values.AddRange(await GetDataAsync<string>(hexMessageList.GetRange(handlerNum, 4), ratingCount, 4, nameof(Appendix_A17)));//正向有功总最大需量发生时间
|
||||
return values;
|
||||
}
|
||||
|
||||
private async Task<List<string>> GetDataAsync<T>(List<string> data, int ratingCount, int len, string appendixName)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = data.GetRange(0 + (i * len), len);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, T>(appendixName, arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,139 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using System.Data;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.145 F190:抄表日冻结正向无功最大需量及发生时间(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F190_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<AnalysisBaseDto<decimal>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F190_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F190_Analysis(ILogger<AFN13_F190_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<AnalysisBaseDto<decimal>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
|
||||
AnalysisBaseDto<decimal> data = GenerateFinalResult(datas, "抄表日冻结正向无功最大需量及发生时间");
|
||||
data.DataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<AnalysisBaseDto<decimal>> unitDataAnalysis = new UnitDataAnalysis<AnalysisBaseDto<decimal>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_190解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.Add(hexMessageList.GetReadTime(4, 3));
|
||||
values.Add(hexMessageList.GetReadTime(7, 5));
|
||||
int ratingCount = hexMessageList.GetRatingCount(12, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
int handlerNum = 13;
|
||||
values.AddRange(await GetDataAsync<decimal>(hexMessageList.GetRange(handlerNum, 3 * (ratingCount + 1)), ratingCount, 3, nameof(Appendix_A23)));//正向有功总最大需量
|
||||
handlerNum += 3 * (ratingCount + 1);//12
|
||||
values.AddRange(await GetDataAsync<string>(hexMessageList.GetRange(handlerNum, 4 * (ratingCount + 1)), ratingCount, 4, nameof(Appendix_A17)));//正向有功总最大需量发生时间
|
||||
handlerNum += 4 * (ratingCount + 1);//28
|
||||
values.AddRange(await GetDataAsync<decimal>(hexMessageList.GetRange(handlerNum, 3 * (ratingCount + 1)), ratingCount, 3, nameof(Appendix_A23)));//正向无功总最大需量
|
||||
handlerNum += 3 * (ratingCount + 1);//48
|
||||
values.AddRange(await GetDataAsync<string>(hexMessageList.GetRange(handlerNum, 4 * (ratingCount + 1)), ratingCount, 4, nameof(Appendix_A17)));//正向无功总最大需量发生时间
|
||||
handlerNum += 4 * (ratingCount + 1);
|
||||
return values;
|
||||
}
|
||||
|
||||
private async Task<List<string>> GetDataAsync<T>(List<string> data, int ratingCount, int len, string appendixName)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = data.GetRange(0 + (i * len), len);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, T>(appendixName, arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
public AnalysisBaseDto<decimal> GenerateFinalResult(List<string> data, string remark = "")
|
||||
{
|
||||
List<AnalysisBaseDto<decimal>> list = new List<AnalysisBaseDto<decimal>>();
|
||||
AnalysisBaseDto<decimal> meter = new AnalysisBaseDto<decimal>
|
||||
{
|
||||
MeterType = MeterTypeEnum.Ammeter
|
||||
};
|
||||
|
||||
decimal value = 0;
|
||||
var errorCode = data[3].CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
{
|
||||
meter.ValidData = false;
|
||||
meter.ErrorCodeMsg = errorCode.Item2;
|
||||
}
|
||||
else
|
||||
decimal.TryParse(data[3], out value);
|
||||
meter.DataValue = value;
|
||||
|
||||
string timeSpan = $"{DateTime.Now.Year}-{data[4].Substring(0, 2)}-{data[4].Substring(2, 2)} {data[4].Substring(4, 2)}:{data[4].Substring(6, 2)}:00";//$"{data[0].Substring(0, 4)}-{data[0].Substring(4, 2)}-{data[0].Substring(6, 2)}";
|
||||
DateTime readingDate = DateTime.Now;
|
||||
if (DateTime.TryParse(timeSpan, out readingDate))
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
return meter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,128 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.148 F193:月冻结正向有功最大需量及发生时间(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F193_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F193_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F193_Analysis(ILogger<AFN13_F193_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<AnalysisBaseDto<decimal>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
|
||||
AnalysisBaseDto<decimal> data = GenerateFinalResult(datas, "月冻结正向有功最大需量及发生时间");
|
||||
data.DataType= $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<AnalysisBaseDto<decimal>> unitDataAnalysis = new UnitDataAnalysis<AnalysisBaseDto<decimal>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_193解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 2),
|
||||
hexMessageList.GetReadTime(6, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(11, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
int handlerNum = 12;
|
||||
values.AddRange(await GetDataAsync<decimal>(hexMessageList.GetRange(handlerNum, 3), 3, nameof(Appendix_A23)));//正向有功总最大需量
|
||||
handlerNum += 3;
|
||||
values.AddRange(await GetDataAsync<string>(hexMessageList.GetRange(handlerNum, 4), 4, nameof(Appendix_A17)));//正向有功总最大需量发生时间
|
||||
return values;
|
||||
}
|
||||
|
||||
private async Task<List<string>> GetDataAsync<T>(List<string> data, int len, string appendixName)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
var errorCode = data.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, T>(appendixName, data); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
return values;
|
||||
}
|
||||
public AnalysisBaseDto<decimal> GenerateFinalResult(List<string> data, string remark = "")
|
||||
{
|
||||
AnalysisBaseDto<decimal> meter = new AnalysisBaseDto<decimal>
|
||||
{
|
||||
MeterType = MeterTypeEnum.Ammeter,
|
||||
};
|
||||
|
||||
decimal value = 0;
|
||||
var errorCode = data[3].CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
{
|
||||
meter.ValidData = false;
|
||||
meter.ErrorCodeMsg = errorCode.Item2;
|
||||
}
|
||||
else
|
||||
decimal.TryParse(data[3], out value);
|
||||
meter.DataValue = value;
|
||||
|
||||
string timeSpan = $"{data[0].Substring(0, 4)}-{data[4].Substring(0, 2)}-{data[4].Substring(2, 2)} {data[4].Substring(4, 2)}:{data[4].Substring(6, 2)}:00";//$"{data[0].Substring(0, 4)}-{data[0].Substring(4, 2)}-{data[0].Substring(6, 2)}";
|
||||
DateTime readingDate = DateTime.Now;
|
||||
if (DateTime.TryParse(timeSpan, out readingDate))
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
return meter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,128 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.150 F195:月冻结反向有功最大需量及发生时间(总、费率 1~M)
|
||||
/// </summary>
|
||||
public class AFN13_F195_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F195_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F195_Analysis(ILogger<AFN13_F195_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<AnalysisBaseDto<decimal>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
|
||||
AnalysisBaseDto<decimal> data = GenerateFinalResult(datas, "月冻结反向有功最大需量及发生时间");
|
||||
data.DataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<AnalysisBaseDto<decimal>> unitDataAnalysis = new UnitDataAnalysis<AnalysisBaseDto<decimal>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_195解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 2),
|
||||
hexMessageList.GetReadTime(6, 5)
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(11, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
int handlerNum = 12;
|
||||
values.AddRange(await GetDataAsync<decimal>(hexMessageList.GetRange(handlerNum, 3), 3,nameof(Appendix_A23)));//正向有功总最大需量
|
||||
handlerNum += 3;
|
||||
values.AddRange(await GetDataAsync<string>(hexMessageList.GetRange(handlerNum, 4), 4, nameof(Appendix_A17)));//正向有功总最大需量发生时间
|
||||
return values;
|
||||
}
|
||||
|
||||
private async Task<List<string>> GetDataAsync<T>(List<string> data, int len, string appendixName)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
var errorCode = data.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, T>(appendixName, data); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
return values;
|
||||
}
|
||||
public AnalysisBaseDto<decimal> GenerateFinalResult(List<string> data, string remark = "")
|
||||
{
|
||||
AnalysisBaseDto<decimal> meter = new AnalysisBaseDto<decimal>
|
||||
{
|
||||
MeterType = MeterTypeEnum.Ammeter
|
||||
};
|
||||
|
||||
decimal value = 0;
|
||||
var errorCode = data[3].CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
{
|
||||
meter.ValidData = false;
|
||||
meter.ErrorCodeMsg = errorCode.Item2;
|
||||
}
|
||||
else
|
||||
decimal.TryParse(data[3], out value);
|
||||
meter.DataValue = value;
|
||||
|
||||
string timeSpan = $"{data[0].Substring(0, 4)}-{data[4].Substring(0, 2)}-{data[4].Substring(2, 2)} {data[4].Substring(4, 2)}:{data[4].Substring(6, 2)}:00";//$"{data[0].Substring(0, 4)}-{data[0].Substring(4, 2)}-{data[0].Substring(6, 2)}";
|
||||
DateTime readingDate = DateTime.Now;
|
||||
if (DateTime.TryParse(timeSpan, out readingDate))
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
return meter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,144 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using System.Data;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.15 F19:月冻结电能表正向有/无功最大需量及发生时间(总、费率 1~M,1≤M≤12)
|
||||
/// </summary>
|
||||
public class AFN13_F19_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F19_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F19_Analysis(ILogger<AFN13_F19_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
List<AnalysisBaseDto<decimal>> data = GenerateFinalResult(datas, dataType, "月冻结电能表正向有功最大需量及发生时间");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_19解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.Add(hexMessageList.GetReadTime(4, 2));//月冻结类数据时标 Td_m
|
||||
values.Add(hexMessageList.GetReadTime(6, 5));//
|
||||
int ratingCount = hexMessageList.GetRatingCount(11, 1);
|
||||
values.Add(ratingCount.ToString());
|
||||
int handlerNum = 12;
|
||||
values.AddRange(await GetDataAsync<decimal>(hexMessageList.GetRange(handlerNum, 3 * (ratingCount + 1)), ratingCount, 3, nameof(Appendix_A23)));//正向有功总最大需量
|
||||
handlerNum += 3 * (ratingCount + 1);
|
||||
values.AddRange(await GetDataAsync<string>(hexMessageList.GetRange(handlerNum, 4 * (ratingCount + 1)), ratingCount, 4, nameof(Appendix_A17)));//正向有功总最大需量发生时间
|
||||
handlerNum += 4 * (ratingCount + 1);
|
||||
values.AddRange(await GetDataAsync<decimal>(hexMessageList.GetRange(handlerNum, 3 * (ratingCount + 1)), ratingCount, 3, nameof(Appendix_A23)));//正向无功总最大需量
|
||||
handlerNum += 3 * (ratingCount + 1);
|
||||
values.AddRange(await GetDataAsync<string>(hexMessageList.GetRange(handlerNum, 4 * (ratingCount + 1)), ratingCount, 4, nameof(Appendix_A17)));//正向无功总最大需量发生时间
|
||||
handlerNum += 4 * (ratingCount + 1);
|
||||
return values;
|
||||
}
|
||||
|
||||
private async Task<List<string>> GetDataAsync<T>(List<string> data, int ratingCount, int len, string appendixName)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = data.GetRange(0 + (i * len), len);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, T>(appendixName, arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
public List<AnalysisBaseDto<decimal>> GenerateFinalResult(List<string> data, string dataType,string remark = "")
|
||||
{
|
||||
List<AnalysisBaseDto<decimal>> list = new List<AnalysisBaseDto<decimal>>();
|
||||
int fCount = Convert.ToInt32(data[2]) + 1;
|
||||
for (int i = 1; i <= 2; i++)
|
||||
{
|
||||
AnalysisBaseDto<decimal> meter = new AnalysisBaseDto<decimal>();
|
||||
meter.MeterType= MeterTypeEnum.Ammeter;
|
||||
int startIndex = i == 1 ? 3 : (3 + i * fCount);
|
||||
decimal value = 0;
|
||||
var errorCode = data[startIndex].CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
{
|
||||
meter.ValidData = false;
|
||||
meter.ErrorCodeMsg = errorCode.Item2;
|
||||
}
|
||||
else
|
||||
decimal.TryParse(data[startIndex], out value);
|
||||
meter.DataValue = value;
|
||||
//2021 01 15
|
||||
string timeSpan = $"{DateTime.Now.Year}-{data[startIndex + fCount].Substring(0, 2)}-{data[startIndex + fCount].Substring(2, 2)} {data[startIndex + fCount].Substring(4, 2)}:{data[startIndex + fCount].Substring(6, 2)}:00";
|
||||
DateTime readingDate = DateTime.Now;
|
||||
if (DateTime.TryParse(timeSpan, out readingDate))
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
meter.DataType = i == 1 ? dataType : $"{dataType}_{ i - 1}";
|
||||
|
||||
remark = i == 1 ? remark : remark.Replace("有功", "无功");
|
||||
list.Add(meter);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,171 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Data;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.3 F3:日冻结正向有/无功最大需量及发生时间(总、费率 1~M,1≤M≤12)
|
||||
/// </summary>
|
||||
public class AFN13_F3_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F3_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F3_Analysis(ILogger<AFN13_F3_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
//冻结数据时标
|
||||
var time = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-{datas[0].Substring(6, 2)} 00:00:00";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = GenerateFinalResult(datas,dataType, "日冻结正向有/无功最大需量及发生时间");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_3解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 3),//日冻结类数据时标 Td_d
|
||||
hexMessageList.GetReadTime(7, 5)//终端抄表时间
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(12, 1);//费率数 M(1≤M≤12)
|
||||
values.Add(ratingCount.ToString());
|
||||
int handlerNum = 13;
|
||||
values.AddRange(await GetDataAsync<decimal>(hexMessageList.GetRange(handlerNum, 3 * (ratingCount + 1)), ratingCount, 3, nameof(Appendix_A23)));//正向有功总最大需量
|
||||
handlerNum += 3 * (ratingCount + 1);//12
|
||||
values.AddRange(await GetDataAsync<string>(hexMessageList.GetRange(handlerNum, 4 * (ratingCount + 1)), ratingCount, 4, nameof(Appendix_A17)));//正向有功总最大需量发生时间
|
||||
handlerNum += 4 * (ratingCount + 1);//28
|
||||
values.AddRange(await GetDataAsync<decimal>(hexMessageList.GetRange(handlerNum, 3 * (ratingCount + 1)), ratingCount, 3, nameof(Appendix_A23)));//正向无功总最大需量
|
||||
handlerNum += 3 * (ratingCount + 1);//48
|
||||
values.AddRange(await GetDataAsync<string>(hexMessageList.GetRange(handlerNum, 4 * (ratingCount + 1)), ratingCount, 4, nameof(Appendix_A17)));//正向无功总最大需量发生时间
|
||||
handlerNum += 4 * (ratingCount + 1);
|
||||
return values;
|
||||
}
|
||||
|
||||
private async Task<List<string>> GetDataAsync<T>(List<string> data, int ratingCount, int len, string appendixName)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = data.GetRange(0 + (i * len), len);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, T>(appendixName, arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
public List<AnalysisBaseDto<decimal>> GenerateFinalResult(List<string> data,string dataType, string remark = "")
|
||||
{
|
||||
List<AnalysisBaseDto<decimal>> list = new List<AnalysisBaseDto<decimal>>();
|
||||
int fCount = Convert.ToInt32(data[2]) + 1;
|
||||
for (int i = 1; i <= 2; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
AnalysisBaseDto<decimal> meter = new AnalysisBaseDto<decimal>
|
||||
{
|
||||
MeterType = MeterTypeEnum.Ammeter
|
||||
};
|
||||
int startIndex = i == 1 ? 3 : (3 + i * fCount);
|
||||
|
||||
var errorCode = data[startIndex].CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
meter.ValidData = false;
|
||||
decimal.TryParse(data[startIndex], out decimal value);//decimal.TryParse(data[startIndex], out value);
|
||||
meter.DataValue = value;
|
||||
|
||||
//TODO:日冻结类数据时标Td 20210824
|
||||
var dataTime = string.Empty;
|
||||
errorCode = data[0].CheckErrorCode();
|
||||
if (data[0].Length == 8 && errorCode is null)
|
||||
dataTime = $"{data[0].Substring(0, 4)}-{data[0].Substring(4, 2)}-{data[0].Substring(6, 2)} 00:00:00";
|
||||
if (!DateTime.TryParse(dataTime, out DateTime readingDate))
|
||||
meter.ValidData = false;
|
||||
meter.TimeSpan = readingDate;//
|
||||
|
||||
//TODO:最大需量发生时间
|
||||
errorCode = data[startIndex + fCount].CheckErrorCode();
|
||||
if (errorCode != null && data[startIndex + fCount].Length != 8)
|
||||
meter.ValidData = false;
|
||||
else
|
||||
{
|
||||
string timeSpan = $"{data[0].Substring(0, 4)}-{data[startIndex + fCount].Substring(0, 2)}-{data[startIndex + fCount].Substring(2, 2)} {data[startIndex + fCount].Substring(4, 2)}:{data[startIndex + fCount].Substring(6, 2)}:00";
|
||||
if (!DateTime.TryParse(timeSpan, out DateTime tsField))
|
||||
meter.ValidData = false;
|
||||
else
|
||||
meter.TimeSpan=tsField;
|
||||
}
|
||||
|
||||
meter.DataType = i == 1 ? dataType : $"{dataType}_{ i - 1}";
|
||||
remark = i == 1 ? remark : remark.Replace("有功", "无功");
|
||||
list.Add(meter);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
if (list.Count == 0)
|
||||
throw new Exception("错误数据");
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,172 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using AutoMapper.Internal.Mappers;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.4 F4:日冻结反向有/无功最大需量及发生时间(总、费率 1~M,1≤M≤12)
|
||||
/// </summary>
|
||||
public class AFN13_F4_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
private readonly ILogger<AFN13_F4_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F4_Analysis(ILogger<AFN13_F4_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
//冻结数据时标
|
||||
var time = $"{datas[0].Substring(0, 4)}-{datas[0].Substring(4, 2)}-{datas[0].Substring(6, 2)} 00:00:00";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = GenerateFinalResult(datas, dataType, "日冻结反向有/无功最大需量及发生时间");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_4解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
hexMessageList.GetReadTime(4, 3),//日冻结类数据时标 Td_d
|
||||
hexMessageList.GetReadTime(7, 5)//终端抄表时间
|
||||
};
|
||||
int ratingCount = hexMessageList.GetRatingCount(12, 1);//费率数 M(1≤M≤12)
|
||||
values.Add(ratingCount.ToString());
|
||||
int handlerNum = 13;
|
||||
values.AddRange(await GetDataAsync<decimal>(hexMessageList.GetRange(handlerNum, 3 * (ratingCount + 1)), ratingCount, 3, nameof(Appendix_A23)));//正向有功总最大需量
|
||||
handlerNum += 3 * (ratingCount + 1);//12
|
||||
values.AddRange(await GetDataAsync<string>(hexMessageList.GetRange(handlerNum, 4 * (ratingCount + 1)), ratingCount, 4, nameof(Appendix_A17)));//正向有功总最大需量发生时间
|
||||
handlerNum += 4 * (ratingCount + 1);//28
|
||||
values.AddRange(await GetDataAsync<decimal>(hexMessageList.GetRange(handlerNum, 3 * (ratingCount + 1)), ratingCount, 3, nameof(Appendix_A23)));//正向无功总最大需量
|
||||
handlerNum += 3 * (ratingCount + 1);//48
|
||||
values.AddRange(await GetDataAsync<string>(hexMessageList.GetRange(handlerNum, 4 * (ratingCount + 1)), ratingCount, 4, nameof(Appendix_A17)));//正向无功总最大需量发生时间
|
||||
handlerNum += 4 * (ratingCount + 1);
|
||||
return values;
|
||||
}
|
||||
|
||||
private async Task<List<string>> GetDataAsync<T>(List<string> data, int ratingCount, int len, string appendixName)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
for (int i = 0; i < ratingCount + 1; i++)
|
||||
{
|
||||
var arr = data.GetRange(0 + (i * len), len);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, T>(appendixName, arr); //从第10个开始,每加5个字节为下一个值的开始
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
public List<AnalysisBaseDto<decimal>> GenerateFinalResult(List<string> data,string dataType, string remark = "")
|
||||
{
|
||||
List<AnalysisBaseDto<decimal>> list = new List<AnalysisBaseDto<decimal>>();
|
||||
int fCount = Convert.ToInt32(data[2]) + 1;
|
||||
for (int i = 1; i <= 2; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
AnalysisBaseDto<decimal> meter = new AnalysisBaseDto<decimal>
|
||||
{
|
||||
MeterType = MeterTypeEnum.Ammeter
|
||||
};
|
||||
int startIndex = i == 1 ? 3 : (3 + i * fCount);
|
||||
|
||||
var errorCode = data[startIndex].CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
{
|
||||
meter.ValidData = false;
|
||||
meter.ErrorCodeMsg = errorCode.Item2;
|
||||
}
|
||||
decimal.TryParse(data[startIndex], out decimal value);//decimal.TryParse(data[startIndex], out value);
|
||||
meter.DataValue = value;
|
||||
|
||||
//TODO:日冻结类数据时标Td 20210824
|
||||
var dataTime = string.Empty;
|
||||
errorCode = data[0].CheckErrorCode();
|
||||
if (data[0].Length == 8 && errorCode is null)
|
||||
dataTime = $"{data[0].Substring(0, 4)}-{data[0].Substring(4, 2)}-{data[0].Substring(6, 2)} 00:00:00";
|
||||
if (!DateTime.TryParse(dataTime, out DateTime readingDate))
|
||||
meter.ValidData = false;
|
||||
meter.TimeSpan = readingDate;
|
||||
|
||||
//TODO:最大需量发生时间
|
||||
errorCode = data[startIndex + fCount].CheckErrorCode();
|
||||
if (errorCode != null && data[startIndex + fCount].Length != 8)
|
||||
meter.ValidData = false;
|
||||
else
|
||||
{
|
||||
string timeSpan = $"{data[0].Substring(0, 4)}-{data[startIndex + fCount].Substring(0, 2)}-{data[startIndex + fCount].Substring(2, 2)} {data[startIndex + fCount].Substring(4, 2)}:{data[startIndex + fCount].Substring(6, 2)}:00";
|
||||
if (!DateTime.TryParse(timeSpan, out DateTime tsField))
|
||||
meter.ValidData = false;
|
||||
else
|
||||
meter.TimeSpan = tsField;
|
||||
}
|
||||
meter.DataType = i == 1 ? dataType : $"{dataType}_{ i - 1}";
|
||||
remark = i == 1 ? remark : remark.Replace("有功", "无功");
|
||||
list.Add(meter);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
if (list.Count == 0)
|
||||
throw new Exception("错误数据");
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.60 F81:测量点有功功率曲线
|
||||
/// </summary>
|
||||
public class AFN13_F81_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F81_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F81_Analysis(ILogger<AFN13_F81_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "有功功率曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_81解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 3), 3);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A9), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.61 F82:测量点 A相有功功率曲线
|
||||
/// </summary>
|
||||
public class AFN13_F82_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F82_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F82_Analysis(ILogger<AFN13_F82_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "A相有功功率曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_82解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 3), 3);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A9), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.61 F83:测量点 B相有功功率曲线
|
||||
/// </summary>
|
||||
public class AFN13_F83_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F83_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F83_Analysis(ILogger<AFN13_F83_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "B相有功功率曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_83解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 3), 3);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A9), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.61 F84:测量点 C相有功功率曲线
|
||||
/// </summary>
|
||||
public class AFN13_F84_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F84_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F84_Analysis(ILogger<AFN13_F84_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "C相有功功率曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_84解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 3), 3);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A9), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.64 F85:测量点无功功率曲线
|
||||
/// </summary>
|
||||
public class AFN13_F85_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F85_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F85_Analysis(ILogger<AFN13_F85_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "无功功率曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_85解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 3), 3);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A9), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.65 F86:测量点 A相无功功率曲线
|
||||
/// </summary>
|
||||
public class AFN13_F86_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F86_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F86_Analysis(ILogger<AFN13_F86_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "A相无功功率曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_86解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 3), 3);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A9), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.66 F87:测量点 B相无功功率曲线
|
||||
/// </summary>
|
||||
public class AFN13_F87_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F87_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F87_Analysis(ILogger<AFN13_F87_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "B相无功功率曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_87解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 3), 3);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A9), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.67 F88:测量点 C相无功功率曲线
|
||||
/// </summary>
|
||||
public class AFN13_F88_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F88_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F88_Analysis(ILogger<AFN13_F88_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "C相无功功率曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_88解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 3), 3);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A9), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.68 F89:测量点 A相电压曲线
|
||||
/// </summary>
|
||||
public class AFN13_F89_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F89_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F89_Analysis(ILogger<AFN13_F89_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "A相电压曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_89解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 2), 2);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A7), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.68 F89:测量点 B相电压曲线
|
||||
/// </summary>
|
||||
public class AFN13_F90_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F90_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F90_Analysis(ILogger<AFN13_F90_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "B相电压曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_90解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 2), 2);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A7), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.68 F89:测量点 C相电压曲线
|
||||
/// </summary>
|
||||
public class AFN13_F91_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F91_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F91_Analysis(ILogger<AFN13_F91_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "C相电压曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_91解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 2), 2);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A7), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.71 F92:测量点 A相电流曲线
|
||||
/// </summary>
|
||||
public class AFN13_F92_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F92_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F92_Analysis(ILogger<AFN13_F92_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "A相电流曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_92解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 3), 3);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A25), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.72 F93:测量点 B相电流曲线
|
||||
/// </summary>
|
||||
public class AFN13_F93_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F93_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F93_Analysis(ILogger<AFN13_F93_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "B相电流曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_93解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 3), 3);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A25), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.73 F94:测量点 C相电流曲线
|
||||
/// </summary>
|
||||
public class AFN13_F94_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F94_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F94_Analysis(ILogger<AFN13_F94_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "C相电流曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_94解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 3), 3);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A25), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.74 F95:测量点零序电流曲线
|
||||
/// </summary>
|
||||
public class AFN13_F95_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F95_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F95_Analysis(ILogger<AFN13_F95_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "测量点零序电流曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_95解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 3), 3);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A25), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.75 F97:测量点正向有功总电能量曲线
|
||||
/// </summary>
|
||||
public class AFN13_F97_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F97_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F97_Analysis(ILogger<AFN13_F97_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "正向有功总电能量曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_97解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A13), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.76 F98:测量点正向无功总电能量曲线
|
||||
/// </summary>
|
||||
public class AFN13_F98_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F98_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F98_Analysis(ILogger<AFN13_F98_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "正向无功总电能量曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_98解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A13), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.13.2.4.77 F99:测量点反向有功总电能量曲线
|
||||
/// </summary>
|
||||
public class AFN13_F99_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN13_F99_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN13_F99_Analysis(ILogger<AFN13_F99_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Enum.GetName(typeof(DensityEnums), Convert.ToInt32(datas[1]))!.Split('_')[1]);//密度-间隔分钟数,
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "反向有功总电能量曲线");
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0D_99解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.AddRange(hexMessageList.GetReadTimeTd_c(4, 7));
|
||||
int.TryParse(values[values.Count - 1], out int n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var arr = hexMessageList.GetRange(11 + (i * 4), 4);
|
||||
var errorCode = arr.CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
values.Add(errorCode.Item1);
|
||||
else
|
||||
{
|
||||
var value = await _analysisStrategyContext.ExecuteAsync<List<string>, decimal>(nameof(Appendix_A13), arr);
|
||||
values.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AFN_00H;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0EH
|
||||
{
|
||||
/// <summary>
|
||||
/// 请求重要事件
|
||||
/// Item1=停电事件
|
||||
/// Item2=上电事件
|
||||
/// </summary>
|
||||
public class AFN14_F1_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<Tuple<string, string>>>
|
||||
{
|
||||
private readonly ILogger<AFN14_F1_Analysis> _logger;
|
||||
|
||||
public AFN14_F1_Analysis(ILogger<AFN14_F1_Analysis> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Task<UnitDataAnalysis<Tuple<string, string>>> ExecuteAsync(TB3761 tB3761)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(nameof(tB3761));
|
||||
ArgumentNullException.ThrowIfNull(nameof(tB3761.UnitData.HexMessageList));
|
||||
int erc = tB3761.UnitData.HexMessageList![8].HexToDec();
|
||||
bool isOnOffPower = erc.Equals(14) ? true : false;
|
||||
if (!isOnOffPower)
|
||||
{
|
||||
throw new Exception($"ERC{erc}非上掉电事件");
|
||||
}
|
||||
UnitDataAnalysis<Tuple<string, string>> dto = new UnitDataAnalysis<Tuple<string, string>>
|
||||
{
|
||||
Code = tB3761.A.Code!,
|
||||
AFN = tB3761.AFN_FC.AFN,
|
||||
Fn = tB3761.DT.Fn,
|
||||
Pn = tB3761.DA.Pn,
|
||||
Data = AnalysisDataUnit(tB3761.UnitData.HexMessageList)
|
||||
};
|
||||
// meterData.DataType = "0E_1";
|
||||
return Task.FromResult(dto);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0E_1解析失败:{tB3761.A.Code}-{tB3761.DT.Fn}-{tB3761.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Tuple<string, string> AnalysisDataUnit(List<string> hexMessageList)
|
||||
{
|
||||
/// Item1=停电事件
|
||||
/// Item2=上电事件
|
||||
return Tuple.Create(HandlerTime(hexMessageList.GetRange(10, 5)), HandlerTime(hexMessageList.GetRange(15, 5)));
|
||||
}
|
||||
/// <summary>
|
||||
/// /解析时间
|
||||
/// </summary>
|
||||
/// <param name="times"></param>
|
||||
/// <param name="isSetCurTime">时间验证失败是否默认为当前时间</param>
|
||||
/// <returns></returns>
|
||||
private string HandlerTime(List<string> times)
|
||||
{
|
||||
var time = string.Empty;
|
||||
try
|
||||
{
|
||||
times.Reverse();
|
||||
time = $"{DateTime.Now.ToString("yyyy").Substring(0, 2)}{times[0]}-{times[1]}-{times[2]} {times[3]}:{times[4]}:00";
|
||||
|
||||
}
|
||||
catch { }
|
||||
return time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,58 @@
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AFN_09H;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
|
||||
namespace GatherService.WattMeter.AnalysisData.AFN_10H
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.16.1.2.1 F1:透明转发 读取SIM卡信息
|
||||
/// </summary>
|
||||
public class AFN16_F101_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<string>>
|
||||
{
|
||||
private readonly ILogger<AFN16_F101_Analysis> _logger;
|
||||
|
||||
public AFN16_F101_Analysis(ILogger<AFN16_F101_Analysis> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Task<UnitDataAnalysis<string>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData.HexMessageList);
|
||||
UnitDataAnalysis<string> dto = new UnitDataAnalysis<string>
|
||||
{
|
||||
Code = input.A.Code,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = AnalysisDataUnit(input.UnitData.HexMessageList) //SIM卡
|
||||
};
|
||||
return Task.FromResult(dto);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"10_101解析失败:{input.A?.Code}-{input.DT?.Fn ?? 0}-{input?.BaseHexMessage?.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private string AnalysisDataUnit(List<string> hexMessageList)
|
||||
{
|
||||
//TODO:转发内容
|
||||
var dataArray = hexMessageList.Skip(18).ToList();
|
||||
var contentLengthArr = dataArray.Skip(1).Take(2).ToList();
|
||||
contentLengthArr.Reverse();
|
||||
int contentLength = string.Join("", contentLengthArr).HexToDec();
|
||||
var dataField = dataArray.Skip(3).Take(contentLength).ToList();
|
||||
var sim = string.Join("", dataField).TrimStart('0');
|
||||
return sim.Length != 20 ? "" : sim;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,107 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.Protocol.T37612012;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
|
||||
namespace GatherService.WattMeter.AnalysisData.AFN_10H
|
||||
{
|
||||
/// <summary>
|
||||
/// 透明转发---跳合闸
|
||||
/// </summary>
|
||||
public class AFN16_F98_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<bool>>
|
||||
{
|
||||
|
||||
private readonly ILogger<AFN16_F98_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN16_F98_Analysis(ILogger<AFN16_F98_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<UnitDataAnalysis<bool>> ExecuteAsync(TB3761 input)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = AnalysisDataUnit(input.UnitData.HexMessageList);
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<bool> unitDataAnalysis = new UnitDataAnalysis<bool>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = (datas[2].Equals("9C") || datas[2].Equals("94")) ? true : false,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Second
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
return await Task.FromResult(unitDataAnalysis);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"10_98跳合闸解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> AnalysisDataUnit(List<string> hexMessageList)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
values.Add(hexMessageList.GetRange(4, 1)[0].HexToDec().ToString());//端口号
|
||||
var contentLengthArr = hexMessageList.GetRange(5, 2);
|
||||
contentLengthArr.Reverse();
|
||||
int contentLength = string.Join("", contentLengthArr).HexToDec();
|
||||
//TODO:转发内容
|
||||
List<string> contentArr = hexMessageList.GetRange(7, contentLength);
|
||||
//TODO:表地址
|
||||
var addressList = contentArr.GetRange(1, 6);
|
||||
addressList.Reverse();
|
||||
var address = string.Join("", addressList);
|
||||
values.Add(address);
|
||||
//TODO:控制码
|
||||
var controlCode = contentArr.GetRange(8, 1)[0];
|
||||
values.Add(controlCode);
|
||||
//TODO:长度
|
||||
//var len = contentArr.GetRange(9, 1)[0].DataConvert(16);
|
||||
//values.Add(len.ToString());
|
||||
//TODO:数据域
|
||||
//var dataField = contentArr.GetRange(10, len);
|
||||
//if (dataField.Count > 0)
|
||||
//{
|
||||
// string dataMark = string.Join("", CalculateErrControl(dataField.GetRange(0, 4)));
|
||||
// values.Add(dataMark);//数据标识
|
||||
// var readValue = CalculateErrControl(dataField.GetRange(4, len - 4));//值
|
||||
// var valueData = GetValue<List<string>>(readValue, (AppendixEnums)Enum.Parse(typeof(AppendixEnums), dataMark));
|
||||
// values.AddRange(valueData);
|
||||
//}
|
||||
|
||||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,17 +1,146 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JiShe.CollectBus.Common;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Encrypt;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IoTDB.Context;
|
||||
using JiShe.CollectBus.IoTDB.Interface;
|
||||
using JiShe.CollectBus.IoTDB.Model;
|
||||
using JiShe.CollectBus.IoTDB.Options;
|
||||
using JiShe.CollectBus.IoTDB.Provider;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.IotSystems.MeterReadingRecords;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Guids;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
{
|
||||
public class DataStorage:ITransientDependency
|
||||
{
|
||||
public DataStorage()
|
||||
private readonly IGuidGenerator _guidGenerator;
|
||||
private readonly IIoTDbProvider _dbProvider;
|
||||
private readonly ServerApplicationOptions _applicationOptions;
|
||||
private readonly IoTDBRuntimeContext _runtimeContext;
|
||||
public DataStorage(IIoTDbProvider dbProvider, IOptions<ServerApplicationOptions> applicationOptions, IGuidGenerator guidGenerator, IoTDBRuntimeContext runtimeContext)
|
||||
{
|
||||
|
||||
_dbProvider= dbProvider;
|
||||
_applicationOptions = applicationOptions.Value;
|
||||
_guidGenerator= guidGenerator;
|
||||
_runtimeContext= runtimeContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存电表信息
|
||||
/// </summary>
|
||||
/// <param name="meterType"></param>
|
||||
/// <param name="timeDensity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AmmeterInfo> GetMeterInfoAsync(string meterType,string timeDensity="15")
|
||||
{
|
||||
var redisCacheMeterInfoHashKeyTemp = $"{string.Format(RedisConst.CacheMeterInfoHashKey, _applicationOptions.SystemType, _applicationOptions.ServerTagName, meterType, timeDensity)}";
|
||||
return await Task.FromResult(new AmmeterInfo());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存数据到IotDb
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="analysisBaseDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> SaveDataToIotDbAsync<T>(UnitDataAnalysis<AnalysisBaseDto<T>> analysisBaseDto)
|
||||
{
|
||||
var data = analysisBaseDto.Data!;
|
||||
|
||||
string taskMark = CommonHelper.GetTaskMark(analysisBaseDto.AFN, analysisBaseDto.Fn, analysisBaseDto.Pn, analysisBaseDto.MSA, analysisBaseDto.PSEQ);
|
||||
string scoreValue = $"{analysisBaseDto.Code}.{taskMark}".Md5Fun();
|
||||
|
||||
var conditions = new List<QueryCondition>();
|
||||
conditions.Add(new QueryCondition()
|
||||
{
|
||||
Field = "ScoreValue",
|
||||
Operator = "=",
|
||||
IsNumber = false,
|
||||
Value = scoreValue
|
||||
});
|
||||
conditions.Add(new QueryCondition()
|
||||
{
|
||||
Field = "TaskMark",
|
||||
Operator = "=",
|
||||
IsNumber = false,
|
||||
Value = taskMark
|
||||
});
|
||||
conditions.Add(new QueryCondition()
|
||||
{
|
||||
Field = "IsReceived",
|
||||
Operator = "=",
|
||||
IsNumber = false,
|
||||
Value = false
|
||||
});
|
||||
var meter = new TreeModelSingleMeasuringEntity<T>()
|
||||
{
|
||||
SystemName = _applicationOptions.SystemType,
|
||||
DeviceId = $"{data.MeterId}",
|
||||
DeviceType = $"{data.MeterType}",
|
||||
ProjectId = $"{data.ProjectId}",
|
||||
Timestamps = data.TimeSpan.GetDateTimeOffset().ToUnixTimeMilliseconds(),
|
||||
SingleMeasuring = new Tuple<string, T>(data.FiledName ?? string.Empty, data.DataValue ?? default)
|
||||
};
|
||||
_runtimeContext.UseTableSessionPool = true; // 使用表模型池
|
||||
var taskSendInfo = await _dbProvider.QueryAsync<MeterReadingTelemetryPacketInfo>(new IoTDBQueryOptions() { TableNameOrTreePath = DevicePathBuilder.GetTableName<MeterReadingTelemetryPacketInfo>(), Conditions = conditions, PageIndex = 0, PageSize = 1 });
|
||||
var taskData = taskSendInfo?.Items.FirstOrDefault();
|
||||
if (taskData != null)
|
||||
{
|
||||
// 更新
|
||||
meter.Timestamps = taskData.Timestamps;
|
||||
taskData.IsReceived=true;
|
||||
taskData.ReceivedMessageHexString= analysisBaseDto.HexMessage;
|
||||
taskData.ReceivedMessageId= analysisBaseDto.MessageId ?? string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 新建
|
||||
var currentTime = DateTime.Now;
|
||||
taskData = new MeterReadingTelemetryPacketInfo()
|
||||
{
|
||||
SystemName = _applicationOptions.SystemType,
|
||||
ProjectId = $"{data.ProjectId}",
|
||||
DeviceType = $"{data.MeterType}",
|
||||
DeviceId = $"{data.MeterId}",
|
||||
Timestamps = DateTime.Now.CheckTimePoint().GetDateTimeOffset().ToUnixTimeNanoseconds(),
|
||||
DatabaseBusiID = data.DatabaseBusiID,
|
||||
PendingCopyReadTime = data.DataTime.CheckTimePoint(),
|
||||
CreationTime = currentTime,
|
||||
MeterAddress = data.MeterAddress,
|
||||
AFN = analysisBaseDto.AFN,
|
||||
Fn = analysisBaseDto.Fn,
|
||||
Seq = analysisBaseDto.PSEQ,
|
||||
MSA = analysisBaseDto.MSA,
|
||||
ItemCode = data.DataType,
|
||||
TaskMark = taskMark,
|
||||
IsSend = false,
|
||||
ManualOrNot = false,
|
||||
Pn = analysisBaseDto.Pn,
|
||||
ReceivedMessageId = analysisBaseDto.MessageId?? string.Empty,
|
||||
ReceivedMessageHexString = analysisBaseDto.HexMessage,
|
||||
IsReceived = true,
|
||||
ReceivedRemark = data.ErrorCodeMsg ?? string.Empty,
|
||||
ScoreValue = $"{analysisBaseDto.Code}.{taskMark}".Md5Fun(),
|
||||
};
|
||||
}
|
||||
|
||||
await _dbProvider.InsertAsync(taskData);
|
||||
//如果无字段名,则不保存数据
|
||||
if (string.IsNullOrWhiteSpace(data.FiledName))
|
||||
{
|
||||
_runtimeContext.UseTableSessionPool = false; // 使树模型池
|
||||
await _dbProvider.InsertAsync(meter);
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 第一套第 2 日时段表数据
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 年时区数 p≤14
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 日时段表数 q≤8
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 日时段数(每日切换数) m≤14
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 费率数 k≤63
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 第一套时区表数据
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 第一套第 1 日时段表数据:
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 第一套第 2 日时段表数据
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 第一套第 3 日时段表数据
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 第一套第 4 日时段表数据
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 第一套第 5 日时段表数据
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 第一套第 6 日时段表数据
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 第一套第 7 日时段表数据
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 第一套第 8 日时段表数据
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
public class Appendix_A1 : IAnalysisStrategy<List<string>, string>
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 附录A.11数据格式
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 附录A.13数据格式
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
/// <summary>
|
||||
/// 附录A.14数据格式
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
public class Appendix_A15 : IAnalysisStrategy<List<string>, string>
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
public class Appendix_A17 : IAnalysisStrategy<List<string>, string>
|
||||
{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
public class Appendix_A23 : IAnalysisStrategy<List<string>, decimal>
|
||||
{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
public class Appendix_A25 : IAnalysisStrategy<List<string>, decimal>
|
||||
{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.Appendix
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.Appendix
|
||||
{
|
||||
public class Appendix_A5 : IAnalysisStrategy<List<string>, decimal>
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user