Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
0
        /// <summary>
        /// 根据业务id获取实体
        /// </summary>
        /// <param name="input"></param>
        /// 只传id, content为空 表示: 只获取结果; 没有历史数据 则返回new;
        /// 传id+content不为空, 表示识别;若content与历史的summary不同则再次识别;相同则返回历史数据
        /// <returns></returns>
        public async Task <FinancialAccountingCertificateOutputDto> GetByBusinessId(GetByBusinessIdInput input)
        {
            var ret = new FinancialAccountingCertificateOutputDto();

            var model = await _repository.FirstOrDefaultAsync(x => x.BusinessId == input.BusinessId && x.BusinessType == (int)input.BusinessType);

            if (model == null)
            {
                if (input.Content.IsNullOrEmpty())
                {
                    return(new FinancialAccountingCertificateOutputDto());
                }
                var clUrl      = _appConfiguration["CLService:clUrl"];
                var requestUrl = $"{clUrl}/discern ";
                var parameter  = new { words = input.Content, tenantid = AbpSession.TenantId };
                var retResult  = HttpClientHelper.PostResponse <CLResultInfo>(requestUrl, parameter);
                Abp.Logging.LogHelper.Logger.Info($"访问财来接口:{requestUrl},参数:{Newtonsoft.Json.JsonConvert.SerializeObject(parameter)},返回结果:{Newtonsoft.Json.JsonConvert.SerializeObject(retResult)}");
                if (retResult == null)
                {
                    throw new UserFriendlyException((int)ErrorCode.HttpPortErr, "文本无法识别,请编辑后再试");
                }
                var createParameter = new CreateFinancialAccountingCertificateInput()
                {
                    BusinessId   = input.BusinessId,
                    BusinessType = (int)input.BusinessType,
                    Code         = "",
                    ResultId     = retResult.Id,
                    Summary      = input.Content,
                };
                foreach (var item in retResult.Content)
                {
                    createParameter.Details.Add(new CreateFACertificateDetailInput()
                    {
                        AccountingCourseId = item.ASid, Amount = item.Money, BusinessType = item.FACType
                    });
                }
                ret = Create(createParameter);
            }
            else
            {
                if (input.Content.IsNullOrEmpty())
                {
                    ret = model.MapTo <FinancialAccountingCertificateOutputDto>();
                    ret.BusinessType_Name = ((FACertificateBusinessType)ret.BusinessType).ToString();
                    using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete))
                    {
                        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,
                            Summary      = a.Summary
                        };

                        foreach (var item in details)
                        {
                            item.BusinessType_Name = ((FACertificateDetailBusinessType)item.BusinessType).ToString();
                            ret.Details.Add(item);
                        }
                    }
                }
                else
                {
                    if (input.Content != model.Summary)
                    {
                        var clUrl      = _appConfiguration["CLService:clUrl"];
                        var requestUrl = $"{clUrl}/discern ";
                        var parameter  = new { words = input.Content, tenantid = AbpSession.TenantId };
                        var retResult  = HttpClientHelper.PostResponse <CLResultInfo>(requestUrl, parameter);
                        Abp.Logging.LogHelper.Logger.Info($"访问财来接口:{requestUrl},参数:{Newtonsoft.Json.JsonConvert.SerializeObject(parameter)},返回结果:{Newtonsoft.Json.JsonConvert.SerializeObject(retResult)}");
                        if (retResult == null)
                        {
                            throw new UserFriendlyException((int)ErrorCode.HttpPortErr, "文本无法识别,请编辑后再试");
                        }
                        model.Summary  = input.Content;
                        model.ResultId = retResult.Id;

                        ret = model.MapTo <FinancialAccountingCertificateOutputDto>();
                        ret.BusinessType_Name = ((FACertificateBusinessType)ret.BusinessType).ToString();
                        ret.ResultId          = retResult.Id;
                        _detailRepository.Delete(r => r.MainId == model.Id);
                        using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete))
                        {
                            foreach (var item in retResult.Content)
                            {
                                var entity = new FACertificateDetail()
                                {
                                    Id = Guid.NewGuid(),
                                    AccountingCourseId = item.ASid,
                                    Amount             = item.Money,
                                    BusinessType       = item.FACType,
                                    MainId             = model.Id,
                                };
                                _detailRepository.Insert(entity);

                                var entityOutput = new FACertificateDetailListOutputDto();
                                entityOutput.AccountingCourseId      = item.ASid;
                                entityOutput.AccountingCourseId_Name = (_aCRepository.Get(item.ASid)).Name;
                                entityOutput.Amount            = item.Money;
                                entityOutput.BusinessType      = item.FACType;
                                entityOutput.BusinessType_Name = ((FACertificateDetailBusinessType)item.FACType).ToString();
                                entityOutput.Id     = entity.Id;
                                entityOutput.MainId = model.Id;
                                ret.Details.Add(entityOutput);
                            }
                        }
                    }
                    else
                    {
                        ret = model.MapTo <FinancialAccountingCertificateOutputDto>();
                        ret.BusinessType_Name = ((FACertificateBusinessType)ret.BusinessType).ToString();
                        using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete))
                        {
                            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;
            }
            if (ret.Type.HasValue)
            {
                ret.TypeName = _abpDictionaryRepository.GetAll().FirstOrDefault(x => x.Id == ret.Type.Value)?.Title;
            }
            return(ret);
        }