Example #1
0
        private CWGLReceivableLogDto GetChangeModel(CWGLReceivable model)
        {
            var ret = model.MapTo <CWGLReceivableLogDto>();

            ret.Mode = model.Mode.ToString();
            return(ret);
        }
Example #2
0
        public async Task <InitWorkFlowOutput> Create(CreateCWGLReceivableInput input)
        {
            var id       = Guid.NewGuid();
            var newmodel = new CWGLReceivable()
            {
                Id           = id,
                UserName     = input.UserName,
                Name         = input.Name,
                Money        = input.Money,
                Mode         = input.Mode,
                BankName     = input.BankName,
                CardNumber   = input.CardNumber,
                BankOpenName = input.BankOpenName,
                Note         = input.Note,
                Nummber      = input.Nummber
            };

            newmodel.Status = 0;
            await _repository.InsertAsync(newmodel);

            if (input.IsSaveFAC)
            {
                var certificateAppService = AbpBootstrapper.Create <Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve <IFinancialAccountingCertificateAppService>();

                input.FACData.BusinessId = id.ToString();
                certificateAppService.CreateOrUpdateWithOutNLP(input.FACData);
            }
            if (input.FileList != null)
            {
                var fileList = new List <AbpFileListInput>();
                foreach (var item in input.FileList)
                {
                    fileList.Add(new AbpFileListInput()
                    {
                        Id = item.Id, Sort = item.Sort
                    });
                }
                await _abpFileRelationAppService.CreateAsync(new CreateFileRelationsInput()
                {
                    BusinessId   = id.ToString(),
                    BusinessType = (int)AbpFileBusinessType.收款管理,
                    Files        = fileList
                });
            }
            return(new InitWorkFlowOutput()
            {
                InStanceId = newmodel.Id.ToString()
            });
        }
Example #3
0
        public async Task Update(UpdateCWGLReceivableInput input)
        {
            if (input.InStanceId != Guid.Empty)
            {
                var dbmodel = await _repository.FirstOrDefaultAsync(x => x.Id == input.InStanceId);

                if (dbmodel == null)
                {
                    throw new UserFriendlyException((int)ErrorCode.CodeValErr, "该数据不存在!");
                }
                var logModel = new CWGLReceivable();
                if (input.IsUpdateForChange)
                {
                    logModel = dbmodel.DeepClone <CWGLReceivable>();
                }
                dbmodel.UserName     = input.UserName;
                dbmodel.Name         = input.Name;
                dbmodel.Money        = input.Money;
                dbmodel.Mode         = input.Mode;
                dbmodel.BankName     = input.BankName;
                dbmodel.CardNumber   = input.CardNumber;
                dbmodel.BankOpenName = input.BankOpenName;
                dbmodel.Note         = input.Note;
                dbmodel.Nummber      = input.Nummber;

                await _repository.UpdateAsync(dbmodel);

                var fileList = new List <AbpFileListInput>();
                if (input.FileList != null)
                {
                    foreach (var item in input.FileList)
                    {
                        fileList.Add(new AbpFileListInput()
                        {
                            Id = item.Id, Sort = item.Sort
                        });
                    }
                }
                await _abpFileRelationAppService.UpdateAsync(new CreateFileRelationsInput()
                {
                    BusinessId   = input.Id.ToString(),
                    BusinessType = (int)AbpFileBusinessType.收款管理,
                    Files        = fileList
                });

                input.FACData.BusinessId = input.InStanceId.ToString();
                var groupId = Guid.NewGuid();
                input.FACData.GroupId = groupId;
                if (input.IsUpdateForChange)
                {
                    var flowModel = _workFlowCacheManager.GetWorkFlowModelFromCache(input.FlowId);
                    if (flowModel == null)
                    {
                        throw new UserFriendlyException((int)ErrorCode.CodeValErr, "流程不存在");
                    }
                    var logs = GetChangeModel(logModel).GetColumnAllLogs(GetChangeModel(dbmodel));
                    await _projectAuditManager.InsertAsync(logs, input.Id.ToString(), flowModel.TitleField.Table, groupId);
                }
            }
            else
            {
                throw new UserFriendlyException((int)ErrorCode.CodeValErr, "该数据不存在!");
            }
        }