dev #3
@ -169,7 +169,7 @@ namespace JiShe.CollectBus.Kafka.Consumer
|
||||
// 检查 Header 是否符合条件
|
||||
if (!headersFilter.Match(result.Message.Headers))
|
||||
{
|
||||
//consumer.Commit(result); // 提交偏移量
|
||||
consumer.Commit(result); // 提交偏移量
|
||||
// 跳过消息
|
||||
continue;
|
||||
}
|
||||
@ -252,7 +252,7 @@ namespace JiShe.CollectBus.Kafka.Consumer
|
||||
// 检查 Header 是否符合条件
|
||||
if (!headersFilter.Match(result.Message.Headers))
|
||||
{
|
||||
//consumer.Commit(result); // 提交偏移量
|
||||
consumer.Commit(result); // 提交偏移量
|
||||
// 跳过消息
|
||||
continue;
|
||||
}
|
||||
@ -356,7 +356,7 @@ namespace JiShe.CollectBus.Kafka.Consumer
|
||||
// 检查 Header 是否符合条件
|
||||
if (!headersFilter.Match(result.Message.Headers))
|
||||
{
|
||||
//consumer.Commit(result); // 提交偏移量
|
||||
consumer.Commit(result); // 提交偏移量
|
||||
// 跳过消息
|
||||
continue;
|
||||
}
|
||||
@ -493,7 +493,7 @@ namespace JiShe.CollectBus.Kafka.Consumer
|
||||
// 检查 Header 是否符合条件
|
||||
if (!headersFilter.Match(result.Message.Headers))
|
||||
{
|
||||
//consumer.Commit(result); // 提交偏移量
|
||||
consumer.Commit(result); // 提交偏移量
|
||||
// 跳过消息
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_09H
|
||||
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_09H
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.9.1.2 F1:终端版本信息
|
||||
|
||||
@ -1,9 +1,4 @@
|
||||
using JiShe.CollectBus.Common.Encrypt;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IoTDB.Interface;
|
||||
using JiShe.CollectBus.IoTDB.Options;
|
||||
using JiShe.CollectBus.IoTDB.Provider;
|
||||
using JiShe.CollectBus.IotSystems.MeterReadingRecords;
|
||||
using JiShe.CollectBus.IoTDB.Interface;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
@ -45,21 +40,6 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
MSA= input.A.A3.D1_D7,
|
||||
PSEQ= input.SEQ.PSEQ,
|
||||
};
|
||||
string taskMark = CommonHelper.GetTaskMark(unitDataAnalysis.AFN, unitDataAnalysis.Fn, unitDataAnalysis.Pn, unitDataAnalysis.MSA, unitDataAnalysis.PSEQ);
|
||||
string scoreValue = $"{unitDataAnalysis.Code}.{taskMark}".Md5Fun();
|
||||
|
||||
var conditions = new List<QueryCondition>();
|
||||
conditions.Add(new QueryCondition()
|
||||
{
|
||||
Field = "ScoreValue",
|
||||
Operator = "=",
|
||||
IsNumber = false,
|
||||
Value = scoreValue
|
||||
});
|
||||
var taskSendInfo = await _dbProvider.QueryAsync<MeterReadingTelemetryPacketInfo>(new IoTDBQueryOptions() { TableNameOrTreePath = DevicePathBuilder.GetTableName<MeterReadingTelemetryPacketInfo>(), Conditions = conditions,PageIndex=0,PageSize=1});
|
||||
|
||||
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
List<AFN12_F129_AnalysisDto> list = GenerateFinalResult(2, datas, "正向有功电能示值", input.AFN_FC.AFN, input.DT.Fn);
|
||||
unitDataAnalysis.Data= list;
|
||||
@ -121,14 +101,5 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 生成最终结果
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public Task<bool> SaveIotDbAsync()
|
||||
//{
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,47 +1,68 @@
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
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.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.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, "上月(上一结算日)正向有功最大需量及发生时间");
|
||||
data.DataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
UnitDataAnalysis<AFN12_F149_AnalysisDto> unitDataAnalysis = new UnitDataAnalysis<AFN12_F149_AnalysisDto>
|
||||
{
|
||||
Code = input.A?.Code,
|
||||
AFN = input.AFN_FC?.AFN ?? 0,
|
||||
Fn = input.DT?.Fn ?? 0,
|
||||
Pn = input.DA?.Pn ?? 0,
|
||||
Data = data
|
||||
};
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
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<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)
|
||||
@ -82,33 +103,43 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
}
|
||||
return values;
|
||||
}
|
||||
public AFN12_F149_AnalysisDto GenerateFinalResult(int index, List<string> data, string remark = "")
|
||||
public AnalysisBaseDto<decimal> GenerateFinalResult(List<string> data,string dataType, string filedDesc = "")
|
||||
{
|
||||
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;
|
||||
dto.ErrorCodeMsg = errorCodeInfo.Item2;
|
||||
}
|
||||
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";
|
||||
|
||||
|
||||
//TODO:时间标
|
||||
if (!DateTime.TryParse(dto.TimeSpan, out DateTime readingDate))
|
||||
dto.ValidData = false;
|
||||
dto.ReadingDate = readingDate;
|
||||
{
|
||||
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(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;
|
||||
}
|
||||
|
||||
dto.FiledDesc = "上月(上一结算日)正向有功最大需量及发生时间";
|
||||
dto.FiledName = dataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 水表抄读取
|
||||
|
||||
@ -6,7 +6,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.12.2.4.22 F25:当前三相及总有/无功功率、功率因数,三相电压、电流、零序电流、视在功率
|
||||
|
||||
@ -6,7 +6,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.12.2.4.1 F2:终端日历时钟
|
||||
|
||||
@ -5,7 +5,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.12.2.4.30 F33:当前正向有/无功电能示值、一/四象限无功电能示值(总、费率 1~M,1≤M≤12)
|
||||
|
||||
@ -6,7 +6,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.12.2.4.46 F49:当前电压、电流相位角
|
||||
|
||||
@ -0,0 +1,102 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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, "反向无功总电能量");
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,99 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.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, "正向有功总电能示值");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,100 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.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, "正向无功总电能示值");
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,100 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.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, "反向有功总电能示值");
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,100 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.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, "反向无功总电能示值");
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,101 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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, "功率因数");
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,102 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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相功率因数");
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,100 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.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相功率因数");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,99 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.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相功率因数");
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,155 @@
|
||||
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.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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, "抄表日冻结电能表正向有功最大需量及发生时间");
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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 filedDesc = "")
|
||||
{
|
||||
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}";
|
||||
filedDesc = i == 1 ? filedDesc : filedDesc.Replace("有功", "无功");
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
|
||||
list.Add(meter);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,100 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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, "一象限无功电能示值");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,100 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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, "四象限无功电能示值");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,100 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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, "二象限无功电能示值");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,100 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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, "三象限无功电能示值");
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,105 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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" });
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,102 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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" });
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,103 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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" });
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,104 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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" });
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,104 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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" });
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,103 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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" });
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,103 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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" });
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,103 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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" });
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,104 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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" });
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,105 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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" });
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,104 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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" });
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,103 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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" });
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,104 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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" });
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,103 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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" });
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,102 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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" });
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,103 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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" });
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,113 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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, "抄表日冻结正向有功最大需量及发生时间");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,141 @@
|
||||
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.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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 filedDesc = "")
|
||||
{
|
||||
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;
|
||||
}
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
return meter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,132 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
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 filedDesc = "")
|
||||
{
|
||||
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;
|
||||
}
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
return meter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,132 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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 filedDesc = "")
|
||||
{
|
||||
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;
|
||||
}
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
return meter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,153 @@
|
||||
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.Appendix;
|
||||
using System.Data;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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, "月冻结电能表正向有功最大需量及发生时间");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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 filedDesc = "")
|
||||
{
|
||||
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}";
|
||||
|
||||
filedDesc = i == 1 ? filedDesc : filedDesc.Replace("有功", "无功");
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
list.Add(meter);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,180 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
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, "日冻结正向有/无功最大需量及发生时间");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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 filedDesc = "")
|
||||
{
|
||||
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}";
|
||||
filedDesc = i == 1 ? filedDesc : filedDesc.Replace("有功", "无功");
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
list.Add(meter);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
if (list.Count == 0)
|
||||
throw new Exception("错误数据");
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,173 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using AutoMapper.Internal.Mappers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
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, "日冻结反向有/无功最大需量及发生时间");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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 filedDesc = "")
|
||||
{
|
||||
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);
|
||||
|
||||
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}";
|
||||
filedDesc = i == 1 ? filedDesc : filedDesc.Replace("有功", "无功");
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
list.Add(meter);
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,101 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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, "有功功率曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,102 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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相有功功率曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,102 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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相有功功率曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,101 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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相有功功率曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,102 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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, "无功功率曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,102 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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相无功功率曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,101 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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相无功功率曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,102 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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相无功功率曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,102 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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相电压曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,102 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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相电压曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,101 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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相电压曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,101 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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相电流曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,102 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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相电流曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,102 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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相电流曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,102 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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, "测量点零序电流曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,102 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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, "正向有功总电能量曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,101 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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, "正向无功总电能量曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,102 @@
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
|
||||
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, "反向有功总电能量曲线");
|
||||
if (data.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data[0].MeterType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.MeterId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.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.SaveMultipleDataToIotDbAsync<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,79 @@
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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,55 @@
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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,68 @@
|
||||
using GatherService.WattMeter.AnalysisData.AFN_10H;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.16 数据转发(AFN=10H)
|
||||
/// </summary>
|
||||
public class AFN16_F1_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<string>>
|
||||
{
|
||||
private readonly ILogger<AFN16_F1_Analysis> _logger;
|
||||
|
||||
public AFN16_F1_Analysis(ILogger<AFN16_F1_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)
|
||||
};
|
||||
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: 待定,等确认如何匹配规则
|
||||
string value = string.Join(" ", hexMessageList);
|
||||
if (value.Contains(F10TranspondMatch.ReadNormal))
|
||||
{
|
||||
if (value.Contains(F10TranspondMatch.PowerHz))//电网频率
|
||||
return "AFN16_F97_Analysis";
|
||||
//else if (value.Contains(F10TranspondMatch.ReadData))//读取电表地址
|
||||
// result = "AFN16_F105_Analysis";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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,247 @@
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 保存数据到IotDb
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="analysisBaseDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> SaveMultipleDataToIotDbAsync<T>(UnitDataAnalysis<List<AnalysisBaseDto<T>>> analysisBaseDto)
|
||||
{
|
||||
var data = analysisBaseDto.Data!;
|
||||
foreach (var item in 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 = $"{item.MeterId}",
|
||||
DeviceType = $"{item.MeterType}",
|
||||
ProjectId = $"{item.ProjectId}",
|
||||
Timestamps = item.TimeSpan.GetDateTimeOffset().ToUnixTimeMilliseconds(),
|
||||
SingleMeasuring = new Tuple<string, T>(item.FiledName ?? string.Empty, item.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 = $"{item.ProjectId}",
|
||||
DeviceType = $"{item.MeterType}",
|
||||
DeviceId = $"{item.MeterId}",
|
||||
Timestamps = DateTime.Now.CheckTimePoint().GetDateTimeOffset().ToUnixTimeNanoseconds(),
|
||||
DatabaseBusiID = item.DatabaseBusiID,
|
||||
PendingCopyReadTime = item.DataTime.CheckTimePoint(),
|
||||
CreationTime = currentTime,
|
||||
MeterAddress = item.MeterAddress,
|
||||
AFN = analysisBaseDto.AFN,
|
||||
Fn = analysisBaseDto.Fn,
|
||||
Seq = analysisBaseDto.PSEQ,
|
||||
MSA = analysisBaseDto.MSA,
|
||||
ItemCode = item.DataType,
|
||||
TaskMark = taskMark,
|
||||
IsSend = false,
|
||||
ManualOrNot = false,
|
||||
Pn = analysisBaseDto.Pn,
|
||||
ReceivedMessageId = analysisBaseDto.MessageId ?? string.Empty,
|
||||
ReceivedMessageHexString = analysisBaseDto.HexMessage,
|
||||
IsReceived = true,
|
||||
ReceivedRemark = item.ErrorCodeMsg ?? string.Empty,
|
||||
ScoreValue = $"{analysisBaseDto.Code}.{taskMark}".Md5Fun(),
|
||||
};
|
||||
}
|
||||
|
||||
await _dbProvider.InsertAsync(taskData);
|
||||
//如果无字段名,则不保存数据
|
||||
if (string.IsNullOrWhiteSpace(item.FiledName))
|
||||
{
|
||||
_runtimeContext.UseTableSessionPool = false; // 使树模型池
|
||||
await _dbProvider.InsertAsync(meter);
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
{
|
||||
public class F10TranspondMatch
|
||||
{
|
||||
/// <summary>
|
||||
/// 188协议良禾水表透传解析
|
||||
/// </summary>
|
||||
public const string WaterLiangHe188 = "1F 90 00";
|
||||
/// <summary>
|
||||
/// 188协议良禾水表透传解析
|
||||
/// </summary>
|
||||
public const string WaterLiangHe188_1 = "90 1F 00";
|
||||
/// <summary>
|
||||
/// 电网频率
|
||||
/// </summary>
|
||||
public const string PowerHz = "35 33 B3 35";
|
||||
|
||||
/// <summary>
|
||||
/// 读取数据
|
||||
/// </summary>
|
||||
public const string ReadData = "34 37 33 37";
|
||||
|
||||
/// <summary>
|
||||
/// 跳合闸 正常应答帧
|
||||
/// </summary>
|
||||
public const string JumpClosingNormal = "68 9C";
|
||||
/// <summary>
|
||||
/// 跳合闸 异常应答帧
|
||||
/// </summary>
|
||||
public const string JumpClosingError = "68 DC";
|
||||
/// <summary>
|
||||
/// 写数据正常应答帧
|
||||
/// </summary>
|
||||
public const string WriteNormal = "68 94 00";
|
||||
/// <summary>
|
||||
/// 写数据异常应答帧
|
||||
/// </summary>
|
||||
public const string WriteError = "68 D4 01";
|
||||
|
||||
/// <summary>
|
||||
/// 读数据异常应答帧
|
||||
/// </summary>
|
||||
public const string ReadError = "68 D1";
|
||||
|
||||
/// <summary>
|
||||
/// 读数据正常应答帧
|
||||
/// </summary>
|
||||
public const string ReadNormal = "68 91";
|
||||
/// <summary>
|
||||
/// 捷先电动阀门(DN50)
|
||||
/// </summary>
|
||||
public const string CJT_188_2018 = "84 05 A0 17 00";
|
||||
|
||||
public const string DLT_645_1997 = "68 84 00";
|
||||
/// <summary>
|
||||
/// ES190_DC 4G水表
|
||||
/// </summary>
|
||||
public const string ES190_DC = "FF D5";
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,9 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using NUglify.JavaScript.Syntax;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012
|
||||
{
|
||||
@ -120,5 +124,235 @@ namespace JiShe.CollectBus.Protocol.T37612012
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断当前时间所在时标(15分钟)
|
||||
/// </summary>
|
||||
/// <param name="curTime"></param>
|
||||
/// <returns></returns>
|
||||
public static DateTime CheckTimePoint(this DateTime curTime)
|
||||
{
|
||||
var curMinute = Convert.ToInt32(curTime.ToString("mm"));
|
||||
string dataTime;
|
||||
if (curMinute >= 0 && curMinute < 15)
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:00:00");
|
||||
else if (curMinute >= 15 && curMinute < 30)
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:15:00");
|
||||
else if (curMinute >= 30 && curMinute < 45)
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:30:00");
|
||||
else
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:45:00");
|
||||
return DateTime.Parse(dataTime);
|
||||
}
|
||||
|
||||
public static DateTime CheckTimeFivePoint(this DateTime curTime)
|
||||
{
|
||||
string dataTime;
|
||||
var curMinute = Convert.ToInt32(curTime.ToString("mm"));
|
||||
if (curMinute >= 0 && curMinute < 5)
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:00:00");
|
||||
else if (curMinute >= 5 && curMinute < 10)
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:5:00");
|
||||
else if (curMinute >= 10 && curMinute < 15)
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:10:00");
|
||||
else if (curMinute >= 15 && curMinute < 20)
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:15:00");
|
||||
else if (curMinute >= 20 && curMinute < 25)
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:20:00");
|
||||
else if (curMinute >= 25 && curMinute < 30)
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:25:00");
|
||||
else if (curMinute >= 30 && curMinute < 35)
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:30:00");
|
||||
else if (curMinute >= 35 && curMinute < 40)
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:35:00");
|
||||
else if (curMinute >= 40 && curMinute < 45)
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:40:00");
|
||||
else if (curMinute >= 45 && curMinute < 50)
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:45:00");
|
||||
else if (curMinute >= 50 && curMinute < 55)
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:50:00");
|
||||
else
|
||||
dataTime = curTime.ToString("yyyy-MM-dd HH:55:00");
|
||||
return DateTime.Parse(dataTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据时标
|
||||
/// </summary>
|
||||
/// <param name="hexMessageList"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="len"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public static List<string> GetReadTimeTd_c(this List<string> hexMessageList, int index, int len)
|
||||
{
|
||||
if (len != 7)
|
||||
throw new ArgumentException("数据时标 Td_c参数为不标准长度");
|
||||
var list = hexMessageList.GetRange(index, len);
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
GetReadTime(list.GetRange(0, 5)),
|
||||
list[5].HexToDec().ToString(),//密度
|
||||
list[6].HexToDec().ToString()//数据点数
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 数据时标型(曲线类型)
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public static List<AnalysisBaseDto<decimal>> GenerateFinalResultTd_c(this List<string> data, int index,int density,string dataType, string filedDesc = "")
|
||||
{
|
||||
List<AnalysisBaseDto<decimal>> list = new List<AnalysisBaseDto<decimal>>();
|
||||
for (int i = index; i < data.Count; i++)
|
||||
{
|
||||
AnalysisBaseDto<decimal> meter = new AnalysisBaseDto<decimal>();
|
||||
meter.MeterType= MeterTypeEnum.Ammeter;
|
||||
|
||||
decimal value = 0;
|
||||
var errorCode = data[i].CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
{
|
||||
meter.ValidData = false;
|
||||
meter.ErrorCodeMsg = errorCode.Item2;
|
||||
}
|
||||
else
|
||||
decimal.TryParse(data[i], out value);
|
||||
meter.DataValue = value;
|
||||
meter.DataType = dataType;
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
if (DateTime.TryParse(CalculateTimeSpan(i - 3, data[0], density), out DateTime readingDate))
|
||||
meter.TimeSpan = readingDate;
|
||||
list.Add(meter);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 月冻结
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="dataType"></param>
|
||||
/// <param name="timeSpan"></param>
|
||||
/// <param name="remark"></param>
|
||||
/// <returns></returns>
|
||||
public static List<AnalysisBaseDto<decimal>> GenerateFinalResultTd_m(this List<string> data, int index,string dataType,string timeSpan, string filedDesc = "")
|
||||
{
|
||||
List<AnalysisBaseDto<decimal>> list = new List<AnalysisBaseDto<decimal>>();
|
||||
for (int i = index; i < data.Count; i++)
|
||||
{
|
||||
AnalysisBaseDto<decimal> meter = new AnalysisBaseDto<decimal>();
|
||||
meter.MeterType = MeterTypeEnum.Ammeter;
|
||||
decimal value = 0;
|
||||
var errorCode = data[i].CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
{
|
||||
meter.ValidData = false;
|
||||
meter.ErrorCodeMsg = errorCode.Item2;
|
||||
}
|
||||
else
|
||||
decimal.TryParse(data[i], out value);
|
||||
meter.DataValue = value;
|
||||
if (DateTime.TryParse(timeSpan, out DateTime readingDate))
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
meter.DataType = i - index == 0 ? dataType : $"{dataType}_{i - index}";
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
list.Add(meter);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 日冻结
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="remark"></param>
|
||||
/// <returns></returns>
|
||||
public static List<AnalysisBaseDto<decimal>> GenerateFinalResultTd_d(this List<string> data, int index,string dataType, string timeSpan, string filedDesc = "")
|
||||
{
|
||||
List<AnalysisBaseDto<decimal>> list = new List<AnalysisBaseDto<decimal>>();
|
||||
int typeIndex = 0;
|
||||
for (int i = index; i < data.Count; i++)
|
||||
{
|
||||
AnalysisBaseDto<decimal> meter = new AnalysisBaseDto<decimal>
|
||||
{
|
||||
MeterType = MeterTypeEnum.Ammeter
|
||||
};
|
||||
decimal value = 0;
|
||||
var errorCode = data[i].CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
{
|
||||
meter.ValidData = false;
|
||||
meter.ErrorCodeMsg = errorCode.Item2;
|
||||
}
|
||||
else
|
||||
decimal.TryParse(data[i], out value);
|
||||
meter.DataValue = value;
|
||||
if (DateTime.TryParse(timeSpan, out DateTime readingDate))
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
meter.DataType = i - index == 0 ? dataType : $"{dataType}_{i - index}";
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
list.Add(meter);
|
||||
typeIndex++;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算时标
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="time"></param>
|
||||
/// <param name="intervalTime"></param>
|
||||
/// <returns></returns>
|
||||
private static string CalculateTimeSpan(int index, string time, int intervalTime)
|
||||
{
|
||||
var startTime = Convert.ToDateTime($"{time.Substring(0, 4)}-{time.Substring(4, 2)}-{time.Substring(6, 2)} {time.Substring(8, 2)}:{time.Substring(10, 2)}");
|
||||
return startTime.AddMinutes(index * intervalTime).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 校验数据值精度
|
||||
/// </summary>
|
||||
/// <param name="meterDatas"></param>
|
||||
/// <param name="mark"></param>
|
||||
/// <returns></returns>
|
||||
public static List<AnalysisBaseDto<decimal>> IsValidData(this List<AnalysisBaseDto<decimal>> meterDatas, List<string> mark)
|
||||
{
|
||||
bool isUpload = false;
|
||||
var jfpgSum = 0M;
|
||||
var totalItem = meterDatas.Find(f => f.DataType.Equals(mark[0]));//meterDatas.Find(f => f.DataType.Equals(mark[0]));
|
||||
for (int i = 1; i <= meterDatas.Count - 1; i++)
|
||||
{
|
||||
var value = meterDatas[i];//meterDatas.Find(f => f.DataType.Equals(mark[i]));
|
||||
if (value.ValidData)
|
||||
jfpgSum += value.DataValue;
|
||||
}
|
||||
var floatingNum = (jfpgSum * 5 / 100);//上下浮动数据
|
||||
var minjfpgSum = jfpgSum - floatingNum;//100-(100*5/100);
|
||||
var maxjfpgSum = jfpgSum + floatingNum;
|
||||
if (totalItem.DataValue <= maxjfpgSum || totalItem.DataValue >= minjfpgSum)//总值,在JFPG之和的浮动范围内
|
||||
isUpload = true;
|
||||
else
|
||||
isUpload = false;
|
||||
if (!isUpload)
|
||||
meterDatas.ForEach(f =>
|
||||
{
|
||||
f.ValidData = false;
|
||||
});
|
||||
return meterDatas;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ namespace JiShe.CollectBus.Protocol.T37612012
|
||||
return;
|
||||
//TODO:根据AFN进行分流推送到kafka
|
||||
string topicName = string.Format(ProtocolConst.AFNTopicNameFormat, tB3761.AFN_FC.AFN.ToString().PadLeft(2, '0'));
|
||||
|
||||
tB3761.MessageId = Guid.NewGuid().ToString();
|
||||
MessageProtocolAnalysis<TB3761> messageReceivedAnalysis = new MessageProtocolAnalysis<TB3761>()
|
||||
{
|
||||
ClientId = tcpSessionClient.Id,
|
||||
@ -122,7 +122,7 @@ namespace JiShe.CollectBus.Protocol.T37612012
|
||||
ClientPort = tcpSessionClient.Port,
|
||||
MessageHexString = tB3761.BaseHexMessage.HexMessageString!,
|
||||
DeviceNo = tB3761.A.Code!,
|
||||
MessageId = Guid.NewGuid().ToString(),
|
||||
MessageId = tB3761.MessageId,
|
||||
ReceivedTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
Data = tB3761
|
||||
};
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Models;
|
||||
using JiShe.CollectBus.IotSystems.Protocols;
|
||||
@ -89,8 +90,8 @@ namespace JiShe.CollectBus.Protocol.T6452007
|
||||
Telemetry3761PacketResponse builderResponse = null;
|
||||
|
||||
List<string> dataUnit = new List<string>();
|
||||
//数据转发场景 10H_F1_1CH
|
||||
if (aFNStr == "10" && request.SubProtocolRequest != null && string.IsNullOrWhiteSpace(request.SubProtocolRequest.ItemCode) == false)
|
||||
//数据转发场景 10H_F1
|
||||
if (request.ItemCode == T37612012PacketItemCodeConst.AFN10HFN01H && request.SubProtocolRequest != null && string.IsNullOrWhiteSpace(request.SubProtocolRequest.ItemCode) == false)
|
||||
{
|
||||
var t645PacketHandlerName = $"C{request.SubProtocolRequest.ItemCode}_Send";
|
||||
Telemetry6452007PacketResponse t645PacketResponse = null;
|
||||
|
||||
@ -80,8 +80,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
/// <returns></returns>
|
||||
Task AmmeterScheduledAutomaticVerificationTime(int timeDensity, AmmeterInfo ammeterInfo, int groupIndex, DateTime timestamps);
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region 水表采集处理
|
||||
/// <summary>
|
||||
@ -103,7 +102,30 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task WatermeterScheduledMeterAutoReading();
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 集中器处理
|
||||
|
||||
/// <summary>
|
||||
/// 自动获取终端版
|
||||
/// </summary>
|
||||
/// <param name="timeDensity">采集频率</param>
|
||||
/// <param name="ammeterInfo">电表信息</param>
|
||||
/// <param name="groupIndex">集中器所在分组</param>
|
||||
/// <param name="timestamps">采集频率对应的时间戳</param>
|
||||
/// <returns></returns>
|
||||
Task ConcentratorScheduledAutomaticGetTerminalVersion(int timeDensity, AmmeterInfo ammeterInfo, int groupIndex, DateTime timestamps);
|
||||
|
||||
/// <summary>
|
||||
/// 自动获取远程通信模块(SIM)版本信息
|
||||
/// </summary>
|
||||
/// <param name="timeDensity">采集频率</param>
|
||||
/// <param name="ammeterInfo">电表信息</param>
|
||||
/// <param name="groupIndex">集中器所在分组</param>
|
||||
/// <param name="timestamps">采集频率对应的时间戳</param>
|
||||
/// <returns></returns>
|
||||
Task ConcentratorScheduledAutomaticGetTelematicsModule(int timeDensity, AmmeterInfo ammeterInfo, int groupIndex, DateTime timestamps);
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@ -135,22 +135,45 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
|
||||
//电表定时广播校时,一天一次。
|
||||
string currentTimeStr = $"{currentTime:HH:mm:00}";
|
||||
//判断是否是自动校时时间
|
||||
if (!string.Equals(currentTimeStr, _applicationOptions.AutomaticVerificationTime, StringComparison.CurrentCultureIgnoreCase))
|
||||
if (string.Equals(currentTimeStr, _applicationOptions.AutomaticVerificationTime, StringComparison.CurrentCultureIgnoreCase))//自动校时
|
||||
{
|
||||
_logger.LogInformation($"{nameof(AmmeterScheduledAutomaticVerificationTime)} 电表自动校时,非自动校时时间");
|
||||
return;
|
||||
//_logger.LogInformation($"{nameof(AmmeterScheduledAutomaticVerificationTime)} 电表自动校时,非自动校时时间");
|
||||
//return;
|
||||
|
||||
_ = CreateMeterPublishTask<AmmeterInfo>(
|
||||
timeDensity: timeDensity,
|
||||
nextTaskTime: currentTime,
|
||||
meterType: MeterTypeEnum.Ammeter,
|
||||
taskCreateAction: async (timeDensity, data, groupIndex, timestamps) =>
|
||||
{
|
||||
await AmmeterScheduledAutomaticVerificationTime(timeDensity, data, groupIndex, timestamps);
|
||||
});
|
||||
}
|
||||
else if (string.Equals(currentTimeStr, _applicationOptions.AutomaticGetTerminalVersionTime, StringComparison.CurrentCultureIgnoreCase))//集中器版本号读取
|
||||
{
|
||||
_ = CreateMeterPublishTask<AmmeterInfo>(
|
||||
timeDensity: timeDensity,
|
||||
nextTaskTime: currentTime,
|
||||
meterType: MeterTypeEnum.Ammeter,
|
||||
taskCreateAction: async (timeDensity, data, groupIndex, timestamps) =>
|
||||
{
|
||||
await ConcentratorScheduledAutomaticGetTerminalVersion(timeDensity, data, groupIndex, timestamps);
|
||||
});
|
||||
}
|
||||
else if (string.Equals(currentTimeStr, _applicationOptions.AutomaticGetTelematicsModuleTime, StringComparison.CurrentCultureIgnoreCase))//SIM卡读取
|
||||
{
|
||||
_ = CreateMeterPublishTask<AmmeterInfo>(
|
||||
timeDensity: timeDensity,
|
||||
nextTaskTime: currentTime,
|
||||
meterType: MeterTypeEnum.Ammeter,
|
||||
taskCreateAction: async (timeDensity, data, groupIndex, timestamps) =>
|
||||
{
|
||||
await ConcentratorScheduledAutomaticGetTelematicsModule(timeDensity, data, groupIndex, timestamps);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = CreateMeterPublishTask<AmmeterInfo>(
|
||||
timeDensity: timeDensity,
|
||||
nextTaskTime: currentTime,
|
||||
meterType: MeterTypeEnum.Ammeter,
|
||||
taskCreateAction: async (timeDensity, data, groupIndex, timestamps) =>
|
||||
{
|
||||
await AmmeterScheduledAutomaticVerificationTime(timeDensity, data, groupIndex, timestamps);
|
||||
});
|
||||
_logger.LogInformation($"{nameof(CreateToBeIssueTasks)} 不是自动校时、采集终端信息等时间,继续处理其他");
|
||||
}
|
||||
|
||||
//检查任务时间节点,由于定时任务10秒钟运行一次,需要判定当前时间是否在任务时间节点内,不在则跳过
|
||||
@ -736,7 +759,8 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
List<MeterReadingTelemetryPacketInfo> taskList = new List<MeterReadingTelemetryPacketInfo>();
|
||||
var metadata = await _dbProvider.GetMetadata<MeterReadingTelemetryPacketInfo>();
|
||||
|
||||
var temCode = "10_01";
|
||||
var itemCode = T37612012PacketItemCodeConst.AFN10HFN01H;
|
||||
var subItemCode = T6452007PacketItemCodeConst.C08;
|
||||
|
||||
//根据电表型号获取协议插件
|
||||
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(ammeterInfo.BrandType);
|
||||
@ -750,12 +774,12 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
{
|
||||
FocusAddress = ammeterInfo.FocusAddress,
|
||||
Pn = ammeterInfo.MeteringCode,
|
||||
ItemCode = temCode,
|
||||
ItemCode = itemCode,
|
||||
SubProtocolRequest = new SubProtocolBuildRequest()
|
||||
{
|
||||
MeterAddress = ammeterInfo.AmmerterAddress,
|
||||
Password = ammeterInfo.Password,
|
||||
ItemCode = T6452007PacketItemCodeConst.C08,
|
||||
ItemCode = subItemCode,
|
||||
}
|
||||
});
|
||||
|
||||
@ -775,7 +799,8 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
Fn = builderResponse.Fn,
|
||||
Seq = builderResponse.Seq,
|
||||
MSA = builderResponse.MSA,
|
||||
ItemCode = temCode,
|
||||
ItemCode = itemCode,
|
||||
SubItemCode = subItemCode,
|
||||
TaskMark = taskMark,
|
||||
IsSend = false,
|
||||
ManualOrNot = false,
|
||||
@ -814,7 +839,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@ -997,38 +1022,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
List<MeterReadingTelemetryPacketInfo> taskList = new List<MeterReadingTelemetryPacketInfo>();
|
||||
|
||||
|
||||
List<string> tempCodes = new List<string>() { "10_1" };
|
||||
|
||||
//todo 后续从协议池获取
|
||||
if (watermeter.MeterTypeName.Equals("水表") && (watermeter.Protocol.Equals((int)MeterLinkProtocol.CJT_188_2018) || watermeter.Protocol.Equals((int)MeterLinkProtocol.DLT_645_1997) || watermeter.Protocol.Equals((int)MeterLinkProtocol.DLT_645_2007)))//水表且(CJT_188_2018或DLT_645_1997)都采用0C_129
|
||||
{
|
||||
if (watermeter.MeterBrand.Contains("炬华有线"))
|
||||
{
|
||||
tempCodes = new List<string>() { "0C_188" };
|
||||
}
|
||||
else
|
||||
{
|
||||
tempCodes = new List<string>() { "0C_129" };
|
||||
}
|
||||
}
|
||||
|
||||
else if (typeName.Trim().Equals("西恩超声波流量计"))
|
||||
{
|
||||
tempCodes = new List<string>() { "10_1" };
|
||||
}
|
||||
else if (typeName.Trim().Equals("江苏华海涡街流量计积算仪"))
|
||||
{
|
||||
tempCodes = new List<string>() { "10_1" };
|
||||
}
|
||||
else if (typeName.Trim().Equals("V880BR涡街流量计"))
|
||||
{
|
||||
tempCodes = new List<string>() { "10_1" };
|
||||
}
|
||||
else if (typeName.Trim().Equals("拓思特涡街流量计H880BR"))
|
||||
{
|
||||
tempCodes = new List<string>() { "10_1" };
|
||||
}
|
||||
|
||||
|
||||
//根据表型号获取协议插件
|
||||
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(watermeter.Code);
|
||||
if (protocolPlugin == null)
|
||||
@ -1037,105 +1031,273 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
//return;
|
||||
}
|
||||
|
||||
foreach (var tempItem in tempCodes)
|
||||
string itemCode = T37612012PacketItemCodeConst.AFN10HFN01H;
|
||||
string subItemCode = T1882018PacketItemCodeConst.CTR0190;
|
||||
|
||||
ProtocolBuildResponse builderResponse = await protocolPlugin.BuildAsync(new ProtocolBuildRequest()
|
||||
{
|
||||
//排除已发送日冻结和月冻结采集项配置
|
||||
if (DayFreezeCodes.Contains(tempItem))
|
||||
FocusAddress = watermeter.FocusAddress,
|
||||
Pn = watermeter.MeteringCode,
|
||||
ItemCode = itemCode,
|
||||
SubProtocolRequest = new SubProtocolBuildRequest()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (MonthFreezeCodes.Contains(tempItem))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//var itemCodeArr = tempItem.Split('_');
|
||||
//var aFNStr = itemCodeArr[0];
|
||||
//var aFN = (AFN)aFNStr.HexToDec();
|
||||
//var fn = int.Parse(itemCodeArr[1]);
|
||||
//TelemetryPacketResponse builderResponse = null;
|
||||
|
||||
//string methonCode = $"AFN{aFNStr}_Fn_Send";
|
||||
////特殊表暂不处理
|
||||
//if (handlerPacketBuilder != null && handlerPacketBuilder.TryGetValue(methonCode
|
||||
// , out var handler))
|
||||
//{
|
||||
// builderResponse = handler(new TelemetryPacketRequest()
|
||||
// {
|
||||
// FocusAddress = watermeter.FocusAddress,
|
||||
// Fn = fn,
|
||||
// Pn = watermeter.MeteringCode,
|
||||
// DataUnit = Build188SendData.Build188WaterMeterReadingSendDataUnit(watermeter.Address),
|
||||
// });
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// _logger.LogWarning($"{nameof(WatermeterCreatePublishTaskAction)} 集中器{watermeter.FocusAddress}的水表{watermeter.Name}采集项{tempItem}无效编码。");
|
||||
// continue;
|
||||
//}
|
||||
|
||||
ProtocolBuildResponse builderResponse = await protocolPlugin.BuildAsync(new ProtocolBuildRequest()
|
||||
{
|
||||
FocusAddress = watermeter.FocusAddress,
|
||||
Pn = watermeter.MeteringCode,
|
||||
ItemCode = tempItem,
|
||||
SubProtocolRequest = new SubProtocolBuildRequest()
|
||||
{
|
||||
MeterAddress = watermeter.MeterAddress,
|
||||
Password = watermeter.Password,
|
||||
ItemCode = tempItem,
|
||||
}
|
||||
});
|
||||
if (builderResponse == null || builderResponse.Data.Length <= 0)
|
||||
{
|
||||
//_logger.LogWarning($"{nameof(AmmerterCreatePublishTask)} 集中器{ammeterInfo.FocusAddress}的电表{ammeterInfo.Name}采集项{tempItem}未能正确获取报文。");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (builderResponse == null || builderResponse.Data.Length <= 0)
|
||||
{
|
||||
_logger.LogWarning($"{nameof(WatermeterCreatePublishTaskAction)} 集中器{watermeter.FocusAddress}的水表{watermeter.Name}采集项{tempItem}未能正确获取报文。");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
string taskMark = CommonHelper.GetTaskMark(builderResponse.AFn, builderResponse.Fn, watermeter.MeteringCode, builderResponse.MSA, builderResponse.Seq);
|
||||
var meterReadingRecords = new MeterReadingTelemetryPacketInfo()
|
||||
{
|
||||
SystemName = SystemType,
|
||||
ProjectId = $"{watermeter.ProjectID}",
|
||||
DeviceType = $"{MeterTypeEnum.Ammeter}",
|
||||
DeviceId = $"{watermeter.MeterId}",
|
||||
Timestamps = DateTimeOffset.Now.ToUnixTimeNanoseconds(),
|
||||
DatabaseBusiID = watermeter.DatabaseBusiID,
|
||||
PendingCopyReadTime = timestamps,
|
||||
CreationTime = currentTime,
|
||||
MeterAddress = watermeter.MeterAddress,
|
||||
AFN = builderResponse.AFn,
|
||||
Fn = builderResponse.Fn,
|
||||
Seq = builderResponse.Seq,
|
||||
MSA = builderResponse.MSA,
|
||||
ItemCode = tempItem,
|
||||
TaskMark = taskMark,
|
||||
IsSend = false,
|
||||
ManualOrNot = false,
|
||||
Pn = watermeter.MeteringCode,
|
||||
IssuedMessageId = GuidGenerator.Create().ToString(),
|
||||
IssuedMessageHexString = Convert.ToHexString(builderResponse.Data),
|
||||
IsReceived = false,
|
||||
ScoreValue = $"{watermeter.FocusAddress}.{taskMark}".Md5Fun(),
|
||||
};
|
||||
|
||||
taskList.Add(meterReadingRecords);
|
||||
Password = watermeter.Password,
|
||||
ItemCode = subItemCode,
|
||||
}
|
||||
});
|
||||
if (builderResponse == null || builderResponse.Data.Length <= 0)
|
||||
{
|
||||
//_logger.LogWarning($"{nameof(AmmerterCreatePublishTask)} 集中器{ammeterInfo.FocusAddress}的电表{ammeterInfo.Name}采集项{tempItem}未能正确获取报文。");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (builderResponse == null || builderResponse.Data.Length <= 0)
|
||||
{
|
||||
_logger.LogWarning($"{nameof(WatermeterCreatePublishTaskAction)} 集中器{watermeter.FocusAddress}的水表{watermeter.Name}采集项{itemCode}未能正确获取报文。");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
string taskMark = CommonHelper.GetTaskMark(builderResponse.AFn, builderResponse.Fn, watermeter.MeteringCode, builderResponse.MSA, builderResponse.Seq);
|
||||
var meterReadingRecords = new MeterReadingTelemetryPacketInfo()
|
||||
{
|
||||
SystemName = SystemType,
|
||||
ProjectId = $"{watermeter.ProjectID}",
|
||||
DeviceType = $"{MeterTypeEnum.Ammeter}",
|
||||
DeviceId = $"{watermeter.MeterId}",
|
||||
Timestamps = DateTimeOffset.Now.ToUnixTimeNanoseconds(),
|
||||
DatabaseBusiID = watermeter.DatabaseBusiID,
|
||||
PendingCopyReadTime = timestamps,
|
||||
CreationTime = currentTime,
|
||||
MeterAddress = watermeter.MeterAddress,
|
||||
AFN = builderResponse.AFn,
|
||||
Fn = builderResponse.Fn,
|
||||
Seq = builderResponse.Seq,
|
||||
MSA = builderResponse.MSA,
|
||||
ItemCode = itemCode,
|
||||
SubItemCode = subItemCode,
|
||||
TaskMark = taskMark,
|
||||
IsSend = false,
|
||||
ManualOrNot = false,
|
||||
Pn = watermeter.MeteringCode,
|
||||
IssuedMessageId = GuidGenerator.Create().ToString(),
|
||||
IssuedMessageHexString = Convert.ToHexString(builderResponse.Data),
|
||||
IsReceived = false,
|
||||
ScoreValue = $"{watermeter.FocusAddress}.{taskMark}".Md5Fun(),
|
||||
};
|
||||
|
||||
taskList.Add(meterReadingRecords);
|
||||
|
||||
return taskList;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 集中器处理
|
||||
/// <summary>
|
||||
/// 自动获取终端版
|
||||
/// </summary>
|
||||
/// <param name="timeDensity">采集频率</param>
|
||||
/// <param name="ammeterInfo">电表信息</param>
|
||||
/// <param name="groupIndex">集中器所在分组</param>
|
||||
/// <param name="timestamps">采集频率对应的时间戳</param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task ConcentratorScheduledAutomaticGetTerminalVersion(int timeDensity, AmmeterInfo ammeterInfo, int groupIndex, DateTime timestamps)
|
||||
{
|
||||
var currentTime = DateTime.Now;
|
||||
string currentTimeStr = $"{currentTime:HH:mm:00}";
|
||||
|
||||
try
|
||||
{
|
||||
//判断是否是自动获取版本号时间
|
||||
if (!string.Equals(currentTimeStr, _applicationOptions.AutomaticGetTerminalVersionTime, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
_logger.LogInformation($"{nameof(ConcentratorScheduledAutomaticGetTerminalVersion)} 集中器自动获取版本号,非自动处理时间");
|
||||
return;
|
||||
}
|
||||
|
||||
List<MeterReadingTelemetryPacketInfo> taskList = new List<MeterReadingTelemetryPacketInfo>();
|
||||
var metadata = await _dbProvider.GetMetadata<MeterReadingTelemetryPacketInfo>();
|
||||
|
||||
var itemCode = T37612012PacketItemCodeConst.AFN09HFN01H;
|
||||
//var subItemCode = T6452007PacketItemCodeConst.C08;
|
||||
|
||||
//根据电表型号获取协议插件
|
||||
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(ammeterInfo.BrandType);
|
||||
if (protocolPlugin == null)
|
||||
{
|
||||
_logger.LogError($"{nameof(AmmeterScheduledAutoValveControl)} 集中器自动获取版本号{currentTime}没有找到对应的协议组件,-105");
|
||||
return;
|
||||
}
|
||||
|
||||
ProtocolBuildResponse builderResponse = await protocolPlugin.BuildAsync(new ProtocolBuildRequest()
|
||||
{
|
||||
FocusAddress = ammeterInfo.FocusAddress,
|
||||
Pn = ammeterInfo.MeteringCode,
|
||||
ItemCode = itemCode,
|
||||
//SubProtocolRequest = new SubProtocolBuildRequest()
|
||||
//{
|
||||
// MeterAddress = ammeterInfo.AmmerterAddress,
|
||||
// Password = ammeterInfo.Password,
|
||||
// ItemCode = subItemCode,
|
||||
//}
|
||||
});
|
||||
|
||||
string taskMark = CommonHelper.GetTaskMark(builderResponse.AFn, builderResponse.Fn, ammeterInfo.MeteringCode, builderResponse.MSA, builderResponse.Seq);
|
||||
var meterReadingRecords = new MeterReadingTelemetryPacketInfo()
|
||||
{
|
||||
SystemName = SystemType,
|
||||
ProjectId = $"{ammeterInfo.ProjectID}",
|
||||
DeviceType = $"{MeterTypeEnum.Ammeter}",
|
||||
DeviceId = $"{ammeterInfo.MeterId}",
|
||||
Timestamps = currentTime.GetDateTimeOffset().ToUnixTimeNanoseconds(),
|
||||
DatabaseBusiID = ammeterInfo.DatabaseBusiID,
|
||||
PendingCopyReadTime = currentTime,
|
||||
CreationTime = currentTime,
|
||||
MeterAddress = ammeterInfo.AmmerterAddress,
|
||||
AFN = builderResponse.AFn,
|
||||
Fn = builderResponse.Fn,
|
||||
Seq = builderResponse.Seq,
|
||||
MSA = builderResponse.MSA,
|
||||
ItemCode = itemCode,
|
||||
//SubItemCode = subItemCode,
|
||||
TaskMark = taskMark,
|
||||
IsSend = false,
|
||||
ManualOrNot = false,
|
||||
Pn = ammeterInfo.MeteringCode,
|
||||
IssuedMessageId = GuidGenerator.Create().ToString(),
|
||||
IssuedMessageHexString = Convert.ToHexString(builderResponse.Data),
|
||||
IsReceived = false,
|
||||
ScoreValue = $"{ammeterInfo.FocusAddress}.{taskMark}".Md5Fun(),
|
||||
};
|
||||
taskList.Add(meterReadingRecords);
|
||||
|
||||
if (taskList == null || taskList.Count <= 0)
|
||||
{
|
||||
_logger.LogError($"{nameof(AmmeterScheduledAutoValveControl)} 定时阀控运行时间{currentTime}没有自动阀控任务生成,-106");
|
||||
return;
|
||||
}
|
||||
|
||||
//任务记录入库
|
||||
await _dbProvider.BatchInsertAsync(metadata, taskList);
|
||||
|
||||
//任务信息推送Kafka
|
||||
_ = DeviceGroupBalanceControl.ProcessWithThrottleAsync<MeterReadingTelemetryPacketInfo>(
|
||||
items: taskList,
|
||||
deviceIdSelector: data => data.DeviceId,
|
||||
processor: (data, groupIndex) =>
|
||||
{
|
||||
_ = KafkaProducerIssuedMessageAction(ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, data, groupIndex);
|
||||
}
|
||||
);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动获取远程通信模块(SIM)版本信息
|
||||
/// </summary>
|
||||
/// <param name="timeDensity">采集频率</param>
|
||||
/// <param name="ammeterInfo">电表信息</param>
|
||||
/// <param name="groupIndex">集中器所在分组</param>
|
||||
/// <param name="timestamps">采集频率对应的时间戳</param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task ConcentratorScheduledAutomaticGetTelematicsModule(int timeDensity, AmmeterInfo ammeterInfo, int groupIndex, DateTime timestamps)
|
||||
{
|
||||
var currentTime = DateTime.Now;
|
||||
string currentTimeStr = $"{currentTime:HH:mm:00}";
|
||||
|
||||
try
|
||||
{
|
||||
//判断是否是自动获取版本号时间
|
||||
if (!string.Equals(currentTimeStr, _applicationOptions.AutomaticGetTerminalVersionTime, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
_logger.LogInformation($"{nameof(ConcentratorScheduledAutomaticGetTelematicsModule)} 自动获取远程通信模块(SIM)版本信息,非自动处理时间");
|
||||
return;
|
||||
}
|
||||
|
||||
List<MeterReadingTelemetryPacketInfo> taskList = new List<MeterReadingTelemetryPacketInfo>();
|
||||
var metadata = await _dbProvider.GetMetadata<MeterReadingTelemetryPacketInfo>();
|
||||
|
||||
var itemCode = T37612012PacketItemCodeConst.AFN09HFN09H;
|
||||
|
||||
//根据电表型号获取协议插件
|
||||
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(ammeterInfo.BrandType);
|
||||
if (protocolPlugin == null)
|
||||
{
|
||||
_logger.LogError($"{nameof(ConcentratorScheduledAutomaticGetTelematicsModule)} 自动获取远程通信模块(SIM)版本信息{currentTime}没有找到对应的协议组件,-105");
|
||||
return;
|
||||
}
|
||||
|
||||
ProtocolBuildResponse builderResponse = await protocolPlugin.BuildAsync(new ProtocolBuildRequest()
|
||||
{
|
||||
FocusAddress = ammeterInfo.FocusAddress,
|
||||
Pn = ammeterInfo.MeteringCode,
|
||||
ItemCode = itemCode,
|
||||
});
|
||||
|
||||
string taskMark = CommonHelper.GetTaskMark(builderResponse.AFn, builderResponse.Fn, ammeterInfo.MeteringCode, builderResponse.MSA, builderResponse.Seq);
|
||||
var meterReadingRecords = new MeterReadingTelemetryPacketInfo()
|
||||
{
|
||||
SystemName = SystemType,
|
||||
ProjectId = $"{ammeterInfo.ProjectID}",
|
||||
DeviceType = $"{MeterTypeEnum.Ammeter}",
|
||||
DeviceId = $"{ammeterInfo.MeterId}",
|
||||
Timestamps = currentTime.GetDateTimeOffset().ToUnixTimeNanoseconds(),
|
||||
DatabaseBusiID = ammeterInfo.DatabaseBusiID,
|
||||
PendingCopyReadTime = currentTime,
|
||||
CreationTime = currentTime,
|
||||
MeterAddress = ammeterInfo.AmmerterAddress,
|
||||
AFN = builderResponse.AFn,
|
||||
Fn = builderResponse.Fn,
|
||||
Seq = builderResponse.Seq,
|
||||
MSA = builderResponse.MSA,
|
||||
ItemCode = itemCode,
|
||||
//SubItemCode = subItemCode,
|
||||
TaskMark = taskMark,
|
||||
IsSend = false,
|
||||
ManualOrNot = false,
|
||||
Pn = ammeterInfo.MeteringCode,
|
||||
IssuedMessageId = GuidGenerator.Create().ToString(),
|
||||
IssuedMessageHexString = Convert.ToHexString(builderResponse.Data),
|
||||
IsReceived = false,
|
||||
ScoreValue = $"{ammeterInfo.FocusAddress}.{taskMark}".Md5Fun(),
|
||||
};
|
||||
taskList.Add(meterReadingRecords);
|
||||
|
||||
if (taskList == null || taskList.Count <= 0)
|
||||
{
|
||||
_logger.LogError($"{nameof(AmmeterScheduledAutoValveControl)} 定时阀控运行时间{currentTime}没有自动阀控任务生成,-106");
|
||||
return;
|
||||
}
|
||||
|
||||
//任务记录入库
|
||||
await _dbProvider.BatchInsertAsync(metadata, taskList);
|
||||
|
||||
//任务信息推送Kafka
|
||||
_ = DeviceGroupBalanceControl.ProcessWithThrottleAsync<MeterReadingTelemetryPacketInfo>(
|
||||
items: taskList,
|
||||
deviceIdSelector: data => data.DeviceId,
|
||||
processor: (data, groupIndex) =>
|
||||
{
|
||||
_ = KafkaProducerIssuedMessageAction(ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, data, groupIndex);
|
||||
}
|
||||
);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 公共处理方法
|
||||
|
||||
|
||||
@ -227,6 +227,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
//获取对应的缓存电表信息
|
||||
var ammeterInfo = ammeterInfos.First();
|
||||
bool tripStateResult = false;
|
||||
string itemCode = T37612012PacketItemCodeConst.AFN10HFN01H;
|
||||
string subItemCode = string.Empty;
|
||||
if (settingInfo.TripType.Equals("on"))
|
||||
{
|
||||
@ -250,7 +251,6 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
continue;
|
||||
}
|
||||
|
||||
var temCode = "10_01_";
|
||||
|
||||
//根据电表型号获取协议插件
|
||||
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(ammeterInfo.BrandType);
|
||||
@ -264,7 +264,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
{
|
||||
FocusAddress = ammeterInfo.FocusAddress,
|
||||
Pn = ammeterInfo.MeteringCode,
|
||||
ItemCode = temCode,
|
||||
ItemCode = itemCode,
|
||||
SubProtocolRequest = new SubProtocolBuildRequest()
|
||||
{
|
||||
MeterAddress = ammeterInfo.AmmerterAddress,
|
||||
@ -289,7 +289,8 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
Fn = builderResponse.Fn,
|
||||
Seq = builderResponse.Seq,
|
||||
MSA = builderResponse.MSA,
|
||||
ItemCode = temCode,
|
||||
ItemCode = itemCode,
|
||||
SubItemCode = subItemCode,
|
||||
TaskMark = taskMark,
|
||||
IsSend = false,
|
||||
ManualOrNot = false,
|
||||
|
||||
@ -104,6 +104,13 @@ namespace JiShe.CollectBus.IotSystems.MeterReadingRecords
|
||||
[FIELDColumn]
|
||||
public string ItemCode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 子项编码,一般用于透明转发的编码
|
||||
/// </summary>
|
||||
[FIELDColumn]
|
||||
public string SubItemCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 帧序列域 SEQ
|
||||
/// </summary>
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -17,22 +19,59 @@ namespace JiShe.CollectBus.Protocol.Contracts.Protocol.Dto
|
||||
/// <summary>
|
||||
/// 数据类型
|
||||
/// </summary>
|
||||
public string DataType { get; set; }
|
||||
public string DataType { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 错误码信息
|
||||
/// </summary>
|
||||
public string ErrorCodeMsg { get; set; }
|
||||
public string? ErrorCodeMsg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 字段名
|
||||
/// </summary>
|
||||
public string FiledName { get; set; }
|
||||
public string? FiledName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 字段描述
|
||||
/// </summary>
|
||||
public string FiledDesc { get; set; }
|
||||
public string? FiledDesc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据时标
|
||||
/// </summary>
|
||||
public DateTime TimeSpan { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据时间
|
||||
/// </summary>
|
||||
public DateTime DataTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 项目Id
|
||||
/// </summary>
|
||||
public int ProjectId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电表ID
|
||||
/// </summary>
|
||||
public int MeterId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 表类型
|
||||
/// </summary>
|
||||
public MeterTypeEnum MeterType { get; set;}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 数据业务库ID
|
||||
/// </summary>
|
||||
public int DatabaseBusiID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 表地址
|
||||
/// </summary>
|
||||
public string MeterAddress { get; set; } = null!;
|
||||
|
||||
}
|
||||
|
||||
public class AnalysisBaseDto<T> : AnalysisBaseDto
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
namespace JiShe.CollectBus.Protocol.Dto
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.Dto
|
||||
{
|
||||
public class UnitDataAnalysis
|
||||
{
|
||||
@ -32,6 +34,26 @@
|
||||
/// </summary>
|
||||
public int PSEQ { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 响应帧
|
||||
/// </summary>
|
||||
public string? HexMessage { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// 消息ID
|
||||
/// </summary>
|
||||
public string? MessageId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 采集密度
|
||||
/// </summary>
|
||||
public int TimeDensity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 采集密度单位
|
||||
/// </summary>
|
||||
public DensityUnit DensityUnit { get; set; }= DensityUnit.Minute;
|
||||
|
||||
}
|
||||
|
||||
public class UnitDataAnalysis<T>: UnitDataAnalysis
|
||||
|
||||
@ -17,6 +17,11 @@ namespace JiShe.CollectBus.Protocol3761
|
||||
/// </summary>
|
||||
public BaseHexMessage BaseHexMessage { get; set;}=new BaseHexMessage();
|
||||
|
||||
/// <summary>
|
||||
/// 报文ID
|
||||
/// </summary>
|
||||
public string? MessageId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 控制域C
|
||||
/// </summary>
|
||||
|
||||
@ -54,6 +54,7 @@ namespace JiShe.CollectBus.Common.Consts
|
||||
public const string ADL = "ADL";
|
||||
public const string BDL = "BDL";
|
||||
public const string CDL = "CDL";
|
||||
public const string LXDL = "LXDL";
|
||||
|
||||
public const string PowerGridFrequency = "PowerGridFrequency";
|
||||
|
||||
@ -106,6 +107,7 @@ namespace JiShe.CollectBus.Common.Consts
|
||||
public const string ADL = "0D_92"; //A相电流曲线
|
||||
public const string BDL = "0D_93"; //B相电流曲线
|
||||
public const string CDL = "0D_94"; //C相电流曲线
|
||||
public const string LXDL = "0D_95"; // 零序电流
|
||||
|
||||
public const string PowerGridFrequency = "10_97"; //电网频率
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace JiShe.CollectBus.Common.Consts
|
||||
{
|
||||
/// <summary>
|
||||
/// T188报文项编码
|
||||
/// T188-2018报文项编码
|
||||
/// </summary>
|
||||
public class T1882018PacketItemCodeConst
|
||||
{
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.CollectBus.Common.Consts
|
||||
{
|
||||
/// <summary>
|
||||
/// T376.1-2012报文项编码
|
||||
/// </summary>
|
||||
public class T37612012PacketItemCodeConst
|
||||
{
|
||||
#region 非可配置的,下行报文编码管理,主要是数据库没有配置,但是需要读取的采集项
|
||||
|
||||
#region 读数据
|
||||
/// <summary>
|
||||
/// 透明转发
|
||||
/// </summary>
|
||||
public const string AFN10HFN01H = $"10_01";
|
||||
|
||||
/// <summary>
|
||||
/// 读取终端信息
|
||||
/// </summary>
|
||||
public const string AFN09HFN01H = $"09_01";
|
||||
|
||||
/// <summary>
|
||||
/// 远程通信模块版本信息
|
||||
/// </summary>
|
||||
public const string AFN09HFN09H = $"09_09";
|
||||
|
||||
#endregion
|
||||
|
||||
#region 写数据
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace JiShe.CollectBus.Common.Consts
|
||||
{
|
||||
/// <summary>
|
||||
/// T6452007报文项编码
|
||||
/// T645-2007报文项编码
|
||||
/// </summary>
|
||||
public class T6452007PacketItemCodeConst
|
||||
{
|
||||
|
||||
@ -373,4 +373,50 @@ namespace JiShe.CollectBus.Common.Enums
|
||||
登录 = 1,
|
||||
心跳 = 3
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据冻结密度
|
||||
/// </summary>
|
||||
public enum DensityEnums
|
||||
{
|
||||
Sec_1 = 255,
|
||||
Sec_5 = 254,
|
||||
Sec_60 = 3,
|
||||
Sec_30 = 2,
|
||||
Sec_15 = 1,
|
||||
Sec_0 = 0
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据冻结密度单位
|
||||
/// </summary>
|
||||
public enum DensityUnit
|
||||
{
|
||||
/// <summary>
|
||||
/// 秒
|
||||
/// </summary>
|
||||
Second=0,
|
||||
/// <summary>
|
||||
/// 分钟
|
||||
/// </summary>
|
||||
Minute=1,
|
||||
/// <summary>
|
||||
/// 小时
|
||||
/// </summary>
|
||||
Hour=2,
|
||||
/// <summary>
|
||||
/// 天
|
||||
/// </summary>
|
||||
Day=3,
|
||||
/// <summary>
|
||||
/// 月
|
||||
/// </summary>
|
||||
Month=4,
|
||||
/// <summary>
|
||||
/// 年
|
||||
/// </summary>
|
||||
Year=5
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -10,6 +10,11 @@
|
||||
/// </summary>
|
||||
public required string ServerTagName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 系统类型
|
||||
/// </summary>
|
||||
public required string SystemType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 首次采集时间
|
||||
/// </summary>
|
||||
@ -19,5 +24,15 @@
|
||||
/// 自动验证时间
|
||||
/// </summary>
|
||||
public required string AutomaticVerificationTime { get; set;}
|
||||
|
||||
/// <summary>
|
||||
/// 自动获取终端版时间
|
||||
/// </summary>
|
||||
public required string AutomaticGetTerminalVersionTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 自动获取远程通信模块(SIM)版本时间
|
||||
/// </summary>
|
||||
public required string AutomaticGetTelematicsModuleTime { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,5 +141,14 @@
|
||||
"DefaultIdempotence": true
|
||||
}
|
||||
},
|
||||
"PlugInFolder": "C:\\Users\\Dai Zan\\Desktop\\Plugins",
|
||||
"ServerApplicationOptions": {
|
||||
"ServerTagName": "JiSheCollectBus100",
|
||||
"SystemType": null,
|
||||
"FirstCollectionTime": "2025-04-22 16:07:00",
|
||||
"AutomaticVerificationTime": "16:07:00",
|
||||
"AutomaticGetTerminalVersionTime": "17:07:00",
|
||||
"AutomaticGetTelematicsModuleTime": "17:30:00"
|
||||
}
|
||||
"PlugInFolder": ""
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user