From ef175c4304547ecde690d9c5b689e805965839c6 Mon Sep 17 00:00:00 2001 From: mahao Date: Fri, 13 Oct 2023 13:45:51 +0800 Subject: [PATCH] =?UTF-8?q?Qad=E5=8F=91=E7=A5=A8=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=AF=BC=E5=87=BA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SettleAccount.HttpApi.Host/Startup.cs | 7 ++++++ .../Entities/BQ/INVOICE_SERVICE.cs | 6 +++++ .../BQ/Syncs/InvoiceSyncQadInvocable.cs | 23 ++++++++----------- ...ttleAccountApplicationAutoMapperProfile.cs | 1 + 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs index 7c0464ce..75dce71f 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs @@ -18,6 +18,7 @@ using SettleAccount.Job.SignalR; using Win.Sfs.SettleAccount.Entities.BQ; using Win.Sfs.SettleAccount.Entities.BQ.Syncs; using Win.Sfs.SettleAccount.ExcelImporter; +using Win.Sfs.SettleAccount.Options; namespace Win.Sfs.SettleAccount { @@ -52,6 +53,7 @@ namespace Win.Sfs.SettleAccount }); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); services.AddSignalR(o => o.EnableDetailedErrors = true); JobHostdService.AddService(services); services.AddSingleton(); @@ -70,6 +72,10 @@ namespace Win.Sfs.SettleAccount options.MaxRequestBodySize = 268435456; options.AllowSynchronousIO = true; }); + services.Configure(options => + { + options.IsSyncInvoiceQadState = true; + }); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) @@ -83,6 +89,7 @@ namespace Win.Sfs.SettleAccount { scheduler.Schedule().EveryMinute(); scheduler.Schedule().EveryMinute(); + scheduler.Schedule().EveryMinute(); }); var contentTypeProvider = new FileExtensionContentTypeProvider(); contentTypeProvider.Mappings.Add(".mjs", "text/javascript"); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs index cd7042ff..c1485cbe 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs @@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Polly; using SettleAccount.Domain.BQ; using Shouldly; @@ -31,6 +32,7 @@ using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.EntityFrameworkCore; using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExportReports; +using Win.Sfs.SettleAccount.Options; using Win.Sfs.Shared.Filter; using Win.Sfs.Shared.RepositoryBase; @@ -49,6 +51,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// 数据中心数据上下文 /// private readonly ExChangeCenterDbContext _exChangeCenterDbContext; + private readonly GlobalConfigOptions _globalConfigOptions; private readonly INormalEfCoreRepository _repository; private readonly INormalEfCoreRepository _wRepository; @@ -64,6 +67,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ ILogger logger, SettleAccountDbContext settleAccountDbContext, ExChangeCenterDbContext exChangeCenterDbContext, + IOptions options, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, @@ -83,6 +87,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ _logger = logger; _settleAccountDbContext = settleAccountDbContext; _exChangeCenterDbContext = exChangeCenterDbContext; + _globalConfigOptions = options.Value; _baseservice = baseservice; _repository = repository; _wRepository = wRepository; @@ -109,6 +114,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [HttpPost] public virtual async Task SubmitToQad(List invbillNums) { + _globalConfigOptions.IsSyncInvoiceQadState = true; for (var i = 0; i < invbillNums.Count; i++) { await SubmitToQadSingle(invbillNums[i]).ConfigureAwait(false); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/InvoiceSyncQadInvocable.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/InvoiceSyncQadInvocable.cs index 4ee4e423..3251bc6b 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/InvoiceSyncQadInvocable.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/InvoiceSyncQadInvocable.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Linq.Dynamic.Core; using System.Threading.Tasks; using Coravel.Invocable; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using SettleAccount.Domain.BQ; @@ -53,22 +54,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs } var taskIDs = invoiceSyncQads.Select(t => t.TaskID); - var teaTaskSubs = _exChangeCenterDbContext.TEA_TASK_SUB.Where(t => taskIDs.Contains(t.TaskID)).ToList(); + var teaTaskSubs = _exChangeCenterDbContext.TEA_TASK_SUB.AsNoTracking().Where(t => taskIDs.Contains(t.TaskID)).ToList(); - invoiceSyncQads.Join(teaTaskSubs, x => x.TaskID, y => y.TaskID, (x, y) => + invoiceSyncQads.ForEach(invoiceSyncQad => { - x.UpdateTaskState(y.TaskState); - x.UpdateFailedInfo(y.FailedInfo); - return x; + var teaTaskSub = teaTaskSubs.FirstOrDefault(t => t.TaskID == invoiceSyncQad.TaskID); + if (teaTaskSub != null) + { + invoiceSyncQad.UpdateTaskState(teaTaskSub.TaskState); + invoiceSyncQad.UpdateFailedInfo(teaTaskSub.FailedInfo); + } }); - - //var query = from a in invoiceSyncQads - // from b in teaTaskSubs - // where a.TaskID == b.TaskID - // select a; - - - + await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false); } } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs index 416d75d2..f08e1bd3 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs @@ -527,6 +527,7 @@ namespace Win.Sfs.SettleAccount private void CreateMapInvoiceSyncQad() { CreateMap(); + CreateMap(); } private void CreateMapInvoiceSettledDiff()