合并
This commit is contained in:
commit
f1f5e82171
@ -226,7 +226,7 @@ namespace JiShe.CollectBus.IncrementalGenerator
|
||||
code.AppendLine($" public string EntityName {{get;}} = \"{classSymbol.Name}\";");
|
||||
// 添加 EntityType 属性
|
||||
code.AppendLine($" public EntityTypeEnum? EntityType {{ get; }} = {entityTypeValue};");
|
||||
|
||||
|
||||
foreach (var prop in propList)
|
||||
{
|
||||
// 安全类型转换
|
||||
@ -531,7 +531,14 @@ namespace JiShe.CollectBus.IncrementalGenerator
|
||||
var entityType = prop.ContainingType.ToDisplayString();//entity 实体类型名称
|
||||
var propType = prop.Type;//实体属性的类型
|
||||
var propTypeName = propType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
|
||||
var declaredTypeName = propType.Name; // 直接获取类型名称(如 "Int32")
|
||||
// var declaredTypeName = propType.Name; // 直接获取类型名称(如 "Int32")
|
||||
// 处理可空类型,获取底层具体类型名称
|
||||
var declaredTypeName = propType switch
|
||||
{
|
||||
INamedTypeSymbol { OriginalDefinition.SpecialType: SpecialType.System_Nullable_T } nullableType =>
|
||||
nullableType.TypeArguments[0].Name, // 提取如 "Int32"
|
||||
_ => propType.Name
|
||||
};
|
||||
|
||||
// 处理主属性
|
||||
var propAttributes = prop.GetAttributes()
|
||||
@ -573,7 +580,7 @@ namespace JiShe.CollectBus.IncrementalGenerator
|
||||
$"new EntityMemberInfo(" +
|
||||
$"\"{prop.Name}.{elementName}\", " +
|
||||
$"typeof({elementType}), " +
|
||||
$"\"{elementDeclaredName}\", " +
|
||||
$"typeof({elementType}).Name, " +//$"\"{elementDeclaredName}\", " +
|
||||
$"(e) => Get{prop.Name}_{elementName}(({entityType})e), " +
|
||||
$"(e, v) => Set{prop.Name}_{elementName}(({entityType})e, ({elementType})v))");
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using JiShe.CollectBus.Common.Attributes;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.IoTDB.Attributes;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
|
||||
namespace JiShe.CollectBus.IoTDB.Model
|
||||
{
|
||||
@ -43,5 +44,27 @@ namespace JiShe.CollectBus.IoTDB.Model
|
||||
/// 时标,也就是业务时间戳,单位毫秒,必须通过DateTimeOffset获取
|
||||
/// </summary>
|
||||
public long Timestamps { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||
|
||||
/// <summary>
|
||||
/// 设备路径
|
||||
/// </summary>
|
||||
public virtual string DevicePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return $"root.{SystemName.ToLower()}.`{ProjectId}`.`{DeviceType}`.{DataType}.`{DeviceId}`";
|
||||
}
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
DevicePath = $"root.{SystemName.ToLower()}.`{ProjectId}`.`{DeviceType}`.{DataType}.`{DeviceId}`";
|
||||
}
|
||||
else
|
||||
{
|
||||
DevicePath = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,8 +6,18 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
/// <summary>
|
||||
/// 设备元数据
|
||||
/// </summary>
|
||||
public class DeviceMetadata
|
||||
public sealed class DeviceMetadata
|
||||
{
|
||||
/// <summary>
|
||||
/// 实体类名称
|
||||
/// </summary>
|
||||
public string EntityName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备表名或树路径,如果实体没有添加TableNameOrTreePath,此处为空
|
||||
/// </summary>
|
||||
public string TableNameOrTreePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实体类型枚举
|
||||
/// </summary>
|
||||
@ -31,6 +41,57 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
/// <summary>
|
||||
/// 值类型集合,用于构建Table的值类型,也就是dataTypes参数
|
||||
/// </summary>
|
||||
public List<TSDataType> DataTypes { get; } = new();
|
||||
public List<TSDataType> DataTypes { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 列处理信息集合
|
||||
/// </summary>
|
||||
public List<ColumnProcessor> Processors { get; } = new List<ColumnProcessor>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列处理信息结构
|
||||
/// </summary>
|
||||
public struct ColumnProcessor
|
||||
{
|
||||
/// <summary>
|
||||
/// 列名
|
||||
/// </summary>
|
||||
public string ColumnName;
|
||||
|
||||
/// <summary>
|
||||
/// 数据类型
|
||||
/// </summary>
|
||||
public TSDataType TSDataType { get; set;}
|
||||
|
||||
/// <summary>
|
||||
/// 值获取委托(参数:实体对象)
|
||||
/// </summary>
|
||||
public Func<object, object> ValueGetter;
|
||||
|
||||
/// <summary>
|
||||
/// 值设置委托(参数:实体对象,新值)
|
||||
/// </summary>
|
||||
public Action<object, object> ValueSetter;
|
||||
|
||||
/// <summary>
|
||||
/// 类型转换委托
|
||||
/// </summary>
|
||||
public Func<object, object> GetConverter;
|
||||
|
||||
/// <summary>
|
||||
/// 类型转换委托
|
||||
/// </summary>
|
||||
public Func<object, object> SetConverter;
|
||||
|
||||
/// <summary>
|
||||
/// 是否单测点
|
||||
/// </summary>
|
||||
public bool IsSingleMeasuring;
|
||||
|
||||
/// <summary>
|
||||
/// 单测点名称委托
|
||||
/// </summary>
|
||||
public Func<object, object> SingleMeasuringNameGetter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,10 @@ using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using JiShe.CollectBus.Analyzers.Shared;
|
||||
using JiShe.CollectBus.IoTDB.Exceptions;
|
||||
using System.Diagnostics.Metrics;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace JiShe.CollectBus.IoTDB.Provider
|
||||
{
|
||||
@ -68,8 +72,13 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
var metadata = await GetMetadata<T>();
|
||||
|
||||
var tablet = BuildTablet(new[] { entity }, metadata);
|
||||
if (tablet == null || tablet.Count <= 0)
|
||||
{
|
||||
_logger.LogError($"{nameof(InsertAsync)} IoTDB插入{typeof(T).Name}的数据时 tablet 为null");
|
||||
return;
|
||||
}
|
||||
|
||||
await CurrentSession.InsertAsync(tablet);
|
||||
await CurrentSession.InsertAsync(tablet.First());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -95,7 +104,15 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
foreach (var batch in batches)
|
||||
{
|
||||
var tablet = BuildTablet(batch, metadata);
|
||||
await CurrentSession.InsertAsync(tablet);
|
||||
if (tablet == null || tablet.Count <= 0)
|
||||
{
|
||||
_logger.LogError($"{nameof(InsertAsync)} IoTDB插入{typeof(T).Name}的数据时 tablet 为null");
|
||||
return;
|
||||
}
|
||||
foreach (var item in tablet)
|
||||
{
|
||||
await CurrentSession.InsertAsync(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -117,13 +134,21 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
try
|
||||
{
|
||||
|
||||
var batchSize = 1000;
|
||||
var batchSize = 2000;
|
||||
var batches = entities.Chunk(batchSize);
|
||||
|
||||
foreach (var batch in batches)
|
||||
{
|
||||
var tablet = BuildTablet(batch, deviceMetadata);
|
||||
await CurrentSession.InsertAsync(tablet);
|
||||
if (tablet == null || tablet.Count <= 0)
|
||||
{
|
||||
_logger.LogError($"{nameof(InsertAsync)} IoTDB插入{typeof(T).Name}的数据时 tablet 为null");
|
||||
return;
|
||||
}
|
||||
foreach (var item in tablet)
|
||||
{
|
||||
await CurrentSession.InsertAsync(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -181,22 +206,54 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
var accessor = SourceEntityAccessorFactory.GetAccessor<T>();
|
||||
|
||||
var columns = CollectColumnMetadata<T>(accessor);
|
||||
var metadata = BuildDeviceMetadata<T>(columns);
|
||||
var tmpMetadata = BuildDeviceMetadata<T>(columns, accessor);
|
||||
|
||||
string tableNameOrTreePath = string.Empty;
|
||||
var tableNameOrTreePathAttribute = typeof(T).GetCustomAttribute<TableNameOrTreePathAttribute>();
|
||||
if (tableNameOrTreePathAttribute != null)
|
||||
{
|
||||
tableNameOrTreePath = tableNameOrTreePathAttribute.TableNameOrTreePath;
|
||||
}
|
||||
tmpMetadata.EntityName = accessor.EntityName;
|
||||
tmpMetadata.EntityType = accessor.EntityType;
|
||||
tmpMetadata.TableNameOrTreePath = tableNameOrTreePath;
|
||||
|
||||
var metaData = MetadataCache.AddOrUpdate(
|
||||
typeof(T),
|
||||
addValueFactory: t => metadata, // 如果键不存在,用此值添加
|
||||
addValueFactory: t => tmpMetadata, // 如果键不存在,用此值添加
|
||||
updateValueFactory: (t, existingValue) =>
|
||||
{
|
||||
var columns = CollectColumnMetadata(accessor);
|
||||
var metadata = BuildDeviceMetadata<T>(columns);
|
||||
var metadata = BuildDeviceMetadata(columns, accessor);
|
||||
|
||||
//对现有值 existingValue 进行修改,返回新值
|
||||
string tableNameOrTreePath = string.Empty;
|
||||
var tableNameOrTreePathAttribute = typeof(T).GetCustomAttribute<TableNameOrTreePathAttribute>();
|
||||
if (tableNameOrTreePathAttribute != null)
|
||||
{
|
||||
tableNameOrTreePath = tableNameOrTreePathAttribute.TableNameOrTreePath;
|
||||
}
|
||||
existingValue.ColumnNames = metadata.ColumnNames;
|
||||
existingValue.DataTypes = metadata.DataTypes;
|
||||
return existingValue;
|
||||
}
|
||||
);
|
||||
|
||||
metadata.EntityType = accessor.EntityType;
|
||||
//var metaData = MetadataCache.GetOrAdd(typeof(T), type =>
|
||||
//{
|
||||
// var columns = CollectColumnMetadata(accessor);
|
||||
// var metadata = BuildDeviceMetadata(columns, accessor);
|
||||
// string tableNameOrTreePath = string.Empty;
|
||||
// var tableNameOrTreePathAttribute = typeof(T).GetCustomAttribute<TableNameOrTreePathAttribute>();
|
||||
// if (tableNameOrTreePathAttribute != null)
|
||||
// {
|
||||
// tableNameOrTreePath = tableNameOrTreePathAttribute.TableNameOrTreePath;
|
||||
// }
|
||||
// metadata.EntityName = accessor.EntityName;
|
||||
// metadata.EntityType = accessor.EntityType;
|
||||
// metadata.TableNameOrTreePath = tableNameOrTreePath;
|
||||
// return metadata;
|
||||
//});
|
||||
|
||||
return await Task.FromResult(metaData);
|
||||
}
|
||||
@ -217,7 +274,6 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
var sessionDataSet = await CurrentSession.ExecuteQueryStatementAsync(query);
|
||||
|
||||
|
||||
_logger.LogWarning($"{nameof(QueryAsync)} 主题的任务 {options.TableNameOrTreePath} 路径批次{options.PageIndex}任务数据读取完成,共消耗{stopwatch2.ElapsedMilliseconds}毫秒。");
|
||||
var result = new BusPagedResult<T>
|
||||
{
|
||||
TotalCount = await GetTotalCount<T>(options),
|
||||
@ -227,7 +283,7 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
|
||||
};
|
||||
stopwatch2.Stop();
|
||||
_logger.LogWarning($"{nameof(QueryAsync)} 主题的任务 {options.TableNameOrTreePath} 路径批次{options.PageIndex}任务数据读取完成,共消耗{stopwatch2.ElapsedMilliseconds}毫秒。");
|
||||
|
||||
//int totalPageCount = (int)Math.Ceiling((double)result.TotalCount / options.PageSize);
|
||||
|
||||
if (result.Items.Count() < result.PageSize)
|
||||
@ -251,338 +307,110 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 构建Tablet
|
||||
///// </summary>
|
||||
///// <typeparam name="T"></typeparam>
|
||||
///// <param name="entities">表实体</param>
|
||||
///// <param name="metadata">设备元数据</param></param>
|
||||
///// <returns></returns>
|
||||
//private Tablet BuildTablet<T>(IEnumerable<T> entities, DeviceMetadata metadata) where T : IoTEntity
|
||||
//{
|
||||
// var timestamps = new List<long>();
|
||||
// var values = new List<List<object>>();
|
||||
// var devicePaths = new HashSet<string>();
|
||||
// List<string> tempColumnNames = new List<string>();
|
||||
// tempColumnNames.AddRange(metadata.ColumnNames);
|
||||
|
||||
// var accessor = SourceEntityAccessorFactory.GetAccessor<T>();
|
||||
|
||||
// var memberCache = new Dictionary<string, EntityMemberInfo>(); // 缓存优化查询
|
||||
// // 预构建成员缓存(Key: NameOrPath)
|
||||
// foreach (var member in accessor.MemberList)
|
||||
// {
|
||||
// memberCache[member.NameOrPath] = member;
|
||||
// }
|
||||
|
||||
// if (accessor.EntityType == null || metadata.EntityType == null)
|
||||
// {
|
||||
// throw new ArgumentException($"{nameof(BuildTablet)} 构建存储结构{nameof(Tablet)}时 {nameof(T)}的EntityType 没有指定,属于异常情况,-101");
|
||||
// }
|
||||
|
||||
// if (metadata.EntityType != accessor.EntityType)
|
||||
// {
|
||||
// throw new ArgumentException($"{nameof(BuildTablet)} 构建存储结构{nameof(Tablet)}时 {nameof(T)}的EntityType 和{nameof(DeviceMetadata)}的 EntityType 不一致,属于异常情况,-102");
|
||||
// }
|
||||
|
||||
// if (metadata.EntityType == EntityTypeEnum.TreeModel && _runtimeContext.UseTableSessionPool == true)
|
||||
// {
|
||||
// throw new ArgumentException($"{nameof(BuildTablet)} 构建存储结构{nameof(Tablet)}时 tree模型不能使用table模型Session连接,属于异常情况,-103");
|
||||
// }
|
||||
// else if (metadata.EntityType == EntityTypeEnum.TableModel && _runtimeContext.UseTableSessionPool == false)
|
||||
// {
|
||||
// throw new ArgumentException($"{nameof(BuildTablet)} 构建存储结构{nameof(Tablet)}时 table模型不能使用tree模型Session连接,属于异常情况,-104");
|
||||
// }
|
||||
|
||||
// string tableNameOrTreePath = string.Empty;
|
||||
// var tableNameOrTreePathAttribute = typeof(T).GetCustomAttribute<TableNameOrTreePathAttribute>();
|
||||
// if (tableNameOrTreePathAttribute != null)
|
||||
// {
|
||||
// tableNameOrTreePath = tableNameOrTreePathAttribute.TableNameOrTreePath;
|
||||
// }
|
||||
|
||||
// foreach (var entity in entities)
|
||||
// {
|
||||
// timestamps.Add(entity.Timestamps);
|
||||
// var rowValues = new List<object>();
|
||||
|
||||
// foreach (var measurement in metadata.ColumnNames)
|
||||
// {
|
||||
// if (!memberCache.TryGetValue(measurement, out var member))
|
||||
// {
|
||||
// throw new ArgumentException($"{nameof(BuildTablet)} 构建存储结构时{accessor.EntityName}没有找到{measurement}对应的member信息,-105");
|
||||
// }
|
||||
|
||||
// var value = member.GetValue(entity);
|
||||
|
||||
// // 特性查询优化
|
||||
// var attributes = member.CustomAttributes ?? Enumerable.Empty<Attribute>();
|
||||
// var singleMeasuringAttr = attributes.OfType<SingleMeasuringAttribute>().FirstOrDefault();
|
||||
// if (singleMeasuringAttr != null)//如果是单侧点
|
||||
// {
|
||||
|
||||
// var tupleItem1Key = $"{member.NameOrPath}.Item1";
|
||||
// if (!memberCache.TryGetValue(tupleItem1Key, out var tuple1Member))
|
||||
// {
|
||||
// throw new ArgumentException($"{nameof(BuildTablet)} 构建存储结构时{accessor.EntityName} 没有找到{measurement}对应的member Item1 信息,-106");
|
||||
// }
|
||||
// int indexOf = metadata.ColumnNames.IndexOf(measurement);
|
||||
// tempColumnNames[indexOf] = (string)tuple1Member.GetValue(entity);
|
||||
|
||||
// var tupleItem2Key = $"{member.NameOrPath}.Item2";
|
||||
// if (!memberCache.TryGetValue(tupleItem2Key, out var tuple2Member))
|
||||
// {
|
||||
// throw new ArgumentException($"{nameof(BuildTablet)} 构建存储结构时{accessor.EntityName} 没有找到{measurement}对应的member Item2 信息,-107");
|
||||
// }
|
||||
|
||||
// value = tuple2Member.GetValue(entity);
|
||||
// }
|
||||
|
||||
// if (value != null)
|
||||
// {
|
||||
// var tempValue = member.DeclaredTypeName.ToUpper() switch
|
||||
// {
|
||||
// "DATETIME" => Convert.ToDateTime(value).GetDateTimeOffset().ToUnixTimeNanoseconds(),
|
||||
// _ => value
|
||||
// };
|
||||
|
||||
// rowValues.Add(tempValue);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// rowValues.Add(value);
|
||||
// }
|
||||
// }
|
||||
|
||||
// values.Add(rowValues);
|
||||
|
||||
// //如果指定了路径
|
||||
// if (!string.IsNullOrWhiteSpace(tableNameOrTreePath))
|
||||
// {
|
||||
// devicePaths.Add(tableNameOrTreePath);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (!_runtimeContext.UseTableSessionPool)//树模型
|
||||
// {
|
||||
// devicePaths.Add(DevicePathBuilder.GetDevicePath(entity));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// devicePaths.Add(DevicePathBuilder.GetTableName<T>());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (devicePaths.Count > 1)
|
||||
// {
|
||||
// throw new Exception($"{nameof(BuildTablet)} 构建Tablet《{typeof(T).Name}》时,批量插入的设备路径不一致。");
|
||||
// }
|
||||
|
||||
// return _runtimeContext.UseTableSessionPool
|
||||
// ? BuildTableSessionTablet(metadata, devicePaths.First(), tempColumnNames, values, timestamps)
|
||||
// : BuildSessionTablet(metadata, devicePaths.First(), tempColumnNames,values, timestamps);
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 构建Tablet
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="entities">表实体集合</param>
|
||||
/// <param name="entities">表实体</param>
|
||||
/// <param name="metadata">设备元数据</param></param>
|
||||
/// <returns></returns>
|
||||
private Tablet BuildTablet<T>(IEnumerable<T> entities, DeviceMetadata metadata) where T : IoTEntity
|
||||
private List<Tablet> BuildTablet<T>(IEnumerable<T> entities, DeviceMetadata metadata) where T : IoTEntity
|
||||
{
|
||||
// 前置校验
|
||||
ValidateMetadataAndAccessor<T>(metadata, out var accessor);
|
||||
|
||||
// 初始化数据结构
|
||||
var (timestamps, values, devicePaths) = (new List<long>(), new List<List<object>>(), new HashSet<string>());
|
||||
var tempColumnNames = new List<string>(metadata.ColumnNames);
|
||||
var memberCache = BuildMemberCache(accessor);
|
||||
var tableNameOrTreePath = GetTableNameOrTreePath<T>();
|
||||
|
||||
// 处理每个实体
|
||||
foreach (var entity in entities)
|
||||
var entitiyList = entities.ToList();
|
||||
if (entitiyList == null || entitiyList.Count <= 0)
|
||||
{
|
||||
ProcessEntity(entity, accessor, metadata, memberCache, tempColumnNames, timestamps, values);
|
||||
UpdateDevicePaths(entity, tableNameOrTreePath, devicePaths);
|
||||
return null;
|
||||
}
|
||||
|
||||
//var accessor = SourceEntityAccessorFactory.GetAccessor<T>();
|
||||
|
||||
//var memberCache = BuildMemberCache(accessor);
|
||||
|
||||
if (metadata.EntityType == null)
|
||||
{
|
||||
throw new ArgumentException($"{nameof(BuildTablet)} 构建存储结构{nameof(Tablet)}时 {nameof(T)}的EntityType 没有指定,属于异常情况,-101");
|
||||
}
|
||||
|
||||
if (metadata.EntityType == EntityTypeEnum.Other)
|
||||
{
|
||||
throw new ArgumentException($"{nameof(BuildTablet)} 构建存储结构{nameof(Tablet)}时 {nameof(T)}的EntityType 不属于IoTDB数据模型实体,属于异常情况,-102");
|
||||
}
|
||||
|
||||
if (metadata.EntityType == EntityTypeEnum.TreeModel && _runtimeContext.UseTableSessionPool == true)
|
||||
{
|
||||
throw new ArgumentException($"{nameof(BuildTablet)} 构建存储结构{nameof(Tablet)}时 tree模型不能使用table模型Session连接,属于异常情况,-103");
|
||||
}
|
||||
else if (metadata.EntityType == EntityTypeEnum.TableModel && _runtimeContext.UseTableSessionPool == false)
|
||||
{
|
||||
throw new ArgumentException($"{nameof(BuildTablet)} 构建存储结构{nameof(Tablet)}时 table模型不能使用tree模型Session连接,属于异常情况,-104");
|
||||
}
|
||||
string tableNameOrTreePath = string.Empty;
|
||||
if (_runtimeContext.UseTableSessionPool)//表模型
|
||||
{
|
||||
//如果指定了路径
|
||||
if (!string.IsNullOrWhiteSpace(metadata.TableNameOrTreePath))
|
||||
{
|
||||
tableNameOrTreePath = metadata.TableNameOrTreePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
tableNameOrTreePath = DevicePathBuilder.GetTableName<T>();
|
||||
}
|
||||
|
||||
return new List<Tablet>() { BuildTablet(entitiyList, metadata, tableNameOrTreePath) };
|
||||
}
|
||||
else
|
||||
{
|
||||
//树模型的时候,实体的设备Id可能会不同,因此需要根据不同路径进行存储。
|
||||
var tabletList = new List<Tablet>();
|
||||
var groupEntities = entitiyList.GroupBy(d => d.DevicePath).ToList();
|
||||
foreach (var group in groupEntities)
|
||||
{
|
||||
tabletList.Add(BuildTablet(group.ToList(), metadata, group.Key));
|
||||
}
|
||||
|
||||
return tabletList;
|
||||
}
|
||||
}
|
||||
|
||||
private Tablet BuildTablet<T>(List<T> entities, DeviceMetadata metadata, string tableNameOrTreePath) where T : IoTEntity
|
||||
{
|
||||
// 预分配内存结构
|
||||
var rowCount = entities.Count;
|
||||
var timestamps = new long[rowCount];
|
||||
var values = new object[rowCount][];
|
||||
for (var i = 0; i < values.Length; i++)
|
||||
{
|
||||
values[i] = new object[metadata.ColumnNames.Count];
|
||||
}
|
||||
|
||||
List<string> tempColumnNames = new List<string>();
|
||||
tempColumnNames.AddRange(metadata.ColumnNames);
|
||||
|
||||
// 顺序处理数据(保证线程安全)
|
||||
for (var row = 0; row < rowCount; row++)
|
||||
{
|
||||
var entity = entities[row];
|
||||
timestamps[row] = entity.Timestamps;
|
||||
|
||||
for (int i = 0; i < metadata.ColumnNames.Count; i++)
|
||||
{
|
||||
var processor = metadata.Processors[i];
|
||||
if (processor.IsSingleMeasuring)
|
||||
{
|
||||
tempColumnNames[i] = (string)processor.SingleMeasuringNameGetter(entity);
|
||||
}
|
||||
|
||||
// 获取并转换值
|
||||
values[row][i] = processor.ValueGetter(entity);
|
||||
}
|
||||
}
|
||||
|
||||
// 后置校验与返回
|
||||
ValidateDevicePaths(devicePaths);
|
||||
// return CreateFinalTablet(metadata, devicePaths.First(), tempColumnNames, values, timestamps);
|
||||
return _runtimeContext.UseTableSessionPool
|
||||
? BuildTableSessionTablet(metadata, devicePaths.First(), tempColumnNames, values, timestamps)
|
||||
: BuildSessionTablet(metadata, devicePaths.First(), tempColumnNames, values, timestamps);
|
||||
? BuildTableSessionTablet(metadata, tableNameOrTreePath, tempColumnNames, values.Select(d => d.ToList()).ToList(), timestamps.ToList())
|
||||
: BuildSessionTablet(metadata, tableNameOrTreePath, tempColumnNames, values.Select(d => d.ToList()).ToList(), timestamps.ToList());
|
||||
}
|
||||
|
||||
private void ValidateMetadataAndAccessor<T>(DeviceMetadata metadata, out ISourceEntityAccessor<T> accessor) where T : IoTEntity
|
||||
{
|
||||
accessor = SourceEntityAccessorFactory.GetAccessor<T>();
|
||||
|
||||
if (accessor.EntityType == null || metadata.EntityType == null)
|
||||
{
|
||||
throw new IoTException($"{nameof(BuildTablet)} 构建IoTDB数据结构时,EntityType未指定", -101);
|
||||
}
|
||||
|
||||
if (metadata.EntityType != accessor.EntityType)
|
||||
{
|
||||
throw new IoTException($"{nameof(BuildTablet)} 构建IoTDB数据结构时,EntityType不一致", -102);
|
||||
}
|
||||
|
||||
bool isTableModel = accessor.EntityType == EntityTypeEnum.TableModel;
|
||||
if (_runtimeContext.UseTableSessionPool != isTableModel)
|
||||
{
|
||||
throw new IoTException($"{nameof(BuildTablet)} 构建IoTDB数据结构时,Session类型不匹配: 预期{(isTableModel ? "Table" : "Tree")}模型", isTableModel ? -104 : -103);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理实体并获取值
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="accessor"></param>
|
||||
/// <param name="metadata"></param>
|
||||
/// <param name="memberCache"></param>
|
||||
/// <param name="tempColumnNames"></param>
|
||||
/// <param name="timestamps"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <exception cref="IoTException"></exception>
|
||||
private void ProcessEntity<T>(
|
||||
T entity,
|
||||
ISourceEntityAccessor<T> accessor,
|
||||
DeviceMetadata metadata,
|
||||
Dictionary<string, EntityMemberInfo> memberCache,
|
||||
List<string> tempColumnNames,
|
||||
List<long> timestamps,
|
||||
List<List<object>> values) where T : IoTEntity
|
||||
{
|
||||
timestamps.Add(entity.Timestamps);
|
||||
var rowValues = new object[metadata.ColumnNames.Count];
|
||||
|
||||
Parallel.ForEach(metadata.ColumnNames, (measurement, state, index) =>
|
||||
{
|
||||
if (!memberCache.TryGetValue(measurement, out var member))
|
||||
{
|
||||
throw new IoTException($"{nameof(BuildTablet)} 构建IoTDB数据结构时,找不到成员: {measurement}", -105);
|
||||
}
|
||||
|
||||
object value = ResolveMemberValue(entity, member, memberCache, tempColumnNames, (int)index);
|
||||
rowValues[index] = ConvertValueByType(member, value);
|
||||
});
|
||||
|
||||
values.Add(rowValues.ToList());
|
||||
}
|
||||
|
||||
private object ResolveMemberValue<T>(
|
||||
T entity,
|
||||
EntityMemberInfo member,
|
||||
Dictionary<string, EntityMemberInfo> memberCache,
|
||||
List<string> tempColumnNames,
|
||||
int columnIndex) where T : IoTEntity
|
||||
{
|
||||
// 单测点逻辑
|
||||
if (member.CustomAttributes?.OfType<SingleMeasuringAttribute>().FirstOrDefault() is { } attr)
|
||||
{
|
||||
var tuple1Key = $"{member.NameOrPath}.Item1";
|
||||
var tuple2Key = $"{member.NameOrPath}.Item2";
|
||||
|
||||
if (!memberCache.TryGetValue(tuple1Key, out var tuple1) || !memberCache.TryGetValue(tuple2Key, out var tuple2))
|
||||
{
|
||||
throw new IoTException($"{nameof(BuildTablet)} 构建IoTDB数据结构时,单侧点元组成员缺失", -106);
|
||||
}
|
||||
|
||||
tempColumnNames[columnIndex] = (string)tuple1.GetValue(entity);
|
||||
return tuple2.GetValue(entity);
|
||||
}
|
||||
return member.GetValue(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置实体的成员值
|
||||
/// </summary>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
private object ConvertValueByType(EntityMemberInfo member, object value)
|
||||
{
|
||||
return member.DeclaredTypeName switch
|
||||
{
|
||||
"DATETIME" => Convert.ToDateTime(value).GetDateTimeOffset().ToUnixTimeNanoseconds(),
|
||||
_ => value
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理设备路径
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="tableNameOrTreePath"></param>
|
||||
/// <param name="devicePaths"></param>
|
||||
private void UpdateDevicePaths<T>(
|
||||
T entity,
|
||||
string tableNameOrTreePath,
|
||||
HashSet<string> devicePaths) where T : IoTEntity
|
||||
{
|
||||
if (!string.IsNullOrEmpty(tableNameOrTreePath))
|
||||
{
|
||||
devicePaths.Add(tableNameOrTreePath);
|
||||
return;
|
||||
}
|
||||
|
||||
var path = _runtimeContext.UseTableSessionPool
|
||||
? DevicePathBuilder.GetTableName<T>()
|
||||
: DevicePathBuilder.GetDevicePath(entity);
|
||||
devicePaths.Add(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证设备路径
|
||||
/// </summary>
|
||||
/// <param name="devicePaths"></param>
|
||||
private void ValidateDevicePaths(HashSet<string> devicePaths)
|
||||
{
|
||||
if (devicePaths.Count == 0)
|
||||
{
|
||||
throw new IoTException($"{nameof(BuildTablet)} 构建IoTDB数据结构时,设备路径集合为空", -108);
|
||||
}
|
||||
|
||||
if (devicePaths.Count > 1)
|
||||
{
|
||||
var paths = string.Join(", ", devicePaths.Take(3));
|
||||
{
|
||||
throw new IoTException($"{nameof(BuildTablet)} 构建IoTDB数据结构时,设备路径不一致。检测到路径: {paths}...", -109);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 缓存优化:避免重复反射
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
private string GetTableNameOrTreePath<T>()
|
||||
{
|
||||
return AttributeCache<T>.TableNameOrTreePath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 特性缓存辅助类
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
private static class AttributeCache<T>
|
||||
{
|
||||
public static readonly string TableNameOrTreePath;
|
||||
|
||||
static AttributeCache()
|
||||
{
|
||||
var attr = typeof(T).GetCustomAttribute<TableNameOrTreePathAttribute>();
|
||||
TableNameOrTreePath = attr?.TableNameOrTreePath ?? string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 构建tree模型的Tablet
|
||||
@ -615,7 +443,7 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
/// <param name="values">数据集合</param>
|
||||
/// <param name="timestamps">时间戳集合</param>
|
||||
/// <returns></returns>
|
||||
private Tablet BuildTableSessionTablet(DeviceMetadata metadata, string tableName, List<string> columns,List<List<object>> values, List<long> timestamps)
|
||||
private Tablet BuildTableSessionTablet(DeviceMetadata metadata, string tableName, List<string> columns, List<List<object>> values, List<long> timestamps)
|
||||
{
|
||||
var tablet = new Tablet(
|
||||
tableName,
|
||||
@ -638,7 +466,7 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
private async Task<string> BuildQuerySQL<T>(IoTDBQueryOptions options) where T : IoTEntity
|
||||
{
|
||||
var metadata = await GetMetadata<T>();
|
||||
var sb = new StringBuilder("SELECT TIME as Timestamps,");
|
||||
var sb = new StringBuilder("SELECT ");
|
||||
sb.AppendJoin(", ", metadata.ColumnNames);
|
||||
sb.Append($" FROM {options.TableNameOrTreePath}");
|
||||
|
||||
@ -749,11 +577,6 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
var accessor = SourceEntityAccessorFactory.GetAccessor<T>();
|
||||
var memberCache = BuildMemberCache(accessor);
|
||||
|
||||
var columns = new List<string>() { "Timestamps" };
|
||||
var dataTypes = new List<TSDataType>() { TSDataType.TIMESTAMP };
|
||||
columns.AddRange(metadata.ColumnNames);
|
||||
dataTypes.AddRange(metadata.DataTypes);
|
||||
|
||||
|
||||
while (dataSet.HasNext() && results.Count < pageSize)
|
||||
{
|
||||
@ -763,28 +586,13 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
Timestamps = record.Timestamps
|
||||
};
|
||||
|
||||
foreach (var measurement in columns)
|
||||
for (int i = 0; i < metadata.Processors.Count; i++)
|
||||
{
|
||||
int indexOf = columns.IndexOf(measurement);
|
||||
var value = record.Values[indexOf];
|
||||
TSDataType tSDataType = dataTypes[indexOf];
|
||||
|
||||
if (!memberCache.TryGetValue(measurement, out var member) && !(value is System.DBNull))
|
||||
var value = record.Values[i];
|
||||
if (!(value is System.DBNull))
|
||||
{
|
||||
throw new Exception($"{nameof(ParseResults)} 解析查询结果 {accessor.EntityName} 属性赋值出现异常,没有找到{measurement}对应的 member信息");
|
||||
metadata.Processors[i].ValueSetter(entity, value);
|
||||
}
|
||||
|
||||
dynamic tempValue = GetTSDataValue(tSDataType, value);
|
||||
|
||||
if (measurement.ToLower().EndsWith("time"))
|
||||
{
|
||||
member.Setter(entity, TimestampHelper.ConvertToDateTime(tempValue, TimestampUnit.Nanoseconds));
|
||||
}
|
||||
else
|
||||
{
|
||||
member.Setter(entity, tempValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
results.Add(entity);
|
||||
@ -802,17 +610,15 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
private List<ColumnInfo> CollectColumnMetadata<T>(ISourceEntityAccessor<T> accessor)
|
||||
{
|
||||
var columns = new List<ColumnInfo>();
|
||||
var memberCache = BuildMemberCache(accessor);
|
||||
var memberCache = BuildMemberCache(accessor);
|
||||
|
||||
foreach (var member in accessor.MemberList)
|
||||
{
|
||||
// 过滤元组子项
|
||||
if (member.NameOrPath.Contains(".Item")) continue;
|
||||
|
||||
// 类型名称处理
|
||||
Type declaredType = member.DeclaredType;
|
||||
var underlyingType = Nullable.GetUnderlyingType(declaredType);
|
||||
string declaredTypeName = underlyingType?.Name ?? member.DeclaredTypeName;
|
||||
// 类型名称处理
|
||||
string declaredTypeName = member.DeclaredTypeName;
|
||||
|
||||
// 特性查询优化
|
||||
var attributes = member.CustomAttributes ?? Enumerable.Empty<Attribute>();
|
||||
@ -825,15 +631,15 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
ColumnInfo? column = null;
|
||||
if (tagAttr != null)
|
||||
{
|
||||
column = new ColumnInfo(member.NameOrPath, ColumnCategory.TAG, GetDataTypeFromTypeName(declaredTypeName), false);
|
||||
column = new ColumnInfo(member.NameOrPath, ColumnCategory.TAG, GetDataTypeFromTypeName(member.DeclaredTypeName), false, member.DeclaredTypeName);
|
||||
}
|
||||
else if (attrColumn != null)
|
||||
{
|
||||
column = new ColumnInfo(member.NameOrPath, ColumnCategory.ATTRIBUTE, GetDataTypeFromTypeName(declaredTypeName), false);
|
||||
column = new ColumnInfo(member.NameOrPath, ColumnCategory.ATTRIBUTE, GetDataTypeFromTypeName(member.DeclaredTypeName), false, member.DeclaredTypeName);
|
||||
}
|
||||
else if (fieldColumn != null)
|
||||
{
|
||||
column = new ColumnInfo(member.NameOrPath, ColumnCategory.FIELD, GetDataTypeFromTypeName(declaredTypeName), false);
|
||||
column = new ColumnInfo(member.NameOrPath, ColumnCategory.FIELD, GetDataTypeFromTypeName(member.DeclaredTypeName), false, member.DeclaredTypeName);
|
||||
}
|
||||
|
||||
// 单测模式处理
|
||||
@ -844,7 +650,7 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
{
|
||||
throw new Exception($"{nameof(CollectColumnMetadata)} {accessor.EntityName} {member.NameOrPath} 单侧点属性解析异常");
|
||||
}
|
||||
column = new ColumnInfo(member.NameOrPath, ColumnCategory.FIELD, GetDataTypeFromTypeName(tupleMember.DeclaredTypeName), true);
|
||||
column = new ColumnInfo(member.NameOrPath, ColumnCategory.FIELD, GetDataTypeFromTypeName(tupleMember.DeclaredTypeName), true, tupleMember.DeclaredTypeName);
|
||||
}
|
||||
|
||||
if (column.HasValue) columns.Add(column.Value);
|
||||
@ -858,7 +664,7 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
/// <param name="typeInfo">待解析的类</param>
|
||||
/// <param name="columns">已处理好的数据列</param>
|
||||
/// <returns></returns>
|
||||
private DeviceMetadata BuildDeviceMetadata<T>(List<ColumnInfo> columns) where T : IoTEntity
|
||||
private DeviceMetadata BuildDeviceMetadata<T>(List<ColumnInfo> columns, ISourceEntityAccessor<T> accessor) where T : IoTEntity
|
||||
{
|
||||
var metadata = new DeviceMetadata();
|
||||
|
||||
@ -877,9 +683,134 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
ProcessCategory(groupedColumns, ColumnCategory.ATTRIBUTE, metadata);
|
||||
ProcessCategory(groupedColumns, ColumnCategory.FIELD, metadata);
|
||||
|
||||
// 新增处理器初始化
|
||||
foreach (var item in metadata.ColumnNames)
|
||||
{
|
||||
ColumnInfo column = columns.FirstOrDefault(d => d.Name == item);
|
||||
|
||||
var processor = new ColumnProcessor
|
||||
{
|
||||
ColumnName = column.Name,
|
||||
IsSingleMeasuring = column.IsSingleMeasuring,
|
||||
GetConverter = GetterConverter(column.DeclaredTypeName.ToUpper()),
|
||||
SetConverter = SetterConverter(column.Name.ToUpper()),
|
||||
TSDataType = column.DataType,
|
||||
};
|
||||
|
||||
// 处理单测点
|
||||
if (column.IsSingleMeasuring)
|
||||
{
|
||||
var item1Member = accessor.MemberList
|
||||
.First(m => m.NameOrPath == $"{column.Name}.Item1");
|
||||
|
||||
processor.SingleMeasuringNameGetter = (obj) =>
|
||||
{
|
||||
// 获取原始值并转为字符串
|
||||
object rawValue = item1Member.Getter(obj);
|
||||
string value = rawValue?.ToString();
|
||||
|
||||
ValidateSingleMeasuringName(value);
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
var item2Member = accessor.MemberList
|
||||
.First(m => m.NameOrPath == $"{column.Name}.Item2");
|
||||
processor.ValueGetter = (obj) =>
|
||||
{
|
||||
object rawValue = item2Member.Getter(obj);
|
||||
return processor.GetConverter(rawValue);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
// 获取对应的成员访问器
|
||||
var member = accessor.MemberList.First(m => m.NameOrPath == column.Name);
|
||||
processor.ValueGetter = (obj) =>
|
||||
{
|
||||
object rawValue = member.Getter(obj);
|
||||
return processor.GetConverter(rawValue);
|
||||
};
|
||||
|
||||
//对应的属性成员进行赋值
|
||||
processor.ValueSetter = (obj, value) =>
|
||||
{
|
||||
dynamic tempValue = GetTSDataValue(processor.TSDataType, value);
|
||||
var rawValue = processor.SetConverter(value);
|
||||
member.Setter(obj, rawValue);
|
||||
};
|
||||
}
|
||||
|
||||
metadata.Processors.Add(processor);
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证单测点名称格式
|
||||
/// </summary>
|
||||
private void ValidateSingleMeasuringName(string value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 规则1: 严格检查ASCII字母和数字(0-9, A-Z, a-z)
|
||||
bool hasInvalidChars = value.Any(c =>
|
||||
!((c >= 'A' && c <= 'Z') ||
|
||||
(c >= 'a' && c <= 'z') ||
|
||||
(c >= '0' && c <= '9')));
|
||||
|
||||
// 规则2: 首字符不能是数字
|
||||
bool startsWithDigit = value[0] >= '0' && value[0] <= '9';
|
||||
|
||||
// 规则3: 全字符串不能都是数字
|
||||
bool allDigits = value.All(c => c >= '0' && c <= '9');
|
||||
|
||||
// 按优先级抛出具体异常
|
||||
if (hasInvalidChars)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"SingleMeasuring name '{value}' 包含非法字符,只允许字母和数字");
|
||||
}
|
||||
else if (startsWithDigit)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"SingleMeasuring name '{value}' 不能以数字开头");
|
||||
}
|
||||
else if (allDigits)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"SingleMeasuring name '{value}' 不能全为数字");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取值的处理器
|
||||
/// </summary>
|
||||
/// <param name="declaredTypeName"></param>
|
||||
/// <returns></returns>
|
||||
private Func<object, object> GetterConverter(string declaredTypeName)
|
||||
{
|
||||
return declaredTypeName switch
|
||||
{
|
||||
"DATETIME" => value => value != null ? ((DateTime)value).GetDateTimeOffset().ToUnixTimeNanoseconds() : null,
|
||||
_ => value => value
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置值的处理
|
||||
/// </summary>
|
||||
/// <param name="columnName"></param>
|
||||
/// <returns></returns>
|
||||
private Func<object, object> SetterConverter(string columnName) =>
|
||||
columnName.ToLower().EndsWith("time")
|
||||
? value => value != null ? TimestampHelper.ConvertToDateTime(Convert.ToInt64(value), TimestampUnit.Nanoseconds) : null
|
||||
: value => value;
|
||||
|
||||
/// <summary>
|
||||
/// 处理不同列类型的逻辑
|
||||
/// </summary>
|
||||
@ -906,6 +837,11 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 声明的类型的名称
|
||||
/// </summary>
|
||||
public string DeclaredTypeName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否是单测点
|
||||
/// </summary>
|
||||
@ -921,12 +857,13 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
/// </summary>
|
||||
public TSDataType DataType { get; }
|
||||
|
||||
public ColumnInfo(string name, ColumnCategory category, TSDataType dataType, bool isSingleMeasuring)
|
||||
public ColumnInfo(string name, ColumnCategory category, TSDataType dataType, bool isSingleMeasuring, string declaredTypeName)
|
||||
{
|
||||
Name = name;
|
||||
Category = category;
|
||||
DataType = dataType;
|
||||
IsSingleMeasuring = isSingleMeasuring;
|
||||
DeclaredTypeName = declaredTypeName;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1023,5 +960,7 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
private static readonly Regex _asciiAlphanumericRegex = new Regex(@"^[a-zA-Z0-9]*$", RegexOptions.Compiled);
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ public class AdminClientService : IAdminClientService, IDisposable, ISingletonDe
|
||||
adminClientConfig.SecurityProtocol = SecurityProtocol.SaslPlaintext;
|
||||
adminClientConfig.SaslMechanism = SaslMechanism.Plain;
|
||||
adminClientConfig.SaslUsername = _kafkaOptionConfig.SaslUserName;
|
||||
adminClientConfig.SaslPassword = _kafkaOptionConfig.SaslUserName;
|
||||
adminClientConfig.SaslPassword = _kafkaOptionConfig.SaslPassword;
|
||||
}
|
||||
return new AdminClientBuilder(adminClientConfig).Build();
|
||||
}
|
||||
|
||||
@ -21,6 +21,10 @@ namespace JiShe.CollectBus.Kafka
|
||||
public static class KafkaSubscribeExtensions
|
||||
{
|
||||
|
||||
private static long _threadCount = 0;
|
||||
private static long _topicSubscribeCount = 0;
|
||||
private static long _threadStartCount = 0;
|
||||
|
||||
public static void UseInitKafkaTopic(this IServiceProvider provider)
|
||||
{
|
||||
//初始化主题信息
|
||||
@ -46,12 +50,12 @@ namespace JiShe.CollectBus.Kafka
|
||||
lifetime.ApplicationStarted.Register(() =>
|
||||
{
|
||||
var logger = provider.GetRequiredService<ILogger<CollectBusKafkaModule>>();
|
||||
var threadCount = 0;
|
||||
var topicCount = 0;
|
||||
//var threadCount = 0;
|
||||
//var topicCount = 0;
|
||||
var assemblyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
|
||||
if (string.IsNullOrWhiteSpace(assemblyPath))
|
||||
{
|
||||
logger.LogInformation($"kafka订阅未能找到程序路径");
|
||||
logger.LogWarning($"kafka订阅未能找到程序路径");
|
||||
return;
|
||||
}
|
||||
var dllFiles = Directory.GetFiles(assemblyPath, "*.dll");
|
||||
@ -69,21 +73,35 @@ namespace JiShe.CollectBus.Kafka
|
||||
if (subscribeTypes.Count == 0)
|
||||
continue;
|
||||
|
||||
foreach (var subscribeType in subscribeTypes)
|
||||
// 并行处理
|
||||
Parallel.ForEach(subscribeTypes, subscribeType =>
|
||||
{
|
||||
var subscribes = provider.GetServices(subscribeType).ToList();
|
||||
subscribes.ForEach(subscribe =>
|
||||
Parallel.ForEach(subscribes,subscribe =>
|
||||
{
|
||||
if (subscribe != null)
|
||||
{
|
||||
Tuple<int, int> tuple = BuildKafkaSubscribe(subscribe, provider, logger, kafkaOptions.Value);
|
||||
threadCount += tuple.Item1;
|
||||
topicCount += tuple.Item2;
|
||||
//threadCount += tuple.Item1;
|
||||
//topicCount += tuple.Item2;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
//foreach (var subscribeType in subscribeTypes)
|
||||
//{
|
||||
// var subscribes = provider.GetServices(subscribeType).ToList();
|
||||
// subscribes.ForEach(subscribe =>
|
||||
// {
|
||||
// if (subscribe != null)
|
||||
// {
|
||||
// Tuple<int, int> tuple = BuildKafkaSubscribe(subscribe, provider, logger, kafkaOptions.Value);
|
||||
// threadCount += tuple.Item1;
|
||||
// topicCount += tuple.Item2;
|
||||
// }
|
||||
// });
|
||||
//}
|
||||
}
|
||||
logger.LogInformation($"kafka订阅主题:{topicCount}数,共启动:{threadCount}线程");
|
||||
logger.LogWarning($"kafka订阅主题:{_topicSubscribeCount}数,共启动:{_threadCount}线程");
|
||||
});
|
||||
}
|
||||
|
||||
@ -135,22 +153,50 @@ namespace JiShe.CollectBus.Kafka
|
||||
//var configuration = provider.GetRequiredService<IConfiguration>();
|
||||
int threadCount = 0;
|
||||
|
||||
foreach (var sub in subscribedMethods)
|
||||
Parallel.ForEach(subscribedMethods, sub =>
|
||||
{
|
||||
int partitionCount = sub.Attribute!.TaskCount==-1?3: sub.Attribute!.TaskCount;// kafkaOptionConfig.NumPartitions;
|
||||
Interlocked.Increment(ref _topicSubscribeCount);
|
||||
int partitionCount = sub.Attribute!.TaskCount == -1 ? 3 : sub.Attribute!.TaskCount;// kafkaOptionConfig.NumPartitions;
|
||||
var adminClientService = provider.GetRequiredService<IAdminClientService>();
|
||||
|
||||
int topicCount = adminClientService.GetTopicPartitionsNum(sub.Attribute!.Topic);
|
||||
|
||||
//int partitionCount = sub.Attribute!.TaskCount == -1 ? topicCount : sub.Attribute!.TaskCount;// kafkaOptionConfig.NumPartitions;
|
||||
|
||||
partitionCount = partitionCount > topicCount ? topicCount : partitionCount;
|
||||
//partitionCount = sub.Attribute!.TaskCount == -1 ? adminClientService.GetTopicPartitionsNum(sub.Attribute!.Topic) : sub.Attribute!.TaskCount;
|
||||
if (partitionCount <= 0)
|
||||
partitionCount = 1;
|
||||
for (int i = 0; i < partitionCount; i++)
|
||||
Parallel.For(0,partitionCount, async (partition) =>
|
||||
{
|
||||
//if (sub.Attribute!.Topic == ProtocolConst.SubscriberLoginReceivedEventName)
|
||||
Task.Run(() => StartConsumerAsync(provider, sub.Attribute!, sub.Method, subscribe, logger));
|
||||
threadCount++;
|
||||
}
|
||||
}
|
||||
Interlocked.Increment(ref _threadCount);
|
||||
//Task.Run(() => StartConsumerAsync(provider, sub.Attribute!, sub.Method, subscribe, logger));
|
||||
//threadCount++;
|
||||
await StartConsumerAsync(provider, sub.Attribute!, sub.Method, subscribe, logger);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
//foreach (var sub in subscribedMethods)
|
||||
//{
|
||||
// //int partitionCount = sub.Attribute!.TaskCount==-1?3: sub.Attribute!.TaskCount;// kafkaOptionConfig.NumPartitions;
|
||||
// var adminClientService = provider.GetRequiredService<IAdminClientService>();
|
||||
|
||||
// int topicCount = adminClientService.GetTopicPartitionsNum(sub.Attribute!.Topic);
|
||||
|
||||
// int partitionCount = sub.Attribute!.TaskCount == -1 ? topicCount : sub.Attribute!.TaskCount;// kafkaOptionConfig.NumPartitions;
|
||||
|
||||
// partitionCount = partitionCount > topicCount ? topicCount : partitionCount;
|
||||
// //partitionCount = sub.Attribute!.TaskCount == -1 ? adminClientService.GetTopicPartitionsNum(sub.Attribute!.Topic) : sub.Attribute!.TaskCount;
|
||||
// if (partitionCount <= 0)
|
||||
// partitionCount = 1;
|
||||
// for (int i = 0; i < partitionCount; i++)
|
||||
// {
|
||||
// //if (sub.Attribute!.Topic == ProtocolConst.SubscriberLoginReceivedEventName)
|
||||
// Task.Run(() => StartConsumerAsync(provider, sub.Attribute!, sub.Method, subscribe, logger));
|
||||
// threadCount++;
|
||||
// }
|
||||
//}
|
||||
return Tuple.Create(threadCount, subscribedMethods.Length);
|
||||
}
|
||||
|
||||
@ -163,6 +209,8 @@ namespace JiShe.CollectBus.Kafka
|
||||
|
||||
if (attr.EnableBatch)
|
||||
{
|
||||
Interlocked.Increment(ref _threadStartCount);
|
||||
logger.LogInformation($"kafka开启线程消费:{_threadStartCount}");
|
||||
await consumerService.SubscribeBatchAsync<dynamic>(attr.Topic, async (message) =>
|
||||
{
|
||||
try
|
||||
@ -183,6 +231,8 @@ namespace JiShe.CollectBus.Kafka
|
||||
}
|
||||
else
|
||||
{
|
||||
Interlocked.Increment(ref _threadStartCount);
|
||||
logger.LogInformation($"kafka开启线程消费:{_threadStartCount}");
|
||||
await consumerService.SubscribeAsync<dynamic>(attr.Topic, async (message) =>
|
||||
{
|
||||
try
|
||||
|
||||
@ -13,6 +13,7 @@ using JiShe.CollectBus.IotSystems.MessageIssueds;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.MongoDB;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
using JiShe.CollectBus.IotSystems.LogRecord;
|
||||
|
||||
namespace JiShe.CollectBus.MongoDB;
|
||||
|
||||
@ -32,7 +33,6 @@ public class CollectBusMongoDbContext : AbpMongoDbContext, ICollectBusMongoDbCon
|
||||
|
||||
public IMongoCollection<MessageIssued> MessageIssueds => Collection<MessageIssued>();
|
||||
|
||||
|
||||
|
||||
protected override void CreateModel(IMongoModelBuilder modelBuilder)
|
||||
{
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
using JiShe.CollectBus.IotSystems.MeterReadingRecords;
|
||||
using JiShe.CollectBus.IotSystems.LogRecord;
|
||||
using JiShe.CollectBus.IotSystems.MeterReadingRecords;
|
||||
using JiShe.CollectBus.Repository;
|
||||
using JiShe.CollectBus.Repository.LogRecord;
|
||||
using JiShe.CollectBus.Repository.MeterReadingRecord;
|
||||
using JiShe.CollectBus.ShardingStrategy;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@ -35,10 +37,14 @@ public class CollectBusMongoDbModule : AbpModule
|
||||
typeof(IShardingStrategy<>),
|
||||
typeof(DayShardingStrategy<>));
|
||||
|
||||
|
||||
context.Services.AddTransient(typeof(HourShardingStrategy<>));
|
||||
|
||||
//// 分表策略仓储 替换默认仓储
|
||||
//options.AddRepository<MeterReadingRecords, MeterReadingRecordRepository>();
|
||||
});
|
||||
|
||||
options.AddRepository<LogRecords, LogRecordRepository>();
|
||||
});
|
||||
context.Services.AddAlwaysDisableUnitOfWorkTransaction();
|
||||
Configure<AbpUnitOfWorkDefaultOptions>(options =>
|
||||
{
|
||||
|
||||
@ -0,0 +1,57 @@
|
||||
using JiShe.CollectBus.IotSystems.LogRecord;
|
||||
using JiShe.CollectBus.IotSystems.MeterReadingRecords;
|
||||
using MongoDB.Driver;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
|
||||
namespace JiShe.CollectBus.Repository.LogRecord
|
||||
{
|
||||
public interface ILogRecordRepository : IRepository<LogRecords, Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// 批量插入
|
||||
/// </summary>
|
||||
/// <param name="entities"></param>
|
||||
/// <param name="dateTime"></param>
|
||||
/// <returns></returns>
|
||||
Task InsertManyAsync(List<LogRecords> entities,
|
||||
DateTime? dateTime);
|
||||
|
||||
/// <summary>
|
||||
/// 单个插入
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="dateTime"></param>
|
||||
/// <returns></returns>
|
||||
Task<LogRecords> InsertAsync(LogRecords entity, DateTime? dateTime);
|
||||
|
||||
/// <summary>
|
||||
/// 单条更新
|
||||
/// </summary>
|
||||
/// <param name="filter">过滤条件,示例:Builders<LogRecords>.Filter.Eq(x => x.Id, filter.Id)</param>
|
||||
/// <param name="update">包含待更新的内容,示例:Builders<LogRecords>.Update.Set(x => x.SendHexMessage, SendHexMessage).Set(x => x.MessageId, MessageId)</param>
|
||||
/// <param name="entity">数据实体,用于获取对应的分片库</param>
|
||||
/// <returns></returns>
|
||||
Task<LogRecords> UpdateOneAsync(FilterDefinition<LogRecords> filter, UpdateDefinition<LogRecords> update, LogRecords entity);
|
||||
|
||||
/// <summary>
|
||||
/// 单个获取
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="dateTime"></param>
|
||||
/// <returns></returns>
|
||||
Task<LogRecords> FirOrDefaultAsync(LogRecords entity, DateTime dateTime);
|
||||
|
||||
/// <summary>
|
||||
/// 多集合数据查询
|
||||
/// </summary>
|
||||
/// <param name="startTime"></param>
|
||||
/// <param name="endTime"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<LogRecords>> ParallelQueryAsync(DateTime startTime, DateTime endTime);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,166 @@
|
||||
using JiShe.CollectBus.IotSystems.LogRecord;
|
||||
using JiShe.CollectBus.IotSystems.MeterReadingRecords;
|
||||
using JiShe.CollectBus.MongoDB;
|
||||
using JiShe.CollectBus.Repository.MeterReadingRecord;
|
||||
using JiShe.CollectBus.ShardingStrategy;
|
||||
using MongoDB.Driver;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Domain.Repositories.MongoDB;
|
||||
using Volo.Abp.MongoDB;
|
||||
|
||||
namespace JiShe.CollectBus.Repository.LogRecord
|
||||
{
|
||||
public class LogRecordRepository : MongoDbRepository<CollectBusMongoDbContext, LogRecords, Guid>, ILogRecordRepository
|
||||
{
|
||||
|
||||
private readonly HourShardingStrategy<LogRecords> _hourShardingStrategy;
|
||||
private readonly IMongoDbContextProvider<CollectBusMongoDbContext> _dbContextProvider;
|
||||
|
||||
public LogRecordRepository(
|
||||
IMongoDbContextProvider<CollectBusMongoDbContext> dbContextProvider,
|
||||
HourShardingStrategy<LogRecords> hourShardingStrategy
|
||||
)
|
||||
: base(dbContextProvider)
|
||||
{
|
||||
_dbContextProvider = dbContextProvider;
|
||||
_hourShardingStrategy = hourShardingStrategy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量插入
|
||||
/// </summary>
|
||||
/// <param name="entities"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<IEnumerable<LogRecords>> InsertManyAsync(IEnumerable<LogRecords> entities, bool autoSave = false, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
var collection = await GetShardedCollection(DateTime.Now);
|
||||
await collection.InsertManyAsync(entities);
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量插入
|
||||
/// </summary>
|
||||
/// <param name="entities"></param>
|
||||
/// <param name="dateTime"></param>
|
||||
/// <returns></returns>
|
||||
public async Task InsertManyAsync(List<LogRecords> entities, DateTime? dateTime)
|
||||
{
|
||||
var collection = await GetShardedCollection(dateTime);
|
||||
await collection.InsertManyAsync(entities);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 单条插入
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<LogRecords> InsertAsync(LogRecords entity, bool autoSave = false, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
var collection = await GetShardedCollection(DateTime.Now);
|
||||
await collection.InsertOneAsync(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 单条插入
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="dateTime"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<LogRecords> InsertAsync(LogRecords entity, DateTime? dateTime)
|
||||
{
|
||||
var collection = await GetShardedCollection(dateTime);
|
||||
await collection.InsertOneAsync(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单条更新
|
||||
/// </summary>
|
||||
/// <param name="filter">过滤条件,示例:Builders<LogRecords>.Filter.Eq(x => x.Id, filter.Id)</param>
|
||||
/// <param name="update">包含待更新的内容,示例:Builders<LogRecords>.Update.Set(x => x.SendHexMessage, SendHexMessage).Set(x => x.MessageId, MessageId)</param>
|
||||
/// <param name="entity">数据实体,用于获取对应的分片库</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LogRecords> UpdateOneAsync(FilterDefinition<LogRecords> filter, UpdateDefinition<LogRecords> update, LogRecords entity)
|
||||
{
|
||||
var collection = await GetShardedCollection(entity.CreationTime);
|
||||
|
||||
await collection.UpdateOneAsync(filter, update);
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 单个获取
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="dateTime"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<LogRecords> FirOrDefaultAsync(LogRecords entity, DateTime dateTime)
|
||||
{
|
||||
var collection = await GetShardedCollection(dateTime);
|
||||
var query = await collection.FindAsync(d => d.CreationTime == dateTime && d.AFN == entity.AFN && d.Fn == entity.Fn && d.Code == entity.Code);
|
||||
return await query.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 多集合数据查询
|
||||
/// </summary>
|
||||
/// <param name="startTime"></param>
|
||||
/// <param name="endTime"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<LogRecords>> ParallelQueryAsync(DateTime startTime, DateTime endTime)
|
||||
{
|
||||
var collectionNames = _hourShardingStrategy.GetQueryCollectionNames(startTime, endTime);
|
||||
|
||||
var dbContext = await DbContextProvider.GetDbContextAsync();
|
||||
|
||||
var tasks = collectionNames.Select(async name =>
|
||||
{
|
||||
var collection = dbContext.Database.GetCollection<LogRecords>(name);
|
||||
var filter = Builders<LogRecords>.Filter.And(
|
||||
Builders<LogRecords>.Filter.Gte(x => x.CreationTime, startTime),
|
||||
Builders<LogRecords>.Filter.Lte(x => x.CreationTime, endTime)
|
||||
);
|
||||
return await collection.Find(filter).ToListAsync();
|
||||
});
|
||||
|
||||
var results = await Task.WhenAll(tasks);
|
||||
return results.SelectMany(r => r).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得分片集合
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<IMongoCollection<LogRecords>> GetShardedCollection(DateTime? dateTime)
|
||||
{
|
||||
var dbContext = await DbContextProvider.GetDbContextAsync();
|
||||
string collectionName = string.Empty;
|
||||
|
||||
if (dateTime != null)
|
||||
{
|
||||
collectionName = _hourShardingStrategy.GetCollectionName(dateTime.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
collectionName = _hourShardingStrategy.GetCurrentCollectionName();
|
||||
}
|
||||
|
||||
return dbContext.Database.GetCollection<LogRecords>(collectionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -22,7 +23,7 @@ namespace JiShe.CollectBus.ShardingStrategy
|
||||
public string GetCollectionName(DateTime dateTime)
|
||||
{
|
||||
var baseName = typeof(TEntity).Name;
|
||||
return $"{baseName}_{dateTime.GetDataTableShardingStrategy()}";
|
||||
return $"{baseName}_{dateTime.GetDataTableShardingStrategy(TableTimeStrategyEnum.DayShardingStrategy)}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -32,7 +33,7 @@ namespace JiShe.CollectBus.ShardingStrategy
|
||||
public string GetCurrentCollectionName()
|
||||
{
|
||||
var baseName = typeof(TEntity).Name;
|
||||
return $"{baseName}_{DateTime.Now.GetDataTableShardingStrategy()}";
|
||||
return $"{baseName}_{DateTime.Now.GetDataTableShardingStrategy(TableTimeStrategyEnum.DayShardingStrategy)}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -50,7 +51,7 @@ namespace JiShe.CollectBus.ShardingStrategy
|
||||
|
||||
while (current <= end)
|
||||
{
|
||||
months.Add($"{baseName}_{current.GetDataTableShardingStrategy()}");
|
||||
months.Add($"{baseName}_{current.GetDataTableShardingStrategy(TableTimeStrategyEnum.DayShardingStrategy)}");
|
||||
current = current.AddMonths(1);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,58 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace JiShe.CollectBus.ShardingStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// 按小时分表
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity"></typeparam>
|
||||
public class HourShardingStrategy<TEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取指定时间对应的集合名
|
||||
/// </summary>
|
||||
/// <param name="dateTime"></param>
|
||||
/// <returns></returns>
|
||||
public string GetCollectionName(DateTime dateTime)
|
||||
{
|
||||
var baseName = typeof(TEntity).Name;
|
||||
return $"{baseName}_{dateTime.GetDataTableShardingStrategy(TableTimeStrategyEnum.HourShardingStrategy)}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前时间对应的集合名
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetCurrentCollectionName()
|
||||
{
|
||||
var baseName = typeof(TEntity).Name;
|
||||
return $"{baseName}_{DateTime.Now.GetDataTableShardingStrategy(TableTimeStrategyEnum.HourShardingStrategy)}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用于查询时确定目标集合
|
||||
/// </summary>
|
||||
/// <param name="startTime"></param>
|
||||
/// <param name="endTime"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<string> GetQueryCollectionNames(DateTime? startTime, DateTime? endTime)
|
||||
{
|
||||
var list = new List<string>();
|
||||
var current = startTime ?? DateTime.MinValue;
|
||||
var end = endTime ?? DateTime.MaxValue;
|
||||
var baseName = typeof(TEntity).Name;
|
||||
|
||||
while (current <= end)
|
||||
{
|
||||
list.Add($"{baseName}_{current.GetDataTableShardingStrategy(TableTimeStrategyEnum.HourShardingStrategy)}");
|
||||
current = current.AddHours(1);
|
||||
}
|
||||
|
||||
return list.Distinct();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,9 +4,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.CollectBus.IoTDB.Model
|
||||
namespace JiShe.CollectBus.ShardingStrategy
|
||||
{
|
||||
internal class Class1
|
||||
public interface IHourShardingStrategy<TEntity> : IShardingStrategy<TEntity>
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,9 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using Apache.IoTDB;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
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.Protocol3761;
|
||||
@ -12,39 +17,60 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_00H
|
||||
public class AFN0_F1_Analysis: IAnalysisStrategy<TB3761>
|
||||
{
|
||||
private readonly ILogger<AFN0_F1_Analysis> _logger;
|
||||
private readonly DataStorage _dataStorage;
|
||||
|
||||
public AFN0_F1_Analysis(ILogger<AFN0_F1_Analysis> logger)
|
||||
public AFN0_F1_Analysis(ILogger<AFN0_F1_Analysis> logger, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_dataStorage= dataStorage;
|
||||
}
|
||||
|
||||
public Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.A.Code);
|
||||
UnitDataAnalysis<bool> dto = new UnitDataAnalysis<bool>
|
||||
var data = new AnalysisBaseDto<bool?>()
|
||||
{
|
||||
FiledDesc = "全部确认",
|
||||
DataValue = true,
|
||||
ItemType= $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}"
|
||||
};
|
||||
// 查询电表信息
|
||||
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.DeviceAddress = ammeterInfo.Address;
|
||||
data.DeviceType = MeterTypeEnum.Focus;
|
||||
data.FocusId= ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<bool?>> dto = new UnitDataAnalysis<AnalysisBaseDto<bool?>>
|
||||
{
|
||||
Code = input.A.Code,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = true,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
Data = data,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.None,
|
||||
TimeDensity = -1
|
||||
TimeDensity = -1,
|
||||
DataType= IOTDBDataTypeConst.Log
|
||||
};
|
||||
result?.Invoke(dto);
|
||||
return Task.FromResult(true);
|
||||
await _dataStorage.SaveDataToIotDbAsync<bool?>(dto);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"00_1解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
}
|
||||
return Task.FromResult(false);
|
||||
return await Task.FromResult(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
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.Protocol3761;
|
||||
@ -12,41 +16,61 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_00H
|
||||
public class AFN0_F2_Analysis : IAnalysisStrategy<TB3761>
|
||||
{
|
||||
private readonly ILogger<AFN0_F2_Analysis> _logger;
|
||||
|
||||
public AFN0_F2_Analysis(ILogger<AFN0_F2_Analysis> logger)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN0_F2_Analysis(ILogger<AFN0_F2_Analysis> logger, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
public Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.A.Code);
|
||||
UnitDataAnalysis<bool> dto = new UnitDataAnalysis<bool>
|
||||
var data = new AnalysisBaseDto<bool?>()
|
||||
{
|
||||
FiledDesc = "全部否认",
|
||||
DataValue = false,
|
||||
ItemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}"
|
||||
};
|
||||
// 查询电表信息
|
||||
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.DeviceAddress = ammeterInfo.Address;
|
||||
data.DeviceType = MeterTypeEnum.Focus;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<bool?>> dto = new UnitDataAnalysis<AnalysisBaseDto<bool?>>
|
||||
{
|
||||
Code = input.A.Code,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = false,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
Data = data,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime =input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.None,
|
||||
TimeDensity = -1
|
||||
TimeDensity = -1,
|
||||
DataType = IOTDBDataTypeConst.Log
|
||||
};
|
||||
result?.Invoke(dto);
|
||||
#if DEBUG
|
||||
_logger.LogWarning($"全部否认:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString}");
|
||||
#endif
|
||||
return Task.FromResult(true);
|
||||
await _dataStorage.SaveDataToIotDbAsync<bool?>(dto);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"00_2解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
return await Task.FromResult(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,18 +1,12 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
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
|
||||
{
|
||||
@ -39,7 +33,8 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_02H
|
||||
{
|
||||
FiledDesc = "登录",
|
||||
FiledName = "Type",
|
||||
DataValue = "Login"
|
||||
DataValue = "Login",
|
||||
ItemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}"
|
||||
};
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(MeterTypeEnum.Focus.ToString(), "15");
|
||||
@ -50,6 +45,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_02H
|
||||
data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
data.DeviceAddress = ammeterInfo.Address;
|
||||
data.DeviceType = MeterTypeEnum.Focus;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<string>> dto = new UnitDataAnalysis<AnalysisBaseDto<string>>
|
||||
{
|
||||
@ -58,11 +54,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_02H
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.None,
|
||||
TimeDensity = -1
|
||||
TimeDensity = -1,
|
||||
DataType = IOTDBDataTypeConst.Status
|
||||
};
|
||||
result?.Invoke(dto);
|
||||
await _dataStorage.SaveStatusToIotDbAsync<string>(dto);
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
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.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_02H
|
||||
{
|
||||
@ -36,7 +33,8 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_02H
|
||||
{
|
||||
FiledDesc = "退出登录",
|
||||
FiledName = "Type",
|
||||
DataValue = "LogOut"
|
||||
DataValue = "LogOut",
|
||||
ItemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}"
|
||||
};
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(MeterTypeEnum.Focus.ToString(), "15");
|
||||
@ -47,6 +45,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_02H
|
||||
data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
data.DeviceAddress = ammeterInfo.Address;
|
||||
data.DeviceType = MeterTypeEnum.Focus;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<string>> dto = new UnitDataAnalysis<AnalysisBaseDto<string>>
|
||||
{
|
||||
@ -55,11 +54,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_02H
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.None,
|
||||
TimeDensity = -1
|
||||
TimeDensity = -1,
|
||||
DataType = IOTDBDataTypeConst.Status
|
||||
};
|
||||
result?.Invoke(dto);
|
||||
await _dataStorage.SaveStatusToIotDbAsync<string>(dto);
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
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.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_02H
|
||||
{
|
||||
@ -36,7 +33,8 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_02H
|
||||
{
|
||||
FiledDesc = "心跳",
|
||||
FiledName = "Type",
|
||||
DataValue = "Heartbeat"
|
||||
DataValue = "Heartbeat",
|
||||
ItemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}"
|
||||
};
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(MeterTypeEnum.Focus.ToString(), "15");
|
||||
@ -47,6 +45,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_02H
|
||||
data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
data.DeviceAddress = ammeterInfo.Address;
|
||||
data.DeviceType = MeterTypeEnum.Focus;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<string>> dto = new UnitDataAnalysis<AnalysisBaseDto<string>>
|
||||
{
|
||||
@ -55,11 +54,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_02H
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.None,
|
||||
TimeDensity = -1
|
||||
TimeDensity = -1,
|
||||
DataType = IOTDBDataTypeConst.Status
|
||||
};
|
||||
result?.Invoke(dto);
|
||||
await _dataStorage.SaveStatusToIotDbAsync<string>(dto);
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
using System.Text;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
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;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@ -16,41 +19,63 @@ namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_09H
|
||||
{
|
||||
private readonly ILogger<AFN9_F1_Analysis> _logger;
|
||||
|
||||
public AFN9_F1_Analysis(ILogger<AFN9_F1_Analysis> logger)
|
||||
private readonly DataStorage _dataStorage;
|
||||
|
||||
public AFN9_F1_Analysis(ILogger<AFN9_F1_Analysis> logger, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData.HexMessageList);
|
||||
var data = AnalysisDataUnit(input.UnitData.HexMessageList);
|
||||
data.AreaCode = input.A.Code?.Substring(0, 4);
|
||||
data.Address = input.A.Code?.Substring(4, 5);
|
||||
UnitDataAnalysis<AFN9_F1_AnalysisDto> dto = new UnitDataAnalysis<AFN9_F1_AnalysisDto>
|
||||
var version = AnalysisDataUnit(input.UnitData.HexMessageList);
|
||||
version.AreaCode = input.A.Code?.Substring(0, 4);
|
||||
version.Address = input.A.Code?.Substring(4, 5);
|
||||
var data = new AnalysisBaseDto<AFN9_F1_AnalysisDto?>()
|
||||
{
|
||||
FiledDesc = "终端版本信息",
|
||||
DataValue = version,
|
||||
ItemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}"
|
||||
};
|
||||
// 查询电表信息
|
||||
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.DeviceAddress = ammeterInfo.Address;
|
||||
data.DeviceType = MeterTypeEnum.Focus;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<AFN9_F1_AnalysisDto?>> dto = new UnitDataAnalysis<AnalysisBaseDto<AFN9_F1_AnalysisDto?>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.None,
|
||||
TimeDensity = -1
|
||||
TimeDensity = -1,
|
||||
DataType=IOTDBDataTypeConst.Data
|
||||
};
|
||||
result?.Invoke(dto);
|
||||
return Task.FromResult(true);
|
||||
await _dataStorage.SaveDataToIotDbAsync(dto);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"09_1解析失败:{input.A?.Code}-{input.DT?.Fn ?? 0}-{input?.BaseHexMessage?.HexMessageString},{ex.Message}");
|
||||
}
|
||||
return Task.FromResult(false);
|
||||
return await Task.FromResult(false);
|
||||
}
|
||||
|
||||
private AFN9_F1_AnalysisDto AnalysisDataUnit(List<string> hexMessageList)
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
using System.Text;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
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.Protocol3761;
|
||||
@ -14,39 +17,60 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_09H
|
||||
public class AFN9_F9_Analysis : IAnalysisStrategy<TB3761>
|
||||
{
|
||||
private readonly ILogger<AFN9_F9_Analysis> _logger;
|
||||
|
||||
public AFN9_F9_Analysis(ILogger<AFN9_F9_Analysis> logger)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN9_F9_Analysis(ILogger<AFN9_F9_Analysis> logger, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData.HexMessageList);
|
||||
UnitDataAnalysis<string> dto = new UnitDataAnalysis<string>
|
||||
var data = new AnalysisBaseDto<string?>()
|
||||
{
|
||||
FiledDesc = "远程通信模块版本信息",
|
||||
DataValue = Encoding.ASCII.GetString(string.Join("", input.UnitData.HexMessageList.Skip(30).Take(20).ToList()).HexToByte()).Replace("\0", ""),
|
||||
ItemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}"
|
||||
};
|
||||
// 查询电表信息
|
||||
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.DeviceAddress = ammeterInfo.Address;
|
||||
data.DeviceType = MeterTypeEnum.Focus;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
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 = Encoding.ASCII.GetString(string.Join("", input.UnitData.HexMessageList.Skip(30).Take(20).ToList()).HexToByte()).Replace("\0", ""), //SIM卡
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
Data = data, //SIM卡
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.None,
|
||||
TimeDensity = -1
|
||||
TimeDensity = -1,
|
||||
DataType= IOTDBDataTypeConst.Data
|
||||
};
|
||||
result?.Invoke(dto);
|
||||
return Task.FromResult(true);
|
||||
await _dataStorage.SaveDataToIotDbAsync(dto);
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"00_1解析失败:{input.A?.Code}-{input.DT?.Fn ?? 0}-{input?.BaseHexMessage?.HexMessageString},{ex.Message}");
|
||||
}
|
||||
return Task.FromResult(false);
|
||||
return await Task.FromResult(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
@ -15,42 +17,64 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0AH
|
||||
{
|
||||
private readonly ILogger<AFN10_F10_Analysis> _logger;
|
||||
|
||||
public AFN10_F10_Analysis(ILogger<AFN10_F10_Analysis> logger)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN10_F10_Analysis(ILogger<AFN10_F10_Analysis> logger, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
public Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData.HexMessageList);
|
||||
Tuple<int, List<AFN10F10Entity>> tuple = AFN10F10EntityAnalysis(input.UnitData.HexMessageList);
|
||||
UnitDataAnalysis<AFN10_F10_AnalysisDto> dto = new UnitDataAnalysis<AFN10_F10_AnalysisDto>
|
||||
|
||||
var data = new AnalysisBaseDto<AFN10_F10_AnalysisDto?>()
|
||||
{
|
||||
FiledDesc = "终端电能表/交流采样装置配置参数",
|
||||
DataValue = new AFN10_F10_AnalysisDto()
|
||||
{
|
||||
AFN10F10Entitys = tuple.Item2,
|
||||
ConfigNum = tuple.Item1
|
||||
},
|
||||
ItemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}"
|
||||
};
|
||||
// 查询电表信息
|
||||
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.DeviceAddress = ammeterInfo.Address;
|
||||
data.DeviceType = MeterTypeEnum.Focus;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<AFN10_F10_AnalysisDto?>> dto = new UnitDataAnalysis<AnalysisBaseDto<AFN10_F10_AnalysisDto?>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = new AFN10_F10_AnalysisDto()
|
||||
{
|
||||
AFN10F10Entitys = tuple.Item2,
|
||||
ConfigNum = tuple.Item1
|
||||
},
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
Data = data,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.None,
|
||||
TimeDensity = -1
|
||||
TimeDensity = -1,
|
||||
DataType=IOTDBDataTypeConst.Param
|
||||
};
|
||||
result?.Invoke(dto);
|
||||
return Task.FromResult(true);
|
||||
await _dataStorage.SaveDataToIotDbAsync<AFN10_F10_AnalysisDto?>(dto);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0A_10解析失败:{input.A?.Code}-{input.DT?.Fn ?? 0}-{input?.BaseHexMessage?.HexMessageString},{ex.Message}");
|
||||
}
|
||||
return Task.FromResult(false);
|
||||
return await Task.FromResult(false);
|
||||
}
|
||||
|
||||
public Tuple<int, List<AFN10F10Entity>> AFN10F10EntityAnalysis(List<string> hexMessageList)
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0AH
|
||||
{
|
||||
@ -16,11 +19,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0AH
|
||||
{
|
||||
private readonly ILogger<AFN10_F66_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
|
||||
public AFN10_F66_Analysis(ILogger<AFN10_F66_Analysis> logger, AnalysisStrategyContext analysisStrategyContext)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN10_F66_Analysis(ILogger<AFN10_F66_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext= analysisStrategyContext;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
@ -29,22 +33,41 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0AH
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData.HexMessageList);
|
||||
var data = await GenerateFinalResult(input.UnitData.HexMessageList);
|
||||
data.Pn = input.DA.Pn;
|
||||
UnitDataAnalysis<AFN10_F66_AnalysisDto> dto = new UnitDataAnalysis<AFN10_F66_AnalysisDto>
|
||||
|
||||
var data = new AnalysisBaseDto<AFN10_F66_AnalysisDto?>()
|
||||
{
|
||||
FiledDesc = "终端电能表/交流采样装置配置参数",
|
||||
DataValue = await GenerateFinalResult(input.UnitData.HexMessageList),
|
||||
ItemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}"
|
||||
};
|
||||
// 查询电表信息
|
||||
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.DeviceAddress = ammeterInfo.Address;
|
||||
data.DeviceType = MeterTypeEnum.Focus;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<AFN10_F66_AnalysisDto?>> dto = new UnitDataAnalysis<AnalysisBaseDto<AFN10_F66_AnalysisDto?>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.None,
|
||||
TimeDensity = -1
|
||||
TimeDensity = -1,
|
||||
DataType = IOTDBDataTypeConst.Param
|
||||
};
|
||||
result?.Invoke(dto);
|
||||
await _dataStorage.SaveDataToIotDbAsync<AFN10_F66_AnalysisDto?>(dto);
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
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.Protocol3761;
|
||||
@ -12,39 +16,60 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0AH
|
||||
public class AFN10_F68_Analysis : IAnalysisStrategy<TB3761>
|
||||
{
|
||||
private readonly ILogger<AFN10_F68_Analysis> _logger;
|
||||
|
||||
public AFN10_F68_Analysis(ILogger<AFN10_F68_Analysis> logger)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN10_F68_Analysis(ILogger<AFN10_F68_Analysis> logger, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData.HexMessageList);
|
||||
UnitDataAnalysis<bool> dto = new UnitDataAnalysis<bool>
|
||||
var data = new AnalysisBaseDto<bool?>()
|
||||
{
|
||||
FiledDesc = "终端电能表/交流采样装置配置参数",
|
||||
DataValue = input.UnitData.HexMessageList[4].Equals("55"),
|
||||
ItemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}"
|
||||
};
|
||||
// 查询电表信息
|
||||
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.DeviceAddress = ammeterInfo.Address;
|
||||
data.DeviceType = MeterTypeEnum.Focus;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<bool?>> dto = new UnitDataAnalysis<AnalysisBaseDto<bool?>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = input.UnitData.HexMessageList[4].Equals("55"),
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
Data = data,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.None,
|
||||
TimeDensity = -1
|
||||
TimeDensity = -1,
|
||||
DataType = IOTDBDataTypeConst.Param
|
||||
};
|
||||
result?.Invoke(dto);
|
||||
return Task.FromResult(true);
|
||||
await _dataStorage.SaveDataToIotDbAsync<bool?>(dto);
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"0A_68解析失败:{input.A?.Code}-{input.DT?.Fn ?? 0}-{input?.BaseHexMessage?.HexMessageString},{ex.Message}");
|
||||
}
|
||||
return Task.FromResult(false);
|
||||
return await Task.FromResult(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,16 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using Apache.IoTDB;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IoTDB.Interface;
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
{
|
||||
@ -17,13 +21,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
{
|
||||
private readonly ILogger<AFN12_F129_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
private readonly IIoTDbProvider _dbProvider;
|
||||
|
||||
public AFN12_F129_Analysis(ILogger<AFN12_F129_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, IIoTDbProvider dbProvider)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN12_F129_Analysis(ILogger<AFN12_F129_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dbProvider= dbProvider;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
@ -41,16 +44,34 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3.D1_D7,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.Second,
|
||||
TimeDensity = 0
|
||||
TimeDensity = 0,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
List<AnalysisBaseDto<decimal?>> list = GenerateFinalResult(2, datas, "正向有功电能示值", input.AFN_FC.AFN, input.DT.Fn);
|
||||
if (list.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(list[0].DeviceType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
list.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
unitDataAnalysis.Data= list;
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync(unitDataAnalysis);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -110,14 +131,14 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
if(decimal.TryParse(data[i], out decimal value))
|
||||
meter.DataValue = value;
|
||||
}
|
||||
meter.DataType = $"{afn.ToString().PadLeft(2, '0')}_{fn}_{i - index}";
|
||||
meter.ItemType = i - index == 0 ? $"{afn.ToString().PadLeft(2, '0')}_{fn}": $"{afn.ToString().PadLeft(2, '0')}_{fn}_{i - index}";
|
||||
string timeSpan = $"{data[0].Substring(0, 4)}-{data[0].Substring(4, 2)}-{data[0].Substring(6, 2)} {data[0].Substring(8, 2)}:{data[0].Substring(10, 2)}:00";
|
||||
if (DateTime.TryParse(timeSpan, out DateTime readingDate))
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
list.Add(meter);
|
||||
}
|
||||
return list;
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
{
|
||||
@ -17,11 +20,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
|
||||
private readonly ILogger<AFN12_F130_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
|
||||
public AFN12_F130_Analysis(ILogger<AFN12_F130_Analysis> logger, AnalysisStrategyContext analysisStrategyContext)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN12_F130_Analysis(ILogger<AFN12_F130_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
@ -32,6 +36,22 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
List<AnalysisBaseDto<decimal?>> list = GenerateFinalResult(2, datas, "正向无功电能示值", input.AFN_FC.AFN, input.DT.Fn);
|
||||
if (list.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(list[0].DeviceType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
list.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal?>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal?>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
@ -39,13 +59,15 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = list,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.Second,
|
||||
TimeDensity = 0
|
||||
TimeDensity = 0,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync(unitDataAnalysis);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -98,12 +120,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
if(decimal.TryParse(data[i], out decimal value))
|
||||
meter.DataValue = value;
|
||||
}
|
||||
meter.DataType = $"{afn.ToString().PadLeft(2, '0')}_{fn}_{i - index}";
|
||||
meter.ItemType = i - index==0 ? $"{afn.ToString().PadLeft(2, '0')}_{fn}": $"{afn.ToString().PadLeft(2, '0')}_{fn}_{i - index}";
|
||||
string timeSpan = $"{data[0].Substring(0, 4)}-{data[0].Substring(4, 2)}-{data[0].Substring(6, 2)} {data[0].Substring(8, 2)}:{data[0].Substring(10, 2)}:00";
|
||||
if(DateTime.TryParse(timeSpan, out DateTime readingDate))
|
||||
meter.TimeSpan = readingDate;
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
list.Add(meter);
|
||||
}
|
||||
return list;
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
@ -8,6 +10,7 @@ using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using YamlDotNet.Core.Tokens;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
{
|
||||
@ -18,11 +21,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
{
|
||||
private readonly ILogger<AFN12_F131_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
|
||||
public AFN12_F131_Analysis(ILogger<AFN12_F131_Analysis> logger, AnalysisStrategyContext analysisStrategyContext)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN12_F131_Analysis(ILogger<AFN12_F131_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
@ -33,6 +37,22 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
List<AnalysisBaseDto<decimal?>> list = GenerateFinalResult(2, datas, "反向有功总电能示值", input.AFN_FC.AFN, input.DT.Fn);
|
||||
if (list.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(list[0].DeviceType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
list.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal?>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal?>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
@ -40,13 +60,15 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = list,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.Second,
|
||||
TimeDensity = 0
|
||||
TimeDensity = 0,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync(unitDataAnalysis);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -100,12 +122,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
if(decimal.TryParse(data[i], out decimal value))
|
||||
meter.DataValue = value;
|
||||
}
|
||||
meter.DataType = $"{afn.ToString().PadLeft(2, '0')}_{fn}_{i - index}";
|
||||
meter.ItemType = i - index==0? $"{afn.ToString().PadLeft(2, '0')}_{fn}" : $"{afn.ToString().PadLeft(2, '0')}_{fn}_{i - index}";
|
||||
string timeSpan = $"{data[0].Substring(0, 4)}-{data[0].Substring(4, 2)}-{data[0].Substring(6, 2)} {data[0].Substring(8, 2)}:{data[0].Substring(10, 2)}:00";
|
||||
if(DateTime.TryParse(timeSpan, out DateTime readTime))
|
||||
meter.TimeSpan = readTime;
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
list.Add(meter);
|
||||
}
|
||||
return list;
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
@ -19,11 +21,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
|
||||
private readonly ILogger<AFN12_F132_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
|
||||
public AFN12_F132_Analysis(ILogger<AFN12_F132_Analysis> logger, AnalysisStrategyContext analysisStrategyContext)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN12_F132_Analysis(ILogger<AFN12_F132_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
|
||||
@ -36,6 +39,22 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
List<AnalysisBaseDto<decimal?>> list = GenerateFinalResult(2, datas, "反向无功电能示值", dataType);
|
||||
if (list.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(list[0].DeviceType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
list.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal?>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal?>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
@ -43,13 +62,15 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
Fn = input.DT.Fn ,
|
||||
Pn = input.DA.Pn,
|
||||
Data = list,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.Second,
|
||||
TimeDensity = 0
|
||||
TimeDensity = 0,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync(unitDataAnalysis);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -82,7 +103,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
}
|
||||
return values;
|
||||
}
|
||||
public List<AnalysisBaseDto<decimal?>> GenerateFinalResult(int index, List<string> data, string dataType, string filedDesc = "")
|
||||
public List<AnalysisBaseDto<decimal?>> GenerateFinalResult(int index, List<string> data, string itemType, string filedDesc = "")
|
||||
{
|
||||
List<AnalysisBaseDto<decimal?>> list = new List<AnalysisBaseDto<decimal?>>();
|
||||
for (int i = index; i < data.Count; i++)
|
||||
@ -103,14 +124,14 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
meter.DataValue = value;
|
||||
}
|
||||
|
||||
meter.DataType = $"{dataType}_{i - index}";
|
||||
meter.ItemType = i - index==0?itemType:$"{itemType}_{i - index}";
|
||||
string timeSpan = $"{data[0].Substring(0, 4)}-{data[0].Substring(4, 2)}-{data[0].Substring(6, 2)} {data[0].Substring(8, 2)}:{data[0].Substring(10, 2)}:00";
|
||||
if (DateTime.TryParse(timeSpan,out DateTime readingDate))
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
list.Add(meter);
|
||||
}
|
||||
return list;
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
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.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Metrics;
|
||||
using static FreeSql.Internal.GlobalFilter;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
{
|
||||
@ -18,11 +22,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
{
|
||||
private readonly ILogger<AFN12_F145_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
|
||||
public AFN12_F145_Analysis(ILogger<AFN12_F145_Analysis> logger, AnalysisStrategyContext analysisStrategyContext)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN12_F145_Analysis(ILogger<AFN12_F145_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
|
||||
@ -33,9 +38,20 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
string itemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
AnalysisBaseDto<decimal?> data = GenerateFinalResult(datas, "当月正向有功最大需量及发生时间", dataType);
|
||||
AnalysisBaseDto<decimal?> data = GenerateFinalResult(datas, "当月正向有功最大需量及发生时间", itemType);
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.DeviceType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ProjectId = ammeterInfo.ProjectID;
|
||||
data.DeviceId = ammeterInfo.MeterId;
|
||||
data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
data.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
|
||||
UnitDataAnalysis<AnalysisBaseDto<decimal?>> unitDataAnalysis = new UnitDataAnalysis<AnalysisBaseDto<decimal?>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
@ -43,13 +59,15 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.Second,
|
||||
TimeDensity = 0
|
||||
TimeDensity = 0,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
await _dataStorage.SaveDataToIotDbAsync(unitDataAnalysis);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -96,7 +114,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
return values;
|
||||
}
|
||||
|
||||
public AnalysisBaseDto<decimal?> GenerateFinalResult(List<string> data, string filedDesc,string dataType)
|
||||
public AnalysisBaseDto<decimal?> GenerateFinalResult(List<string> data, string filedDesc,string itemType)
|
||||
{
|
||||
AnalysisBaseDto<decimal?> dto = new AnalysisBaseDto<decimal?>
|
||||
{
|
||||
@ -119,9 +137,9 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0CH
|
||||
{
|
||||
dto.TimeSpan = readingDate;
|
||||
}
|
||||
dto.DataType = dataType;
|
||||
dto.ItemType = itemType;
|
||||
dto.FiledDesc = filedDesc;
|
||||
dto.FiledName = dto.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
dto.FiledName = dto.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -9,6 +10,7 @@ using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static FreeSql.Internal.GlobalFilter;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
@ -36,9 +38,9 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
List<string> datas = await AnalysisDataUnit(input.UnitData.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
string itemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
AnalysisBaseDto<decimal?> data = GenerateFinalResult(datas, dataType,"上月(上一结算日)正向有功最大需量及发生时间");
|
||||
AnalysisBaseDto<decimal?> data = GenerateFinalResult(datas, itemType,"上月(上一结算日)正向有功最大需量及发生时间");
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.DeviceType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
@ -47,6 +49,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
data.DeviceId = ammeterInfo.MeterId;
|
||||
data.DatabaseBusiID=ammeterInfo.DatabaseBusiID;
|
||||
data.DeviceAddress= ammeterInfo.AmmerterAddress;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<decimal?>> unitDataAnalysis = new UnitDataAnalysis<AnalysisBaseDto<decimal?>>
|
||||
{
|
||||
@ -57,11 +60,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
MSA=input.A.A3!.D1_D7!,
|
||||
PSEQ=input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage=input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage=input.BaseHexMessage.HexMessageString,
|
||||
MessageId=input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.Second,
|
||||
TimeDensity = 0
|
||||
TimeDensity = 0,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
@ -110,7 +114,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
}
|
||||
return values;
|
||||
}
|
||||
public AnalysisBaseDto<decimal?> GenerateFinalResult(List<string> data,string dataType, string filedDesc = "")
|
||||
public AnalysisBaseDto<decimal?> GenerateFinalResult(List<string> data,string itemType, string filedDesc = "")
|
||||
{
|
||||
AnalysisBaseDto<decimal?> dto = new AnalysisBaseDto<decimal?>
|
||||
{
|
||||
@ -144,9 +148,9 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
dto.TimeSpan= dto.TimeSpan.Value.AddYears(-1);
|
||||
}
|
||||
dto.DataType = dataType;
|
||||
dto.ItemType = itemType;
|
||||
dto.FiledDesc = "上月(上一结算日)正向有功最大需量及发生时间";
|
||||
dto.FiledName = dto.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
dto.FiledName = dto.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
@ -1,12 +1,16 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
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;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using YamlDotNet.Core.Tokens;
|
||||
using static FreeSql.Internal.GlobalFilter;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
@ -18,11 +22,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
|
||||
private readonly ILogger<AFN12_F188_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
|
||||
public AFN12_F188_Analysis(ILogger<AFN12_F188_Analysis> logger, AnalysisStrategyContext analysisStrategyContext)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN12_F188_Analysis(ILogger<AFN12_F188_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
@ -34,8 +39,18 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
ArgumentNullException.ThrowIfNull(input.AFN_FC.AFN);
|
||||
ArgumentNullException.ThrowIfNull(input.DT.Fn);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
AnalysisBaseDto<decimal?> data = GenerateFinalResult(input.UnitData.HexMessageList, dataType);
|
||||
string itemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
AnalysisBaseDto<decimal?> data = GenerateFinalResult(input.UnitData.HexMessageList, itemType);
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.DeviceType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ProjectId = ammeterInfo.ProjectID;
|
||||
data.DeviceId = ammeterInfo.MeterId;
|
||||
data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
data.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<decimal?>> dto = new UnitDataAnalysis<AnalysisBaseDto<decimal?>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
@ -43,13 +58,15 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.Second,
|
||||
TimeDensity = 0
|
||||
TimeDensity = 0,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
result?.Invoke(dto);
|
||||
await _dataStorage.SaveDataToIotDbAsync(dto);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -59,7 +76,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
}
|
||||
return await Task.FromResult(false);
|
||||
}
|
||||
public AnalysisBaseDto<decimal?> GenerateFinalResult(List<string> hexMessageList,string dataType)
|
||||
public AnalysisBaseDto<decimal?> GenerateFinalResult(List<string> hexMessageList,string itemType)
|
||||
{
|
||||
AnalysisBaseDto<decimal?> dto = new AnalysisBaseDto<decimal?>
|
||||
{
|
||||
@ -77,9 +94,9 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
if (decimal.TryParse($"{arr[11]}{arr[12]}{arr[13]}.{arr[14]}", out decimal value))
|
||||
dto.DataValue = value;
|
||||
}
|
||||
dto.DataType = dataType;
|
||||
dto.ItemType = itemType;
|
||||
dto.FiledDesc = "水示值";
|
||||
dto.FiledName = dto.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
dto.FiledName = dto.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
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;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@ -19,14 +22,15 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
private readonly ILogger<AFN12_F25_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
|
||||
public AFN12_F25_Analysis(ILogger<AFN12_F25_Analysis> logger, AnalysisStrategyContext analysisStrategyContext)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN12_F25_Analysis(ILogger<AFN12_F25_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public List<string> DataType { get; set; } = new List<string>() { "YGGL", "YGGL_A", "YGGL_B", "YGGL_C", "WGGL", "WGGL_A", "WGGL_B", "WGGL_C", "GLYS", "GLYS_A", "GLYS_B", "GLYS_C", "DY_A", "DY_B", "DY_C", "DL_A", "DL_B", "DL_C", "LXDL", "SZGL", "SZGL_A", "SZGL_B", "SZGL_C" };
|
||||
public List<string> ItemType { get; set; } = new List<string>() { "YGGL", "AYGGL", "BYGGL", "CYGGL", "WGGL", "AWGGL", "BWGGL", "CWGGL", "GLYS", "AGLYS", "BGLYS", "CGLYS", "ADY", "BDY", "CDY", "ADL", "BDL", "CDL", "LXDL", "SZGL", "ASZGL", "BSZGL", "CSZGL" };
|
||||
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
{
|
||||
@ -56,12 +60,29 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
dto.DataValue = value;
|
||||
}
|
||||
|
||||
dto.DataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}_{DataType[i-1]}";
|
||||
dto.FiledName = DataType[i - 1].GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
dto.ItemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}_{ItemType[i-1]}";
|
||||
dto.FiledName = ItemType[i - 1].GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
dto.TimeSpan = Convert.ToDateTime($"{data[0].Substring(0, 4)}-{data[0].Substring(4, 2)}-{data[0].Substring(6, 2)} {data[0].Substring(8, 2)}:{data[0].Substring(10, 2)}:00");
|
||||
dto.FiledDesc = remarks[i - 1];
|
||||
list.Add(dto);
|
||||
}
|
||||
if (list.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(list[0].ItemType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
list.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal?>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal?>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
@ -69,13 +90,15 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = list,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.Second,
|
||||
TimeDensity = 0
|
||||
TimeDensity = 0,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync(unitDataAnalysis);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@ -8,6 +8,10 @@ using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using System.Diagnostics.Metrics;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using static FreeSql.Internal.GlobalFilter;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
@ -18,11 +22,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
private readonly ILogger<AFN12_F2_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
|
||||
public AFN12_F2_Analysis(ILogger<AFN12_F2_Analysis> logger, AnalysisStrategyContext analysisStrategyContext)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN12_F2_Analysis(ILogger<AFN12_F2_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
@ -32,9 +37,19 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
string itemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
var data = await GenerateFinalResultAsync(input.UnitData.HexMessageList, dataType);
|
||||
var data = await GenerateFinalResultAsync(input.UnitData.HexMessageList, itemType);
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.DeviceType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ProjectId = ammeterInfo.ProjectID;
|
||||
data.DeviceId = ammeterInfo.MeterId;
|
||||
data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
data.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<string>> dto = new UnitDataAnalysis<AnalysisBaseDto<string>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
@ -42,13 +57,15 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.Second,
|
||||
TimeDensity = 0
|
||||
TimeDensity = 0,
|
||||
DataType = IOTDBDataTypeConst.Param,
|
||||
};
|
||||
result?.Invoke(dto);
|
||||
await _dataStorage.SaveDataToIotDbAsync(dto);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -59,7 +76,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
return await Task.FromResult(false);
|
||||
}
|
||||
|
||||
public async Task<AnalysisBaseDto<string>> GenerateFinalResultAsync(List<string> hexMessageList,string dataType)
|
||||
public async Task<AnalysisBaseDto<string>> GenerateFinalResultAsync(List<string> hexMessageList,string itemType)
|
||||
{
|
||||
AnalysisBaseDto<string> dto = new AnalysisBaseDto<string>();
|
||||
var arr = hexMessageList.GetRange(4, 6);
|
||||
@ -77,7 +94,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
dto.DataValue = $"{data.Item1} {data.Item2}";
|
||||
});
|
||||
}
|
||||
dto.DataType = dataType;
|
||||
dto.ItemType = itemType;
|
||||
dto.FiledName = "TerminalTime";
|
||||
dto.FiledDesc = "召读终端时间";
|
||||
return await Task.FromResult(dto);
|
||||
|
||||
@ -1,10 +1,16 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
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;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using static FreeSql.Internal.GlobalFilter;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
@ -16,14 +22,14 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
private List<string> DataUnitHexList { get; set; }=new List<string>();
|
||||
private readonly ILogger<AFN12_F33_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
|
||||
public AFN12_F33_Analysis(ILogger<AFN12_F33_Analysis> logger, AnalysisStrategyContext analysisStrategyContext)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN12_F33_Analysis(ILogger<AFN12_F33_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
{
|
||||
try
|
||||
@ -34,20 +40,38 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
|
||||
DataUnitHexList = input.UnitData.HexMessageList.GetRange(24, (5 * (rationgCount + 1)) + (4 * (rationgCount + 1)) * 3);
|
||||
GetDataUnitHexString(input.UnitData.HexMessageList, rationgCount);
|
||||
UnitDataAnalysis<AFN12_F33_AnalysisDto> unitDataAnalysis = new UnitDataAnalysis<AFN12_F33_AnalysisDto>
|
||||
var data = new AnalysisBaseDto<AFN12_F33_AnalysisDto?>()
|
||||
{
|
||||
FiledDesc = "当前正向有/无功电能示值、一/四象限无功电能示值",
|
||||
DataValue = await AnalysisDataUnit(input.UnitData.HexMessageList, rationgCount),
|
||||
ItemType= $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}"
|
||||
};
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.DeviceType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ProjectId = ammeterInfo.ProjectID;
|
||||
data.DeviceId = ammeterInfo.MeterId;
|
||||
data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
data.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<AFN12_F33_AnalysisDto?>> unitDataAnalysis = new UnitDataAnalysis<AnalysisBaseDto<AFN12_F33_AnalysisDto?>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = await AnalysisDataUnit(input.UnitData.HexMessageList, rationgCount),
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
Data = data,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.Second,
|
||||
TimeDensity = 0
|
||||
TimeDensity = 0,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
await _dataStorage.SaveDataToIotDbAsync(unitDataAnalysis);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -117,7 +141,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
ChildNodes model = new ChildNodes()
|
||||
{
|
||||
Value = value //29,4 33,4 37,4 41,4
|
||||
Value = value
|
||||
};
|
||||
children.Add(model);
|
||||
});
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
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;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@ -18,14 +21,15 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
{
|
||||
private readonly ILogger<AFN12_F49_Analysis> _logger;
|
||||
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
||||
|
||||
public AFN12_F49_Analysis(ILogger<AFN12_F49_Analysis> logger, AnalysisStrategyContext analysisStrategyContext)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN12_F49_Analysis(ILogger<AFN12_F49_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_analysisStrategyContext = analysisStrategyContext;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public List<string> DataType { get; set; } = new List<string>() { "Uab_Ua", "Ub", "Ucb_Uc", "Ia", "Ib", "Ic" };
|
||||
public List<string> ItemType { get; set; } = new List<string>() { "Uab_Ua", "Ub", "Ucb_Uc", "Ia", "Ib", "Ic" };
|
||||
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
{
|
||||
@ -53,11 +57,27 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
if(decimal.TryParse(data[i], out decimal value))
|
||||
dto.DataValue = value;
|
||||
}
|
||||
dto.DataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}_{DataType[i]}";
|
||||
dto.FiledName = dto.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
dto.ItemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}_{ItemType[i]}";
|
||||
dto.FiledName = dto.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
dto.FiledDesc= remarks[i];
|
||||
list.Add(dto);
|
||||
}
|
||||
if (list.Count > 0)
|
||||
{
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(list[0].DeviceType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
list.ForEach(item =>
|
||||
{
|
||||
item.ProjectId = ammeterInfo.ProjectID;
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
UnitDataAnalysis<List<AnalysisBaseDto<decimal?>>> unitDataAnalysis = new UnitDataAnalysis<List<AnalysisBaseDto<decimal?>>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
@ -65,13 +85,15 @@ namespace JiShe.CollectBus.Protocol.T37612012.AFN_0CH
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data= list,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.Second,
|
||||
TimeDensity = 0
|
||||
TimeDensity = 0,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync(unitDataAnalysis);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -65,11 +67,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度,注意这里会兼容存储做判断
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -50,6 +51,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -62,11 +64,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度,注意这里会兼容存储做判断
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -52,6 +52,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,7 +65,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度,注意这里会兼容存储做判断
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -36,9 +37,9 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
int density = Convert.ToInt32(Convert.ToInt32(datas[1]).GetEnumDescription(typeof(DensityEnums)));
|
||||
|
||||
string dataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
string itemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}";
|
||||
|
||||
List<AnalysisBaseDto<decimal?>> data = datas.GenerateFinalResultTd_c(3, density, dataType, "反向有功总电能示值");
|
||||
List<AnalysisBaseDto<decimal?>> data = datas.GenerateFinalResultTd_c(3, density, itemType, "反向有功总电能示值");
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,11 +66,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度,注意这里会兼容存储做判断
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -51,6 +52,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -63,11 +65,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度,注意这里会兼容存储做判断
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -51,6 +52,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -63,11 +65,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度,注意这里会兼容存储做判断
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -51,6 +52,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -63,11 +65,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度,注意这里会兼容存储做判断
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -50,6 +51,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -62,11 +64,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度,注意这里会兼容存储做判断
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -51,6 +52,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -63,11 +65,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -50,6 +51,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -62,11 +64,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
@ -148,10 +151,10 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
meter.DataType = i == 1 ? dataType : $"{dataType}_{ i - 1}";
|
||||
meter.ItemType = i == 1 ? dataType : $"{dataType}_{ i - 1}";
|
||||
filedDesc = i == 1 ? filedDesc : filedDesc.Replace("有功", "无功");
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
|
||||
list.Add(meter);
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -50,6 +51,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -62,11 +64,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -51,6 +52,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -63,11 +65,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -50,6 +51,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -62,11 +64,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -51,6 +52,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -63,11 +65,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
@ -50,6 +51,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -62,11 +64,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
@ -49,6 +50,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -61,11 +63,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
@ -62,11 +63,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
@ -49,6 +50,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -61,11 +63,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
@ -49,6 +50,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -61,11 +63,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
@ -49,6 +50,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -61,11 +63,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
@ -49,6 +50,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -61,11 +63,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
@ -49,6 +50,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -61,11 +63,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
@ -48,6 +49,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -60,11 +62,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -49,6 +50,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -61,11 +63,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -49,6 +50,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -61,11 +63,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
@ -48,6 +49,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -60,11 +62,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -49,6 +50,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -61,11 +63,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -49,6 +50,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -61,11 +63,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
@ -48,6 +49,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -60,11 +62,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -49,6 +50,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -61,11 +63,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -50,6 +51,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -62,11 +64,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -8,6 +9,7 @@ using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static FreeSql.Internal.GlobalFilter;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -45,6 +47,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
data.DeviceId = ammeterInfo.MeterId;
|
||||
data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
data.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<decimal?>> unitDataAnalysis = new UnitDataAnalysis<AnalysisBaseDto<decimal?>>
|
||||
{
|
||||
@ -55,11 +58,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
@ -136,9 +140,9 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
meter.DataType = dataType;
|
||||
meter.ItemType = dataType;
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
return meter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,8 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using static FreeSql.Internal.GlobalFilter;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -46,6 +48,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
data.DeviceId = ammeterInfo.MeterId;
|
||||
data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
data.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<decimal?>> unitDataAnalysis = new UnitDataAnalysis<AnalysisBaseDto<decimal?>>
|
||||
{
|
||||
@ -56,11 +59,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
@ -128,9 +132,9 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
meter.DataType = dataType;
|
||||
meter.ItemType = dataType;
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
return meter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,8 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using static FreeSql.Internal.GlobalFilter;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -46,6 +48,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
data.DeviceId = ammeterInfo.MeterId;
|
||||
data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
data.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<decimal?>> unitDataAnalysis = new UnitDataAnalysis<AnalysisBaseDto<decimal?>>
|
||||
{
|
||||
@ -56,11 +59,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Month,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
@ -128,9 +132,9 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
meter.DataType = dataType;
|
||||
meter.ItemType = dataType;
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
return meter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using YamlDotNet.Core.Tokens;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -51,6 +52,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -63,11 +65,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
@ -146,10 +149,10 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
meter.DataType = i == 1 ? dataType : $"{dataType}_{ i - 1}";
|
||||
meter.ItemType = i == 1 ? dataType : $"{dataType}_{ i - 1}";
|
||||
filedDesc = i == 1 ? filedDesc : filedDesc.Replace("有功", "无功");
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
list.Add(meter);
|
||||
}
|
||||
return list;
|
||||
|
||||
@ -11,6 +11,7 @@ using JiShe.CollectBus.Common.Extensions;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -54,6 +55,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -66,11 +68,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
@ -162,10 +165,10 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
else
|
||||
meter.TimeSpan=tsField;
|
||||
}
|
||||
meter.DataType = i == 1 ? dataType : $"{dataType}_{ i - 1}";
|
||||
meter.ItemType = i == 1 ? dataType : $"{dataType}_{ i - 1}";
|
||||
filedDesc = i == 1 ? filedDesc : filedDesc.Replace("有功", "无功");
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
list.Add(meter);
|
||||
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ using JiShe.CollectBus.Common.Extensions;
|
||||
using AutoMapper.Internal.Mappers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -53,6 +54,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -65,11 +67,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Day,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
@ -164,10 +167,10 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
else
|
||||
meter.TimeSpan = tsField;
|
||||
}
|
||||
meter.DataType = i == 1 ? dataType : $"{dataType}_{ i - 1}";
|
||||
meter.ItemType = i == 1 ? dataType : $"{dataType}_{ i - 1}";
|
||||
filedDesc = i == 1 ? filedDesc : filedDesc.Replace("有功", "无功");
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
list.Add(meter);
|
||||
}
|
||||
return list;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -51,6 +52,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -63,11 +65,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -9,6 +9,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,11 +66,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -9,6 +9,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,11 +66,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -51,6 +52,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -63,11 +65,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -9,6 +9,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,11 +66,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -9,6 +9,7 @@ using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,11 +66,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -51,6 +52,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -63,11 +65,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -9,6 +9,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,11 +66,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -9,6 +9,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,11 +66,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -9,6 +9,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,11 +66,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
@ -51,6 +52,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -63,11 +65,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -9,6 +9,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,11 +66,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -9,6 +9,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,11 +66,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -9,6 +9,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,11 +66,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -9,6 +9,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,11 +66,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -9,6 +9,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,11 +66,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -9,6 +9,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,11 +66,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -9,6 +9,7 @@ using JiShe.CollectBus.Protocol.T37612012.Appendix;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
{
|
||||
@ -52,6 +53,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
item.DeviceId = ammeterInfo.MeterId;
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,11 +66,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0DH
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = density,//密度-间隔分钟数,
|
||||
DensityUnit = DensityUnit.Minute,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
await _dataStorage.SaveMultipleDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
@ -55,6 +56,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0EH
|
||||
item.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
item.DeviceAddress = ammeterInfo.Address;
|
||||
item.DeviceType = MeterTypeEnum.Focus;
|
||||
item.FocusId = ammeterInfo.FocusId;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -65,11 +67,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_0EH
|
||||
Fn = input.DT.Fn,
|
||||
Pn = input.DA.Pn,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.None,
|
||||
TimeDensity = -1
|
||||
TimeDensity = -1,
|
||||
DataType = IOTDBDataTypeConst.Event,
|
||||
};
|
||||
// meterData.DataType = "0E_1";
|
||||
result?.Invoke(dto);
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
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;
|
||||
using JiShe.CollectBus.Protocol3761;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text;
|
||||
|
||||
namespace GatherService.WattMeter.AnalysisData.AFN_10H
|
||||
{
|
||||
@ -13,40 +18,59 @@ namespace GatherService.WattMeter.AnalysisData.AFN_10H
|
||||
public class AFN16_F101_Analysis : IAnalysisStrategy<TB3761>
|
||||
{
|
||||
private readonly ILogger<AFN16_F101_Analysis> _logger;
|
||||
|
||||
public AFN16_F101_Analysis(ILogger<AFN16_F101_Analysis> logger)
|
||||
private readonly DataStorage _dataStorage;
|
||||
public AFN16_F101_Analysis(ILogger<AFN16_F101_Analysis> logger, DataStorage dataStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
public Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(input);
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData.HexMessageList);
|
||||
UnitDataAnalysis<string> dto = new UnitDataAnalysis<string>
|
||||
var data = new AnalysisBaseDto<string?>()
|
||||
{
|
||||
FiledDesc = "透读取SIM卡信息",
|
||||
DataValue = AnalysisDataUnit(input.UnitData.HexMessageList),
|
||||
ItemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}"
|
||||
};
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.DeviceType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ProjectId = ammeterInfo.ProjectID;
|
||||
data.DeviceId = ammeterInfo.MeterId;
|
||||
data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
data.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
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 = AnalysisDataUnit(input.UnitData.HexMessageList), //SIM卡
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
Data = data, //SIM卡
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.None,
|
||||
TimeDensity = -1
|
||||
TimeDensity = -1,
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
};
|
||||
result?.Invoke(dto);
|
||||
return Task.FromResult(true);
|
||||
await _dataStorage.SaveDataToIotDbAsync<string?>(dto);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"10_101解析失败:{input.A?.Code}-{input.DT?.Fn ?? 0}-{input?.BaseHexMessage?.HexMessageString},{ex.Message}");
|
||||
|
||||
}
|
||||
return Task.FromResult(false);
|
||||
return await Task.FromResult(false);
|
||||
}
|
||||
private string AnalysisDataUnit(List<string> hexMessageList)
|
||||
{
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using GatherService.WattMeter.AnalysisData.AFN_10H;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
@ -41,6 +42,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H
|
||||
|
||||
List<string> datas = await AnalysisDataUnitAsync(input.UnitData.HexMessageList);
|
||||
AnalysisBaseDto<decimal?> data = GenerateFinalResult(datas);
|
||||
|
||||
// 查询电表信息
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.DeviceType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
@ -49,6 +51,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H
|
||||
data.DeviceId = ammeterInfo.MeterId;
|
||||
data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
data.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<decimal?>> unitDataAnalysis = new UnitDataAnalysis<AnalysisBaseDto<decimal?>>
|
||||
{
|
||||
@ -59,14 +62,17 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = data,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
TimeDensity = 1,//密度-间隔,
|
||||
DensityUnit = DensityUnit.Hour,
|
||||
ReceivedTime = input.ReceivedTime
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DataType = IOTDBDataTypeConst.Data
|
||||
|
||||
};
|
||||
await _dataStorage.SaveDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
await _dataStorage.SaveDataToIotDbAsync<decimal?>(unitDataAnalysis);
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -92,10 +98,10 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H
|
||||
meter.DataValue = value;
|
||||
}
|
||||
|
||||
meter.DataType = "10_97";
|
||||
meter.ItemType = "10_97";
|
||||
meter.ValidData = data[2].Equals("91") || data[2].Equals("B1");
|
||||
meter.FiledDesc = "电网频率";//"电网频率";
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
return meter;
|
||||
}
|
||||
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.Protocol;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
@ -33,17 +36,25 @@ namespace GatherService.WattMeter.AnalysisData.AFN_10H
|
||||
ArgumentNullException.ThrowIfNull(input.UnitData?.HexMessageList);
|
||||
|
||||
List<string> datas = AnalysisDataUnit(input.UnitData.HexMessageList);
|
||||
|
||||
|
||||
var data = new AnalysisBaseDto<bool?>()
|
||||
{
|
||||
FiledDesc = "跳合闸",
|
||||
DataValue = (datas[2].Equals("9C") || datas[2].Equals("94")) ? true : false,
|
||||
ItemType= "10_98",
|
||||
};
|
||||
|
||||
// 查询电表信息
|
||||
//AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.MeterType.ToString(), "15");
|
||||
//if (ammeterInfo != null)
|
||||
//{
|
||||
// data.ProjectId = ammeterInfo.ProjectID;
|
||||
// data.MeterId = ammeterInfo.MeterId;
|
||||
// data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
// data.MeterAddress = ammeterInfo.AmmerterAddress;
|
||||
//}
|
||||
UnitDataAnalysis<bool> unitDataAnalysis = new UnitDataAnalysis<bool>
|
||||
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(data.DeviceType.ToString(), "15");
|
||||
if (ammeterInfo != null)
|
||||
{
|
||||
data.ProjectId = ammeterInfo.ProjectID;
|
||||
data.DeviceId = ammeterInfo.MeterId;
|
||||
data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
||||
data.DeviceAddress = ammeterInfo.AmmerterAddress;
|
||||
data.FocusId = ammeterInfo.FocusId;
|
||||
}
|
||||
UnitDataAnalysis<AnalysisBaseDto<bool?>> unitDataAnalysis = new UnitDataAnalysis<AnalysisBaseDto<bool?>>
|
||||
{
|
||||
Code = input.A.Code!,
|
||||
AFN = input.AFN_FC.AFN,
|
||||
@ -51,15 +62,16 @@ namespace GatherService.WattMeter.AnalysisData.AFN_10H
|
||||
Pn = input.DA.Pn,
|
||||
MSA = input.A.A3!.D1_D7!,
|
||||
PSEQ = input.SEQ.PSEQ,
|
||||
Data = (datas[2].Equals("9C") || datas[2].Equals("94")) ? true : false,
|
||||
HexMessage = input.BaseHexMessage.HexMessageString,
|
||||
Data = data,
|
||||
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
||||
MessageId = input.MessageId,
|
||||
ReceivedTime = input.ReceivedTime,
|
||||
DensityUnit = DensityUnit.None,
|
||||
TimeDensity = -1
|
||||
TimeDensity = -1,
|
||||
DataType = IOTDBDataTypeConst.Data
|
||||
};
|
||||
//await _dataStorage.SaveDataToIotDbAsync<decimal>(unitDataAnalysis);
|
||||
result?.Invoke(unitDataAnalysis);
|
||||
await _dataStorage.SaveDataToIotDbAsync(unitDataAnalysis);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@ -10,11 +10,15 @@ using JiShe.CollectBus.IoTDB.Model;
|
||||
using JiShe.CollectBus.IoTDB.Options;
|
||||
using JiShe.CollectBus.IoTDB.Provider;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.IotSystems.LogRecord;
|
||||
using JiShe.CollectBus.IotSystems.MeterReadingRecords;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Metrics;
|
||||
using System.Threading.Channels;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Guids;
|
||||
using static FreeSql.Internal.GlobalFilter;
|
||||
@ -28,12 +32,36 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
private readonly IIoTDbProvider _dbProvider;
|
||||
private readonly ServerApplicationOptions _applicationOptions;
|
||||
private readonly IoTDBRuntimeContext _runtimeContext;
|
||||
public DataStorage(IIoTDbProvider dbProvider, IOptions<ServerApplicationOptions> applicationOptions, IGuidGenerator guidGenerator, IoTDBRuntimeContext runtimeContext)
|
||||
private readonly ILogger<DataStorage> _logger;
|
||||
|
||||
public DataStorage(IIoTDbProvider dbProvider, IOptions<ServerApplicationOptions> applicationOptions,
|
||||
IGuidGenerator guidGenerator, IoTDBRuntimeContext runtimeContext, ILogger<DataStorage> logger)
|
||||
{
|
||||
_dbProvider= dbProvider;
|
||||
_applicationOptions = applicationOptions.Value;
|
||||
_guidGenerator= guidGenerator;
|
||||
_runtimeContext= runtimeContext;
|
||||
_logger= logger;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 日志保存通道写入
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task LogSaveWriterAsync(ChannelWriter<object> channelWriter, dynamic dataItems)
|
||||
{
|
||||
await channelWriter.WriteAsync(dataItems);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 日志刷新通道写入
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task LogRefreshSaveWriterAsync(ChannelWriter<object> channelWriter, dynamic dataItems)
|
||||
{
|
||||
await channelWriter.WriteAsync(dataItems);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -95,7 +123,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
DeviceId = $"{data.DeviceId}",
|
||||
DeviceType = $"{data.DeviceType.ToString()}",
|
||||
ProjectId = $"{data.ProjectId}",
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
DataType = analysisBaseDto.DataType,
|
||||
Timestamps = data.TimeSpan!.Value.GetFormatTime(analysisBaseDto.DensityUnit, analysisBaseDto.TimeDensity).GetDateTimeOffset().ToUnixTimeNanoseconds(),
|
||||
SingleMeasuring = (data.FiledName ?? string.Empty, data.DataValue ?? default)
|
||||
};
|
||||
@ -107,7 +135,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
// 更新
|
||||
meter.Timestamps = taskData.PendingCopyReadTime.GetDateTimeOffset().ToUnixTimeNanoseconds();
|
||||
taskData.IsReceived=true;
|
||||
taskData.ReceivedMessageHexString= analysisBaseDto.HexMessage;
|
||||
taskData.ReceivedMessageHexString= analysisBaseDto.ReceivedHexMessage;
|
||||
taskData.ReceivedMessageId= analysisBaseDto.MessageId ?? string.Empty;
|
||||
}
|
||||
else
|
||||
@ -120,28 +148,32 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
ProjectId = $"{data.ProjectId}",
|
||||
DeviceType = $"{data.DeviceType}",
|
||||
DeviceId = $"{data.DeviceId}",
|
||||
DataType = analysisBaseDto.DataType,
|
||||
FocusId = data.FocusId,
|
||||
FocusAddress = analysisBaseDto.Code,
|
||||
Timestamps = DateTime.Now.GetDateTimeOffset().ToUnixTimeNanoseconds(),
|
||||
DatabaseBusiID = data.DatabaseBusiID,
|
||||
PendingCopyReadTime = data.TimeSpan.Value.GetFormatTime(analysisBaseDto.DensityUnit, analysisBaseDto.TimeDensity),
|
||||
PendingCopyReadTime = data.TimeSpan.Value.GetFormatTime(analysisBaseDto.DensityUnit, analysisBaseDto.TimeDensity),
|
||||
CreationTime = currentTime,
|
||||
MeterAddress = data.DeviceAddress,
|
||||
MeterAddress = analysisBaseDto.Code == data.DeviceAddress ? "" : data.DeviceAddress, // 判断是否能取到表地址
|
||||
AFN = analysisBaseDto.AFN,
|
||||
Fn = analysisBaseDto.Fn,
|
||||
Seq = analysisBaseDto.PSEQ,
|
||||
MSA = analysisBaseDto.MSA,
|
||||
ItemCode = data.DataType,
|
||||
ItemCode = data.ItemType,
|
||||
TaskMark = taskMark,
|
||||
IsSend = false,
|
||||
ManualOrNot = false,
|
||||
Pn = analysisBaseDto.Pn,
|
||||
ReceivedMessageId = analysisBaseDto.MessageId?? string.Empty,
|
||||
ReceivedMessageHexString = analysisBaseDto.HexMessage,
|
||||
ReceivedMessageId = analysisBaseDto.MessageId ?? string.Empty,
|
||||
ReceivedMessageHexString = analysisBaseDto.ReceivedHexMessage,
|
||||
IsReceived = true,
|
||||
ReceivedRemark = data.ErrorCodeMsg ?? string.Empty,
|
||||
ScoreValue = $"{analysisBaseDto.Code}.{taskMark}".Md5Fun(),
|
||||
ReceivedTime = analysisBaseDto.ReceivedTime,
|
||||
};
|
||||
}
|
||||
|
||||
_runtimeContext.UseTableSessionPool = true; // 使树模型池
|
||||
await _dbProvider.InsertAsync(taskData);
|
||||
//如果无字段名,则不保存数据
|
||||
if (!string.IsNullOrWhiteSpace(data.FiledName))
|
||||
@ -158,12 +190,13 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="analysisBaseDto"></param>
|
||||
/// <param name="saveData"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> SaveMultipleDataToIotDbAsync<T>(UnitDataAnalysis<List<AnalysisBaseDto<T>>> analysisBaseDto)
|
||||
{
|
||||
var data = analysisBaseDto.Data!;
|
||||
List<MeterReadingTelemetryPacketInfo> meterReadingTelemetryPacketInfos = new List<MeterReadingTelemetryPacketInfo>();
|
||||
List< TreeModelSingleMeasuringEntity<T>> treeModelSingleMeasuringEntities = new List<TreeModelSingleMeasuringEntity<T>>();
|
||||
List<TreeModelSingleMeasuringEntity<T>> treeModelSingleMeasuringEntities = new List<TreeModelSingleMeasuringEntity<T>>();
|
||||
foreach (var item in data)
|
||||
{
|
||||
if(!item.TimeSpan.HasValue)
|
||||
@ -199,7 +232,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
DeviceId = $"{item.DeviceId}",
|
||||
DeviceType = $"{item.DeviceType}",
|
||||
ProjectId = $"{item.ProjectId}",
|
||||
DataType = IOTDBDataTypeConst.Data,
|
||||
DataType = analysisBaseDto.DataType,
|
||||
Timestamps = item.TimeSpan!.Value.GetFormatTime(analysisBaseDto.DensityUnit, analysisBaseDto.TimeDensity).GetDateTimeOffset().ToUnixTimeNanoseconds(), // TODO:这里暂时格式化15分钟数据,需要进行调整
|
||||
SingleMeasuring =(item.FiledName ?? string.Empty, item.DataValue ?? default)
|
||||
};
|
||||
@ -211,7 +244,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
// 更新
|
||||
meter.Timestamps = taskData.PendingCopyReadTime.GetDateTimeOffset().ToUnixTimeNanoseconds();
|
||||
taskData.IsReceived = true;
|
||||
taskData.ReceivedMessageHexString = analysisBaseDto.HexMessage;
|
||||
taskData.ReceivedMessageHexString = analysisBaseDto.ReceivedHexMessage;
|
||||
taskData.ReceivedMessageId = analysisBaseDto.MessageId ?? string.Empty;
|
||||
}
|
||||
else
|
||||
@ -223,36 +256,41 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
SystemName = _applicationOptions.SystemType,
|
||||
ProjectId = $"{item.ProjectId}",
|
||||
DeviceType = $"{item.DeviceType}",
|
||||
DeviceId = $"{item.DeviceId}",
|
||||
DeviceId = $"{item.DeviceId}",
|
||||
DataType = IOTDBDataTypeConst.Log, // 匹配不到下发记录标记为LOG
|
||||
Timestamps = DateTime.Now.CheckTimePoint().GetDateTimeOffset().ToUnixTimeNanoseconds(),
|
||||
DatabaseBusiID = item.DatabaseBusiID,
|
||||
PendingCopyReadTime = item.TimeSpan.Value.GetFormatTime(analysisBaseDto.DensityUnit, analysisBaseDto.TimeDensity),
|
||||
CreationTime = currentTime,
|
||||
MeterAddress = item.DeviceAddress,
|
||||
FocusId = item.FocusId,
|
||||
FocusAddress = analysisBaseDto.Code,
|
||||
MeterAddress = analysisBaseDto.Code == item.DeviceAddress ? "" : item.DeviceAddress, // 判断是否能取到表地址
|
||||
AFN = analysisBaseDto.AFN,
|
||||
Fn = analysisBaseDto.Fn,
|
||||
Seq = analysisBaseDto.PSEQ,
|
||||
MSA = analysisBaseDto.MSA,
|
||||
ItemCode = item.DataType,
|
||||
ItemCode = item.ItemType,
|
||||
TaskMark = taskMark,
|
||||
IsSend = false,
|
||||
ManualOrNot = false,
|
||||
Pn = analysisBaseDto.Pn,
|
||||
ReceivedMessageId = analysisBaseDto.MessageId ?? string.Empty,
|
||||
ReceivedMessageHexString = analysisBaseDto.HexMessage,
|
||||
ReceivedMessageHexString = analysisBaseDto.ReceivedHexMessage,
|
||||
IsReceived = true,
|
||||
ReceivedRemark = item.ErrorCodeMsg ?? string.Empty,
|
||||
ScoreValue = $"{analysisBaseDto.Code}.{taskMark}".Md5Fun(),
|
||||
ReceivedTime = analysisBaseDto.ReceivedTime,
|
||||
};
|
||||
}
|
||||
meterReadingTelemetryPacketInfos.Add(taskData);
|
||||
//如果无字段名,则不保存数据
|
||||
//如果无字段名,则不保存数据,如saveData=false 也不保存数据
|
||||
if (!string.IsNullOrWhiteSpace(item.FiledName))
|
||||
{
|
||||
treeModelSingleMeasuringEntities.Add(meter);
|
||||
}
|
||||
}
|
||||
// 批量保存数据
|
||||
_runtimeContext.UseTableSessionPool = true; // 使树模型池
|
||||
await _dbProvider.BatchInsertAsync(meterReadingTelemetryPacketInfos);
|
||||
if (treeModelSingleMeasuringEntities.Count > 0)
|
||||
{
|
||||
@ -273,6 +311,8 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
ArgumentNullException.ThrowIfNull(nameof(analysisBaseDto.Data));
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(nameof(analysisBaseDto.Data.FiledName));
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(nameof(analysisBaseDto.Data.DataValue));
|
||||
List<TreeModelSingleMeasuringEntity<T>> treeModelSingleMeasuringEntities = new List<TreeModelSingleMeasuringEntity<T>>();
|
||||
|
||||
var data = analysisBaseDto.Data!;
|
||||
if (!data.TimeSpan.HasValue)
|
||||
data.TimeSpan = analysisBaseDto.ReceivedTime;
|
||||
@ -284,7 +324,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
DeviceId = $"{data.DeviceId}",
|
||||
DeviceType = $"{data.DeviceType}",
|
||||
ProjectId = $"{data.ProjectId}",
|
||||
DataType = IOTDBDataTypeConst.Status,
|
||||
DataType = analysisBaseDto.DataType,
|
||||
Timestamps = timestamps,
|
||||
SingleMeasuring = (data.FiledName!, data.DataValue!)
|
||||
};
|
||||
@ -297,41 +337,64 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
DeviceId = $"{data.DeviceId}",
|
||||
DeviceType = $"{data.DeviceType}",
|
||||
ProjectId = $"{data.ProjectId}",
|
||||
DataType = IOTDBDataTypeConst.Status,
|
||||
DataType = analysisBaseDto.DataType,
|
||||
Timestamps = timestamps,
|
||||
SingleMeasuring = (ConcentratorStatusFieldConst.FrameData, analysisBaseDto.HexMessage ?? string.Empty)
|
||||
SingleMeasuring = (ConcentratorStatusFieldConst.FrameData, analysisBaseDto.ReceivedHexMessage ?? string.Empty)
|
||||
};
|
||||
|
||||
_runtimeContext.UseTableSessionPool = false; // 使树模型池
|
||||
await _dbProvider.InsertAsync(treeFrameData);
|
||||
|
||||
// 时间
|
||||
var treeRecordingTimeData = new TreeModelSingleMeasuringEntity<long>()
|
||||
var treeRecordingTimeData = new TreeModelSingleMeasuringEntity<DateTime>()
|
||||
{
|
||||
SystemName = _applicationOptions.SystemType,
|
||||
DeviceId = $"{data.DeviceId}",
|
||||
DeviceType = $"{data.DeviceType}",
|
||||
ProjectId = $"{data.ProjectId}",
|
||||
Timestamps = timestamps,
|
||||
DataType = IOTDBDataTypeConst.Status,
|
||||
SingleMeasuring = (ConcentratorStatusFieldConst.RecordingTime, (data.TimeSpan.HasValue ? data.TimeSpan.Value : DateTime.Now).GetDateTimeOffset().ToUnixTimeNanoseconds())
|
||||
DataType = analysisBaseDto.DataType,
|
||||
SingleMeasuring = (ConcentratorStatusFieldConst.RecordingTime, data.TimeSpan.HasValue ? data.TimeSpan.Value : DateTime.Now)
|
||||
};
|
||||
_runtimeContext.UseTableSessionPool = false; // 使树模型池
|
||||
await _dbProvider.InsertAsync(treeRecordingTimeData);
|
||||
// 备注
|
||||
var treeRemarkData = new TreeModelSingleMeasuringEntity<string>()
|
||||
|
||||
// 新建
|
||||
string taskMark = CommonHelper.GetTaskMark(analysisBaseDto.AFN, analysisBaseDto.Fn, analysisBaseDto.Pn, analysisBaseDto.MSA, analysisBaseDto.PSEQ);
|
||||
var currentTime = DateTime.Now;
|
||||
var taskData = new MeterReadingTelemetryPacketInfo()
|
||||
{
|
||||
SystemName = _applicationOptions.SystemType,
|
||||
DeviceId = $"{data.DeviceId}",
|
||||
DeviceType = $"{data.DeviceType}",
|
||||
ProjectId = $"{data.ProjectId}",
|
||||
DataType = IOTDBDataTypeConst.Status,
|
||||
Timestamps = timestamps,
|
||||
SingleMeasuring = (ConcentratorStatusFieldConst.Remark, data.FiledDesc ?? string.Empty)
|
||||
DeviceType = $"{data.DeviceType}",
|
||||
DeviceId = $"{data.DeviceId}",
|
||||
DataType = analysisBaseDto.DataType,
|
||||
FocusId = data.FocusId,
|
||||
FocusAddress = analysisBaseDto.Code,
|
||||
Timestamps = DateTime.Now.GetDateTimeOffset().ToUnixTimeNanoseconds(),
|
||||
DatabaseBusiID = data.DatabaseBusiID,
|
||||
PendingCopyReadTime = data.TimeSpan!.Value.GetFormatTime(analysisBaseDto.DensityUnit, analysisBaseDto.TimeDensity),
|
||||
CreationTime = currentTime,
|
||||
MeterAddress = analysisBaseDto.Code == data.DeviceAddress ? "" : data.DeviceAddress,// 判断是否能取到表地址
|
||||
AFN = analysisBaseDto.AFN,
|
||||
Fn = analysisBaseDto.Fn,
|
||||
Seq = analysisBaseDto.PSEQ,
|
||||
MSA = analysisBaseDto.MSA,
|
||||
ItemCode = data.ItemType,
|
||||
TaskMark = taskMark,
|
||||
IsSend = false,
|
||||
ManualOrNot = false,
|
||||
Pn = analysisBaseDto.Pn,
|
||||
ReceivedMessageId = analysisBaseDto.MessageId ?? string.Empty,
|
||||
ReceivedMessageHexString = analysisBaseDto.ReceivedHexMessage,
|
||||
IsReceived = true,
|
||||
ReceivedRemark = data.ErrorCodeMsg ?? string.Empty,
|
||||
ScoreValue = $"{analysisBaseDto.Code}.{taskMark}".Md5Fun(),
|
||||
ReceivedTime=analysisBaseDto.ReceivedTime,
|
||||
};
|
||||
_runtimeContext.UseTableSessionPool = false; // 使树模型池
|
||||
await _dbProvider.InsertAsync(treeRemarkData);
|
||||
|
||||
_runtimeContext.UseTableSessionPool = true; // 使表模型池
|
||||
await _dbProvider.InsertAsync(taskData);
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
@ -344,7 +407,8 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
public async Task<bool> SaveMultipleStatusToIotDbAsync<T>(UnitDataAnalysis<List<AnalysisBaseDto<T>>> analysisBaseDto)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(nameof(analysisBaseDto.Data));
|
||||
|
||||
List<MeterReadingTelemetryPacketInfo> meterReadingTelemetryPacketInfos = new List<MeterReadingTelemetryPacketInfo>();
|
||||
|
||||
var data = analysisBaseDto.Data!;
|
||||
foreach (var item in data)
|
||||
{
|
||||
@ -361,7 +425,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
DeviceId = $"{item.DeviceId}",
|
||||
DeviceType = $"{item.DeviceType}",
|
||||
ProjectId = $"{item.ProjectId}",
|
||||
DataType = IOTDBDataTypeConst.Status,
|
||||
DataType = analysisBaseDto.DataType,
|
||||
Timestamps = timestamps,
|
||||
SingleMeasuring = (item.FiledName!, item.DataValue!)
|
||||
};
|
||||
@ -373,41 +437,71 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
SystemName = _applicationOptions.SystemType,
|
||||
DeviceType = $"{item.DeviceType}",
|
||||
ProjectId = $"{item.ProjectId}",
|
||||
DataType = IOTDBDataTypeConst.Status,
|
||||
DataType = analysisBaseDto.DataType,
|
||||
Timestamps = timestamps,
|
||||
SingleMeasuring = (ConcentratorStatusFieldConst.FrameData, analysisBaseDto.HexMessage ?? string.Empty)
|
||||
SingleMeasuring = (ConcentratorStatusFieldConst.FrameData, analysisBaseDto.ReceivedHexMessage ?? string.Empty)
|
||||
};
|
||||
|
||||
_runtimeContext.UseTableSessionPool = false; // 使树模型池
|
||||
await _dbProvider.InsertAsync(treeFrameData);
|
||||
|
||||
// 时间
|
||||
var treeRecordingTimeData = new TreeModelSingleMeasuringEntity<long>()
|
||||
var treeRecordingTimeData = new TreeModelSingleMeasuringEntity<DateTime>()
|
||||
{
|
||||
SystemName = _applicationOptions.SystemType,
|
||||
DeviceType = $"{item.DeviceType}",
|
||||
ProjectId = $"{item.ProjectId}",
|
||||
DataType = IOTDBDataTypeConst.Status,
|
||||
DataType = analysisBaseDto.DataType,
|
||||
Timestamps = timestamps,
|
||||
SingleMeasuring = (ConcentratorStatusFieldConst.RecordingTime, (item.TimeSpan.HasValue ? item.TimeSpan.Value : DateTime.Now).GetDateTimeOffset().ToUnixTimeNanoseconds())
|
||||
SingleMeasuring = (ConcentratorStatusFieldConst.RecordingTime, item.TimeSpan.HasValue ? item.TimeSpan.Value : DateTime.Now)
|
||||
};
|
||||
_runtimeContext.UseTableSessionPool = false; // 使树模型池
|
||||
await _dbProvider.InsertAsync(treeRecordingTimeData);
|
||||
// 备注
|
||||
var treeRemarkData = new TreeModelSingleMeasuringEntity<string>()
|
||||
|
||||
// 新建
|
||||
string taskMark = CommonHelper.GetTaskMark(analysisBaseDto.AFN, analysisBaseDto.Fn, analysisBaseDto.Pn, analysisBaseDto.MSA, analysisBaseDto.PSEQ);
|
||||
var currentTime = DateTime.Now;
|
||||
var taskData = new MeterReadingTelemetryPacketInfo()
|
||||
{
|
||||
SystemName = _applicationOptions.SystemType,
|
||||
DeviceType = $"{item.DeviceType}",
|
||||
ProjectId = $"{item.ProjectId}",
|
||||
DataType = IOTDBDataTypeConst.Status,
|
||||
Timestamps = timestamps,
|
||||
SingleMeasuring =(ConcentratorStatusFieldConst.Remark, item.FiledDesc ?? string.Empty)
|
||||
DeviceType = $"{item.DeviceType}",
|
||||
DeviceId = $"{item.DeviceId}",
|
||||
DataType = analysisBaseDto.DataType,
|
||||
Timestamps = DateTime.Now.GetDateTimeOffset().ToUnixTimeNanoseconds(),
|
||||
DatabaseBusiID = item.DatabaseBusiID,
|
||||
PendingCopyReadTime = item.TimeSpan!.Value.GetFormatTime(analysisBaseDto.DensityUnit, analysisBaseDto.TimeDensity),
|
||||
CreationTime = currentTime,
|
||||
FocusId = item.FocusId,
|
||||
FocusAddress = analysisBaseDto.Code,
|
||||
MeterAddress= analysisBaseDto.Code== item.DeviceAddress?"": item.DeviceAddress,// 判断是否能取到表地址
|
||||
AFN = analysisBaseDto.AFN,
|
||||
Fn = analysisBaseDto.Fn,
|
||||
Seq = analysisBaseDto.PSEQ,
|
||||
MSA = analysisBaseDto.MSA,
|
||||
ItemCode = item.ItemType,
|
||||
TaskMark = taskMark,
|
||||
IsSend = false,
|
||||
ManualOrNot = false,
|
||||
Pn = analysisBaseDto.Pn,
|
||||
ReceivedMessageId = analysisBaseDto.MessageId ?? string.Empty,
|
||||
ReceivedMessageHexString = analysisBaseDto.ReceivedHexMessage,
|
||||
IsReceived = true,
|
||||
ReceivedRemark = item.ErrorCodeMsg ?? string.Empty,
|
||||
ScoreValue = $"{analysisBaseDto.Code}.{taskMark}".Md5Fun(),
|
||||
ReceivedTime = analysisBaseDto.ReceivedTime,
|
||||
};
|
||||
_runtimeContext.UseTableSessionPool = false; // 使树模型池
|
||||
await _dbProvider.InsertAsync(treeRemarkData);
|
||||
|
||||
meterReadingTelemetryPacketInfos.Add(taskData);
|
||||
}
|
||||
if (meterReadingTelemetryPacketInfos.Count > 0)
|
||||
{
|
||||
_runtimeContext.UseTableSessionPool = true; // 使表模型池
|
||||
await _dbProvider.BatchInsertAsync(meterReadingTelemetryPacketInfos);
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
using System.Reflection;
|
||||
using System.Threading.Channels;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.T37612012.AnalysisData;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Volo.Abp;
|
||||
|
||||
@ -262,9 +262,9 @@ namespace JiShe.CollectBus.Protocol.T37612012
|
||||
meter.DataValue = value;
|
||||
}
|
||||
}
|
||||
meter.DataType = dataType;
|
||||
meter.ItemType = dataType;
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
if (DateTime.TryParse(CalculateTimeSpan(i - 3, data[0], density), out DateTime readingDate))
|
||||
meter.TimeSpan = readingDate;
|
||||
list.Add(meter);
|
||||
@ -305,9 +305,9 @@ namespace JiShe.CollectBus.Protocol.T37612012
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
meter.DataType = i - index == 0 ? dataType : $"{dataType}_{i - index}";
|
||||
meter.ItemType = i - index == 0 ? dataType : $"{dataType}_{i - index}";
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
list.Add(meter);
|
||||
}
|
||||
return list;
|
||||
@ -348,9 +348,9 @@ namespace JiShe.CollectBus.Protocol.T37612012
|
||||
{
|
||||
meter.TimeSpan = readingDate;
|
||||
}
|
||||
meter.DataType = i - index == 0 ? dataType : $"{dataType}_{i - index}";
|
||||
meter.ItemType = i - index == 0 ? dataType : $"{dataType}_{i - index}";
|
||||
meter.FiledDesc = filedDesc;
|
||||
meter.FiledName = meter.DataType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
meter.FiledName = meter.ItemType.GetDataFieldByGatherDataType() ?? string.Empty;
|
||||
list.Add(meter);
|
||||
typeIndex++;
|
||||
}
|
||||
@ -385,7 +385,7 @@ namespace JiShe.CollectBus.Protocol.T37612012
|
||||
if (item.ValidData && item.DataValue.HasValue)
|
||||
jfpgSum += item.DataValue.Value;
|
||||
}
|
||||
var totalItem = meterDatas.FirstOrDefault(f => f.DataType.Equals(mark[0]));//meterDatas.Find(f => f.DataType.Equals(mark[0]));
|
||||
var totalItem = meterDatas.FirstOrDefault(f => f.ItemType.Equals(mark[0]));//meterDatas.Find(f => f.DataType.Equals(mark[0]));
|
||||
if (totalItem != null)
|
||||
{
|
||||
var floatingNum = (jfpgSum * 5 / 100);//上下浮动数据
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="TouchSocket" Version="3.1.0" />
|
||||
<PackageReference Include="TouchSocket" Version="3.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.Common.Models;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -34,14 +35,31 @@ namespace JiShe.CollectBus.Application.Contracts
|
||||
/// <param name="redisHashCacheKey">主数据存储Hash缓存Key</param>
|
||||
/// <param name="redisSetIndexCacheKey">Set索引缓存Key</param>
|
||||
/// <param name="redisZSetScoresIndexCacheKey">ZSET索引缓存Key</param>
|
||||
/// <param name="redisDeviceInfoHashCacheKey">设备缓存信息</param>
|
||||
/// <param name="items">待缓存数据集合</param>
|
||||
/// <returns></returns>
|
||||
Task BatchInsertDataAsync<T>(
|
||||
string redisHashCacheKey,
|
||||
string redisSetIndexCacheKey,
|
||||
string redisZSetScoresIndexCacheKey,
|
||||
string redisDeviceInfoHashCacheKey,
|
||||
IEnumerable<T> items) where T : DeviceCacheBasicModel;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 批量添加数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="redisSetIndexCacheKey">Set索引缓存Key</param>
|
||||
/// <param name="redisDeviceInfoHashCacheKey">设备缓存信息</param>
|
||||
/// <param name="items">待缓存数据集合</param>
|
||||
/// <returns></returns>
|
||||
Task BatchInsertDataAsync2<T>(
|
||||
string redisSetIndexCacheKey,
|
||||
string redisDeviceInfoHashCacheKey,
|
||||
Dictionary<string, List<T>> items) where T : DeviceCacheBasicModel;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除缓存信息
|
||||
/// </summary>
|
||||
@ -123,7 +141,7 @@ namespace JiShe.CollectBus.Application.Contracts
|
||||
/// <param name="lastMember">最后一个唯一标识</param>
|
||||
/// <param name="descending">排序方式</param>
|
||||
/// <returns></returns>
|
||||
Task<BusCacheGlobalPagedResult<T>> GetPagedData<T>(
|
||||
Task<BusCacheGlobalPagedResult<T>> GetSingleData<T>(
|
||||
string redisHashCacheKey,
|
||||
string redisZSetScoresIndexCacheKey,
|
||||
string scoreValueRawData,
|
||||
|
||||
@ -1,13 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using Cassandra.Mapping;
|
||||
using Cassandra.Mapping;
|
||||
using JiShe.CollectBus.Cassandra;
|
||||
using JiShe.CollectBus.DataChannels;
|
||||
using JiShe.CollectBus.DataMigration.Options;
|
||||
using JiShe.CollectBus.FreeRedis;
|
||||
using JiShe.CollectBus.FreeSql;
|
||||
using JiShe.CollectBus.Interceptors;
|
||||
@ -16,9 +9,14 @@ using JiShe.CollectBus.IotSystems.MeterReadingRecords;
|
||||
using JiShe.CollectBus.Kafka;
|
||||
using JiShe.CollectBus.Mappers;
|
||||
using JiShe.CollectBus.Protocol;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.ScheduledMeterReading;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application;
|
||||
using Volo.Abp.Autofac;
|
||||
@ -83,6 +81,17 @@ public class CollectBusApplicationModule : AbpModule
|
||||
//下发任务通道构建
|
||||
DataChannelManage.TaskDataChannel = Channel.CreateUnbounded<ValueTuple<string, List<MeterReadingTelemetryPacketInfo>>>();
|
||||
|
||||
|
||||
// 日志存储通道构建
|
||||
DataChannelManage.LogSaveChannel = Channel.CreateUnbounded<object>();
|
||||
|
||||
// 日志刷新通道构建
|
||||
DataChannelManage.LogRefreshChannel = Channel.CreateUnbounded<object>();
|
||||
|
||||
// 启动通道任务
|
||||
var _dataChannelManage = context.ServiceProvider.GetRequiredService<DataChannelManageService>();
|
||||
_ = _dataChannelManage.LogSaveAsync(DataChannelManage.LogSaveChannel.Reader);
|
||||
|
||||
//默认初始化表计信息
|
||||
var dbContext = context.ServiceProvider.GetRequiredService<EnergySystemScheduledMeterReadingService>();
|
||||
_= dbContext.InitAmmeterCacheData();
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.CollectBus.IotSystems.MeterReadingRecords;
|
||||
using JiShe.CollectBus.Protocol.Dto;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -14,5 +15,16 @@ namespace JiShe.CollectBus.DataChannels
|
||||
/// 下发任务通道
|
||||
/// </summary>
|
||||
public static Channel<ValueTuple<string, List<MeterReadingTelemetryPacketInfo>>> TaskDataChannel;
|
||||
|
||||
/// <summary>
|
||||
/// 日志保存管道
|
||||
/// </summary>
|
||||
public static Channel<object> LogSaveChannel;
|
||||
|
||||
/// <summary>
|
||||
/// 日志刷新管道
|
||||
/// </summary>
|
||||
public static Channel<object> LogRefreshChannel;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user