合并代码
This commit is contained in:
commit
ea91622217
@ -1,11 +1,12 @@
|
||||
using GatherService.WattMeter.AnalysisData.AFN_10H;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Devices;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H.Ammeter;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H.Watermeter;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
@ -54,6 +55,11 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H
|
||||
{
|
||||
result?.Invoke(dto);
|
||||
});
|
||||
else if (value.Contains(F10TranspondMatch.ES190_DC))
|
||||
await _analysisStrategyContext.ExecuteAsync<TB3761>(nameof(ES190DC_Analysis), input, dto =>
|
||||
{
|
||||
result?.Invoke(dto);
|
||||
});
|
||||
else
|
||||
{
|
||||
//TODO: 写入1条日志
|
||||
|
||||
@ -11,7 +11,7 @@ using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text;
|
||||
|
||||
namespace GatherService.WattMeter.AnalysisData.AFN_10H
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H.Ammeter
|
||||
{
|
||||
/// <summary>
|
||||
/// 5.16.1.2.1 F1:透明转发 读取SIM卡信息
|
||||
@ -64,7 +64,7 @@ namespace GatherService.WattMeter.AnalysisData.AFN_10H
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
result?.Invoke(dto);
|
||||
await _dataStorage.SaveDataToIotDbAsync<string?>(dto);
|
||||
await _dataStorage.SaveDataToIotDbAsync(dto);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -1,5 +1,4 @@
|
||||
using DeviceDetectorNET.Parser.Device;
|
||||
using GatherService.WattMeter.AnalysisData.AFN_10H;
|
||||
using DeviceDetectorNET.Parser.Device;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
@ -19,7 +18,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static FreeSql.Internal.GlobalFilter;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H.Ammeter
|
||||
{
|
||||
/// <summary>
|
||||
/// 透抄 电网频率
|
||||
@ -74,7 +73,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H
|
||||
|
||||
};
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
await _dataStorage.SaveDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
await _dataStorage.SaveDataToIotDbAsync(unitDataAnalysis);
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
@ -134,7 +133,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H
|
||||
string dataMark = string.Join("",dataField.GetRange(0, 4).ReduceHex33(true));
|
||||
values.Add(dataMark);//数据标识
|
||||
var readValue = dataField.GetRange(4, len - 4).ReduceHex33(true);//值
|
||||
await _analysisStrategyContext.ExecuteAsync<List<string>>($"Appendix_{dataMark}", readValue, (value) =>
|
||||
await _analysisStrategyContext.ExecuteAsync($"Appendix_{dataMark}", readValue, (value) =>
|
||||
{
|
||||
values.Add(value.ToString());
|
||||
});
|
||||
@ -11,7 +11,7 @@ using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace GatherService.WattMeter.AnalysisData.AFN_10H
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H.Ammeter
|
||||
{
|
||||
/// <summary>
|
||||
/// 透明转发---跳合闸
|
||||
@ -42,7 +42,7 @@ namespace GatherService.WattMeter.AnalysisData.AFN_10H
|
||||
var data = new AnalysisBaseDto<bool?>()
|
||||
{
|
||||
FiledDesc = "跳合闸",
|
||||
DataValue = (datas[2].Equals("9C") || datas[2].Equals("94")) ? true : false,
|
||||
DataValue = datas[2].Equals("9C") || datas[2].Equals("94") ? true : false,
|
||||
ItemType= "10_98",
|
||||
};
|
||||
|
||||
@ -0,0 +1,130 @@
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Devices;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H.Ammeter;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H.Watermeter
|
||||
{
|
||||
/// <summary>
|
||||
/// ES_190DC 4G水表读数解析
|
||||
/// </summary>
|
||||
public class ES190DC_Analysis : IAnalysisStrategy<TB3761>
|
||||
{
|
||||
private readonly ILogger<ES190DC_Analysis> _logger;
|
||||
private readonly DataStorage _dataStorage;
|
||||
public ES190DC_Analysis(ILogger<ES190DC_Analysis> logger, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.A.Code);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<AnalysisBaseDto<decimal?>> list = GenerateFinalResult(input.UnitData.HexMessageList);
|
||||
if (list.Count > 0)
|
||||
{
|
||||
// 查询设备信息
|
||||
DeviceInfo? deviceInfo = await _dataStorage.GetDeviceInfoAsync(input.A.Code, input.DA.Pn, list[0].DeviceAddress);
|
||||
if (deviceInfo != null)
|
||||
{
|
||||
list.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = deviceInfo.ProjectID;
|
||||
item.DeviceId = deviceInfo.MeterId;
|
||||
item.DatabaseBusiID = deviceInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = deviceInfo.MeterAddress;
|
||||
item.FocusId = deviceInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
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 = list,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Hour,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data
|
||||
|
||||
};
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync(unitDataAnalysis);
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"ES190DC 4G水表解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return await Task.FromResult(false);
|
||||
}
|
||||
}
|
||||
|
||||
private List<AnalysisBaseDto<decimal?>> GenerateFinalResult(List<string> hexMessageList)
|
||||
{
|
||||
List<AnalysisBaseDto<decimal?>> list = new List<AnalysisBaseDto<decimal?>>();
|
||||
string address = string.Join("", hexMessageList.Skip(12).Take(7).Reverse());
|
||||
if (hexMessageList[19].Contains("81"))
|
||||
{
|
||||
int count = Convert.ToInt32(hexMessageList[36].HexToDec());
|
||||
DateTime startTime = Convert.ToDateTime($"{DateTime.Now.Year.ToString().Substring(0, 2)}{hexMessageList[41]}-{hexMessageList[40]}-{hexMessageList[39]} {hexMessageList[38]}:{hexMessageList[37]}:00");
|
||||
|
||||
List<string> valueArr = hexMessageList.GetRange(42, count * 4);
|
||||
int nextIndex = 0;
|
||||
for (int i = 1; i <= count; i++)
|
||||
{
|
||||
AnalysisBaseDto<decimal?> meter = new AnalysisBaseDto<decimal?>();
|
||||
meter.DeviceType = MeterTypeEnum.WaterMeter;
|
||||
meter.DeviceAddress = address;
|
||||
var arr = valueArr.GetRange(nextIndex, 4);
|
||||
var errorCode = arr[4].CheckErrorCode();
|
||||
if (errorCode != null)
|
||||
{
|
||||
meter.ValidData = false;
|
||||
meter.ErrorCodeMsg = errorCode.Item2;
|
||||
}
|
||||
else
|
||||
{
|
||||
string val = $"{arr[3]}{arr[2]}{arr[1]}.{arr[0]}";
|
||||
if (decimal.TryParse(val, out decimal value))
|
||||
meter.DataValue = value;
|
||||
}
|
||||
string timeSpan = startTime.AddHours(i - 1).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
if (DateTime.TryParse(timeSpan, out DateTime readingDate))
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
meter.ItemType = "10_250";
|
||||
meter.FiledDesc = "当前累积流量";
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
nextIndex += 4;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,7 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace JiShe.CollectBus.DataChannels
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user