Exemplo n.º 1
0
        /// <summary>
        /// 自动给办公室主任创建的任务, 进行加签
        /// </summary>
        /// <param name="id"></param>
        /// <param name="taskId"></param>
        /// <returns></returns>
        public async Task <string> AutoAddWriteForTask(Guid id, Guid taskId)
        {
            var model = await _repository.GetAsync(id);

            if (model.CreateUserRoleType != CreateUserRoleTypeEnum.BGSZR)
            {
                throw new UserFriendlyException((int)ErrorCode.CodeValErr, "办公室主任创建的任务才会自动加签");
            }

            var addUserList = new List <long>();

            addUserList.Add(model.TaskCreateUserId);
            var userRoles = await UserManager.GetRolesAsync(await UserManager.GetUserByIdAsync(model.TaskCreateUserId));

            if (userRoles.Any(r => string.Compare(r, "ZJL", true) == 0))
            {
            }
            else if (userRoles.Any(r => string.Compare(r, "OrgFGLD", true) == 0))
            {
                var users = _workFlowOrganizationUnitsManager.GetAbpUsersByRoleCode("ZJL");
                if (users.Count == 0)
                {
                    throw new UserFriendlyException((int)ErrorCode.CodeValErr, "未能找到总经理");
                }
                addUserList.Add(users.FirstOrDefault().Id);
            }
            else if (userRoles.Any(r => string.Compare(r, "DLEADER", true) == 0))
            {
                var chargeleaders = _workFlowOrganizationUnitsManager.GetChargeLeaderUsers(model.TaskCreateUserId).FirstOrDefault();
                if (chargeleaders == null)
                {
                    throw new UserFriendlyException((int)ErrorCode.CodeValErr, "未能找到任务发起者的部门分管领导");
                }
                addUserList.Add(chargeleaders.Id);


                var users = _workFlowOrganizationUnitsManager.GetAbpUsersByRoleCode("ZJL");
                if (users.Count == 0)
                {
                    throw new UserFriendlyException((int)ErrorCode.CodeValErr, "未能找到总经理");
                }
                addUserList.Add(users.FirstOrDefault().Id);
            }
            else
            {
            }
            var addUsers = string.Join(",", addUserList.Distinct().Select(r => $"{MemberPerfix.UserPREFIX}{r}"));
            var workFlowWorkTaskAppService = Abp.AbpBootstrapper.Create <Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve <IWorkFlowWorkTaskAppService>();
            var output = workFlowWorkTaskAppService.AddWrite(taskId, 2, 3, addUsers, "");

            return(output.ReturnMsg);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据主键获取实体
        /// </summary>
        /// <param name="input">主键</param>
        /// <returns></returns>

        public async Task <FinancialAccountingCertificateOutputDto> Get(NullableIdDto <Guid> input)
        {
            var model = await _repository.FirstOrDefaultAsync(x => x.Id == input.Id.Value);

            if (model == null)
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该数据不存在。");
            }
            var ret = model.MapTo <FinancialAccountingCertificateOutputDto>();

            using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete))
            {
                if (ret.Type.HasValue)
                {
                    ret.TypeName = _abpDictionaryRepository.GetAll().FirstOrDefault(x => x.Id == ret.Type.Value)?.Title;
                }
                ret.BusinessType_Name = ((FACertificateBusinessType)ret.BusinessType).ToString();
                var details = from a in _detailRepository.GetAll()
                              join b in _aCRepository.GetAll() on a.AccountingCourseId equals b.Id
                              where !a.IsDeleted && a.MainId == model.Id
                              select new FACertificateDetailListOutputDto()
                {
                    AccountingCourseId      = b.Id,
                    AccountingCourseId_Name = b.Name,
                    Amount       = a.Amount,
                    BusinessType = a.BusinessType,
                    CreationTime = a.CreationTime,
                    Id           = a.Id,
                    MainId       = a.MainId,
                };
                foreach (var item in details)
                {
                    item.BusinessType_Name = ((FACertificateDetailBusinessType)item.BusinessType).ToString();
                    ret.Details.Add(item);
                }
            }
            var cwUsers = _workFlowOrganizationUnitsManager.GetAbpUsersByRoleCode("CW");
            var clUsers = _workFlowOrganizationUnitsManager.GetAbpUsersByRoleCode("CL");

            if (cwUsers.Count() > 0)
            {
                ret.CWGL_Name = cwUsers.FirstOrDefault().Name;
            }
            if (clUsers.Count() > 0)
            {
                ret.CWCL_Name = clUsers.FirstOrDefault().Name;
            }

            return(ret);
        }
Exemplo n.º 3
0
        public async Task Update(SupplyScrapUpdateInput input)
        {
            var query = from a in _supplyScrapMainRepository.GetAll()
                        join b in _supplyScrapSubRepository.GetAll() on a.Id equals b.MainId
                        join c in _supplyBaseRepository.GetAll() on b.SupplyId equals c.Id
                        where a.Id == input.Id
                        select new { b, c };

            if (query.Count() != input.SubList.Count())
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "请指定报废处置结果");
            }
            var data = await query.ToListAsync();

            var service    = Abp.AbpBootstrapper.Create <Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve <ICW_PersonalTodoAppService>();
            var first_User = _workFlowOrganizationUnitsManager.GetAbpUsersByRoleCode("XZRY").FirstOrDefault();

            if (first_User == null)
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "未找到行政人员");
            }
            foreach (var item in input.SubList)
            {
                var entity = data.FirstOrDefault(r => r.b.Id == item.SubId);
                if (entity == null)
                {
                    throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "参数错误");
                }
                if (item.CWType == CWGL.Enums.RefundResultType.无退无报)
                {
                    continue;
                }
                await service.Create(new CreateCW_PersonalTodoInput()
                {
                    BusinessId   = item.SubId.ToString(),
                    BusinessType = CW_PersonalType.用品报废,
                    CWType       = item.CWType,
                    FlowId       = input.FlowId,
                    Amout_Gather = item.Amout_Gather,
                    Amout_Pay    = item.Amout_Pay,
                    Status       = CW_PersonalToStatus.未处理,
                    Title        = $"用品:{entity.c.Code}-报废",
                    UserId       = first_User.Id
                });
            }
        }
Exemplo n.º 4
0
        public void AfterRepairAction(string instanceId, Guid flowId)
        {
            var id = instanceId.ToGuid();
            var model = _supplyRepairRepository.Get(id);
            var supplyModel = _supplyBaseRepository.Get(model.SupplyId);
            if (model.RepairResult == RepairResultEnum.维修成功)
            {
                var service = Abp.AbpBootstrapper.Create<Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve<ICW_PersonalTodoAppService>();
                var first_User = _workFlowOrganizationUnitsManager.GetAbpUsersByRoleCode("XZRY").FirstOrDefault();
                if (first_User == null)
                    throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "未找到行政人员");
                service.Create(new CreateCW_PersonalTodoInput()
                {
                    BusinessId = model.Id.ToString(),
                    BusinessType = CW_PersonalType.用品维修,
                    CWType = CWGL.Enums.RefundResultType.财务应付款,
                    FlowId = flowId,
                    Status = CW_PersonalToStatus.未处理,
                    Title = $"用品:{supplyModel.Code}-维修",
                    UserId = first_User.Id,

                });

                var s = _supplyBaseRepository.Get(model.SupplyId);
                s.Status = (int)SupplyStatus.被领用;
                var u = _userSupplyRepository.FirstOrDefault(ite => ite.SupplyId == model.SupplyId && ite.Status == (int)UserSupplyStatus.维修中);
                if (u != null)
                    u.Status = (int)UserSupplyStatus.使用中;
            }
            else if (model.RepairResult == RepairResultEnum.维修失败)
            {
                var s = _supplyBaseRepository.Get(model.SupplyId);
                s.Status = (int)SupplyStatus.报废中;
                var u = _userSupplyRepository.FirstOrDefault(ite => ite.SupplyId == model.SupplyId && ite.Status == (int)UserSupplyStatus.维修中);
                if (u != null)
                    _userSupplyRepository.Delete(u);

                var serviceScranp = Abp.AbpBootstrapper.Create<Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve<ISupplyScrapAppService>();
                var list = serviceScranp.Create(new CreateSupplyScrapMainInput()
                {
                    FlowId = "665548ae-a5fb-4eee-89de-a00b6875949e".ToGuid(),
                    FlowTitle = "维修失败报废",
                    SupplyScrapSub = new List<CreateSupplyScrapSubInput>()
                {
                     new  CreateSupplyScrapSubInput ()
                     {
                          SupplyId = model.SupplyId,
                          Reason = model.ScrapReason,
                          UserSupplyId =model.UserSupplyId,
                     }
                }
                });
                var info = list.FirstOrDefault();
                //备注:强制提交后有待办,建议前端直接调用以下方法
                CurrentUnitOfWork.SaveChanges();
                var flower = Abp.AbpBootstrapper.Create<Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve<IWorkFlowAppService>();
                var next = flower.GetNextStepForRunSync(new GetNextStepForRunInput()
                {
                    TaskId = info.TaskId
                });
                var run = Abp.AbpBootstrapper.Create<Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve<IWorkFlowWorkTaskAppService>();
                var steps = next.Steps.Select(ite => new ExecuteWorkChooseStep() { id = ite.NextStepId.ToString(), member = ite.DefaultUserId }).ToList();
                var ret = run.ExecuteTaskSync(new ExecuteWorkFlowInput()
                {
                    ActionType = "submit",
                    FlowId = info.FlowId,
                    GroupId = info.GroupId,
                    InstanceId = info.InStanceId,
                    IsHideNextTask = true,
                    StepId = info.StepId,
                    Steps = steps,
                    TaskId = info.TaskId,
                    Title = $"维修失败报废"
                });
            }
        }