fix 优化任务分配速度

This commit is contained in:
2024-05-30 23:01:21 +08:00
parent bce58ef938
commit 7f14b1fdc5
13 changed files with 195 additions and 47 deletions

View File

@@ -1,4 +1,5 @@
using Dlhis.ScheduledTask.Common.Request;
using Dlhis.Basic.Api.Request;
using Dlhis.ScheduledTask.Common.Request;
namespace Dlhis.ScheduledTask.Common.Services;
@@ -20,4 +21,7 @@ public interface IHangfireService : IScopeDependency
/// <param name="request"></param>
/// <returns></returns>
Task CreateSapWerkSyncBackgroundJobAsync(SapNoRequest request);
}
void GeneratePermissions(GeneratePermissionIdRequest request);
}

View File

@@ -1,4 +1,6 @@
using Dlhis.Entity.Basic.Entity;
using Dlhis.Basic.Api;
using Dlhis.Basic.Api.Request;
using Dlhis.Entity.Basic.Entity;
using Dlhis.ScheduledTask.Common.Request;
using Hangfire;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
@@ -33,7 +35,7 @@ public class HangfireService : IHangfireService
{
var jobKey = $"hangfire:background:werk:{request.Code}";
using var handler = await _redisCache.LockAsync(jobKey);
await using var handler = await _redisCache.LockAsync(jobKey);
if (handler.Acquired)
{
var werkInfo = await _dbContext.Queryable<WerkEntity>().Where(x => x.Werk == request.Code).SingleAsync();
@@ -44,4 +46,10 @@ public class HangfireService : IHangfireService
BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoByWerkAsync(request.Code));
}
}
}
/// <inheritdoc />
public void GeneratePermissions(GeneratePermissionIdRequest request)
{
BackgroundJob.Enqueue<IDevicePermissionApi>(x => x.GeneratePermissionsAsync(request));
}
}