Browse Source

推送逻辑,导入excel生成预约ID

master
wxd 1 year ago
parent
commit
97e47e1237
  1. 60
      src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs
  2. 284
      src/Shentun.Peis.Application/ThirdBookingPushs/ThirdBookingPushAppService.cs
  3. 18
      src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs
  4. 4
      src/Shentun.Peis.DbMigrator/appsettings.json
  5. 118
      src/Shentun.Peis.Domain/AesHelper.cs
  6. 2
      src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs

60
src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs

@ -32,6 +32,7 @@ using Shentun.Peis.SumSummaryContents;
using Shentun.Peis.SumSummaryHeaders; using Shentun.Peis.SumSummaryHeaders;
using Shentun.Peis.SumSummaryReports; using Shentun.Peis.SumSummaryReports;
using Shentun.Peis.SysParmValues; using Shentun.Peis.SysParmValues;
using Shentun.Peis.ThirdBookingPushs;
using Shentun.Utilities; using Shentun.Utilities;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -129,7 +130,7 @@ namespace Shentun.Peis.PatientRegisters
private readonly IRepository<PatientPoison> _patientPoisonRepository; private readonly IRepository<PatientPoison> _patientPoisonRepository;
private readonly PatientPoisonManager _patientPoisonManager; private readonly PatientPoisonManager _patientPoisonManager;
private readonly IRepository<Diagnosis> _diagnosisRepository; private readonly IRepository<Diagnosis> _diagnosisRepository;
private readonly ThirdBookingPushAppService _thirdBookingPushAppService;
public PatientRegisterAppService( public PatientRegisterAppService(
IRepository<PatientRegister, Guid> repository, IRepository<PatientRegister, Guid> repository,
IRepository<Patient, Guid> patientRepository, IRepository<Patient, Guid> patientRepository,
@ -189,7 +190,8 @@ namespace Shentun.Peis.PatientRegisters
IRepository<PatientOccupationalDisease, Guid> patientOccupationalDiseaseRepository, IRepository<PatientOccupationalDisease, Guid> patientOccupationalDiseaseRepository,
IRepository<PatientPoison> patientPoisonRepository, IRepository<PatientPoison> patientPoisonRepository,
PatientPoisonManager patientPoisonManager, PatientPoisonManager patientPoisonManager,
IRepository<Diagnosis> diagnosisRepository)
IRepository<Diagnosis> diagnosisRepository,
ThirdBookingPushAppService thirdBookingPushAppService)
: base(repository) : base(repository)
{ {
this._repository = repository; this._repository = repository;
@ -251,6 +253,7 @@ namespace Shentun.Peis.PatientRegisters
_patientPoisonRepository = patientPoisonRepository; _patientPoisonRepository = patientPoisonRepository;
_patientPoisonManager = patientPoisonManager; _patientPoisonManager = patientPoisonManager;
_diagnosisRepository = diagnosisRepository; _diagnosisRepository = diagnosisRepository;
_thirdBookingPushAppService = thirdBookingPushAppService;
} }
/// <summary> /// <summary>
/// 获取通过主键 /// 获取通过主键
@ -885,28 +888,6 @@ namespace Shentun.Peis.PatientRegisters
// return dto; // return dto;
//} //}
/// <summary>
/// 创建 登记档案 用这个 返回信息包含了档案跟登记信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/patientregister/createreturninfo")]
[RemoteService(false)]
public async Task<PatientRegisterOrNoDto> CreateReturnInfoAsync(CreatePatientRegisterDto input)
{
throw new UserFriendlyException("改接口已经禁止使用");
PatientRegisterOrNoDto msg = new PatientRegisterOrNoDto();
var createEntity = ObjectMapper.Map<CreatePatientRegisterDto, PatientRegister>(input);
var createPatientEntity = ObjectMapper.Map<CreatePatientRegisterDto, Patient>(input);
var entity = await _manager.CreateAsync(createEntity, createPatientEntity, input.IsMaxMedicalTimes);
if (entity != null)
{
msg = await GetPatientRegisterOrNo(entity.Id);
}
return msg;
}
/// <summary> /// <summary>
/// 新版人员登记 /// 新版人员登记
@ -1003,7 +984,13 @@ namespace Shentun.Peis.PatientRegisters
} }
#region 推送人寿状态
if (!string.IsNullOrWhiteSpace(input.ThirdBookingId))
{
await _thirdBookingPushAppService.PushRegisterAsync(new PatientRegisterIdInputDto { PatientRegisterId = entity.Id });
}
#endregion
//throw new Exception("后续不更新"); //throw new Exception("后续不更新");
if (createRegisterCheckAsbitemEntity != null) if (createRegisterCheckAsbitemEntity != null)
@ -2216,7 +2203,14 @@ namespace Shentun.Peis.PatientRegisters
var entity = await _repository.GetAsync(input.PatientRegisterId); var entity = await _repository.GetAsync(input.PatientRegisterId);
var entitydto = ObjectMapper.Map<UpdatePatientRegisterAuditorDoctorDto, PatientRegister>(input); var entitydto = ObjectMapper.Map<UpdatePatientRegisterAuditorDoctorDto, PatientRegister>(input);
var newentity = await _manager.UpdatePatientRegisterAuditorDoctorAsync(entitydto, entity); var newentity = await _manager.UpdatePatientRegisterAuditorDoctorAsync(entitydto, entity);
#region 推送人寿体检完成状态
if (!string.IsNullOrWhiteSpace(entity.ThirdBookingId)
&& input.IsAudit == 'Y')
{
await _thirdBookingPushAppService.PushCompletePhysicalAsync(new PatientRegisterIdInputDto { PatientRegisterId = entity.Id });
}
#endregion
return ObjectMapper.Map<PatientRegister, PatientRegisterDto>(newentity); return ObjectMapper.Map<PatientRegister, PatientRegisterDto>(newentity);
} }
@ -2635,6 +2629,24 @@ namespace Shentun.Peis.PatientRegisters
PatientRegister patientRegister = null; PatientRegister patientRegister = null;
CreateRegisterCheckAsbitemEntity createRegisterCheckAsbitemEntity = null; CreateRegisterCheckAsbitemEntity createRegisterCheckAsbitemEntity = null;
patientRegister = await _manager.CreateAsync(createPatientRegisterArg); patientRegister = await _manager.CreateAsync(createPatientRegisterArg);
#region 人寿的信息生成一个预约ID
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 customerOrgRegisterId = interfaceConfig.GetSection("Interface").GetSection("CustomerOrgRegisterId").Value;
if (customerOrgRegisterId == input.CustomerOrgRegisterId.ToString())
{
patientRegister.ThirdBookingId = patientRegister.Id;
}
}
#endregion
if (customerOrgGroupId != null) if (customerOrgGroupId != null)
await _patientRegisterManager.SetCustomerOrgGroupId(patientRegister, (Guid)customerOrgGroupId); await _patientRegisterManager.SetCustomerOrgGroupId(patientRegister, (Guid)customerOrgGroupId);
await _repository.InsertAsync(patientRegister, true); await _repository.InsertAsync(patientRegister, true);

284
src/Shentun.Peis.Application/ThirdBookingPushs/ThirdBookingPushAppService.cs

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Net.Http.Headers; using Microsoft.Net.Http.Headers;
@ -9,12 +10,15 @@ 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 Spire.Pdf.Exporting.XPS.Schema;
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net.Http; using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Net.Mime; using System.Net.Mime;
using System.Security.Policy; using System.Security.Policy;
using System.Text;
using System.Threading.Channels; using System.Threading.Channels;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
@ -235,200 +239,127 @@ namespace Shentun.Peis.ThirdBookingPushs
/// <returns></returns> /// <returns></returns>
[HttpPost("api/app/ThirdBookingPush/PushReportFile")] [HttpPost("api/app/ThirdBookingPush/PushReportFile")]
public async Task PushReportFileAsync(PushReportFileInputDto input) 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);
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";
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 上传文件 #region 上传文件
byte[] filebytes = Convert.FromBase64String(input.ReportBase64); //字节数组 byte[] filebytes = Convert.FromBase64String(input.ReportBase64); //字节数组
byte[] fileDataEncrypt = AesHelper.AESEncrypt(filebytes, aesKey); byte[] fileDataEncrypt = AesHelper.AESEncrypt(filebytes, aesKey);
string fileSign = AesHelper.GetMD5Hash2(fileDataEncrypt);
string fileSign = AesHelper.GetMD5Hash(fileDataEncrypt);
var fileInputParm = new EncryDataRequstDto var fileInputParm = new EncryDataRequstDto
{ {
SIGN = fileSign, SIGN = fileSign,
ICODE = iCode
ICODE = thirdBookingEnt.ICode
}; };
var fileResultEncry = await CallBookingFileAppServiceAsync<EncryDataResultDto>(baseApiAddress, fileUploadApiAddress, fileInputParm, fileDataEncrypt, "123.txt");
var fileResultEncry = await CallBookingFileAppServiceAsync<EncryDataResultDto>(baseApiAddress, fileUploadApiAddress, fileInputParm, fileDataEncrypt, $"{input.PatientRegisterId.ToString()}.pdf");
if (fileResultEncry.FLAG) if (fileResultEncry.FLAG)
{ {
//验签 //验签
if (fileResultEncry.SIGN == AesHelper.GetMD5Hash(fileResultEncry.DATA))
if (fileResultEncry.SIGN == AesHelper.GetMD5(fileResultEncry.DATA))
{ {
//解密 //解密
string fileResultStr = AesHelper.AESDecrypt(fileResultEncry.DATA, aesKey); //报文ID
string fileId = Encoding.UTF8.GetString(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 = fileId,
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");
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
#endregion
// }
// }
// }
}
}
}
// }
// }
}
}
//}
}
@ -503,53 +434,31 @@ namespace Shentun.Peis.ThirdBookingPushs
/// <returns></returns> /// <returns></returns>
private async Task<TOut> CallBookingFileAppServiceAsync<TOut>(string baseApiAddress, string url, EncryDataRequstDto data, byte[] fileBytes, string fileName) 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"
//};
var multipartContent = new MultipartFormDataContent();
multipartContent.Add(new StringContent(data.ICODE), "ICODE"); multipartContent.Add(new StringContent(data.ICODE), "ICODE");
multipartContent.Add(new StringContent(data.SIGN), "SIGN"); multipartContent.Add(new StringContent(data.SIGN), "SIGN");
// 添加文件
ByteArrayContent fileContent = new ByteArrayContent(fileBytes); ByteArrayContent fileContent = new ByteArrayContent(fileBytes);
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
multipartContent.Add(fileContent, "DATA", fileName);
fileContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data");
fileContent.Headers.ContentDisposition.Name = "DATA";
fileContent.Headers.ContentDisposition.FileName = fileName;
multipartContent.Add(fileContent);
multipartContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("multipart/form-data");
// multipartContent.Add(fileBytes, "DATA", fileName);
var httpClient = new HttpClient();
httpClient.Timeout = TimeSpan.FromMinutes(5);
httpClient.BaseAddress = new Uri(baseApiAddress);
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));//设置accept标头,告诉JSON是可接受的响应类型
HttpResponseMessage response = null; HttpResponseMessage response = null;
response = await httpClient.PostAsync(url, multipartContent); response = await httpClient.PostAsync(url, multipartContent);
string result; string result;
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{ {
@ -561,15 +470,12 @@ namespace Shentun.Peis.ThirdBookingPushs
var resultDto = JsonConvert.DeserializeObject<TOut>(result); var resultDto = JsonConvert.DeserializeObject<TOut>(result);
return resultDto; return resultDto;
}
//// 创建MultipartFormDataContent实例
//MultipartFormDataContent multipartContent = new MultipartFormDataContent();
}
}
} }

18
src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs

@ -36,6 +36,7 @@ using System.Threading;
using NPOI.HSSF.Record.Chart; using NPOI.HSSF.Record.Chart;
using System.IdentityModel.Tokens.Jwt; using System.IdentityModel.Tokens.Jwt;
using Shentun.Peis.PlugIns.Sms; using Shentun.Peis.PlugIns.Sms;
using Shentun.Peis.ThirdBookingPushs;
namespace Shentun.Peis.TransToWebPeis namespace Shentun.Peis.TransToWebPeis
{ {
@ -63,6 +64,7 @@ namespace Shentun.Peis.TransToWebPeis
private readonly PrintReportAppService _printReportAppService; private readonly PrintReportAppService _printReportAppService;
private readonly IConfiguration _configuration; private readonly IConfiguration _configuration;
private readonly IRepository<Patient, Guid> _patientRepository; private readonly IRepository<Patient, Guid> _patientRepository;
private readonly ThirdBookingPushAppService _thirdBookingPushAppService;
private readonly SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig() private readonly SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
{ {
@ -98,7 +100,8 @@ namespace Shentun.Peis.TransToWebPeis
UnitOfWorkManager unitOfWorkManager, UnitOfWorkManager unitOfWorkManager,
PrintReportAppService printReportAppService, PrintReportAppService printReportAppService,
IConfiguration configuration, IConfiguration configuration,
IRepository<Patient, Guid> patientRepository)
IRepository<Patient, Guid> patientRepository,
ThirdBookingPushAppService thirdBookingPushAppService)
{ {
_itemTypeRepository = itemTypeRepository; _itemTypeRepository = itemTypeRepository;
_logger = logger; _logger = logger;
@ -119,6 +122,7 @@ namespace Shentun.Peis.TransToWebPeis
_printReportAppService = printReportAppService; _printReportAppService = printReportAppService;
_configuration = configuration; _configuration = configuration;
_patientRepository = patientRepository; _patientRepository = patientRepository;
_thirdBookingPushAppService = thirdBookingPushAppService;
} }
@ -137,6 +141,8 @@ namespace Shentun.Peis.TransToWebPeis
if (isPatientRegister.CompleteFlag != PatientRegisterCompleteFlag.SumCheck) if (isPatientRegister.CompleteFlag != PatientRegisterCompleteFlag.SumCheck)
throw new UserFriendlyException("人员未总检,无法上传"); throw new UserFriendlyException("人员未总检,无法上传");
if (string.IsNullOrWhiteSpace(isPatientRegister.ThirdBookingId))
{
//同步数据 //同步数据
await TransPatientRegisterByPatientRegisterIdAsync(new PatientRegisterIdInputDto { PatientRegisterId = input.PatientRegisterId }); await TransPatientRegisterByPatientRegisterIdAsync(new PatientRegisterIdInputDto { PatientRegisterId = input.PatientRegisterId });
@ -166,6 +172,16 @@ namespace Shentun.Peis.TransToWebPeis
//推送短信 //推送短信
await PushSmsAsync(patientRegisterEnt); await PushSmsAsync(patientRegisterEnt);
} }
else
{
//上传到人寿
await _thirdBookingPushAppService.PushReportFileAsync(new PushReportFileInputDto
{
PatientRegisterId = input.PatientRegisterId,
ReportBase64 = input.ReportBase64
});
}
}
/// <summary> /// <summary>
/// 根据人员登记ID上传人员体检信息 上传备单 /// 根据人员登记ID上传人员体检信息 上传备单

4
src/Shentun.Peis.DbMigrator/appsettings.json

@ -1,7 +1,7 @@
{ {
"ConnectionStrings": { "ConnectionStrings": {
"Default": "Host=140.143.162.39;Port=5432;Database=ShentunPeis240701;User ID=postgres;Password=shentun123;"
//"Default": "Host=192.168.2.67;Port=5432;Database=ShentunPeis;User ID=postgres;Password=st123;"
//"Default": "Host=140.143.162.39;Port=5432;Database=ShentunPeis240701;User ID=postgres;Password=shentun123;"
"Default": "Host=192.168.2.67;Port=5432;Database=ShentunPeis;User ID=postgres;Password=st123;"
//"Default": "Host=localhost;Port=5432;Database=ShentunPeis1218;User ID=postgres;Password=wxd123;" //"Default": "Host=localhost;Port=5432;Database=ShentunPeis1218;User ID=postgres;Password=wxd123;"
//"Default": "Host=10.1.12.140;Port=5432;Database=ShentunPeis0508;User ID=postgres;Password=st123;" //"Default": "Host=10.1.12.140;Port=5432;Database=ShentunPeis0508;User ID=postgres;Password=st123;"
}, },

118
src/Shentun.Peis.Domain/AesHelper.cs

@ -10,20 +10,21 @@ using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Security; using Org.BouncyCastle.Security;
using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Utilities;
using NPOI.POIFS.Crypt;
namespace Shentun.Peis namespace Shentun.Peis
{ {
public class AesHelper public class AesHelper
{ {
private static readonly byte[] Key = Encoding.UTF8.GetBytes("1234567812345678"); // 16字节密钥
private static readonly byte[] Iv = Encoding.UTF8.GetBytes("1234567812345678"); // 16字节初始化向量
//private static readonly byte[] Key = Encoding.UTF8.GetBytes("1234567812345678"); // 16字节密钥
//private static readonly byte[] Iv = Encoding.UTF8.GetBytes("1234567812345678"); // 16字节初始化向量
/// <summary> /// <summary>
/// MD5加密 /// MD5加密
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
public static string GetMD5Hash(string input)
public static string GetMD5(string input)
{ {
using (MD5 md5 = MD5.Create()) using (MD5 md5 = MD5.Create())
{ {
@ -46,7 +47,7 @@ namespace Shentun.Peis
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
public static string GetMD5Hash2(byte[] input)
public static string GetMD5Hash(byte[] input)
{ {
using (MD5 md5 = MD5.Create()) using (MD5 md5 = MD5.Create())
{ {
@ -57,90 +58,85 @@ namespace Shentun.Peis
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++) for (int i = 0; i < hashBytes.Length; i++)
{ {
sb.Append(hashBytes[i].ToString("X2"));
sb.Append(hashBytes[i].ToString("x2"));
} }
return sb.ToString(); return sb.ToString();
} }
} }
/// <summary> /// <summary>
/// 解密
/// Aes加
/// </summary> /// </summary>
/// <param name="strinput"></param>
/// <param name="strkey"></param>
/// <param name="toEncryptArray"></param>
/// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
public static string AESDecrypt(string strinput, string strkey)
public static byte[] AESEncrypt(byte[] toEncryptArray, string key)
{ {
try
{
//string dummyData = strinput.Trim().Replace("%", "").Replace(",", "").Replace(" ", "+").Replace("_", "/").Replace("-", "+");
//if (dummyData.Length % 4 > 0)
//{
// dummyData = dummyData.PadRight(dummyData.Length + 4 - dummyData.Length % 4, '=');
//}
byte[] inputArray = Convert.FromBase64String(strinput);
byte[] key = Encoding.UTF8.GetBytes(strkey);
IBufferedCipher cipher = CipherUtilities.GetCipher("AES/ECB/PKCS5Padding");
cipher.Init(false, AesKey(strkey));
// cipher.Init(false, new ParametersWithIV(new DesParameters(key), key)); 带IV向量的算法可以用到。
byte[] rv = new byte[cipher.GetOutputSize(inputArray.Length)];
int tam = cipher.ProcessBytes(inputArray, 0, inputArray.Length, rv, 0);
cipher.DoFinal(rv, tam);
return Encoding.UTF8.GetString(rv);
}
catch (Exception ex)
byte[] keyArray = null;
using (var sha1 = new SHA1CryptoServiceProvider())
{ {
byte[] hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(key));
var rd = sha1.ComputeHash(hash);
keyArray = rd.Take(16).ToArray();
}
return "";
}
RijndaelManaged rDel = new RijndaelManaged();
rDel.Key = keyArray;
rDel.Mode = CipherMode.ECB;
rDel.Padding = PaddingMode.PKCS7;
ICryptoTransform cTransform = rDel.CreateEncryptor();
byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
return resultArray;
} }
/// <summary> /// <summary>
/// 加密
/// Aes解
/// </summary> /// </summary>
/// <param name="inputArray"></param>
/// <param name="strkey"></param>
/// <param name="toDecryptArray"></param>
/// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
public static byte[] AESEncrypt(byte[] inputArray, string strkey)
{
try
public static byte[] AESDecrypt(string decryptValue, string key)
{ {
//byte[] inputArray = Encoding.UTF8.GetBytes(strinput);
byte[] key = Encoding.UTF8.GetBytes(strkey);
IBufferedCipher cipher = CipherUtilities.GetCipher("AES/ECB/PKCS5Padding");
//cipher.Init(true, new ParametersWithIV(new DesParameters(key), key));
cipher.Init(true, AesKey(strkey));
byte[] rv = new byte[cipher.GetOutputSize(inputArray.Length)];
int tam = cipher.ProcessBytes(inputArray, 0, inputArray.Length, rv, 0);
cipher.DoFinal(rv, tam);
//return Convert.ToBase64String(rv);
return rv;
}
catch (Exception ex)
byte[] toDecryptArray = ParseHexStr2Byte(decryptValue);
byte[] keyArray = null;
using (var sha1 = new SHA1CryptoServiceProvider())
{ {
return null;
}
byte[] hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(key));
var rd = sha1.ComputeHash(hash);
keyArray = rd.Take(16).ToArray();
} }
RijndaelManaged rDel = new RijndaelManaged();
rDel.Key = keyArray;
rDel.Mode = CipherMode.ECB; // 注意:ECB模式不推荐用于生产环境
rDel.Padding = PaddingMode.PKCS7;
ICryptoTransform cTransform = rDel.CreateDecryptor();
byte[] resultArray = cTransform.TransformFinalBlock(toDecryptArray, 0, toDecryptArray.Length);
return resultArray;
}
public static KeyParameter AesKey(String key)
/// <summary>
/// 16进制转二进制
/// </summary>
/// <param name="hexStr"></param>
/// <returns></returns>
public static byte[] ParseHexStr2Byte(string hexStr)
{ {
byte[] bs = Encoding.Default.GetBytes(key);
if (bs.Length != 16)
if (string.IsNullOrEmpty(hexStr))
return null;
byte[] result = new byte[hexStr.Length / 2];
for (int i = 0; i < hexStr.Length / 2; i++)
{ {
bs = Arrays.CopyOf(bs, 16);// 处理数组长度为16(不足16位,不空;超过16位取前16位)
int high = Convert.ToInt32(hexStr.Substring(i * 2, 1), 16);
int low = Convert.ToInt32(hexStr.Substring(i * 2 + 1, 1), 16);
result[i] = (byte)(high * 16 + low);
} }
return new KeyParameter(bs);
return result;
} }
} }
} }

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

@ -633,7 +633,7 @@ public class PeisHttpApiHostModule : AbpModule
app.UseConfiguredEndpoints(); app.UseConfiguredEndpoints();
//任务计划 //任务计划
await StartScheduler(context);
//await StartScheduler(context);
} }

Loading…
Cancel
Save