Browse Source

导入结果报告图片

bjmzak
wxd 1 year ago
parent
commit
9f554f2db4
  1. 27
      src/Shentun.Peis.Application/ImportPacsResults/ImportPacsResultAppService.cs
  2. 23
      src/Shentun.Peis.Domain/CacheService.cs

27
src/Shentun.Peis.Application/ImportPacsResults/ImportPacsResultAppService.cs

@ -21,6 +21,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Security.Cryptography.Xml; using System.Security.Cryptography.Xml;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
@ -129,7 +130,7 @@ namespace Shentun.Peis.ImportPacsResults
throw new UserFriendlyException("input参数不能为空"); throw new UserFriendlyException("input参数不能为空");
} }
if(string.IsNullOrWhiteSpace(input.CheckRequestNo))
if (string.IsNullOrWhiteSpace(input.CheckRequestNo))
{ {
throw new UserFriendlyException("CheckRequestNo不能为空"); throw new UserFriendlyException("CheckRequestNo不能为空");
} }
@ -206,7 +207,7 @@ namespace Shentun.Peis.ImportPacsResults
string pictureUrl; string pictureUrl;
foreach (var file in input.Files) foreach (var file in input.Files)
{ {
if(string.IsNullOrWhiteSpace(file.FileTransMode))
if (string.IsNullOrWhiteSpace(file.FileTransMode))
{ {
throw new UserFriendlyException("文件传输模式不能为空"); throw new UserFriendlyException("文件传输模式不能为空");
} }
@ -214,7 +215,7 @@ namespace Shentun.Peis.ImportPacsResults
{ {
throw new UserFriendlyException("文件格式不能为空"); throw new UserFriendlyException("文件格式不能为空");
} }
if(file.FileTransMode != "0" && file.FileTransMode != "1")
if (file.FileTransMode != "0" && file.FileTransMode != "1")
{ {
throw new UserFriendlyException("文件传输模式不正确"); throw new UserFriendlyException("文件传输模式不正确");
} }
@ -233,7 +234,7 @@ namespace Shentun.Peis.ImportPacsResults
} }
if (file.FileTransMode == "1") if (file.FileTransMode == "1")
{ {
if(string.IsNullOrWhiteSpace(file.FileUrl))
if (string.IsNullOrWhiteSpace(file.FileUrl))
{ {
throw new UserFriendlyException("文件URL不能为空"); throw new UserFriendlyException("文件URL不能为空");
} }
@ -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.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.Write(pdfBytes, 0, pdfBytes.Length);
writer.Close(); writer.Close();
} }
} }
PDFHelper.ConvertPdfToImage(tempPdf, tempFilePath ,"tempImage");
pictureUrl = ImageHelper.SavePacsFile(absolutePath, tempFilePath + "\\tempImage_0.jpg", firstEntity.patientRegister.Id.ToString(),
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("/"));
}
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); firstEntity.registerCheck.Id.ToString(), fileName);
} }
else else

23
src/Shentun.Peis.Domain/CacheService.cs

@ -67,8 +67,7 @@ namespace Shentun.Peis
IRepository<CustomerOrg, Guid> customerOrgRepository, IRepository<CustomerOrg, Guid> customerOrgRepository,
IRepository<MaritalStatus> maritalStatusRepository, IRepository<MaritalStatus> maritalStatusRepository,
IRepository<MedicalType, Guid> medicalTypeRepository, IRepository<MedicalType, Guid> medicalTypeRepository,
IRepository<PersonnelType, Guid> personnelTypeRepository
,
IRepository<PersonnelType, Guid> personnelTypeRepository,
IDistributedCache<string, Guid> customerOrgTopNameCache) IDistributedCache<string, Guid> customerOrgTopNameCache)
{ {
_userCache = userCache; _userCache = userCache;
@ -164,11 +163,19 @@ namespace Shentun.Peis
private async Task<MaritalStatus> GetMaritalStatusAsync(char id) private async Task<MaritalStatus> 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<string> GetMaritalStatusNameAsync(char id) public async Task<string> GetMaritalStatusNameAsync(char id)
{ {
@ -323,7 +330,7 @@ namespace Shentun.Peis
public async Task<CustomerOrg> GetTopCustomerOrgAsync(Guid id) public async Task<CustomerOrg> GetTopCustomerOrgAsync(Guid id)
{ {
var entity = (CustomerOrg)_customerOrgCache.Get(id); var entity = (CustomerOrg)_customerOrgCache.Get(id);
if(entity == null)
if (entity == null)
{ {
entity = await _customerOrgRepository.GetAsync(o => o.Id == id); entity = await _customerOrgRepository.GetAsync(o => o.Id == id);
_customerOrgCache.Set(id, entity); _customerOrgCache.Set(id, entity);

Loading…
Cancel
Save