统计数据调整

This commit is contained in:
yanghongwei 2025-06-29 20:55:31 +08:00
parent 64853e5ffe
commit 1d9da8d6e6
1 changed files with 15 additions and 3 deletions

View File

@ -380,7 +380,7 @@ namespace LY.App.Service
.WhereIF(input.strartDate.HasValue, st => st.CreateTime >= input.strartDate.Value)
.WhereIF(input.endDate.HasValue, st => st.CreateTime <= input.endDate.Value.AddDays(1))
.OrderBy(s => s.BatchId, OrderByType.Desc)
.GroupBy(s => new { s.BatchId, s.serial_number, s.device_type, s.positionId, s.PostionName, s.freq })
.GroupBy(s => new { s.BatchId, s.serial_number, s.device_type })
.Select(st => new AlarmRepDto
{
batchId = st.BatchId.ToString(),
@ -390,10 +390,22 @@ namespace LY.App.Service
Frequency = SqlFunc.AggregateMax(st.freq),
duration = (SqlFunc.AggregateMax(st.CreateTime) - SqlFunc.AggregateMin(st.CreateTime)).TotalSeconds,
model = st.device_type,
positionId = st.positionId,
positionName = st.PostionName
positionId = SqlFunc.AggregateMax(st.positionId),
}).MergeTable()//合并查询
.ToPageListAsync(input.pageNum, input.pageSize, total);
var ids= items.Select(s => s.positionId).Distinct().ToList();
var positionNames = await _db.Queryable<PositionInfo>()
.Where(s => ids.Contains(s.Id))
.Select(s => new { s.Id, s.Name })
.ToListAsync();
foreach (var item in items)
{
var positionName = positionNames.FirstOrDefault(s => s.Id == item.positionId)?.Name;
if (!string.IsNullOrEmpty(positionName))
{
item.positionName = positionName;
}
}
return Tuple.Create(total.Value, items);
}