80 lines
3.1 KiB
C#
80 lines
3.1 KiB
C#
using JiShe.CollectBus.Common.Enums;
|
||
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.AFN_00H;
|
||
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 static FreeSql.Internal.GlobalFilter;
|
||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||
|
||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_02H
|
||
{
|
||
/// <summary>
|
||
/// 5.3.3.1 F1:登录
|
||
/// </summary>
|
||
public class AFN2_F1_Analysis : IAnalysisStrategy<TB3761>
|
||
{
|
||
private readonly ILogger<AFN2_F1_Analysis> _logger;
|
||
private readonly DataStorage _dataStorage;
|
||
public AFN2_F1_Analysis(ILogger<AFN2_F1_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);
|
||
var data = new AnalysisBaseDto<string>()
|
||
{
|
||
FiledDesc = "登录",
|
||
FiledName = "Type",
|
||
DataValue = "Login"
|
||
};
|
||
// 查询电表信息
|
||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(MeterTypeEnum.Focus.ToString(), "15");
|
||
if (ammeterInfo != null)
|
||
{
|
||
data.ProjectId = ammeterInfo.ProjectID;
|
||
data.DeviceId = ammeterInfo.FocusId;
|
||
data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||
data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||
data.DeviceType = MeterTypeEnum.Focus;
|
||
}
|
||
UnitDataAnalysis<AnalysisBaseDto<string>> dto = new UnitDataAnalysis<AnalysisBaseDto<string>>
|
||
{
|
||
Code = input.A.Code,
|
||
AFN = input.AFN_FC.AFN,
|
||
Fn = input.DT.Fn,
|
||
Pn = input.DA.Pn,
|
||
Data = data,
|
||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||
MessageId = input.MessageId,
|
||
ReceivedTime = input.ReceivedTime,
|
||
DensityUnit = DensityUnit.None,
|
||
TimeDensity = -1
|
||
};
|
||
result?.Invoke(dto);
|
||
await _dataStorage.SaveStatusToIotDbAsync<string>(dto);
|
||
return await Task.FromResult(true);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
_logger.LogError(ex, $"02_1解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||
}
|
||
return await Task.FromResult(false);
|
||
}
|
||
|
||
}
|
||
}
|