From f4d8708f849c6122a78874b54033af2e45f7f4a7 Mon Sep 17 00:00:00 2001 From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com> Date: Mon, 6 May 2024 16:11:52 +0800 Subject: [PATCH] LIS --- .../ChargeRequestPlugInsGem.cs | 10 +- .../LisResultImportPlugInsBase.cs | 52 ++++++++++ .../PatientRegisterForLisRequest.cs | 13 +++ .../RegisterCheckAsbitemAppService.cs | 99 ++++++++++++------- .../ChargeRequests/ChargeRequestManager.cs | 6 +- .../LisRequests/LisRequestManager.cs | 6 +- .../PatientRegisterManager.cs | 6 +- .../RegisterChecks/RegisterCheckManager.cs | 6 +- .../PeisHttpApiHostModule.cs | 8 +- .../ChargeRequestInterfaceQueryWorker.cs | 6 +- .../ImportLisResultInterfaceWorker.cs | 85 ++++++++++++++++ .../Schedulers/ThirdInterfaceWorkerBase.cs | 75 ++++++++++++++ .../PrintReportAppServiceTest.cs | 2 +- 13 files changed, 319 insertions(+), 55 deletions(-) create mode 100644 src/Shentun.ColumnReferencePlugIns/PatientRegisterForLisRequest.cs create mode 100644 src/Shentun.Peis.HttpApi.Host/Schedulers/ImportLisResultInterfaceWorker.cs create mode 100644 src/Shentun.Peis.HttpApi.Host/Schedulers/ThirdInterfaceWorkerBase.cs diff --git a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ChargeRequestPlugInsGem.cs b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ChargeRequestPlugInsGem.cs index 20ff888..dc23c65 100644 --- a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ChargeRequestPlugInsGem.cs +++ b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ChargeRequestPlugInsGem.cs @@ -187,7 +187,15 @@ namespace Shentun.Peis.PlugIns.Gem foreach (var chargeRequest in chargeRequests) { - SyncChargeRequestFlagFromInterfaceAsync(chargeRequest.ChargeRequestId); + try + { + SyncChargeRequestFlagFromInterfaceAsync(chargeRequest.ChargeRequestId); + } + catch(Exception ex) + { + + } + } return base.DoWork(); } diff --git a/src/Shentun.ColumnReferencePlugIns/LisResultImportPlugInsBase.cs b/src/Shentun.ColumnReferencePlugIns/LisResultImportPlugInsBase.cs index 6c4984f..9ace07e 100644 --- a/src/Shentun.ColumnReferencePlugIns/LisResultImportPlugInsBase.cs +++ b/src/Shentun.ColumnReferencePlugIns/LisResultImportPlugInsBase.cs @@ -53,6 +53,58 @@ namespace Shentun.Peis.PlugIns } } + public async Task> GetRequestPatientRegisters(int days) + { + using (DbConnection conn = new NpgsqlConnection(AppConnctionStr)) + { + string sql; + var startDate = DateTime.Now.Date.AddDays(-days); + sql = @" SELECT register_check.patient_register_id + from lis_request ,register_check_asbitem,register_check +WHERE lis_request.id = register_check_asbitem.lis_request_id and +register_check_asbitem.register_check_id = register_check.id and +lis_request.creation_time > @StartDate +ORDER BY lis_request.creation_time + "; + var satientRegisterForLisRequests = (await conn.QueryAsync(sql, + new { StartDate = startDate })).ToList(); + + return satientRegisterForLisRequests; + } + + } + + public override Task DoWork() + { + var queryDaysStr = InterfaceConfig.GetSection("Scheduler").GetSection("QueryDays").Value; + if (string.IsNullOrWhiteSpace(queryDaysStr)) + { + queryDaysStr = "1"; + } + if (!int.TryParse(queryDaysStr, out int days)) + { + days = 1; + } + var patientRegisters = GetRequestPatientRegisters(days).Result; + + foreach (var patientRegister in patientRegisters) + { + try + { + ImportResultAsync(new LisResultImportPlugInsInput() + { + PatientRegisterId = patientRegister.PatientRegisterId, + }); + } + catch (Exception ex) + { + + } + + } + return Task.CompletedTask; + } + protected async Task LoginAsync() { var relult = await LoginAsync(AppLisUser, AppLisPassword); diff --git a/src/Shentun.ColumnReferencePlugIns/PatientRegisterForLisRequest.cs b/src/Shentun.ColumnReferencePlugIns/PatientRegisterForLisRequest.cs new file mode 100644 index 0000000..34d7727 --- /dev/null +++ b/src/Shentun.ColumnReferencePlugIns/PatientRegisterForLisRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Shentun.Peis.PlugIns +{ + public class PatientRegisterForLisRequest + { + public Guid PatientRegisterId { get; set; } + } +} diff --git a/src/Shentun.Peis.Application/RegisterCheckAsbitems/RegisterCheckAsbitemAppService.cs b/src/Shentun.Peis.Application/RegisterCheckAsbitems/RegisterCheckAsbitemAppService.cs index 689240d..55ada24 100644 --- a/src/Shentun.Peis.Application/RegisterCheckAsbitems/RegisterCheckAsbitemAppService.cs +++ b/src/Shentun.Peis.Application/RegisterCheckAsbitems/RegisterCheckAsbitemAppService.cs @@ -18,6 +18,7 @@ using Shentun.Peis.Sexs; using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Dynamic.Core; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Application.Services; @@ -53,6 +54,7 @@ namespace Shentun.Peis.RegisterAsbitems private readonly IRepository _customerOrgGroupDetailRepository; private readonly IRepository _medicalPackageDetailRepository; private readonly IRepository _customerOrgRepository; + private readonly IRepository _chargeRequestRepository; private readonly DeviceTypeManager _deviceTypeManager; private readonly CustomerOrgManager _customerOrgManager; private readonly ForSexManager _forSexManager; @@ -84,7 +86,8 @@ namespace Shentun.Peis.RegisterAsbitems ForSexManager forSexManager, RegisterCheckAsbitemManager registerAsbitemManager, CardBillManager cardBillManager, - CacheService cacheService) + CacheService cacheService, + IRepository chargeRequestRepository) { this._userRepository = userRepository; this._registerCheckAsbitemRepository = registerAsbitemRepository; @@ -111,6 +114,7 @@ namespace Shentun.Peis.RegisterAsbitems _cacheService = cacheService; _customerOrgGroupDetailRepository = customerOrgGroupDetailRepository; _medicalPackageDetailRepository = medicalPackageDetailRepository; + _chargeRequestRepository = chargeRequestRepository; } @@ -340,42 +344,71 @@ namespace Shentun.Peis.RegisterAsbitems public async Task> GetCanChargeAsbitemsByPatientRegisterIdAsync(PatientRegisterIdInputDto input) { var patientReigister = await _patientRegisterRepository.GetAsync(input.PatientRegisterId); - var entlist = (await _registerCheckAsbitemRepository.GetQueryableAsync()) - .Include(x => x.Asbitem) - .Include(x => x.Asbitem.ItemType) - .Include(x => x.RegisterCheck) - .Where(m => m.PatientRegisterId == input.PatientRegisterId && - m.IsCharge == 'N' && m.PayTypeFlag == PayTypeFlag.PersonPay) - .ToList().OrderByDescending(o => o.GroupPackageId).ThenBy(o => o.Asbitem.DisplayOrder); - - + var entlist = (from registerCheck in await _registerCheckRepository.GetQueryableAsync() + join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() + on registerCheck.Id equals registerCheckAsbitem.RegisterCheckId + join asbitem in await _asbitemRepository.GetQueryableAsync() + on registerCheckAsbitem.AsbitemId equals asbitem.Id + join itemType in await _itemTypeRepository.GetQueryableAsync() + on asbitem.ItemTypeId equals itemType.Id + where registerCheck.PatientRegisterId == input.PatientRegisterId + && registerCheckAsbitem.IsCharge == 'N' + && registerCheckAsbitem.PayTypeFlag == PayTypeFlag.PersonPay + select new + { + RegisterCheck = registerCheck, + RegisterCheckAsbitem = registerCheckAsbitem, + Asbitem = asbitem, + ItemType = itemType + }).OrderBy(o => o.ItemType.DisplayOrder) + .OrderBy(o => o.Asbitem.DisplayOrder) + .ToList(); + + var chargeRequests = ( + from registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() + join chargeRequest in await _chargeRequestRepository.GetQueryableAsync() + on registerCheckAsbitem.ChargeRequestId equals chargeRequest.Id + where chargeRequest.PatientRegisterId == input.PatientRegisterId + && (chargeRequest.ChargeRequestFlag == ChargeRequestFlag.ChargeRequest + || chargeRequest.ChargeRequestFlag == ChargeRequestFlag.CancelChargeRequest + || chargeRequest.ChargeRequestFlag == ChargeRequestFlag.RefundRequest) + select new + { + + RegisterCheckAsbitem = registerCheckAsbitem, + ChargeRequest = chargeRequest, + }) + .ToList(); + + entlist = entlist.Where(o=> !chargeRequests.Select(o=>o.ChargeRequest.Id).ToList() + .Contains((Guid)(o.RegisterCheckAsbitem.ChargeRequestId==null?Guid.Empty: o.RegisterCheckAsbitem.ChargeRequestId))).ToList(); var entdto = entlist.Select(s => new RegisterCheckAsbitemOrAsbitemDto { - RegisterCheckAsbitemId = s.Id, - Discount = s.StandardPrice == 0 ? 100 : Math.Round(Convert.ToDecimal(s.ChargePrice * 100 / s.StandardPrice), 2), + RegisterCheckAsbitemId = s.RegisterCheckAsbitem.Id, + Discount = s.RegisterCheckAsbitem.StandardPrice == 0 ? 100 : Math.Round(Convert.ToDecimal(s.RegisterCheckAsbitem.ChargePrice * 100 / s.RegisterCheckAsbitem.StandardPrice), 2), IsLock = s.RegisterCheck.IsLock, - CreationTime = s.CreationTime, - CreatorId = s.CreatorId, - Id = s.Id, - LastModificationTime = s.LastModificationTime, - LastModifierId = s.LastModifierId, - Amount = s.Amount, - AsbitemId = s.AsbitemId, + CreationTime = s.RegisterCheckAsbitem.CreationTime, + CreatorId = s.RegisterCheckAsbitem.CreatorId, + Id = s.RegisterCheckAsbitem.Id, + LastModificationTime = s.RegisterCheckAsbitem.LastModificationTime, + LastModifierId = s.RegisterCheckAsbitem.LastModifierId, + Amount = s.RegisterCheckAsbitem.Amount, + AsbitemId = s.RegisterCheckAsbitem.AsbitemId, AsbitemName = s.Asbitem.DisplayName, - ChargePrice = s.ChargePrice, + ChargePrice = s.RegisterCheckAsbitem.ChargePrice, IsBelongGroupPackage = 'N', //GroupPackageId = s.GroupPackageId, CheckCompleteFlag = s.RegisterCheck.CompleteFlag, DeviceTypeName = s.Asbitem.DeviceTypeId != null ? _cacheService.GetDeviceTypeNameAsync(s.Asbitem.DeviceTypeId.Value).Result : "", - IsCharge = s.IsCharge, + IsCharge = s.RegisterCheckAsbitem.IsCharge, ItemTypeName = s.Asbitem.ItemType.DisplayName, - LisRequestId = s.LisRequestId, - PatientRegisterId = s.PatientRegisterId, - PayTypeFlag = s.PayTypeFlag, + LisRequestId = s.RegisterCheckAsbitem.LisRequestId, + PatientRegisterId = s.RegisterCheck.PatientRegisterId, + PayTypeFlag = s.RegisterCheckAsbitem.PayTypeFlag, SexName = _cacheService.GetForSexNameAsync(s.Asbitem.ForSexId).Result, - StandardPrice = s.StandardPrice, - CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result, - LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result + StandardPrice = s.RegisterCheckAsbitem.StandardPrice, + CreatorName = _cacheService.GetSurnameAsync(s.RegisterCheckAsbitem.CreatorId).Result, + LastModifierName = _cacheService.GetSurnameAsync(s.RegisterCheckAsbitem.LastModifierId).Result }).ToList(); //设置GroupPackageId @@ -897,7 +930,7 @@ namespace Shentun.Peis.RegisterAsbitems throw new UserFriendlyException("input参数不能为空"); } await _registerAsbitemManager.MergeRegisterAsbitemAsync(input.RegisterCheckIds); - + } @@ -916,7 +949,7 @@ namespace Shentun.Peis.RegisterAsbitems throw new UserFriendlyException("input参数不能为空"); } await _registerAsbitemManager.CancelMergeRegisterAsbitemAsync(input.RegisterCheckIds); - + } @@ -950,7 +983,7 @@ namespace Shentun.Peis.RegisterAsbitems from ae in ee.DefaultIfEmpty() where a.PatientRegisterId == PatientRegisterId orderby c.DisplayOrder ascending, ad.CreationTime ascending, b.DisplayOrder ascending - select new + select new { RegisterAsbitemId = a.Id, AsbitemName = b.DisplayName, @@ -963,15 +996,15 @@ namespace Shentun.Peis.RegisterAsbitems }).ToList(); var getMergeRegisterCheckAsbitemListDtsos = new List(); - var registerCheckIds = entlist.Select(o=>o.RegisterCheckId).Distinct().ToList(); - foreach(var registerCheckId in registerCheckIds) + var registerCheckIds = entlist.Select(o => o.RegisterCheckId).Distinct().ToList(); + foreach (var registerCheckId in registerCheckIds) { var getMergeRegisterCheckAsbitemListDto = new GetMergeRegisterCheckAsbitemListDto() { RegisterCheckId = registerCheckId }; - var ents = entlist.Where(o=>o.RegisterCheckId == registerCheckId).ToList(); + var ents = entlist.Where(o => o.RegisterCheckId == registerCheckId).ToList(); getMergeRegisterCheckAsbitemListDto.MergerAsbitemName = ents[0].MergerAsbitemName; foreach (var item in ents) { diff --git a/src/Shentun.Peis.Domain/ChargeRequests/ChargeRequestManager.cs b/src/Shentun.Peis.Domain/ChargeRequests/ChargeRequestManager.cs index 45d3c05..dc61721 100644 --- a/src/Shentun.Peis.Domain/ChargeRequests/ChargeRequestManager.cs +++ b/src/Shentun.Peis.Domain/ChargeRequests/ChargeRequestManager.cs @@ -183,10 +183,8 @@ namespace Shentun.Peis.ChargeRequests //新的日期 为1 maxnum primarykeyBuilderEnt.DateString = date; } - else - { - maxnum = (Convert.ToInt32(primarykeyBuilderEnt.SerialNo) + 1).ToString(); - } + + maxnum = (Convert.ToInt32(primarykeyBuilderEnt.SerialNo) + 1).ToString(); primarykeyBuilderEnt.SerialNo = maxnum; //更新新的序列号 LisRequestNo = request_no_rule_prefix + date + maxnum.PadLeft(Convert.ToInt32(request_no_rule_tail_len), '0'); diff --git a/src/Shentun.Peis.Domain/LisRequests/LisRequestManager.cs b/src/Shentun.Peis.Domain/LisRequests/LisRequestManager.cs index d6d8ec2..3ed87fb 100644 --- a/src/Shentun.Peis.Domain/LisRequests/LisRequestManager.cs +++ b/src/Shentun.Peis.Domain/LisRequests/LisRequestManager.cs @@ -425,10 +425,8 @@ namespace Shentun.Peis.LisRequests //新的日期 为1 maxnum primarykeyBuilderEnt.DateString = date; } - else - { - maxnum = (Convert.ToInt32(primarykeyBuilderEnt.SerialNo) + 1).ToString(); - } + + maxnum = (Convert.ToInt32(primarykeyBuilderEnt.SerialNo) + 1).ToString(); primarykeyBuilderEnt.SerialNo = maxnum; //更新新的序列号 LisRequestNo = lis_request_no_rule_prefix + date + maxnum.PadLeft(Convert.ToInt32(lis_request_no_rule_tail_len), '0'); diff --git a/src/Shentun.Peis.Domain/PatientRegisters/PatientRegisterManager.cs b/src/Shentun.Peis.Domain/PatientRegisters/PatientRegisterManager.cs index 18c152f..b3b7e57 100644 --- a/src/Shentun.Peis.Domain/PatientRegisters/PatientRegisterManager.cs +++ b/src/Shentun.Peis.Domain/PatientRegisters/PatientRegisterManager.cs @@ -815,10 +815,8 @@ namespace Shentun.Peis.PatientRegisters //新的日期 为1 maxnum primarykeyBuilderEnt.DateString = date; } - else - { - maxnum = (Convert.ToInt32(primarykeyBuilderEnt.SerialNo) + 1).ToString(); - } + + maxnum = (Convert.ToInt32(primarykeyBuilderEnt.SerialNo) + 1).ToString(); primarykeyBuilderEnt.SerialNo = maxnum; //更新新的序列号 PatientRegisterNo = patient_register_no_rule_prefix + date + maxnum.PadLeft(Convert.ToInt32(patient_register_no_rule_tail_len), '0'); diff --git a/src/Shentun.Peis.Domain/RegisterChecks/RegisterCheckManager.cs b/src/Shentun.Peis.Domain/RegisterChecks/RegisterCheckManager.cs index 785bf7a..09938ee 100644 --- a/src/Shentun.Peis.Domain/RegisterChecks/RegisterCheckManager.cs +++ b/src/Shentun.Peis.Domain/RegisterChecks/RegisterCheckManager.cs @@ -490,10 +490,8 @@ namespace Shentun.Peis.RegisterChecks //新的日期 为1 maxnum primarykeyBuilderEnt.DateString = date; } - else - { - maxnum = (Convert.ToInt32(primarykeyBuilderEnt.SerialNo) + 1).ToString(); - } + + maxnum = (Convert.ToInt32(primarykeyBuilderEnt.SerialNo) + 1).ToString(); primarykeyBuilderEnt.SerialNo = maxnum; //更新新的序列号 CheckRequestNo = check_request_no_rule_prefix + date + maxnum.PadLeft(Convert.ToInt32(check_request_no_rule_tail_len), '0'); diff --git a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs index 98599ae..4ea64a6 100644 --- a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs +++ b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs @@ -559,7 +559,7 @@ public class PeisHttpApiHostModule : AbpModule app.UseConfiguredEndpoints(); //任务计划 - //await StartScheduler(context); + await StartScheduler(context); } private async Task StartScheduler(ApplicationInitializationContext context) @@ -598,7 +598,11 @@ public class PeisHttpApiHostModule : AbpModule { if(thirdInterfaceDto.ThirdInterfaceType == "02") { - RecurringJob.AddOrUpdate("收费接口", o => o.DoWork(), corn, TimeZoneInfo.Local); + RecurringJob.AddOrUpdate("收费接口", o => o.DoWork(thirdInterfaceDto.Id), corn, TimeZoneInfo.Local); + } + else if(thirdInterfaceDto.ThirdInterfaceType == "03") + { + RecurringJob.AddOrUpdate("导入检验结果接口", o => o.DoWork(thirdInterfaceDto.Id), corn, TimeZoneInfo.Local); } } } diff --git a/src/Shentun.Peis.HttpApi.Host/Schedulers/ChargeRequestInterfaceQueryWorker.cs b/src/Shentun.Peis.HttpApi.Host/Schedulers/ChargeRequestInterfaceQueryWorker.cs index 3bef515..84877ce 100644 --- a/src/Shentun.Peis.HttpApi.Host/Schedulers/ChargeRequestInterfaceQueryWorker.cs +++ b/src/Shentun.Peis.HttpApi.Host/Schedulers/ChargeRequestInterfaceQueryWorker.cs @@ -17,7 +17,7 @@ namespace Shentun.Peis.Schedulers { public interface IChargeRequestInterfaceQueryWorker { - public void DoWorkAsync(Guid interfaceId); + public void DoWork(Guid interfaceId); public void DoWork(); } public class ChargeRequestInterfaceQueryWorker : HangfireBackgroundWorkerBase, IChargeRequestInterfaceQueryWorker @@ -40,7 +40,7 @@ namespace Shentun.Peis.Schedulers Logger.LogInformation("Executed ChargeRequestInterfaceQueryWorker..!"); return Task.CompletedTask; } - public void DoWorkAsync(Guid interfaceId) + public void DoWork(Guid interfaceId) { if (_isRunning) return; lock (lockObject) @@ -55,6 +55,7 @@ namespace Shentun.Peis.Schedulers var thirdInterfaceDto = thirdInterFaceForHostOutDto.Data.Where(o => o.Id == interfaceId).FirstOrDefault(); if (thirdInterfaceDto == null) { + _isRunning = false; return ; } @@ -69,6 +70,7 @@ namespace Shentun.Peis.Schedulers .GetSection("IsActive").Value; if (isActive != "Y") { + _isRunning = false; return ; } var assemblyName = interfaceConfig.GetSection("Interface").GetSection("AssemblyName").Value; diff --git a/src/Shentun.Peis.HttpApi.Host/Schedulers/ImportLisResultInterfaceWorker.cs b/src/Shentun.Peis.HttpApi.Host/Schedulers/ImportLisResultInterfaceWorker.cs new file mode 100644 index 0000000..7e89b75 --- /dev/null +++ b/src/Shentun.Peis.HttpApi.Host/Schedulers/ImportLisResultInterfaceWorker.cs @@ -0,0 +1,85 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using Shentun.Utilities; +using System; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.BackgroundWorkers.Hangfire; + +namespace Shentun.Peis.Schedulers +{ + public interface IImportLisResultInterfaceWorker + { + public void DoWork(Guid interfaceId); + public void DoWork(); + } + public class ImportLisResultInterfaceWorker : HangfireBackgroundWorkerBase, IImportLisResultInterfaceWorker + { + private string isActive = "N"; + private static long i; + private static bool _isRunning = false; + private static readonly object lockObject = new object(); + public void DoWork(Guid interfaceId) + { + if (_isRunning) return; + lock (lockObject) + { + _isRunning = true; + try + { + Logger.LogInformation("Executed ImportLisResultInterfaceWorker..!"); + var appServiceHelper = new AppServiceHelper(); + appServiceHelper.Login(); + var thirdInterFaceForHostOutDto = appServiceHelper.CallAppService("api/app/ThirdInterface/GetList", null); + var thirdInterfaceDto = thirdInterFaceForHostOutDto.Data.Where(o => o.Id == interfaceId).FirstOrDefault(); + if (thirdInterfaceDto == null) + { + _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(); + + 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[] objects = new object[] { chargeRequestPlugInsInput }; + ReflectionHelper.InvokeAsync(assemblyName, className, parmValue, funName); + } + + + } + catch (Exception ex) + { + Logger.LogError("Executed ImportLisResultInterfaceWorker Error" + ex.Message); + } + _isRunning = false; + return; + } + } + + public void DoWork() + { + throw new System.NotImplementedException(); + } + + public override Task DoWorkAsync(CancellationToken cancellationToken = default) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/Shentun.Peis.HttpApi.Host/Schedulers/ThirdInterfaceWorkerBase.cs b/src/Shentun.Peis.HttpApi.Host/Schedulers/ThirdInterfaceWorkerBase.cs new file mode 100644 index 0000000..b71ee84 --- /dev/null +++ b/src/Shentun.Peis.HttpApi.Host/Schedulers/ThirdInterfaceWorkerBase.cs @@ -0,0 +1,75 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using Shentun.Utilities; +using System; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.BackgroundWorkers.Hangfire; + +namespace Shentun.Peis.Schedulers +{ + public class ThirdInterfaceWorkerBase: HangfireBackgroundWorkerBase + { + private string isActive = "N"; + private static long i; + private static bool _isRunning = false; + private static readonly object lockObject = new object(); + public void DoWork(Guid interfaceId) + { + if (_isRunning) return; + lock (lockObject) + { + _isRunning = true; + try + { + Logger.LogInformation("Executed ImportLisResultInterfaceWorker..!"); + var appServiceHelper = new AppServiceHelper(); + appServiceHelper.Login(); + var thirdInterFaceForHostOutDto = appServiceHelper.CallAppService("api/app/ThirdInterface/GetList", null); + var thirdInterfaceDto = thirdInterFaceForHostOutDto.Data.Where(o => o.Id == interfaceId).FirstOrDefault(); + if (thirdInterfaceDto == null) + { + _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(); + + 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[] objects = new object[] { chargeRequestPlugInsInput }; + ReflectionHelper.InvokeAsync(assemblyName, className, parmValue, funName); + } + + + } + catch (Exception ex) + { + Logger.LogError("Executed ImportLisResultInterfaceWorker Error" + ex.Message); + } + _isRunning = false; + return; + } + } + + public override Task DoWorkAsync(CancellationToken cancellationToken = default) + { + throw new System.NotImplementedException(); + } + } +} diff --git a/test/Shentun.Peis.Application.Tests/PrintReportAppServiceTest.cs b/test/Shentun.Peis.Application.Tests/PrintReportAppServiceTest.cs index 86b1265..8ad3dee 100644 --- a/test/Shentun.Peis.Application.Tests/PrintReportAppServiceTest.cs +++ b/test/Shentun.Peis.Application.Tests/PrintReportAppServiceTest.cs @@ -34,7 +34,7 @@ namespace Shentun.Peis using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true)) { var items = await _appService.GetLisRequestReportByPatientRegisterIdAsync(new PatientRegisterIdInputDto() - { PatientRegisterId = new Guid("3a123c55-06de-4988-691c-448b5af468ff") }); + { PatientRegisterId = new Guid("3a125ed8-991d-4304-5ca9-36edd0485450") }); _output.WriteLine(items.Count().ToString()); foreach (var item in items) {