统计数据调整
This commit is contained in:
		
							parent
							
								
									64853e5ffe
								
							
						
					
					
						commit
						1d9da8d6e6
					
				| 
						 | 
					@ -380,7 +380,7 @@ namespace LY.App.Service
 | 
				
			||||||
                .WhereIF(input.strartDate.HasValue, st => st.CreateTime >= input.strartDate.Value)
 | 
					                .WhereIF(input.strartDate.HasValue, st => st.CreateTime >= input.strartDate.Value)
 | 
				
			||||||
                .WhereIF(input.endDate.HasValue, st => st.CreateTime <= input.endDate.Value.AddDays(1))
 | 
					                .WhereIF(input.endDate.HasValue, st => st.CreateTime <= input.endDate.Value.AddDays(1))
 | 
				
			||||||
                .OrderBy(s => s.BatchId, OrderByType.Desc)
 | 
					                .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
 | 
					                .Select(st => new AlarmRepDto
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    batchId = st.BatchId.ToString(),
 | 
					                    batchId = st.BatchId.ToString(),
 | 
				
			||||||
| 
						 | 
					@ -390,10 +390,22 @@ namespace LY.App.Service
 | 
				
			||||||
                    Frequency = SqlFunc.AggregateMax(st.freq),
 | 
					                    Frequency = SqlFunc.AggregateMax(st.freq),
 | 
				
			||||||
                    duration = (SqlFunc.AggregateMax(st.CreateTime) - SqlFunc.AggregateMin(st.CreateTime)).TotalSeconds,
 | 
					                    duration = (SqlFunc.AggregateMax(st.CreateTime) - SqlFunc.AggregateMin(st.CreateTime)).TotalSeconds,
 | 
				
			||||||
                    model = st.device_type,
 | 
					                    model = st.device_type,
 | 
				
			||||||
                    positionId = st.positionId,
 | 
					                    positionId = SqlFunc.AggregateMax(st.positionId),
 | 
				
			||||||
                    positionName = st.PostionName
 | 
					 | 
				
			||||||
                }).MergeTable()//合并查询
 | 
					                }).MergeTable()//合并查询
 | 
				
			||||||
                .ToPageListAsync(input.pageNum, input.pageSize, total);
 | 
					                .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);
 | 
					            return Tuple.Create(total.Value, items);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue