/// <summary> /// 获取所有数据 /// </summary> public async Task <ListResultOutput <DataTypeDto> > GetAllList() { try { //var query = await _IDataTypeRepository.GetAllListAsync(); var query = _IDataTypeRepository.GetAllList(); var list = new ListResultOutput <DataTypeDto>(query.MapTo <List <DataTypeDto> >()); return(list); } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// 地图统计列表 /// </summary> /// <returns></returns> public DataTypeCountOutput GetAllCountByDataType(string userCode) { try { if (string.IsNullOrWhiteSpace(userCode)) { return(null); } List <MapEntity> mapList = null; if (userCode.ToUpper() == ConstHelper.CONST_SYSTEMNAME) { #region 超级用户 mapList = _IMapRepository.GetAllList(); #endregion } else { List <SystemUserDto> userQuery = _SystemUserApp.GetUserDataByUserCodeAsync(userCode).Result; if (userQuery != null && userQuery.Count > 0) { var userids = userQuery.Select(s => s.UserCode).ToArray(); mapList = _IMapRepository.GetAllList(s => userids.Contains(s.CreateUserId)); } } //var mapList = _IMapRepository.GetAllList(); //if (!string.IsNullOrEmpty(userCode)) //{ // List<string> listUserCode = _IOperateLogAppService.GetAllUserCodeByUserCode(userCode); // if (listUserCode != null) // { // if (listUserCode.Count != 0) // { // mapList = mapList.Where(s => listUserCode.Contains(s.CreateUserId)).ToList(); // } // } //} var dataTypeChild = _IDataTypeRepository.GetAllList(); var dataTypeParent = _IDataTypeRepository.GetAllList(); //类型父子级集合 var result = (from m in mapList join c in dataTypeChild on m.MapType equals c.Id join p in dataTypeParent on c.ParentID equals p.Id into cp from cpp in cp.DefaultIfEmpty() group c by new { DataTypeParentName = (cpp == null) ? c.TypeName : cpp.TypeName, DataTypeParentID = (cpp == null) ? c.Id : cpp.Id } into g select new { DataType = g.Key.DataTypeParentID, DataTypeName = g.Key.DataTypeParentName, DataCount = g.Count() }); DataTypeCountOutput ret = new DataTypeCountOutput(); ret.Data = new List <DataTypeCountDto>(); ret.Colors = new List <string>(); ret.Names = new List <string>(); int i = 0, count = 0, cnt = result.Count(); foreach (var item in result) { ret.Data.Add(new DataTypeCountDto { Id = item.DataType, Name = item.DataTypeName, Value = item.DataCount }); ret.Names.Add(item.DataTypeName); } return(ret); } catch (Exception ex) { return(null); } }