7.2.0.95
修复 LL优先级比L低 添加报警属性验证规则
This commit is contained in:
@@ -27,7 +27,7 @@ namespace ThingsGateway.Gateway.Application;
|
||||
[Tenant(SqlSugarConst.DB_Custom)]
|
||||
[SugarIndex("index_device", nameof(Variable.DeviceId), OrderByType.Asc)]
|
||||
[SugarIndex("unique_variable_name", nameof(Variable.Name), OrderByType.Asc, true)]
|
||||
public class Variable : BaseDataEntity
|
||||
public class Variable : BaseDataEntity,IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备
|
||||
@@ -418,6 +418,53 @@ public class Variable : BaseDataEntity
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
public ConcurrentDictionary<long, ModelValueValidateForm>? VariablePropertyModels;
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
|
||||
if (HHAlarmEnable && HHAlarmCode == null)
|
||||
{
|
||||
yield return new ValidationResult("HHAlarmCode cannot be null when HHAlarmEnable is true", new[] { nameof(HHAlarmCode) });
|
||||
}
|
||||
if (HAlarmEnable && HAlarmCode == null)
|
||||
{
|
||||
yield return new ValidationResult("HAlarmCode cannot be null when HAlarmEnable is true", new[] { nameof(HAlarmCode) });
|
||||
}
|
||||
if (LAlarmEnable && LAlarmCode == null)
|
||||
{
|
||||
yield return new ValidationResult("LAlarmCode cannot be null when LAlarmEnable is true", new[] { nameof(LAlarmCode) });
|
||||
}
|
||||
if (LLAlarmEnable && LLAlarmCode == null)
|
||||
{
|
||||
yield return new ValidationResult("LLAlarmCode cannot be null when LLAlarmEnable is true", new[] { nameof(LLAlarmCode) });
|
||||
}
|
||||
|
||||
if (HHAlarmEnable && HAlarmEnable && HHAlarmCode <= HAlarmCode)
|
||||
{
|
||||
yield return new ValidationResult("HHAlarmCode must be greater than HAlarmCode", new[] { nameof(HHAlarmCode), nameof(HAlarmCode) });
|
||||
}
|
||||
if (HAlarmEnable && LAlarmEnable && HAlarmCode <= LAlarmCode)
|
||||
{
|
||||
yield return new ValidationResult("HAlarmCode must be greater than LAlarmCode", new[] { nameof(HAlarmCode), nameof(LAlarmCode) });
|
||||
}
|
||||
if (LAlarmEnable && LLAlarmEnable && LAlarmCode <= LLAlarmCode)
|
||||
{
|
||||
yield return new ValidationResult("LAlarmCode must be greater than LLAlarmCode", new[] { nameof(LAlarmCode), nameof(LLAlarmCode) });
|
||||
}
|
||||
|
||||
if (HHAlarmEnable && LAlarmEnable && HHAlarmCode <= LAlarmCode)
|
||||
{
|
||||
yield return new ValidationResult("HHAlarmCode should be greater than or less than LAlarmCode", new[] { nameof(HHAlarmCode), nameof(LAlarmCode) });
|
||||
}
|
||||
if (HHAlarmEnable && LLAlarmEnable && HHAlarmCode <= LLAlarmCode)
|
||||
{
|
||||
yield return new ValidationResult("HHAlarmCode should be greater than or less than LLAlarmCode", new[] { nameof(HHAlarmCode), nameof(LLAlarmCode) });
|
||||
}
|
||||
if (HAlarmEnable && LLAlarmEnable && HAlarmCode <= LLAlarmCode)
|
||||
{
|
||||
yield return new ValidationResult("HAlarmCode should be greater than or less than LLAlarmCode", new[] { nameof(HAlarmCode), nameof(LLAlarmCode) });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ModelValueValidateForm
|
||||
|
@@ -182,14 +182,6 @@ internal sealed class AlarmHostedService : BackgroundService, IAlarmHostedServic
|
||||
return AlarmTypeEnum.H; // 返回高报警类型枚举
|
||||
}
|
||||
|
||||
// 检查是否启用了低报警功能,并且变量的值小于低报警的限制值
|
||||
if (tag.LAlarmEnable && tag.Value.ToDecimal() < tag.LAlarmCode.ToDecimal())
|
||||
{
|
||||
limit = tag.LAlarmCode.ToString()!; // 将报警限制值设置为低报警的限制值
|
||||
expressions = tag.LRestrainExpressions!; // 获取低报警的约束表达式
|
||||
text = tag.LAlarmText!; // 获取低报警时的报警文本
|
||||
return AlarmTypeEnum.L; // 返回低报警类型枚举
|
||||
}
|
||||
|
||||
// 检查是否启用了低低报警功能,并且变量的值小于低低报警的限制值
|
||||
if (tag.LLAlarmEnable && tag.Value.ToDecimal() < tag.LLAlarmCode.ToDecimal())
|
||||
@@ -200,6 +192,16 @@ internal sealed class AlarmHostedService : BackgroundService, IAlarmHostedServic
|
||||
return AlarmTypeEnum.LL; // 返回低低报警类型枚举
|
||||
}
|
||||
|
||||
|
||||
// 检查是否启用了低报警功能,并且变量的值小于低报警的限制值
|
||||
if (tag.LAlarmEnable && tag.Value.ToDecimal() < tag.LAlarmCode.ToDecimal())
|
||||
{
|
||||
limit = tag.LAlarmCode.ToString()!; // 将报警限制值设置为低报警的限制值
|
||||
expressions = tag.LRestrainExpressions!; // 获取低报警的约束表达式
|
||||
text = tag.LAlarmText!; // 获取低报警时的报警文本
|
||||
return AlarmTypeEnum.L; // 返回低报警类型枚举
|
||||
}
|
||||
|
||||
return null; // 如果不符合任何报警条件,则返回null
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>7.2.0.94</Version>
|
||||
<Version>7.2.0.95</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Reference in New Issue
Block a user