优化代码

This commit is contained in:
ChenYi 2025-05-12 10:14:08 +08:00
parent cf9bf6c210
commit e35172d69f
6 changed files with 10 additions and 10 deletions

View File

@ -134,7 +134,7 @@ namespace JiShe.CollectBus.IoTDB.Provider
try
{
var batchSize = 1000;
var batchSize = 2000;
var batches = entities.Chunk(batchSize);
foreach (var batch in batches)

View File

@ -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>

View File

@ -63,8 +63,8 @@ namespace JiShe.CollectBus.DataChannels
public async Task ScheduledMeterTaskReadingAsync(
ChannelReader<ValueTuple<string, List<MeterReadingTelemetryPacketInfo>>> telemetryPacketInfoReader)
{
const int BatchSize = 20000;
const int EmptyWaitMilliseconds = 1000;
const int BatchSize = 100000;
const int EmptyWaitMilliseconds = 200;
var timeout = TimeSpan.FromSeconds(5);
var timer = Stopwatch.StartNew();
long timeoutMilliseconds = 0;

View File

@ -19,8 +19,8 @@
<PackageReference Include="Volo.Abp.AutoMapper" Version="8.3.3" />
<PackageReference Include="Volo.Abp.BackgroundWorkers.Hangfire" Version="8.3.3" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="8.3.3" />
<PackageReference Include="TouchSocket" Version="3.1.0" />
<PackageReference Include="TouchSocket.Hosting" Version="3.1.0" />
<PackageReference Include="TouchSocket" Version="3.1.2" />
<PackageReference Include="TouchSocket.Hosting" Version="3.1.2" />
<PackageReference Include="Volo.Abp.EventBus.Kafka" Version="8.3.3" />
<ProjectReference Include="..\..\protocols\JiShe.CollectBus.Protocol\JiShe.CollectBus.Protocol.csproj" />

View File

@ -250,14 +250,14 @@ public class SampleAppService : CollectBusAppService, ISampleAppService, IKafkaS
{
time = DateTime.Now;
var meter = new TableModelSingleMeasuringEntity<int>()
var meter = new TableModelSingleMeasuringEntity<bool>()
{
SystemName = "energy",
DeviceId = "402440506",
DeviceType = "Ammeter",
ProjectId = "10059",
Timestamps = time.GetDateTimeOffset().ToUnixTimeMilliseconds(),
SingleColumn = (measuring, value)
SingleColumn = (measuring, true)
};
_dbContext.UseTableSessionPool = true;
await _iotDBProvider.InsertAsync(meter);

View File

@ -231,7 +231,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
//检查任务时间节点由于定时任务10秒钟运行一次需要判定当前时间是否在任务时间节点内不在则跳过
var currentTaskTime = tasksToBeIssueModel.LastTaskTime.CalculateNextCollectionTime(timeDensity);//程序启动缓存电表的时候NextTaskTime需要格式化到下一个采集点时间。
if (!IsTaskTime(currentTaskTime, timeDensity))
if (!IsTaskTime(currentTaskTime, timeDensity))//todo 如果时间超过两个采集频率周期,就一直处理,直到追加到下一个采集频率周期。
{
_logger.LogInformation($"{nameof(CreateToBeIssueTasks)} 构建待处理的下发指令任务处理时Key=>{item}时间节点不在当前时间范围内,103");
continue;
@ -498,7 +498,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
timer.Stop();
_logger.LogInformation($"{nameof(InitAmmeterCacheData)} 初始化电表缓存数据完成,耗时{timer.ElapsedMilliseconds}毫秒");
_logger.LogWarning($"{nameof(InitAmmeterCacheData)} 初始化电表缓存数据完成,耗时{timer.ElapsedMilliseconds}毫秒");
}
/// <summary>