From 9f554f2db4a07bdb6fd34712f84ec432d5883a44 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Wed, 12 Jun 2024 23:38:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E7=BB=93=E6=9E=9C=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ImportPacsResultAppService.cs | 33 +++++++++++++------ src/Shentun.Peis.Domain/CacheService.cs | 33 +++++++++++-------- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/Shentun.Peis.Application/ImportPacsResults/ImportPacsResultAppService.cs b/src/Shentun.Peis.Application/ImportPacsResults/ImportPacsResultAppService.cs index 7d1df31..ba3896b 100644 --- a/src/Shentun.Peis.Application/ImportPacsResults/ImportPacsResultAppService.cs +++ b/src/Shentun.Peis.Application/ImportPacsResults/ImportPacsResultAppService.cs @@ -21,6 +21,7 @@ using System.IO; using System.Linq; using System.Security.Cryptography.Xml; using System.Text; +using System.Threading; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Application.Services; @@ -129,7 +130,7 @@ namespace Shentun.Peis.ImportPacsResults throw new UserFriendlyException("input参数不能为空"); } - if(string.IsNullOrWhiteSpace(input.CheckRequestNo)) + if (string.IsNullOrWhiteSpace(input.CheckRequestNo)) { throw new UserFriendlyException("CheckRequestNo不能为空"); } @@ -206,7 +207,7 @@ namespace Shentun.Peis.ImportPacsResults string pictureUrl; foreach (var file in input.Files) { - if(string.IsNullOrWhiteSpace(file.FileTransMode)) + if (string.IsNullOrWhiteSpace(file.FileTransMode)) { throw new UserFriendlyException("文件传输模式不能为空"); } @@ -214,7 +215,7 @@ namespace Shentun.Peis.ImportPacsResults { throw new UserFriendlyException("文件格式不能为空"); } - if(file.FileTransMode != "0" && file.FileTransMode != "1") + if (file.FileTransMode != "0" && file.FileTransMode != "1") { throw new UserFriendlyException("文件传输模式不正确"); } @@ -233,7 +234,7 @@ namespace Shentun.Peis.ImportPacsResults } if (file.FileTransMode == "1") { - if(string.IsNullOrWhiteSpace(file.FileUrl)) + if (string.IsNullOrWhiteSpace(file.FileUrl)) { throw new UserFriendlyException("文件URL不能为空"); } @@ -259,7 +260,7 @@ namespace Shentun.Peis.ImportPacsResults } else if (file.FileFormat == "1") { - + byte[] pdfBytes = Convert.FromBase64String(file.FileBase64); var tempFilePath = DirectoryHelper.GetAppDirectory() + "\\temp-files"; if (!Directory.Exists(tempFilePath)) @@ -271,16 +272,28 @@ namespace Shentun.Peis.ImportPacsResults using (System.IO.FileStream stream = new System.IO.FileStream(tempPdf, System.IO.FileMode.Create)) { //通过流的方式写入 - using(System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream) ) + using (System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream)) { writer.Write(pdfBytes, 0, pdfBytes.Length); writer.Close(); } - + + } + + string hostName = file.FileUrl.Replace("http://", "").Replace("https://", ""); + if (hostName.IndexOf(":") > 0) + { + hostName = hostName.Substring(0, hostName.IndexOf(":")); + } + else + { + hostName = hostName.Substring(0, hostName.IndexOf("/")); } - PDFHelper.ConvertPdfToImage(tempPdf, tempFilePath ,"tempImage"); - pictureUrl = ImageHelper.SavePacsFile(absolutePath, tempFilePath + "\\tempImage_0.jpg", firstEntity.patientRegister.Id.ToString(), + string tempImageName = "tempImage" + hostName; + PDFHelper.ConvertPdfToImage(tempPdf, tempFilePath, tempImageName); + + pictureUrl = ImageHelper.SavePacsFile(absolutePath, tempFilePath + "\\" + tempImageName + "_0.jpg", firstEntity.patientRegister.Id.ToString(), firstEntity.registerCheck.Id.ToString(), fileName); } else @@ -288,7 +301,7 @@ namespace Shentun.Peis.ImportPacsResults throw new UserFriendlyException("不支持的文件类型"); } - + if (string.IsNullOrWhiteSpace(pictureUrl)) { diff --git a/src/Shentun.Peis.Domain/CacheService.cs b/src/Shentun.Peis.Domain/CacheService.cs index 9806c22..cec2bf5 100644 --- a/src/Shentun.Peis.Domain/CacheService.cs +++ b/src/Shentun.Peis.Domain/CacheService.cs @@ -38,7 +38,7 @@ namespace Shentun.Peis private readonly IRepository _forSexRepository; private readonly IRepository _deviceTypeRepository; private readonly IRepository _asbitemRepository; - + private readonly IRepository _itemTypeRepository; private readonly IRepository _customerOrgRepository; private readonly IRepository _maritalStatusRepository; @@ -67,8 +67,7 @@ namespace Shentun.Peis IRepository customerOrgRepository, IRepository maritalStatusRepository, IRepository medicalTypeRepository, - IRepository personnelTypeRepository -, + IRepository personnelTypeRepository, IDistributedCache customerOrgTopNameCache) { _userCache = userCache; @@ -164,11 +163,19 @@ namespace Shentun.Peis private async Task GetMaritalStatusAsync(char id) { - var entity = await _maritalStatusCache.GetOrAddAsync( - id, //缓存键 - async () => (await _maritalStatusRepository.GetQueryableAsync()).Where(o => o.Id == id).Single() - ); - return entity; + var maritalStatusEntity = await _maritalStatusCache.GetAsync(id); + if (maritalStatusEntity == null) + { + maritalStatusEntity = await _maritalStatusRepository.FirstOrDefaultAsync(f => f.Id == id); + } + + return maritalStatusEntity; + + //var entity = await _maritalStatusCache.GetOrAddAsync( + // id, //缓存键 + // async () => (await _maritalStatusRepository.GetQueryableAsync()).Where(o => o.Id == id).Single() + //); + //return entity; } public async Task GetMaritalStatusNameAsync(char id) { @@ -306,7 +313,7 @@ namespace Shentun.Peis _customerOrgCache.Set(id, entity); //entity = (CustomerOrg)_customerOrgCache.Get(id); } - + return entity; } @@ -322,13 +329,13 @@ namespace Shentun.Peis public async Task GetTopCustomerOrgAsync(Guid id) { - var entity = (CustomerOrg)_customerOrgCache.Get(id); - if(entity == null) + var entity = (CustomerOrg)_customerOrgCache.Get(id); + if (entity == null) { entity = await _customerOrgRepository.GetAsync(o => o.Id == id); _customerOrgCache.Set(id, entity); } - + if (entity.ParentId != null && entity.ParentId != Guid.Empty) { entity = await GetTopCustomerOrgAsync((Guid)entity.ParentId); @@ -366,7 +373,7 @@ namespace Shentun.Peis _customerOrgCache.Set(id, entity); } - + if (entity.Id == GuidFlag.PersonCustomerOrgId) { return entity.DisplayName;