Browse Source

插件

bjmzak
DESKTOP-G961P6V\Zhh 2 years ago
parent
commit
857af7e92e
  1. 3
      src/Shentun.ColumnReferencePlugIns/ImportLisResultPlugInsBase.cs
  2. 2
      src/Shentun.ColumnReferencePlugIns/ImportLisResultPlugInsDbBase.cs
  3. 4
      src/Shentun.ColumnReferencePlugIns/ImportPacsResultPlugInsBase.cs
  4. 15
      src/Shentun.ColumnReferencePlugIns/LisRequestPlugInsBase.cs
  5. 40
      src/Shentun.ColumnReferencePlugIns/PlugInsBase.cs
  6. 20
      src/Shentun.ColumnReferencePlugIns/ThirdPlugInsBase.cs
  7. 10
      src/Shentun.Peis.Application/ColumnReferences/ColumnReferenceAppService.cs
  8. 7
      src/Shentun.Peis.Application/ImportLisResults/ImportLisResultAppService.cs
  9. 5
      src/Shentun.Peis.Application/ImportPacsResults/ImportPacsResultAppService.cs
  10. 37
      src/Shentun.Peis.Domain/ChargeRequests/ChargeRequestManager.cs
  11. 3
      src/Shentun.Peis.Domain/LisRequests/LisRequestManager.cs
  12. 41
      src/Shentun.Peis.HttpApi.Host/AppServiceHelper.cs
  13. 6
      src/Shentun.Peis.HttpApi.Host/Schedulers/ThirdInterfaceWorkerBase.cs
  14. 6
      src/Shentun.Utilities/ReflectionHelper.cs

3
src/Shentun.ColumnReferencePlugIns/ImportLisResultPlugInsBase.cs

@ -62,11 +62,12 @@ register_check.patient_register_id = patient_register.id and
(
patient_register.complete_flag = '1' or
patient_register.complete_flag = '2') and
patient_register.medical_center_id =@MedicalCenterId and
lis_request.creation_time > @StartDate
ORDER BY register_check.patient_register_id
";
var patientRegisterForLisRequests = (await conn.QueryAsync<PatientRegisterForLisRequest>(sql,
new { StartDate = startDate })).ToList();
new { MedicalCenterId = _thirdInterfaceDto.MedicalCenterId, StartDate = startDate })).ToList();
return patientRegisterForLisRequests;
}

2
src/Shentun.ColumnReferencePlugIns/ImportLisResultPlugInsDbBase.cs

@ -48,7 +48,7 @@ namespace Shentun.Peis.PlugIns
//设置结果,生成小结
await LoginAsync();
//await LoginAsync();
var createImportLisResultDtos = new List<CreateImportLisResultDto>();
foreach (var lisRequest in lisRequests)
{

4
src/Shentun.ColumnReferencePlugIns/ImportPacsResultPlugInsBase.cs

@ -1,5 +1,6 @@
using Dapper;
using Npgsql;
using Shentun.Peis.ThirdInterfaces;
using System;
using System.Collections.Generic;
using System.Data.Common;
@ -66,12 +67,13 @@ where
(
patient_register.complete_flag = '1' or
patient_register.complete_flag = '2') and
patient_register.medical_center_id =@MedicalCenterId and
patient_register.medical_start_date >@StartDate and
register_check.creation_time >@StartDate
ORDER BY register_check.patient_register_id
";
var patientRegisterForLisRequests = (await conn.QueryAsync<PatientRegisterForLisRequest>(sql,
new { StartDate = startDate })).ToList();
new { MedicalCenterId = _thirdInterfaceDto.MedicalCenterId, StartDate = startDate })).ToList();
return patientRegisterForLisRequests;
}

15
src/Shentun.ColumnReferencePlugIns/LisRequestPlugInsBase.cs

@ -15,6 +15,21 @@ namespace Shentun.Peis.PlugIns
{
protected Guid AsbitemColumnReferenceId;
protected Guid SampleTypeColumnReferenceId;
public LisRequestPlugInsBase(Guid thirdInterfaceId):base(thirdInterfaceId)
{
var asbitemColumnReferenceIdStr = InterfaceConfig.GetSection("Interface").GetSection("AsbitemColumnReferenceId").Value;
if (!string.IsNullOrWhiteSpace(asbitemColumnReferenceIdStr))
{
AsbitemColumnReferenceId = new Guid(asbitemColumnReferenceIdStr);
}
var sampleTypeColumnReferenceIdStr = InterfaceConfig.GetSection("Interface").GetSection("SampleTypeColumnReferenceId").Value;
if (!string.IsNullOrWhiteSpace(sampleTypeColumnReferenceIdStr))
{
SampleTypeColumnReferenceId = new Guid(sampleTypeColumnReferenceIdStr);
}
}
public LisRequestPlugInsBase(string parmValue) : base(parmValue)
{

40
src/Shentun.ColumnReferencePlugIns/PlugInsBase.cs

@ -21,17 +21,17 @@ namespace Shentun.Peis.PlugIns
{
public class PlugInsBase
{
protected IConfiguration AppConfig;
protected IConfiguration InterfaceConfig;
protected IConfiguration? AppConfig;
protected IConfiguration? InterfaceConfig;
protected string? AppConnctionStr;
private string _appBaseAddress;
private static string _accesToken;
private string? _appBaseAddress;
private static string? _accesToken;
protected string? SelfUser;
protected string? SelfPassword;
protected string InterfaceSql;
protected string InterfaceSqlKeyColumn;
protected string InterfaceDbType;
protected string? InterfaceSql;
protected string? InterfaceSqlKeyColumn;
protected string? InterfaceDbType;
protected string? InterfaceConnctionStr;
protected string? InterfaceWebApiUrl;
@ -45,12 +45,24 @@ namespace Shentun.Peis.PlugIns
{
Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true;
}
public PlugInsBase()
{
Init();
}
public PlugInsBase(string parmValue)
{
Init();
Init(parmValue);
}
public void Init()
{
AppConfig = new ConfigurationBuilder()
.SetBasePath(DirectoryHelper.GetAppDirectory()) // 设置基础路径为当前目录
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();
.SetBasePath(DirectoryHelper.GetAppDirectory()) // 设置基础路径为当前目录
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();
AppConnctionStr = AppConfig.GetSection("ConnectionStrings")
.GetSection("Default").Value;
_appBaseAddress = AppConfig.GetSection("App")
@ -59,9 +71,11 @@ namespace Shentun.Peis.PlugIns
.GetSection("SelfUser").Value;
SelfPassword = AppConfig.GetSection("App")
.GetSection("SelfPassword").Value;
}
public void Init(string parmValue)
{
var configurationBuilder = new ConfigurationBuilder()
.AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue)));
.AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue)));
InterfaceConfig = configurationBuilder.Build();
InterfaceSql = InterfaceConfig.GetSection("Interface").GetSection("Sql").Value;
@ -98,9 +112,7 @@ namespace Shentun.Peis.PlugIns
{
UserColumnReferenceId = new Guid(userColumnReferenceIdStr);
}
}
protected DbConnection CreateInterfaceDbConnect()
{
DbConnection conn;

20
src/Shentun.ColumnReferencePlugIns/ThirdPlugInsBase.cs

@ -1,6 +1,7 @@
using Dapper;
using Microsoft.Extensions.Configuration;
using Npgsql;
using Shentun.Peis.ThirdInterfaces;
using Shentun.Utilities;
using System;
using System.Collections.Generic;
@ -13,7 +14,24 @@ namespace Shentun.Peis.PlugIns
{
public class ThirdPlugInsBase: PlugInsBase
{
//private Guid _thirdInterfaceId;
protected ThirdInterfaceDto _thirdInterfaceDto;
public ThirdPlugInsBase(Guid thirdInterfaceId):base()
{
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
{
string sql;
sql = @"
SELECT *
from third_interface
where id =@ThirdInterfaceId
";
_thirdInterfaceDto = ( conn.Query<ThirdInterfaceDto>(sql,
new { ThirdInterfaceId = thirdInterfaceId })).Single();
Init(_thirdInterfaceDto.ParmValue);
}
}
public ThirdPlugInsBase(string parmValue):base(parmValue)
{

10
src/Shentun.Peis.Application/ColumnReferences/ColumnReferenceAppService.cs

@ -248,7 +248,7 @@ namespace Shentun.Peis.ColumnReferences
var config = configurationBuilder.Build();
var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value;
var className = config.GetSection("Interface").GetSection("ClassName").Value;
var list = await ReflectionHelper.InvokeAsync<List<ColumnReferenceColumn>>(assemblyName, className, parmValue, "GetAppColumns");
var list = await ReflectionHelper.InvokeAsync<List<ColumnReferenceColumn>>(assemblyName, className, [parmValue], "GetAppColumns");
return list;
@ -272,7 +272,7 @@ namespace Shentun.Peis.ColumnReferences
var config = configurationBuilder.Build();
var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value;
var className = config.GetSection("Interface").GetSection("ClassName").Value;
var list = await ReflectionHelper.InvokeAsync<List<ColumnReferenceColumn>>(assemblyName, className, parmValue, "GetInterfaceColumns");
var list = await ReflectionHelper.InvokeAsync<List<ColumnReferenceColumn>>(assemblyName, className, [parmValue], "GetInterfaceColumns");
return list;
}
@ -293,7 +293,7 @@ namespace Shentun.Peis.ColumnReferences
var config = configurationBuilder.Build();
var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value;
var className = config.GetSection("Interface").GetSection("ClassName").Value;
var list = await ReflectionHelper.InvokeAsync <List<ColumnReferenceCodeValue>>(assemblyName, className, parmValue, "GetAppCodeValuesAsync");
var list = await ReflectionHelper.InvokeAsync <List<ColumnReferenceCodeValue>>(assemblyName, className, [parmValue], "GetAppCodeValuesAsync");
return list;
}
@ -317,7 +317,7 @@ namespace Shentun.Peis.ColumnReferences
var config = configurationBuilder.Build();
var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value;
var className = config.GetSection("Interface").GetSection("ClassName").Value;
var list = await ReflectionHelper.InvokeAsync<List<ColumnReferenceCodeValue>>(assemblyName, className, parmValue, "GetInterfaceCodeValuesAsync");
var list = await ReflectionHelper.InvokeAsync<List<ColumnReferenceCodeValue>>(assemblyName, className, [parmValue], "GetInterfaceCodeValuesAsync");
@ -345,7 +345,7 @@ namespace Shentun.Peis.ColumnReferences
var config = configurationBuilder.Build();
var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value;
var className = config.GetSection("Interface").GetSection("ClassName").Value;
var list = await ReflectionHelper.InvokeAsync<List<ColumnReferenceCodeValue>>(assemblyName, className, parmValue, "GetInterfaceCodeValuesAsync");
var list = await ReflectionHelper.InvokeAsync<List<ColumnReferenceCodeValue>>(assemblyName, className, [parmValue], "GetInterfaceCodeValuesAsync");
var result = new List<ColumnReferenceInterfaceCodeValueDto>();
foreach ( var item in items)
{

7
src/Shentun.Peis.Application/ImportLisResults/ImportLisResultAppService.cs

@ -287,8 +287,10 @@ namespace Shentun.Peis.ImportLisResults
[HttpPost("api/app/ImportLisResult/ImportResultByPatientRegisterId")]
public async Task ImportResultByPatientRegisterIdAsync(PatientRegisterIdInputDto input)
{
var patientRegister = await _patientRegisterRepository.GetAsync(input.PatientRegisterId);
var thirdInterfaces = await _thirdInterfaceRepository.GetListAsync(o =>
o.ThirdInterfaceType == ThirdInterfaceTypeFlag.ImportLisResult
o.ThirdInterfaceType == ThirdInterfaceTypeFlag.ImportLisResult
&& o.MedicalCenterId == patientRegister.MedicalCenterId
&& o.IsActive == 'Y');
foreach (var thirdInterface in thirdInterfaces)
{
@ -299,7 +301,8 @@ namespace Shentun.Peis.ImportLisResults
var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value;
var className = config.GetSection("Interface").GetSection("ClassName").Value;
object[] objects = new object[] { input.PatientRegisterId };
var pluginsOut = await Utilities.ReflectionHelper.InvokeAsync<ImportLisResultPlugInsOut>(assemblyName, className, parmValue, "ImportResultByPatientRegisterIdAsync", objects);
var pluginsOut = await Utilities.ReflectionHelper.InvokeAsync<ImportLisResultPlugInsOut>(assemblyName,
className, [thirdInterface.Id], "ImportResultByPatientRegisterIdAsync", objects);
}
}

5
src/Shentun.Peis.Application/ImportPacsResults/ImportPacsResultAppService.cs

@ -312,8 +312,10 @@ namespace Shentun.Peis.ImportPacsResults
[HttpPost("api/app/ImportPacsResult/ImportResultByPatientRegisterId")]
public async Task ImportResultByPatientRegisterIdAsync(PatientRegisterIdInputDto input)
{
var patientRegister = await _patientRegisterRepository.GetAsync(input.PatientRegisterId);
var thirdInterfaces = await _thirdInterfaceRepository.GetListAsync(o =>
o.ThirdInterfaceType == ThirdInterfaceTypeFlag.ImportPacsResult
&& o.MedicalCenterId == patientRegister.MedicalCenterId
&& o.IsActive == 'Y');
foreach (var thirdInterface in thirdInterfaces)
{
@ -324,7 +326,8 @@ namespace Shentun.Peis.ImportPacsResults
var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value;
var className = config.GetSection("Interface").GetSection("ClassName").Value;
object[] objects = new object[] { input.PatientRegisterId };
var pluginsOut = await Utilities.ReflectionHelper.InvokeAsync<ImportPacsResultPlugInsOut>(assemblyName, className, parmValue, "ImportResultByPatientRegisterIdAsync", objects);
var pluginsOut = await Utilities.ReflectionHelper.InvokeAsync<ImportPacsResultPlugInsOut>(assemblyName,
className, [thirdInterface.Id], "ImportResultByPatientRegisterIdAsync", objects);
}
}

37
src/Shentun.Peis.Domain/ChargeRequests/ChargeRequestManager.cs

@ -67,25 +67,25 @@ namespace Shentun.Peis.ChargeRequests
public async Task SendThirChargeRequestAsync(Guid id,string funName)
{
//var patientRegisterEntity = (from patientRegister in await _patientRegisterRepository.GetQueryableAsync()
// join registerCheck in await _registerCheckRepository.GetQueryableAsync()
// on patientRegister.Id equals registerCheck.PatientRegisterId
// join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync()
// on registerCheck.Id equals registerCheckAsbitem.RegisterCheckId
// join chargeRequest in await _repository.GetQueryableAsync()
// on registerCheckAsbitem.LisRequestId equals chargeRequest.Id
// where chargeRequest.Id == id
// select new
// {
// patientRegister
// }).ToList().FirstOrDefault();
//if (patientRegisterEntity == null)
//{
// return;
//}
var patientRegisterEntity = (from patientRegister in await _patientRegisterRepository.GetQueryableAsync()
join registerCheck in await _registerCheckRepository.GetQueryableAsync()
on patientRegister.Id equals registerCheck.PatientRegisterId
join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync()
on registerCheck.Id equals registerCheckAsbitem.RegisterCheckId
join chargeRequest in await _repository.GetQueryableAsync()
on registerCheckAsbitem.ChargeRequestId equals chargeRequest.Id
where chargeRequest.Id == id
select new
{
patientRegister
}).ToList().FirstOrDefault();
if (patientRegisterEntity == null)
{
return;
}
var thirdInterfaces = (await _thirdInterfaceRepository.GetListAsync(o => o.ThirdInterfaceType == ThirdInterfaceTypeFlag.ChargeRequest
))
&& o.MedicalCenterId == patientRegisterEntity.patientRegister.MedicalCenterId))
.OrderBy(o => o.DisplayOrder).ToList();
foreach (var thirdInterface in thirdInterfaces)
{
@ -101,7 +101,8 @@ namespace Shentun.Peis.ChargeRequests
var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value;
var className = config.GetSection("Interface").GetSection("ClassName").Value;
object[] objects = new object[] { chargeRequestPlugInsInput };
var chargeRequestPluginsOut = await ReflectionHelper.InvokeAsync<ChargeRequestPlugInsOut>(assemblyName, className, parmValue, funName, objects);
var chargeRequestPluginsOut = await ReflectionHelper.InvokeAsync<ChargeRequestPlugInsOut>(assemblyName,
className, [thirdInterface.Id], funName, objects);
}
}

3
src/Shentun.Peis.Domain/LisRequests/LisRequestManager.cs

@ -359,7 +359,8 @@ namespace Shentun.Peis.LisRequests
var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value;
var className = config.GetSection("Interface").GetSection("ClassName").Value;
object[] objects = new object[] { lisRequestPluginsInput };
var LisRequestPluginsOut = await ReflectionHelper.InvokeAsync<LisRequestPlugInsOut>(assemblyName, className, parmValue, "SendRequestAsync", objects);
var LisRequestPluginsOut = await ReflectionHelper.InvokeAsync<LisRequestPlugInsOut>(assemblyName,
className, [thirdInterface.Id], "SendRequestAsync", objects);
}
}

41
src/Shentun.Peis.HttpApi.Host/AppServiceHelper.cs

@ -7,6 +7,8 @@ using System.Net.Http;
using System.Threading.Tasks;
using System;
using Newtonsoft.Json.Converters;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
namespace Shentun.Peis
{
@ -14,7 +16,7 @@ namespace Shentun.Peis
{
protected IConfiguration AppConfig;
private string _appBaseAddress;
private string _accesToken;
private static string _accesToken;
private string _selfUser;
private string _selfPassword;
@ -35,6 +37,7 @@ namespace Shentun.Peis
public async Task<TOut> CallAppServiceAsync<TInput, TOut>(string url, TInput data)
{
string baseAddress = _appBaseAddress;
await CheckLoginAsync();
using (var httpClientHandler = new HttpClientHandler())
{
using (var httpClient = new HttpClient(httpClientHandler))
@ -230,5 +233,41 @@ namespace Shentun.Peis
}
}
private async Task CheckLoginAsync()
{
if (string.IsNullOrWhiteSpace(_accesToken))
{
await LoginAsync();
}
else
{
var handler = new JwtSecurityTokenHandler();
var payload = handler.ReadJwtToken(_accesToken).Payload;
var claims = payload.Claims;
var exp = claims.First(claim => claim.Type == "exp").Value;
if (exp == null)
{
await LoginAsync();
}
else
{
if (long.TryParse(exp, out var expires))
{
var expireTime = DateTimeOffset.FromUnixTimeSeconds(expires).LocalDateTime;
if (expireTime <= DateTime.Now)
{
await LoginAsync();
}
}
else
{
await LoginAsync();
}
}
}
}
}
}

6
src/Shentun.Peis.HttpApi.Host/Schedulers/ThirdInterfaceWorkerBase.cs

@ -27,7 +27,7 @@ namespace Shentun.Peis.Schedulers
{
//Logger.LogInformation("Executed" + GetType().Name + "..!");
var appServiceHelper = new AppServiceHelper();
appServiceHelper.Login();
//appServiceHelper.Login();
var thirdInterFaceForHostOutDto = appServiceHelper.CallAppService<object, ThirdInterFaceForHostOutDto>("api/app/ThirdInterface/GetList", null);
var thirdInterfaceDto = thirdInterFaceForHostOutDto.Data.Where(o => o.Id == interfaceId).FirstOrDefault();
if (thirdInterfaceDto == null)
@ -57,8 +57,8 @@ namespace Shentun.Peis.Schedulers
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.Invoke(assemblyName, className, parmValue, funName);
object[] classConstructorArg = new object[] { thirdInterfaceDto.Id };
ReflectionHelper.Invoke(assemblyName, className, classConstructorArg, funName);
}

6
src/Shentun.Utilities/ReflectionHelper.cs

@ -9,7 +9,7 @@ namespace Shentun.Utilities
{
public class ReflectionHelper
{
public static async Task<T> InvokeAsync<T>(string assemblyName, string className, string classConstructorArg, string methodName, object[] args = null)
public static async Task<T> InvokeAsync<T>(string assemblyName, string className, object[] classConstructorArg, string methodName, object[] args = null)
{
Assembly assembly = Assembly.Load(assemblyName);
Type type = assembly.GetType(className);
@ -36,7 +36,7 @@ namespace Shentun.Utilities
return returnValue;
}
public static async Task InvokeAsync(string assemblyName, string className, string classConstructorArg, string methodName, object[] args = null)
public static async Task InvokeAsync(string assemblyName, string className, object[] classConstructorArg, string methodName, object[] args = null)
{
Assembly assembly = Assembly.Load(assemblyName);
Type type = assembly.GetType(className);
@ -62,7 +62,7 @@ namespace Shentun.Utilities
return ;
}
public static void Invoke(string assemblyName, string className, string classConstructorArg, string methodName, object[] args = null)
public static void Invoke(string assemblyName, string className, object[] classConstructorArg, string methodName, object[] args = null)
{
Assembly assembly = Assembly.Load(assemblyName);
Type type = assembly.GetType(className);

Loading…
Cancel
Save