11 changed files with 16779 additions and 6 deletions
-
23src/Shentun.Peis.Application.Contracts/ThirdBookingPushs/EncryDataRequstDto.cs
-
33src/Shentun.Peis.Application.Contracts/ThirdBookingPushs/EncryDataResultDto.cs
-
23src/Shentun.Peis.Application.Contracts/ThirdBookingPushs/GetEncryptDataInputDto.cs
-
132src/Shentun.Peis.Application.Contracts/ThirdBookingPushs/PushCompletePhysicalInputDto.cs
-
102src/Shentun.Peis.Application.Contracts/ThirdBookingPushs/PushRegisterInputDto.cs
-
282src/Shentun.Peis.Application/ThirdBookingPushs/ThirdBookingPushAppService.cs
-
10src/Shentun.Peis.Domain/ThirdBookings/ThirdBooking.cs
-
132src/Shentun.Peis.Domain/newRsaHelper.cs
-
15959src/Shentun.Peis.EntityFrameworkCore/Migrations/20240927133036_update_third_booking_icode.Designer.cs
-
77src/Shentun.Peis.EntityFrameworkCore/Migrations/20240927133036_update_third_booking_icode.cs
-
12src/Shentun.Peis.EntityFrameworkCore/Migrations/PeisDbContextModelSnapshot.cs
@ -0,0 +1,23 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.ThirdBookingPushs |
||||
|
{ |
||||
|
public class EncryDataRequstDto |
||||
|
{ |
||||
|
/// 来源系统编码
|
||||
|
/// </summary>
|
||||
|
public string ICODE { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 加密的响应报文
|
||||
|
/// </summary>
|
||||
|
public string DATA { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 响应报文加签
|
||||
|
/// </summary>
|
||||
|
public string SIGN { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.ThirdBookingPushs |
||||
|
{ |
||||
|
public class EncryDataResultDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 接口调用状态
|
||||
|
/// </summary>
|
||||
|
public bool FLAG { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 接口调用结果信息
|
||||
|
/// </summary>
|
||||
|
public string MESSAGE { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 来源系统编码
|
||||
|
/// </summary>
|
||||
|
public string ICODE { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 加密的响应报文
|
||||
|
/// </summary>
|
||||
|
public string DATA { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 响应报文加签
|
||||
|
/// </summary>
|
||||
|
public string SIGN { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.ThirdBookingPushs |
||||
|
{ |
||||
|
public class GetEncryptDataInputDto |
||||
|
{ |
||||
|
/// 来源系统编码
|
||||
|
/// </summary>
|
||||
|
public string ICODE { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 加密的响应报文
|
||||
|
/// </summary>
|
||||
|
public string DATA { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 响应报文加签
|
||||
|
/// </summary>
|
||||
|
public string SIGN { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,132 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.ThirdBookingPushs |
||||
|
{ |
||||
|
public class PushCompletePhysicalInputDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 体检年度
|
||||
|
/// </summary>
|
||||
|
public string YEAR { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 客户来源
|
||||
|
/// </summary>
|
||||
|
public string SOURCE { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 姓名
|
||||
|
/// </summary>
|
||||
|
public string NAME { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 证件类型
|
||||
|
/// </summary>
|
||||
|
public string IDTYPE { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 证件号
|
||||
|
/// </summary>
|
||||
|
public string IDNO { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 性别
|
||||
|
/// </summary>
|
||||
|
public string GENDER { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 出生日期
|
||||
|
/// </summary>
|
||||
|
public string BIRTHDAY { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 年龄
|
||||
|
/// </summary>
|
||||
|
public short AGE { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 手机号
|
||||
|
/// </summary>
|
||||
|
public string MOBILE { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 到检体检机构
|
||||
|
/// </summary>
|
||||
|
public string CONFIRMORG { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 到检体检中心名称
|
||||
|
/// </summary>
|
||||
|
public string CONFIRMORGCENTERDESC { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 到检方式
|
||||
|
/// </summary>
|
||||
|
public string CONFIRMTYPE { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 到检时间(登记时间)
|
||||
|
/// </summary>
|
||||
|
public string CONFIRMTIME { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 体检套餐编码
|
||||
|
/// </summary>
|
||||
|
public string EXAMPACKAGECODE { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 体检套餐描述
|
||||
|
/// </summary>
|
||||
|
public string EXAMPACKAGEDESC { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 体检开始时间
|
||||
|
/// </summary>
|
||||
|
public string EXAMBEGINTIME { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 体检完成时间
|
||||
|
/// </summary>
|
||||
|
public string EXAMCOMPLETETIME { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 体检ID
|
||||
|
/// </summary>
|
||||
|
public string EXAMID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 体检预约ID
|
||||
|
/// </summary>
|
||||
|
public string BOOKINGID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 预约方式
|
||||
|
/// </summary>
|
||||
|
public string BOOKINGTYPE { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 预约方式为其它时说明
|
||||
|
/// </summary>
|
||||
|
public string BOOKINGTYPEELSEDESC { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 预约日期
|
||||
|
/// </summary>
|
||||
|
public string BOOKINGDATE { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 预约时间
|
||||
|
/// </summary>
|
||||
|
public string BOOKINGTIME { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 预约时间描述
|
||||
|
/// </summary>
|
||||
|
public string BOOKINGDATEDESC { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,102 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.ThirdBookingPushs |
||||
|
{ |
||||
|
public class PushRegisterInputDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 体检年度
|
||||
|
/// </summary>
|
||||
|
public string YEAR { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 客户来源
|
||||
|
/// </summary>
|
||||
|
public string SOURCE { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 姓名
|
||||
|
/// </summary>
|
||||
|
public string NAME { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 证件类型
|
||||
|
/// </summary>
|
||||
|
public string IDTYPE { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 证件号
|
||||
|
/// </summary>
|
||||
|
public string IDNO { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 手机号
|
||||
|
/// </summary>
|
||||
|
public string MOBILE { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 到检体检机构
|
||||
|
/// </summary>
|
||||
|
public string CONFIRMORG { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 到检体检中心名称
|
||||
|
/// </summary>
|
||||
|
public string CONFIRMORGCENTERDESC { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 到检方式
|
||||
|
/// </summary>
|
||||
|
public string CONFIRMTYPE { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 到检时间(登记时间)
|
||||
|
/// </summary>
|
||||
|
public string CONFIRMTIME { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 体检套餐编码
|
||||
|
/// </summary>
|
||||
|
public string EXAMPACKAGECODE { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 体检套餐描述
|
||||
|
/// </summary>
|
||||
|
public string EXAMPACKAGEDESC { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 体检预约ID
|
||||
|
/// </summary>
|
||||
|
public string BOOKINGID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 预约方式
|
||||
|
/// </summary>
|
||||
|
public string BOOKINGTYPE { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 预约方式为其它时说明
|
||||
|
/// </summary>
|
||||
|
public string BOOKINGTYPEELSEDESC { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 预约日期
|
||||
|
/// </summary>
|
||||
|
public string BOOKINGDATE { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 预约时间
|
||||
|
/// </summary>
|
||||
|
public string BOOKINGTIME { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 预约时间描述
|
||||
|
/// </summary>
|
||||
|
public string BOOKINGDATEDESC { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,282 @@ |
|||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Newtonsoft.Json.Converters; |
||||
|
using Newtonsoft.Json; |
||||
|
using Shentun.Peis.Enums; |
||||
|
using Shentun.Peis.Models; |
||||
|
using Shentun.Peis.PatientRegisters; |
||||
|
using Shentun.Peis.PlugIns.Sms; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Net.Http.Headers; |
||||
|
using System.Net.Http; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace Shentun.Peis.ThirdBookingPushs |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 推送体检信息到人寿
|
||||
|
/// </summary>
|
||||
|
[Authorize] |
||||
|
[ApiExplorerSettings(GroupName = "Work")] |
||||
|
public class ThirdBookingPushAppService : ApplicationService |
||||
|
{ |
||||
|
|
||||
|
private readonly IRepository<ThirdInterface, Guid> _thirdInterfaceRepository; |
||||
|
private readonly IRepository<PatientRegister, Guid> _patientRegisterRepository; |
||||
|
private readonly IRepository<ThirdBooking, Guid> _thirdBookingRepository; |
||||
|
private readonly IRepository<CustomerOrgGroup, Guid> _customerOrgGroupRepository; |
||||
|
public ThirdBookingPushAppService( |
||||
|
IRepository<ThirdInterface, Guid> thirdInterfaceRepository, |
||||
|
IRepository<PatientRegister, Guid> patientRegisterRepository, |
||||
|
IRepository<ThirdBooking, Guid> thirdBookingRepository, |
||||
|
IRepository<CustomerOrgGroup, Guid> customerOrgGroupRepository |
||||
|
) |
||||
|
{ |
||||
|
_thirdInterfaceRepository = thirdInterfaceRepository; |
||||
|
_patientRegisterRepository = patientRegisterRepository; |
||||
|
_thirdBookingRepository = thirdBookingRepository; |
||||
|
_customerOrgGroupRepository = customerOrgGroupRepository; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 推送登记
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/ThirdBookingPush/PushRegister")] |
||||
|
public async Task PushRegisterAsync(PatientRegisterIdInputDto input) |
||||
|
{ |
||||
|
var thirdBookingInterface = await _thirdInterfaceRepository.FirstOrDefaultAsync(o => o.ThirdInterfaceType == |
||||
|
ThirdInterfaceTypeFlag.ThirdBooking); |
||||
|
if (thirdBookingInterface != null && thirdBookingInterface.IsActive == 'Y') |
||||
|
{ |
||||
|
|
||||
|
var parmValue = thirdBookingInterface.ParmValue; |
||||
|
var configurationBuilder = new ConfigurationBuilder() |
||||
|
.AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); |
||||
|
var interfaceConfig = configurationBuilder.Build(); |
||||
|
var baseApiAddress = interfaceConfig.GetSection("Interface").GetSection("BaseApiAddress").Value; |
||||
|
var registerApiAddress = interfaceConfig.GetSection("Interface").GetSection("RegisterApiAddress").Value; |
||||
|
var publicKey = interfaceConfig.GetSection("Interface").GetSection("YuanFuPublicKey").Value; |
||||
|
var privateKey = interfaceConfig.GetSection("Interface").GetSection("MinZhongPrivateKey").Value; |
||||
|
var iCode = interfaceConfig.GetSection("Interface").GetSection("ICODE").Value; |
||||
|
var isActive = interfaceConfig.GetSection("Interface").GetSection("IsActive").Value; |
||||
|
if (!string.IsNullOrWhiteSpace(isActive) |
||||
|
&& isActive == "Y") |
||||
|
{ |
||||
|
|
||||
|
var patientRegisterEnt = await _patientRegisterRepository.GetAsync(input.PatientRegisterId); |
||||
|
|
||||
|
if (patientRegisterEnt != null && string.IsNullOrWhiteSpace(patientRegisterEnt.ThirdBookingId)) |
||||
|
{ |
||||
|
var thirdBookingEnt = await _thirdBookingRepository.FirstOrDefaultAsync(f => f.Id == Guid.Parse(patientRegisterEnt.ThirdBookingId)); |
||||
|
|
||||
|
var customerOrgGroupEnt = await _customerOrgGroupRepository.GetAsync(g => g.Id == Guid.Parse(thirdBookingEnt.CustomerOrgGroupId)); |
||||
|
|
||||
|
var pushRegisterInput = new PushRegisterInputDto |
||||
|
{ |
||||
|
BOOKINGDATE = thirdBookingEnt.BookingDate.ToString("yyyy-MM-dd"), |
||||
|
BOOKINGDATEDESC = "", |
||||
|
BOOKINGID = patientRegisterEnt.ThirdBookingId, |
||||
|
BOOKINGTIME = thirdBookingEnt.BookingDate.ToString("HH:mm:ss"), |
||||
|
BOOKINGTYPE = "1", |
||||
|
BOOKINGTYPEELSEDESC = "", |
||||
|
CONFIRMORG = "MINZ", |
||||
|
CONFIRMORGCENTERDESC = "民众", |
||||
|
CONFIRMTIME = patientRegisterEnt.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"), |
||||
|
CONFIRMTYPE = "1", |
||||
|
EXAMPACKAGECODE = thirdBookingEnt.CustomerOrgGroupId, |
||||
|
EXAMPACKAGEDESC = customerOrgGroupEnt.DisplayName, |
||||
|
IDNO = thirdBookingEnt.IdNo, |
||||
|
IDTYPE = thirdBookingEnt.IdType, |
||||
|
MOBILE = thirdBookingEnt.Phone, |
||||
|
NAME = patientRegisterEnt.PatientName, |
||||
|
SOURCE = "BjGJ", |
||||
|
YEAR = "2024" |
||||
|
}; |
||||
|
|
||||
|
var inputPara = GetEncryptData(JsonConvert.SerializeObject(pushRegisterInput), iCode, publicKey, privateKey); |
||||
|
|
||||
|
await CallBookingAppServiceAsync<EncryDataRequstDto, EncryDataResultDto>(baseApiAddress, registerApiAddress, inputPara); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 推送完成体检数据
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/ThirdBookingPush/PushCompletePhysical")] |
||||
|
public async Task PushCompletePhysicalAsync(PatientRegisterIdInputDto input) |
||||
|
{ |
||||
|
var thirdBookingInterface = await _thirdInterfaceRepository.FirstOrDefaultAsync(o => o.ThirdInterfaceType == |
||||
|
ThirdInterfaceTypeFlag.ThirdBooking); |
||||
|
if (thirdBookingInterface != null && thirdBookingInterface.IsActive == 'Y') |
||||
|
{ |
||||
|
|
||||
|
var parmValue = thirdBookingInterface.ParmValue; |
||||
|
var configurationBuilder = new ConfigurationBuilder() |
||||
|
.AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); |
||||
|
var interfaceConfig = configurationBuilder.Build(); |
||||
|
var baseApiAddress = interfaceConfig.GetSection("Interface").GetSection("BaseApiAddress").Value; |
||||
|
var completeApiAddress = interfaceConfig.GetSection("Interface").GetSection("CompleteApiAddress").Value; |
||||
|
var publicKey = interfaceConfig.GetSection("Interface").GetSection("YuanFuPublicKey").Value; |
||||
|
var privateKey = interfaceConfig.GetSection("Interface").GetSection("MinZhongPrivateKey").Value; |
||||
|
var iCode = interfaceConfig.GetSection("Interface").GetSection("ICODE").Value; |
||||
|
var isActive = interfaceConfig.GetSection("Interface").GetSection("IsActive").Value; |
||||
|
if (!string.IsNullOrWhiteSpace(isActive) |
||||
|
&& isActive == "Y") |
||||
|
{ |
||||
|
|
||||
|
var patientRegisterEnt = await _patientRegisterRepository.GetAsync(input.PatientRegisterId); |
||||
|
|
||||
|
if (patientRegisterEnt != null && string.IsNullOrWhiteSpace(patientRegisterEnt.ThirdBookingId)) |
||||
|
{ |
||||
|
var thirdBookingEnt = await _thirdBookingRepository.FirstOrDefaultAsync(f => f.Id == Guid.Parse(patientRegisterEnt.ThirdBookingId)); |
||||
|
|
||||
|
var customerOrgGroupEnt = await _customerOrgGroupRepository.GetAsync(g => g.Id == Guid.Parse(thirdBookingEnt.CustomerOrgGroupId)); |
||||
|
|
||||
|
var pushCompletePhysicalInput = new PushCompletePhysicalInputDto |
||||
|
{ |
||||
|
BOOKINGDATE = thirdBookingEnt.BookingDate.ToString("yyyy-MM-dd"), |
||||
|
BOOKINGDATEDESC = "", |
||||
|
BOOKINGID = patientRegisterEnt.ThirdBookingId, |
||||
|
BOOKINGTIME = thirdBookingEnt.BookingDate.ToString("HH:mm:ss"), |
||||
|
BOOKINGTYPE = "1", |
||||
|
BOOKINGTYPEELSEDESC = "", |
||||
|
CONFIRMORG = "MINZ", |
||||
|
CONFIRMORGCENTERDESC = "民众", |
||||
|
CONFIRMTIME = patientRegisterEnt.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"), |
||||
|
CONFIRMTYPE = "1", |
||||
|
EXAMPACKAGECODE = thirdBookingEnt.CustomerOrgGroupId, |
||||
|
EXAMPACKAGEDESC = customerOrgGroupEnt.DisplayName, |
||||
|
IDNO = thirdBookingEnt.IdNo, |
||||
|
IDTYPE = thirdBookingEnt.IdType, |
||||
|
MOBILE = thirdBookingEnt.Phone, |
||||
|
NAME = patientRegisterEnt.PatientName, |
||||
|
SOURCE = "BjGJ", |
||||
|
YEAR = "2024", |
||||
|
AGE = patientRegisterEnt.Age == null ? (short)0 : patientRegisterEnt.Age.Value, |
||||
|
BIRTHDAY = patientRegisterEnt.BirthDate != null ? patientRegisterEnt.BirthDate.Value.ToString("yyyy-MM-dd") : "", |
||||
|
EXAMBEGINTIME = patientRegisterEnt.MedicalStartDate != null ? patientRegisterEnt.MedicalStartDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", |
||||
|
EXAMCOMPLETETIME = patientRegisterEnt.SummaryDate != null ? patientRegisterEnt.SummaryDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", |
||||
|
EXAMID = patientRegisterEnt.Id.ToString(), |
||||
|
GENDER = GetSexId(patientRegisterEnt.SexId) |
||||
|
}; |
||||
|
|
||||
|
var inputPara = GetEncryptData(JsonConvert.SerializeObject(pushCompletePhysicalInput), iCode, publicKey, privateKey); |
||||
|
|
||||
|
await CallBookingAppServiceAsync<EncryDataRequstDto, EncryDataResultDto>(baseApiAddress, completeApiAddress, inputPara); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 发起请求
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TInput"></typeparam>
|
||||
|
/// <typeparam name="TOut"></typeparam>
|
||||
|
/// <param name="baseApiAddress"></param>
|
||||
|
/// <param name="url"></param>
|
||||
|
/// <param name="data"></param>
|
||||
|
/// <param name="method"></param>
|
||||
|
/// <returns></returns>
|
||||
|
/// <exception cref="Exception"></exception>
|
||||
|
private async Task<TOut> CallBookingAppServiceAsync<TInput, TOut>(string baseApiAddress, string url, TInput data, string method = "post") |
||||
|
{ |
||||
|
using (var httpClientHandler = new HttpClientHandler()) |
||||
|
{ |
||||
|
using (var httpClient = new HttpClient(httpClientHandler)) |
||||
|
{ |
||||
|
httpClient.BaseAddress = new Uri(baseApiAddress); |
||||
|
|
||||
|
httpClient.DefaultRequestHeaders.Accept.Add( |
||||
|
new MediaTypeWithQualityHeaderValue("application/json"));//设置accept标头,告诉JSON是可接受的响应类型
|
||||
|
|
||||
|
var sendData = JsonConvert.SerializeObject(data); |
||||
|
using (HttpContent httpContent = new StringContent(sendData)) |
||||
|
{ |
||||
|
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json;charset=utf-8"); |
||||
|
HttpResponseMessage response = null; |
||||
|
if (method == "post") |
||||
|
{ |
||||
|
response = await httpClient.PostAsync(url, httpContent); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
response = await httpClient.GetAsync(url); |
||||
|
} |
||||
|
|
||||
|
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; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 生成请求密文数据
|
||||
|
/// </summary>
|
||||
|
/// <param name="resultJson"></param>
|
||||
|
/// <param name="ICODE"></param>
|
||||
|
/// <param name="publicKey"></param>
|
||||
|
/// <param name="privateKey"></param>
|
||||
|
/// <returns></returns>
|
||||
|
private static EncryDataRequstDto GetEncryptData(string resultJson, string ICODE, string publicKey, string privateKey) |
||||
|
{ |
||||
|
string data = newRsaHelper.RSAEncrypt(resultJson, publicKey); |
||||
|
string sign = newRsaHelper.SignData(data, privateKey); |
||||
|
var result = new EncryDataRequstDto |
||||
|
{ |
||||
|
DATA = data, |
||||
|
SIGN = sign, |
||||
|
ICODE = ICODE |
||||
|
}; |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 转换性别
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
private string GetSexId(char SexId) |
||||
|
{ |
||||
|
string SexName = ""; |
||||
|
if (SexId == 'M') |
||||
|
{ |
||||
|
SexName = "0"; |
||||
|
} |
||||
|
if (SexId == 'F') |
||||
|
{ |
||||
|
SexName = "1"; |
||||
|
} |
||||
|
return SexName; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,132 @@ |
|||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Org.BouncyCastle.Crypto.Parameters; |
||||
|
using Org.BouncyCastle.Security; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Security.Cryptography; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Shentun.Peis |
||||
|
{ |
||||
|
public static class newRsaHelper |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
private static int _maxEncryptSize = 117; |
||||
|
private static int _maxDecryptSize = 128; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/***************以下是java提供的公私钥转成.net公私钥XML的方式*************************************/ |
||||
|
/// <summary>
|
||||
|
/// RSA公钥格式转换,java->.net
|
||||
|
/// </summary>
|
||||
|
/// <param name="publicKey">java生成的公钥</param>
|
||||
|
/// <returns></returns>
|
||||
|
public static string RSAPublicKeyJava2DotNet(string publicKey) |
||||
|
{ |
||||
|
RsaKeyParameters publicKeyParam = (RsaKeyParameters)PublicKeyFactory.CreateKey(Convert.FromBase64String(publicKey)); |
||||
|
return string.Format("<RSAKeyValue><Modulus>{0}</Modulus><Exponent>{1}</Exponent></RSAKeyValue>", |
||||
|
Convert.ToBase64String(publicKeyParam.Modulus.ToByteArrayUnsigned()), |
||||
|
Convert.ToBase64String(publicKeyParam.Exponent.ToByteArrayUnsigned())); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// RSA私钥格式转换,java->.net
|
||||
|
/// </summary>
|
||||
|
/// <param name="privateKey">java生成的RSA私钥</param>
|
||||
|
/// <returns></returns>
|
||||
|
public static string RSAPrivateKeyJava2DotNet(string privateKey) |
||||
|
{ |
||||
|
RsaPrivateCrtKeyParameters privateKeyParam = (RsaPrivateCrtKeyParameters)PrivateKeyFactory.CreateKey(Convert.FromBase64String(privateKey)); |
||||
|
|
||||
|
return string.Format("<RSAKeyValue><Modulus>{0}</Modulus><Exponent>{1}</Exponent><P>{2}</P><Q>{3}</Q><DP>{4}</DP><DQ>{5}</DQ><InverseQ>{6}</InverseQ><D>{7}</D></RSAKeyValue>", |
||||
|
Convert.ToBase64String(privateKeyParam.Modulus.ToByteArrayUnsigned()), |
||||
|
Convert.ToBase64String(privateKeyParam.PublicExponent.ToByteArrayUnsigned()), |
||||
|
Convert.ToBase64String(privateKeyParam.P.ToByteArrayUnsigned()), |
||||
|
Convert.ToBase64String(privateKeyParam.Q.ToByteArrayUnsigned()), |
||||
|
Convert.ToBase64String(privateKeyParam.DP.ToByteArrayUnsigned()), |
||||
|
Convert.ToBase64String(privateKeyParam.DQ.ToByteArrayUnsigned()), |
||||
|
Convert.ToBase64String(privateKeyParam.QInv.ToByteArrayUnsigned()), |
||||
|
Convert.ToBase64String(privateKeyParam.Exponent.ToByteArrayUnsigned())); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 加密
|
||||
|
/// </summary>
|
||||
|
/// <param name="bizContent"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public static string RSAEncrypt(string bizContent,string publicKey) |
||||
|
{ |
||||
|
|
||||
|
string yuanFuPublicKey_Net = RSAPublicKeyJava2DotNet(publicKey); |
||||
|
|
||||
|
//此处请根据需要设置集合capacity,也可不指定
|
||||
|
var encryptedData = new List<byte>(45000); |
||||
|
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) |
||||
|
{ |
||||
|
rsa.FromXmlString(yuanFuPublicKey_Net); |
||||
|
|
||||
|
int start = 0; |
||||
|
var bytes = Encoding.UTF8.GetBytes(bizContent).AsSpan(); |
||||
|
while (start < bytes.Length) |
||||
|
{ |
||||
|
var buffer = bytes.Length - start <= _maxEncryptSize |
||||
|
? bytes.Slice(start).ToArray() : bytes.Slice(start, _maxEncryptSize).ToArray(); |
||||
|
|
||||
|
encryptedData.AddRange(rsa.Encrypt(buffer, false)); |
||||
|
start += _maxEncryptSize; |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
return Convert.ToBase64String(encryptedData.ToArray()); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 签名
|
||||
|
/// </summary>
|
||||
|
/// <param name="value"></param>
|
||||
|
/// <param name="publicKey"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public static string SignData(string value,string privateKey) |
||||
|
{ |
||||
|
if (string.IsNullOrEmpty(value)) return value; |
||||
|
|
||||
|
string minZhongPrivateKey_Net = RSAPrivateKeyJava2DotNet(privateKey); |
||||
|
|
||||
|
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) |
||||
|
{ |
||||
|
rsa.FromXmlString(minZhongPrivateKey_Net); |
||||
|
|
||||
|
var buffer = Encoding.UTF8.GetBytes(value); |
||||
|
buffer = rsa.SignData(buffer, CryptoConfig.MapNameToOID("MD5")); |
||||
|
|
||||
|
return Convert.ToBase64String(buffer); |
||||
|
|
||||
|
////使用hex格式输出数据
|
||||
|
//StringBuilder result = new StringBuilder();
|
||||
|
//foreach (byte b in buffer)
|
||||
|
//{
|
||||
|
// result.AppendFormat("{0:x2}", b);
|
||||
|
//}
|
||||
|
//return result.ToString();
|
||||
|
//或者使用下面的输出
|
||||
|
//return BitConverter.ToString(buffer).Replace("-", "").ToLower();
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
15959
src/Shentun.Peis.EntityFrameworkCore/Migrations/20240927133036_update_third_booking_icode.Designer.cs
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,77 @@ |
|||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace Shentun.Peis.Migrations |
||||
|
{ |
||||
|
public partial class update_third_booking_icode : Migration |
||||
|
{ |
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.AlterColumn<string>( |
||||
|
name: "third_medical_center_id", |
||||
|
table: "third_booking", |
||||
|
type: "character varying(50)", |
||||
|
maxLength: 50, |
||||
|
nullable: true, |
||||
|
comment: "第三方体检中心Id", |
||||
|
oldClrType: typeof(string), |
||||
|
oldType: "character varying(32)", |
||||
|
oldMaxLength: 32, |
||||
|
oldNullable: true, |
||||
|
oldComment: "第三方体检中心Id"); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<string>( |
||||
|
name: "customer_org_group_id", |
||||
|
table: "third_booking", |
||||
|
type: "character varying(50)", |
||||
|
maxLength: 50, |
||||
|
nullable: true, |
||||
|
comment: "单位分组ID", |
||||
|
oldClrType: typeof(string), |
||||
|
oldType: "character varying(32)", |
||||
|
oldMaxLength: 32, |
||||
|
oldNullable: true, |
||||
|
oldComment: "单位分组ID"); |
||||
|
|
||||
|
migrationBuilder.AddColumn<string>( |
||||
|
name: "icode", |
||||
|
table: "third_booking", |
||||
|
type: "text", |
||||
|
nullable: true); |
||||
|
} |
||||
|
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "icode", |
||||
|
table: "third_booking"); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<string>( |
||||
|
name: "third_medical_center_id", |
||||
|
table: "third_booking", |
||||
|
type: "character varying(32)", |
||||
|
maxLength: 32, |
||||
|
nullable: true, |
||||
|
comment: "第三方体检中心Id", |
||||
|
oldClrType: typeof(string), |
||||
|
oldType: "character varying(50)", |
||||
|
oldMaxLength: 50, |
||||
|
oldNullable: true, |
||||
|
oldComment: "第三方体检中心Id"); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<string>( |
||||
|
name: "customer_org_group_id", |
||||
|
table: "third_booking", |
||||
|
type: "character varying(32)", |
||||
|
maxLength: 32, |
||||
|
nullable: true, |
||||
|
comment: "单位分组ID", |
||||
|
oldClrType: typeof(string), |
||||
|
oldType: "character varying(50)", |
||||
|
oldMaxLength: 50, |
||||
|
oldNullable: true, |
||||
|
oldComment: "单位分组ID"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue