Ejemplo n.º 1
0
        public async Task <List <CreateOrUpdateFinishOutput> > GetFinishResult(Guid projectId, int auditRole, bool isForHuizongBySelf = false)
        {
            var ret = new List <CreateOrUpdateFinishOutput>();

            if (isForHuizongBySelf)
            {
                if (!AbpSession.UserId.HasValue)
                {
                    throw new UserFriendlyException((int)ErrorCode.SignCodeErr, "未登录");
                }
            }
            var finish_query = from a in _projectPersentFinishRepository.GetAll()
                               join b in _projectPersentFinishAllotRepository.GetAll() on a.Id equals b.FinishId
                               join e in _projectAuditMemberRepository.GetAll() on b.AuditMembeId equals e.Id
                               join cc in _projectPersentFinishResultRepository.GetAll() on b.Id equals cc.AllotId into g
                               from c in g.DefaultIfEmpty()
                               join d in _userRepository.GetAll() on e.UserId equals d.Id
                               where a.ProjectId == projectId && (!isForHuizongBySelf || (isForHuizongBySelf && b.IsMain && e.UserId == AbpSession.UserId.Value))
                               select new { FinishId = a.Id, FinishName = a.Name, WorkDay = a.WorkDay, AllotId = b.Id, IsMain = b.IsMain, UserId = d.Id, UserName = d.Name,
                                            Persent  = a.Persent,
                                            ResultId = c == null ? Guid.Empty : c.Id, ResultType = c == null ? 0 : c.ResultType, CjzFile = c == null ? "" : c.CJZFiles,
                                            Files    = c == null ? "" : c.Files, Remark = c == null ? "" : c.Remark, AuditaAmount = c == null ? 0 : c.AuditAmount, c.SurePersent };

            var datas = await finish_query.ToListAsync();

            var finishs = datas.Select(r => r.FinishId).Distinct();

            foreach (var item in finishs)
            {
                var finish_allots = datas.Where(r => r.FinishId == item);
                var finish_One    = finish_allots.FirstOrDefault();
                var entity_finish = new CreateOrUpdateFinishOutput()
                {
                    Id = finish_One.FinishId, Name = finish_One.FinishName, WorkDay = finish_One.WorkDay, Persent = finish_One.Persent
                };
                var finishs_allots_ids = finish_allots.Select(r => r.AllotId).Distinct();
                foreach (var allots_id in finishs_allots_ids)
                {
                    var finish_allots_result = datas.Where(r => r.AllotId == allots_id);
                    var finish_allots_One    = finish_allots_result.FirstOrDefault();
                    var entity_allot         = new CreateOrUpdateFinishAllotOutput()
                    {
                        Id       = allots_id,
                        IsMain   = finish_allots_One.IsMain,
                        UserId   = finish_allots_One.UserId,
                        UserName = finish_allots_One.UserName,
                    };
                    var result_data = finish_allots_result.FirstOrDefault(r => r.ResultType == 1);
                    if (result_data != null)
                    {
                        entity_allot.Result = new ProjectAuditResultInfoOutput()
                        {
                            AuditAmount = result_data.AuditaAmount,
                            CjzFile     = await _abpFileRelationAppService.GetAsync(new GetAbpFilesInput()
                            {
                                BusinessId = result_data.ResultId.ToString(), BusinessType = (int)AbpFileBusinessType.工程评审CJZ结果
                            }),
                            Files = await _abpFileRelationAppService.GetListAsync(new GetAbpFilesInput()
                            {
                                BusinessId = result_data.ResultId.ToString(), BusinessType = (int)AbpFileBusinessType.工程评审结果
                            }),
                            Remark      = result_data.Remark,
                            Id          = result_data.ResultId,
                            SurePersent = result_data.SurePersent,
                        };


                        var result_data2 = finish_allots_result.FirstOrDefault(r => r.ResultType == 2);
                        if (result_data2 != null)
                        {
                            entity_finish.GatherResult = new ProjectAuditResultInfoOutput()
                            {
                                AuditAmount = result_data2.AuditaAmount,
                                CjzFile     = await _abpFileRelationAppService.GetAsync(new GetAbpFilesInput()
                                {
                                    BusinessId = result_data2.ResultId.ToString(), BusinessType = (int)AbpFileBusinessType.评审事项汇总CJZ结果
                                }),
                                Files = await _abpFileRelationAppService.GetListAsync(new GetAbpFilesInput()
                                {
                                    BusinessId = result_data2.ResultId.ToString(), BusinessType = (int)AbpFileBusinessType.评审事项汇总结果
                                }),
                                Remark      = result_data2.Remark,
                                Id          = result_data.ResultId,
                                SurePersent = result_data.SurePersent,
                            };
                        }
                    }



                    entity_finish.FinishMembers.Add(entity_allot);
                }
                var mainAllot = entity_finish.FinishMembers.FirstOrDefault(r => r.IsMain);
                if (mainAllot == null)
                {
                    throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "数据异常");
                }
                entity_finish.MainAllotId = mainAllot.Id;
                switch ((AuditRoleEnum)auditRole)
                {
                case AuditRoleEnum.工程评审:
                    if (entity_finish.FinishMembers.Exists(ite => ite.UserId == AbpSession.UserId.Value))
                    {
                        ret.Add(entity_finish);
                    }
                    break;

                default:
                    ret.Add(entity_finish);
                    break;
                }
            }
            return(ret);
        }
Ejemplo n.º 2
0
        public async Task <GetProjectMemberForEditOutput> GetAsync(EntityDto <Guid> input)
        {
            var ret     = new GetProjectMemberForEditOutput();
            var service = Abp.AbpBootstrapper.Create <Abp.Modules.AbpModule>()
                          .IocManager.IocContainer.Resolve <IProjectAppService>();
            var projectBase = await service.GetSingleProject(new GetSingleProjectInput()
            {
                AppraisalTypeId = 8, Id = input.Id,
            });

            var membsers_query = from memeber in _projectAuditMemberRepository.GetAll()
                                 join auditRole in _projectAuditRoleRepository.GetAll() on memeber.UserAuditRole equals auditRole.Id
                                 join user in _userRepository.GetAll() on memeber.UserId equals user.Id
                                 join membergroups in _projectAuditGroupRepository.GetAll() on memeber.GroupId equals membergroups.Id into g
                                 from membergroup in g.DefaultIfEmpty()
                                 where memeber.ProjectBaseId == input.Id
                                 select new CreateOrUpdateAuditMemberOutput()
            {
                AuditRoleId = memeber.UserAuditRole, AuditRoleName = auditRole.Name, Id = memeber.Id, UserId = user.Id, UserName = user.Name, GroupId = memeber.GroupId, GroupName = membergroup.Name, WorkDes = memeber.WorkDes, WorkDays = memeber.WorkDays, FlowId = memeber.FlowId, Des = memeber.Des, Percentes = memeber.Percentes
            };

            ret.ProjectId       = projectBase.BaseOutput.Id.Value;
            ret.SingleProjectId = input.Id;
            ret.ProjectInfo     = projectBase;
            ret.Members         = await membsers_query.ToListAsync();

            foreach (var item in ret.Members)
            {
                //财务初审的部门id 从flowId里面来
                if (item.AuditRoleId == (int)AuditRoleEnum.财务初审)
                {
                    item.UserId = item.FlowId.ToLong();
                }
            }

            var finishs_query = from finish in _projectPersentFinishRepository.GetAll()
                                join allot in _projectPersentFinishAllotRepository.GetAll() on finish.Id equals allot.FinishId into g
                                where finish.ProjectId == input.Id
                                select new
            {
                F = finish,
                A = from a in g
                    join memeber in _projectAuditMemberRepository.GetAll() on a.AuditMembeId equals memeber.Id
                    join user in _userRepository.GetAll() on memeber.UserId equals user.Id
                    select new { UserId = user.Id, UserName = user.Name, IsMain = a.IsMain }
            };

            foreach (var item in finishs_query)
            {
                var entity = new CreateOrUpdateFinishOutput();
                entity.Id      = item.F.Id;
                entity.Name    = item.F.Name;
                entity.Persent = item.F.Persent;
                entity.WorkDay = item.F.WorkDay;
                foreach (var obj in item.A)
                {
                    var entity_user = new CreateOrUpdateFinishAllotOutput();
                    entity_user.UserId   = obj.UserId;
                    entity_user.UserName = obj.UserName;
                    entity_user.IsMain   = obj.IsMain;
                    entity.FinishMembers.Add(entity_user);
                }
                ret.Finishs.Add(entity);
            }

            return(ret);
        }