Compare commits

...

6 Commits

Author SHA1 Message Date
Diego
d1248811fd build: 10.5.11 2025-04-30 23:05:36 +08:00
2248356998 qq.com
022d016e8e feat: 添加采集组 2025-04-30 23:04:51 +08:00
Diego
f73245e650 build: 10.5.10 2025-04-30 15:31:39 +08:00
2248356998 qq.com
484461fa05 更新依赖 2025-04-30 15:29:19 +08:00
Diego
7e0b7aff2a feat: sqldb支持数组 2025-04-28 15:52:32 +08:00
Diego
6c450dcb09 feat: sqldb支持数组类型 2025-04-28 15:52:11 +08:00
19 changed files with 94 additions and 57 deletions

View File

@@ -7,7 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="BootstrapBlazor.FontAwesome" Version="9.0.2" /> <PackageReference Include="BootstrapBlazor.FontAwesome" Version="9.0.2" />
<PackageReference Include="BootstrapBlazor" Version="9.5.12" /> <PackageReference Include="BootstrapBlazor" Version="9.6.0" />
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" /> <PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
</ItemGroup> </ItemGroup>

View File

@@ -1,8 +1,8 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<PluginVersion>10.5.8</PluginVersion> <PluginVersion>10.5.11</PluginVersion>
<ProPluginVersion>10.5.8</ProPluginVersion> <ProPluginVersion>10.5.11</ProPluginVersion>
<AuthenticationVersion>2.1.7</AuthenticationVersion> <AuthenticationVersion>2.1.7</AuthenticationVersion>
</PropertyGroup> </PropertyGroup>

View File

@@ -10,8 +10,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="9.0.4" /> <PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="9.0.4" />
<PackageReference Include="TouchSocket" Version="3.1.0" /> <PackageReference Include="TouchSocket" Version="3.1.1" />
<PackageReference Include="TouchSocket.SerialPorts" Version="3.1.0" /> <PackageReference Include="TouchSocket.SerialPorts" Version="3.1.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -51,6 +51,13 @@ public class Variable : BaseDataEntity, IValidatableObject
[Required] [Required]
public virtual string Name { get; set; } public virtual string Name { get; set; }
/// <summary>
/// 采集组
/// </summary>
[SugarColumn(ColumnDescription = "采集组", IsNullable = true)]
[AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true, Order = 1)]
public virtual string CollectGroup { get; set; } = string.Empty;
/// <summary> /// <summary>
/// 分组名称 /// 分组名称
/// </summary> /// </summary>

View File

@@ -97,6 +97,7 @@
"Name": "Name", "Name": "Name",
"Description": "Description", "Description": "Description",
"Group": "Group", "Group": "Group",
"CollectGroup": "CollectGroup",
"DeviceId": "CollectionDevice", "DeviceId": "CollectionDevice",
"DeviceId.MinValue": "{0} cannot be empty", "DeviceId.MinValue": "{0} cannot be empty",
"DeviceId.Required": "{0} cannot be empty", "DeviceId.Required": "{0} cannot be empty",
@@ -452,6 +453,7 @@
"Name.Required": "{0} cannot be empty", "Name.Required": "{0} cannot be empty",
"Description": "Description", "Description": "Description",
"Group": "Group", "Group": "Group",
"CollectGroup": "CollectGroup",
"DeviceId": "CollectionDevice", "DeviceId": "CollectionDevice",
"DeviceId.MinValue": "{0} cannot be empty", "DeviceId.MinValue": "{0} cannot be empty",
"DeviceId.Required": "{0} cannot be empty", "DeviceId.Required": "{0} cannot be empty",

View File

@@ -89,7 +89,8 @@
"Name": "名称", "Name": "名称",
"Name.Required": " {0} 不可为空", "Name.Required": " {0} 不可为空",
"Description": "描述", "Description": "描述",
"Group": "组", "Group": "业务组",
"CollectGroup": "采集组",
"DeviceId": "采集设备", "DeviceId": "采集设备",
"DeviceId.MinValue": " {0} 不可为空", "DeviceId.MinValue": " {0} 不可为空",
"DeviceId.Required": " {0} 不可为空", "DeviceId.Required": " {0} 不可为空",
@@ -486,7 +487,8 @@
"Name": "名称", "Name": "名称",
"Name.Required": " {0} 不可为空", "Name.Required": " {0} 不可为空",
"Description": "描述", "Description": "描述",
"Group": "组", "Group": "业务组",
"CollectGroup": "采集组",
"DeviceId": "采集设备", "DeviceId": "采集设备",
"DeviceId.MinValue": " {0} 不可为空", "DeviceId.MinValue": " {0} 不可为空",
"DeviceId.Required": " {0} 不可为空", "DeviceId.Required": " {0} 不可为空",

View File

@@ -8,8 +8,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" /> <PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageReference Include="Rougamo.Fody" Version="5.0.0" /> <PackageReference Include="Rougamo.Fody" Version="5.0.0" />
<PackageReference Include="TouchSocket.Dmtp" Version="3.1.0" /> <PackageReference Include="TouchSocket.Dmtp" Version="3.1.1" />
<PackageReference Include="TouchSocket.WebApi.Swagger" Version="3.1.0" /> <PackageReference Include="TouchSocket.WebApi.Swagger" Version="3.1.1" />
<PackageReference Include="ThingsGateway.Authentication" Version="$(AuthenticationVersion)" /> <PackageReference Include="ThingsGateway.Authentication" Version="$(AuthenticationVersion)" />
</ItemGroup> </ItemGroup>

View File

@@ -44,6 +44,7 @@
<EditorItem @bind-Field="@context.Name" Readonly=BatchEditEnable /> <EditorItem @bind-Field="@context.Name" Readonly=BatchEditEnable />
<EditorItem @bind-Field="@context.Description" /> <EditorItem @bind-Field="@context.Description" />
<EditorItem @bind-Field="@context.CollectGroup" />
<EditorItem @bind-Field="@context.Group" /> <EditorItem @bind-Field="@context.Group" />
<EditorItem @bind-Field="@context.Unit" /> <EditorItem @bind-Field="@context.Unit" />

View File

@@ -7,7 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\ThingsGateway.Gateway.Application\ThingsGateway.Gateway.Application.csproj" /> <ProjectReference Include="..\ThingsGateway.Gateway.Application\ThingsGateway.Gateway.Application.csproj" />
<PackageReference Include="BootstrapBlazor.UniverSheet" Version="9.0.3" /> <PackageReference Include="BootstrapBlazor.UniverSheet" Version="9.0.4" />
<PackageReference Include="BootstrapBlazor.WinBox" Version="9.0.7" /> <PackageReference Include="BootstrapBlazor.WinBox" Version="9.0.7" />
<PackageReference Include="BootstrapBlazor.CodeEditor" Version="9.0.1" /> <PackageReference Include="BootstrapBlazor.CodeEditor" Version="9.0.1" />
<ProjectReference Include="..\..\Admin\ThingsGateway.Admin.Razor\ThingsGateway.Admin.Razor.csproj" /> <ProjectReference Include="..\..\Admin\ThingsGateway.Admin.Razor\ThingsGateway.Admin.Razor.csproj" />

View File

@@ -160,9 +160,19 @@ public class OpcDaMaster : IDisposable
/// <returns></returns> /// <returns></returns>
public Dictionary<string, List<OpcItem>> AddItemsWithSave(List<string> items) public Dictionary<string, List<OpcItem>> AddItemsWithSave(List<string> items)
{ {
int i = 0; lock (this)
ItemDicts = items.ConvertAll(o => new OpcItem(o)).ChunkTrivialBetter(OpcDaProperty.GroupSize).ToDictionary(a => "default" + (i++)); {
return ItemDicts;
int i = ItemDicts.Count;
var addItems = items.ConvertAll(o => new OpcItem(o)).ChunkTrivialBetter(OpcDaProperty.GroupSize).ToDictionary(a => "default" + (i++));
foreach (var item in addItems)
{
ItemDicts.TryAdd(item.Key, item.Value);
}
return addItems;
}
} }
/// <summary> /// <summary>

View File

@@ -12,8 +12,6 @@ using BootstrapBlazor.Components;
using Mapster; using Mapster;
using Newtonsoft.Json.Linq;
using SqlSugar; using SqlSugar;
using ThingsGateway.Admin.Application; using ThingsGateway.Admin.Application;
@@ -68,7 +66,7 @@ public partial class QuestDBProducer : BusinessBaseWithCacheIntervalVariableMode
_config.ForType<VariableRuntime, QuestDBHistoryValue>() _config.ForType<VariableRuntime, QuestDBHistoryValue>()
//.Map(dest => dest.Id, src => CommonUtils.GetSingleId()) //.Map(dest => dest.Id, src => CommonUtils.GetSingleId())
.Map(dest => dest.Id, src => src.Id)//Id更改为变量Id .Map(dest => dest.Id, src => src.Id)//Id更改为变量Id
.Map(dest => dest.Value, src => src.Value != null ? src.Value.GetType() == typeof(string) ? src.Value.ToString() : JToken.FromObject(src.Value).ToString() : string.Empty) .Map(dest => dest.Value, src => src.Value == null ? string.Empty : src.Value.ToString() ?? string.Empty)
.Map(dest => dest.CollectTime, (src) => src.CollectTime < DateTime.MinValue ? utcTime : src.CollectTime!.Value.ToUniversalTime())//注意sqlsugar插入时无时区直接utc时间 .Map(dest => dest.CollectTime, (src) => src.CollectTime < DateTime.MinValue ? utcTime : src.CollectTime!.Value.ToUniversalTime())//注意sqlsugar插入时无时区直接utc时间
.Map(dest => dest.CreateTime, (src) => DateTime.UtcNow) .Map(dest => dest.CreateTime, (src) => DateTime.UtcNow)
;//注意sqlsugar插入时无时区直接utc时间 ;//注意sqlsugar插入时无时区直接utc时间

View File

@@ -12,8 +12,6 @@ using BootstrapBlazor.Components;
using Mapster; using Mapster;
using Newtonsoft.Json.Linq;
using SqlSugar; using SqlSugar;
using ThingsGateway.Admin.Application; using ThingsGateway.Admin.Application;
@@ -158,7 +156,7 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVariableModel<
_config.ForType<VariableRuntime, SQLHistoryValue>() _config.ForType<VariableRuntime, SQLHistoryValue>()
//.Map(dest => dest.Id, (src) =>CommonUtils.GetSingleId()) //.Map(dest => dest.Id, (src) =>CommonUtils.GetSingleId())
.Map(dest => dest.Id, src => src.Id)//Id更改为变量Id .Map(dest => dest.Id, src => src.Id)//Id更改为变量Id
.Map(dest => dest.Value, src => src.Value != null ? src.Value.GetType() == typeof(string) ? src.Value.ToString() : JToken.FromObject(src.Value).ToString() : string.Empty) .Map(dest => dest.Value, src => src.Value == null ? string.Empty : src.Value.ToString() ?? string.Empty)
.Map(dest => dest.CreateTime, (src) => DateTime.Now); .Map(dest => dest.CreateTime, (src) => DateTime.Now);
_exRealTimerTick = new(_driverPropertys.RealTableBusinessInterval); _exRealTimerTick = new(_driverPropertys.RealTableBusinessInterval);

View File

@@ -19,7 +19,7 @@
<PackageReference Include="SqlSugar.TDengineCore" Version="4.18.8" GeneratePathProperty="true"> <PackageReference Include="SqlSugar.TDengineCore" Version="4.18.11" GeneratePathProperty="true">
<PrivateAssets>contentFiles;compile;build;buildMultitargeting;buildTransitive;analyzers;</PrivateAssets> <PrivateAssets>contentFiles;compile;build;buildMultitargeting;buildTransitive;analyzers;</PrivateAssets>
</PackageReference> </PackageReference>

View File

@@ -80,6 +80,11 @@ public class ModbusMaster : CollectFoundationBase
protected override async Task<List<VariableSourceRead>> ProtectedLoadSourceReadAsync(List<VariableRuntime> deviceVariables) protected override async Task<List<VariableSourceRead>> ProtectedLoadSourceReadAsync(List<VariableRuntime> deviceVariables)
{ {
await Task.CompletedTask.ConfigureAwait(false); await Task.CompletedTask.ConfigureAwait(false);
return _plc.LoadSourceRead<VariableSourceRead>(deviceVariables, _driverPropertys.MaxPack, CurrentDevice.IntervalTime); List<VariableSourceRead> variableSourceReads = new();
foreach (var deviceVariable in deviceVariables.GroupBy(a => a.CollectGroup))
{
variableSourceReads.AddRange(_plc.LoadSourceRead<VariableSourceRead>(deviceVariable, _driverPropertys.MaxPack, CurrentDevice.IntervalTime));
}
return variableSourceReads;
} }
} }

View File

@@ -122,25 +122,31 @@ public class OpcDaMaster : CollectBase
{ {
if (deviceVariables.Count > 0) if (deviceVariables.Count > 0)
{ {
var result = _plc.AddItemsWithSave(deviceVariables.Where(a => !string.IsNullOrEmpty(a.RegisterAddress)).Select(a => a.RegisterAddress!).ToList()); List<VariableSourceRead> variableSourceReads = new List<VariableSourceRead>();
var sourVars = result?.Select( foreach (var deviceVariableGroups in deviceVariables.GroupBy(a => a.CollectGroup))
it => {
{
var read = new VariableSourceRead()
{
TimeTick = new(_driverProperties.UpdateRate.ToString()),
RegisterAddress = it.Key,
};
HashSet<string> ids = new(it.Value.Select(b => b.ItemID));
var variables = deviceVariables.Where(a => ids.Contains(a.RegisterAddress)); var result = _plc.AddItemsWithSave(deviceVariableGroups.Where(a => !string.IsNullOrEmpty(a.RegisterAddress)).Select(a => a.RegisterAddress!).ToList());
foreach (var v in variables) var sourVars = result?.Select(
it =>
{ {
read.AddVariable(v); var read = new VariableSourceRead()
} {
return read; TimeTick = new(_driverProperties.UpdateRate.ToString()),
}).ToList(); RegisterAddress = it.Key,
return sourVars; };
HashSet<string> ids = new(it.Value.Select(b => b.ItemID));
var variables = deviceVariableGroups.Where(a => ids.Contains(a.RegisterAddress));
foreach (var v in variables)
{
read.AddVariable(v);
}
return read;
}).ToList();
variableSourceReads.AddRange(sourVars);
}
return variableSourceReads;
} }
else else
{ {

View File

@@ -187,24 +187,27 @@ public class OpcUaMaster : CollectBase
await Task.CompletedTask.ConfigureAwait(false); await Task.CompletedTask.ConfigureAwait(false);
if (deviceVariables.Count > 0) if (deviceVariables.Count > 0)
{ {
var dataLists = deviceVariables.ChunkBetter(_driverProperties.GroupSize); List<VariableSourceRead> variableSourceReads = new List<VariableSourceRead>();
foreach (var deviceVariableGroups in deviceVariables.GroupBy(a => a.CollectGroup))
var dataResult = new List<VariableSourceRead>();
foreach (var variable in dataLists)
{ {
var sourVars = new VariableSourceRead() var dataLists = deviceVariableGroups.ChunkBetter(_driverProperties.GroupSize);
{
TimeTick = new(_driverProperties.UpdateRate.ToString()),
RegisterAddress = Guid.NewGuid().ToString(),
};
foreach (var item in variable)
{
sourVars.AddVariable(item);
}
dataResult.Add(sourVars);
}
return dataResult; foreach (var variable in dataLists)
{
var sourVars = new VariableSourceRead()
{
TimeTick = new(_driverProperties.UpdateRate.ToString()),
RegisterAddress = Guid.NewGuid().ToString(),
};
foreach (var item in variable)
{
sourVars.AddVariable(item);
}
variableSourceReads.Add(sourVars);
}
}
return variableSourceReads;
} }
else else
{ {

View File

@@ -221,7 +221,12 @@ public class SiemensS7Master : CollectFoundationBase
{ {
} }
return _plc.LoadSourceRead<VariableSourceRead>(deviceVariables, _plc.OnLine ? _plc.PduLength : _driverPropertys.MaxPack, CurrentDevice.IntervalTime); List<VariableSourceRead> variableSourceReads = new();
foreach (var deviceVariable in deviceVariables.GroupBy(a => a.CollectGroup))
{
variableSourceReads.AddRange(_plc.LoadSourceRead<VariableSourceRead>(deviceVariable, _driverPropertys.MaxPack, CurrentDevice.IntervalTime));
}
return variableSourceReads;
} }
finally { } finally { }
} }

View File

@@ -16,7 +16,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="TouchSocket.Dmtp" Version="3.1.0" /> <PackageReference Include="TouchSocket.Dmtp" Version="3.1.1" />
</ItemGroup> </ItemGroup>

View File

@@ -1,6 +1,6 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<Version>10.5.8</Version> <Version>10.5.11</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>