This commit is contained in:
2248356998 qq.com
2025-07-20 21:52:59 +08:00
parent ca86441e05
commit 605830edce
13 changed files with 31 additions and 26 deletions

View File

@@ -1,3 +1,3 @@
https://gitee.com/dothttpshttps://gitee.com/dotnetchina/SqlSugar/commit/b8a1e3320a72fb075633845ce2fba2d14f86affe
https://gitee.com/dotnetchina/SqlSugar/commit/b8a1e3320a72fb075633845ce2fba2d14f86affe
修改大部分CA规则后期优化减少字符串操作

View File

@@ -67,10 +67,11 @@ namespace ThingsGateway.SqlSugar
Check.Exception(attribute == null, $"{typeof(T).Name} need SplitTableAttribute");
groupModels = new List<GroupModel>();
var db = this.Context;
var context = db.SplitHelper<T>();
foreach (var item in datas)
{
var value = db.SplitHelper<T>().GetValue(attribute.SplitType, item);
var tableName = db.SplitHelper<T>().GetTableName(attribute.SplitType, value);
var value = context.GetValue(attribute.SplitType, item);
var tableName = context.GetTableName(attribute.SplitType, value);
groupModels.Add(new GroupModel() { GroupName = tableName, Item = item });
}
result = 0;

View File

@@ -133,14 +133,16 @@ namespace ThingsGateway.SqlSugar
groupModels = new List<GroupModel>();
var db = FastestProvider.context;
var hasSplitField = typeof(T).GetProperties().Any(it => it.GetCustomAttribute<SplitFieldAttribute>() != null);
var context = db.SplitHelper<T>();
foreach (var item in datas)
{
if (groupModels.Count > 0 && !hasSplitField)
groupModels.Add(new GroupModel() { GroupName = groupModels[0].GroupName, Item = item });
else
{
var value = db.SplitHelper<T>().GetValue(attribute.SplitType, item);
var tableName = db.SplitHelper<T>().GetTableName(attribute.SplitType, value);
var value = context.GetValue(attribute.SplitType, item);
var tableName = context.GetTableName(attribute.SplitType, value);
groupModels.Add(new GroupModel() { GroupName = tableName, Item = item });
}
}

View File

@@ -168,10 +168,11 @@ namespace ThingsGateway.SqlSugar
Check.Exception(attribute == null, $"{typeof(T).Name} need SplitTableAttribute");
groupModels = new List<GroupModel>();
var db = this.Context;
var context = db.SplitHelper<T>();
foreach (var item in datas)
{
var value = db.SplitHelper<T>().GetValue(attribute.SplitType, item);
var tableName = db.SplitHelper<T>().GetTableName(attribute.SplitType, value);
var value = context.GetValue(attribute.SplitType, item);
var tableName = context.GetTableName(attribute.SplitType, value);
groupModels.Add(new GroupModel() { GroupName = tableName, Item = item });
}
var tablenames = groupModels.Select(it => it.GroupName).Distinct().ToList();

View File

@@ -692,7 +692,7 @@ namespace ThingsGateway.SqlSugar
{
return ScopedContext.UpdateableT(UpdateObj);
}
public SplitTableContext SplitHelper<T>() where T : class, new()
{
return ScopedContext.SplitHelper<T>();

View File

@@ -141,10 +141,11 @@ namespace ThingsGateway.SqlSugar
Check.Exception(attribute == null, $"{typeof(T).Name} need SplitTableAttribute");
groupModels = new List<GroupModel>();
var db = this.Context;
var context = db.SplitHelper<T>();
foreach (var item in datas)
{
var value = db.SplitHelper<T>().GetValue(attribute.SplitType, item);
var tableName = db.SplitHelper<T>().GetTableName(attribute.SplitType, value);
var value = context.GetValue(attribute.SplitType, item);
var tableName = context.GetTableName(attribute.SplitType, value);
groupModels.Add(new GroupModel() { GroupName = tableName, Item = item });
}
result = 0;

View File

@@ -1,11 +1,11 @@
<Project>
<PropertyGroup>
<PluginVersion>10.9.44</PluginVersion>
<ProPluginVersion>10.9.44</ProPluginVersion>
<DefaultVersion>10.9.56</DefaultVersion>
<AuthenticationVersion>2.9.20</AuthenticationVersion>
<SourceGeneratorVersion>10.9.20</SourceGeneratorVersion>
<PluginVersion>10.9.62</PluginVersion>
<ProPluginVersion>10.9.62</ProPluginVersion>
<DefaultVersion>10.9.62</DefaultVersion>
<AuthenticationVersion>2.9.22</AuthenticationVersion>
<SourceGeneratorVersion>10.9.22</SourceGeneratorVersion>
<NET8Version>8.0.18</NET8Version>
<NET9Version>9.0.7</NET9Version>
<SatelliteResourceLanguages>zh-Hans;en-US</SatelliteResourceLanguages>

View File

@@ -10,8 +10,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="$(NET9Version)" />
<PackageReference Include="TouchSocket" Version="3.1.13" />
<PackageReference Include="TouchSocket.SerialPorts" Version="3.1.13" />
<PackageReference Include="TouchSocket" Version="3.1.14" />
<PackageReference Include="TouchSocket.SerialPorts" Version="3.1.14" />
</ItemGroup>
<ItemGroup>

View File

@@ -10,8 +10,8 @@
<PackageReference Include="Riok.Mapperly" Version="4.2.1" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="Rougamo.Fody" Version="5.0.1" />
<PackageReference Include="System.Linq.Async" Version="6.0.3" />
<PackageReference Include="TouchSocket.Dmtp" Version="3.1.13" />
<PackageReference Include="TouchSocket.WebApi.Swagger" Version="3.1.13" />
<PackageReference Include="TouchSocket.Dmtp" Version="3.1.14" />
<PackageReference Include="TouchSocket.WebApi.Swagger" Version="3.1.14" />
<PackageReference Include="ThingsGateway.Authentication" Version="$(AuthenticationVersion)" />
<!--<ProjectReference Include="..\..\PluginPro\ThingsGateway.Authentication\ThingsGateway.Authentication.csproj" />-->

View File

@@ -151,7 +151,7 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVariable, IDBH
var list = RealTimeVariables.ToListWithDequeue();
try
{
var varLists = list.Batch(100000);
var varLists = list.Batch(_driverPropertys.SplitSize);
foreach (var varList in varLists)
{
var result = await UpdateAsync(varList, cancellationToken).ConfigureAwait(false);

View File

@@ -135,10 +135,10 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVariable
if (numberData.Any())
{
var data = numberData.AdaptListSQLNumberHistoryValue();
Stopwatch stopwatch = new();
stopwatch.Start();
var data = numberData.AdaptListSQLNumberHistoryValue();
var result = await _db.Fastest<SQLNumberHistoryValue>().PageSize(50000).SplitTable().BulkCopyAsync(data).ConfigureAwait(false);
var result = await _db.Fastest<SQLNumberHistoryValue>().SplitTable().BulkCopyAsync(data).ConfigureAwait(false);
stopwatch.Stop();
//var result = await db.Insertable(dbInserts).SplitTable().ExecuteCommandAsync().ConfigureAwait(false);
@@ -154,7 +154,7 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVariable
Stopwatch stopwatch = new();
stopwatch.Start();
var data = stringData.AdaptListSQLHistoryValue();
var result = await _db.Fastest<SQLHistoryValue>().PageSize(50000).SplitTable().BulkCopyAsync(data).ConfigureAwait(false);
var result = await _db.Fastest<SQLHistoryValue>().SplitTable().BulkCopyAsync(data).ConfigureAwait(false);
stopwatch.Stop();
//var result = await db.Insertable(dbInserts).SplitTable().ExecuteCommandAsync().ConfigureAwait(false);
@@ -215,7 +215,7 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVariable
stopwatch.Start();
var data = datas.AdaptListSQLRealValue();
var result = await _db.Fastest<SQLRealValue>().AS(_driverPropertys.ReadDBTableName).PageSize(100000).BulkUpdateAsync(data).ConfigureAwait(false);
var result = await _db.Fastest<SQLRealValue>().AS(_driverPropertys.ReadDBTableName).BulkUpdateAsync(data).ConfigureAwait(false);
stopwatch.Stop();
if (result > 0)

View File

@@ -69,7 +69,7 @@ public partial class SqlHistoryAlarm : BusinessBaseWithCacheAlarm
if (_db.CurrentConnectionConfig.DbType == SqlSugar.DbType.QuestDB)
result = await _db.Insertable(dbInserts).AS(_driverPropertys.TableName).ExecuteCommandAsync(cancellationToken).ConfigureAwait(false);
else
result = await _db.Fastest<HistoryAlarm>().AS(_driverPropertys.TableName).PageSize(50000).BulkCopyAsync(dbInserts.AdaptListHistoryAlarm()).ConfigureAwait(false);
result = await _db.Fastest<HistoryAlarm>().AS(_driverPropertys.TableName).PageSize(100000).BulkCopyAsync(dbInserts.AdaptListHistoryAlarm()).ConfigureAwait(false);
stopwatch.Stop();
//var result = await db.Insertable(dbInserts).SplitTable().ExecuteCommandAsync().ConfigureAwait(false);

View File

@@ -16,7 +16,7 @@
<ItemGroup>
<PackageReference Include="TouchSocket.Dmtp" Version="3.1.13" />
<PackageReference Include="TouchSocket.Dmtp" Version="3.1.14" />
<PackageReference Include="Riok.Mapperly" Version="4.2.1" ExcludeAssets="runtime" PrivateAssets="all" />
</ItemGroup>