|
|
@ -1,24 +1,23 @@ |
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
|
|
using Newtonsoft.Json.Converters; |
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
|
|
using Microsoft.Net.Http.Headers; |
|
|
using Newtonsoft.Json; |
|
|
using Newtonsoft.Json; |
|
|
|
|
|
using NPOI.HPSF; |
|
|
|
|
|
using NPOI.SS.Formula.Functions; |
|
|
using Shentun.Peis.Enums; |
|
|
using Shentun.Peis.Enums; |
|
|
using Shentun.Peis.Models; |
|
|
using Shentun.Peis.Models; |
|
|
using Shentun.Peis.PatientRegisters; |
|
|
using Shentun.Peis.PatientRegisters; |
|
|
using Shentun.Peis.PlugIns.Sms; |
|
|
|
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
|
|
|
using System.IO; |
|
|
using System.IO; |
|
|
using System.Linq; |
|
|
|
|
|
using System.Net.Http.Headers; |
|
|
|
|
|
using System.Net.Http; |
|
|
using System.Net.Http; |
|
|
using System.Text; |
|
|
|
|
|
|
|
|
using System.Net.Http.Headers; |
|
|
|
|
|
using System.Security.Policy; |
|
|
|
|
|
using System.Threading.Channels; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Volo.Abp.Application.Services; |
|
|
using Volo.Abp.Application.Services; |
|
|
using Volo.Abp.Domain.Repositories; |
|
|
using Volo.Abp.Domain.Repositories; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
|
|
using NPOI.POIFS.Crypt.Dsig; |
|
|
|
|
|
using NPOI.SS.Formula.Functions; |
|
|
|
|
|
|
|
|
|
|
|
namespace Shentun.Peis.ThirdBookingPushs |
|
|
namespace Shentun.Peis.ThirdBookingPushs |
|
|
{ |
|
|
{ |
|
|
@ -69,6 +68,7 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
var privateKey = interfaceConfig.GetSection("Interface").GetSection("MinZhongPrivateKey").Value; |
|
|
var privateKey = interfaceConfig.GetSection("Interface").GetSection("MinZhongPrivateKey").Value; |
|
|
var medicalYear = interfaceConfig.GetSection("Interface").GetSection("MedicalYear").Value; |
|
|
var medicalYear = interfaceConfig.GetSection("Interface").GetSection("MedicalYear").Value; |
|
|
var isActive = interfaceConfig.GetSection("Interface").GetSection("IsActive").Value; |
|
|
var isActive = interfaceConfig.GetSection("Interface").GetSection("IsActive").Value; |
|
|
|
|
|
var iCode = interfaceConfig.GetSection("Interface").GetSection("ICODE").Value; |
|
|
if (!string.IsNullOrWhiteSpace(isActive) |
|
|
if (!string.IsNullOrWhiteSpace(isActive) |
|
|
&& isActive == "Y") |
|
|
&& isActive == "Y") |
|
|
{ |
|
|
{ |
|
|
@ -79,7 +79,12 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
&& !string.IsNullOrWhiteSpace(patientRegisterEnt.ThirdBookingId)) |
|
|
&& !string.IsNullOrWhiteSpace(patientRegisterEnt.ThirdBookingId)) |
|
|
{ |
|
|
{ |
|
|
var thirdBookingEnt = await _thirdBookingRepository.FirstOrDefaultAsync(f => f.Id == Guid.Parse(patientRegisterEnt.ThirdBookingId)); |
|
|
var thirdBookingEnt = await _thirdBookingRepository.FirstOrDefaultAsync(f => f.Id == Guid.Parse(patientRegisterEnt.ThirdBookingId)); |
|
|
string iCode = thirdBookingEnt.ICode; |
|
|
|
|
|
|
|
|
if (thirdBookingEnt != null) |
|
|
|
|
|
{ |
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(thirdBookingEnt.ICode)) |
|
|
|
|
|
{ |
|
|
|
|
|
iCode = thirdBookingEnt.ICode; |
|
|
|
|
|
} |
|
|
if (thirdBookingEnt.MedicalStatus == '0') |
|
|
if (thirdBookingEnt.MedicalStatus == '0') |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
@ -109,7 +114,7 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
|
|
|
|
|
|
var inputPara = GetEncryptData(JsonConvert.SerializeObject(pushRegisterInput), iCode, publicKey, privateKey); |
|
|
var inputPara = GetEncryptData(JsonConvert.SerializeObject(pushRegisterInput), iCode, publicKey, privateKey); |
|
|
|
|
|
|
|
|
var resultPara = await CallBookingAppServiceAsync<EncryDataRequstDto, EncryDataResultDto>(baseApiAddress, registerApiAddress, inputPara, "application/json;charset=utf-8"); |
|
|
|
|
|
|
|
|
var resultPara = await CallBookingAppServiceAsync<EncryDataRequstDto, EncryDataResultDto>(baseApiAddress, registerApiAddress, inputPara, "application/json"); |
|
|
if (resultPara.FLAG) |
|
|
if (resultPara.FLAG) |
|
|
{ |
|
|
{ |
|
|
var decryptDataPara = GetDecryptData<DecryptBaseDto>(resultPara, publicKey, privateKey); |
|
|
var decryptDataPara = GetDecryptData<DecryptBaseDto>(resultPara, publicKey, privateKey); |
|
|
@ -121,6 +126,7 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -149,6 +155,7 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
var privateKey = interfaceConfig.GetSection("Interface").GetSection("MinZhongPrivateKey").Value; |
|
|
var privateKey = interfaceConfig.GetSection("Interface").GetSection("MinZhongPrivateKey").Value; |
|
|
var isActive = interfaceConfig.GetSection("Interface").GetSection("IsActive").Value; |
|
|
var isActive = interfaceConfig.GetSection("Interface").GetSection("IsActive").Value; |
|
|
var medicalYear = interfaceConfig.GetSection("Interface").GetSection("MedicalYear").Value; |
|
|
var medicalYear = interfaceConfig.GetSection("Interface").GetSection("MedicalYear").Value; |
|
|
|
|
|
var iCode = interfaceConfig.GetSection("Interface").GetSection("ICODE").Value; |
|
|
if (!string.IsNullOrWhiteSpace(isActive) |
|
|
if (!string.IsNullOrWhiteSpace(isActive) |
|
|
&& isActive == "Y") |
|
|
&& isActive == "Y") |
|
|
{ |
|
|
{ |
|
|
@ -160,7 +167,13 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
&& !string.IsNullOrWhiteSpace(patientRegisterEnt.ThirdBookingId)) |
|
|
&& !string.IsNullOrWhiteSpace(patientRegisterEnt.ThirdBookingId)) |
|
|
{ |
|
|
{ |
|
|
var thirdBookingEnt = await _thirdBookingRepository.FirstOrDefaultAsync(f => f.Id == Guid.Parse(patientRegisterEnt.ThirdBookingId)); |
|
|
var thirdBookingEnt = await _thirdBookingRepository.FirstOrDefaultAsync(f => f.Id == Guid.Parse(patientRegisterEnt.ThirdBookingId)); |
|
|
string iCode = thirdBookingEnt.ICode; |
|
|
|
|
|
|
|
|
if (thirdBookingEnt != null) |
|
|
|
|
|
{ |
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(thirdBookingEnt.ICode)) |
|
|
|
|
|
{ |
|
|
|
|
|
iCode = thirdBookingEnt.ICode; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (thirdBookingEnt.MedicalStatus == '1') |
|
|
if (thirdBookingEnt.MedicalStatus == '1') |
|
|
{ |
|
|
{ |
|
|
var customerOrgGroupEnt = await _customerOrgGroupRepository.GetAsync(g => g.Id == Guid.Parse(thirdBookingEnt.CustomerOrgGroupId)); |
|
|
var customerOrgGroupEnt = await _customerOrgGroupRepository.GetAsync(g => g.Id == Guid.Parse(thirdBookingEnt.CustomerOrgGroupId)); |
|
|
@ -195,7 +208,7 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
|
|
|
|
|
|
var inputPara = GetEncryptData(JsonConvert.SerializeObject(pushCompletePhysicalInput), iCode, publicKey, privateKey); |
|
|
var inputPara = GetEncryptData(JsonConvert.SerializeObject(pushCompletePhysicalInput), iCode, publicKey, privateKey); |
|
|
|
|
|
|
|
|
var resultPara = await CallBookingAppServiceAsync<EncryDataRequstDto, EncryDataResultDto>(baseApiAddress, completeApiAddress, inputPara, "application/json;charset=utf-8"); |
|
|
|
|
|
|
|
|
var resultPara = await CallBookingAppServiceAsync<EncryDataRequstDto, EncryDataResultDto>(baseApiAddress, completeApiAddress, inputPara, "application/json"); |
|
|
|
|
|
|
|
|
if (resultPara.FLAG) |
|
|
if (resultPara.FLAG) |
|
|
{ |
|
|
{ |
|
|
@ -208,6 +221,7 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -237,6 +251,7 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
var aesKey = interfaceConfig.GetSection("Interface").GetSection("AesKey").Value; |
|
|
var aesKey = interfaceConfig.GetSection("Interface").GetSection("AesKey").Value; |
|
|
var isActive = interfaceConfig.GetSection("Interface").GetSection("IsActive").Value; |
|
|
var isActive = interfaceConfig.GetSection("Interface").GetSection("IsActive").Value; |
|
|
var medicalYear = interfaceConfig.GetSection("Interface").GetSection("MedicalYear").Value; |
|
|
var medicalYear = interfaceConfig.GetSection("Interface").GetSection("MedicalYear").Value; |
|
|
|
|
|
var iCode = interfaceConfig.GetSection("Interface").GetSection("ICODE").Value; |
|
|
if (!string.IsNullOrWhiteSpace(isActive) |
|
|
if (!string.IsNullOrWhiteSpace(isActive) |
|
|
&& isActive == "Y") |
|
|
&& isActive == "Y") |
|
|
{ |
|
|
{ |
|
|
@ -248,24 +263,31 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
&& patientRegisterEnt.CompleteFlag == PatientRegisterCompleteFlag.SumCheck) |
|
|
&& patientRegisterEnt.CompleteFlag == PatientRegisterCompleteFlag.SumCheck) |
|
|
{ |
|
|
{ |
|
|
var thirdBookingEnt = await _thirdBookingRepository.FirstOrDefaultAsync(f => f.Id == Guid.Parse(patientRegisterEnt.ThirdBookingId)); |
|
|
var thirdBookingEnt = await _thirdBookingRepository.FirstOrDefaultAsync(f => f.Id == Guid.Parse(patientRegisterEnt.ThirdBookingId)); |
|
|
string iCode = thirdBookingEnt.ICode; |
|
|
|
|
|
|
|
|
if (thirdBookingEnt != null) |
|
|
|
|
|
{ |
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(thirdBookingEnt.ICode)) |
|
|
|
|
|
{ |
|
|
|
|
|
iCode = thirdBookingEnt.ICode; |
|
|
|
|
|
} |
|
|
if (thirdBookingEnt.MedicalStatus == '2') |
|
|
if (thirdBookingEnt.MedicalStatus == '2') |
|
|
{ |
|
|
{ |
|
|
var customerOrgGroupEnt = await _customerOrgGroupRepository.GetAsync(g => g.Id == Guid.Parse(thirdBookingEnt.CustomerOrgGroupId)); |
|
|
var customerOrgGroupEnt = await _customerOrgGroupRepository.GetAsync(g => g.Id == Guid.Parse(thirdBookingEnt.CustomerOrgGroupId)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 上传文件
|
|
|
#region 上传文件
|
|
|
byte[] filebytes = Convert.FromBase64String(input.ReportBase64); |
|
|
|
|
|
string fileDataEncrypt = AesHelper.AESEncrypt(filebytes, aesKey); |
|
|
|
|
|
string fileSign = AesHelper.GetMD5Hash(fileDataEncrypt); |
|
|
|
|
|
|
|
|
byte[] filebytes = Convert.FromBase64String(input.ReportBase64); //字节数组
|
|
|
|
|
|
byte[] fileDataEncrypt = AesHelper.AESEncrypt(filebytes, aesKey); |
|
|
|
|
|
string fileSign = AesHelper.GetMD5Hash2(fileDataEncrypt); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fileInputParm = new EncryDataRequstDto |
|
|
var fileInputParm = new EncryDataRequstDto |
|
|
{ |
|
|
{ |
|
|
DATA = fileDataEncrypt, |
|
|
|
|
|
SIGN = fileSign, |
|
|
SIGN = fileSign, |
|
|
ICODE = thirdBookingEnt.ICode |
|
|
ICODE = thirdBookingEnt.ICode |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
var fileResultEncry = await CallBookingAppServiceAsync<EncryDataRequstDto, EncryDataResultDto>(baseApiAddress, completeApiAddress, fileInputParm, "multipart/form-data"); |
|
|
|
|
|
|
|
|
var fileResultEncry = await CallBookingFileAppServiceAsync<EncryDataResultDto>(baseApiAddress, completeApiAddress, fileInputParm, fileDataEncrypt, "006429_民众测试.pdf"); |
|
|
|
|
|
|
|
|
if (fileResultEncry.FLAG) |
|
|
if (fileResultEncry.FLAG) |
|
|
{ |
|
|
{ |
|
|
@ -323,6 +345,7 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -359,7 +382,11 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
var sendData = JsonConvert.SerializeObject(data); |
|
|
var sendData = JsonConvert.SerializeObject(data); |
|
|
using (HttpContent httpContent = new StringContent(sendData)) |
|
|
using (HttpContent httpContent = new StringContent(sendData)) |
|
|
{ |
|
|
{ |
|
|
httpContent.Headers.ContentType = new MediaTypeHeaderValue(contentType); |
|
|
|
|
|
|
|
|
var mediaTypeHeaderValue = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType); |
|
|
|
|
|
mediaTypeHeaderValue.CharSet = "utf-8"; |
|
|
|
|
|
|
|
|
|
|
|
httpContent.Headers.ContentType = mediaTypeHeaderValue; |
|
|
|
|
|
|
|
|
HttpResponseMessage response = null; |
|
|
HttpResponseMessage response = null; |
|
|
if (method == "post") |
|
|
if (method == "post") |
|
|
{ |
|
|
{ |
|
|
@ -389,6 +416,85 @@ namespace Shentun.Peis.ThirdBookingPushs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 发起请求 上传文件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="TOut"></typeparam>
|
|
|
|
|
|
/// <param name="baseApiAddress"></param>
|
|
|
|
|
|
/// <param name="url"></param>
|
|
|
|
|
|
/// <param name="data"></param>
|
|
|
|
|
|
/// <param name="fileBytes"></param>
|
|
|
|
|
|
/// <param name="fileName"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
private async Task<TOut> CallBookingFileAppServiceAsync<TOut>(string baseApiAddress, string url, EncryDataRequstDto data, byte[] fileBytes, string fileName) |
|
|
|
|
|
{ |
|
|
|
|
|
using (var httpClientHandler = new HttpClientHandler()) |
|
|
|
|
|
{ |
|
|
|
|
|
using (var httpClient = new HttpClient(httpClientHandler)) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
httpClient.Timeout = TimeSpan.FromMilliseconds(600000); |
|
|
|
|
|
|
|
|
|
|
|
httpClient.BaseAddress = new Uri(baseApiAddress); |
|
|
|
|
|
|
|
|
|
|
|
httpClient.DefaultRequestHeaders.Accept.Add( |
|
|
|
|
|
new MediaTypeWithQualityHeaderValue("application/json"));//设置accept标头,告诉JSON是可接受的响应类型
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
// 添加文件
|
|
|
|
|
|
ByteArrayContent fileContent = new ByteArrayContent(fileBytes); |
|
|
|
|
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream"); |
|
|
|
|
|
multipartContent.Add(fileContent, "DATA", fileName); |
|
|
|
|
|
|
|
|
|
|
|
multipartContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("multipart/form-data"); |
|
|
|
|
|
|
|
|
|
|
|
HttpResponseMessage response = null; |
|
|
|
|
|
|
|
|
|
|
|
response = await httpClient.PostAsync(url, multipartContent); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//// 创建MultipartFormDataContent实例
|
|
|
|
|
|
//MultipartFormDataContent multipartContent = new MultipartFormDataContent();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 生成请求密文数据
|
|
|
/// 生成请求密文数据
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|