Example #1
0
        public async Task <InitWorkFlowOutput> WriteRegistration(WorkRegistrationInput input)
        {
            long userId = AbpSession.UserId.Value;

            if (input.StepId.HasValue)
            {
                var taskModel = await _workFlowTaskRepository.FirstOrDefaultAsync(r => r.InstanceID == input.ProjectId.Value.ToString() && r.StepID == input.StepId.Value);

                if (taskModel != null)
                {
                    input.StepName = taskModel.StepName;
                }
            }
            var regId = await _workTaskManager.InsertRegistration(new ProjectWorkTask
            {
                UserId    = userId,
                TaskType  = input.Type == 1 ? 3 : 4,
                ProjectId = input.ProjectId,
                Title     = string.Format("{0}-{1}", input.Title, input.WorkTime.ToString("yyyyMMdd")),
                StepId    = input.StepId,
                StepName  = input.StepName
            },
                                                                  new ProjectRegistration
            {
                SendUserId         = userId,
                ProjectId          = input.ProjectId,
                Code               = input.Code,
                Title              = string.Format("{0}-{1}", input.Title, input.WorkTime.ToString("yyyyMMdd")),
                WorkTime           = input.WorkTime,
                Type               = input.Type,
                Content            = input.Content,
                RecieveUserId      = 0,
                StepId             = input.StepId,
                PersonOnChargeType = input.IsPersonOnCharge? PersonOnChargeTypeEnum.负责人:PersonOnChargeTypeEnum.普通,
                StepName           = input.StepName
            }, input.Files);


            var initRetdata = _workFlowWorkTaskAppService.InitWorkFlowInstance(new InitWorkFlowInput()
            {
                FlowId = input.FlowId, FlowTitle = input.FlowTitle, InStanceId = regId.ToString()
            });

            return(new InitWorkFlowOutput()
            {
                InStanceId = regId.ToString(), FlowId = input.FlowId, GroupId = initRetdata.GroupId, TaskId = initRetdata.TaskId, StepId = initRetdata.StepId, StepName = initRetdata.StepName
            });
        }
Example #2
0
        public async Task <PmInitWorkFlowOutput> WriteRegistrationIsPm(WorkRegistrationInput input)
        {
            var list = _appConfiguration["App:WorkContact"].Split(",").Select(x => x.ToGuid()).ToList();

            if (input.StepId.HasValue)
            {
                var  isPm           = list.Contains(input.StepId.Value);
                long personOnCharge = 0;
                if (isPm)
                {
                    var leaderMemberType = (int)AuditRoleEnum.项目负责人;
                    var pmUserId         = (from pm in _projectAuditMemberRepository.GetAll()
                                            join u in _userRepository.GetAll() on pm.UserId equals u.Id
                                            where pm.ProjectBaseId == input.ProjectId.Value && pm.UserAuditRole == leaderMemberType
                                            select u.Id).FirstOrDefault();
                    if (pmUserId != null)
                    {
                        personOnCharge = pmUserId;
                    }
                }
                if (personOnCharge > 0)
                {
                    long userId = AbpSession.UserId.Value;
                    if (input.StepId.HasValue)
                    {
                        var taskModel = await _workFlowTaskRepository.FirstOrDefaultAsync(r => r.InstanceID == input.ProjectId.Value.ToString() && r.StepID == input.StepId.Value);

                        if (taskModel != null)
                        {
                            input.StepName = taskModel.StepName;
                        }
                    }
                    var regId = await _workTaskManager.InsertRegistration(new ProjectWorkTask
                    {
                        UserId    = userId,
                        TaskType  = input.Type == 1 ? 3 : 4,
                        ProjectId = input.ProjectId,
                        Title     = string.Format("{0}-{1}", input.Title, input.WorkTime.ToString("yyyyMMdd")),
                        StepId    = input.StepId,
                        StepName  = input.StepName
                    },
                                                                          new ProjectRegistration
                    {
                        SendUserId         = userId,
                        ProjectId          = input.ProjectId,
                        Code               = input.Code,
                        Title              = string.Format("{0}-{1}", input.Title, input.WorkTime.ToString("yyyyMMdd")),
                        WorkTime           = input.WorkTime,
                        Type               = input.Type,
                        Content            = input.Content,
                        RecieveUserId      = 0,
                        StepId             = input.StepId,
                        StepName           = input.StepName,
                        PersonOnChargeType = PersonOnChargeTypeEnum.待汇总,
                        PersonOnCharge     = personOnCharge
                    }, input.Files);

                    return(new PmInitWorkFlowOutput()
                    {
                        IsPm = true, initWorkFlow = null
                    });
                }
                else
                {
                    var initWorkFlow = await WriteRegistration(input);

                    return(new PmInitWorkFlowOutput()
                    {
                        IsPm = false, initWorkFlow = initWorkFlow
                    });
                }
            }
            else
            {
                input.StepName = "负责人汇总";
                var initWorkFlow = await WriteRegistration(input);

                var registrations = _projectRegistrationRepository.GetAll().Where(x => input.RegistrationIds.Contains(x.Id)).ToList();
                registrations.ForEach(x =>
                {
                    x.RegistrationId     = initWorkFlow.InStanceId.ToGuid();
                    x.IsSummary          = true;
                    x.PersonOnChargeType = PersonOnChargeTypeEnum.已汇总;
                    _projectRegistrationRepository.Update(x);
                });
                return(new PmInitWorkFlowOutput()
                {
                    IsPm = false, initWorkFlow = initWorkFlow
                });
            }
        }