From 7d76fc59ff07da3211823a6d2ef5d72566613267 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Tue, 26 Nov 2024 17:02:11 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=97=A5=E6=9C=9F=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/SapBusinessTripService.cs | 2 +- .../Jobs/SyncBusinessTripJob.cs | 9 ++++++++- Src/Dlhis.ScheduledTask/Program.cs | 16 ++++++++++++++++ .../Controllers/HangfireController.cs | 17 ++++++++++++++++- .../appsettings.Development.json | 15 +++++++++++---- 5 files changed, 52 insertions(+), 7 deletions(-) diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/SapBusinessTripService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/SapBusinessTripService.cs index 79381e05..77e259c4 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/SapBusinessTripService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/SapBusinessTripService.cs @@ -40,7 +40,7 @@ public class SapBusinessTripService : ISapBusinessTripService try { - var tripResponse = await _jinkoJipApi.GetBusinessTripInfosByFactoryAsync(factory, today, today); + var tripResponse = await _jinkoJipApi.GetBusinessTripInfosByFactoryAsync(factory, yesterday, today); if (!tripResponse.Items.Any()) { return; diff --git a/Src/Dlhis.ScheduledTask/Jobs/SyncBusinessTripJob.cs b/Src/Dlhis.ScheduledTask/Jobs/SyncBusinessTripJob.cs index 5f0d179e..e8fbad0f 100644 --- a/Src/Dlhis.ScheduledTask/Jobs/SyncBusinessTripJob.cs +++ b/Src/Dlhis.ScheduledTask/Jobs/SyncBusinessTripJob.cs @@ -24,7 +24,14 @@ public class SyncBusinessTripJob : BaseJob foreach (var factory in factories) { - await _syncApi.HandlerBusinessTripsAsync(factory.Code); + try + { + await _syncApi.HandlerBusinessTripsAsync(factory.Code); + } + catch (Exception e) + { + Logger.LogError(e, "同步出差人员异常:{msg}", e.Message); + } } } } \ No newline at end of file diff --git a/Src/Dlhis.ScheduledTask/Program.cs b/Src/Dlhis.ScheduledTask/Program.cs index 7c759046..7f86717a 100644 --- a/Src/Dlhis.ScheduledTask/Program.cs +++ b/Src/Dlhis.ScheduledTask/Program.cs @@ -22,4 +22,20 @@ public class Startup : DefaultStartup base.ConfigureServices(services); services.AddRedis(); } + + /// + public override void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + base.Configure(app, env); + + var a = app.ApplicationServices.GetService().SyncMealSupplementRecordsAsync(new List() + { + new SyncMealSupplementRecordRequest + { + UniqueId = null, + Status = null, + Msg = null + } + }).GetAwaiter().GetResult(); + } } \ No newline at end of file diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/HangfireController.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/HangfireController.cs index f92169c4..b9b03f45 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/HangfireController.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/HangfireController.cs @@ -1,4 +1,5 @@ using Dlhis.Basic.Api; +using Dlhis.Jip.Api; using Dlhis.Jip.Api.Request; using Hangfire; using Kurisu.AspNetCore.Utils; @@ -16,10 +17,12 @@ namespace Dlhis.ScheduledTask.TaskAssignment.Controllers; public class HangfireController : ControllerBase { private readonly RedisCache _redisCache; + private readonly IJinkoJipApi _jinkoJipApi; - public HangfireController( RedisCache redisCache) + public HangfireController(RedisCache redisCache, IJinkoJipApi jinkoJipApi) { _redisCache = redisCache; + _jinkoJipApi = jinkoJipApi; } /// @@ -53,4 +56,16 @@ public class HangfireController : ControllerBase BackgroundJob.Enqueue(x => x.SyncGainfoByWerkAsync(request.Code)); } } + + [HttpPost("test")] + public async Task TestAsync() + { + return await _jinkoJipApi.SyncMealSupplementRecordsAsync(new List() + { + new() + { + UniqueId = "Dl-Test01", Msg = "成功", Status = "SUCCESS" + } + }); + } } \ No newline at end of file diff --git a/Src/Dlhis.ScheduledTask/appsettings.Development.json b/Src/Dlhis.ScheduledTask/appsettings.Development.json index bfd5a43d..da038ced 100644 --- a/Src/Dlhis.ScheduledTask/appsettings.Development.json +++ b/Src/Dlhis.ScheduledTask/appsettings.Development.json @@ -36,11 +36,18 @@ "ClientSecret": "123456" } }, +// "JinkoOptions": { +// "Jip": { +// "BaseUrl": "http://172.16.202.34:8000", +// "Key": "FACE-7409WIBX", +// "Secret": "be0a4b88-cd80-4509-b9b9-865205d0d3d8" +// } +// }, "JinkoOptions": { "Jip": { - "BaseUrl": "http://172.16.202.34:8000", - "Key": "FACE-7409WIBX", - "Secret": "be0a4b88-cd80-4509-b9b9-865205d0d3d8" + "BaseUrl": "http://jip.jinkosolar.com", + "Key": "FACE-CUOJG9N7", + "Secret": "130c2f2d-03a0-4720-8e25-538ffac7a7cb" } - } + }, }