fix 超时设置

This commit is contained in:
2024-11-28 14:57:39 +08:00
parent 2004035d9b
commit 971ef87957
7 changed files with 38 additions and 26 deletions

View File

@@ -0,0 +1,15 @@
using Kurisu.RemoteCall.Abstractions;
using Microsoft.Extensions.DependencyInjection;
namespace Dlhis.Basic.Api.ClientHandler;
public class LongRunClientHandler : IHttpRemoteCallPolicyHandler
{
/// <inheritdoc />
public IHttpClientBuilder ConfigureHttpClient(IHttpClientBuilder builder)
{
builder.ConfigureHttpClient(x => { x.Timeout = TimeSpan.FromHours(1); });
return builder;
}
}

View File

@@ -1,15 +0,0 @@
using Kurisu.RemoteCall.Attributes;
namespace Dlhis.Basic.Api;
[RequestResultHandler]
[EnableRemoteClient(Name = "basic-service", BaseUrl = "${InternalRequest:BasicRequestUrl}")]
public interface IGainfoApi
{
/// <summary>
/// 外包自动离职处理
/// </summary>
/// <returns></returns>
[Post("/api/gainfoOutsource/autoResign")]
Task OutsourceAutoResignAsync();
}

View File

@@ -1,3 +1,4 @@
using Dlhis.Basic.Api.ClientHandler;
using Dlhis.Basic.Api.ContentHandlers;
using Dlhis.Basic.Api.Response;
using Kurisu.RemoteCall.Attributes;
@@ -5,7 +6,7 @@ using Kurisu.RemoteCall.Attributes;
namespace Dlhis.Basic.Api;
[RequestResultHandler]
[EnableRemoteClient(Name = "basic-service", BaseUrl = "${InternalRequest:BasicRequestUrl}")]
[EnableRemoteClient(Name = "longRun-service", BaseUrl = "${InternalRequest:BasicRequestUrl}", PolicyHandler = typeof(LongRunClientHandler))]
public interface ISyncApi
{
[Post("/api/sync/gainfo/werk")]
@@ -27,4 +28,11 @@ public interface ISyncApi
[Post("/api/sync/businessTrips")]
[RequestContentHandler(typeof(CodeContentHandler))]
Task HandlerBusinessTripsAsync(string code);
/// <summary>
/// 外包自动离职处理
/// </summary>
/// <returns></returns>
[Post("/api/gainfoOutsource/autoResign")]
Task OutsourceAutoResignAsync();
}

View File

@@ -219,7 +219,7 @@ public class DevicePermissionService : IDevicePermissionService
var waitAddTasks = new ConcurrentBag<DeviceTaskEntity>();
var waitDeleteTasks = new ConcurrentBag<DeviceTaskEntity>();
Parallel.ForEach(userNos, new ParallelOptions() { MaxDegreeOfParallelism = 100 }, userNo =>
Parallel.ForEach(userNos, new ParallelOptions { MaxDegreeOfParallelism = 100 }, userNo =>
{
before.TryGetValue(userNo, out var beforeTenantDeviceCodes);
beforeTenantDeviceCodes ??= new List<UserTenantDeviceCodeDto>();

View File

@@ -1,6 +1,7 @@
using Dlhis.Basic.Organization.Request;
using Dlhis.Basic.Organization.Services;
using Dlhis.Jip.Api.Responses;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -23,12 +24,14 @@ public class SyncController : ControllerBase
}
[HttpPost("/api/sync/gainfo/werk")]
[IgnoreTenant]
public async Task TodoByWerkAsync(CodeRequest request)
{
await _gainfoUpdateService.TodoByWerkAsync(request.Code);
}
[HttpPost("/api/sync/gainfo/user")]
[IgnoreTenant]
public async Task TodoByCodeAsync(CodeRequest request)
{
await _gainfoUpdateService.TodoByCodeAsync(request.Code);
@@ -48,6 +51,7 @@ public class SyncController : ControllerBase
}
[HttpPost("/api/sync/businessTrips")]
[IgnoreTenant]
public async Task GetPositionsAsync(CodeRequest request)
{
await _sapBusinessTripService.HandlerBusinessTripsByFactoryAsync(request.Code);

View File

@@ -9,17 +9,17 @@ namespace Dlhis.ScheduledTask.Jobs;
[RecurringJob(nameof(OutsourceAutoResignJob), "0 0 1 1/1 * ? ", Name = "自动处理外包离职")]
public class OutsourceAutoResignJob : BaseJob
{
private readonly IGainfoApi _gainfoApi;
private readonly ISyncApi _syncApi;
/// <inheritdoc />
public OutsourceAutoResignJob(IServiceProvider serviceProvider, IGainfoApi gainfoApi) : base(serviceProvider)
public OutsourceAutoResignJob(IServiceProvider serviceProvider, ISyncApi syncApi) : base(serviceProvider)
{
_gainfoApi = gainfoApi;
_syncApi = syncApi;
}
/// <inheritdoc />
protected override async Task RunAsync(IServiceProvider serviceProvider)
{
await _gainfoApi.OutsourceAutoResignAsync();
await _syncApi.OutsourceAutoResignAsync();
}
}

View File

@@ -26,13 +26,13 @@ public class SyncPersonJob : BaseJob
{
if (!werk.BackgroundJobKey.IsEmpty())
{
continue;
}
var jobKey = BackgroundJob.Enqueue<ISyncApi>(x => x.SyncGainfoByWerkAsync(werk.Werk));
werk.BackgroundJobKey = jobKey;
await DbContext.UpdateAsync(werk);
continue;
}
Logger.LogInformation("SAP创建人事范围{werk}后台调度任务", werk.Werk);
}
}