From 1d9da8d6e63dbded939e783b2d56decf48c16ad5 Mon Sep 17 00:00:00 2001 From: yanghongwei Date: Sun, 29 Jun 2025 20:55:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=95=B0=E6=8D=AE=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/AlarmService.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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); }