From 0041e3ac29ddbe55e6f2a5cc183153130eb65876 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Tue, 11 Jun 2024 16:46:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PeisHttpApiHostModule.cs | 5 + ...tElectrocardiogramResultInterfaceWorker.cs | 92 +++++++++++++++++++ ...yncPatientRegisterReportInterfaceWorker.cs | 91 ++++++++++++++++++ 3 files changed, 188 insertions(+) create mode 100644 src/Shentun.Peis.HttpApi.Host/Schedulers/ImportElectrocardiogramResultInterfaceWorker.cs create mode 100644 src/Shentun.Peis.HttpApi.Host/Schedulers/SyncPatientRegisterReportInterfaceWorker.cs diff --git a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs index 0f212b4..672ccbc 100644 --- a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs +++ b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs @@ -644,6 +644,11 @@ public class PeisHttpApiHostModule : AbpModule { RecurringJob.AddOrUpdate(thirdInterfaceDto.DisplayName, o => o.DoWork(thirdInterfaceDto.Id), corn, TimeZoneInfo.Local); } + else if (thirdInterfaceDto.ThirdInterfaceType == "08") + { + //心电图 + RecurringJob.AddOrUpdate(thirdInterfaceDto.DisplayName, o => o.DoWork(thirdInterfaceDto.Id), corn, TimeZoneInfo.Local); + } } } diff --git a/src/Shentun.Peis.HttpApi.Host/Schedulers/ImportElectrocardiogramResultInterfaceWorker.cs b/src/Shentun.Peis.HttpApi.Host/Schedulers/ImportElectrocardiogramResultInterfaceWorker.cs new file mode 100644 index 0000000..0946c00 --- /dev/null +++ b/src/Shentun.Peis.HttpApi.Host/Schedulers/ImportElectrocardiogramResultInterfaceWorker.cs @@ -0,0 +1,92 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using Shentun.Peis.ThirdInterfaces; +using Shentun.Utilities; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Shentun.Peis.Schedulers +{ + public interface IImportElectrocardiogramResultInterfaceWorker + { + public void DoWork(Guid interfaceId); + public void DoWork(); + } + + public class ImportElectrocardiogramResultInterfaceWorker : ThirdInterfaceWorkerBase, IImportElectrocardiogramResultInterfaceWorker + { + + private static long i; + private static bool _isRunning = false; + private static readonly object lockObject = new object(); + public virtual void DoWork(Guid interfaceId) + { + if (_isRunning) return; + //lock (lockObject) + //{ + _isRunning = true; + try + { + //Logger.LogInformation("Executed" + GetType().Name + "..!"); + var appServiceHelper = new AppServiceHelper(); + //appServiceHelper.Login(); + var thirdInterfaceDtos = appServiceHelper.CallAppService>("api/app/ThirdInterface/GetList", null); + var thirdInterfaceDto = thirdInterfaceDtos.Where(o => o.Id == interfaceId).FirstOrDefault(); + if (thirdInterfaceDto == null) + { + _isRunning = false; + return; + } + if (thirdInterfaceDto.IsActive != 'Y') + { + _isRunning = false; + return; + } + var parmValue = thirdInterfaceDto.ParmValue; + if (!string.IsNullOrWhiteSpace(parmValue)) + { + var configurationBuilder = new ConfigurationBuilder() + .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); + var interfaceConfig = configurationBuilder.Build(); + + var isActive = interfaceConfig.GetSection("Interface").GetSection("Scheduler") + .GetSection("IsActive").Value; + if (isActive != "Y") + { + _isRunning = false; + return; + } + var assemblyName = interfaceConfig.GetSection("Interface").GetSection("AssemblyName").Value; + var className = interfaceConfig.GetSection("Interface").GetSection("ClassName").Value; + var funName = "DoWork"; + object[] classConstructorArg = new object[] { thirdInterfaceDto.Id }; + ReflectionHelper.Invoke(assemblyName, className, classConstructorArg, funName); + } + + + } + catch (Exception ex) + { + _isRunning = false; + Logger.LogError("Executed " + GetType().Name + " Error" + ex.Message); + } + _isRunning = false; + return; + //} + } + + public void DoWork() + { + throw new NotImplementedException(); + } + + public override Task DoWorkAsync(CancellationToken cancellationToken = default) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/Shentun.Peis.HttpApi.Host/Schedulers/SyncPatientRegisterReportInterfaceWorker.cs b/src/Shentun.Peis.HttpApi.Host/Schedulers/SyncPatientRegisterReportInterfaceWorker.cs new file mode 100644 index 0000000..68f8f2d --- /dev/null +++ b/src/Shentun.Peis.HttpApi.Host/Schedulers/SyncPatientRegisterReportInterfaceWorker.cs @@ -0,0 +1,91 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using Shentun.Peis.ThirdInterfaces; +using Shentun.Utilities; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Shentun.Peis.Schedulers +{ + public interface ISyncPatientRegisterReportInterfaceWorker + { + public void DoWork(Guid interfaceId); + public void DoWork(); + } + + public class SyncPatientRegisterReportInterfaceWorker : ThirdInterfaceWorkerBase, ISyncPatientRegisterReportInterfaceWorker + { + private static long i; + private static bool _isRunning = false; + private static readonly object lockObject = new object(); + public virtual void DoWork(Guid interfaceId) + { + if (_isRunning) return; + //lock (lockObject) + //{ + _isRunning = true; + try + { + //Logger.LogInformation("Executed" + GetType().Name + "..!"); + var appServiceHelper = new AppServiceHelper(); + //appServiceHelper.Login(); + var thirdInterfaceDtos = appServiceHelper.CallAppService>("api/app/ThirdInterface/GetList", null); + var thirdInterfaceDto = thirdInterfaceDtos.Where(o => o.Id == interfaceId).FirstOrDefault(); + if (thirdInterfaceDto == null) + { + _isRunning = false; + return; + } + if (thirdInterfaceDto.IsActive != 'Y') + { + _isRunning = false; + return; + } + var parmValue = thirdInterfaceDto.ParmValue; + if (!string.IsNullOrWhiteSpace(parmValue)) + { + var configurationBuilder = new ConfigurationBuilder() + .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); + var interfaceConfig = configurationBuilder.Build(); + + var isActive = interfaceConfig.GetSection("Interface").GetSection("Scheduler") + .GetSection("IsActive").Value; + if (isActive != "Y") + { + _isRunning = false; + return; + } + var assemblyName = interfaceConfig.GetSection("Interface").GetSection("AssemblyName").Value; + var className = interfaceConfig.GetSection("Interface").GetSection("ClassName").Value; + var funName = "DoWork"; + object[] classConstructorArg = new object[] { thirdInterfaceDto.Id }; + ReflectionHelper.Invoke(assemblyName, className, classConstructorArg, funName); + } + + + } + catch (Exception ex) + { + _isRunning = false; + Logger.LogError("Executed " + GetType().Name + " Error" + ex.Message); + } + _isRunning = false; + return; + //} + } + + public void DoWork() + { + throw new NotImplementedException(); + } + + public override Task DoWorkAsync(CancellationToken cancellationToken = default) + { + throw new NotImplementedException(); + } + } +}