Exemplo n.º 1
0
        public string ProjectWriteRegisFlowActive(Guid instanceId)
        {
            var subInstaceId      = "";
            var projectRegisModel = _projectRegistrationRepository.Get(instanceId);
            var noticeService     = Abp.AbpBootstrapper.Create <Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve <IProjectNoticeAppService>();
            var noticeInput       = new NoticePublishInputForWorkSpaceInput();

            noticeInput.ProjectId = projectRegisModel.ProjectId.Value;
            var inputTypeStr = projectRegisModel.Type == 1 ? "工作联系" : "意见征询";

            noticeInput.Content = $"发布{inputTypeStr},详情在项目查询工作室查看";

            var projectName = from p in _singleProjectInfoRepository.GetAll()
                              where p.Id == projectRegisModel.ProjectId
                              select p.SingleProjectName;

            if (projectName.Any())
            {
                //noticeInput.Title = $"项目:{projectName.FirstOrDefault()} 发布{inputTypeStr}";
                //noticeService.CreateProjectWorkSpaceNotice(noticeInput);



                var model = new NoticeDocument();
                model.Id                    = Guid.NewGuid();
                model.DispatchTime          = DateTime.Now;
                model.Content               = projectRegisModel.Content;
                model.IsNeedRes             = true;
                model.ProjectId             = projectRegisModel.ProjectId;
                model.Title                 = $"{projectName.FirstOrDefault()}-工作联系";
                model.ProjectRegistrationId = instanceId;
                //model.NoticeType = input.NoticeType;
                //model.DispatchUnit = input.DispatchUnit;
                //model.Status = 0;
                //model.PrintNum = input.PrintNum;
                //model.DispatchCode = input.DispatchCode;
                //model.Urgency = input.Urgency;
                //model.SecretLevel = input.SecretLevel;
                //model.ReceiveId = input.ReceiveId;
                //model.ReceiveName = input.ReceiveName;
                //model.Reason = input.Reason;
                //model.PubilishUserName = input.PubilishUserName;
                //model.MainReceiveName = input.MainReceiveName;
                //model.DocumentTyep = input.DocumentTyep;
                //model.DispatchUnitName = input.DispatchUnitName;
                _noticeDocumentRepository.Insert(model);
                subInstaceId = model.Id.ToString();
            }
            else
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "获取项目数据异常");
            }
            return(subInstaceId);
        }
Exemplo n.º 2
0
        public Guid CreateActive(string instanceId, long userId)
        {
            var ret                = new DispatchPublishInput();
            var projectId          = instanceId.ToGuid();
            var singleprojectmodel = _singleProjectRepository.Get(projectId);
            var projectmodel       = _projectBaseRepository.FirstOrDefault(ite => ite.Id == singleprojectmodel.ProjectId);

            if (projectmodel == null)
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "项目信息不存在。");
            }
            if (projectmodel.SendUnit == 0)
            {
                ret.SendUnitName = string.Empty;
            }
            else
            {
                var sendunitemodel = _constructionOrganizationRepository.Get(projectmodel.SendUnit);
                ret.SendUnitName = sendunitemodel == null ? "" : sendunitemodel.Name;
            }

            ret.ProjectName     = projectmodel.ProjectName;
            ret.ProjectCode     = projectmodel.ProjectCode;
            ret.AppraisalTypeId = projectmodel.AppraisalTypeId;
            ret.ProjectId       = projectmodel.Id;
            var leaderModel = from a in _projectAuditMemberRepository.GetAll()
                              join u in _userRepository.GetAll() on a.UserId equals u.Id
                              where a.ProjectBaseId == projectId && a.UserAuditRole == 1
                              select u.Name;

            ret.ProjectLeader = leaderModel.FirstOrDefault() ?? "";
            var query = from memeber in _projectAuditMemberRepository.GetAll()
                        join user in _userRepository.GetAll() on memeber.UserId equals user.Id
                        where memeber.UserAuditRole == 2 && memeber.ProjectBaseId == projectmodel.Id
                        select user.Name;

            ret.ProjectReviewer = "";
            var membsers = query.ToList();

            foreach (var name in membsers)
            {
                if (!string.IsNullOrWhiteSpace(ret.ProjectReviewer))
                {
                    ret.ProjectReviewer = ret.ProjectReviewer + ",";
                }
                ret.ProjectReviewer = ret.ProjectReviewer + name;;
            }
            ret.StartDate = projectmodel.CreationTime;

            var auditRole        = (int)AuditRoleEnum.核人三;
            var threadAuditModel = from a in _projectAuditMemberRepository.GetAll()
                                   join b in _projectAuditMemberResultRepository.GetAll() on a.Id equals b.Pid
                                   where a.ProjectBaseId == projectmodel.Id && a.UserAuditRole == auditRole
                                   select b;

            ret.AuditAmount = threadAuditModel.FirstOrDefault()?.AuditAmount ?? null;


            var newId  = Guid.NewGuid();
            var entity = new NoticeDocument()
            {
                Id                         = newId,
                Title                      = $"{projectmodel.ProjectName}-{singleprojectmodel.SingleProjectName}-发文",
                Additional                 = "",
                DispatchCode               = "",
                ProjectId                  = projectId,
                ProjectLeader              = ret.ProjectLeader,
                ProjectReviewer            = ret.ProjectReviewer,
                ProjectUndertakeCode       = ret.ProjectUndertakeCode,
                Reason                     = "",
                CreatorUserId              = userId,
                SendUnitName               = ret.SendUnitName,
                DispatchTime               = DateTime.Now,
                NoticeDocumentBusinessType = (int)NoticeDocumentBusinessType.项目评审发文,
            };

            if (ret.EndDate.HasValue)
            {
                entity.EndDate = ret.EndDate.Value;
            }
            if (ret.StartDate.HasValue)
            {
                entity.StartDate = ret.StartDate.Value;
            }
            _noticeDocumentRepository.Insert(entity);
            return(newId);
        }