2025-06-03 11:58:17 +08:00
|
|
|
|
using JiShe.CollectBus.Common.Helpers;
|
2025-04-25 09:28:56 +08:00
|
|
|
|
using JiShe.CollectBus.IotSystems.MessageReceiveds;
|
2025-06-03 11:58:17 +08:00
|
|
|
|
using JiShe.CollectBus.Protocol;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol.Dto;
|
2025-04-25 14:23:06 +08:00
|
|
|
|
using JiShe.CollectBus.Protocol.Interfaces;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol3761;
|
2025-04-25 09:28:56 +08:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
using TouchSocket.Sockets;
|
|
|
|
|
|
|
|
|
|
|
|
namespace JiShe.CollectBus.Subscribers
|
|
|
|
|
|
{
|
|
|
|
|
|
public class SubscriberAnalysisAppService : CollectBusAppService, ISubscriberAnalysisAppService, IKafkaSubscribe
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly ILogger<SubscriberAnalysisAppService> _logger;
|
|
|
|
|
|
private readonly ITcpService _tcpService;
|
|
|
|
|
|
private readonly IServiceProvider _serviceProvider;
|
2025-06-03 11:58:17 +08:00
|
|
|
|
private readonly IoTDBSessionPoolProvider _dbProvider;
|
2025-04-25 09:28:56 +08:00
|
|
|
|
private readonly IProtocolService _protocolService;
|
|
|
|
|
|
|
|
|
|
|
|
public SubscriberAnalysisAppService(ILogger<SubscriberAnalysisAppService> logger,
|
|
|
|
|
|
ITcpService tcpService,
|
|
|
|
|
|
IServiceProvider serviceProvider,
|
2025-06-03 11:58:17 +08:00
|
|
|
|
IoTDBSessionPoolProvider dbProvider,
|
2025-05-26 11:20:32 +08:00
|
|
|
|
IProtocolService protocolService)
|
2025-04-25 09:28:56 +08:00
|
|
|
|
{
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
|
_tcpService = tcpService;
|
|
|
|
|
|
_serviceProvider = serviceProvider;
|
|
|
|
|
|
_dbProvider = dbProvider;
|
|
|
|
|
|
_protocolService = protocolService;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-19 08:51:10 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 解析AFN00H
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="receivedMessage"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-06-03 11:58:17 +08:00
|
|
|
|
[KafkaSubscribe(KafkaTopicConsts.SubscriberAFN00HReceivedEventName)]
|
2025-05-19 08:51:10 +08:00
|
|
|
|
public async Task<ISubscribeAck> ReceivedAFN00Event(MessageProtocolAnalysis<TB3761> receivedMessage)
|
|
|
|
|
|
{
|
|
|
|
|
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(receivedMessage.DeviceNo);
|
|
|
|
|
|
if (protocolPlugin == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError("协议不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (receivedMessage.Data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (receivedMessage.Data.DT == null || receivedMessage.Data.AFN_FC == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
string serverName = $"AFN{receivedMessage.Data.AFN_FC.AFN}_F{receivedMessage.Data.DT.Fn}_Analysis";
|
|
|
|
|
|
//var analysisStrategy = _serviceProvider.GetKeyedService<IAnalysisStrategy>($"AFN0_F1_Analysis");
|
|
|
|
|
|
|
|
|
|
|
|
//var data = await analysisStrategy.ExecuteAsync<UnitDataDto<bool>>(tB3761);
|
|
|
|
|
|
var executor = _serviceProvider.GetRequiredService<AnalysisStrategyContext>();
|
|
|
|
|
|
await executor.ExecuteAsync<TB3761>(serverName, receivedMessage.Data);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SubscribeAck.Fail();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 解析AFN01H
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="receivedMessage"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-06-03 11:58:17 +08:00
|
|
|
|
[KafkaSubscribe(KafkaTopicConsts.SubscriberAFN01HReceivedEventName)]
|
2025-05-19 08:51:10 +08:00
|
|
|
|
public async Task<ISubscribeAck> ReceivedAFN01Event(MessageProtocolAnalysis<TB3761> receivedMessage)
|
|
|
|
|
|
{
|
|
|
|
|
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(receivedMessage.DeviceNo);
|
|
|
|
|
|
if (protocolPlugin == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError("协议不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (receivedMessage.Data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (receivedMessage.Data.DT == null || receivedMessage.Data.AFN_FC == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
string serverName = $"AFN{receivedMessage.Data.AFN_FC.AFN}_F{receivedMessage.Data.DT.Fn}_Analysis";
|
|
|
|
|
|
//var analysisStrategy = _serviceProvider.GetKeyedService<IAnalysisStrategy>($"AFN0_F1_Analysis");
|
|
|
|
|
|
|
|
|
|
|
|
//var data = await analysisStrategy.ExecuteAsync<UnitDataDto<bool>>(tB3761);
|
|
|
|
|
|
var executor = _serviceProvider.GetRequiredService<AnalysisStrategyContext>();
|
|
|
|
|
|
await executor.ExecuteAsync<TB3761>(serverName, receivedMessage.Data);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SubscribeAck.Fail();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 解析AFN02H
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="receivedMessage"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-06-03 11:58:17 +08:00
|
|
|
|
[KafkaSubscribe(KafkaTopicConsts.SubscriberAFN02HReceivedEventName)]
|
2025-05-19 08:51:10 +08:00
|
|
|
|
public async Task<ISubscribeAck> ReceivedAFN02Event(MessageProtocolAnalysis<TB3761> receivedMessage)
|
|
|
|
|
|
{
|
|
|
|
|
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(receivedMessage.DeviceNo);
|
|
|
|
|
|
if (protocolPlugin == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError("协议不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (receivedMessage.Data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (receivedMessage.Data.DT == null || receivedMessage.Data.AFN_FC == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
string serverName = $"AFN{receivedMessage.Data.AFN_FC.AFN}_F{receivedMessage.Data.DT.Fn}_Analysis";
|
|
|
|
|
|
//var analysisStrategy = _serviceProvider.GetKeyedService<IAnalysisStrategy>($"AFN0_F1_Analysis");
|
|
|
|
|
|
|
|
|
|
|
|
//var data = await analysisStrategy.ExecuteAsync<UnitDataDto<bool>>(tB3761);
|
|
|
|
|
|
var executor = _serviceProvider.GetRequiredService<AnalysisStrategyContext>();
|
|
|
|
|
|
await executor.ExecuteAsync<TB3761>(serverName, receivedMessage.Data, (result) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var ssss = (UnitDataAnalysis<AnalysisBaseDto<string>>)result;
|
|
|
|
|
|
_logger.LogInformation($"解析AFN02H数据:{ssss.Serialize()}");
|
|
|
|
|
|
});
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
return SubscribeAck.Fail();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 解析AFN03H
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="receivedMessage"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-06-03 11:58:17 +08:00
|
|
|
|
[KafkaSubscribe(KafkaTopicConsts.SubscriberAFN03HReceivedEventName)]
|
2025-05-19 08:51:10 +08:00
|
|
|
|
public async Task<ISubscribeAck> ReceivedAFN03Event(MessageProtocolAnalysis<TB3761> receivedMessage)
|
|
|
|
|
|
{
|
|
|
|
|
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(receivedMessage.DeviceNo);
|
|
|
|
|
|
if (protocolPlugin == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError("协议不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (receivedMessage.Data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (receivedMessage.Data.DT == null || receivedMessage.Data.AFN_FC == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
string serverName = $"AFN{receivedMessage.Data.AFN_FC.AFN}_F{receivedMessage.Data.DT.Fn}_Analysis";
|
|
|
|
|
|
//var analysisStrategy = _serviceProvider.GetKeyedService<IAnalysisStrategy>($"AFN0_F1_Analysis");
|
|
|
|
|
|
|
|
|
|
|
|
//var data = await analysisStrategy.ExecuteAsync<UnitDataDto<bool>>(tB3761);
|
|
|
|
|
|
var executor = _serviceProvider.GetRequiredService<AnalysisStrategyContext>();
|
|
|
|
|
|
await executor.ExecuteAsync<TB3761>(serverName, receivedMessage.Data);
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SubscribeAck.Fail();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 解析AFN04H
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="receivedMessage"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-06-03 11:58:17 +08:00
|
|
|
|
[KafkaSubscribe(KafkaTopicConsts.SubscriberAFN04HReceivedEventName)]
|
2025-05-19 08:51:10 +08:00
|
|
|
|
public async Task<ISubscribeAck> ReceivedAFN04Event(MessageProtocolAnalysis<TB3761> receivedMessage)
|
|
|
|
|
|
{
|
|
|
|
|
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(receivedMessage.DeviceNo);
|
|
|
|
|
|
if (protocolPlugin == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError("协议不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (receivedMessage.Data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (receivedMessage.Data.DT == null || receivedMessage.Data.AFN_FC == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
string serverName = $"AFN{receivedMessage.Data.AFN_FC.AFN}_F{receivedMessage.Data.DT.Fn}_Analysis";
|
|
|
|
|
|
//var analysisStrategy = _serviceProvider.GetKeyedService<IAnalysisStrategy>($"AFN0_F1_Analysis");
|
|
|
|
|
|
|
|
|
|
|
|
//var data = await analysisStrategy.ExecuteAsync<UnitDataDto<bool>>(tB3761);
|
|
|
|
|
|
var executor = _serviceProvider.GetRequiredService<AnalysisStrategyContext>();
|
|
|
|
|
|
await executor.ExecuteAsync<TB3761>(serverName, receivedMessage.Data);
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SubscribeAck.Fail();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 解析AFN05H
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="receivedMessage"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-06-03 11:58:17 +08:00
|
|
|
|
[KafkaSubscribe(KafkaTopicConsts.SubscriberAFN05HReceivedEventName)]
|
2025-05-19 08:51:10 +08:00
|
|
|
|
public async Task<ISubscribeAck> ReceivedAFN05Event(MessageProtocolAnalysis<TB3761> receivedMessage)
|
|
|
|
|
|
{
|
|
|
|
|
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(receivedMessage.DeviceNo);
|
|
|
|
|
|
if (protocolPlugin == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError("协议不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (receivedMessage.Data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (receivedMessage.Data.DT == null || receivedMessage.Data.AFN_FC == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
string serverName = $"AFN{receivedMessage.Data.AFN_FC.AFN}_F{receivedMessage.Data.DT.Fn}_Analysis";
|
|
|
|
|
|
//var analysisStrategy = _serviceProvider.GetKeyedService<IAnalysisStrategy>($"AFN0_F1_Analysis");
|
|
|
|
|
|
|
|
|
|
|
|
//var data = await analysisStrategy.ExecuteAsync<UnitDataDto<bool>>(tB3761);
|
|
|
|
|
|
var executor = _serviceProvider.GetRequiredService<AnalysisStrategyContext>();
|
|
|
|
|
|
await executor.ExecuteAsync<TB3761>(serverName, receivedMessage.Data);
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SubscribeAck.Fail();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 解析AFN09H
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="receivedMessage"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-06-03 11:58:17 +08:00
|
|
|
|
[KafkaSubscribe(KafkaTopicConsts.SubscriberAFN09HReceivedEventName)]
|
2025-05-19 08:51:10 +08:00
|
|
|
|
public async Task<ISubscribeAck> ReceivedAFN09Event(MessageProtocolAnalysis<TB3761> receivedMessage)
|
|
|
|
|
|
{
|
|
|
|
|
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(receivedMessage.DeviceNo);
|
|
|
|
|
|
if (protocolPlugin == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError("协议不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (receivedMessage.Data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (receivedMessage.Data.DT == null || receivedMessage.Data.AFN_FC == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
string serverName = $"AFN{receivedMessage.Data.AFN_FC.AFN}_F{receivedMessage.Data.DT.Fn}_Analysis";
|
|
|
|
|
|
//var analysisStrategy = _serviceProvider.GetKeyedService<IAnalysisStrategy>($"AFN0_F1_Analysis");
|
|
|
|
|
|
|
|
|
|
|
|
//var data = await analysisStrategy.ExecuteAsync<UnitDataDto<bool>>(tB3761);
|
|
|
|
|
|
var executor = _serviceProvider.GetRequiredService<AnalysisStrategyContext>();
|
|
|
|
|
|
await executor.ExecuteAsync<TB3761>(serverName, receivedMessage.Data);
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SubscribeAck.Fail();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 解析AFN0AH
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="receivedMessage"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-06-03 11:58:17 +08:00
|
|
|
|
[KafkaSubscribe(KafkaTopicConsts.SubscriberAFN0AHReceivedEventName)]
|
2025-05-19 08:51:10 +08:00
|
|
|
|
public async Task<ISubscribeAck> ReceivedAFN0AEvent(MessageProtocolAnalysis<TB3761> receivedMessage)
|
|
|
|
|
|
{
|
|
|
|
|
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(receivedMessage.DeviceNo);
|
|
|
|
|
|
if (protocolPlugin == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError("协议不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (receivedMessage.Data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (receivedMessage.Data.DT == null || receivedMessage.Data.AFN_FC == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
string serverName = $"AFN{receivedMessage.Data.AFN_FC.AFN}_F{receivedMessage.Data.DT.Fn}_Analysis";
|
|
|
|
|
|
//var analysisStrategy = _serviceProvider.GetKeyedService<IAnalysisStrategy>($"AFN0_F1_Analysis");
|
|
|
|
|
|
|
|
|
|
|
|
//var data = await analysisStrategy.ExecuteAsync<UnitDataDto<bool>>(tB3761);
|
|
|
|
|
|
var executor = _serviceProvider.GetRequiredService<AnalysisStrategyContext>();
|
|
|
|
|
|
await executor.ExecuteAsync<TB3761>(serverName, receivedMessage.Data);
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SubscribeAck.Fail();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 解析AFN0BH
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="receivedMessage"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-06-03 11:58:17 +08:00
|
|
|
|
[KafkaSubscribe(KafkaTopicConsts.SubscriberAFN0BHReceivedEventName)]
|
2025-05-19 08:51:10 +08:00
|
|
|
|
public async Task<ISubscribeAck> ReceivedAFN0BEvent(MessageProtocolAnalysis<TB3761> receivedMessage)
|
|
|
|
|
|
{
|
|
|
|
|
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(receivedMessage.DeviceNo);
|
|
|
|
|
|
if (protocolPlugin == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError("协议不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (receivedMessage.Data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (receivedMessage.Data.DT == null || receivedMessage.Data.AFN_FC == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
string serverName = $"AFN{receivedMessage.Data.AFN_FC.AFN}_F{receivedMessage.Data.DT.Fn}_Analysis";
|
|
|
|
|
|
//var analysisStrategy = _serviceProvider.GetKeyedService<IAnalysisStrategy>($"AFN0_F1_Analysis");
|
|
|
|
|
|
|
|
|
|
|
|
//var data = await analysisStrategy.ExecuteAsync<UnitDataDto<bool>>(tB3761);
|
|
|
|
|
|
var executor = _serviceProvider.GetRequiredService<AnalysisStrategyContext>();
|
|
|
|
|
|
await executor.ExecuteAsync<TB3761>(serverName, receivedMessage.Data);
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SubscribeAck.Fail();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 解析AFN0CH
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="receivedMessage"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-06-03 11:58:17 +08:00
|
|
|
|
[KafkaSubscribe(KafkaTopicConsts.SubscriberAFN0CHReceivedEventName)]
|
2025-05-19 08:51:10 +08:00
|
|
|
|
public async Task<ISubscribeAck> ReceivedAFN0CEvent(MessageProtocolAnalysis<TB3761> receivedMessage)
|
|
|
|
|
|
{
|
|
|
|
|
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(receivedMessage.DeviceNo);
|
|
|
|
|
|
if (protocolPlugin == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError("协议不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (receivedMessage.Data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (receivedMessage.Data.DT == null || receivedMessage.Data.AFN_FC == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
string serverName = $"AFN{receivedMessage.Data.AFN_FC.AFN}_F{receivedMessage.Data.DT.Fn}_Analysis";
|
|
|
|
|
|
//var analysisStrategy = _serviceProvider.GetKeyedService<IAnalysisStrategy>($"AFN0_F1_Analysis");
|
|
|
|
|
|
|
|
|
|
|
|
//var data = await analysisStrategy.ExecuteAsync<UnitDataDto<bool>>(tB3761);
|
|
|
|
|
|
var executor = _serviceProvider.GetRequiredService<AnalysisStrategyContext>();
|
|
|
|
|
|
await executor.ExecuteAsync<TB3761>(serverName, receivedMessage.Data);
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SubscribeAck.Fail();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 解析AFN0DH
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="receivedMessage"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-06-03 11:58:17 +08:00
|
|
|
|
[KafkaSubscribe(KafkaTopicConsts.SubscriberAFN0DHReceivedEventName)]
|
2025-05-19 08:51:10 +08:00
|
|
|
|
public async Task<ISubscribeAck> ReceivedAFN0DEvent(MessageProtocolAnalysis<TB3761> receivedMessage)
|
|
|
|
|
|
{
|
|
|
|
|
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(receivedMessage.DeviceNo);
|
|
|
|
|
|
if (protocolPlugin == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError("协议不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (receivedMessage.Data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (receivedMessage.Data.DT == null || receivedMessage.Data.AFN_FC == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
string serverName = $"AFN{receivedMessage.Data.AFN_FC.AFN}_F{receivedMessage.Data.DT.Fn}_Analysis";
|
|
|
|
|
|
//var analysisStrategy = _serviceProvider.GetKeyedService<IAnalysisStrategy>($"AFN0_F1_Analysis");
|
|
|
|
|
|
|
|
|
|
|
|
//var data = await analysisStrategy.ExecuteAsync<UnitDataDto<bool>>(tB3761);
|
|
|
|
|
|
var executor = _serviceProvider.GetRequiredService<AnalysisStrategyContext>();
|
|
|
|
|
|
await executor.ExecuteAsync<TB3761>(serverName, receivedMessage.Data);
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SubscribeAck.Fail();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 解析AFN0EH
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="receivedMessage"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-06-03 11:58:17 +08:00
|
|
|
|
[KafkaSubscribe(KafkaTopicConsts.SubscriberAFN0EHReceivedEventName)]
|
2025-05-19 08:51:10 +08:00
|
|
|
|
public async Task<ISubscribeAck> ReceivedAFN0EEvent(MessageProtocolAnalysis<TB3761> receivedMessage)
|
|
|
|
|
|
{
|
|
|
|
|
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(receivedMessage.DeviceNo);
|
|
|
|
|
|
if (protocolPlugin == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError("协议不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (receivedMessage.Data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (receivedMessage.Data.DT == null || receivedMessage.Data.AFN_FC == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
string serverName = $"AFN{receivedMessage.Data.AFN_FC.AFN}_F{receivedMessage.Data.DT.Fn}_Analysis";
|
|
|
|
|
|
//var analysisStrategy = _serviceProvider.GetKeyedService<IAnalysisStrategy>($"AFN0_F1_Analysis");
|
|
|
|
|
|
|
|
|
|
|
|
//var data = await analysisStrategy.ExecuteAsync<UnitDataDto<bool>>(tB3761);
|
|
|
|
|
|
var executor = _serviceProvider.GetRequiredService<AnalysisStrategyContext>();
|
|
|
|
|
|
await executor.ExecuteAsync<TB3761>(serverName, receivedMessage.Data);
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SubscribeAck.Fail();
|
|
|
|
|
|
}
|
2025-04-27 15:44:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 解析AFN0HH
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="receivedMessage"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-06-03 11:58:17 +08:00
|
|
|
|
[KafkaSubscribe(KafkaTopicConsts.SubscriberAFN10HReceivedEventName)]
|
2025-04-27 15:44:54 +08:00
|
|
|
|
public async Task<ISubscribeAck> ReceivedAFN0HEvent(MessageProtocolAnalysis<TB3761> receivedMessage)
|
|
|
|
|
|
{
|
|
|
|
|
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(receivedMessage.DeviceNo);
|
|
|
|
|
|
if (protocolPlugin == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError("协议不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (receivedMessage.Data == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (receivedMessage.Data.DT == null || receivedMessage.Data.AFN_FC == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError($"数据解析失败:{receivedMessage.Serialize()}");
|
|
|
|
|
|
return SubscribeAck.Success();
|
|
|
|
|
|
}
|
|
|
|
|
|
string serverName = $"AFN{receivedMessage.Data.AFN_FC.AFN}_F{receivedMessage.Data.DT.Fn}_Analysis";
|
|
|
|
|
|
//var analysisStrategy = _serviceProvider.GetKeyedService<IAnalysisStrategy>($"AFN0_F1_Analysis");
|
|
|
|
|
|
|
|
|
|
|
|
//var data = await analysisStrategy.ExecuteAsync<UnitDataDto<bool>>(tB3761);
|
|
|
|
|
|
var executor = _serviceProvider.GetRequiredService<AnalysisStrategyContext>();
|
2025-04-29 09:16:48 +08:00
|
|
|
|
await executor.ExecuteAsync<TB3761>(serverName, receivedMessage.Data);
|
|
|
|
|
|
return SubscribeAck.Success();
|
2025-04-27 15:44:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SubscribeAck.Fail();
|
|
|
|
|
|
}
|
2025-04-25 09:28:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|