Browse Source

收费

bjmzak
DESKTOP-G961P6V\Zhh 2 years ago
parent
commit
3d38397ab2
  1. 14
      ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ChargeRequestPlugInsGem.cs
  2. 51
      src/Shentun.ColumnReferencePlugIns/ChargeRequestPlugInsBase.cs
  3. 14
      src/Shentun.Peis.Application/ChargeRequests/ChargeRequestAppService.cs
  4. 9
      src/Shentun.Peis.Domain.Shared/Enums/ChargeRequestFlag.cs
  5. 122
      src/Shentun.Peis.HttpApi.Host/AppServiceHelper.cs
  6. 62
      src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs
  7. 81
      src/Shentun.Peis.HttpApi.Host/Schedulers/ChargeRequestInterfaceQueryWorker.cs
  8. 2
      src/Shentun.Peis.HttpApi.Host/Shentun.Peis.HttpApi.Host.csproj
  9. 7
      src/Shentun.Peis.HttpApi.Host/appsettings.json
  10. 4408
      src/Shentun.Peis.HttpApi.Host/package-lock.json
  11. 840
      src/Shentun.Peis.HttpApi.Host/yarn.lock
  12. 26
      src/Shentun.Utilities/ReflectionHelper.cs

14
ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ChargeRequestPlugInsGem.cs

@ -1,4 +1,5 @@
using Dapper;
using log4net.Repository.Hierarchy;
using Npgsql;
using ServiceReferenceHzcyHis;
using System;
@ -23,7 +24,7 @@ namespace Shentun.Peis.PlugIns.Gem
{
//建立人员档案
var patientRegisterForPlugIns = await GetPatientRegisterForPlugInsAsync(input.ChargeRequestId);
var chargeRequestForPlugIns = await GeChargeRequestForPlugInsAsync(input.ChargeRequestId);
var chargeRequestForPlugIns = await GetChargeRequestForPlugInsAsync(input.ChargeRequestId);
if(chargeRequestForPlugIns == null)
{
throw new Exception("没有申请单信息");
@ -132,7 +133,7 @@ namespace Shentun.Peis.PlugIns.Gem
public override async Task<ChargeRequestPlugInsOut> CancelRequestAsync(ChargeRequestPlugInsInput input)
{
var chargeRequestForPlugIns = await GeChargeRequestForPlugInsAsync(input.ChargeRequestId);
var chargeRequestForPlugIns = await GetChargeRequestForPlugInsAsync(input.ChargeRequestId);
if (chargeRequestForPlugIns == null)
{
throw new Exception("没有申请单信息");
@ -160,12 +161,18 @@ namespace Shentun.Peis.PlugIns.Gem
{
throw new Exception("作废申请单失败" + result.MsgHeader.Detail);
}
await CancelAppChargeRequestAsync(input.ChargeRequestId);
return new ChargeRequestPlugInsOut();
}
public override Task DoWorkAsync()
{
throw new Exception("格尔木DoWorkAsync。。。");
//return base.DoWorkAsync();
}
public override async Task<ChargeRequestPlugInsOut> RefundRequestAsync(ChargeRequestPlugInsInput input)
{
var chargeRequestForPlugIns = await GeChargeRequestForPlugInsAsync(input.ChargeRequestId);
var chargeRequestForPlugIns = await GetChargeRequestForPlugInsAsync(input.ChargeRequestId);
if (chargeRequestForPlugIns == null)
{
throw new Exception("没有申请单信息");
@ -194,6 +201,7 @@ namespace Shentun.Peis.PlugIns.Gem
{
throw new Exception("允许退费申请失败" + result.MsgHeader.Detail);
}
await RefundAppChargeRequestAsync(input.ChargeRequestId);
return new ChargeRequestPlugInsOut();
}
public async Task<HisPatientQueryOut> PatientQuery(HisPatientQueryInput input)

51
src/Shentun.ColumnReferencePlugIns/ChargeRequestPlugInsBase.cs

@ -66,7 +66,7 @@ where patient.id = patient_register.patient_id and
}
public async Task<ChargeRequestForPlugIns> GeChargeRequestForPlugInsAsync(Guid chargeRequestId)
public async Task<ChargeRequestForPlugIns> GetChargeRequestForPlugInsAsync(Guid chargeRequestId)
{
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
{
@ -101,6 +101,55 @@ where patient.id = patient_register.patient_id and
return chargeRequestForPlugIns;
}
}
public async Task CancelAppChargeRequestAsync(Guid chargeRequestId)
{
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
{
string sql;
sql = @" update charge_request set charge_request_flag = '2' where id = @ChargeRequestId
";
conn.Execute(sql,
new { ChargeRequestId = chargeRequestId });
}
}
public async Task RefundAppChargeRequestAsync(Guid chargeRequestId)
{
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
{
string sql;
sql = @" update charge_request set charge_request_flag = '3' where id = @ChargeRequestId
";
conn.Execute(sql,
new { ChargeRequestId = chargeRequestId });
}
}
public async Task SetAppChargeRequestIsChargeAsync(Guid chargeRequestId)
{
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
{
string sql;
sql = @" update charge_request set charge_request_flag = '1' where id = @ChargeRequestId
";
conn.Execute(sql,
new { ChargeRequestId = chargeRequestId });
sql = @" update register_check_asbitem set is_charge = 'Y' where charge_request_id = @ChargeRequestId
";
conn.Execute(sql,
new { ChargeRequestId = chargeRequestId });
}
}
public virtual async Task DoWorkAsync()
{
}
}
public class ChargeRequestPlugInsInput

14
src/Shentun.Peis.Application/ChargeRequests/ChargeRequestAppService.cs

@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Mvc;
using Org.BouncyCastle.Asn1.Ocsp;
using Shentun.Peis.ChargeRequestAsbitems;
using Shentun.Peis.Enums;
using Shentun.Peis.LisRequests;
using Shentun.Peis.Models;
using Shentun.Peis.PatientRegisters;
@ -69,12 +70,15 @@ namespace Shentun.Peis.ChargeRequests
var list = (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
where registerCheck.PatientRegisterId == input.PatientRegisterId &&
input.RegisterCheckAsbitems.Select(o=>o.RegisterCheckAsbitemId)
.Contains(registerCheckAsbitem.Id)
select new
{
registerCheckAsbitem
registerCheckAsbitem,
asbitem
}).ToList();
var chargeRequestSource = new ChargeRequest()
{
@ -84,6 +88,14 @@ namespace Shentun.Peis.ChargeRequests
//更新登记组合项目
foreach (var item in list)
{
if(item.registerCheckAsbitem.ChargeRequestId != null)
{
var haveChargeRequest = await _chargeRequestRepository.GetAsync((Guid)item.registerCheckAsbitem.ChargeRequestId);
if(haveChargeRequest.ChargeRequestFlag == ChargeRequestFlag.Request)
{
throw new UserFriendlyException($"{item.asbitem.DisplayName}已经申请,必须先撤销申请");
}
}
item.registerCheckAsbitem.ChargeRequestId = chargeRequest.Id;
await _registerCheckAsbitemRepository.UpdateAsync(item.registerCheckAsbitem);
}

9
src/Shentun.Peis.Domain.Shared/Enums/ChargeRequestFlag.cs

@ -11,13 +11,12 @@ namespace Shentun.Peis.Enums
[Description("申请")]
public const char Request = '0';
[Description("作废")]
public const char Cancel = '1';
[Description("已收费")]
public const char Charge = '2';
public const char Charge = '1';
[Description("作废")]
public const char Cancel = '2';
[Description("退费")]
public const char Refund = '3';

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

@ -0,0 +1,122 @@
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using Shentun.Peis.PlugIns;
using Shentun.Utilities;
using System.Net.Http.Headers;
using System.Net.Http;
using System.Threading.Tasks;
using System;
namespace Shentun.Peis
{
public class AppServiceHelper
{
protected IConfiguration AppConfig;
private string _appBaseAddress;
private string _accesToken;
private string _selfUser;
private string _selfPassword;
public AppServiceHelper()
{
AppConfig = new ConfigurationBuilder()
.SetBasePath(DirectoryHelper.GetAppDirectory()) // 设置基础路径为当前目录
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();
_appBaseAddress = AppConfig.GetSection("App")
.GetSection("SelfUrl").Value;
_appBaseAddress = AppConfig.GetSection("App")
.GetSection("SelfUrl").Value;
_appBaseAddress = AppConfig.GetSection("App")
.GetSection("SelfUrl").Value;
}
public async Task<TOut> CallAppServiceAsync<TInput, TOut>(string url, TInput data)
{
string baseAddress = _appBaseAddress;
using (var httpClientHandler = new HttpClientHandler())
{
using (var httpClient = new HttpClient(httpClientHandler))
{
httpClient.BaseAddress = new Uri(baseAddress);
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));//设置accept标头,告诉JSON是可接受的响应类型
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _accesToken);
string sendData = "";
if (data != null)
{
sendData = JsonConvert.SerializeObject(data);
}
using (HttpContent httpContent = new StringContent(sendData))
{
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
HttpResponseMessage response = await httpClient.PostAsync(url, 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<TOut>(result);
return resultDto;
}
}
}
}
public async Task LoginAsync()
{
await LoginAsync(_selfUser, _selfPassword);
}
public async Task LoginAsync(string userId, string password)
{
using (var httpClientHandler = new HttpClientHandler())
{
using (var httpClient = new HttpClient(httpClientHandler))
{
httpClient.BaseAddress = new Uri(_appBaseAddress);
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));//设置accept标头,告诉JSON是可接受的响应类型
var url = "api/identity/users/login";
var loginUser = new LoginInputDto()
{
UserName = userId,
Password = password
};
var sendData = JsonConvert.SerializeObject(loginUser);
using (HttpContent httpContent = new StringContent(sendData))
{
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
HttpResponseMessage response = await httpClient.PostAsync(url, httpContent);
string result;
if (!response.IsSuccessStatusCode)
{
result = response.Content.ReadAsStringAsync().Result;
throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result);
}
result = await response.Content.ReadAsStringAsync();
var restultDto = JsonConvert.DeserializeObject<LoginOutDto>(result);
if (restultDto == null)
{
throw new Exception("返回结果是空");
}
if (restultDto.Code != "1")
{
throw new Exception($"登录失败{restultDto.Message}");
}
_accesToken = restultDto.Data.access_token;
}
}
}
}
}
}

62
src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs

@ -57,6 +57,13 @@ using Volo.Abp.Json;
using Shentun.Utilities;
using Volo.Abp.SecurityLog;
using Volo.Abp.Auditing;
using Volo.Abp.BackgroundWorkers.Hangfire;
using Hangfire;
using Hangfire.PostgreSql;
using Volo.Abp.BackgroundWorkers;
using Shentun.Peis.Schedulers;
using System.Threading.Tasks;
using Shentun.Peis.ThirdInterfaces;
namespace Shentun.Peis;
[DependsOn(
@ -68,7 +75,8 @@ namespace Shentun.Peis;
typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule),
typeof(AbpAccountWebOpenIddictModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
typeof(AbpSwashbuckleModule),
typeof(AbpBackgroundWorkersHangfireModule)
)]
public class PeisHttpApiHostModule : AbpModule
{
@ -204,6 +212,8 @@ public class PeisHttpApiHostModule : AbpModule
});
*/
//后台计划任务
ConfigureHangfire(context, configuration);
}
/// <summary>
@ -440,7 +450,14 @@ public class PeisHttpApiHostModule : AbpModule
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
private void ConfigureHangfire(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddHangfire(config =>
{
config.UsePostgreSqlStorage(configuration.GetConnectionString("Default"));
});
}
public override async void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
@ -540,5 +557,46 @@ public class PeisHttpApiHostModule : AbpModule
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
//任务计划
// await StartScheduler(context);
}
private async Task StartScheduler(ApplicationInitializationContext context)
{
//await context.AddBackgroundWorkerAsync<ChargeRequestInterfaceQueryWorker>();
//RecurringJob.AddOrUpdate<IChargeRequestInterfaceQueryWorker>("收费接口", o => o.DoWorkAsync(new Guid("")), CheckedBills, TimeZoneInfo.Local);
//BackgroundJob.Enqueue<ChargeRequestInterfaceQueryWorker>(x => x.DoWorkWithArgAsync(new Guid("")));
var appServiceHelper = new AppServiceHelper();
await appServiceHelper.LoginAsync();
var thirdInterfaceDtos = appServiceHelper.CallAppServiceAsync<object, List<ThirdInterfaceDto>>("api/app/ThirdInterface/GetList", null).Result;
if (thirdInterfaceDtos != null)
{
foreach (var thirdInterfaceDto in thirdInterfaceDtos)
{
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;
var corn = interfaceConfig.GetSection("Interface").GetSection("Scheduler")
.GetSection("Corn").Value;
if (isActive == "Y")
{
if(thirdInterfaceDto.ThirdInterfaceType == "02")
{
RecurringJob.AddOrUpdate<IChargeRequestInterfaceQueryWorker>("收费接口", o => o.DoWorkAsync(thirdInterfaceDto.Id), corn, TimeZoneInfo.Local);
}
}
}
}
}
}
}

81
src/Shentun.Peis.HttpApi.Host/Schedulers/ChargeRequestInterfaceQueryWorker.cs

@ -0,0 +1,81 @@
using Hangfire;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Shentun.Peis.PlugIns;
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;
using Volo.Abp.BackgroundWorkers.Hangfire;
using static Org.BouncyCastle.Math.EC.ECCurve;
namespace Shentun.Peis.Schedulers
{
public interface IChargeRequestInterfaceQueryWorker
{
public Task DoWorkAsync(Guid interfaceId);
}
public class ChargeRequestInterfaceQueryWorker : HangfireBackgroundWorkerBase, IChargeRequestInterfaceQueryWorker
{
private string isActive = "N";
public ChargeRequestInterfaceQueryWorker()
{
//RecurringJobId = nameof(ChargeRequestInterfaceQueryWorker);
//CronExpression = Cron.Daily();
//获取所有第三方接口
}
public override Task DoWorkAsync(CancellationToken cancellationToken = default)
{
Logger.LogInformation("Executed ChargeRequestInterfaceQueryWorker..!");
return Task.CompletedTask;
}
public Task DoWorkAsync(Guid interfaceId)
{
try
{
var appServiceHelper = new AppServiceHelper();
appServiceHelper.LoginAsync();
var thirdInterfaceDtos = appServiceHelper.CallAppServiceAsync<object, List<ThirdInterfaceDto>>("api/app/ThirdInterface/GetList", null).Result;
var thirdInterfaceDto = thirdInterfaceDtos.Where(o => o.Id == interfaceId).FirstOrDefault();
if (thirdInterfaceDto == null)
{
return Task.CompletedTask;
}
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")
{
return Task.CompletedTask;
}
var assemblyName = interfaceConfig.GetSection("Interface").GetSection("AssemblyName").Value;
var className = interfaceConfig.GetSection("Interface").GetSection("ClassName").Value;
var funName = "DoWorkAsync";
//object[] objects = new object[] { chargeRequestPlugInsInput };
ReflectionHelper.InvokeAsync(assemblyName, className, parmValue, funName);
}
Logger.LogInformation("Executed ChargeRequestInterfaceQueryWorker..!");
}
catch (Exception ex)
{
Logger.LogError("Executed ChargeRequestInterfaceQueryWorker Error" + ex.Message);
}
return Task.CompletedTask;
}
}
}

2
src/Shentun.Peis.HttpApi.Host/Shentun.Peis.HttpApi.Host.csproj

@ -10,11 +10,13 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Hangfire.PostgreSql" Version="1.7.0" />
<PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Volo.Abp.AspNetCore.MultiTenancy" Version="6.0.0" />
<PackageReference Include="Volo.Abp.Autofac" Version="6.0.0" />
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="6.0.0" />
<PackageReference Include="Volo.Abp.BackgroundWorkers.Hangfire" Version="6.0.3" />
<PackageReference Include="Volo.Abp.Swashbuckle" Version="6.0.0" />
<PackageReference Include="Volo.Abp.Account.Web.OpenIddict" Version="6.0.0" />
</ItemGroup>

7
src/Shentun.Peis.HttpApi.Host/appsettings.json

@ -1,9 +1,12 @@
{
"App": {
"SelfUrl": "http://localhost:9530",
"SelfUrl": "http://10.1.12.140:9529",
//"SelfUrl": "http://localhost:9530",
"ClientUrl": "http://localhost:9530",
"CorsOrigins": "https://*.Peis.com,http://localhost:4200,http://localhost:9530,http://192.168.1.108:9530,http://localhost:8080,http://localhost:8081",
"RedirectAllowedUrls": "http://localhost:9530"
"RedirectAllowedUrls": "http://localhost:9530",
"SelfUser": "admin",
"SelfPassword": "666666"
},
"ConnectionStrings": {
//"Default": "Host=140.143.162.39;Port=5432;Database=ShentunPeis070703;User ID=postgres;Password=shentun123;"

4408
src/Shentun.Peis.HttpApi.Host/package-lock.json
File diff suppressed because it is too large
View File

840
src/Shentun.Peis.HttpApi.Host/yarn.lock
File diff suppressed because it is too large
View File

26
src/Shentun.Utilities/ReflectionHelper.cs

@ -35,5 +35,31 @@ namespace Shentun.Utilities
}
return returnValue;
}
public static async Task InvokeAsync(string assemblyName, string className, string classConstructorArg, string methodName, object[] args = null)
{
Assembly assembly = Assembly.Load(assemblyName);
Type type = assembly.GetType(className);
// 创建类的实例
object instance = Activator.CreateInstance(type, classConstructorArg);
// 获取方法信息
MethodInfo method = type.GetMethod(methodName);
// 调用方法,如果方法需要参数,可以传入对应的参数数组,例如: new object[] { arg1, arg2 }
var isAsync = (method.ReturnType == typeof(Task) ||
(method.ReturnType.IsGenericType && method.ReturnType.GetGenericTypeDefinition() == typeof(Task<>)));
if (isAsync)
{
// 使用反射调用方法
//object returnValue = method.Invoke(instance, args);
await (Task)method.Invoke(instance, args);
}
else
{
method.Invoke(instance, args);
}
return ;
}
}
}
Loading…
Cancel
Save