From c38f02a0c9795f047aae64992359f244bdc4b8f2 Mon Sep 17 00:00:00 2001 From: zhouhongjun <565221961@qq.com> Date: Thu, 9 May 2024 15:47:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E7=BA=BF=E7=A8=8BBUG=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/JobHostdService.cs | 4 ++-- .../Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs | 9 ++++++--- .../EntityFrameworkCore/ExChangeCenterDbContext.cs | 2 +- .../EntityFrameworkCore/SettleAccountDbContext.cs | 2 +- .../EntityFrameworkCore/WMSBJBMPTDbContext.cs | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs index 0717ef53..76d3e6b7 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs @@ -140,8 +140,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { var jobItem = this.GetJobItem(job.Id); Guid? jobLogId = null; - // 如果作业正在运行并且心跳超过20秒,则停止作业 - if (jobItem.IsRunning && (DateTime.Now - jobItem.HeartBeat.Value).TotalSeconds > 20) + // 如果作业正在运行并且心跳超过120分钟,则停止作业 + if (jobItem.IsRunning && (DateTime.Now - jobItem.HeartBeat.Value).TotalMinutes > 120) { JobItemStop(jobItem.Id); } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs index f1a78c77..30f3d749 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using Coravel.Invocable; using EFCore.BulkExtensions; +using Hangfire.Common; using LinqToDB; using Microsoft.AspNetCore.Mvc; using SettleAccount.Domain.BQ; @@ -103,7 +105,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs .Where(t => t.UID > int.Parse(syncPosition)) .Where(t => t.DeliverBillType == deliverBillType) .Where(t => deliverSubBillTypes.Contains(t.DeliverSubBillType)) - .OrderBy(b => b.UID).Take(10_000).ToList(); + .OrderBy(b => b.UID).Take(1_000).ToList(); var jisSeDetails = ObjectMapper.Map, List>(wmsSeRecords); if (jisSeDetails.Any()) { @@ -121,7 +123,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs /// /// /// 同步TM_BJBMPT_JIS_RECORD表发运数据 - /// 同步十次、每次同步100_000条发运数据 + /// 同步十次、每次同步1_000条发运数据 /// private async Task SyncJisRecordAsync() { @@ -145,7 +147,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs .Where(t => t.UID > int.Parse(syncPosition)) .Where(t => t.DeliverBillType == deliverBillType) .Where(t => deliverSubBillTypes.Contains(t.DeliverSubBillType)) - .OrderBy(b => b.UID).Take(10_000).ToList(); + .OrderBy(b => b.UID).Take(1_000).ToList(); var jisSeDetails = ObjectMapper.Map, List>(wmsSeRecords); if (jisSeDetails.Any()) { @@ -201,6 +203,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs t.CreationTime = dateTimeNow; }); var syncPosition = seDetails.Last().UID.ToString(); + using var transaction = await _settleAccountDbContext.Database.BeginTransactionAsync().ConfigureAwait(false); try diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ExChangeCenterDbContext.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ExChangeCenterDbContext.cs index 5e13c444..103ec92e 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ExChangeCenterDbContext.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ExChangeCenterDbContext.cs @@ -15,7 +15,7 @@ namespace Win.Sfs.SettleAccount.EntityFrameworkCore public ExChangeCenterDbContext(DbContextOptions options) : base(options) { - this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(120)); + this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(50)); } protected override void OnModelCreating(ModelBuilder modelBuilder) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContext.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContext.cs index 8a07943f..bb3d7ad1 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContext.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContext.cs @@ -14,7 +14,7 @@ namespace Win.Sfs.SettleAccount public SettleAccountDbContext(DbContextOptions options) : base(options) { - this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(120)); + this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(50)); } protected override void OnModelCreating(ModelBuilder builder) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/WMSBJBMPTDbContext.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/WMSBJBMPTDbContext.cs index 2c691091..2426c87e 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/WMSBJBMPTDbContext.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/WMSBJBMPTDbContext.cs @@ -17,7 +17,7 @@ namespace Win.Sfs.SettleAccount.EntityFrameworkCore public WMSBJBMPTDbContext(DbContextOptions options) : base(options) { - this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(120)); + this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(50)); } protected override void OnModelCreating(ModelBuilder modelBuilder)