Compare commits

..

No commits in common. "63a6ace884c17ecc4007bfa7ff0f73b9625989f9" and "d87f7a2c414436e18bc32fbd5c0876981524640c" have entirely different histories.

5 changed files with 17 additions and 37 deletions

View File

@ -10,7 +10,6 @@ using JiShe.CollectBus.Protocol3761;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0EH namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0EH
{ {
@ -49,7 +48,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0EH
if (list.Count > 0) if (list.Count > 0)
{ {
// 查询设备信息 // 查询设备信息
DeviceInfo? deviceInfo = await _dataStorage.GetDeviceInfoAsync(input.A.Code); DeviceInfo? deviceInfo = await _dataStorage.GetDeviceInfoAsync(input.A.Code, input.DA.Pn);
if (deviceInfo != null) if (deviceInfo != null)
{ {
list.ForEach(item => list.ForEach(item =>
@ -58,7 +57,6 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0EH
item.DeviceId = deviceInfo.MeterId; item.DeviceId = deviceInfo.MeterId;
item.DatabaseBusiID = deviceInfo.DatabaseBusiID; item.DatabaseBusiID = deviceInfo.DatabaseBusiID;
item.DeviceAddress = deviceInfo.MeterAddress; item.DeviceAddress = deviceInfo.MeterAddress;
item.DeviceType = MeterTypeEnum.Focus;
item.FocusId = deviceInfo.FocusId; item.FocusId = deviceInfo.FocusId;
}); });
} }

View File

@ -1,5 +1,4 @@
using DeviceDetectorNET.Parser.Device; using GatherService.WattMeter.AnalysisData.AFN_10H;
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.Enums;
using JiShe.CollectBus.Common.Extensions; using JiShe.CollectBus.Common.Extensions;
@ -47,7 +46,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H
AnalysisBaseDto<decimal?> data = GenerateFinalResult(datas); AnalysisBaseDto<decimal?> data = GenerateFinalResult(datas);
// 查询设备信息 // 查询设备信息
DeviceInfo? deviceInfo = await _dataStorage.GetDeviceInfoAsync(input.A.Code, input.DA.Pn, datas[1]); DeviceInfo? deviceInfo = await _dataStorage.GetDeviceInfoAsync(input.A.Code, input.DA.Pn);
if (deviceInfo != null) if (deviceInfo != null)
{ {
data.ProjectId = deviceInfo.ProjectID; data.ProjectId = deviceInfo.ProjectID;
@ -88,8 +87,8 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H
private AnalysisBaseDto<decimal?> GenerateFinalResult(List<string> data) private AnalysisBaseDto<decimal?> GenerateFinalResult(List<string> data)
{ {
AnalysisBaseDto<decimal?> meter = new AnalysisBaseDto<decimal?>(); AnalysisBaseDto<decimal?> meter = new AnalysisBaseDto<decimal?>();
meter.DeviceType = MeterTypeEnum.Ammeter;
var errorCode = data[4].CheckErrorCode(); var errorCode = data[7].CheckErrorCode();
if (errorCode != null) if (errorCode != null)
{ {
meter.ValidData = false; meter.ValidData = false;
@ -97,7 +96,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H
} }
else else
{ {
if(decimal.TryParse(data[4], out decimal value)) if(decimal.TryParse(data[7], out decimal value))
meter.DataValue = value; meter.DataValue = value;
} }
@ -134,7 +133,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H
string dataMark = string.Join("",dataField.GetRange(0, 4).ReduceHex33(true)); string dataMark = string.Join("",dataField.GetRange(0, 4).ReduceHex33(true));
values.Add(dataMark);//数据标识 values.Add(dataMark);//数据标识
var readValue = dataField.GetRange(4, len - 4).ReduceHex33(true);//值 var readValue = dataField.GetRange(4, len - 4).ReduceHex33(true);//值
await _analysisStrategyContext.ExecuteAsync<List<string>>($"Appendix_{dataMark}", readValue, (value) => await _analysisStrategyContext.ExecuteAsync<List<string>>($" Appendix_{dataMark}", readValue, (value) =>
{ {
values.Add(value.ToString()); values.Add(value.ToString());
}); });

View File

@ -81,11 +81,11 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
/// <param name="meterType"></param> /// <param name="meterType"></param>
/// <param name="timeDensity"></param> /// <param name="timeDensity"></param>
/// <returns></returns> /// <returns></returns>
public async Task<DeviceInfo?> GetDeviceInfoAsync(string code,int pn=1,string meterAddress=null) public async Task<DeviceInfo?> GetDeviceInfoAsync(string code,int pn=1)
{ {
string redisCacheDeviceInfoHashKey = $"{string.Format(RedisConst.CacheDeviceInfoHashKey, _applicationOptions.SystemType, _applicationOptions.ServerTagName)}"; string redisCacheDeviceInfoHashKey = $"{string.Format(RedisConst.CacheDeviceInfoHashKey, _applicationOptions.SystemType, _applicationOptions.ServerTagName)}";
string deviceKey= $"{code}:{pn}"; string deviceKey= $"{code}:{pn}";
var deviceInfo= await _imemoryCache.GetOrCreateAsync(deviceKey, async entry => return await _imemoryCache.GetOrCreateAsync(deviceKey, async entry =>
{ {
List<DeviceInfo> devices= await Instance.HGetAsync<List<DeviceInfo>>(redisCacheDeviceInfoHashKey, code) ?? new List<DeviceInfo>(); List<DeviceInfo> devices= await Instance.HGetAsync<List<DeviceInfo>>(redisCacheDeviceInfoHashKey, code) ?? new List<DeviceInfo>();
var data = devices.Where(s => s.MeteringCode == pn).FirstOrDefault(); var data = devices.Where(s => s.MeteringCode == pn).FirstOrDefault();
@ -95,22 +95,6 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
entry.SetSlidingExpiration(TimeSpan.FromSeconds(5)); entry.SetSlidingExpiration(TimeSpan.FromSeconds(5));
return data ?? default; return data ?? default;
}); });
if (deviceInfo == null && !string.IsNullOrWhiteSpace(meterAddress))
{
// TODO:透明转发回来的pn为0情况
string deviceAddressKey = $"{code}:{meterAddress}";
deviceInfo = await _imemoryCache.GetOrCreateAsync(deviceAddressKey, async entry =>
{
List<DeviceInfo> devices = await Instance.HGetAsync<List<DeviceInfo>>(redisCacheDeviceInfoHashKey, code) ?? new List<DeviceInfo>();
var data = devices.Where(s => s.MeterAddress == meterAddress).FirstOrDefault();
if (data != null)
entry.SetSlidingExpiration(TimeSpan.FromMinutes(5));
else
entry.SetSlidingExpiration(TimeSpan.FromSeconds(5));
return data ?? default;
});
}
return deviceInfo;
} }
/// <summary> /// <summary>

View File

@ -19,19 +19,18 @@ namespace JiShe.CollectBus.Protocol.T37612012.Appendix
{ {
try try
{ {
if (data.Count == 2) if (data.Count != 2)
{ return null;
var value = string.Join(".", data); var value = string.Join(".", data);
//电网频率 var values= new List<string>() { "电网频率", "10_97", "1", value };
result?.Invoke(value); result?.Invoke(values);
return Task.FromResult(true); return Task.FromResult(true);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, $"Appendix_02800002解析失败:{ex.Message}"); _logger.LogError(ex, $"Appendix_02800002解析失败:{ex.Message}");
return Task.FromResult(false);
} }
return Task.FromResult(false);
} }
} }
} }

View File

@ -141,7 +141,7 @@
} }
}, },
"ServerApplicationOptions": { "ServerApplicationOptions": {
"ServerTagName": "JiSheCollectBus99", "ServerTagName": "JiSheCollectBus8",
"SystemType": "Energy", "SystemType": "Energy",
"FirstCollectionTime": "2025-04-28 15:07:00", "FirstCollectionTime": "2025-04-28 15:07:00",
"AutomaticVerificationTime": "16:07:00", "AutomaticVerificationTime": "16:07:00",