更新插件
This commit is contained in:
@@ -13,5 +13,4 @@ global using System.Collections.Generic;
|
||||
global using System.Threading;
|
||||
global using System.Threading.Tasks;
|
||||
|
||||
global using ThingsGateway.Components;
|
||||
global using ThingsGateway.Gateway.Application;
|
@@ -2,86 +2,66 @@
|
||||
@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 BootstrapBlazor.Components
|
||||
@using ThingsGateway.Gateway.Application
|
||||
@namespace ThingsGateway.Plugin.SqlDB
|
||||
@inject UserResoures UserResoures
|
||||
@inherits BaseComponentBase
|
||||
|
||||
@if (SqlDBProducer._driverPropertys.IsHisDB)
|
||||
{
|
||||
<MCardText>
|
||||
@AppService.I18n.T("历史表")
|
||||
</MCardText>
|
||||
<div>
|
||||
HistoryValue
|
||||
</div>
|
||||
|
||||
<AppDataTable @ref="_datatable" TItem="SQLHistoryValue" SearchItem="SqlDBPageInput"
|
||||
AddItem="object" EditItem="object" IsShowSelect=false
|
||||
SearchModel="@_search" IsShowOperCol=true
|
||||
QueryCallAsync="QueryCallAsync" FirstQuery=false
|
||||
IsShowDetailButton IsShowQueryButton>
|
||||
<SearchTemplate>
|
||||
<AdminTable TItem="SQLHistoryValue" AutoGenerateColumns="true" ShowDefaultButtons=false
|
||||
AllowResizing="true" IsFixedHeader=true IsMultipleSelect=false
|
||||
ShowExtendEditButton=false ShowExtendDeleteButton=false ShowExtendButtons=false
|
||||
ShowExportButton="true"
|
||||
OnQueryAsync="OnQueryHisAsync" IsPagination=true CustomerSearchModel="@_searchHis">
|
||||
<CustomerSearchTemplate>
|
||||
@if (context is SqlDBPageInput 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>
|
||||
</AdminTable>
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
}
|
||||
@if (SqlDBProducer._driverPropertys.IsReadDB)
|
||||
{
|
||||
<MCardText>
|
||||
@AppService.I18n.T("实时表")
|
||||
</MCardText>
|
||||
<AppDataTable @ref="_datatable" TItem="SQLRealValue" SearchItem="SqlDBPageInput"
|
||||
AddItem="object" EditItem="object" IsShowSelect=false
|
||||
SearchModel="@_searchReal" IsShowOperCol=true
|
||||
QueryCallAsync="RealQueryCallAsync" FirstQuery=false
|
||||
IsShowDetailButton IsShowQueryButton>
|
||||
<SearchTemplate>
|
||||
<div>
|
||||
ReadValue
|
||||
</div>
|
||||
|
||||
<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 TItem="SQLRealValue" AutoGenerateColumns="true" ShowDefaultButtons=false
|
||||
AllowResizing="true" IsFixedHeader=true IsMultipleSelect=false
|
||||
ShowExtendEditButton=false ShowExtendDeleteButton=false ShowExtendButtons=false
|
||||
ShowExportButton="true"
|
||||
OnQueryAsync="OnQueryRealAsync" IsPagination=true CustomerSearchModel="@_searchReal">
|
||||
<CustomerSearchTemplate>
|
||||
@if (context is SqlDBPageInput model)
|
||||
{
|
||||
@Render(model)
|
||||
}
|
||||
</CustomerSearchTemplate>
|
||||
|
||||
</AdminTable>
|
||||
|
||||
}
|
||||
@code {
|
||||
RenderFragment Render(SqlDBPageInput 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>;
|
||||
|
||||
}
|
@@ -8,47 +8,31 @@
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using BootstrapBlazor.Components;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
using SqlSugar;
|
||||
|
||||
using ThingsGateway.Admin.Core;
|
||||
using ThingsGateway.Core;
|
||||
|
||||
namespace ThingsGateway.Plugin.SqlDB;
|
||||
|
||||
public partial class SqlDBPage : IDriverUIBase
|
||||
{
|
||||
private readonly SqlDBPageInput _search = new();
|
||||
private readonly SqlDBPageInput _searchHis = new();
|
||||
private readonly SqlDBPageInput _searchReal = new();
|
||||
private IAppDataTable _datatable;
|
||||
|
||||
[Parameter, EditorRequired]
|
||||
public object Driver { get; set; }
|
||||
|
||||
public SqlDBProducer SqlDBProducer => (SqlDBProducer)Driver;
|
||||
|
||||
private async Task<SqlSugarPagedList<SQLHistoryValue>> QueryCallAsync(SqlDBPageInput input)
|
||||
private async Task<QueryData<SQLHistoryValue>> OnQueryHisAsync(QueryPageOptions options)
|
||||
{
|
||||
var query = SqlDBProducer.Query(input);
|
||||
var pageInfo = await query.ToPagedListAsync(input.Current, input.Size);//分页
|
||||
return pageInfo;
|
||||
var query = await SqlDBProducer.QueryHisData(options);
|
||||
return query;
|
||||
}
|
||||
|
||||
private async Task<SqlSugarPagedList<SQLRealValue>> RealQueryCallAsync(SqlDBPageInput input)
|
||||
private async Task<QueryData<SQLRealValue>> OnQueryRealAsync(QueryPageOptions options)
|
||||
{
|
||||
using var db = SqlDBBusinessDatabaseUtil.GetDb(SqlDBProducer._driverPropertys);
|
||||
var query = db.Queryable<SQLRealValue>().AS(SqlDBProducer._driverPropertys.ReadDBTableName)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.VariableName), it => it.Name.Contains(input.VariableName))
|
||||
;
|
||||
|
||||
for (int i = input.SortField.Count - 1; i >= 0; i--)
|
||||
{
|
||||
query = query.OrderByIF(!string.IsNullOrEmpty(input.SortField[i]), $"{input.SortField[i]} {(input.SortDesc[i] ? "desc" : "asc")}");
|
||||
}
|
||||
query = query.OrderBy(it => it.Id, OrderByType.Desc);//排序
|
||||
|
||||
var pageInfo = await query.ToPagedListAsync(input.Current, input.Size);//分页
|
||||
return pageInfo;
|
||||
var query = await SqlDBProducer.QueryRealData(options);
|
||||
return query;
|
||||
}
|
||||
}
|
@@ -8,17 +8,39 @@
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using BootstrapBlazor.Components;
|
||||
|
||||
using ThingsGateway.Core.Extension;
|
||||
using ThingsGateway.Plugin.SqlDB;
|
||||
|
||||
namespace ThingsGateway.Gateway.Application;
|
||||
|
||||
public class SqlDBPageInput : DBPageInput
|
||||
public class SqlDBPageInput : 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(SQLHistoryValue.Name), VariableName));
|
||||
ret.AddIF(SearchDate != null, () => new SearchFilterAction(nameof(SQLHistoryValue.CreateTime), SearchDate!.Start, FilterAction.GreaterThanOrEqual));
|
||||
ret.AddIF(SearchDate != null, () => new SearchFilterAction(nameof(SQLHistoryValue.CreateTime), SearchDate!.End, FilterAction.LessThanOrEqual));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Reset()
|
||||
{
|
||||
SearchDate = null;
|
||||
VariableName = null;
|
||||
}
|
||||
}
|
@@ -8,6 +8,8 @@
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using BootstrapBlazor.Components;
|
||||
|
||||
using Mapster;
|
||||
|
||||
using SqlSugar;
|
||||
@@ -104,6 +106,92 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVarModel<SQLHi
|
||||
await Delay(cancellationToken);
|
||||
}
|
||||
|
||||
internal async Task<QueryData<SQLHistoryValue>> QueryHisData(QueryPageOptions option)
|
||||
{
|
||||
var db = SqlDBBusinessDatabaseUtil.GetDb(_driverPropertys);
|
||||
var ret = new QueryData<SQLHistoryValue>()
|
||||
{
|
||||
IsSorted = option.SortOrder != SortOrder.Unset,
|
||||
IsFiltered = option.Filters.Any(),
|
||||
IsAdvanceSearch = option.AdvanceSearches.Any(),
|
||||
IsSearch = option.Searches.Any() || option.CustomerSearches.Any()
|
||||
};
|
||||
|
||||
var query = db.GetQuery<SQLHistoryValue>(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 async Task<QueryData<SQLRealValue>> QueryRealData(QueryPageOptions option)
|
||||
{
|
||||
var db = SqlDBBusinessDatabaseUtil.GetDb(_driverPropertys);
|
||||
var ret = new QueryData<SQLRealValue>()
|
||||
{
|
||||
IsSorted = option.SortOrder != SortOrder.Unset,
|
||||
IsFiltered = option.Filters.Any(),
|
||||
IsAdvanceSearch = option.AdvanceSearches.Any(),
|
||||
IsSearch = option.Searches.Any() || option.CustomerSearches.Any()
|
||||
};
|
||||
|
||||
var query = db.GetQuery<SQLRealValue>(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<SQLHistoryValue> Query(DBPageInput input)
|
||||
{
|
||||
var db = SqlDBBusinessDatabaseUtil.GetDb(_driverPropertys);
|
||||
|
@@ -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;
|
||||
|
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ThingsGateway.Plugin.TDengineDB.TDengineDBProducerProperty": {
|
||||
"BigTextConnectStr": "ConnectString",
|
||||
|
||||
"IsInterval": "IsInterval",
|
||||
"BusinessInterval": "BusinessInterval",
|
||||
"IsAllVariable": "IsAllVariable",
|
||||
"QueueMaxCount": "QueueMaxCount",
|
||||
"SplitSize": "SplitSize",
|
||||
"CacheEnable": "CacheEnable"
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ThingsGateway.Plugin.TDengineDB.TDengineDBProducerProperty": {
|
||||
"BigTextConnectStr": "连接字符串",
|
||||
|
||||
"IsInterval": "启用定时上传",
|
||||
"BusinessInterval": "定时上传间隔",
|
||||
"IsAllVariable": "选择全部变量",
|
||||
"QueueMaxCount": "内存队列最大数量",
|
||||
"SplitSize": "上传每页条数",
|
||||
"CacheEnable": "启用缓存"
|
||||
}
|
||||
}
|
@@ -8,6 +8,8 @@
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using BootstrapBlazor.Components;
|
||||
|
||||
using SqlSugar;
|
||||
using SqlSugar.TDengine;
|
||||
|
||||
@@ -31,35 +33,35 @@ public class TDengineDBHistoryValue : STable, IPrimaryIdEntity, IDBHistoryValue
|
||||
/// </summary>
|
||||
[SugarColumn(InsertServerTime = true)]
|
||||
[Description("上传时间")]
|
||||
[DataTable(Order = 1, IsShow = true, Sortable = true, DefaultFilter = false, CellClass = " table-text-truncate ")]
|
||||
[AutoGenerateColumn(Order = 1, Visible = true, Sortable = true, Filterable = false)]
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 采集时间
|
||||
/// </summary>
|
||||
[Description("采集时间")]
|
||||
[DataTable(Order = 1, IsShow = true, Sortable = true, DefaultFilter = false, CellClass = " table-text-truncate ")]
|
||||
[AutoGenerateColumn(Order = 1, Visible = true, Sortable = true, Filterable = false)]
|
||||
public DateTime CollectTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备名称
|
||||
/// </summary>
|
||||
[Description("设备名称")]
|
||||
[DataTable(Order = 1, IsShow = true, Sortable = true, DefaultFilter = false, CellClass = " table-text-truncate ")]
|
||||
[AutoGenerateColumn(Order = 1, Visible = true, Sortable = true, Filterable = false)]
|
||||
public string DeviceName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 变量名称
|
||||
/// </summary>
|
||||
[Description("变量名称")]
|
||||
[DataTable(Order = 1, IsShow = true, Sortable = true, DefaultFilter = false, CellClass = " table-text-truncate ")]
|
||||
[AutoGenerateColumn(Order = 1, Visible = true, Sortable = true, Filterable = false)]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否在线
|
||||
/// </summary>
|
||||
[Description("是否在线")]
|
||||
[DataTable(Order = 1, IsShow = true, Sortable = true, DefaultFilter = false, CellClass = " table-text-truncate ")]
|
||||
[AutoGenerateColumn(Order = 1, Visible = true, Sortable = true, Filterable = false)]
|
||||
public bool IsOnline { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -67,6 +69,6 @@ public class TDengineDBHistoryValue : STable, IPrimaryIdEntity, IDBHistoryValue
|
||||
/// </summary>
|
||||
[Description("变量值")]
|
||||
[SugarColumn(Length = 18, DecimalDigits = 2)]
|
||||
[DataTable(Order = 1, IsShow = true, Sortable = true, DefaultFilter = false, CellClass = " table-text-truncate ")]
|
||||
[AutoGenerateColumn(Order = 1, Visible = true, Sortable = true, Filterable = false)]
|
||||
public string Value { get; set; }
|
||||
}
|
@@ -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.TDengineDB
|
||||
@inject UserResoures UserResoures
|
||||
@inherits BaseComponentBase
|
||||
|
||||
|
||||
<AppDataTable @ref="_datatable" TItem="TDengineDBHistoryValue" SearchItem="TDengineDBPageInput"
|
||||
AddItem="object" EditItem="object" IsShowSelect=false
|
||||
SearchModel="@_search" IsShowOperCol=true
|
||||
QueryCallAsync="QueryCallAsync" FirstQuery=false
|
||||
IsShowDetailButton IsShowQueryButton>
|
||||
<SearchTemplate>
|
||||
<AdminTable TItem="TDengineDBHistoryValue" 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 TDengineDBPageInput 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(TDengineDBPageInput 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>;
|
||||
|
||||
}
|
||||
|
@@ -8,22 +8,24 @@
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using BootstrapBlazor.Components;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace ThingsGateway.Plugin.TDengineDB;
|
||||
|
||||
public partial class TDengineDBPage : IDriverUIBase
|
||||
{
|
||||
private readonly TDengineDBPageInput _search = new();
|
||||
private IAppDataTable _datatable;
|
||||
|
||||
[Parameter, EditorRequired]
|
||||
public object Driver { get; set; }
|
||||
|
||||
public TDengineDBProducer TDengineDBProducer => (TDengineDBProducer)Driver;
|
||||
private TDengineDBPageInput CustomerSearchModel { get; set; } = new();
|
||||
|
||||
private async Task<SqlSugarPagedList<TDengineDBHistoryValue>> QueryCallAsync(TDengineDBPageInput input)
|
||||
private async Task<QueryData<TDengineDBHistoryValue>> OnQueryAsync(QueryPageOptions options)
|
||||
{
|
||||
var query = TDengineDBProducer.Query(input);
|
||||
var pageInfo = await query.ToPagedListAsync(input.Current, input.Size);//分页
|
||||
return pageInfo;
|
||||
var query = await TDengineDBProducer.QueryData(options);
|
||||
return query;
|
||||
}
|
||||
|
||||
public TDengineDBProducer TDengineDBProducer => (TDengineDBProducer)Driver;
|
||||
}
|
@@ -8,17 +8,39 @@
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using BootstrapBlazor.Components;
|
||||
|
||||
using ThingsGateway.Core.Extension;
|
||||
using ThingsGateway.Plugin.TDengineDB;
|
||||
|
||||
namespace ThingsGateway.Gateway.Application;
|
||||
|
||||
public class TDengineDBPageInput : DBPageInput
|
||||
public class TDengineDBPageInput : 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(TDengineDBHistoryValue.Name), VariableName));
|
||||
ret.AddIF(SearchDate != null, () => new SearchFilterAction(nameof(TDengineDBHistoryValue.CreateTime), SearchDate!.Start, FilterAction.GreaterThanOrEqual));
|
||||
ret.AddIF(SearchDate != null, () => new SearchFilterAction(nameof(TDengineDBHistoryValue.CreateTime), SearchDate!.End, FilterAction.LessThanOrEqual));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Reset()
|
||||
{
|
||||
SearchDate = null;
|
||||
VariableName = null;
|
||||
}
|
||||
}
|
@@ -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.TDengineDB;
|
||||
/// <summary>
|
||||
/// TDengineDBProducer
|
||||
/// </summary>
|
||||
public partial class TDengineDBProducer : BusinessBaseWithCacheInterval<TDengineDBHistoryValue>, IDBHistoryService
|
||||
public partial class TDengineDBProducer : BusinessBaseWithCacheIntervalVarModel<TDengineDBHistoryValue>, IDBHistoryService
|
||||
{
|
||||
private readonly TDengineDBProducerVariableProperty _variablePropertys = new();
|
||||
internal readonly TDengineDBProducerProperty _driverPropertys = new();
|
||||
@@ -68,12 +70,55 @@ public partial class TDengineDBProducer : BusinessBaseWithCacheInterval<TDengine
|
||||
|
||||
protected override async Task ProtectedExecuteAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await UpdateTMemory(cancellationToken);
|
||||
await UpdateTCache(cancellationToken);
|
||||
await UpdateVarModelMemory(cancellationToken);
|
||||
await UpdateVarModelCache(cancellationToken);
|
||||
|
||||
await Delay(cancellationToken);
|
||||
}
|
||||
|
||||
internal async Task<QueryData<TDengineDBHistoryValue>> QueryData(QueryPageOptions option)
|
||||
{
|
||||
using var db = BusinessDatabaseUtil.GetDb(_driverPropertys.DbType, _driverPropertys.BigTextConnectStr);
|
||||
var ret = new QueryData<TDengineDBHistoryValue>()
|
||||
{
|
||||
IsSorted = option.SortOrder != SortOrder.Unset,
|
||||
IsFiltered = option.Filters.Any(),
|
||||
IsAdvanceSearch = option.AdvanceSearches.Any(),
|
||||
IsSearch = option.Searches.Any() || option.CustomerSearches.Any()
|
||||
};
|
||||
|
||||
var query = db.GetQuery<TDengineDBHistoryValue>(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<TDengineDBHistoryValue> Query(DBPageInput input)
|
||||
{
|
||||
var db = BusinessDatabaseUtil.GetDb(_driverPropertys.DbType, _driverPropertys.BigTextConnectStr);
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
using Mapster;
|
||||
|
||||
using ThingsGateway.Cache;
|
||||
using ThingsGateway.Admin.Application;
|
||||
using ThingsGateway.Foundation;
|
||||
|
||||
using TouchSocket.Core;
|
||||
@@ -20,7 +20,7 @@ namespace ThingsGateway.Plugin.TDengineDB;
|
||||
/// <summary>
|
||||
/// RabbitMQProducer
|
||||
/// </summary>
|
||||
public partial class TDengineDBProducer : BusinessBaseWithCacheInterval<TDengineDBHistoryValue>
|
||||
public partial class TDengineDBProducer : BusinessBaseWithCacheIntervalVarModel<TDengineDBHistoryValue>
|
||||
{
|
||||
private TypeAdapterConfig _config;
|
||||
|
||||
|
@@ -15,5 +15,7 @@ namespace ThingsGateway.Plugin.TDengineDB;
|
||||
public class TDengineDBProducerProperty : BusinessPropertyWithCacheInterval
|
||||
{
|
||||
public DbType DbType { get; set; } = DbType.TDengine;
|
||||
[DynamicProperty("链接字符串", "")] public string BigTextConnectStr { get; set; } = "Host=localhost;Port=6030;Username=root;Password=taosdata;Database=test";
|
||||
|
||||
[DynamicProperty]
|
||||
public string BigTextConnectStr { get; set; } = "Host=localhost;Port=6030;Username=root;Password=taosdata;Database=test";
|
||||
}
|
@@ -3,10 +3,16 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Exec Command="@echo off
setlocal enabledelayedexpansion

set "targetFWS=net6.0 net7.0 net8.0"
for %25%25f in (%25targetFWS%25) do (
 set "dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)"
 if not exist "!dir!" md "!dir!"
 copy "$(TargetDir)*TDengineDB*.dll" "!dir!"
)

endlocal
" />
|
||||
<Exec Command="@echo off
setlocal enabledelayedexpansion

set targetFWS=$(TargetFrameworks)
for %25%25f in (%25targetFWS%25) do (
 set "dir=$(SolutionDir)ThingsGateway.Server\bin\$(Configuration)\%25%25f\Plugins\$(AssemblyName)"
 if not exist "!dir!" md "!dir!"
 copy "$(TargetDir)*TDengineDB*.dll" "!dir!"

)

endlocal


" />
|
||||
</Target>
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="Locales\*.json" />
|
||||
<EmbeddedResource Include="Locales\*.json" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user