|
|
|
@ -13,6 +13,7 @@ using System; |
|
|
|
using System.IO; |
|
|
|
using System.Net.Http; |
|
|
|
using System.Net.Http.Headers; |
|
|
|
using System.Net.Mime; |
|
|
|
using System.Security.Policy; |
|
|
|
using System.Threading.Channels; |
|
|
|
using System.Threading.Tasks; |
|
|
|
@ -24,7 +25,7 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
|
/// <summary>
|
|
|
|
/// 推送体检信息到人寿
|
|
|
|
/// </summary>
|
|
|
|
[Authorize] |
|
|
|
//[Authorize]
|
|
|
|
[ApiExplorerSettings(GroupName = "Work")] |
|
|
|
public class ThirdBookingPushAppService : ApplicationService |
|
|
|
{ |
|
|
|
@ -235,125 +236,199 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
|
[HttpPost("api/app/ThirdBookingPush/PushReportFile")] |
|
|
|
public async Task PushReportFileAsync(PushReportFileInputDto input) |
|
|
|
{ |
|
|
|
var thirdBookingInterface = await _thirdInterfaceRepository.FirstOrDefaultAsync(o => o.ThirdInterfaceType == |
|
|
|
ThirdInterfaceTypeFlag.ThirdBooking); |
|
|
|
if (thirdBookingInterface != null && thirdBookingInterface.IsActive == 'Y') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var baseApiAddress = "https://uat-ewp.beijinglife.com.cn"; |
|
|
|
var fileUploadApiAddress = "service/file/fup"; |
|
|
|
//var reportApiAddress = interfaceConfig.GetSection("Interface").GetSection("ReportApiAddress").Value;
|
|
|
|
//var publicKey = interfaceConfig.GetSection("Interface").GetSection("YuanFuPublicKey").Value;
|
|
|
|
//var privateKey = interfaceConfig.GetSection("Interface").GetSection("MinZhongPrivateKey").Value;
|
|
|
|
var aesKey = "MZ20240417UP"; |
|
|
|
//var isActive = interfaceConfig.GetSection("Interface").GetSection("IsActive").Value;
|
|
|
|
//var medicalYear = interfaceConfig.GetSection("Interface").GetSection("MedicalYear").Value;
|
|
|
|
var iCode = "EXAMINATION_MZ"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 上传文件
|
|
|
|
byte[] filebytes = Convert.FromBase64String(input.ReportBase64); //字节数组
|
|
|
|
byte[] fileDataEncrypt = AesHelper.AESEncrypt(filebytes, aesKey); |
|
|
|
string fileSign = AesHelper.GetMD5Hash2(fileDataEncrypt); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fileInputParm = new EncryDataRequstDto |
|
|
|
{ |
|
|
|
SIGN = fileSign, |
|
|
|
ICODE = iCode |
|
|
|
}; |
|
|
|
|
|
|
|
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 aesKey = interfaceConfig.GetSection("Interface").GetSection("AesKey").Value; |
|
|
|
var isActive = interfaceConfig.GetSection("Interface").GetSection("IsActive").Value; |
|
|
|
var medicalYear = interfaceConfig.GetSection("Interface").GetSection("MedicalYear").Value; |
|
|
|
var iCode = interfaceConfig.GetSection("Interface").GetSection("ICODE").Value; |
|
|
|
if (!string.IsNullOrWhiteSpace(isActive) |
|
|
|
&& isActive == "Y") |
|
|
|
var fileResultEncry = await CallBookingFileAppServiceAsync<EncryDataResultDto>(baseApiAddress, fileUploadApiAddress, fileInputParm, fileDataEncrypt, "123.txt"); |
|
|
|
|
|
|
|
if (fileResultEncry.FLAG) |
|
|
|
{ |
|
|
|
//验签
|
|
|
|
if (fileResultEncry.SIGN == AesHelper.GetMD5Hash(fileResultEncry.DATA)) |
|
|
|
{ |
|
|
|
//解密
|
|
|
|
string fileResultStr = AesHelper.AESDecrypt(fileResultEncry.DATA, aesKey); //报文ID
|
|
|
|
|
|
|
|
var patientRegisterEnt = await _patientRegisterRepository.GetAsync(input.PatientRegisterId); |
|
|
|
|
|
|
|
if (patientRegisterEnt != null |
|
|
|
&& !string.IsNullOrWhiteSpace(patientRegisterEnt.ThirdBookingId) |
|
|
|
&& patientRegisterEnt.CompleteFlag == PatientRegisterCompleteFlag.SumCheck) |
|
|
|
{ |
|
|
|
var thirdBookingEnt = await _thirdBookingRepository.FirstOrDefaultAsync(f => f.Id == Guid.Parse(patientRegisterEnt.ThirdBookingId)); |
|
|
|
if (thirdBookingEnt != null) |
|
|
|
{ |
|
|
|
if (!string.IsNullOrWhiteSpace(thirdBookingEnt.ICode)) |
|
|
|
{ |
|
|
|
iCode = thirdBookingEnt.ICode; |
|
|
|
} |
|
|
|
if (thirdBookingEnt.MedicalStatus == '2') |
|
|
|
{ |
|
|
|
var customerOrgGroupEnt = await _customerOrgGroupRepository.GetAsync(g => g.Id == Guid.Parse(thirdBookingEnt.CustomerOrgGroupId)); |
|
|
|
|
|
|
|
|
|
|
|
#region 上传文件
|
|
|
|
byte[] filebytes = Convert.FromBase64String(input.ReportBase64); //字节数组
|
|
|
|
byte[] fileDataEncrypt = AesHelper.AESEncrypt(filebytes, aesKey); |
|
|
|
string fileSign = AesHelper.GetMD5Hash2(fileDataEncrypt); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fileInputParm = new EncryDataRequstDto |
|
|
|
{ |
|
|
|
SIGN = fileSign, |
|
|
|
ICODE = thirdBookingEnt.ICode |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
var fileResultEncry = await CallBookingFileAppServiceAsync<EncryDataResultDto>(baseApiAddress, completeApiAddress, fileInputParm, fileDataEncrypt, "006429_民众测试.pdf"); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
if (fileResultEncry.FLAG) |
|
|
|
{ |
|
|
|
//验签
|
|
|
|
if (fileResultEncry.SIGN == AesHelper.GetMD5Hash(fileResultEncry.DATA)) |
|
|
|
{ |
|
|
|
//解密
|
|
|
|
string fileResultStr = AesHelper.AESDecrypt(fileResultEncry.DATA, aesKey); //报文ID
|
|
|
|
|
|
|
|
|
|
|
|
#region 上传报告
|
|
|
|
|
|
|
|
var pushMedicalReportInput = new PushMedicalReportInputDto |
|
|
|
{ |
|
|
|
EXAMPACKAGECODE = thirdBookingEnt.CustomerOrgGroupId, |
|
|
|
IDNO = thirdBookingEnt.IdNo, |
|
|
|
IDTYPE = thirdBookingEnt.IdType, |
|
|
|
NAME = patientRegisterEnt.PatientName, |
|
|
|
SOURCE = "BjGJ", |
|
|
|
YEAR = medicalYear, |
|
|
|
BUSINESSID = patientRegisterEnt.Id.ToString(), |
|
|
|
JSONBASE64 = "", |
|
|
|
ORGCODE = "MINZ", |
|
|
|
PDFBASE64 = "", |
|
|
|
PDFFILEID = fileResultStr, |
|
|
|
PUSHTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var pushMedicalReportInputEncrypt = GetEncryptData(JsonConvert.SerializeObject(pushMedicalReportInput), iCode, publicKey, privateKey); |
|
|
|
|
|
|
|
var reportResultPara = await CallBookingAppServiceAsync<EncryDataRequstDto, EncryDataResultDto>(baseApiAddress, completeApiAddress, pushMedicalReportInputEncrypt, "application/json;charset=utf-8"); |
|
|
|
|
|
|
|
if (reportResultPara.FLAG) |
|
|
|
{ |
|
|
|
var decryptDataPara = GetDecryptData<PushReportDecryptDto>(reportResultPara, publicKey, privateKey); |
|
|
|
if (decryptDataPara.FLAG == true) |
|
|
|
{ |
|
|
|
thirdBookingEnt.MedicalStatus = '3'; |
|
|
|
await _thirdBookingRepository.UpdateAsync(thirdBookingEnt); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
///// 推送体检报告
|
|
|
|
///// </summary>
|
|
|
|
///// <returns></returns>
|
|
|
|
//[HttpPost("api/app/ThirdBookingPush/PushReportFile")]
|
|
|
|
//public async Task PushReportFileAsync(PushReportFileInputDto 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 fileUploadApiAddress = interfaceConfig.GetSection("Interface").GetSection("FileUploadApiAddress").Value;
|
|
|
|
// var reportApiAddress = interfaceConfig.GetSection("Interface").GetSection("ReportApiAddress").Value;
|
|
|
|
// var publicKey = interfaceConfig.GetSection("Interface").GetSection("YuanFuPublicKey").Value;
|
|
|
|
// var privateKey = interfaceConfig.GetSection("Interface").GetSection("MinZhongPrivateKey").Value;
|
|
|
|
// var aesKey = interfaceConfig.GetSection("Interface").GetSection("AesKey").Value;
|
|
|
|
// var isActive = interfaceConfig.GetSection("Interface").GetSection("IsActive").Value;
|
|
|
|
// var medicalYear = interfaceConfig.GetSection("Interface").GetSection("MedicalYear").Value;
|
|
|
|
// var iCode = interfaceConfig.GetSection("Interface").GetSection("ICODE").Value;
|
|
|
|
// if (!string.IsNullOrWhiteSpace(isActive)
|
|
|
|
// && isActive == "Y")
|
|
|
|
// {
|
|
|
|
|
|
|
|
// var patientRegisterEnt = await _patientRegisterRepository.GetAsync(input.PatientRegisterId);
|
|
|
|
|
|
|
|
// if (patientRegisterEnt != null
|
|
|
|
// && !string.IsNullOrWhiteSpace(patientRegisterEnt.ThirdBookingId)
|
|
|
|
// && patientRegisterEnt.CompleteFlag == PatientRegisterCompleteFlag.SumCheck)
|
|
|
|
// {
|
|
|
|
// var thirdBookingEnt = await _thirdBookingRepository.FirstOrDefaultAsync(f => f.Id == Guid.Parse(patientRegisterEnt.ThirdBookingId));
|
|
|
|
// if (thirdBookingEnt != null)
|
|
|
|
// {
|
|
|
|
// if (!string.IsNullOrWhiteSpace(thirdBookingEnt.ICode))
|
|
|
|
// {
|
|
|
|
// iCode = thirdBookingEnt.ICode;
|
|
|
|
// }
|
|
|
|
// if (thirdBookingEnt.MedicalStatus == '2')
|
|
|
|
// {
|
|
|
|
// var customerOrgGroupEnt = await _customerOrgGroupRepository.GetAsync(g => g.Id == Guid.Parse(thirdBookingEnt.CustomerOrgGroupId));
|
|
|
|
|
|
|
|
|
|
|
|
// #region 上传文件
|
|
|
|
// byte[] filebytes = Convert.FromBase64String(input.ReportBase64); //字节数组
|
|
|
|
// byte[] fileDataEncrypt = AesHelper.AESEncrypt(filebytes, aesKey);
|
|
|
|
// string fileSign = AesHelper.GetMD5Hash2(fileDataEncrypt);
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// var fileInputParm = new EncryDataRequstDto
|
|
|
|
// {
|
|
|
|
// SIGN = fileSign,
|
|
|
|
// ICODE = thirdBookingEnt.ICode
|
|
|
|
// };
|
|
|
|
|
|
|
|
// var fileResultEncry = await CallBookingFileAppServiceAsync<EncryDataResultDto>(baseApiAddress, fileUploadApiAddress, fileInputParm, fileDataEncrypt, "006429_民众测试.pdf");
|
|
|
|
|
|
|
|
// if (fileResultEncry.FLAG)
|
|
|
|
// {
|
|
|
|
// //验签
|
|
|
|
// if (fileResultEncry.SIGN == AesHelper.GetMD5Hash(fileResultEncry.DATA))
|
|
|
|
// {
|
|
|
|
// //解密
|
|
|
|
// string fileResultStr = AesHelper.AESDecrypt(fileResultEncry.DATA, aesKey); //报文ID
|
|
|
|
|
|
|
|
|
|
|
|
// #region 上传报告
|
|
|
|
|
|
|
|
// var pushMedicalReportInput = new PushMedicalReportInputDto
|
|
|
|
// {
|
|
|
|
// EXAMPACKAGECODE = thirdBookingEnt.CustomerOrgGroupId,
|
|
|
|
// IDNO = thirdBookingEnt.IdNo,
|
|
|
|
// IDTYPE = thirdBookingEnt.IdType,
|
|
|
|
// NAME = patientRegisterEnt.PatientName,
|
|
|
|
// SOURCE = "BjGJ",
|
|
|
|
// YEAR = medicalYear,
|
|
|
|
// BUSINESSID = patientRegisterEnt.Id.ToString(),
|
|
|
|
// JSONBASE64 = "",
|
|
|
|
// ORGCODE = "MINZ",
|
|
|
|
// PDFBASE64 = "",
|
|
|
|
// PDFFILEID = fileResultStr,
|
|
|
|
// PUSHTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
|
// };
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// var pushMedicalReportInputEncrypt = GetEncryptData(JsonConvert.SerializeObject(pushMedicalReportInput), iCode, publicKey, privateKey);
|
|
|
|
|
|
|
|
// var reportResultPara = await CallBookingAppServiceAsync<EncryDataRequstDto, EncryDataResultDto>(baseApiAddress, reportApiAddress, pushMedicalReportInputEncrypt, "application/json;charset=utf-8");
|
|
|
|
|
|
|
|
// if (reportResultPara.FLAG)
|
|
|
|
// {
|
|
|
|
// var decryptDataPara = GetDecryptData<PushReportDecryptDto>(reportResultPara, publicKey, privateKey);
|
|
|
|
// if (decryptDataPara.FLAG == true)
|
|
|
|
// {
|
|
|
|
// thirdBookingEnt.MedicalStatus = '3';
|
|
|
|
// await _thirdBookingRepository.UpdateAsync(thirdBookingEnt);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -446,19 +521,20 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
|
using (MultipartFormDataContent multipartContent = new MultipartFormDataContent()) |
|
|
|
{ |
|
|
|
// 添加文本字段
|
|
|
|
var icode = new StringContent(data.ICODE); |
|
|
|
icode.Headers.ContentDisposition= new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") |
|
|
|
{ |
|
|
|
Name = "ICODE" |
|
|
|
}; |
|
|
|
var sign = new StringContent(data.SIGN); |
|
|
|
icode.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") |
|
|
|
{ |
|
|
|
Name = "SIGN" |
|
|
|
}; |
|
|
|
|
|
|
|
//multipartContent.Add(new StringContent(data.ICODE), "ICODE");
|
|
|
|
//multipartContent.Add(new StringContent(data.SIGN), "SIGN");
|
|
|
|
//var icode = new StringContent(data.ICODE);
|
|
|
|
//icode.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data")
|
|
|
|
//{
|
|
|
|
// Name = "ICODE"
|
|
|
|
//};
|
|
|
|
//var sign = new StringContent(data.SIGN);
|
|
|
|
//icode.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data")
|
|
|
|
//{
|
|
|
|
// Name = "SIGN"
|
|
|
|
//};
|
|
|
|
|
|
|
|
|
|
|
|
multipartContent.Add(new StringContent(data.ICODE), "ICODE"); |
|
|
|
multipartContent.Add(new StringContent(data.SIGN), "SIGN"); |
|
|
|
// 添加文件
|
|
|
|
ByteArrayContent fileContent = new ByteArrayContent(fileBytes); |
|
|
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream"); |
|
|
|
@ -466,6 +542,8 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
|
|
|
|
|
multipartContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("multipart/form-data"); |
|
|
|
|
|
|
|
// multipartContent.Add(fileBytes, "DATA", fileName);
|
|
|
|
|
|
|
|
HttpResponseMessage response = null; |
|
|
|
|
|
|
|
response = await httpClient.PostAsync(url, multipartContent); |
|
|
|
|