Browse Source

多线程BUG修复

master
zhouhongjun 7 months ago
parent
commit
c38f02a0c9
  1. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs
  2. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs
  3. 2
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ExChangeCenterDbContext.cs
  4. 2
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContext.cs
  5. 2
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/WMSBJBMPTDbContext.cs

4
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);
}

9
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<TM_BJBMPT_JIT_RECORD>, List<BBAC_SE_DETAIL>>(wmsSeRecords);
if (jisSeDetails.Any())
{
@ -121,7 +123,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
/// </summary>
/// <remarks>
/// 同步TM_BJBMPT_JIS_RECORD表发运数据
/// 同步十次、每次同步100_000条发运数据
/// 同步十次、每次同步1_000条发运数据
/// </remarks>
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<TM_BJBMPT_JIS_RECORD>, List<BBAC_SE_DETAIL>>(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

2
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ExChangeCenterDbContext.cs

@ -15,7 +15,7 @@ namespace Win.Sfs.SettleAccount.EntityFrameworkCore
public ExChangeCenterDbContext(DbContextOptions<ExChangeCenterDbContext> options) : base(options)
{
this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(120));
this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(50));
}
protected override void OnModelCreating(ModelBuilder modelBuilder)

2
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContext.cs

@ -14,7 +14,7 @@ namespace Win.Sfs.SettleAccount
public SettleAccountDbContext(DbContextOptions<SettleAccountDbContext> options)
: base(options)
{
this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(120));
this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(50));
}
protected override void OnModelCreating(ModelBuilder builder)

2
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/WMSBJBMPTDbContext.cs

@ -17,7 +17,7 @@ namespace Win.Sfs.SettleAccount.EntityFrameworkCore
public WMSBJBMPTDbContext(DbContextOptions<WMSBJBMPTDbContext> options) : base(options)
{
this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(120));
this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(50));
}
protected override void OnModelCreating(ModelBuilder modelBuilder)

Loading…
Cancel
Save