fix 心跳间隔控制

This commit is contained in:
2024-02-23 21:06:31 +08:00
parent 1ddebd4666
commit e259c3ab92
2 changed files with 6 additions and 2 deletions

View File

@@ -43,7 +43,6 @@ public class DeviceSaveRequest : IValidatableObject
/// <summary>
/// 心跳间隔
/// </summary>
[Range(0, int.MaxValue)]
public int HeartbeatInterval { get; set; }
/// <summary>
@@ -83,5 +82,10 @@ public class DeviceSaveRequest : IValidatableObject
{
yield return new ValidationResult($"{DeviceTypeEnumType.Door.GetDescription()}才可设置作为考勤设备", new[] { nameof(AsAttendance) });
}
if (HeartbeatInterval != 0 && HeartbeatInterval < 30)
{
yield return new ValidationResult($"心跳间隔需要设置>=30秒", new[] { nameof(HeartbeatInterval) });
}
}
}

View File

@@ -24,7 +24,7 @@ public class HeartbeatJob
_dbContext.Client.QueryFilter.ClearAndBackup<ITenantId>();
try
{
var devices = await _dbContext.Queryable<DeviceEntity>().Where(x => x.Enable).ToListAsync();
var devices = await _dbContext.Queryable<DeviceEntity>().Where(x => x.Enable).Where(x => x.HeartbeatInterval > 0).ToListAsync();
foreach (var device in devices)
{
try