缩略图测试
parent
04a24ea438
commit
ca1f23ca4d
|
@ -0,0 +1,94 @@
|
||||||
|
using AutoMapper;
|
||||||
|
using IRaCIS.Core.Application.Helper;
|
||||||
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
using IRaCIS.Core.Infrastructure.Extention;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace IRaCIS.Core.API.Controllers
|
||||||
|
{
|
||||||
|
[ApiExplorerSettings(GroupName = "Trial")]
|
||||||
|
[ApiController]
|
||||||
|
public class CommonController : ControllerBase
|
||||||
|
{
|
||||||
|
public IMapper _mapper { get; set; }
|
||||||
|
public IUserInfo _userInfo { get; set; }
|
||||||
|
|
||||||
|
private readonly IWebHostEnvironment _hostEnvironment;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public CommonController(IMapper mapper, IUserInfo userInfo, IMediator mediator, IWebHostEnvironment hostEnvironment)
|
||||||
|
{
|
||||||
|
_hostEnvironment = hostEnvironment;
|
||||||
|
_mapper = mapper;
|
||||||
|
_userInfo = userInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[AllowAnonymous]
|
||||||
|
[HttpGet("Common/LocalFilePreview")]
|
||||||
|
public async Task<FileContentResult> LocalFilePreview(string relativePath)
|
||||||
|
{
|
||||||
|
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;
|
||||||
|
|
||||||
|
var _fileStorePath = Path.Combine(rootPath, relativePath.Replace('/', '\\').Trim('\\'));
|
||||||
|
|
||||||
|
|
||||||
|
var storePreviewPath = _fileStorePath + ".preview.jpeg";
|
||||||
|
|
||||||
|
//if (!System.IO.File.Exists(storePreviewPath))
|
||||||
|
//{
|
||||||
|
ImageResizeHelper.ResizeSave(_fileStorePath, storePreviewPath);
|
||||||
|
//}
|
||||||
|
|
||||||
|
return new FileContentResult(await System.IO.File.ReadAllBytesAsync(storePreviewPath), "image/jpeg");
|
||||||
|
|
||||||
|
//_logger.LogError(rootPath);
|
||||||
|
|
||||||
|
//_logger.LogError(_fileStorePath);
|
||||||
|
|
||||||
|
|
||||||
|
//if (!File.Exists(storePreviewPath))
|
||||||
|
//{
|
||||||
|
|
||||||
|
//Bitmap sourceImage = new Bitmap(File.OpenRead(_fileStorePath));
|
||||||
|
|
||||||
|
//System.Drawing.Image destinationImage = new Bitmap(500, 500);
|
||||||
|
//Graphics g = Graphics.FromImage(destinationImage);
|
||||||
|
|
||||||
|
//g.DrawImage(
|
||||||
|
// sourceImage,
|
||||||
|
// new Rectangle(0, 0, 500, 500),
|
||||||
|
// new Rectangle(0, 0, sourceImage.Width, sourceImage.Height),
|
||||||
|
// GraphicsUnit.Pixel
|
||||||
|
//);
|
||||||
|
|
||||||
|
//destinationImage.Save(storePreviewPath);
|
||||||
|
|
||||||
|
//var image = SKBitmap.Decode(_fileStorePath);
|
||||||
|
////设置图片新的size
|
||||||
|
//var newImg = image.Resize(new SKSizeI(50, 50), SKFilterQuality.Medium);
|
||||||
|
//using var fs = new FileStream(storePreviewPath, FileMode.Create);
|
||||||
|
//newImg.Encode(fs, SKEncodedImageFormat.Png, 100);
|
||||||
|
//fs.Flush();
|
||||||
|
|
||||||
|
|
||||||
|
//var image = NetVips.Image.NewFromFile(_fileStorePath);
|
||||||
|
//var newImg = image.Resize(0.5);
|
||||||
|
//newImg.WriteToFile(storePreviewPath);
|
||||||
|
|
||||||
|
|
||||||
|
//var image = NetVips.Image.NewFromFile(_fileStorePath);
|
||||||
|
//var newImg = image.ThumbnailImage(500);
|
||||||
|
//newImg.WriteToFile(_fileStorePath);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
|
||||||
|
using SixLabors.ImageSharp;
|
||||||
|
using SixLabors.ImageSharp.Processing;
|
||||||
|
|
||||||
|
namespace IRaCIS.Core.Application.Helper;
|
||||||
|
|
||||||
|
public static class ImageResizeHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public static void ResizeSave(string filePath, string? fileStorePath)
|
||||||
|
{
|
||||||
|
|
||||||
|
fileStorePath = fileStorePath ?? filePath + ".preview.jpeg";
|
||||||
|
|
||||||
|
using (var image = SixLabors.ImageSharp.Image.Load(filePath))
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
image.Mutate(x => x.Resize(500, 500));
|
||||||
|
|
||||||
|
image.Save(fileStorePath);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -82,14 +82,18 @@
|
||||||
<PackageReference Include="MimeKit" Version="3.2.0" />
|
<PackageReference Include="MimeKit" Version="3.2.0" />
|
||||||
<PackageReference Include="MiniExcel" Version="1.26.1" />
|
<PackageReference Include="MiniExcel" Version="1.26.1" />
|
||||||
<PackageReference Include="My.Extensions.Localization.Json" Version="3.0.0" />
|
<PackageReference Include="My.Extensions.Localization.Json" Version="3.0.0" />
|
||||||
|
<PackageReference Include="NetVips" Version="2.1.0" />
|
||||||
|
<PackageReference Include="NetVips.Native" Version="8.12.2" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
|
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
|
||||||
<PackageReference Include="Panda.DynamicWebApi" Version="1.2.0" />
|
<PackageReference Include="Panda.DynamicWebApi" Version="1.2.0" />
|
||||||
<PackageReference Include="Quartz" Version="3.4.0" />
|
<PackageReference Include="Quartz" Version="3.4.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.31.0" />
|
<PackageReference Include="SharpCompress" Version="0.31.0" />
|
||||||
|
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.1" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.2" />
|
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.2" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.3.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.3.0" />
|
||||||
|
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.17.0" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.17.0" />
|
||||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.18" />
|
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.18" />
|
||||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||||
|
|
|
@ -20,6 +20,8 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
|
|
||||||
public string FullFilePath { get; set; } = string.Empty;
|
public string FullFilePath { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string PreviewPath => "/Common/LocalFilePreview?relativePath=" + Path;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
|
|
||||||
public List<NoneDicomStudyFileView> NoneDicomStudyFileList { get; set; } = new List<NoneDicomStudyFileView>();
|
public List<NoneDicomStudyFileView> NoneDicomStudyFileList { get; set; } = new List<NoneDicomStudyFileView>();
|
||||||
|
|
||||||
|
public List<string> NoneDicomStudyPreviewList=> NoneDicomStudyFileList.Select(t=> t.PreviewPath).ToList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>NoneDicomStudyQuery 列表查询参数模型</summary>
|
///<summary>NoneDicomStudyQuery 列表查询参数模型</summary>
|
||||||
|
|
|
@ -14,10 +14,13 @@ using IRaCIS.Core.Application.Service.Inspection.DTO;
|
||||||
using Nito.AsyncEx;
|
using Nito.AsyncEx;
|
||||||
using IRaCIS.Application.Interfaces;
|
using IRaCIS.Application.Interfaces;
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using SixLabors.ImageSharp.Processing;
|
|
||||||
using SixLabors.ImageSharp;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using System.Drawing;
|
||||||
|
using SixLabors.ImageSharp.Processing;
|
||||||
|
using SixLabors.ImageSharp;
|
||||||
|
using IRaCIS.Core.Application.Helper;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Contracts
|
namespace IRaCIS.Core.Application.Contracts
|
||||||
{
|
{
|
||||||
|
@ -44,10 +47,10 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
IDictionaryService dictionaryService,
|
IDictionaryService dictionaryService,
|
||||||
IInspectionService inspectionService,
|
IInspectionService inspectionService,
|
||||||
IRepository<StudyMonitor> studyMonitorRepository,
|
IRepository<StudyMonitor> studyMonitorRepository,
|
||||||
IRepository<NoneDicomStudyFile> noneDicomStudyFileRepository,IRepository<SubjectVisit> subjectVisitRepository, ILogger<NoneDicomStudyService> logger)
|
IRepository<NoneDicomStudyFile> noneDicomStudyFileRepository, IRepository<SubjectVisit> subjectVisitRepository, ILogger<NoneDicomStudyService> logger)
|
||||||
{
|
{
|
||||||
_noneDicomStudyRepository = noneDicomStudyRepository;
|
_noneDicomStudyRepository = noneDicomStudyRepository;
|
||||||
|
|
||||||
this._httpContext = httpContext;
|
this._httpContext = httpContext;
|
||||||
this._dictionaryService = dictionaryService;
|
this._dictionaryService = dictionaryService;
|
||||||
this._inspectionService = inspectionService;
|
this._inspectionService = inspectionService;
|
||||||
|
@ -87,7 +90,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
[TypeFilter(typeof(TrialResourceFilter))]
|
[TypeFilter(typeof(TrialResourceFilter))]
|
||||||
public async Task<IResponseOutput<NoneDicomStudyAddReturnDto>> AddOrUpdateNoneDicomStudy(NoneDicomStudyAddOrEdit addOrEditNoneDicomStudy)
|
public async Task<IResponseOutput<NoneDicomStudyAddReturnDto>> AddOrUpdateNoneDicomStudy(NoneDicomStudyAddOrEdit addOrEditNoneDicomStudy)
|
||||||
{
|
{
|
||||||
var visitList = await _subjectVisitRepository.Where(t => t.SubjectId == addOrEditNoneDicomStudy.SubjectId).Select(t => new { t.VisitNum, t.EarliestScanDate, t.LatestScanDate, t.Id }).ToListAsync();
|
var visitList = await _subjectVisitRepository.Where(t => t.SubjectId == addOrEditNoneDicomStudy.SubjectId).Select(t => new { t.VisitNum, t.EarliestScanDate, t.LatestScanDate, t.Id }).ToListAsync();
|
||||||
|
|
||||||
var currentVisitNum = await _subjectVisitRepository.Where(t => t.Id == addOrEditNoneDicomStudy.SubjectVisitId).Select(t => t.VisitNum).FirstOrDefaultAsync();
|
var currentVisitNum = await _subjectVisitRepository.Where(t => t.Id == addOrEditNoneDicomStudy.SubjectVisitId).Select(t => t.VisitNum).FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
@ -155,7 +158,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
|
|
||||||
[TypeFilter(typeof(TrialResourceFilter))]
|
[TypeFilter(typeof(TrialResourceFilter))]
|
||||||
[HttpDelete("{trialId:guid}/{subjectVisitId:guid}/{noneDicomStudyId:guid}")]
|
[HttpDelete("{trialId:guid}/{subjectVisitId:guid}/{noneDicomStudyId:guid}")]
|
||||||
public async Task<IResponseOutput> DeleteNoneDicomStudy(Guid noneDicomStudyId,Guid subjectVisitId)
|
public async Task<IResponseOutput> DeleteNoneDicomStudy(Guid noneDicomStudyId, Guid subjectVisitId)
|
||||||
{
|
{
|
||||||
//提交了 但是IQC同意的时候 是可以删除的 | 普通提交后也不能删除
|
//提交了 但是IQC同意的时候 是可以删除的 | 普通提交后也不能删除
|
||||||
if (await _subjectVisitRepository.AnyAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.Submitted &&
|
if (await _subjectVisitRepository.AnyAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.Submitted &&
|
||||||
|
@ -164,7 +167,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
return ResponseOutput.NotOk("CRC Has Submited Image,can not delete");
|
return ResponseOutput.NotOk("CRC Has Submited Image,can not delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
await _noneDicomStudyRepository.DeleteFromQueryAsync( noneDicomStudyId);
|
await _noneDicomStudyRepository.DeleteFromQueryAsync(noneDicomStudyId);
|
||||||
|
|
||||||
await _noneDicomStudyFileRepository.DeleteFromQueryAsync(t => t.NoneDicomStudyId == noneDicomStudyId);
|
await _noneDicomStudyFileRepository.DeleteFromQueryAsync(t => t.NoneDicomStudyId == noneDicomStudyId);
|
||||||
|
|
||||||
|
@ -189,7 +192,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
}
|
}
|
||||||
//var subjectVisitId = await _noneDicomStudyFileRepository.Where(t => t.Id == noneDicomStudyFileId).Select(t => t.NoneDicomStudy.SubjectVisitId).FirstOrDefaultAsync();
|
//var subjectVisitId = await _noneDicomStudyFileRepository.Where(t => t.Id == noneDicomStudyFileId).Select(t => t.NoneDicomStudy.SubjectVisitId).FirstOrDefaultAsync();
|
||||||
|
|
||||||
var success = await _noneDicomStudyFileRepository.DeleteFromQueryAsync(t => t.Id == noneDicomStudyFileId,true);
|
var success = await _noneDicomStudyFileRepository.DeleteFromQueryAsync(t => t.Id == noneDicomStudyFileId, true);
|
||||||
|
|
||||||
return ResponseOutput.Ok();
|
return ResponseOutput.Ok();
|
||||||
}
|
}
|
||||||
|
@ -212,37 +215,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
return await _repository.Where<NoneDicomStudyFile>(t => t.NoneDicomStudy.SubjectVisitId == subjectVisitId).ProjectTo<NoneDicomStudyFileView>(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken }).ToListAsync();
|
return await _repository.Where<NoneDicomStudyFile>(t => t.NoneDicomStudy.SubjectVisitId == subjectVisitId).ProjectTo<NoneDicomStudyFileView>(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken }).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[AllowAnonymous]
|
|
||||||
[HttpGet]
|
|
||||||
public async Task<FileContentResult> NoneDicomFilePreview(string relativePath)
|
|
||||||
{
|
|
||||||
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;
|
|
||||||
|
|
||||||
var _fileStorePath = Path.Combine(rootPath, relativePath.Replace('/', '\\').Trim('\\'));
|
|
||||||
|
|
||||||
//_logger.LogError(rootPath);
|
|
||||||
|
|
||||||
//_logger.LogError(_fileStorePath);
|
|
||||||
|
|
||||||
var storePreviewPath = _fileStorePath + ".preview.jpg";
|
|
||||||
|
|
||||||
//if (!File.Exists(storePreviewPath))
|
|
||||||
//{
|
|
||||||
|
|
||||||
using (var image = SixLabors.ImageSharp.Image.Load(await File.ReadAllBytesAsync(_fileStorePath)))
|
|
||||||
{
|
|
||||||
image.Mutate(x => x
|
|
||||||
.Resize(1000, 1000)
|
|
||||||
);
|
|
||||||
|
|
||||||
await image.SaveAsJpegAsync(storePreviewPath);
|
|
||||||
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
|
|
||||||
return new FileContentResult(await File.ReadAllBytesAsync(storePreviewPath), "image/jpg");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上传非Dicom 文件 支持压缩包
|
/// 上传非Dicom 文件 支持压缩包
|
||||||
|
@ -308,7 +281,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
// 上传非Dicom 后 将状态改为待提交 分为普通上传 和QC后重传 普通上传时才改为待提交
|
// 上传非Dicom 后 将状态改为待提交 分为普通上传 和QC后重传 普通上传时才改为待提交
|
||||||
await _subjectVisitRepository.UpdatePartialFromQueryAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.None, u => new SubjectVisit() { SubmitState = SubmitStateEnum.ToSubmit });
|
await _subjectVisitRepository.UpdatePartialFromQueryAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.None, u => new SubjectVisit() { SubmitState = SubmitStateEnum.ToSubmit });
|
||||||
|
|
||||||
var studyCode= await _noneDicomStudyRepository.Where(t=>t.Id== noneDicomStudyId).Select(t => t.StudyCode).FirstOrDefaultAsync();
|
var studyCode = await _noneDicomStudyRepository.Where(t => t.Id == noneDicomStudyId).Select(t => t.StudyCode).FirstOrDefaultAsync();
|
||||||
|
|
||||||
await _studyMonitorRepository.AddAsync(new StudyMonitor()
|
await _studyMonitorRepository.AddAsync(new StudyMonitor()
|
||||||
{
|
{
|
||||||
|
@ -317,7 +290,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
IsDicom = false,
|
IsDicom = false,
|
||||||
IsDicomReUpload = false,
|
IsDicomReUpload = false,
|
||||||
StudyId = noneDicomStudyId,
|
StudyId = noneDicomStudyId,
|
||||||
StudyCode= studyCode,
|
StudyCode = studyCode,
|
||||||
UploadStartTime = startTime,
|
UploadStartTime = startTime,
|
||||||
UploadFinishedTime = DateTime.Now,
|
UploadFinishedTime = DateTime.Now,
|
||||||
IP = _userInfo.IP,
|
IP = _userInfo.IP,
|
||||||
|
|
|
@ -19,9 +19,9 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
public class SystemNotice : Entity, IAuditUpdate, IAuditAdd
|
public class SystemNotice : Entity, IAuditUpdate, IAuditAdd
|
||||||
{
|
{
|
||||||
|
|
||||||
public List<SystemNoticeUserType> NoticeUserTypeList { get; set; }
|
public List<SystemNoticeUserType> NoticeUserTypeList { get; set; }=new List<SystemNoticeUserType>();
|
||||||
|
|
||||||
public List<SystemNoticeUserRead> NoticeUserReadList { get; set; }
|
public List<SystemNoticeUserRead> NoticeUserReadList { get; set; }=new List<SystemNoticeUserRead>();
|
||||||
|
|
||||||
public User CreateUser { get; set; }
|
public User CreateUser { get; set; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue