diff --git a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_10H/AFN16_F1_Analysis.cs b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_10H/AFN16_F1_Analysis.cs index 7039b32..67b0005 100644 --- a/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_10H/AFN16_F1_Analysis.cs +++ b/protocols/JiShe.CollectBus.Protocol.T37612012/AnalysisData/AFN_10H/AFN16_F1_Analysis.cs @@ -1,5 +1,8 @@ using GatherService.WattMeter.AnalysisData.AFN_10H; +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; @@ -21,11 +24,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H { private readonly ILogger _logger; private readonly AnalysisStrategyContext _analysisStrategyContext; - - public AFN16_F1_Analysis(ILogger logger, AnalysisStrategyContext analysisStrategyContext) + private readonly DataStorage _dataStorage; + public AFN16_F1_Analysis(ILogger logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage) { _logger = logger; _analysisStrategyContext = analysisStrategyContext; + _dataStorage = dataStorage; } public async Task ExecuteAsync(TB3761 input, Action? result = null) @@ -52,6 +56,38 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H }); else { + //TODO: 写入1条日志 + var data = new AnalysisBaseDto() + { + FiledDesc = "透明转发", + ItemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}" + }; + // 查询设备信息 + DeviceInfo? deviceInfo = await _dataStorage.GetDeviceInfoAsync(input.A.Code); + if (deviceInfo != null) + { + data.ProjectId = deviceInfo.ProjectID; + data.DeviceId = deviceInfo.FocusId; + data.DatabaseBusiID = deviceInfo.DatabaseBusiID; + data.DeviceAddress = deviceInfo.FocusAddress; + data.DeviceType = MeterTypeEnum.Focus; + data.FocusId = deviceInfo.FocusId; + } + UnitDataAnalysis> dto = new UnitDataAnalysis> + { + Code = input.A.Code, + AFN = input.AFN_FC.AFN, + Fn = input.DT.Fn, + Pn = input.DA.Pn, + Data = data, + ReceivedHexMessage = input.BaseHexMessage.HexMessageString, + MessageId = input.MessageId, + ReceivedTime = input.ReceivedTime, + DensityUnit = DensityUnit.None, + TimeDensity = -1, + DataType = IOTDBDataTypeConst.Log + }; + await _dataStorage.SaveDataToIotDbAsync(dto); _logger.LogWarning($"未能找到透明传发解析方式:{input.BaseHexMessage.HexMessageString}"); } } @@ -60,7 +96,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H } catch (Exception ex) { - _logger.LogError(ex, $"10_101解析失败:{input.A?.Code}-{input.DT?.Fn ?? 0}-{input?.BaseHexMessage?.HexMessageString},{ex.Message}"); + _logger.LogError(ex, $"10_1解析失败:{input.A?.Code}-{input.DT?.Fn ?? 0}-{input?.BaseHexMessage?.HexMessageString},{ex.Message}"); } return await Task.FromResult(false); diff --git a/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs b/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs index 14c7fea..30ae8ba 100644 --- a/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs +++ b/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs @@ -1,4 +1,5 @@ -using DeviceDetectorNET.Parser.Device; +using Confluent.Kafka; +using DeviceDetectorNET.Parser.Device; using FreeSql.Internal.CommonProvider; using JiShe.CollectBus.Ammeters; using JiShe.CollectBus.Application.Contracts; @@ -542,7 +543,7 @@ public class SampleAppService : CollectBusAppService, ISampleAppService, IKafkaS /// /// /// - [KafkaSubscribe(ProtocolConst.TESTSENDTOPIC)] + [KafkaSubscribe(ProtocolConst.TESTSENDTOPIC), ApiExplorerSettings(IgnoreApi = true)] public async Task KafkaSubscribeTestSendAsync(KafkaSendDto dto) {