Exemple #1
0
        /// <summary>
        /// 审核任务列表
        /// </summary>
        /// <param name="user"></param>
        /// <param name="condition"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <PagingResponseMessage <TasksExamineResponse> > TasksExaminelistAsync(UserInfo user, TaskExamineListRequest condition, CancellationToken cancellationToken = default(CancellationToken))
        {
            var response = new PagingResponseMessage <TasksExamineResponse>();

            response.Extension = new List <TasksExamineResponse>();
            var taskInfoQuery = _iTaskStore.GetTaskExamineList(condition.PeriodId);

            if (!string.IsNullOrWhiteSpace(condition.TaskName)) //任务名称
            {
                taskInfoQuery = taskInfoQuery.Where(task => task.TaskName.Contains(condition.TaskName));
            }
            if (condition.ExamineState != null) //审核状态
            {
                taskInfoQuery = taskInfoQuery.Where(task => task.ExamineState == condition.ExamineState);
            }
            if (!string.IsNullOrWhiteSpace(condition.CreateUser)) //发布人
            {
                taskInfoQuery = taskInfoQuery.Where(task => task.CreateUser.Contains(condition.CreateUser));
            }
            if (condition.StartTime.HasValue)//发布开始时间
            {
                taskInfoQuery = taskInfoQuery.Where(task => task.CreateTime >= condition.StartTime);
            }
            if (condition.EndTime.HasValue)//发布结束时间
            {
                taskInfoQuery = taskInfoQuery.Where(task => task.CreateTime <= condition.EndTime);
            }


            response.PageIndex  = condition.PageIndex;
            response.PageSize   = condition.PageSize;
            response.TotalCount = await taskInfoQuery.CountAsync();

            var taskInfoList = await taskInfoQuery.Skip(condition.PageIndex *condition.PageSize).Take(condition.PageSize).ToListAsync();

            // 19-12-10 查询任务接取人
            var taskIds   = taskInfoList.Select(a => a.Id);
            var periodId  = condition.PeriodId;
            var taskUsers = await(from tu in _iTaskStore.GetTaskUsers()
                                  where taskIds.Contains(tu.TaskId)
                                  join u in _iUserStore.GetUserInfos() on tu.UserId equals u.Id
                                  select new TasksExamineResponse.TaskUserDetails4
            {
                TaskId           = tu.TaskId,
                UserId           = tu.UserId,
                UserName         = u.UserName,
                OrganizationName = u.OrganizationName,
                GroupName        = u.GroupName,
            })
                            //.OrderBy(a => a.TaskId)
                            //// 20200107-修复-王森 一个格子里面显示两行每行3个总共6个人,多的不显示
                            //.Take(6)
                            .ToListAsync(cancellationToken);
            //任务人员关系表
            var taskUserIdQuery = _iTaskStore.GetTaskUsers().Where(w => taskIds.Contains(w.TaskId)).Select(s => s.UserId);
            //参与人员积分(任务对应赛季的积分)
            var scoreInfoList = await _iTaskStore.GetScoreInfos().Where(w => taskUserIdQuery.Contains(w.UserId) && w.PeriodId == periodId).ToListAsync();

            //称号信息
            var titleList = await _iTaskStore.GetScoreTitles().Where(w => !w.IsDelete && w.PeriodId == periodId).ToListAsync();

            titleList.ForEach(fo => fo.Icon = _config["FileUrl"] + fo.Icon);
            taskUsers.ForEach(task =>
            {
                task.ScoreTitle = (titleList.FirstOrDefault(fi => fi.StartScore <= scoreInfoList.First(f => f.UserId == task.UserId).Score&& fi.EndScore >= scoreInfoList.First(f => f.UserId == task.UserId).Score)?.Title) ?? "未知称号";
                task.Icon       = titleList.FirstOrDefault(fi => fi.StartScore <= scoreInfoList.First(f => f.UserId == task.UserId).Score&& fi.EndScore >= scoreInfoList.First(f => f.UserId == task.UserId).Score)?.Icon;
            });

            taskInfoList.ForEach(fo => fo.TaskUsers = taskUsers.Where(a => a.TaskId == fo.Id));
            response.Extension = taskInfoList;
            return(response);
        }