コード例 #1
0
        public async Task <WorkFlowTrainUserExperienceOutputDto> GetMyExperience(GetTrainUserExperienceInput input)
        {
            var result = new WorkFlowTrainUserExperienceOutputDto();
            var user   = await base.GetCurrentUserAsync();

            var userid = "u_" + user.Id;

            result.UserExperience = await _experienceAppService.GetIsExistence(input);

            result.CanChange = result.UserExperience == null || !(await _repository.GetAll().AnyAsync(x =>
                                                                                                      !x.IsDeleted && x.CourseId == input.TrainId && x.SubmitUsers.GetStrContainsArray(userid)));
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// 根据主键获取实体
        /// </summary>
        /// <param name="input">主键</param>
        /// <returns></returns>
        public async Task <TrainUserExperienceOutputDto> GetIsExistence(GetTrainUserExperienceInput input)
        {
            var dbmodel = await _repository.FirstOrDefaultAsync(x => x.TrainId == input.TrainId && x.Type == input.ExperienceType && x.UserId == AbpSession.UserId.Value);

            if (dbmodel == null)
            {
                return(null);
            }
            var tmp = dbmodel.MapTo <TrainUserExperienceOutputDto>();

            tmp.FileList = await _abpFileRelationAppService.GetListAsync(new GetAbpFilesInput()
            {
                BusinessId   = dbmodel.Id.ToString(),
                BusinessType = (int)AbpFileBusinessType.培训心得
            });

            return(tmp);
        }
コード例 #3
0
        /// <summary>
        /// 根据条件分页获取列表
        /// </summary>
        /// <param name="page">查询实体</param>
        /// <returns></returns>
        public async Task <List <TrainUserExperienceOrganListOutputDto> > GetOrganList(GetTrainUserExperienceInput input)
        {
            var list = new List <TrainUserExperienceOrganListOutputDto>();

            var organizeManager = Abp.AbpBootstrapper.Create <Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve <WorkFlowOrganizationUnitsManager>();
            var arr             = new List <long>();
            var courseid        = Guid.Empty;

            switch (input.ExperienceType)
            {
            case TrainExperienceType.Train:
                var train = _trainRepository.GetAll().FirstOrDefault(x => x.Id == input.TrainId);
                arr = train.JoinUser.Split(',').Select(x => long.Parse(x.Replace("u_", ""))).ToList();
                break;

            case TrainExperienceType.Course:
                var course = await _courseExperienceRepository.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id == input.TrainId);

                var exps = string.IsNullOrEmpty(course?.ExperienceId)
                        ? new List <Guid>()
                        : course?.ExperienceId.Split(",").Select(Guid.Parse);
                arr = await _repository.GetAll().Where(x => x.IsUse && exps.Contains(x.Id)).Select(x => x.UserId).ToListAsync();

                courseid = course.CourseId;
                break;
            }
            var leaders  = new List <long>();
            var myLeader = organizeManager.GetChargeLeader(AbpSession.UserId.Value);

            foreach (var userId in arr)
            {
                var leaderstr = organizeManager.GetChargeLeader(userId);
                if (!string.IsNullOrEmpty(leaderstr))
                {
                    var leaderarr = leaderstr.Split(',').Select(x => long.Parse(x.Replace("u_", ""))).ToList();
                    foreach (var leaderInt in leaderarr)
                    {
                        var organ = organizeManager.GetDeptByUserID(leaderInt);
                        var user  = _userRepository.GetAll().FirstOrDefault(x => x.Id == leaderInt);
                        if (list.Count(x => x.LeaderId == leaderInt) == 0)
                        {
                            var users = new List <long>();
                            users.Add(userId);
                            if (!input.IsMy)
                            {
                                list.Add(new TrainUserExperienceOrganListOutputDto
                                {
                                    LeaderId   = leaderInt,
                                    Users      = users,
                                    LeaderName = user?.Name,
                                    OrganName  = organ?.DisplayName,
                                    Id         = organ != null ? organ.Id : 0
                                });
                            }
                            else
                            {
                                if (myLeader.Split(",").Select(x => long.Parse(x.Replace("u_", ""))).ToList().Contains(leaderInt))
                                {
                                    list.Add(new TrainUserExperienceOrganListOutputDto
                                    {
                                        LeaderId   = leaderInt,
                                        Users      = users,
                                        LeaderName = user?.Name,
                                        OrganName  = organ?.DisplayName,
                                        Id         = organ != null ? organ.Id : 0
                                    });
                                }
                            }

                            leaders.Add(leaderInt);
                        }
                        else
                        {
                            list.First(x => x.LeaderId == leaderInt).Users.Add(userId);
                        }
                    }
                }
            }
            if (!input.IsMy)
            {
                foreach (var item in list)
                {
                    var trainId = (input.ExperienceType == TrainExperienceType.Train ? input.TrainId : courseid);
                    item.List = (from a in _repository.GetAll().Where(x => !x.IsDeleted && x.IsUse && x.TrainId == trainId && x.Type == input.ExperienceType && item.Users.Contains(x.UserId))
                                 join b in _userRepository.GetAll() on a.UserId equals b.Id
                                 select new TrainUserExperienceListOutputDto()
                    {
                        Id = a.Id,
                        UserId = a.UserId,
                        UserName = b.Name,
                        TrainId = a.TrainId,
                        Experience = a.Experience,
                        Approval = a.Approval,
                        CreationTime = a.CreationTime
                    }).ToList();
                    var tasks    = _workFlowTaskRepository.GetAll().Where(x => x.InstanceID == input.TrainId.ToString() && x.Status == 2 && !string.IsNullOrEmpty(x.Comment) && x.ReceiveID == item.LeaderId).OrderByDescending(x => x.CompletedTime1);
                    var approval = "";
                    foreach (var info in tasks.Select(x => x.Comment).ToList())
                    {
                        approval += info + "<br>";
                    }
                    item.Approval = approval;
                    var task = tasks.FirstOrDefault();
                    if (task != null)
                    {
                        item.ApprovalTime = task.CompletedTime1;
                    }
                }
            }

            var tasklist = _workFlowTaskRepository.GetAll().Where(x => x.InstanceID == input.TrainId.ToString() && x.Status == 2 && !string.IsNullOrEmpty(x.Comment) && !leaders.Contains(x.ReceiveID)).ToList();

            foreach (var item in tasklist)
            {
                var organ = organizeManager.GetDeptByUserID(item.ReceiveID);
                if (organ != null)
                {
                    list.Add(new TrainUserExperienceOrganListOutputDto
                    {
                        LeaderId     = item.ReceiveID,
                        Approval     = item.Comment,
                        ApprovalTime = item.CompletedTime1,
                        LeaderName   = item.ReceiveName,
                        Id           = organ.Id
                    });
                }
            }

            return(list);
        }