fix 超时设置
This commit is contained in:
15
Src/Dlhis.Basic.Api/ClientHandler/LongRunClientHandler.cs
Normal file
15
Src/Dlhis.Basic.Api/ClientHandler/LongRunClientHandler.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Dlhis.Basic.Api.ClientHandler;
|
||||||
using Dlhis.Basic.Api.ContentHandlers;
|
using Dlhis.Basic.Api.ContentHandlers;
|
||||||
using Dlhis.Basic.Api.Response;
|
using Dlhis.Basic.Api.Response;
|
||||||
using Kurisu.RemoteCall.Attributes;
|
using Kurisu.RemoteCall.Attributes;
|
||||||
@@ -5,7 +6,7 @@ using Kurisu.RemoteCall.Attributes;
|
|||||||
namespace Dlhis.Basic.Api;
|
namespace Dlhis.Basic.Api;
|
||||||
|
|
||||||
[RequestResultHandler]
|
[RequestResultHandler]
|
||||||
[EnableRemoteClient(Name = "basic-service", BaseUrl = "${InternalRequest:BasicRequestUrl}")]
|
[EnableRemoteClient(Name = "longRun-service", BaseUrl = "${InternalRequest:BasicRequestUrl}", PolicyHandler = typeof(LongRunClientHandler))]
|
||||||
public interface ISyncApi
|
public interface ISyncApi
|
||||||
{
|
{
|
||||||
[Post("/api/sync/gainfo/werk")]
|
[Post("/api/sync/gainfo/werk")]
|
||||||
@@ -27,4 +28,11 @@ public interface ISyncApi
|
|||||||
[Post("/api/sync/businessTrips")]
|
[Post("/api/sync/businessTrips")]
|
||||||
[RequestContentHandler(typeof(CodeContentHandler))]
|
[RequestContentHandler(typeof(CodeContentHandler))]
|
||||||
Task HandlerBusinessTripsAsync(string code);
|
Task HandlerBusinessTripsAsync(string code);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 外包自动离职处理
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Post("/api/gainfoOutsource/autoResign")]
|
||||||
|
Task OutsourceAutoResignAsync();
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,7 @@ public class DevicePermissionService : IDevicePermissionService
|
|||||||
var waitAddTasks = new ConcurrentBag<DeviceTaskEntity>();
|
var waitAddTasks = new ConcurrentBag<DeviceTaskEntity>();
|
||||||
var waitDeleteTasks = 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);
|
before.TryGetValue(userNo, out var beforeTenantDeviceCodes);
|
||||||
beforeTenantDeviceCodes ??= new List<UserTenantDeviceCodeDto>();
|
beforeTenantDeviceCodes ??= new List<UserTenantDeviceCodeDto>();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Dlhis.Basic.Organization.Request;
|
using Dlhis.Basic.Organization.Request;
|
||||||
using Dlhis.Basic.Organization.Services;
|
using Dlhis.Basic.Organization.Services;
|
||||||
using Dlhis.Jip.Api.Responses;
|
using Dlhis.Jip.Api.Responses;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@@ -23,12 +24,14 @@ public class SyncController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("/api/sync/gainfo/werk")]
|
[HttpPost("/api/sync/gainfo/werk")]
|
||||||
|
[IgnoreTenant]
|
||||||
public async Task TodoByWerkAsync(CodeRequest request)
|
public async Task TodoByWerkAsync(CodeRequest request)
|
||||||
{
|
{
|
||||||
await _gainfoUpdateService.TodoByWerkAsync(request.Code);
|
await _gainfoUpdateService.TodoByWerkAsync(request.Code);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("/api/sync/gainfo/user")]
|
[HttpPost("/api/sync/gainfo/user")]
|
||||||
|
[IgnoreTenant]
|
||||||
public async Task TodoByCodeAsync(CodeRequest request)
|
public async Task TodoByCodeAsync(CodeRequest request)
|
||||||
{
|
{
|
||||||
await _gainfoUpdateService.TodoByCodeAsync(request.Code);
|
await _gainfoUpdateService.TodoByCodeAsync(request.Code);
|
||||||
@@ -46,8 +49,9 @@ public class SyncController : ControllerBase
|
|||||||
{
|
{
|
||||||
return await _jinkoSapService.GetPositionsAsync();
|
return await _jinkoSapService.GetPositionsAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("/api/sync/businessTrips")]
|
[HttpPost("/api/sync/businessTrips")]
|
||||||
|
[IgnoreTenant]
|
||||||
public async Task GetPositionsAsync(CodeRequest request)
|
public async Task GetPositionsAsync(CodeRequest request)
|
||||||
{
|
{
|
||||||
await _sapBusinessTripService.HandlerBusinessTripsByFactoryAsync(request.Code);
|
await _sapBusinessTripService.HandlerBusinessTripsByFactoryAsync(request.Code);
|
||||||
|
|||||||
@@ -9,17 +9,17 @@ namespace Dlhis.ScheduledTask.Jobs;
|
|||||||
[RecurringJob(nameof(OutsourceAutoResignJob), "0 0 1 1/1 * ? ", Name = "自动处理外包离职")]
|
[RecurringJob(nameof(OutsourceAutoResignJob), "0 0 1 1/1 * ? ", Name = "自动处理外包离职")]
|
||||||
public class OutsourceAutoResignJob : BaseJob
|
public class OutsourceAutoResignJob : BaseJob
|
||||||
{
|
{
|
||||||
private readonly IGainfoApi _gainfoApi;
|
private readonly ISyncApi _syncApi;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public OutsourceAutoResignJob(IServiceProvider serviceProvider, IGainfoApi gainfoApi) : base(serviceProvider)
|
public OutsourceAutoResignJob(IServiceProvider serviceProvider, ISyncApi syncApi) : base(serviceProvider)
|
||||||
{
|
{
|
||||||
_gainfoApi = gainfoApi;
|
_syncApi = syncApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
await _gainfoApi.OutsourceAutoResignAsync();
|
await _syncApi.OutsourceAutoResignAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,13 +26,13 @@ public class SyncPersonJob : BaseJob
|
|||||||
{
|
{
|
||||||
if (!werk.BackgroundJobKey.IsEmpty())
|
if (!werk.BackgroundJobKey.IsEmpty())
|
||||||
{
|
{
|
||||||
|
var jobKey = BackgroundJob.Enqueue<ISyncApi>(x => x.SyncGainfoByWerkAsync(werk.Werk));
|
||||||
|
werk.BackgroundJobKey = jobKey;
|
||||||
|
await DbContext.UpdateAsync(werk);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var jobKey = BackgroundJob.Enqueue<ISyncApi>(x => x.SyncGainfoByWerkAsync(werk.Werk));
|
|
||||||
werk.BackgroundJobKey = jobKey;
|
|
||||||
await DbContext.UpdateAsync(werk);
|
|
||||||
|
|
||||||
Logger.LogInformation("SAP创建人事范围{werk}后台调度任务", werk.Werk);
|
Logger.LogInformation("SAP创建人事范围{werk}后台调度任务", werk.Werk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user