diff --git a/Service/AlarmService.cs b/Service/AlarmService.cs index 630431a..8546958 100644 --- a/Service/AlarmService.cs +++ b/Service/AlarmService.cs @@ -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() + .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); }