release:6.1.0.20

feat: 添加报警确认api
feat: 添加插件属性自定义ui
This commit is contained in:
Diego
2024-09-05 11:45:28 +08:00
parent ec3607f779
commit 5c63359550
22 changed files with 137 additions and 35 deletions

View File

@@ -2,16 +2,16 @@
<!--PRO插件需补充 LicenseKey 文件也可以不依赖单独放到Plugins文件夹内-->
<ItemGroup>
<PackageReference Include="ThingsGateway.Plugin.DCON" Version="*"/>
<!--<PackageReference Include="ThingsGateway.Plugin.DKQ_A16D" Version="*" />-->
<PackageReference Include="ThingsGateway.Plugin.EDPF_NT" Version="*" />
<!--<PackageReference Include="ThingsGateway.Plugin.IDR210" Version="*" />-->
<PackageReference Include="ThingsGateway.Plugin.KELID2008" Version="*" />
<PackageReference Include="ThingsGateway.Plugin.LKSIS" Version="*" />
<PackageReference Include="ThingsGateway.Plugin.Melsec" Version="*" />
<PackageReference Include="ThingsGateway.Plugin.Omron" Version="*" />
<!--<PackageReference Include="ThingsGateway.Plugin.URF_R330" Version="*" />-->
<PackageReference Include="ThingsGateway.Plugin.USBScaner" Version="*" />
<PackageReference Include="ThingsGateway.Plugin.DCON" Version="6.1.0.20"/>
<!--<PackageReference Include="ThingsGateway.Plugin.DKQ_A16D" Version="6.1.0.20" />-->
<PackageReference Include="ThingsGateway.Plugin.EDPF_NT" Version="6.1.0.20" />
<!--<PackageReference Include="ThingsGateway.Plugin.IDR210" Version="6.1.0.20" />-->
<PackageReference Include="ThingsGateway.Plugin.KELID2008" Version="6.1.0.20" />
<PackageReference Include="ThingsGateway.Plugin.LKSIS" Version="6.1.0.20" />
<PackageReference Include="ThingsGateway.Plugin.Melsec" Version="6.1.0.20" />
<PackageReference Include="ThingsGateway.Plugin.Omron" Version="6.1.0.20" />
<!--<PackageReference Include="ThingsGateway.Plugin.URF_R330" Version="6.1.0.20" />-->
<PackageReference Include="ThingsGateway.Plugin.USBScaner" Version="6.1.0.20" />
</ItemGroup>

View File

@@ -16,6 +16,7 @@
<ItemGroup>
<ProjectReference Include="$(SolutionDir)ThingsGateway.Gateway.Razor\ThingsGateway.Gateway.Razor.csproj">
<PrivateAssets>all</PrivateAssets>
<Private>false</Private>
<ExcludeAssets>runtime</ExcludeAssets>
</ProjectReference>

View File

@@ -14,6 +14,13 @@
"TargetId": "212725263001002",
"ExtJson": null
},
{
"Id": 503217516294214,
"Category": "UserHasRole",
"ObjectId": 502961796145221,
"TargetId": "502961260494917",
"ExtJson": null
},
{
"Id": 103217516294213,
"ObjectId": 212725263001001,
@@ -22,4 +29,4 @@
"ExtJson": ""
}
]
}
}

View File

@@ -20,7 +20,7 @@ public class OpenApiLoginInput
/// <summary>
/// 账号
///</summary>
/// <example>apiAdmin</example>
/// <example>ApiAdmin</example>
[Required]
public string Account { get; set; }

View File

@@ -65,6 +65,19 @@ public class RuntimeInfoControler : ControllerBase
.ToPagedList(input);
return data.Adapt<SqlSugarPagedList<AlarmVariable>>();
}
/// <summary>
/// 确认实时报警
/// </summary>
/// <returns></returns>
[HttpPost("checkRealAlarm")]
[DisplayName("确认实时报警")]
public void CheckRealAlarm(string variableName)
{
if (GlobalData.ReadOnlyRealAlarmVariables.TryGetValue(variableName, out var variable))
{
HostedServiceUtil.AlarmHostedService.ConfirmAlarm(variable);
}
}
/// <summary>
/// 获取变量信息

View File

@@ -18,7 +18,8 @@
"RuntimeInfoControler": "Get runtime information",
"GetCollectDeviceList": "Get device information",
"GetVariableList": "Get variable information",
"GetRealAlarmList": "Get real-time alarm information"
"GetRealAlarmList": "Get real-time alarm information",
"CheckRealAlarm": "Confirm real-time alarm"
}

View File

@@ -18,7 +18,8 @@
"RuntimeInfoControler": "获取运行态信息",
"GetCollectDeviceList": "获取设备信息",
"GetVariableList": "获取变量信息",
"GetRealAlarmList": "获取实时报警信息"
"GetRealAlarmList": "获取实时报警信息",
"CheckRealAlarm": "确认实时报警"
}

View File

@@ -17,6 +17,7 @@
"RuntimeInfoControler": "獲取運行態信息",
"GetCollectDeviceList": "獲取設備信息",
"GetVariableList": "獲取變量信息",
"GetRealAlarmList": "獲取實時警報信息"
"GetRealAlarmList": "獲取實時警報信息",
"CheckRealAlarm": "確認實時警報"
}
}

View File

@@ -28,7 +28,7 @@ public enum EventTypeEnum
/// <summary>
/// 报警确认
/// </summary>
Check,
Confirm,
/// <summary>
/// 报警恢复

View File

@@ -377,17 +377,6 @@ public class AlarmHostedService : BackgroundService
}
changed = true;
}
else if (eventEnum == EventTypeEnum.Check)
{
// 如果是确认报警事件
item.AlarmType = alarmEnum;
item.EventType = eventEnum;
item.AlarmLimit = limit.ToString();
item.AlarmCode = item.Value.ToString();
item.AlarmText = text;
item.EventTime = DateTime.Now;
changed = true;
}
// 触发报警变化事件
if (changed)
@@ -401,9 +390,9 @@ public class AlarmHostedService : BackgroundService
RealAlarmVariables.AddOrUpdate(item.Name, a => item, (a, b) => item);
}
}
else
else if (item.EventType == EventTypeEnum.Finish)
{
// 如果是需恢复报警事件或检查报警事件,则从实时报警列表中移除该变量
// 如果是需恢复报警事件,则从实时报警列表中移除该变量
RealAlarmVariables.TryRemove(item.Name, out _);
}
OnAlarmChanged?.Invoke(item.Adapt<AlarmVariable>());
@@ -412,6 +401,14 @@ public class AlarmHostedService : BackgroundService
}
public void ConfirmAlarm(VariableRunTime item)
{
// 如果是确认报警事件
item.EventType = EventTypeEnum.Confirm;
item.EventTime = DateTime.Now;
OnAlarmChanged?.Invoke(item.Adapt<AlarmVariable>());
}
#endregion
#region 线

View File

@@ -52,6 +52,11 @@ public abstract class DriverBase : DisposableObject
/// </summary>
public virtual Type DriverDebugUIType { get; }
/// <summary>
/// 插件属性UI Type如果不存在返回null
/// </summary>
public virtual Type DriverPropertyUIType { get; }
/// <summary>
/// 插件配置项
/// </summary>

View File

@@ -35,7 +35,7 @@ public interface IPluginService
/// <param name="pluginName"></param>
/// <param name="driverBase"></param>
/// <returns></returns>
(IEnumerable<IEditorItem> EditorItems, object Model) GetDriverPropertyTypes(string pluginName, DriverBase? driverBase = null);
(IEnumerable<IEditorItem> EditorItems, object Model, Type PropertyUIType) GetDriverPropertyTypes(string pluginName, DriverBase? driverBase = null);
/// <summary>
/// 根据插件类型获取信息

View File

@@ -239,7 +239,7 @@ public class PluginService : IPluginService
/// <param name="pluginName">插件名称</param>
/// <param name="driverBase">驱动基类实例,可选参数</param>
/// <returns>返回包含属性名称及其信息的字典</returns>
public (IEnumerable<IEditorItem> EditorItems, object Model) GetDriverPropertyTypes(string pluginName, DriverBase? driverBase = null)
public (IEnumerable<IEditorItem> EditorItems, object Model, Type PropertyUIType) GetDriverPropertyTypes(string pluginName, DriverBase? driverBase = null)
{
// 使用锁确保线程安全
lock (this)
@@ -258,12 +258,12 @@ public class PluginService : IPluginService
{
// 返回缓存中存储的属性类型数据
var editorItems = data[pluginName];
return (editorItems, driverBase.DriverProperties);
return (editorItems, driverBase.DriverProperties, driverBase.DriverPropertyUIType);
}
}
// 如果缓存中不存在该插件的数据,则重新获取并缓存
return (SetCache(driverBase, pluginName, cacheKey, dispose), driverBase.DriverProperties); // 调用 SetCache 方法进行缓存并返回结果
return (SetCache(driverBase, pluginName, cacheKey, dispose), driverBase.DriverProperties, driverBase.DriverPropertyUIType); // 调用 SetCache 方法进行缓存并返回结果
// 定义 SetCache 方法,用于设置缓存并返回
IEnumerable<IEditorItem> SetCache(DriverBase driverBase, string pluginName, string cacheKey, bool dispose)

View File

@@ -212,6 +212,9 @@ else
<TabItem Text=@Localizer["PluginInformation"]>
@if (Model.PluginPropertyModel != null)
{
if (PropertyUIType==null)
{
<ValidateForm Model="Model.PluginPropertyModel.Value" @ref=Model.PluginPropertyModel.ValidateForm Id="@Model.Id.ToString()">
<EditorFormObject class="p-2" Items=PluginPropertyEditorItems AutoGenerateAllItem="false" RowType=RowType.Inline ItemsPerRow=2 ShowLabelTooltip=true LabelWidth=250 Model="Model.PluginPropertyModel.Value" @key=Model.PluginPropertyModel.Value.GetType().TypeHandle.Value>
@@ -255,7 +258,12 @@ else
}
</FieldItems>
</EditorFormObject>
</ValidateForm>
</ValidateForm>
}
else
{
@UIRenderFragment
}
}
</TabItem>

View File

@@ -22,6 +22,8 @@ public partial class DeviceEditComponent
{
private IEnumerable<IEditorItem> PluginPropertyEditorItems;
private RenderFragment UIRenderFragment;
private Type PropertyUIType;
[Parameter]
public bool BatchEditEnable { get; set; }
@@ -125,6 +127,16 @@ public partial class DeviceEditComponent
var data = PluginService.GetDriverPropertyTypes(selectedItem?.Value);
Model.PluginPropertyModel = new ModelValueValidateForm() { Value = data.Model };
PluginPropertyEditorItems = data.EditorItems;
PropertyUIType = data.PropertyUIType;
if (PropertyUIType != null)
{
var component = new ThingsGatewayDynamicComponent(PropertyUIType, new Dictionary<string, object?>
{
[nameof(DeviceEditComponent.Model)] = Model,
[nameof(DeviceEditComponent.PluginPropertyEditorItems)] = PluginPropertyEditorItems,
});
UIRenderFragment = component.Render();
}
if (Model.DevicePropertys?.Any() == true)
{
PluginServiceUtil.SetModel(Model.PluginPropertyModel.Value, Model.DevicePropertys);

View File

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>6.1.0.19</Version>
<Version>6.1.0.20</Version>
</PropertyGroup>
<ItemGroup>

View File

@@ -28,6 +28,7 @@
"HisDBTableName": "HisDBTableName",
"DbType": "DbType",
"BigTextConnectStr": "ConnectString",
"BigTextScriptTabe": "DynamicScript",
"IsInterval": "IsInterval",
"BusinessInterval": "BusinessInterval",

View File

@@ -28,6 +28,7 @@
"HisDBTableName": "历史表名称",
"DbType": "数据库类型",
"BigTextConnectStr": "链接字符串",
"BigTextScriptTabe": "动态脚本",
"IsInterval": "启用定时上传",
"BusinessInterval": "定时上传间隔",

View File

@@ -28,6 +28,7 @@
"HisDBTableName": "歷史表名稱",
"DbType": "資料庫類型",
"BigTextConnectStr": "連結字串",
"BigTextScriptTabe":"動態腳本",
"IsInterval": "啟用定時上傳",
"BusinessInterval": "定時上傳間隔",

View File

@@ -15,7 +15,9 @@ using Mapster;
using SqlSugar;
using ThingsGateway.Core;
using ThingsGateway.Debug;
using ThingsGateway.Foundation;
using ThingsGateway.NewLife.X.Extension;
namespace ThingsGateway.Plugin.SqlDB;
@@ -29,6 +31,7 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVarModel<SQLHi
/// <inheritdoc/>
public override Type DriverUIType => typeof(SqlDBPage);
public override Type DriverPropertyUIType => typeof(SqlDBProducerPropertyRazor);
public override VariablePropertyBase VariablePropertys => _variablePropertys;
@@ -56,6 +59,12 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVarModel<SQLHi
_exRealTimerTick = new(_driverPropertys.BusinessInterval);
//必须为间隔上传
if (!_driverPropertys.BigTextScriptTabe.IsNullOrEmpty() && _driverPropertys.IsInterval)
{
//TODO: 动态表格式未完成
}
base.Init(channel);
}

View File

@@ -40,4 +40,11 @@ public class SqlDBProducerProperty : BusinessPropertyWithCacheInterval
[Required]
[AutoGenerateColumn(ComponentType = typeof(Textarea), Rows = 1)]
public string BigTextConnectStr { get; set; } = "server=.;uid=sa;pwd=111111;database=test;";
/// <summary>
/// 表脚本
/// </summary>
[DynamicProperty(Remark = "必须为间隔上传,才生效")]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptTabe { get; set; }
}

View File

@@ -0,0 +1,37 @@
@using BootstrapBlazor.Components
@using ThingsGateway.Core.Extension
@using ThingsGateway.Foundation
@using ThingsGateway.Admin.Application
@using ThingsGateway.Admin.Razor
@using ThingsGateway.Gateway.Application
@using ThingsGateway.Plugin.SqlDB
@namespace ThingsGateway.Debug
<ValidateForm Model="Model.PluginPropertyModel.Value" @ref=Model.PluginPropertyModel.ValidateForm Id="@Model.Id.ToString()">
<EditorFormObject class="p-2" Items=PluginPropertyEditorItems AutoGenerateAllItem="false" RowType=RowType.Inline ItemsPerRow=2 ShowLabelTooltip=true LabelWidth=250 Model="Model.PluginPropertyModel.Value" @key=Model.PluginPropertyModel.Value.GetType().TypeHandle.Value>
<FieldItems>
@if (Model.PluginPropertyModel.Value is SqlDBProducerProperty businessProperty)
{
<EditorItem FieldExpression=@(()=>context) Field=@(context)>
<EditTemplate Context="value">
<div class="col-12 col-md-12">
<Textarea @bind-Value=@businessProperty.BigTextScriptTabe ShowLabelTooltip="true"
rows="5" ShowLabel="true" />
</div>
</EditTemplate>
</EditorItem>
}
</FieldItems>
</EditorFormObject>
</ValidateForm>
@code{
[Parameter, EditorRequired]
public Device Model { get; set; }
[Parameter, EditorRequired]
public IEnumerable<IEditorItem> PluginPropertyEditorItems { get; set; }
}