fix 修改离线设备判断逻辑
This commit is contained in:
@@ -551,10 +551,10 @@ public class BalanceService : IBalanceService
|
||||
public async Task<ConsumeNumberResponse> GetConsumeNumberAsync()
|
||||
{
|
||||
var devices = await _dbContext.Queryable<DeviceEntity>()
|
||||
.Where(x => x.Type == DeviceTypeEnumType.Meal)
|
||||
.Where(x => x.Type == DeviceTypeEnumType.Meal && x.Enable)
|
||||
.ToListAsync();
|
||||
|
||||
var offCount = devices.Where(x => x.Enable == false).Count();
|
||||
var offCount = GetOfflineDevicesCount(devices).Count;
|
||||
|
||||
var places = await _dbContext.Queryable<BusinessPlaceEntity>()
|
||||
.ToListAsync();
|
||||
@@ -592,6 +592,26 @@ public class BalanceService : IBalanceService
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取离线设备
|
||||
/// </summary>
|
||||
/// <param name="devices"></param>
|
||||
/// <returns></returns>
|
||||
private List<DeviceEntity> GetOfflineDevicesCount(List<DeviceEntity> devices)
|
||||
{
|
||||
var list = new List<DeviceEntity>();
|
||||
foreach (var device in devices)
|
||||
{
|
||||
TimeSpan timeDifference = DateTime.Now - device.ModifiedTime;
|
||||
if (timeDifference.TotalSeconds > (device.HeartbeatInterval * 3))
|
||||
{
|
||||
list.Add(device);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private async Task<List<ConsumptionTrendResponse>> GetConsumptionTrendsAsync(ConsumptionTrendEnumType type)
|
||||
{
|
||||
var bs = await _dbContext.Queryable<BalanceRecordEntity>()
|
||||
|
||||
Reference in New Issue
Block a user