public async Task <PagedResultDto <EmployeeGoOutDto> > GetListAsync(GetEmployeeGoOutListInput input) { //var query = from a in _repository.GetAll() // join u in UserManager.Users on a.UserId equals u.Id // select new { EmployeeGoOut = a, UserName = u.Name }; var user = await base.GetCurrentUserAsync(); var query = from a in _repository.GetAll() join u in UserManager.Users on a.UserId equals u.Id join b in _workFlowTaskRepository.GetAll() on a.Id.ToString() equals b.InstanceID into g where (a.CreatorUserId == user.Id || (g.Count() > 0 && g.Any(r => r.ReceiveID == user.Id))) select new { EmployeeGoOut = a, UserName = u.Name }; query = query.WhereIf(input.StartTime.HasValue, r => r.EmployeeGoOut.GoOutTime >= input.StartTime.Value).WhereIf(input.EndTime.HasValue, r => r.EmployeeGoOut.GoOutTime <= input.EndTime.Value); //if (await UserManager.IsInRoleAsync(user, StaticRoleNames.Host.HR)) //{ // if (input.OrgId.HasValue) // { // var users = _workFlowOrganizationUnitsManager.GetAllUsersById(input.OrgId.Value); // if (users.Count > 0) // { // var userIds = users.Select(r => r.Id); // query = query.Where(r => userIds.Contains(input.CreateUserId.Value)); // } // } // query = query.WhereIf(input.CreateUserId.HasValue, r => r.EmployeeGoOut.CreatorUserId == input.CreateUserId.Value); //} //else if (await UserManager.IsInRoleAsync(user, StaticRoleNames.Host.DepartmentLeader)) //{ // var currentOrgId = _workFlowOrganizationUnitsManager.GetDeptByUserID(AbpSession.UserId.Value); // var users = _workFlowOrganizationUnitsManager.GetAllUsersById(input.OrgId.Value); // if (users.Count > 0) // { // var userIds = users.Select(r => r.Id); // query = query.Where(r => r.EmployeeGoOut.CreatorUserId == AbpSession.UserId.Value || userIds.Contains(input.CreateUserId.Value)); // } // else // { // query = query.Where(r => r.EmployeeGoOut.CreatorUserId == AbpSession.UserId.Value); // } //} //else //{ // query = query.Where(r => r.EmployeeGoOut.CreatorUserId == AbpSession.UserId.Value); //} if (input.OrgId.HasValue) { var users = _workFlowOrganizationUnitsManager.GetAllUsersById(input.OrgId.Value); if (users.Count > 0) { var userIds = users.Select(r => r.Id); query = query.Where(r => r.EmployeeGoOut.CreatorUserId.HasValue && userIds.Contains(r.EmployeeGoOut.CreatorUserId.Value)); } } query = query.WhereIf(input.CreateUserId.HasValue, r => r.EmployeeGoOut.CreatorUserId == input.CreateUserId.Value); if (input.Status.Count > 0) { query = query.Where(r => input.Status.Contains(r.EmployeeGoOut.Status)); } query = query.Distinct(); var totoalCount = await query.CountAsync(); var ret = query.OrderByDescending(r => r.EmployeeGoOut.CreationTime).PageBy(input).ToList(); var data = new List <EmployeeGoOutDto>(); foreach (var item in ret) { var entity = new EmployeeGoOutDto() { Id = item.EmployeeGoOut.Id, BackTime = item.EmployeeGoOut.BackTime, GoOutHour = item.EmployeeGoOut.GoOutHour, GoOutTime = item.EmployeeGoOut.GoOutTime, OutTele = item.EmployeeGoOut.OutTele, Reason = item.EmployeeGoOut.Reason, Status = item.EmployeeGoOut.Status, StatusTitle = _workFlowTaskManager.GetStatusTitle(input.FlowId, item.EmployeeGoOut.Status), UserId = item.EmployeeGoOut.UserId, UserName = item.UserName }; data.Add(entity); } return(new PagedResultDto <EmployeeGoOutDto>(totoalCount, data)); }
public PagedResultDto <OATodoList> GetOATodoList(SearchProjectListStatus input) { //获取当前用户orgid var org = _organizeRepository.GetDeptByUserID(AbpSession.UserId.Value); var underuserids = new List <long>(); if (org != null) { int cout = 0; underuserids = _organizeRepository.GetAllUsersById(org.Id).Select(ite => ite.Id).ToList(); } //var userguids = _roadFlowUserRepository.GetAll().Where(ite => underuserids.Contains(ite.AbpUserId)).Select(ite => ite.Id).ToList(); underuserids.Add(AbpSession.UserId.Value); var oatask = _oataskRepository.GetAll().Where(ite => underuserids.Contains(ite.CreatorUserId.Value)); switch (input.Status) { case 0: oatask = oatask.Where(ite => ite.Status == 0); break; case 1: oatask = oatask.Where(ite => ite.Status == 2); break; case 2: oatask = oatask.Where(ite => ite.Status == 1); break; } var count = oatask.Count(); var ret = oatask.OrderByDescending(ite => ite.CreationTime).PageBy(input).ToList(); var model = new List <OATodoList>(); foreach (var i in ret) { var x = new OATodoList(); x.Doing = true; var memberIdArry = i.ExecutorUser.Split(","); //foreach (var member in memberIdArry) //{ // var memberName = ""; // if (member.IsGuid()) // { // var memberId = member.ToGuid(); // var memberModel = _organizeRepository.FirstOrDefault(r => r.Id == memberId); // if (memberModel != null) // { // memberName = "[部门]" + memberModel.Name; // } // } // else if (member.StartsWith(MemberPerfix.UserPREFIX)) // { // var memberId = MemberPerfix.RemovePrefix(member).ToGuid(); // var usermodel = // _roadFlowUserRepository.FirstOrDefault( // r => r.Id == memberId); // if (usermodel != null) // { // memberName = usermodel.Name; // } // } // else // { // } // if (!memberName.IsNullOrWhiteSpace()) // { // if (!x.DoUser.IsNullOrWhiteSpace()) // x.DoUser = x.DoUser + ","; // x.DoUser = x.DoUser + memberName; // } //} x.Level = "C"; switch (i.PriorityCode) { case "1": x.Level = "A"; break; case "2": x.Level = "B"; break; case "3": x.Level = "C"; break; } x.ReciveTime = i.CreationTime; x.Title = i.Title; var valuser = _userRepository.GetAll().FirstOrDefault(ite => ite.Id == i.ValUser); if (valuser != null) { x.WatchUser = valuser.Surname; } x.Des = i.Summary; model.Add(x); } return(new PagedResultDto <OATodoList>(count, model)); }