fix 优化任务分配速度
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using Dlhis.ScheduledTask.Common.Request;
|
||||
using Dlhis.Basic.Api;
|
||||
using Dlhis.Basic.Api.Request;
|
||||
using Dlhis.ScheduledTask.Common.Request;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -42,4 +44,11 @@ public class HangfireController : ControllerBase
|
||||
{
|
||||
await _hangfireService.CreateSapWerkSyncBackgroundJobAsync(request);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("assignment-generate")]
|
||||
public void GeneratePermissionsAsync(GeneratePermissionIdRequest request)
|
||||
{
|
||||
_hangfireService.GeneratePermissions(request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user