更新插件

This commit is contained in:
Kimdiego2098
2024-04-15 12:04:34 +08:00
parent f4904c3b53
commit e036b59306
21 changed files with 322 additions and 104 deletions

View File

@@ -32,13 +32,13 @@ public partial class KafkaProducer : BusinessBaseWithCacheIntervalScript<Variabl
protected override void VariableChange(VariableRunTime variableRunTime, VariableData variable)
{
AddQueueVarModel(new(variableRunTime.Adapt<VariableData>()));
AddQueueVarModel(new(variable));
base.VariableChange(variableRunTime, variable);
}
protected override void DeviceChange(DeviceRunTime deviceRunTime, DeviceData deviceData)
{
AddQueueDevModel(new(deviceRunTime.Adapt<DeviceData>()));
AddQueueDevModel(new(deviceData));
base.DeviceChange(deviceRunTime, deviceData);
}
@@ -112,8 +112,9 @@ public partial class KafkaProducer : BusinessBaseWithCacheIntervalScript<Variabl
{
//保留消息
//分解List避免超出字节大小限制
var varData = CurrentDevice.VariableRunTimes.Adapt<List<VariableData>>().ChunkBetter(_driverPropertys.SplitSize);
var devData = CollectDevices.Adapt<List<DeviceData>>().ChunkBetter(_driverPropertys.SplitSize);
var varData = CurrentDevice.VariableRunTimes.Values.Adapt<List<VariableData>>().ChunkBetter(_driverPropertys.SplitSize);
var devData = CollectDevices.Values.Adapt<List<DeviceData>>().ChunkBetter(_driverPropertys.SplitSize);
var alramData = GlobalData.ReadOnlyRealAlarmVariables.Adapt<List<AlarmVariable>>().ChunkBetter(_driverPropertys.SplitSize);
foreach (var item in varData)
{
if (!success)
@@ -127,6 +128,12 @@ public partial class KafkaProducer : BusinessBaseWithCacheIntervalScript<Variabl
break;
await UpdateDevModel(item, cancellationToken);
}
foreach (var item in alramData)
{
if (!success)
break;
await UpdateAlarmModel(item, cancellationToken);
}
}
/// <summary>

View File

@@ -3,7 +3,7 @@
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="@echo off&#xD;&#xA;setlocal enabledelayedexpansion&#xD;&#xA;&#xD;&#xA;set &quot;targetFWS=net6.0 net7.0 net8.0&quot;&#xD;&#xA;for %25%25f in (%25targetFWS%25) do (&#xD;&#xA; set &quot;dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)&quot;&#xD;&#xA; if not exist &quot;!dir!&quot; md &quot;!dir!&quot;&#xD;&#xA; copy &quot;$(TargetDir)*Kafka*.dll&quot; &quot;!dir!&quot;&#xD;&#xA;)&#xD;&#xA;&#xD;&#xA;endlocal&#xD;&#xA;" />
<Exec Command="@echo off&#xD;&#xA;setlocal enabledelayedexpansion&#xD;&#xA;&#xD;&#xA;set targetFWS=$(TargetFrameworks)&#xD;&#xA;for %25%25f in (%25targetFWS%25) do (&#xD;&#xA; set &quot;dir=$(SolutionDir)ThingsGateway.Server\bin\$(Configuration)\%25%25f\Plugins\$(AssemblyName)&quot;&#xD;&#xA; if not exist &quot;!dir!&quot; md &quot;!dir!&quot;&#xD;&#xA; copy &quot;$(TargetDir)*Kafka*.dll&quot; &quot;!dir!&quot;&#xD;&#xA;&#xD;&#xA;)&#xD;&#xA;&#xD;&#xA;endlocal&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;" />
</Target>
<PropertyGroup>

View File

@@ -0,0 +1,35 @@
{
"ThingsGateway.Plugin.Kafka.KafkaProducerProperty": {
"BigTextConnectStr": "ConnectString",
"IsInterval": "IsInterval",
"BusinessInterval": "BusinessInterval",
"IsAllVariable": "IsAllVariable",
"QueueMaxCount": "QueueMaxCount",
"SplitSize": "SplitSize",
"CacheEnable": "CacheEnable"
},
"ThingsGateway.Plugin.Mqtt.MqttServerProperty": {
"IP": "IP",
"Port": "Port",
"WebSocketPort": "WebSocketPort",
"StartWithId": "StartWithId",
"DeviceRpcEnable": "DeviceRpcEnable",
"RpcWriteTopic": "RpcWriteTopic",
"BigTextScriptDeviceModel": "BigTextScriptDeviceModel",
"BigTextScriptVariableModel": "BigTextScriptVariableModel",
"BigTextScriptAlarmModel": "BigTextScriptAlarmModel",
"IsDeviceList": "IsDeviceList",
"IsVariableList": "IsVariableList",
"IsAlarmList": "IsAlarmList",
"DeviceTopic": "DeviceTopic",
"VariableTopic": "VariableTopic",
"AlarmTopic": "AlarmTopic",
"IsInterval": "IsInterval",
"BusinessInterval": "BusinessInterval",
"IsAllVariable": "IsAllVariable",
"QueueMaxCount": "QueueMaxCount",
"SplitSize": "SplitSize",
"CacheEnable": "CacheEnable"
}
}

View File

@@ -0,0 +1,12 @@
{
"ThingsGateway.Plugin.QuestDB.QuestDBProducerProperty": {
"BigTextConnectStr": "连接字符串",
"IsInterval": "启用定时上传",
"BusinessInterval": "定时上传间隔",
"IsAllVariable": "选择全部变量",
"QueueMaxCount": "内存队列最大数量",
"SplitSize": "上传每页条数",
"CacheEnable": "启用缓存"
}
}

View File

@@ -8,6 +8,8 @@
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using SqlSugar;
using System.ComponentModel;
@@ -24,6 +26,7 @@ namespace ThingsGateway.Plugin.QuestDB;
public class QuestDBHistoryValue : IPrimaryIdEntity, IDBHistoryValue
{
[SugarColumn(ColumnDescription = "变量Id")]
[AutoGenerateColumn(Ignore = true)]
public long Id { get; set; }
/// <summary>
@@ -31,21 +34,21 @@ public class QuestDBHistoryValue : IPrimaryIdEntity, IDBHistoryValue
/// </summary>
[TimeDbSplitField(DateType.Month)]
[Description("采集时间")]
[DataTable(Order = 1, IsShow = true, Sortable = true, DefaultFilter = false, CellClass = " table-text-truncate ")]
[AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
public DateTime CollectTime { get; set; }
/// <summary>
/// 上传时间
/// </summary>
[Description("上传时间")]
[DataTable(Order = 1, IsShow = true, Sortable = true, DefaultFilter = false, CellClass = " table-text-truncate ")]
[AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
public DateTime CreateTime { get; set; }
/// <summary>
/// 设备名称
/// </summary>
[Description("设备名称")]
[DataTable(Order = 1, IsShow = true, Sortable = true, DefaultFilter = false, CellClass = " table-text-truncate ")]
[AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
public string DeviceName { get; set; }
/// <summary>
@@ -53,20 +56,20 @@ public class QuestDBHistoryValue : IPrimaryIdEntity, IDBHistoryValue
/// </summary>
[SugarColumn(ColumnDataType = "symbol")]
[Description("变量名称")]
[DataTable(Order = 1, IsShow = true, Sortable = true, DefaultFilter = false, CellClass = " table-text-truncate ")]
[AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
public string Name { get; set; }
/// <summary>
/// 是否在线
/// </summary>
[Description("是否在线")]
[DataTable(Order = 1, IsShow = true, Sortable = true, DefaultFilter = false, CellClass = " table-text-truncate ")]
[AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
public bool IsOnline { get; set; }
/// <summary>
/// 变量值
/// </summary>
[Description("变量值")]
[DataTable(Order = 1, IsShow = true, Sortable = true, DefaultFilter = false, CellClass = " table-text-truncate ")]
[AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
public string Value { get; set; }
}

View File

@@ -2,57 +2,36 @@
@using Microsoft.AspNetCore.Authorization;
@using Microsoft.Extensions.Logging
@using ThingsGateway.Admin.Application;
@using ThingsGateway.Admin.Blazor
@using ThingsGateway.Admin.Razor
@using ThingsGateway.Core.Extension
@using ThingsGateway.Gateway.Application
@using BootstrapBlazor.Components
@namespace ThingsGateway.Plugin.QuestDB
@inject UserResoures UserResoures
@inherits BaseComponentBase
<AppDataTable @ref="_datatable" TItem="QuestDBHistoryValue" SearchItem="QuestDBPageInput"
AddItem="object" EditItem="object" IsShowSelect=false
SearchModel="@_search" IsShowOperCol=true
QueryCallAsync="QueryCallAsync" FirstQuery=false
IsShowDetailButton IsShowQueryButton>
<SearchTemplate>
<AdminTable TItem="QuestDBHistoryValue" AutoGenerateColumns="true" ShowDefaultButtons=false
AllowResizing="true" IsFixedHeader=true IsMultipleSelect=false
ShowExtendEditButton=false ShowExtendDeleteButton=false ShowExtendButtons=false
ShowExportButton="true"
OnQueryAsync="OnQueryAsync" IsPagination=true CustomerSearchModel="@CustomerSearchModel">
<CustomerSearchTemplate>
@if (context is QuestDBPageInput model)
{
@Render(model)
}
</CustomerSearchTemplate>
<PDateTimePicker @bind-Value="context.StartTime"
TimeFormat="TimeFormat.Hr24"
ViewType="DateTimePickerViewType.Compact">
<ActivatorContent Context="dt">
<MTextField @bind-Value="context.StartTime" Label=@AppService.I18n.T(context.Description(x => x.StartTime))
Clearable Class="my-1 mx-2 "
Filled Outlined
Readonly Dense
@attributes="@dt.Attrs">
</MTextField>
</ActivatorContent>
</PDateTimePicker>
<PDateTimePicker @bind-Value="context.EndTime"
TimeFormat="TimeFormat.Hr24"
ViewType="DateTimePickerViewType.Compact">
<ActivatorContent Context="dt">
<MTextField @bind-Value="context.EndTime" Label=@AppService.I18n.T(context.Description(x => x.EndTime))
Clearable Class="my-1 mx-2 "
Filled Outlined
Readonly Dense
@attributes="@dt.Attrs">
</MTextField>
</ActivatorContent>
</PDateTimePicker>
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 " Outlined
@bind-Value="context.VariableName" Label=@AppService.I18n.T(context.Description(x => x.VariableName)) />
</SearchTemplate>
</AppDataTable>
</AdminTable>
@code {
RenderFragment Render(QuestDBPageInput model) =>
@<div class="row form-inline g-2">
<div class="col-12 ">
<BootstrapInput @bind-Value="model.VariableName" ShowLabel="true" />
</div>
<div class="col-12 ">
<DateTimeRange @bind-Value="model.SearchDate" ShowLabel="true" />
</div>
</div>;
}

View File

@@ -8,22 +8,24 @@
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using Microsoft.AspNetCore.Components;
namespace ThingsGateway.Plugin.QuestDB;
public partial class QuestDBPage : IDriverUIBase
{
private readonly QuestDBPageInput _search = new();
private IAppDataTable _datatable;
[Parameter, EditorRequired]
public object Driver { get; set; }
public QuestDBProducer QuestDBProducer => (QuestDBProducer)Driver;
private QuestDBPageInput CustomerSearchModel { get; set; } = new();
private async Task<SqlSugarPagedList<QuestDBHistoryValue>> QueryCallAsync(QuestDBPageInput input)
private async Task<QueryData<QuestDBHistoryValue>> OnQueryAsync(QueryPageOptions options)
{
var query = QuestDBProducer.Query(input);
var pageInfo = await query.ToPagedListAsync(input.Current, input.Size);//分页
return pageInfo;
var query = await QuestDBProducer.QueryData(options);
return query;
}
public QuestDBProducer QuestDBProducer => (QuestDBProducer)Driver;
}

View File

@@ -8,17 +8,39 @@
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using ThingsGateway.Core.Extension;
using ThingsGateway.Plugin.QuestDB;
namespace ThingsGateway.Gateway.Application;
public class QuestDBPageInput : DBPageInput
public class QuestDBPageInput : ITableSearchModel
{
/// <summary>
/// 开始时间
/// 时间区
/// </summary>
public override DateTime? StartTime { get; set; } = DateTime.Now.AddDays(-1);
public DateTimeRangeValue? SearchDate { get; set; }
/// <summary>
/// 结束时间
/// 变量名称,不为空时忽略<see cref="VariableNames"/>
/// </summary>
public override DateTime? EndTime { get; set; } = DateTime.Now.AddDays(1);
public virtual string? VariableName { get; set; }
/// <inheritdoc/>
public IEnumerable<IFilterAction> GetSearches()
{
var ret = new List<IFilterAction>();
ret.AddIF(!string.IsNullOrEmpty(VariableName), () => new SearchFilterAction(nameof(QuestDBHistoryValue.Name), VariableName));
ret.AddIF(SearchDate != null, () => new SearchFilterAction(nameof(QuestDBHistoryValue.CreateTime), SearchDate!.Start, FilterAction.GreaterThanOrEqual));
ret.AddIF(SearchDate != null, () => new SearchFilterAction(nameof(QuestDBHistoryValue.CreateTime), SearchDate!.End, FilterAction.LessThanOrEqual));
return ret;
}
/// <inheritdoc/>
public void Reset()
{
SearchDate = null;
VariableName = null;
}
}

View File

@@ -8,11 +8,13 @@
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using Mapster;
using SqlSugar;
using ThingsGateway.Admin.Core;
using ThingsGateway.Admin.Application;
using ThingsGateway.Core;
using ThingsGateway.Foundation;
@@ -21,7 +23,7 @@ namespace ThingsGateway.Plugin.QuestDB;
/// <summary>
/// QuestDBProducer
/// </summary>
public partial class QuestDBProducer : BusinessBaseWithCacheInterval<QuestDBHistoryValue>, IDBHistoryService
public partial class QuestDBProducer : BusinessBaseWithCacheIntervalVarModel<QuestDBHistoryValue>, IDBHistoryService
{
private readonly QuestDBProducerVariableProperty _variablePropertys = new();
internal readonly QuestDBProducerProperty _driverPropertys = new();
@@ -70,13 +72,56 @@ public partial class QuestDBProducer : BusinessBaseWithCacheInterval<QuestDBHist
protected override async Task ProtectedExecuteAsync(CancellationToken cancellationToken)
{
await UpdateTMemory(cancellationToken);
await UpdateVarModelMemory(cancellationToken);
await UpdateTCache(cancellationToken);
await UpdateVarModelCache(cancellationToken);
await Delay(cancellationToken);
}
internal async Task<QueryData<QuestDBHistoryValue>> QueryData(QueryPageOptions option)
{
using var db = BusinessDatabaseUtil.GetDb(_driverPropertys.DbType, _driverPropertys.BigTextConnectStr);
var ret = new QueryData<QuestDBHistoryValue>()
{
IsSorted = option.SortOrder != SortOrder.Unset,
IsFiltered = option.Filters.Any(),
IsAdvanceSearch = option.AdvanceSearches.Any(),
IsSearch = option.Searches.Any() || option.CustomerSearches.Any()
};
var query = db.GetQuery<QuestDBHistoryValue>(option);
if (option.IsPage)
{
RefAsync<int> totalCount = 0;
var items = await query
.ToPageListAsync(option.PageIndex, option.PageItems, totalCount);
ret.TotalCount = totalCount;
ret.Items = items;
}
else if (option.IsVirtualScroll)
{
RefAsync<int> totalCount = 0;
var items = await query
.ToPageListAsync(option.StartIndex, option.PageItems, totalCount);
ret.TotalCount = totalCount;
ret.Items = items;
}
else
{
var items = await query
.ToListAsync();
ret.TotalCount = items.Count;
ret.Items = items;
}
return ret;
}
internal ISugarQueryable<QuestDBHistoryValue> Query(DBPageInput input)
{
var db = BusinessDatabaseUtil.GetDb(_driverPropertys.DbType, _driverPropertys.BigTextConnectStr);

View File

@@ -8,12 +8,19 @@
// QQ群605534569
//------------------------------------------------------------------------------
using Mapster;
using ThingsGateway.Admin.Application;
using ThingsGateway.Foundation;
using TouchSocket.Core;
namespace ThingsGateway.Plugin.QuestDB;
/// <summary>
/// RabbitMQProducer
/// </summary>
public partial class QuestDBProducer : BusinessBaseWithCacheInterval<QuestDBHistoryValue>
public partial class QuestDBProducer : BusinessBaseWithCacheIntervalVarModel<QuestDBHistoryValue>
{
private TypeAdapterConfig _config;
@@ -53,7 +60,7 @@ public partial class QuestDBProducer : BusinessBaseWithCacheInterval<QuestDBHist
//var result = await db.Insertable(dbInserts).SplitTable().ExecuteCommandAsync();
if (result > 0)
{
LogMessage.Trace($"主题{nameof(QuestDBHistoryValue)}数量{result}");
LogMessage.Trace($"Topic{nameof(QuestDBHistoryValue)}Count{result}");
}
return new();
}

View File

@@ -15,5 +15,7 @@ namespace ThingsGateway.Plugin.QuestDB;
public class QuestDBProducerProperty : BusinessPropertyWithCacheInterval
{
public DbType DbType { get; set; } = DbType.QuestDB;
[DynamicProperty("链接字符串", "")] public string BigTextConnectStr { get; set; } = "host=localhost;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;";
[DynamicProperty]
public string BigTextConnectStr { get; set; } = "host=localhost;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;";
}

View File

@@ -3,12 +3,13 @@
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="@echo off&#xD;&#xA;setlocal enabledelayedexpansion&#xD;&#xA;&#xD;&#xA;set &quot;targetFWS=net6.0 net7.0 net8.0&quot;&#xD;&#xA;for %25%25f in (%25targetFWS%25) do (&#xD;&#xA; set &quot;dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)&quot;&#xD;&#xA; if not exist &quot;!dir!&quot; md &quot;!dir!&quot;&#xD;&#xA; copy &quot;$(TargetDir)*QuestDB*.dll&quot; &quot;!dir!&quot;&#xD;&#xA;)&#xD;&#xA;&#xD;&#xA;endlocal&#xD;&#xA;" />
<Exec Command="@echo off&#xD;&#xA;setlocal enabledelayedexpansion&#xD;&#xA;&#xD;&#xA;set targetFWS=$(TargetFrameworks)&#xD;&#xA;for %25%25f in (%25targetFWS%25) do (&#xD;&#xA; set &quot;dir=$(SolutionDir)ThingsGateway.Server\bin\$(Configuration)\%25%25f\Plugins\$(AssemblyName)&quot;&#xD;&#xA; if not exist &quot;!dir!&quot; md &quot;!dir!&quot;&#xD;&#xA; copy &quot;$(TargetDir)*QuestDB*.dll&quot; &quot;!dir!&quot;&#xD;&#xA;&#xD;&#xA;)&#xD;&#xA;&#xD;&#xA;endlocal&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;" />
</Target>
<ItemGroup>
<Content Remove="Locales\*.json" />
<EmbeddedResource Include="Locales\*.json" />
</ItemGroup>

View File

@@ -6,16 +6,11 @@
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using BlazorComponent
@using Masa.Blazor
@using Masa.Blazor.Presets
@using System.Net.Http.Json
@using System.IO;
@using System.Text.Json;
@using System.Reflection;
@using ThingsGateway.Components;
@using ThingsGateway.Admin.Core;
@using ThingsGateway.Admin.Application;
@using ThingsGateway.Core;

View File

@@ -0,0 +1,50 @@
{
"ThingsGateway.Plugin.RabbitMQ.RabbitMQProducerProperty": {
"IP": "IP",
"Port": "Port",
"UserName": "UserName",
"Password": "Password",
"IsQueueDeclare": "IsQueueDeclare",
"VirtualHost": "VirtualHost",
"ExchangeName": "ExchangeName",
"BigTextScriptDeviceModel": "BigTextScriptDeviceModel",
"BigTextScriptVariableModel": "BigTextScriptVariableModel",
"BigTextScriptAlarmModel": "BigTextScriptAlarmModel",
"IsDeviceList": "IsDeviceList",
"IsVariableList": "IsVariableList",
"IsAlarmList": "IsAlarmList",
"DeviceTopic": "DeviceTopic",
"VariableTopic": "VariableTopic",
"AlarmTopic": "AlarmTopic",
"IsInterval": "IsInterval",
"BusinessInterval": "BusinessInterval",
"IsAllVariable": "IsAllVariable",
"QueueMaxCount": "QueueMaxCount",
"SplitSize": "SplitSize",
"CacheEnable": "CacheEnable"
},
"ThingsGateway.Plugin.Mqtt.MqttServerProperty": {
"IP": "IP",
"Port": "Port",
"WebSocketPort": "WebSocketPort",
"StartWithId": "StartWithId",
"DeviceRpcEnable": "DeviceRpcEnable",
"RpcWriteTopic": "RpcWriteTopic",
"BigTextScriptDeviceModel": "BigTextScriptDeviceModel",
"BigTextScriptVariableModel": "BigTextScriptVariableModel",
"BigTextScriptAlarmModel": "BigTextScriptAlarmModel",
"IsDeviceList": "IsDeviceList",
"IsVariableList": "IsVariableList",
"IsAlarmList": "IsAlarmList",
"DeviceTopic": "DeviceTopic",
"VariableTopic": "VariableTopic",
"AlarmTopic": "AlarmTopic",
"IsInterval": "IsInterval",
"BusinessInterval": "BusinessInterval",
"IsAllVariable": "IsAllVariable",
"QueueMaxCount": "QueueMaxCount",
"SplitSize": "SplitSize",
"CacheEnable": "CacheEnable"
}
}

View File

@@ -0,0 +1,56 @@
{
"ThingsGateway.Plugin.RabbitMQ.RabbitMQProducerProperty": {
"IP": "IP",
"Port": "端口",
"UserName": "用户名",
"Password": "密码",
"IsQueueDeclare": "声明队列",
"VirtualHost": "虚拟Host",
"ExchangeName": "交换机名称",
"BigTextScriptDeviceModel": "设备上传脚本",
"BigTextScriptVariableModel": "变量上传脚本",
"BigTextScriptAlarmModel": "报警上传脚本",
"IsDeviceList": "设备状态列表上传",
"IsVariableList": "变量列表上传",
"IsAlarmList": "报警列表上传",
"DeviceTopic": "设备主题",
"VariableTopic": "变量主题",
"AlarmTopic": "比较主题",
"IsInterval": "启用定时上传",
"BusinessInterval": "定时上传间隔",
"IsAllVariable": "选择全部变量",
"QueueMaxCount": "内存队列最大数量",
"SplitSize": "上传每页条数",
"CacheEnable": "启用缓存"
},
"ThingsGateway.Plugin.Mqtt.MqttServerProperty": {
"IP": "IP",
"Port": "端口",
"WebSocketPort": "Websocket端口",
"StartWithId": "允许连接的ID前缀",
"DeviceRpcEnable": "允许Rpc写入",
"RpcWriteTopic": "Rpc写入主题",
"BigTextScriptDeviceModel": "设备上传脚本",
"BigTextScriptVariableModel": "变量上传脚本",
"BigTextScriptAlarmModel": "报警上传脚本",
"IsDeviceList": "设备状态列表上传",
"IsVariableList": "变量列表上传",
"IsAlarmList": "报警列表上传",
"DeviceTopic": "设备主题",
"VariableTopic": "变量主题",
"AlarmTopic": "比较主题",
"IsInterval": "启用定时上传",
"BusinessInterval": "定时上传间隔",
"IsAllVariable": "选择全部变量",
"QueueMaxCount": "内存队列最大数量",
"SplitSize": "上传每页条数",
"CacheEnable": "启用缓存"
}
}

View File

@@ -14,6 +14,7 @@ using RabbitMQ.Client;
using System.Text;
using ThingsGateway.Admin.Application;
using ThingsGateway.Foundation;
using ThingsGateway.Foundation.Extension.Generic;
@@ -32,13 +33,13 @@ public partial class RabbitMQProducer : BusinessBaseWithCacheIntervalScript<Vari
protected override void VariableChange(VariableRunTime variableRunTime, VariableData variable)
{
AddQueueVarModel(new(variableRunTime.Adapt<VariableData>()));
AddQueueVarModel(new(variable));
base.VariableChange(variableRunTime, variable);
}
protected override void DeviceChange(DeviceRunTime deviceRunTime, DeviceData deviceData)
{
AddQueueDevModel(new(deviceRunTime.Adapt<DeviceData>()));
AddQueueDevModel(new(deviceData));
base.DeviceChange(deviceRunTime, deviceData);
}
@@ -112,9 +113,9 @@ public partial class RabbitMQProducer : BusinessBaseWithCacheIntervalScript<Vari
{
//保留消息
//分解List避免超出字节大小限制
var varData = CurrentDevice.VariableRunTimes.Adapt<List<VariableData>>().ChunkBetter(_driverPropertys.SplitSize);
var devData = CollectDevices.Adapt<List<DeviceData>>().ChunkBetter(_driverPropertys.SplitSize);
var alramData = WorkerUtil.GetWoker<AlarmWorker>().RealAlarmVariables.Adapt<List<AlarmVariable>>().ChunkBetter(_driverPropertys.SplitSize);
var varData = CurrentDevice.VariableRunTimes.Values.Adapt<List<VariableData>>().ChunkBetter(_driverPropertys.SplitSize);
var devData = CollectDevices.Values.Adapt<List<DeviceData>>().ChunkBetter(_driverPropertys.SplitSize);
var alramData = GlobalData.ReadOnlyRealAlarmVariables.Adapt<List<AlarmVariable>>().ChunkBetter(_driverPropertys.SplitSize);
foreach (var item in varData)
{
if (!success)
@@ -149,12 +150,12 @@ public partial class RabbitMQProducer : BusinessBaseWithCacheIntervalScript<Vari
if (_model != null)
{
_model.BasicPublish(_driverPropertys.ExchangeName, topic, properties, Encoding.UTF8.GetBytes(payLoad));
LogMessage.Trace($"主题{topic}{Environment.NewLine}负载{payLoad}");
LogMessage.Trace($"Topic{topic}{Environment.NewLine}PayLoad{payLoad}");
return new();
}
else
{
return new("上传失败");
return new("Upload fail");
}
}
catch (Exception ex)

View File

@@ -20,37 +20,37 @@ public class RabbitMQProducerProperty : BusinessPropertyWithCacheIntervalScript
/// <summary>
/// IP
/// </summary>
[DynamicProperty("IP", "")]
[DynamicProperty]
public string IP { get; set; } = "localhost";
/// <summary>
/// 端口
/// </summary>
[DynamicProperty("端口", "")]
[DynamicProperty]
public int Port { get; set; } = 5672;
/// <summary>
/// UserName
/// </summary>
[DynamicProperty("账号", "")]
[DynamicProperty]
public string UserName { get; set; } = "guest";
/// <summary>
/// Password
/// </summary>
[DynamicProperty("密码", "")]
[DynamicProperty]
public string Password { get; set; } = "guest";
/// <summary>
/// IsQueueDeclare
/// </summary>
[DynamicProperty("是否声明队列", "不支持动态通配符主题")]
[DynamicProperty]
public bool IsQueueDeclare { get; set; } = false;
/// <summary>
/// VirtualHost
/// </summary>
[DynamicProperty("虚拟Host", "")]
[DynamicProperty]
public string VirtualHost { get; set; } = ConnectionFactory.DefaultVHost;
///// <summary>
@@ -62,6 +62,6 @@ public class RabbitMQProducerProperty : BusinessPropertyWithCacheIntervalScript
/// <summary>
/// 交换机名称
/// </summary>
[DynamicProperty("交换机名称", "")]
[DynamicProperty]
public string? ExchangeName { get; set; } = "";
}

View File

@@ -15,6 +15,7 @@
<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<Content Remove="Locales\*.json" />
<EmbeddedResource Include="Locales\*.json" />

View File

@@ -15,7 +15,7 @@ using SqlSugar;
using System.ComponentModel.DataAnnotations;
using System.Reflection;
using ThingsGateway.Admin.Core;
using ThingsGateway.Admin.Application;
using ThingsGateway.Plugin.SqlDB;
namespace ThingsGateway.Gateway.Application;

View File

@@ -12,7 +12,6 @@ using Mapster;
using SqlSugar;
using ThingsGateway.Admin.Core;
using ThingsGateway.Core;
using ThingsGateway.Foundation;
@@ -21,7 +20,7 @@ namespace ThingsGateway.Plugin.SqlDB;
/// <summary>
/// SqlDBProducer
/// </summary>
public partial class SqlDBProducer : BusinessBaseWithCacheInterval<SQLHistoryValue>, IDBHistoryService
public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVarModel<SQLHistoryValue>, IDBHistoryService
{
private readonly SqlDBProducerVariableProperty _variablePropertys = new();
internal readonly SqlDBProducerProperty _driverPropertys = new();

View File

@@ -10,6 +10,7 @@
using Mapster;
using ThingsGateway.Admin.Application;
using ThingsGateway.Foundation;
using TouchSocket.Core;
@@ -19,7 +20,7 @@ namespace ThingsGateway.Plugin.SqlDB;
/// <summary>
/// SqlDBProducer
/// </summary>
public partial class SqlDBProducer : BusinessBaseWithCacheInterval<SQLHistoryValue>
public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVarModel<SQLHistoryValue>
{
private TypeAdapterConfig _config;
private TimeTick _exRealTimerTick;