修改代码
This commit is contained in:
parent
53b4e16f2d
commit
25989539bf
@ -6,3 +6,4 @@ global using JiShe.ServicePro.Enums;
|
||||
global using JiShe.ServicePro.FreeRedisProvider;
|
||||
global using JiShe.ServicePro.Consts;
|
||||
global using JiShe.ServicePro.Core;
|
||||
global using JiShe.ServicePro.ServerOptions;
|
||||
@ -6,3 +6,4 @@ global using JiShe.ServicePro.Enums;
|
||||
global using JiShe.ServicePro.FreeRedisProvider;
|
||||
global using JiShe.ServicePro.Consts;
|
||||
global using JiShe.ServicePro.Core;
|
||||
global using JiShe.ServicePro.ServerOptions;
|
||||
@ -6,3 +6,4 @@ global using JiShe.ServicePro.Enums;
|
||||
global using JiShe.ServicePro.FreeRedisProvider;
|
||||
global using JiShe.ServicePro.Consts;
|
||||
global using JiShe.ServicePro.Core;
|
||||
global using JiShe.ServicePro.ServerOptions;
|
||||
9
protocols/JiShe.CollectBus.Protocol/GlobalUsings.cs
Normal file
9
protocols/JiShe.CollectBus.Protocol/GlobalUsings.cs
Normal file
@ -0,0 +1,9 @@
|
||||
// Global using directives
|
||||
|
||||
global using System.Text;
|
||||
global using Volo.Abp.Modularity;
|
||||
global using JiShe.ServicePro.Enums;
|
||||
global using JiShe.ServicePro.FreeRedisProvider;
|
||||
global using JiShe.ServicePro.Consts;
|
||||
global using JiShe.ServicePro.Core;
|
||||
global using JiShe.ServicePro.ServerOptions;
|
||||
@ -183,129 +183,5 @@ namespace JiShe.CollectBus.DataChannels
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 日志保存
|
||||
///// </summary>
|
||||
///// <param name="channelReader"></param>
|
||||
///// <returns></returns>
|
||||
//public async Task LogSaveAsync(ChannelReader<object> channelReader)
|
||||
//{
|
||||
// const int BatchSize = 1000;
|
||||
// const int EmptyWaitMilliseconds = 1000;
|
||||
// var timeout = TimeSpan.FromSeconds(2);
|
||||
// var timer = Stopwatch.StartNew();
|
||||
// long timeoutMilliseconds = 0;
|
||||
// try
|
||||
// {
|
||||
// while (true)
|
||||
// {
|
||||
// var batch = new List<object>();
|
||||
// var canRead = channelReader.Count;
|
||||
// if (canRead <= 0)
|
||||
// {
|
||||
// if (timeoutMilliseconds > 0)
|
||||
// {
|
||||
// _logger.LogError($"{nameof(LogSaveAsync)} 通道处理数据耗时{timeoutMilliseconds}毫秒");
|
||||
// }
|
||||
// timeoutMilliseconds = 0;
|
||||
// //无消息时短等待1秒
|
||||
// await Task.Delay(EmptyWaitMilliseconds);
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// timer.Restart();
|
||||
// var startTime = DateTime.Now;
|
||||
|
||||
// try
|
||||
// {
|
||||
// // 异步批量读取数据
|
||||
// while (batch != null && batch.Count < BatchSize && (DateTime.Now - startTime) < timeout)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (channelReader.TryRead(out var dataItem))
|
||||
// {
|
||||
// batch.Add(dataItem);
|
||||
// }
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// throw;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// throw;
|
||||
// }
|
||||
|
||||
// if (batch == null || batch.Count == 0)
|
||||
// {
|
||||
// await Task.Delay(EmptyWaitMilliseconds);
|
||||
// continue;
|
||||
// }
|
||||
// try
|
||||
// {
|
||||
|
||||
// // 按小时分组
|
||||
// var hourGroups = new Dictionary<DateTime, List<LogRecords>>();
|
||||
// DateTime? dateTime = null;
|
||||
// List<LogRecords> batchList = new List<LogRecords>();
|
||||
// int index = 1;
|
||||
// foreach (var item in batch)
|
||||
// {
|
||||
// var records = item.Adapt<LogRecords>();
|
||||
|
||||
// if (!records.ReceivedTime.HasValue)
|
||||
// records.ReceivedTime = DateTime.Now;
|
||||
// var curDateTime = new DateTime(records.ReceivedTime.Value.Year, records.ReceivedTime.Value.Month, records.ReceivedTime.Value.Hour, records.ReceivedTime.Value.Day, records.ReceivedTime.Value.Hour, 0, 0);
|
||||
// if (!dateTime.HasValue || curDateTime != dateTime)
|
||||
// {
|
||||
// dateTime = curDateTime;
|
||||
// if (batchList.Count > 0)
|
||||
// {
|
||||
// var immutableList = ImmutableList.CreateRange(batchList);
|
||||
// hourGroups.Add(dateTime.Value, immutableList.ToList());
|
||||
// batchList.Clear();
|
||||
// }
|
||||
// }
|
||||
// batchList.Add(records);
|
||||
// // 最后一批
|
||||
// if(index== batch.Count)
|
||||
// {
|
||||
// var immutableList = ImmutableList.CreateRange(batchList);
|
||||
// hourGroups.Add(dateTime.Value, immutableList.ToList());
|
||||
// batchList.Clear();
|
||||
// }
|
||||
// index++;
|
||||
// }
|
||||
// foreach (var (time, records) in hourGroups)
|
||||
// {
|
||||
// // 批量写入数据库
|
||||
// await _logRecordRepository.InsertManyAsync(records, time);
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// _logger.LogError(ex, "数据通道处理日志数据时发生异常");
|
||||
// }
|
||||
// batch.Clear();
|
||||
// timer.Stop();
|
||||
|
||||
// timeoutMilliseconds = timeoutMilliseconds + timer.ElapsedMilliseconds;
|
||||
|
||||
// startTime = DateTime.Now;
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// _logger.LogCritical(ex, "日志处理发生致命错误");
|
||||
// throw;
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,3 +14,4 @@ global using JiShe.ServicePro.FreeSqlProvider;
|
||||
global using JiShe.ServicePro.Kafka.Producer;
|
||||
global using JiShe.ServicePro.Consts;
|
||||
global using JiShe.ServicePro.Core;
|
||||
global using JiShe.ServicePro.ServerOptions;
|
||||
|
||||
@ -19,6 +19,7 @@ namespace JiShe.CollectBus.Subscribers
|
||||
private readonly IoTDBSessionPoolProvider _dbProvider;
|
||||
private readonly IProtocolService _protocolService;
|
||||
|
||||
|
||||
public SubscriberAnalysisAppService(ILogger<SubscriberAnalysisAppService> logger,
|
||||
ITcpService tcpService,
|
||||
IServiceProvider serviceProvider,
|
||||
|
||||
@ -1,53 +0,0 @@
|
||||
namespace JiShe.CollectBus.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务器应用配置
|
||||
/// </summary>
|
||||
public class ServerApplicationOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务器标识
|
||||
/// </summary>
|
||||
public string ServerTagName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 系统类型
|
||||
/// </summary>
|
||||
public string SystemType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 首次采集时间
|
||||
/// </summary>
|
||||
public DateTime? FirstCollectionTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 自动验证时间
|
||||
/// </summary>
|
||||
public string AutomaticVerificationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 自动获取终端版时间
|
||||
/// </summary>
|
||||
public string AutomaticTerminalVersionTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 自动获取远程通信模块(SIM)版本时间
|
||||
/// </summary>
|
||||
public string AutomaticTelematicsModuleTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 日冻结抄读时间
|
||||
/// </summary>
|
||||
public string AutomaticDayFreezeTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 月冻结抄读时间
|
||||
/// </summary>
|
||||
public string AutomaticMonthFreezeTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认协议插件
|
||||
/// </summary>
|
||||
public string DefaultProtocolPlugin { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
using JiShe.CollectBus.Common;
|
||||
using JiShe.CollectBus.Host.HealthChecks;
|
||||
using JiShe.CollectBus.Host.Swaggers;
|
||||
using JiShe.ServicePro.ServerOptions;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Swashbuckle.AspNetCore.SwaggerUI;
|
||||
using Volo.Abp;
|
||||
|
||||
@ -34,9 +34,10 @@
|
||||
"IoTDBOptions": {
|
||||
"UserName": "root",
|
||||
"Password": "root",
|
||||
"ClusterList": [ "121.42.175.177:16667" ],
|
||||
"TreeModelClusterList": [ "121.42.175.177:16667" ],
|
||||
"TableModelClusterList": [ "121.42.175.177:16667" ],
|
||||
"PoolSize": 32,
|
||||
"DataBaseName": "energy",
|
||||
"TableModelDataBaseName": "energy",
|
||||
"OpenDebugMode": true,
|
||||
"UseTableSessionPoolByDefault": false
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user