Exemplo n.º 1
0
        private FinancialAccountingCertificateOutputDto CreateWithOutNLP(CreateFinancialAccountingCertificateInput input)
        {
            var ret          = new FinancialAccountingCertificateOutputDto();
            var service      = AbpBootstrapper.Create <Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve <IWorkFlowOrganizationUnitsAppService>();
            var userOrgModel = service.GetUserPostInfoV2(new NullableIdDto <long>()
            {
                Id = AbpSession.UserId.Value,
            }, new NullableIdDto <long>()
            {
                Id = null
            });

            var newmodel = new FinancialAccountingCertificate()
            {
                Code = input.Code == null ? "" : input.Code,
                //BusinessType = input.BusinessType,
                BusinessType = 1,
                BusinessId   = input.BusinessId,
                //UserId = input.UserId,
                UserId            = AbpSession.UserId.Value,
                OrgId             = userOrgModel.OrgId,
                KeepUserId        = input.KeepUserId,
                AuditUserId       = input.AuditUserId,
                CashierUserId     = input.CashierUserId,
                MakeUserId        = input.MakeUserId,
                Summary           = input.Summary,
                Type              = input.Type,
                Name              = input.Name,
                Region            = input.Region,
                TotalDebitAmount  = input.TotalDebitAmount,
                TotalCreditAmount = input.TotalCreditAmount,
                Id       = Guid.NewGuid(),
                ResultId = input.ResultId,
            };

            using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete))
            {
                foreach (var item in input.Details)
                {
                    var entity = new FACertificateDetail()
                    {
                        Id = Guid.NewGuid(),
                        AccountingCourseId = item.AccountingCourseId,
                        Amount             = item.Amount,
                        Summary            = item.Summary,
                        BusinessType       = item.BusinessType,
                        MainId             = newmodel.Id,
                    };

                    _detailRepository.Insert(entity);


                    var entityOutput = new FACertificateDetailListOutputDto();
                    entityOutput.AccountingCourseId      = item.AccountingCourseId;
                    entityOutput.AccountingCourseId_Name = (_aCRepository.Get(item.AccountingCourseId)).Name;
                    entityOutput.Amount            = item.Amount;
                    entityOutput.Summary           = item.Summary;
                    entityOutput.BusinessType      = item.BusinessType;
                    entityOutput.BusinessType_Name = ((FACertificateDetailBusinessType)item.BusinessType).ToString();
                    entityOutput.Id     = entity.Id;
                    entityOutput.MainId = newmodel.Id;
                    //if (item.BusinessType == (int)FACertificateDetailBusinessType.借)
                    //    newmodel.TotalDebitAmount = newmodel.TotalDebitAmount + item.Amount;
                    //else
                    //    newmodel.TotalCreditAmount = newmodel.TotalCreditAmount + item.Amount;
                    ret.Details.Add(entityOutput);
                }
            }

            _repository.Insert(newmodel);
            ret.ResultId          = input.ResultId;
            ret.BusinessId        = input.BusinessId;
            ret.BusinessType      = input.BusinessType;
            ret.BusinessType_Name = ((FACertificateBusinessType)ret.BusinessType).ToString();
            ret.AuditUserId       = input.AuditUserId;
            ret.CashierUserId     = input.CashierUserId;
            ret.Code         = input.Code;
            ret.CreationTime = DateTime.Now;
            ret.Id           = newmodel.Id;
            ret.KeepUserId   = input.KeepUserId;
            ret.MakeUserId   = input.MakeUserId;
            ret.OrgId        = newmodel.OrgId;
            ret.Summary      = newmodel.Summary;
            return(ret);
        }
Exemplo n.º 2
0
        private FinancialAccountingCertificateOutputDto Create(CreateFinancialAccountingCertificateInput input)
        {
            var ret          = new FinancialAccountingCertificateOutputDto();
            var service      = AbpBootstrapper.Create <Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve <IWorkFlowOrganizationUnitsAppService>();
            var userOrgModel = service.GetUserPostInfoV2(new NullableIdDto <long>()
            {
                Id = AbpSession.UserId.Value,
            }, new NullableIdDto <long>()
            {
                Id = null
            });
            var newmodel = new FinancialAccountingCertificate()
            {
                Code         = input.Code,
                BusinessType = input.BusinessType,
                BusinessId   = input.BusinessId,
                //UserId = input.UserId,
                UserId            = AbpSession.UserId.Value,
                OrgId             = userOrgModel.OrgId,
                KeepUserId        = input.KeepUserId,
                AuditUserId       = input.AuditUserId,
                CashierUserId     = input.CashierUserId,
                MakeUserId        = input.MakeUserId,
                Summary           = input.Summary,
                Type              = input.Type,
                Name              = input.Name,
                Region            = input.Region,
                TotalDebitAmount  = input.TotalDebitAmount,
                TotalCreditAmount = input.TotalCreditAmount,
                Id       = Guid.NewGuid(),
                ResultId = input.ResultId,
            };

            using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete))
            {
                foreach (var item in input.Details)
                {
                    var entity = new FACertificateDetail()
                    {
                        Id = Guid.NewGuid(),
                        AccountingCourseId = item.AccountingCourseId,
                        Amount             = item.Amount,
                        BusinessType       = item.BusinessType,
                        MainId             = newmodel.Id,
                    };

                    _detailRepository.Insert(entity);


                    var entityOutput = new FACertificateDetailListOutputDto();
                    entityOutput.AccountingCourseId      = item.AccountingCourseId;
                    entityOutput.AccountingCourseId_Name = (_aCRepository.Get(item.AccountingCourseId)).Name;
                    entityOutput.Amount            = item.Amount;
                    entityOutput.BusinessType      = item.BusinessType;
                    entityOutput.BusinessType_Name = ((FACertificateDetailBusinessType)item.BusinessType).ToString();
                    entityOutput.Id     = entity.Id;
                    entityOutput.MainId = newmodel.Id;
                    //if (item.BusinessType == (int)FACertificateDetailBusinessType.借)
                    //    newmodel.TotalDebitAmount = newmodel.TotalDebitAmount + item.Amount;
                    //else
                    //    newmodel.TotalCreditAmount = newmodel.TotalCreditAmount + item.Amount;
                    ret.Details.Add(entityOutput);
                }
            }

            if (input.IsResultChangeByUser)
            {
                var clUrl      = _appConfiguration["CLService:clUrl"];
                var requestUrl = $"{clUrl}/modify ";
                var param      = new CLResultInfo {
                    Id = input.ResultId, Content = input.Details.Select(r => new CLResultDetailInfo {
                        ASid = r.AccountingCourseId, Money = r.Amount, FACType = r.BusinessType
                    }).ToList(),
                };
                Task.Run(() =>
                {
                    var result = HttpClientHelper.PostResponse(requestUrl, param);
                    Abp.Logging.LogHelper.Logger.Info($"访问财来接口:{requestUrl},参数:{Newtonsoft.Json.JsonConvert.SerializeObject(param)},返回结果:{result}");
                });
            }
            _repository.Insert(newmodel);
            ret.ResultId          = input.ResultId;
            ret.BusinessId        = input.BusinessId;
            ret.BusinessType      = input.BusinessType;
            ret.BusinessType_Name = ((FACertificateBusinessType)ret.BusinessType).ToString();
            ret.AuditUserId       = input.AuditUserId;
            ret.CashierUserId     = input.CashierUserId;
            ret.Code         = input.Code;
            ret.CreationTime = DateTime.Now;
            ret.Id           = newmodel.Id;
            ret.KeepUserId   = input.KeepUserId;
            ret.MakeUserId   = input.MakeUserId;
            ret.OrgId        = newmodel.OrgId;
            ret.Summary      = newmodel.Summary;
            ret.Type         = newmodel.Type;
            ret.Name         = newmodel.Name;
            ret.Region       = newmodel.Region;

            return(ret);
        }