From 5467fae884f15c4ae171efe41ab664d906fb3723 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Wed, 26 Jun 2024 16:12:55 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E7=BA=A6=E6=8A=A5=E8=A1=A8=E3=80=81?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=8C=E6=AD=A5=E9=A2=84=E7=99=BB=E8=AE=B0?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WebAppoints/WebAppointPlugInsBase.cs | 25 +++++++++++ .../WebAppoints/WebAppointWebPeisPlugIns.cs | 42 +++++++++++++++++++ .../GetAppointStatisticsReportDto.cs | 34 +++++++++++++++ .../CustomerReports/CustomerOrgInputDto.cs | 40 ++++++++++++++++++ .../SyncPatientRegisterReportInputDto.cs | 3 +- .../AppointPatientRegisterAppService.cs | 39 +++++++++++++++-- ...yncPatientRegisterReportInterfaceWorker.cs | 35 ++++++++++++++-- 7 files changed, 209 insertions(+), 9 deletions(-) create mode 100644 src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GetAppointStatisticsReportDto.cs create mode 100644 src/Shentun.Peis.Application.Contracts/CustomerReports/CustomerOrgInputDto.cs diff --git a/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointPlugInsBase.cs b/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointPlugInsBase.cs index 608c278f..474d2ac7 100644 --- a/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointPlugInsBase.cs +++ b/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointPlugInsBase.cs @@ -2,6 +2,7 @@ using Npgsql; using Shentun.Peis.AppointPatientRegisters; using Shentun.Peis.AppointRegisterAsbitems; +using Shentun.Peis.CustomerReports; using Shentun.Peis.TransToWebPeiss; using System; using System.Collections.Generic; @@ -58,5 +59,29 @@ namespace Shentun.Peis.PlugIns.WebAppoints { throw new NotImplementedException(); } + + + + /// + /// 获取需要同步到web的预登记人员ID + /// + /// + /// + /// + public virtual async Task> GetSyncPreRegistrationPatientRegisterIds(SyncPatientRegisterReportInputDto input) + { + throw new NotImplementedException(); + } + + /// + /// 获取预约统计报表 + /// + /// + /// + /// + public virtual async Task> GetAppointStatisticsReportAsync(List input) + { + throw new NotImplementedException(); + } } } diff --git a/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointWebPeisPlugIns.cs b/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointWebPeisPlugIns.cs index 3da800e4..270f2c74 100644 --- a/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointWebPeisPlugIns.cs +++ b/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointWebPeisPlugIns.cs @@ -7,6 +7,7 @@ using Newtonsoft.Json.Linq; using Npgsql; using Shentun.Peis.AppointPatientRegisters; using Shentun.Peis.AppointRegisterAsbitems; +using Shentun.Peis.CustomerReports; using Shentun.Peis.Enums; using Shentun.Peis.PlugIns.ColumnReferences; using Shentun.Peis.TransToWebPeiss; @@ -30,6 +31,7 @@ namespace Shentun.Peis.PlugIns.WebAppoints private string _webPeisGetAppointPatientRegisterListByFilterUrl; private string _webPeisGetAppointRegisterAsbitemListByIdUrl; private string _webPeisGetByPatientRegisterIdUrl; + private string _webPeisGetAppointStatisticsReportUrl; private Guid _medicalCenterId; public WebAppointWebPeisPlugIns(Guid thirdInterfaceId) : base(thirdInterfaceId) { @@ -48,6 +50,7 @@ namespace Shentun.Peis.PlugIns.WebAppoints _webPeisGetAppointPatientRegisterListByFilterUrl = InterfaceConfig.GetSection("Interface").GetSection("GetAppointPatientRegisterListByFilterUrl").Value; _webPeisGetAppointRegisterAsbitemListByIdUrl = InterfaceConfig.GetSection("Interface").GetSection("GetAppointRegisterAsbitemListByIdUrl").Value; _webPeisGetByPatientRegisterIdUrl = InterfaceConfig.GetSection("Interface").GetSection("GetByPatientRegisterIdUrl").Value; + _webPeisGetAppointStatisticsReportUrl = InterfaceConfig.GetSection("Interface").GetSection("GetAppointStatisticsReportUrl").Value; } /// /// 获取预约人员列表 @@ -103,6 +106,7 @@ namespace Shentun.Peis.PlugIns.WebAppoints (_webPeisGetByPatientRegisterIdUrl, webAppointPatientRegisterIdInput); return appointPatientRegisterDto; } + /// /// 获取需要同步到web的人员ID /// @@ -126,6 +130,44 @@ namespace Shentun.Peis.PlugIns.WebAppoints } } + /// + /// 获取需要同步到web的预登记人员ID + /// + /// + /// + public override async Task> GetSyncPreRegistrationPatientRegisterIds(SyncPatientRegisterReportInputDto input) + { + using (DbConnection conn = new NpgsqlConnection(AppConnctionStr)) + { + string sql; + sql = @" + SELECT + id + from patient_register + where summary_date >= @HandDate and + complete_flag = @CompleteFlag + "; + var patientRegisterIds = (await conn.QueryAsync(sql, + new { HandDate = DateTime.Now.Date.AddDays(-input.QueryDays), CompleteFlag = PatientRegisterCompleteFlag.PreRegistration })).ToList(); + return patientRegisterIds; + } + } + + + /// + /// 获取预约统计报表 + /// + /// + /// + /// + public override async Task> GetAppointStatisticsReportAsync(List input) + { + var appointStatisticsReportListDto = await CallWePeisAppServiceAsync, + List> + (_webPeisGetAppointStatisticsReportUrl, input); + return appointStatisticsReportListDto; + } + public async virtual Task> LoginWebPeisAsync() { if (string.IsNullOrWhiteSpace(_webPeisUser)) diff --git a/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GetAppointStatisticsReportDto.cs b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GetAppointStatisticsReportDto.cs new file mode 100644 index 00000000..b7ba2b20 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GetAppointStatisticsReportDto.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.AppointPatientRegisters +{ + public class GetAppointStatisticsReportDto + { + /// + /// 单位名称 + /// + public string CustomerOrgName { get; set; } + + /// + /// 登记人数 备单人数 + /// + public int RegisterCount { get; set; } + + /// + /// 预约人数 + /// + public int AppointCount { get; set; } + + /// + /// 未预约人数 + /// + public int UnAppointCount { get; set; } + + /// + /// 已开始检查人数 + /// + public int CheckCount { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/CustomerReports/CustomerOrgInputDto.cs b/src/Shentun.Peis.Application.Contracts/CustomerReports/CustomerOrgInputDto.cs new file mode 100644 index 00000000..3855e35c --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/CustomerReports/CustomerOrgInputDto.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.CustomerReports +{ + public class CustomerOrgInputDto + { + /// + /// 单位ID 需要包含查出子级ID + /// + public Guid CustomerOrgId { get; set; } + + /// + /// 单位体检次数ID + /// + public Guid CustomerOrgRegisterId { get; set; } + + /// + /// + /// + public List CustomerOrgGroupId { get; set; } = new List(); + + /// + /// 日期类型(1、登记日期 2、体检日期 3、总检日期) + /// + public char DateType { get; set; } + + /// + /// 开始日期 + /// + public string StartDate { get; set; } + + + /// + /// 结束日期 + /// + public string EndDate { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/TransToWebPeiss/SyncPatientRegisterReportInputDto.cs b/src/Shentun.Peis.Application.Contracts/TransToWebPeiss/SyncPatientRegisterReportInputDto.cs index 20d84072..24a8534c 100644 --- a/src/Shentun.Peis.Application.Contracts/TransToWebPeiss/SyncPatientRegisterReportInputDto.cs +++ b/src/Shentun.Peis.Application.Contracts/TransToWebPeiss/SyncPatientRegisterReportInputDto.cs @@ -8,7 +8,6 @@ namespace Shentun.Peis.TransToWebPeiss { //int QueryDays, string reportApiBaseAddress, string reportApiUrl public int QueryDays { get; set; } - public string ReportApiBaseAddress { get; set; } - public string ReportApiUrl { get; set; } + } } diff --git a/src/Shentun.Peis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs b/src/Shentun.Peis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs index d29515b0..8089ee81 100644 --- a/src/Shentun.Peis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs +++ b/src/Shentun.Peis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using NUglify.JavaScript.Syntax; using Shentun.Peis.AppointRegisterAsbitems; +using Shentun.Peis.CustomerReports; using Shentun.Peis.Enums; using Shentun.Peis.Models; using Shentun.Peis.PatientRegisters; @@ -24,9 +25,9 @@ namespace Shentun.Peis.AppointPatientRegisters [Authorize] public class AppointPatientRegisterAppService : ApplicationService { - private readonly IRepository _thirdInterfaceRepository; + private readonly IRepository _thirdInterfaceRepository; - public AppointPatientRegisterAppService(IRepository thirdInterfaceRepository) + public AppointPatientRegisterAppService(IRepository thirdInterfaceRepository) { _thirdInterfaceRepository = thirdInterfaceRepository; } @@ -40,11 +41,11 @@ namespace Shentun.Peis.AppointPatientRegisters public async Task> GetListByFilterAsync(AppointPatientRegisterInputDto input) { var thirdInterface = await _thirdInterfaceRepository.GetAsync(input.ThirdInterFaceId); - if(thirdInterface.IsActive != 'Y') + if (thirdInterface.IsActive != 'Y') { throw new UserFriendlyException("该接口已禁用"); } - + var appointPatientRegisterPlugInsInputDto = new AppointPatientRegisterInputDto() { ThirdInterFaceId = input.ThirdInterFaceId, @@ -123,5 +124,35 @@ namespace Shentun.Peis.AppointPatientRegisters return pluginsOut; } + + + /// + /// 获取预约统计报表 + /// + /// + [HttpPost("api/app/AppointPatientRegister/GetAppointStatisticsReport")] + public async Task> GetAppointStatisticsReportAsync(List input) + { + + var thirdInterface = await _thirdInterfaceRepository.FirstOrDefaultAsync(f => f.ThirdInterfaceType == ThirdInterfaceTypeFlag.WebAppoint); + if (thirdInterface.IsActive != 'Y') + { + throw new UserFriendlyException("该接口已禁用"); + } + + + object[] objects = [input]; + var parmValue = thirdInterface.ParmValue; + var configurationBuilder = new ConfigurationBuilder() + .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); + var config = configurationBuilder.Build(); + var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value; + var className = config.GetSection("Interface").GetSection("ClassName").Value; + + var pluginsOut = await Utilities.ReflectionHelper.InvokeAsync>(assemblyName, + className, [thirdInterface.Id], "GetAppointStatisticsReportAsync", objects); + return pluginsOut; + + } } } diff --git a/src/Shentun.Peis.HttpApi.Host/Schedulers/SyncPatientRegisterReportInterfaceWorker.cs b/src/Shentun.Peis.HttpApi.Host/Schedulers/SyncPatientRegisterReportInterfaceWorker.cs index 18125e88..f50a7dbc 100644 --- a/src/Shentun.Peis.HttpApi.Host/Schedulers/SyncPatientRegisterReportInterfaceWorker.cs +++ b/src/Shentun.Peis.HttpApi.Host/Schedulers/SyncPatientRegisterReportInterfaceWorker.cs @@ -112,6 +112,8 @@ namespace Shentun.Peis.Schedulers var QueryDays = Convert.ToInt32(interfaceConfig.GetSection("Interface").GetSection("Scheduler") .GetSection("QueryDays").Value); + + //获取报告地址 var reportApiBaseAddress = interfaceConfig.GetSection("Interface").GetSection("ReportApiBaseAddress").Value; var reportApiUrl = interfaceConfig.GetSection("Interface").GetSection("ReportApiUrl").Value; @@ -119,9 +121,7 @@ namespace Shentun.Peis.Schedulers SyncPatientRegisterReportInputDto input = new SyncPatientRegisterReportInputDto { - QueryDays = QueryDays, - ReportApiBaseAddress = reportApiBaseAddress, - ReportApiUrl = reportApiUrl + QueryDays = QueryDays }; @@ -132,6 +132,35 @@ namespace Shentun.Peis.Schedulers object[] objects = [input]; var pluginsOut = ReflectionHelper.InvokeAsync>(assemblyName, className, classConstructorArg, funName, objects).Result; + #region 同步备单数据 + + var preRegistrationFunName = "GetSyncPreRegistrationPatientRegisterIds"; + var preRegistrationPluginsOut = ReflectionHelper.InvokeAsync>(assemblyName, className, classConstructorArg, preRegistrationFunName, objects).Result; + + if (preRegistrationPluginsOut.Any()) + { + + foreach (var item in pluginsOut) + { + + PatientRegisterIdInputDto patientRegisterIdDto = new PatientRegisterIdInputDto + { + PatientRegisterId = item.Id + }; + + appServiceHelper.CallAppService("api/app/TransToWebPeis/TransPatientRegisterByPatientRegisterId", patientRegisterIdDto); + } + + + Logger.LogError("同步预登记数据成功"); + } + + + #endregion + + + + //需要同步报告的数据 if (pluginsOut.Any()) { // pluginsOut = pluginsOut.Take(10).ToList();