/// <summary> /// 获取设备的总揽数据 /// </summary> /// <param name="sites">场站编号集合</param> /// <returns></returns> public async Task <BaseResponse> GetDeviceOverViewAsync(List <int> sites, string GroupId) { var device = await _dr.FindWithOnline(a => sites.Contains(a.ProjectId.Value)).ToListAsync(); //获取类型的分类以及分类下的子类型标示 var Types = await _tr.Find(a => a.GroupId == GroupId && a.Parent == null).ToListAsync(); if (Types == null || Types.Count == 0) { return(new BaseResponse { Success = false, Message = "该组织没有添加类型" }); } DeviceOverViewDto dto = new DeviceOverViewDto(); List <DeviceTypeInfo> list = new List <DeviceTypeInfo>(); foreach (var item in Types) { DeviceTypeInfo dti = new DeviceTypeInfo { TypeId = item.Id, TypeName = item.TypeName, Icon = item.ICON }; List <int> listType = await _tr.FindTypeChildAsync(item.Id); var online = device.Where(a => listType.Contains(a.TypeId) && (a.DeviceOnline != null && a.DeviceOnline.State == true)).Count(); var num = device.Where(a => listType.Contains(a.TypeId)).Count(); dti.OnlineNum = online; dti.Num = num; dto.Num += dti.Num; dto.OnlineNum += dti.OnlineNum; dto.TypeData.Add(dti); } return(new BResponse <DeviceOverViewDto> { Success = true, Message = "获取数据成功", Data = dto }); }
public async Task <bool> IsExist(Expression <Func <TypeModel, bool> > predicate) { var ret = await _tr.Find(predicate).FirstOrDefaultAsync(); if (ret == null) { return(false); } else { return(true); } }