加上时间筛选和取最近30条

This commit is contained in:
pangwenpeng 2024-07-24 17:58:41 +08:00
parent 2dd3a1b18c
commit 54c03916a8
1 changed files with 12 additions and 0 deletions

View File

@ -66,6 +66,18 @@ namespace langguanApi.Service
entity.StateString=item.State==0?"停止":"运行";
washerHistroyResult.Add(entity);
}
if (!string.IsNullOrWhiteSpace(input.startTime))
{
washerHistroyResult = washerHistroyResult.Where(p => Convert.ToDateTime(p.Time) >= Convert.ToDateTime(input.startTime)).ToList();
}
if (!string.IsNullOrWhiteSpace(input.endTime))
{
washerHistroyResult = washerHistroyResult.Where(p => Convert.ToDateTime(p.Time) <= Convert.ToDateTime(input.endTime)).ToList();
}
if (washerHistroyResult.Any())
{
washerHistroyResult = washerHistroyResult.OrderByDescending(p => p.Time).Take(30).ToList();
}
return washerHistroyResult;
}
}