From 2ff7f0cdcdff4f1114f01d95f576bbcadb27107f Mon Sep 17 00:00:00 2001
From: wxd <123@qq.com>
Date: Wed, 12 Jun 2024 19:06:05 +0800
Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../WebAppoints/SyncPatientRegisterIdsDto.cs | 16 +++
.../WebAppoints/WebAppointPlugInsBase.cs | 12 ++
.../WebAppoints/WebAppointWebPeisPlugIns.cs | 30 +++++
.../SyncPatientRegisterReportInputDto.cs | 14 +++
.../WebApiOutDto.cs | 6 +
.../PrintReports/PrintReportAppService.cs | 4 +-
.../TransToWebPeisAppService.cs | 108 +++++++++++++++++-
.../PeisHttpApiHostModule.cs | 10 +-
...yncPatientRegisterReportInterfaceWorker.cs | 93 ++++++++++++++-
9 files changed, 276 insertions(+), 17 deletions(-)
create mode 100644 src/Shentun.ColumnReferencePlugIns/WebAppoints/SyncPatientRegisterIdsDto.cs
create mode 100644 src/Shentun.Peis.Application.Contracts/TransToWebPeiss/SyncPatientRegisterReportInputDto.cs
diff --git a/src/Shentun.ColumnReferencePlugIns/WebAppoints/SyncPatientRegisterIdsDto.cs b/src/Shentun.ColumnReferencePlugIns/WebAppoints/SyncPatientRegisterIdsDto.cs
new file mode 100644
index 00000000..7b035d75
--- /dev/null
+++ b/src/Shentun.ColumnReferencePlugIns/WebAppoints/SyncPatientRegisterIdsDto.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Shentun.Peis.PlugIns.WebAppoints
+{
+ public class SyncPatientRegisterIdsDto
+ {
+ ///
+ /// 人员登记ID
+ ///
+ public Guid Id { get; set; }
+ }
+}
diff --git a/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointPlugInsBase.cs b/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointPlugInsBase.cs
index a3f1f1b6..cce4c8fe 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.TransToWebPeiss;
using System;
using System.Collections.Generic;
using System.Data.Common;
@@ -40,5 +41,16 @@ namespace Shentun.Peis.PlugIns.WebAppoints
throw new NotImplementedException();
}
+
+ ///
+ /// 获取需要同步到web的人员ID
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task> GetSyncPatientRegisterIds(SyncPatientRegisterReportInputDto input)
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointWebPeisPlugIns.cs b/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointWebPeisPlugIns.cs
index d30b57ca..661b89e7 100644
--- a/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointWebPeisPlugIns.cs
+++ b/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointWebPeisPlugIns.cs
@@ -1,12 +1,18 @@
using Azure.Core;
+using Dapper;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
+using Npgsql;
using Shentun.Peis.AppointPatientRegisters;
using Shentun.Peis.AppointRegisterAsbitems;
+using Shentun.Peis.Enums;
+using Shentun.Peis.PlugIns.ColumnReferences;
+using Shentun.Peis.TransToWebPeiss;
using System;
using System.Collections.Generic;
+using System.Data.Common;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Net.Http.Headers;
@@ -78,6 +84,30 @@ namespace Shentun.Peis.PlugIns.WebAppoints
(_webPeisGetAppointRegisterAsbitemListByIdUrl, webAppointPatientRegisterIdInput);
return appointRegisterAsbitemDtos;
}
+
+ ///
+ /// 获取需要同步到web的人员ID
+ ///
+ ///
+ ///
+ public override async Task> GetSyncPatientRegisterIds(SyncPatientRegisterReportInputDto input)
+ {
+ using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
+ {
+ string sql;
+ sql = @"
+ SELECT
+ id
+ from patient_register
+ where last_modification_time > @HandDate and
+ complete_flag = @CompleteFlag
+ ";
+ var patientRegisterIds = (await conn.QueryAsync(sql,
+ new { HandDate = DateTime.Now.AddDays(-input.QueryDays), CompleteFlag = PatientRegisterCompleteFlag.SumCheck })).ToList();
+ return patientRegisterIds;
+ }
+ }
+
public async virtual Task> LoginWebPeisAsync()
{
if (string.IsNullOrWhiteSpace(_webPeisUser))
diff --git a/src/Shentun.Peis.Application.Contracts/TransToWebPeiss/SyncPatientRegisterReportInputDto.cs b/src/Shentun.Peis.Application.Contracts/TransToWebPeiss/SyncPatientRegisterReportInputDto.cs
new file mode 100644
index 00000000..20d84072
--- /dev/null
+++ b/src/Shentun.Peis.Application.Contracts/TransToWebPeiss/SyncPatientRegisterReportInputDto.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.Peis.TransToWebPeiss
+{
+ public class SyncPatientRegisterReportInputDto
+ {
+ //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.Contracts/WebApiOutDto.cs b/src/Shentun.Peis.Application.Contracts/WebApiOutDto.cs
index 510b5815..f1e3c17d 100644
--- a/src/Shentun.Peis.Application.Contracts/WebApiOutDto.cs
+++ b/src/Shentun.Peis.Application.Contracts/WebApiOutDto.cs
@@ -10,4 +10,10 @@ namespace Shentun.Peis
public string Message { get; set; }
public T? Data { get; set; }
}
+
+ public class WebApiClientOutDto
+ {
+ public int code { get; set; }
+ public string data { get; set; }
+ }
}
diff --git a/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs b/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs
index 2f75b53c..a16e6f17 100644
--- a/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs
+++ b/src/Shentun.Peis.Application/PrintReports/PrintReportAppService.cs
@@ -976,7 +976,7 @@ namespace Shentun.Peis.PrintReports
///
private async Task> GetMedicalReportSummaryDtos(PatientRegister patientRegister)
{
- var sumSummarylist = (await _sumSummaryHeaderRepository.GetDbSetAsync())
+ var sumSummarylist = (await _sumSummaryHeaderRepository.GetQueryableAsync())
.Include(x => x.SumSummaryContents)
.Where(m => m.PatientRegisterId == patientRegister.Id).OrderBy(o => o.DisplayOrder).ToList();
var medicalReportSumSummaryDtos = new List();
@@ -1003,7 +1003,7 @@ namespace Shentun.Peis.PrintReports
///
private async Task> GetMedicalReportSuggestinoDtos(PatientRegister patientRegister)
{
- var sumSuggestionlist = (await _sumSuggestionHeaderRepository.GetDbSetAsync())
+ var sumSuggestionlist = (await _sumSuggestionHeaderRepository.GetQueryableAsync())
.Include(x => x.SumSuggestionContents)
.Where(m => m.PatientRegisterId == patientRegister.Id).OrderBy(o => o.DisplayOrder).ToList();
var medicalReportSumSuggestionDtos = new List();
diff --git a/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs b/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs
index 821420fd..d28023b9 100644
--- a/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs
+++ b/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs
@@ -31,6 +31,8 @@ using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
using Volo.Abp.Uow;
+using Shentun.Peis.PrintReports;
+using System.Threading;
namespace Shentun.Peis.TransToWebPeis
{
@@ -55,6 +57,7 @@ namespace Shentun.Peis.TransToWebPeis
private readonly IRepository _registerCheckRepository;
private readonly IRepository _patientRegisterExterRepository;
private readonly UnitOfWorkManager _unitOfWorkManager;
+ private readonly PrintReportAppService _printReportAppService;
private readonly SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
@@ -80,7 +83,8 @@ namespace Shentun.Peis.TransToWebPeis
IRepository patientRegisterRepository,
IRepository registerCheckRepository,
IRepository patientRegisterExterRepository,
- UnitOfWorkManager unitOfWorkManager)
+ UnitOfWorkManager unitOfWorkManager,
+ PrintReportAppService printReportAppService)
{
_itemTypeRepository = itemTypeRepository;
_logger = logger;
@@ -98,8 +102,9 @@ namespace Shentun.Peis.TransToWebPeis
_registerCheckRepository = registerCheckRepository;
_patientRegisterExterRepository = patientRegisterExterRepository;
_unitOfWorkManager = unitOfWorkManager;
+ _printReportAppService = printReportAppService;
}
-
+
///
@@ -115,11 +120,14 @@ namespace Shentun.Peis.TransToWebPeis
throw new UserFriendlyException("人员不存在");
if (isPatientRegister.CompleteFlag != PatientRegisterCompleteFlag.SumCheck)
throw new UserFriendlyException("人员未总检,无法上传");
+
//同步数据
await TransPatientRegisterByPatientRegisterIdAsync(new PatientRegisterIdInputDto { PatientRegisterId = input.PatientRegisterId });
+
//上传报告
var thirdInterfaces = await _thirdInterfaceRepository.GetListAsync(o => o.ThirdInterfaceType ==
ThirdInterfaceTypeFlag.TranToWebPeis);
+
foreach (var thirdInterface in thirdInterfaces)
{
var parmValue = thirdInterface.ParmValue;
@@ -138,6 +146,7 @@ namespace Shentun.Peis.TransToWebPeis
var patientRegisterEnt = await _patientRegisterRepository.GetAsync(input.PatientRegisterId);
patientRegisterEnt.IsUpload = 'Y';
await _patientRegisterRepository.UpdateAsync(patientRegisterEnt);
+
}
///
@@ -199,6 +208,93 @@ namespace Shentun.Peis.TransToWebPeis
}
}
+ ///
+ /// 导入数据 任务计划用
+ ///
+ ///
+ ///
+ ///
+ [HttpPost("api/app/TransToWebPeis/SyncPatientRegisterReportByPatientRegisterId")]
+ public async Task SyncPatientRegisterReportByPatientRegisterIdAsync(PatientRegisterIdInputDto input)
+ {
+
+ var thirdInterface = await _thirdInterfaceRepository.FirstOrDefaultAsync(f => f.ThirdInterfaceType == ThirdInterfaceTypeFlag.TranToWebPeis);
+ if (thirdInterface.IsActive != 'Y')
+ {
+ throw new UserFriendlyException("该接口已禁用");
+ }
+
+ var parmValue = thirdInterface.ParmValue;
+ var configurationBuilder = new ConfigurationBuilder()
+ .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue)));
+ var config = configurationBuilder.Build();
+ var reportApiBaseAddress = config.GetSection("Interface").GetSection("ReportApiBaseAddress").Value;
+ var reportApiUrl = config.GetSection("Interface").GetSection("ReportApiUrl").Value;
+
+ string reportBase64 = "";
+ #region 获取报告地址
+
+ var printReportData = await _printReportAppService.GetMedicalReportAsync(new PatientRegisterIdInputDto
+ {
+ PatientRegisterId = input.PatientRegisterId
+ });
+
+
+ using (var httpClientHandler = new HttpClientHandler())
+ {
+ using (var httpClient = new HttpClient(httpClientHandler))
+ {
+ httpClient.BaseAddress = new Uri(reportApiBaseAddress);
+
+ httpClient.DefaultRequestHeaders.Accept.Add(
+ new MediaTypeWithQualityHeaderValue("application/json"));//设置accept标头,告诉JSON是可接受的响应类型
+
+
+ var sendData = JsonConvert.SerializeObject(printReportData);
+ using (HttpContent httpContent = new StringContent(sendData))
+ {
+ httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ HttpResponseMessage response = null;
+
+ response = await httpClient.PostAsync(reportApiUrl, httpContent);
+
+
+ string result;
+ if (!response.IsSuccessStatusCode)
+ {
+ result = response.Content.ReadAsStringAsync().Result;
+ throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result);
+ }
+ result = await response.Content.ReadAsStringAsync();
+
+ var resultDto = JsonConvert.DeserializeObject(result);
+ if (resultDto != null)
+ {
+ if (resultDto.code != 1)
+ {
+ throw new Exception($"调用WebApi失败,返回-1,消息:" + result);
+ }
+
+ reportBase64 = resultDto.data;
+ }
+ }
+
+ }
+ }
+
+ Thread.Sleep(1000);
+
+ #endregion
+
+ if (!string.IsNullOrWhiteSpace(reportBase64))
+ {
+ await UploadPeisReportAsync(new UploadPeisReportIuputDto
+ {
+ PatientRegisterId = input.PatientRegisterId,
+ ReportBase64 = reportBase64
+ });
+ }
+ }
#region MyRegion
@@ -209,7 +305,7 @@ namespace Shentun.Peis.TransToWebPeis
///
[HttpPost("api/app/TransToWebPeis/TransBaseData")]
- private async Task TransBaseDataAsync()
+ public async Task TransBaseDataAsync()
{
var thirdInterfaces = await _thirdInterfaceRepository.GetListAsync(o => o.ThirdInterfaceType ==
ThirdInterfaceTypeFlag.TranToWebPeis);
@@ -336,7 +432,7 @@ namespace Shentun.Peis.TransToWebPeis
}
}
- }
+ }
#endregion
#region 基础数据
@@ -886,7 +982,7 @@ namespace Shentun.Peis.TransToWebPeis
new SugarParameter("customer_org_register_id",patientRegisterEnt.CustomerOrgRegisterId),
new SugarParameter("concurrency_stamp",patientRegisterEnt.ConcurrencyStamp),
// new SugarParameter("creation_time",patientRegisterEnt.CreationTime),
- new SugarParameter("creation_time",DateTime.Now),
+ new SugarParameter("creation_time",patientRegisterEnt.CreationTime),
new SugarParameter("creator_id",patientRegisterEnt.CreatorId),
new SugarParameter("last_modification_time",patientRegisterEnt.LastModificationTime),
new SugarParameter("last_modifier_id",patientRegisterEnt.LastModifierId),
@@ -1356,7 +1452,7 @@ namespace Shentun.Peis.TransToWebPeis
if (patientRegisterIds.Any())
await ExportPatientRegisterWithDetailReverseData();
- }
+ }
#endregion
}
diff --git a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs
index 672ccbc5..a8efa861 100644
--- a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs
+++ b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs
@@ -64,7 +64,7 @@ using Volo.Abp.BackgroundWorkers;
using Shentun.Peis.Schedulers;
using System.Threading.Tasks;
using Shentun.Peis.ThirdInterfaces;
-using Microsoft.AspNetCore.Server.Kestrel.Core;
+
namespace Shentun.Peis;
[DependsOn(
@@ -247,8 +247,8 @@ public class PeisHttpApiHostModule : AbpModule
Configure(x =>
{
x.DefaultDateTimeFormat = "yyyy-MM-dd HH:mm:ss";
-
-
+
+
});
}
@@ -644,6 +644,10 @@ public class PeisHttpApiHostModule : AbpModule
{
RecurringJob.AddOrUpdate(thirdInterfaceDto.DisplayName, o => o.DoWork(thirdInterfaceDto.Id), corn, TimeZoneInfo.Local);
}
+ else if (thirdInterfaceDto.ThirdInterfaceType == "06")
+ {
+ RecurringJob.AddOrUpdate(thirdInterfaceDto.DisplayName, o => o.DoWork(thirdInterfaceDto.Id), corn, TimeZoneInfo.Local);
+ }
else if (thirdInterfaceDto.ThirdInterfaceType == "08")
{
//心电图
diff --git a/src/Shentun.Peis.HttpApi.Host/Schedulers/SyncPatientRegisterReportInterfaceWorker.cs b/src/Shentun.Peis.HttpApi.Host/Schedulers/SyncPatientRegisterReportInterfaceWorker.cs
index 68f8f2d6..6c362b0d 100644
--- a/src/Shentun.Peis.HttpApi.Host/Schedulers/SyncPatientRegisterReportInterfaceWorker.cs
+++ b/src/Shentun.Peis.HttpApi.Host/Schedulers/SyncPatientRegisterReportInterfaceWorker.cs
@@ -1,28 +1,59 @@
-using Microsoft.Extensions.Configuration;
+using Azure;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
+using Newtonsoft.Json.Converters;
+using Newtonsoft.Json;
+using Shentun.Peis.CustomerOrgs;
+using Shentun.Peis.Enums;
+using Shentun.Peis.Models;
+using Shentun.Peis.PatientRegisters;
using Shentun.Peis.ThirdInterfaces;
+using Shentun.Peis.TransToWebPeis;
using Shentun.Utilities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Security.Policy;
using System.Threading;
using System.Threading.Tasks;
+using Volo.Abp.Domain.Repositories;
+using Shentun.Peis.PrintReports;
+using Shentun.Peis.TransToWebPeiss;
+using Shentun.Peis.AppointRegisterAsbitems;
+using Shentun.Peis.PlugIns.WebAppoints;
namespace Shentun.Peis.Schedulers
{
public interface ISyncPatientRegisterReportInterfaceWorker
{
- public void DoWork(Guid interfaceId);
+ 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)
+ private readonly TransToWebPeisAppService _appService;
+ private readonly PrintReportAppService _printReportAppService;
+ private readonly IRepository _patientRegisterRepository;
+ public SyncPatientRegisterReportInterfaceWorker(
+ TransToWebPeisAppService appService,
+ IRepository patientRegisterRepository,
+ PrintReportAppService printReportAppService)
+ {
+ _appService = appService;
+ _patientRegisterRepository = patientRegisterRepository;
+ _printReportAppService = printReportAppService;
+ }
+
+ public void DoWork(Guid interfaceId)
{
if (_isRunning) return;
//lock (lockObject)
@@ -32,7 +63,7 @@ namespace Shentun.Peis.Schedulers
{
//Logger.LogInformation("Executed" + GetType().Name + "..!");
var appServiceHelper = new AppServiceHelper();
- //appServiceHelper.Login();
+ appServiceHelper.Login();
var thirdInterfaceDtos = appServiceHelper.CallAppService