mirror of
				https://gitee.com/ThingsGateway/ThingsGateway.git
				synced 2025-10-31 07:33:58 +08:00 
			
		
		
		
	Compare commits
	
		
			5 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | b790cf5f4e | ||
|   | d1248811fd | ||
|   | 022d016e8e | ||
|   | f73245e650 | ||
|   | 484461fa05 | 
| @@ -21,7 +21,7 @@ | ||||
| 		<PackageReference Include="BootstrapBlazor.TableExport" Version="9.2.4" /> | ||||
| 		<PackageReference Include="UAParser" Version="3.1.47" /> | ||||
| 		<PackageReference Include="Rougamo.Fody" Version="5.0.0" /> | ||||
| 		<PackageReference Include="SqlSugarCore" Version="5.1.4.189" /> | ||||
| 		<PackageReference Include="SqlSugarCore" Version="5.1.4.191" /> | ||||
| 	</ItemGroup> | ||||
| 	<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' "> | ||||
| 		<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.1" /> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
| 	</PropertyGroup> | ||||
| 	<ItemGroup> | ||||
| 		<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" /> | ||||
| 	</ItemGroup> | ||||
|  | ||||
|   | ||||
| @@ -1,8 +1,8 @@ | ||||
| <Project> | ||||
|  | ||||
| 	<PropertyGroup> | ||||
| 		<PluginVersion>10.5.9</PluginVersion> | ||||
| 		<ProPluginVersion>10.5.9</ProPluginVersion> | ||||
| 		<PluginVersion>10.5.12</PluginVersion> | ||||
| 		<ProPluginVersion>10.5.12</ProPluginVersion> | ||||
| 		<AuthenticationVersion>2.1.7</AuthenticationVersion> | ||||
| 	</PropertyGroup> | ||||
|  | ||||
|   | ||||
| @@ -10,8 +10,8 @@ | ||||
|  | ||||
| 	<ItemGroup> | ||||
| 		<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="9.0.4" /> | ||||
| 		<PackageReference Include="TouchSocket" Version="3.1.0" /> | ||||
| 		<PackageReference Include="TouchSocket.SerialPorts" Version="3.1.0" /> | ||||
| 		<PackageReference Include="TouchSocket" Version="3.1.1" /> | ||||
| 		<PackageReference Include="TouchSocket.SerialPorts" Version="3.1.1" /> | ||||
| 	</ItemGroup> | ||||
|  | ||||
| 	<ItemGroup> | ||||
|   | ||||
| @@ -51,6 +51,13 @@ public class Variable : BaseDataEntity, IValidatableObject | ||||
|     [Required] | ||||
|     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> | ||||
|   | ||||
| @@ -97,6 +97,7 @@ | ||||
|     "Name": "Name", | ||||
|     "Description": "Description", | ||||
|     "Group": "Group", | ||||
|     "CollectGroup": "CollectGroup", | ||||
|     "DeviceId": "CollectionDevice", | ||||
|     "DeviceId.MinValue": "{0} cannot be empty", | ||||
|     "DeviceId.Required": "{0} cannot be empty", | ||||
| @@ -452,6 +453,7 @@ | ||||
|     "Name.Required": "{0} cannot be empty", | ||||
|     "Description": "Description", | ||||
|     "Group": "Group", | ||||
|     "CollectGroup": "CollectGroup", | ||||
|     "DeviceId": "CollectionDevice", | ||||
|     "DeviceId.MinValue": "{0} cannot be empty", | ||||
|     "DeviceId.Required": "{0} cannot be empty", | ||||
|   | ||||
| @@ -89,7 +89,8 @@ | ||||
|     "Name": "名称", | ||||
|     "Name.Required": " {0} 不可为空", | ||||
|     "Description": "描述", | ||||
|     "Group": "分组", | ||||
|     "Group": "业务组", | ||||
|     "CollectGroup": "采集组", | ||||
|     "DeviceId": "采集设备", | ||||
|     "DeviceId.MinValue": " {0} 不可为空", | ||||
|     "DeviceId.Required": " {0} 不可为空", | ||||
| @@ -486,7 +487,8 @@ | ||||
|     "Name": "名称", | ||||
|     "Name.Required": " {0} 不可为空", | ||||
|     "Description": "描述", | ||||
|     "Group": "分组", | ||||
|     "Group": "业务组", | ||||
|     "CollectGroup": "采集组", | ||||
|     "DeviceId": "采集设备", | ||||
|     "DeviceId.MinValue": " {0} 不可为空", | ||||
|     "DeviceId.Required": " {0} 不可为空", | ||||
|   | ||||
| @@ -8,8 +8,8 @@ | ||||
| 	<ItemGroup> | ||||
| 		<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" /> | ||||
| 		<PackageReference Include="Rougamo.Fody" Version="5.0.0" /> | ||||
| 		<PackageReference Include="TouchSocket.Dmtp" Version="3.1.0" /> | ||||
| 		<PackageReference Include="TouchSocket.WebApi.Swagger" Version="3.1.0" /> | ||||
| 		<PackageReference Include="TouchSocket.Dmtp" Version="3.1.1" /> | ||||
| 		<PackageReference Include="TouchSocket.WebApi.Swagger" Version="3.1.1" /> | ||||
| 		<PackageReference Include="ThingsGateway.Authentication" Version="$(AuthenticationVersion)" /> | ||||
|  | ||||
| 	</ItemGroup> | ||||
|   | ||||
| @@ -44,6 +44,7 @@ | ||||
|                     <EditorItem @bind-Field="@context.Name" Readonly=BatchEditEnable /> | ||||
|  | ||||
|                     <EditorItem @bind-Field="@context.Description" /> | ||||
|                     <EditorItem @bind-Field="@context.CollectGroup" /> | ||||
|                     <EditorItem @bind-Field="@context.Group" /> | ||||
|  | ||||
|                     <EditorItem @bind-Field="@context.Unit" /> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
| 	</PropertyGroup> | ||||
| 	<ItemGroup> | ||||
| 		<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.CodeEditor" Version="9.0.1" /> | ||||
| 		<ProjectReference Include="..\..\Admin\ThingsGateway.Admin.Razor\ThingsGateway.Admin.Razor.csproj" /> | ||||
|   | ||||
| @@ -160,9 +160,19 @@ public class OpcDaMaster : IDisposable | ||||
|     /// <returns></returns> | ||||
|     public Dictionary<string, List<OpcItem>> AddItemsWithSave(List<string> items) | ||||
|     { | ||||
|         int i = 0; | ||||
|         ItemDicts = items.ConvertAll(o => new OpcItem(o)).ChunkTrivialBetter(OpcDaProperty.GroupSize).ToDictionary(a => "default" + (i++)); | ||||
|         return ItemDicts; | ||||
|         lock (this) | ||||
|         { | ||||
|  | ||||
|             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> | ||||
|   | ||||
| @@ -12,7 +12,7 @@ | ||||
|     </PackageReference> | ||||
|     <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" /> | ||||
|     <PackageReference Include="xunit" Version="2.9.3" /> | ||||
|     <PackageReference Include="xunit.runner.visualstudio" Version="3.0.2"> | ||||
|     <PackageReference Include="xunit.runner.visualstudio" Version="3.1.0"> | ||||
|       <PrivateAssets>all</PrivateAssets> | ||||
|       <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||||
|     </PackageReference> | ||||
|   | ||||
| @@ -12,8 +12,6 @@ using BootstrapBlazor.Components; | ||||
|  | ||||
| using Mapster; | ||||
|  | ||||
| using Newtonsoft.Json.Linq; | ||||
|  | ||||
| using SqlSugar; | ||||
|  | ||||
| using ThingsGateway.Admin.Application; | ||||
| @@ -68,7 +66,7 @@ public partial class QuestDBProducer : BusinessBaseWithCacheIntervalVariableMode | ||||
|         _config.ForType<VariableRuntime, QuestDBHistoryValue>() | ||||
|             //.Map(dest => dest.Id, src => CommonUtils.GetSingleId()) | ||||
|             .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.CreateTime, (src) => DateTime.UtcNow) | ||||
|             ;//注意sqlsugar插入时无时区,直接utc时间 | ||||
|   | ||||
| @@ -12,8 +12,6 @@ using BootstrapBlazor.Components; | ||||
|  | ||||
| using Mapster; | ||||
|  | ||||
| using Newtonsoft.Json.Linq; | ||||
|  | ||||
| using SqlSugar; | ||||
|  | ||||
| using ThingsGateway.Admin.Application; | ||||
| @@ -156,17 +154,11 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVariableModel< | ||||
|     { | ||||
|         _config = new TypeAdapterConfig(); | ||||
|         _config.ForType<VariableRuntime, SQLHistoryValue>() | ||||
|             .Map(dest => dest.Id, (src) => CommonUtils.GetSingleId()) | ||||
|             //.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.Id, (src) =>CommonUtils.GetSingleId()) | ||||
|             .Map(dest => dest.Id, src => src.Id)//Id更改为变量Id | ||||
|             .Map(dest => dest.Value, src => src.Value == null ? string.Empty : src.Value.ToString() ?? string.Empty) | ||||
|             .Map(dest => dest.CreateTime, (src) => DateTime.Now); | ||||
|  | ||||
|         _config.ForType<VariableRuntime, SQLRealValue>() | ||||
|     //.Map(dest => dest.Id, (src) =>CommonUtils.GetSingleId()) | ||||
|     .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); | ||||
|  | ||||
|          | ||||
|         _exRealTimerTick = new(_driverPropertys.RealTableBusinessInterval); | ||||
|  | ||||
|         await base.InitChannelAsync(channel, cancellationToken).ConfigureAwait(false); | ||||
| @@ -228,7 +220,7 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVariableModel< | ||||
|                         var groups = varList.GroupBy(a => a.Group); | ||||
|                         foreach (var item in groups) | ||||
|                         { | ||||
|                             var result = await UpdateAsync(item.Adapt<List<SQLRealValue>>(_config), cancellationToken).ConfigureAwait(false); | ||||
|                             var result = await UpdateAsync(item.Adapt<List<SQLRealValue>>(), cancellationToken).ConfigureAwait(false); | ||||
|                             if (success != result.IsSuccess) | ||||
|                             { | ||||
|                                 if (!result.IsSuccess) | ||||
| @@ -239,7 +231,7 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVariableModel< | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         var result = await UpdateAsync(varList.Adapt<List<SQLRealValue>>(_config), cancellationToken).ConfigureAwait(false); | ||||
|                         var result = await UpdateAsync(varList.Adapt<List<SQLRealValue>>(), cancellationToken).ConfigureAwait(false); | ||||
|                         if (success != result.IsSuccess) | ||||
|                         { | ||||
|                             if (!result.IsSuccess) | ||||
|   | ||||
| @@ -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> | ||||
| 		</PackageReference> | ||||
|  | ||||
|   | ||||
| @@ -80,6 +80,11 @@ public class ModbusMaster : CollectFoundationBase | ||||
|     protected override async Task<List<VariableSourceRead>> ProtectedLoadSourceReadAsync(List<VariableRuntime> deviceVariables) | ||||
|     { | ||||
|         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; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -122,25 +122,31 @@ public class OpcDaMaster : CollectBase | ||||
|         { | ||||
|             if (deviceVariables.Count > 0) | ||||
|             { | ||||
|                 var result = _plc.AddItemsWithSave(deviceVariables.Where(a => !string.IsNullOrEmpty(a.RegisterAddress)).Select(a => a.RegisterAddress!).ToList()); | ||||
|                 var sourVars = result?.Select( | ||||
|           it => | ||||
|           { | ||||
|               var read = new VariableSourceRead() | ||||
|               { | ||||
|                   TimeTick = new(_driverProperties.UpdateRate.ToString()), | ||||
|                   RegisterAddress = it.Key, | ||||
|               }; | ||||
|               HashSet<string> ids = new(it.Value.Select(b => b.ItemID)); | ||||
|                 List<VariableSourceRead> variableSourceReads = new List<VariableSourceRead>(); | ||||
|                 foreach (var deviceVariableGroups in deviceVariables.GroupBy(a => a.CollectGroup)) | ||||
|                 { | ||||
|  | ||||
|               var variables = deviceVariables.Where(a => ids.Contains(a.RegisterAddress)); | ||||
|               foreach (var v in variables) | ||||
|                     var result = _plc.AddItemsWithSave(deviceVariableGroups.Where(a => !string.IsNullOrEmpty(a.RegisterAddress)).Select(a => a.RegisterAddress!).ToList()); | ||||
|                     var sourVars = result?.Select( | ||||
|               it => | ||||
|               { | ||||
|                   read.AddVariable(v); | ||||
|               } | ||||
|               return read; | ||||
|           }).ToList(); | ||||
|                 return sourVars; | ||||
|                   var read = new VariableSourceRead() | ||||
|                   { | ||||
|                       TimeTick = new(_driverProperties.UpdateRate.ToString()), | ||||
|                       RegisterAddress = it.Key, | ||||
|                   }; | ||||
|                   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 | ||||
|             { | ||||
|   | ||||
| @@ -187,24 +187,27 @@ public class OpcUaMaster : CollectBase | ||||
|         await Task.CompletedTask.ConfigureAwait(false); | ||||
|         if (deviceVariables.Count > 0) | ||||
|         { | ||||
|             var dataLists = deviceVariables.ChunkBetter(_driverProperties.GroupSize); | ||||
|  | ||||
|             var dataResult = new List<VariableSourceRead>(); | ||||
|             foreach (var variable in dataLists) | ||||
|             List<VariableSourceRead> variableSourceReads = new List<VariableSourceRead>(); | ||||
|             foreach (var deviceVariableGroups in deviceVariables.GroupBy(a => a.CollectGroup)) | ||||
|             { | ||||
|                 var sourVars = new VariableSourceRead() | ||||
|                 { | ||||
|                     TimeTick = new(_driverProperties.UpdateRate.ToString()), | ||||
|                     RegisterAddress = Guid.NewGuid().ToString(), | ||||
|                 }; | ||||
|                 foreach (var item in variable) | ||||
|                 { | ||||
|                     sourVars.AddVariable(item); | ||||
|                 } | ||||
|                 dataResult.Add(sourVars); | ||||
|             } | ||||
|                 var dataLists = deviceVariableGroups.ChunkBetter(_driverProperties.GroupSize); | ||||
|  | ||||
|             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 | ||||
|         { | ||||
|   | ||||
| @@ -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 { } | ||||
|     } | ||||
|   | ||||
| @@ -16,7 +16,7 @@ | ||||
|  | ||||
|  | ||||
| 	<ItemGroup> | ||||
| 	  <PackageReference Include="TouchSocket.Dmtp" Version="3.1.0" /> | ||||
| 	  <PackageReference Include="TouchSocket.Dmtp" Version="3.1.1" /> | ||||
| 	</ItemGroup> | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| <Project> | ||||
|   <PropertyGroup> | ||||
|     <Version>10.5.9</Version> | ||||
|     <Version>10.5.12</Version> | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user