From 97e47e1237d142dc0a4275a41465c6ea77ac780c Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Mon, 28 Oct 2024 15:51:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=AF=BC=E5=85=A5excel=E7=94=9F=E6=88=90=E9=A2=84=E7=BA=A6ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PatientRegisterAppService.cs | 60 ++-- .../ThirdBookingPushAppService.cs | 326 +++++++----------- .../TransToWebPeisAppService.cs | 62 ++-- src/Shentun.Peis.DbMigrator/appsettings.json | 4 +- src/Shentun.Peis.Domain/AesHelper.cs | 118 +++---- .../PeisHttpApiHostModule.cs | 2 +- 6 files changed, 251 insertions(+), 321 deletions(-) diff --git a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs index d1fe1a2..a14f040 100644 --- a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs +++ b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs @@ -32,6 +32,7 @@ using Shentun.Peis.SumSummaryContents; using Shentun.Peis.SumSummaryHeaders; using Shentun.Peis.SumSummaryReports; using Shentun.Peis.SysParmValues; +using Shentun.Peis.ThirdBookingPushs; using Shentun.Utilities; using System; using System.Collections.Generic; @@ -129,7 +130,7 @@ namespace Shentun.Peis.PatientRegisters private readonly IRepository _patientPoisonRepository; private readonly PatientPoisonManager _patientPoisonManager; private readonly IRepository _diagnosisRepository; - + private readonly ThirdBookingPushAppService _thirdBookingPushAppService; public PatientRegisterAppService( IRepository repository, IRepository patientRepository, @@ -189,7 +190,8 @@ namespace Shentun.Peis.PatientRegisters IRepository patientOccupationalDiseaseRepository, IRepository patientPoisonRepository, PatientPoisonManager patientPoisonManager, - IRepository diagnosisRepository) + IRepository diagnosisRepository, + ThirdBookingPushAppService thirdBookingPushAppService) : base(repository) { this._repository = repository; @@ -251,6 +253,7 @@ namespace Shentun.Peis.PatientRegisters _patientPoisonRepository = patientPoisonRepository; _patientPoisonManager = patientPoisonManager; _diagnosisRepository = diagnosisRepository; + _thirdBookingPushAppService = thirdBookingPushAppService; } /// /// 获取通过主键 @@ -885,28 +888,6 @@ namespace Shentun.Peis.PatientRegisters // return dto; //} - /// - /// 创建 登记档案 用这个 返回信息包含了档案跟登记信息 - /// - /// - /// - [HttpPost("api/patientregister/createreturninfo")] - [RemoteService(false)] - public async Task CreateReturnInfoAsync(CreatePatientRegisterDto input) - { - throw new UserFriendlyException("改接口已经禁止使用"); - PatientRegisterOrNoDto msg = new PatientRegisterOrNoDto(); - - var createEntity = ObjectMapper.Map(input); - var createPatientEntity = ObjectMapper.Map(input); - var entity = await _manager.CreateAsync(createEntity, createPatientEntity, input.IsMaxMedicalTimes); - if (entity != null) - { - msg = await GetPatientRegisterOrNo(entity.Id); - - } - return msg; - } /// /// 新版人员登记 @@ -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("后续不更新"); if (createRegisterCheckAsbitemEntity != null) @@ -2216,7 +2203,14 @@ namespace Shentun.Peis.PatientRegisters var entity = await _repository.GetAsync(input.PatientRegisterId); var entitydto = ObjectMapper.Map(input); 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(newentity); } @@ -2635,6 +2629,24 @@ namespace Shentun.Peis.PatientRegisters PatientRegister patientRegister = null; CreateRegisterCheckAsbitemEntity createRegisterCheckAsbitemEntity = null; 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) await _patientRegisterManager.SetCustomerOrgGroupId(patientRegister, (Guid)customerOrgGroupId); await _repository.InsertAsync(patientRegister, true); diff --git a/src/Shentun.Peis.Application/ThirdBookingPushs/ThirdBookingPushAppService.cs b/src/Shentun.Peis.Application/ThirdBookingPushs/ThirdBookingPushAppService.cs index d7708a3..2a0a732 100644 --- a/src/Shentun.Peis.Application/ThirdBookingPushs/ThirdBookingPushAppService.cs +++ b/src/Shentun.Peis.Application/ThirdBookingPushs/ThirdBookingPushAppService.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Net.Http.Headers; @@ -9,12 +10,15 @@ using NPOI.SS.Formula.Functions; using Shentun.Peis.Enums; using Shentun.Peis.Models; using Shentun.Peis.PatientRegisters; +using Spire.Pdf.Exporting.XPS.Schema; using System; +using System.Collections.Generic; using System.IO; using System.Net.Http; using System.Net.Http.Headers; using System.Net.Mime; using System.Security.Policy; +using System.Text; using System.Threading.Channels; using System.Threading.Tasks; using Volo.Abp.Application.Services; @@ -236,199 +240,126 @@ namespace Shentun.Peis.ThirdBookingPushs [HttpPost("api/app/ThirdBookingPush/PushReportFile")] public async Task PushReportFileAsync(PushReportFileInputDto input) { - - - - 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 + var thirdBookingInterface = await _thirdInterfaceRepository.FirstOrDefaultAsync(o => o.ThirdInterfaceType == + ThirdInterfaceTypeFlag.ThirdBooking); + if (thirdBookingInterface != null && thirdBookingInterface.IsActive == 'Y') { - SIGN = fileSign, - ICODE = iCode - }; - - var fileResultEncry = await CallBookingFileAppServiceAsync(baseApiAddress, fileUploadApiAddress, fileInputParm, fileDataEncrypt, "123.txt"); - if (fileResultEncry.FLAG) - { - //验签 - if (fileResultEncry.SIGN == AesHelper.GetMD5Hash(fileResultEncry.DATA)) + 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") { - //解密 - string fileResultStr = AesHelper.AESDecrypt(fileResultEncry.DATA, aesKey); //报文ID - - - - - } - - - } - - #endregion - - - - - - - - - - - - - } - - ///// - ///// 推送体检报告 - ///// - ///// - //[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); + 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)); + 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); + #region 上传文件 + byte[] filebytes = Convert.FromBase64String(input.ReportBase64); //字节数组 + byte[] fileDataEncrypt = AesHelper.AESEncrypt(filebytes, aesKey); + string fileSign = AesHelper.GetMD5Hash(fileDataEncrypt); - // var fileInputParm = new EncryDataRequstDto - // { - // SIGN = fileSign, - // ICODE = thirdBookingEnt.ICode - // }; + var fileInputParm = new EncryDataRequstDto + { + SIGN = fileSign, + ICODE = thirdBookingEnt.ICode + }; - // var fileResultEncry = await CallBookingFileAppServiceAsync(baseApiAddress, fileUploadApiAddress, fileInputParm, fileDataEncrypt, "006429_民众测试.pdf"); + var fileResultEncry = await CallBookingFileAppServiceAsync(baseApiAddress, fileUploadApiAddress, fileInputParm, fileDataEncrypt, $"{input.PatientRegisterId.ToString()}.pdf"); - // if (fileResultEncry.FLAG) - // { - // //验签 - // if (fileResultEncry.SIGN == AesHelper.GetMD5Hash(fileResultEncry.DATA)) - // { - // //解密 - // string fileResultStr = AesHelper.AESDecrypt(fileResultEncry.DATA, aesKey); //报文ID + if (fileResultEncry.FLAG) + { + //验签 + if (fileResultEncry.SIGN == AesHelper.GetMD5(fileResultEncry.DATA)) + { + //解密 + string fileId = Encoding.UTF8.GetString(AesHelper.AESDecrypt(fileResultEncry.DATA, aesKey)); //报文ID - // #region 上传报告 + #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 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 pushMedicalReportInputEncrypt = GetEncryptData(JsonConvert.SerializeObject(pushMedicalReportInput), iCode, publicKey, privateKey); - // var reportResultPara = await CallBookingAppServiceAsync(baseApiAddress, reportApiAddress, pushMedicalReportInputEncrypt, "application/json;charset=utf-8"); + var reportResultPara = await CallBookingAppServiceAsync(baseApiAddress, reportApiAddress, pushMedicalReportInputEncrypt, "application/json"); - // if (reportResultPara.FLAG) - // { - // var decryptDataPara = GetDecryptData(reportResultPara, publicKey, privateKey); - // if (decryptDataPara.FLAG == true) - // { - // thirdBookingEnt.MedicalStatus = '3'; - // await _thirdBookingRepository.UpdateAsync(thirdBookingEnt); - // } - // } + if (reportResultPara.FLAG) + { + var decryptDataPara = GetDecryptData(reportResultPara, publicKey, privateKey); + if (decryptDataPara.FLAG == true) + { + thirdBookingEnt.MedicalStatus = '3'; + await _thirdBookingRepository.UpdateAsync(thirdBookingEnt); + } + } - // #endregion + #endregion - // } + } - // } + } - // #endregion + #endregion - // } - // } - // } + } + } + } - // } - // } + } + } - //} + } @@ -503,73 +434,48 @@ namespace Shentun.Peis.ThirdBookingPushs /// private async Task CallBookingFileAppServiceAsync(string baseApiAddress, string url, EncryDataRequstDto data, byte[] fileBytes, string fileName) { - using (var httpClientHandler = new HttpClientHandler()) - { - using (var httpClient = new HttpClient(httpClientHandler)) - { + var multipartContent = new MultipartFormDataContent(); + multipartContent.Add(new StringContent(data.ICODE), "ICODE"); + multipartContent.Add(new StringContent(data.SIGN), "SIGN"); - httpClient.Timeout = TimeSpan.FromMilliseconds(600000); - httpClient.BaseAddress = new Uri(baseApiAddress); + ByteArrayContent fileContent = new ByteArrayContent(fileBytes); + 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); - httpClient.DefaultRequestHeaders.Accept.Add( - new MediaTypeWithQualityHeaderValue("application/json"));//设置accept标头,告诉JSON是可接受的响应类型 + var httpClient = new HttpClient(); + httpClient.Timeout = TimeSpan.FromMinutes(5); + 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"); - - // multipartContent.Add(fileBytes, "DATA", fileName); + HttpResponseMessage response = null; - HttpResponseMessage response = null; + response = await httpClient.PostAsync(url, multipartContent); - 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(result); + return resultDto; - 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(result); - - return resultDto; - } - //// 创建MultipartFormDataContent实例 - //MultipartFormDataContent multipartContent = new MultipartFormDataContent(); - } - } } diff --git a/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs b/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs index 0993790..5606baf 100644 --- a/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs +++ b/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs @@ -36,6 +36,7 @@ using System.Threading; using NPOI.HSSF.Record.Chart; using System.IdentityModel.Tokens.Jwt; using Shentun.Peis.PlugIns.Sms; +using Shentun.Peis.ThirdBookingPushs; namespace Shentun.Peis.TransToWebPeis { @@ -63,6 +64,7 @@ namespace Shentun.Peis.TransToWebPeis private readonly PrintReportAppService _printReportAppService; private readonly IConfiguration _configuration; private readonly IRepository _patientRepository; + private readonly ThirdBookingPushAppService _thirdBookingPushAppService; private readonly SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig() { @@ -98,7 +100,8 @@ namespace Shentun.Peis.TransToWebPeis UnitOfWorkManager unitOfWorkManager, PrintReportAppService printReportAppService, IConfiguration configuration, - IRepository patientRepository) + IRepository patientRepository, + ThirdBookingPushAppService thirdBookingPushAppService) { _itemTypeRepository = itemTypeRepository; _logger = logger; @@ -119,6 +122,7 @@ namespace Shentun.Peis.TransToWebPeis _printReportAppService = printReportAppService; _configuration = configuration; _patientRepository = patientRepository; + _thirdBookingPushAppService = thirdBookingPushAppService; } @@ -137,34 +141,46 @@ namespace Shentun.Peis.TransToWebPeis if (isPatientRegister.CompleteFlag != PatientRegisterCompleteFlag.SumCheck) throw new UserFriendlyException("人员未总检,无法上传"); - //同步数据 - await TransPatientRegisterByPatientRegisterIdAsync(new PatientRegisterIdInputDto { PatientRegisterId = input.PatientRegisterId }); + if (string.IsNullOrWhiteSpace(isPatientRegister.ThirdBookingId)) + { + //同步数据 + await TransPatientRegisterByPatientRegisterIdAsync(new PatientRegisterIdInputDto { PatientRegisterId = input.PatientRegisterId }); - //上传报告 - var thirdInterfaces = await _thirdInterfaceRepository.GetListAsync(o => o.ThirdInterfaceType == - ThirdInterfaceTypeFlag.TranToWebPeis); + //上传报告 + var thirdInterfaces = await _thirdInterfaceRepository.GetListAsync(o => o.ThirdInterfaceType == + ThirdInterfaceTypeFlag.TranToWebPeis); - foreach (var thirdInterface in thirdInterfaces) - { - var parmValue = thirdInterface.ParmValue; - var configurationBuilder = new ConfigurationBuilder() - .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); - var interfaceConfig = configurationBuilder.Build(); - var url = interfaceConfig.GetSection("Interface").GetSection("Url").Value; - var user = interfaceConfig.GetSection("Interface").GetSection("User").Value; - var password = interfaceConfig.GetSection("Interface").GetSection("Password").Value; + foreach (var thirdInterface in thirdInterfaces) + { + var parmValue = thirdInterface.ParmValue; + var configurationBuilder = new ConfigurationBuilder() + .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); + var interfaceConfig = configurationBuilder.Build(); + var url = interfaceConfig.GetSection("Interface").GetSection("Url").Value; + var user = interfaceConfig.GetSection("Interface").GetSection("User").Value; + var password = interfaceConfig.GetSection("Interface").GetSection("Password").Value; - var result = await CallAppServiceAsync(url, "", input); + var result = await CallAppServiceAsync(url, "", input); - } + } - //更新上传状态 - var patientRegisterEnt = await _patientRegisterRepository.GetAsync(input.PatientRegisterId); - patientRegisterEnt.IsUpload = 'Y'; - await _patientRegisterRepository.UpdateAsync(patientRegisterEnt); + //更新上传状态 + var patientRegisterEnt = await _patientRegisterRepository.GetAsync(input.PatientRegisterId); + patientRegisterEnt.IsUpload = 'Y'; + await _patientRegisterRepository.UpdateAsync(patientRegisterEnt); - //推送短信 - await PushSmsAsync(patientRegisterEnt); + //推送短信 + await PushSmsAsync(patientRegisterEnt); + } + else + { + //上传到人寿 + await _thirdBookingPushAppService.PushReportFileAsync(new PushReportFileInputDto + { + PatientRegisterId = input.PatientRegisterId, + ReportBase64 = input.ReportBase64 + }); + } } /// diff --git a/src/Shentun.Peis.DbMigrator/appsettings.json b/src/Shentun.Peis.DbMigrator/appsettings.json index 3444c1b..f671d85 100644 --- a/src/Shentun.Peis.DbMigrator/appsettings.json +++ b/src/Shentun.Peis.DbMigrator/appsettings.json @@ -1,7 +1,7 @@ { "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=10.1.12.140;Port=5432;Database=ShentunPeis0508;User ID=postgres;Password=st123;" }, diff --git a/src/Shentun.Peis.Domain/AesHelper.cs b/src/Shentun.Peis.Domain/AesHelper.cs index 7e015d0..05e2220 100644 --- a/src/Shentun.Peis.Domain/AesHelper.cs +++ b/src/Shentun.Peis.Domain/AesHelper.cs @@ -10,20 +10,21 @@ using Org.BouncyCastle.Crypto.Parameters; using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Security; using Org.BouncyCastle.Utilities; +using NPOI.POIFS.Crypt; namespace Shentun.Peis { 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字节初始化向量 /// /// MD5加密 /// /// /// - public static string GetMD5Hash(string input) + public static string GetMD5(string input) { using (MD5 md5 = MD5.Create()) { @@ -46,7 +47,7 @@ namespace Shentun.Peis /// /// /// - public static string GetMD5Hash2(byte[] input) + public static string GetMD5Hash(byte[] input) { using (MD5 md5 = MD5.Create()) { @@ -57,90 +58,85 @@ namespace Shentun.Peis StringBuilder sb = new StringBuilder(); for (int i = 0; i < hashBytes.Length; i++) { - sb.Append(hashBytes[i].ToString("X2")); + sb.Append(hashBytes[i].ToString("x2")); } return sb.ToString(); } } + + /// - /// 解密 + /// Aes加密 /// - /// - /// + /// + /// /// - 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; } /// - /// 加密 + /// Aes解密 /// - /// - /// + /// + /// /// - public static byte[] AESEncrypt(byte[] inputArray, string strkey) + public static byte[] AESDecrypt(string decryptValue, string key) { - try - { - //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) + /// + /// 16进制转二进制 + /// + /// + /// + 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; } - - - } } diff --git a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs index 2470ad4..e34fe1d 100644 --- a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs +++ b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs @@ -633,7 +633,7 @@ public class PeisHttpApiHostModule : AbpModule app.UseConfiguredEndpoints(); //任务计划 - await StartScheduler(context); + //await StartScheduler(context); }