2025-05-12 16:09:53 +08:00
|
|
|
|
using Apache.IoTDB;
|
|
|
|
|
|
using JiShe.CollectBus.Common.Consts;
|
|
|
|
|
|
using JiShe.CollectBus.Common.Enums;
|
|
|
|
|
|
using JiShe.CollectBus.Common.Extensions;
|
2025-05-12 14:02:22 +08:00
|
|
|
|
using JiShe.CollectBus.IotSystems.Ammeters;
|
2025-05-13 17:49:12 +08:00
|
|
|
|
using JiShe.CollectBus.IotSystems.Devices;
|
2025-05-12 14:02:22 +08:00
|
|
|
|
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
2025-04-30 17:25:35 +08:00
|
|
|
|
using JiShe.CollectBus.Protocol.Dto;
|
2025-04-25 14:23:06 +08:00
|
|
|
|
using JiShe.CollectBus.Protocol.Interfaces;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol3761;
|
2025-06-03 11:58:17 +08:00
|
|
|
|
using JiShe.ServicePro.Enums;
|
|
|
|
|
|
using JiShe.ServicePro.FreeRedisProvider;
|
2025-04-22 16:48:53 +08:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
2025-04-27 09:16:37 +08:00
|
|
|
|
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_00H
|
2025-04-22 16:48:53 +08:00
|
|
|
|
{
|
2025-04-22 23:45:08 +08:00
|
|
|
|
/// <summary>
|
2025-04-24 19:31:28 +08:00
|
|
|
|
/// 5.1.3.1 F1:全部确认:对收到报文中的全部数据单元标识进行确认
|
2025-04-22 23:45:08 +08:00
|
|
|
|
/// </summary>
|
2025-04-29 09:16:48 +08:00
|
|
|
|
public class AFN0_F1_Analysis: IAnalysisStrategy<TB3761>
|
2025-04-22 16:48:53 +08:00
|
|
|
|
{
|
|
|
|
|
|
private readonly ILogger<AFN0_F1_Analysis> _logger;
|
2025-05-12 14:02:22 +08:00
|
|
|
|
private readonly DataStorage _dataStorage;
|
2025-04-22 16:48:53 +08:00
|
|
|
|
|
2025-05-12 14:02:22 +08:00
|
|
|
|
public AFN0_F1_Analysis(ILogger<AFN0_F1_Analysis> logger, DataStorage dataStorage)
|
2025-04-22 16:48:53 +08:00
|
|
|
|
{
|
|
|
|
|
|
_logger = logger;
|
2025-05-12 14:02:22 +08:00
|
|
|
|
_dataStorage= dataStorage;
|
2025-04-22 16:48:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-12 14:02:22 +08:00
|
|
|
|
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
2025-04-22 16:48:53 +08:00
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2025-04-29 09:16:48 +08:00
|
|
|
|
ArgumentNullException.ThrowIfNull(input);
|
|
|
|
|
|
ArgumentNullException.ThrowIfNull(input.A.Code);
|
2025-05-12 14:02:22 +08:00
|
|
|
|
var data = new AnalysisBaseDto<bool?>()
|
|
|
|
|
|
{
|
|
|
|
|
|
FiledDesc = "全部确认",
|
2025-05-12 16:09:53 +08:00
|
|
|
|
DataValue = true,
|
|
|
|
|
|
ItemType= $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}"
|
2025-05-12 14:02:22 +08:00
|
|
|
|
};
|
|
|
|
|
|
// 查询电表信息
|
2025-06-03 11:58:17 +08:00
|
|
|
|
DeviceCacheInfo? deviceInfo = await _dataStorage.GetDeviceInfoAsync(input.A.Code);
|
2025-05-13 17:49:12 +08:00
|
|
|
|
if (deviceInfo != null)
|
2025-05-12 14:02:22 +08:00
|
|
|
|
{
|
2025-06-03 23:01:46 +08:00
|
|
|
|
data.ProjectId = deviceInfo.ProjectId;
|
2025-05-13 17:49:12 +08:00
|
|
|
|
data.DeviceId = deviceInfo.FocusId;
|
|
|
|
|
|
data.DatabaseBusiID = deviceInfo.DatabaseBusiID;
|
|
|
|
|
|
data.DeviceAddress = deviceInfo.FocusAddress;
|
2025-05-12 14:02:22 +08:00
|
|
|
|
data.DeviceType = MeterTypeEnum.Focus;
|
2025-05-13 17:49:12 +08:00
|
|
|
|
data.FocusId= deviceInfo.FocusId;
|
2025-05-12 14:02:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
UnitDataAnalysis<AnalysisBaseDto<bool?>> dto = new UnitDataAnalysis<AnalysisBaseDto<bool?>>
|
2025-04-22 16:48:53 +08:00
|
|
|
|
{
|
2025-04-29 09:16:48 +08:00
|
|
|
|
Code = input.A.Code,
|
|
|
|
|
|
AFN = input.AFN_FC.AFN,
|
|
|
|
|
|
Fn = input.DT.Fn,
|
|
|
|
|
|
Pn = input.DA.Pn,
|
2025-05-12 14:02:22 +08:00
|
|
|
|
Data = data,
|
|
|
|
|
|
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
2025-04-29 11:43:16 +08:00
|
|
|
|
MessageId = input.MessageId,
|
2025-04-30 17:25:35 +08:00
|
|
|
|
ReceivedTime = input.ReceivedTime,
|
|
|
|
|
|
DensityUnit = DensityUnit.None,
|
2025-05-12 16:09:53 +08:00
|
|
|
|
TimeDensity = -1,
|
|
|
|
|
|
DataType= IOTDBDataTypeConst.Log
|
2025-04-22 16:48:53 +08:00
|
|
|
|
};
|
2025-04-29 09:16:48 +08:00
|
|
|
|
result?.Invoke(dto);
|
2025-05-12 14:02:22 +08:00
|
|
|
|
await _dataStorage.SaveDataToIotDbAsync<bool?>(dto);
|
|
|
|
|
|
return await Task.FromResult(true);
|
2025-04-22 16:48:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
2025-04-29 09:16:48 +08:00
|
|
|
|
_logger.LogError(ex, $"00_1解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
2025-04-22 16:48:53 +08:00
|
|
|
|
}
|
2025-05-12 14:02:22 +08:00
|
|
|
|
return await Task.FromResult(false);
|
2025-04-22 16:48:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-04-24 00:34:00 +08:00
|
|
|
|
|
2025-04-22 16:48:53 +08:00
|
|
|
|
}
|