diff --git a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs index f8a017c5b..7b48775da 100644 --- a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs +++ b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs @@ -228,7 +228,6 @@ namespace IRaCIS.Core.API.Controllers } - [HttpPost, Route("Study/PreArchiveStudy")] [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] public async Task PreArchiveStudy(PreArchiveStudyCommand preArchiveStudyCommand, @@ -264,12 +263,6 @@ namespace IRaCIS.Core.API.Controllers } - //public string UploadOOSTest(string filePath, string route) - //{ - - //} - - /// Dicom 归档 [HttpPost, Route("Study/ArchiveStudy")] [DisableFormValueModelBinding] @@ -443,260 +436,43 @@ namespace IRaCIS.Core.API.Controllers } - - - - - /// - /// 上传临床数据 多文件 - /// - /// - /// - [HttpPost("ClinicalData/UploadVisitClinicalData/{trialId:guid}/{subjectVisitId:guid}")] - [DisableRequestSizeLimit] - //[Authorize(Policy = IRaCISPolicy.CRC)] - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - - public async Task UploadVisitClinicalData(Guid subjectVisitId) + public class UploadNoneDicomFileCommand { - await _qCCommon.VerifyIsCRCSubmmitAsync(_repository, _userInfo, subjectVisitId); - var sv = _repository.Where(t => t.Id == subjectVisitId).Select(t => new { t.TrialId, t.SiteId, t.SubjectId }).FirstOrDefault().IfNullThrowException(); + public Guid TrialId { get; set; } + public Guid SubjectVisitId { get; set; } + public Guid NoneDicomStudyId { get; set; } + public Guid StudyMonitorId { get; set; } - await FileUploadAsync(async (fileName) => + + public List UploadedFileList { get; set; } = new List(); + + + public class OSSFileDTO { - var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetClinicalDataPath(_hostEnvironment, fileName, sv.TrialId, sv.SiteId, sv.SubjectId, subjectVisitId); - //插入临床pdf 路径 - await _repository.AddAsync(new PreviousPDF() - { - SubjectVisitId = subjectVisitId, - - IsVisist = true, - DataType = ClinicalDataType.MedicalHistory, - UploadType = ClinicalUploadType.PDF, - SubjectId = sv.SubjectId, - TrialId = sv.TrialId, - ClinicalLevel = ClinicalLevel.Subject, - Path = relativePath, - FileName = fileRealName - }); - return serverFilePath; - }); - await _repository.SaveChangesAsync(); - return ResponseOutput.Ok(); - + public string FilePath { get; set; } + public string FileName { get; set; } + public int FileFize { get; set; } + } } - /// - /// 上传临床数据模板 - /// - /// - /// - [HttpPost("ClinicalData/UploadClinicalTemplate")] - [DisableRequestSizeLimit] - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "BeforeOngoingCantOpt", "AfterStopCannNotOpt" })] - - - public async Task>> UploadClinicalTemplate(Guid? trialId) - { - if (trialId == null) - trialId = default(Guid); - - var filerelativePath = string.Empty; - List fileDtos = new List(); - await FileUploadAsync(async (fileName) => - { - var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetClinicalTemplatePath(_hostEnvironment, fileName, trialId.Value); - //插入临床pdf 路径 - filerelativePath = relativePath; - - fileDtos.Add(new FileDto() - { - FileName = fileName, - Path = relativePath - - }); - await Task.CompletedTask; - return serverFilePath; - }); - - return ResponseOutput.Ok(fileDtos); - } - - - - /// - /// 上传阅片临床数据 - /// - /// - /// - /// - /// - [HttpPost("ClinicalData/UploadClinicalData/{trialId:guid}/{subjectId:guid}/{readingId:guid}")] - [DisableRequestSizeLimit] - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - - public async Task>> UploadReadClinicalData(Guid trialId, Guid subjectId, Guid readingId) - { - var filerelativePath = string.Empty; - List fileDtos = new List(); - - var siteid = await _repository.Where(x => x.Id == subjectId).Select(x => x.SiteId).FirstOrDefaultAsync(); - - await FileUploadAsync(async (fileName) => - { - var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetReadClinicalDataPath(_hostEnvironment, fileName, trialId, siteid, subjectId, readingId); - //插入临床pdf 路径 - filerelativePath = relativePath; - - fileDtos.Add(new FileDto() - { - FileName = fileName, - Path = relativePath - - }); - await Task.CompletedTask; - return serverFilePath; - }); - - return ResponseOutput.Ok(fileDtos); - - } - - - /// - /// 上传截图 - /// - /// - /// - [HttpPost("Printscreen/UploadPrintscreen/{subjectId:guid}")] - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - public async Task> UploadPrintscreen(Guid subjectId) - { - - var subjectInfo = await this._repository.Where(x => x.Id == subjectId).FirstNotNullAsync(); - - FileDto fileDto = new FileDto(); - await FileUploadAsync(async (fileName) => - { - var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetUploadPrintscreenFilePath(_hostEnvironment, fileName, subjectInfo.TrialId, subjectInfo.SiteId, subjectInfo.Id); - fileDto.Path = relativePath; - fileDto.FileName = fileName; - await Task.CompletedTask; - return serverFilePath; - }); - - - return ResponseOutput.Ok(fileDto); - } - - - /// - /// 上传Reading问题的图像 - /// - /// - /// - /// - [HttpPost("VisitTask/UploadReadingAnswerImage/{trialId:guid}/{visitTaskId:guid}")] - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - public async Task> UploadReadingAnswerImage(Guid trialId, Guid visitTaskId) - { - - FileDto fileDto = new FileDto(); - await FileUploadAsync(async (fileName) => - { - var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetFilePath(_hostEnvironment, fileName, trialId, visitTaskId, StaticData.Folder.JudgeTask); - fileDto.Path = relativePath; - fileDto.FileName = fileName; - await Task.CompletedTask; - return serverFilePath; - }); - - - return ResponseOutput.Ok(fileDto); - } - - /// - /// 上传裁判任务的图像 - /// - /// - /// - /// - [HttpPost("VisitTask/UploadJudgeTaskImage/{trialId:guid}/{visitTaskId:guid}")] - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - public async Task> UploadJudgeTaskImage(Guid trialId, Guid visitTaskId) - { - - FileDto fileDto = new FileDto(); - await FileUploadAsync(async (fileName) => - { - var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetFilePath(_hostEnvironment, fileName, trialId, visitTaskId, StaticData.Folder.JudgeTask); - fileDto.Path = relativePath; - fileDto.FileName = fileName; - - await Task.CompletedTask; - - return serverFilePath; - }); - - return ResponseOutput.Ok(fileDto); - } - - - - /// - /// 上传医学审核图片 - /// - /// - /// - /// - [HttpPost("TaskMedicalReview/UploadMedicalReviewImage/{trialId:guid}/{taskMedicalReviewId:guid}")] - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - public async Task> UploadMedicalReviewImage(Guid trialId, Guid taskMedicalReviewId) - { - string path = string.Empty; - FileDto fileDto = new FileDto(); - await FileUploadAsync(async (fileName) => - { - - var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetMedicalReviewImage(_hostEnvironment, fileName, trialId, taskMedicalReviewId); - - - //await _repository.UpdatePartialFromQueryAsync(x => x.Id == taskMedicalReviewId, x => new TaskMedicalReview() - //{ - // ImagePath = relativePath, - // FileName = fileName, - //}); - - path = relativePath; - fileDto.Path = relativePath; - fileDto.FileName = fileName; - return serverFilePath; - }); - - await _repository.SaveChangesAsync(); - return ResponseOutput.Ok(fileDto); - } - - - /// /// 上传非Dicom 文件 支持压缩包 多文件上传 /// - /// - /// - /// - /// /// /// //[DisableRequestSizeLimit] - [RequestSizeLimit(1_073_741_824)] - [HttpPost("NoneDicomStudy/UploadNoneDicomFile/{trialId:guid}/{subjectVisitId:guid}/{noneDicomStudyId:guid}/{studyMonitorId:guid}")] + [HttpPost("NoneDicomStudy/UploadNoneDicomFile")] [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] //[Authorize(Policy = IRaCISPolicy.CRC)] - public async Task UploadNoneDicomFile(IFormCollection formCollection, Guid subjectVisitId, Guid noneDicomStudyId, Guid studyMonitorId, + public async Task UploadNoneDicomFile(UploadNoneDicomFileCommand incommand, [FromServices] IRepository _noneDicomStudyRepository, [FromServices] IRepository _studyMonitorRepository) { + var subjectVisitId = incommand.SubjectVisitId; + var studyMonitorId = incommand.StudyMonitorId; + var noneDicomStudyId = incommand.NoneDicomStudyId; + + await _qCCommon.VerifyIsCRCSubmmitAsync(_repository, _userInfo, subjectVisitId); var sv = (await _repository.Where(t => t.Id == subjectVisitId).Select(t => new { t.TrialId, t.SiteId, t.SubjectId }).FirstOrDefaultAsync()).IfNullThrowConvertException(); @@ -705,33 +481,24 @@ namespace IRaCIS.Core.API.Controllers studyMonitor.UploadFinishedTime = DateTime.Now; - await FileUploadAsync(async (fileName) => + foreach (var item in incommand.UploadedFileList) { + await _repository.AddAsync(new NoneDicomStudyFile() { FileName = item.FileName, Path = item.FilePath, NoneDicomStudyId = noneDicomStudyId }); - var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetNoneDicomFilePath(_hostEnvironment, fileName, sv.TrialId, sv.SiteId, sv.SubjectId, subjectVisitId); - - await _repository.AddAsync(new NoneDicomStudyFile() { FileName = fileRealName, Path = relativePath, NoneDicomStudyId = noneDicomStudyId }); - - return serverFilePath; - }); - + } var uploadFinishedTime = DateTime.Now; - - //// 上传非Dicom 后 将状态改为待提交 分为普通上传 和QC后重传 普通上传时才改为待提交 - //await _repository.UpdatePartialFromQueryAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.None, u => new SubjectVisit() { SubmitState = SubmitStateEnum.ToSubmit }); - var noneDicomStudy = await _noneDicomStudyRepository.FirstOrDefaultAsync((t => t.Id == noneDicomStudyId)); - noneDicomStudy.FileCount = noneDicomStudy.FileCount + formCollection.Files.Count; + noneDicomStudy.FileCount = noneDicomStudy.FileCount + incommand.UploadedFileList.Count; - studyMonitor.FileCount = formCollection.Files.Count; - studyMonitor.FileSize = formCollection.Files.Sum(t => t.Length); + studyMonitor.FileCount = incommand.UploadedFileList.Count; + studyMonitor.FileSize = incommand.UploadedFileList.Sum(t => t.FileFize); studyMonitor.IsDicom = false; studyMonitor.IsDicomReUpload = false; studyMonitor.StudyId = noneDicomStudyId; studyMonitor.StudyCode = noneDicomStudy.StudyCode; - studyMonitor.ArchiveFinishedTime = DateTime.Now; + studyMonitor.ArchiveFinishedTime = DateTime.Now; studyMonitor.IP = _userInfo.IP; await _repository.SaveChangesAsync(); @@ -742,6 +509,7 @@ namespace IRaCIS.Core.API.Controllers + /// /// 一致性核查 excel上传 支持三种格式 /// @@ -982,9 +750,6 @@ namespace IRaCIS.Core.API.Controllers } - - - /// /// 上传文件( 不是医生个人的文件)[FileUpload] /// 例如:阅片章程等 @@ -1057,8 +822,6 @@ namespace IRaCIS.Core.API.Controllers } - - [HttpPost, Route("enroll/downloadResume/{trialId:guid}/{language}")] [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] [AllowAnonymous] @@ -1068,6 +831,7 @@ namespace IRaCIS.Core.API.Controllers return ResponseOutput.Ok(zipPath); } + } #endregion @@ -1084,8 +848,6 @@ namespace IRaCIS.Core.API.Controllers private readonly IWebHostEnvironment _hostEnvironment; - - public UploadDownLoadController(IMapper mapper, IUserInfo userInfo, IMediator mediator, IWebHostEnvironment hostEnvironment) { _hostEnvironment = hostEnvironment; @@ -1094,104 +856,6 @@ namespace IRaCIS.Core.API.Controllers _userInfo = userInfo; } - /// 缩略图 - [AllowAnonymous] - [HttpGet("Common/LocalFilePreview")] - public async Task LocalFilePreview(string relativePath) - { - - var _fileStorePath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, relativePath); - - var storePreviewPath = _fileStorePath + ".preview.jpeg"; - - if (!System.IO.File.Exists(storePreviewPath)) - { - ImageHelper.ResizeSave(_fileStorePath, storePreviewPath); - } - - return new FileContentResult(await System.IO.File.ReadAllBytesAsync(storePreviewPath), "image/jpeg"); - - } - - - /// 通用文件下载 - [AllowAnonymous] - [HttpGet("CommonDocument/DownloadCommonDoc")] - public async Task DownloadCommonFile(string code, [FromServices] IRepository _commonDocumentRepository) - { - var (filePath, fileName) = await FileStoreHelper.GetCommonDocPhysicalFilePathAsync(_hostEnvironment, _commonDocumentRepository, code); - - new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType); - - return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", fileName); - - } - - /// - /// 下载项目临床数据文件 - /// - /// - /// - /// - [AllowAnonymous] - [HttpGet("CommonDocument/DownloadTrialClinicalFile")] - public async Task DownloadTrialClinicalFile(Guid clinicalDataTrialSetId, [FromServices] IRepository _clinicalDataTrialSetRepository) - { - var (filePath, fileName) = await FileStoreHelper.GetTrialClinicalPathAsync(_hostEnvironment, _clinicalDataTrialSetRepository, clinicalDataTrialSetId); - - new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType); - - return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", fileName); - - } - - - /// - /// 下载系统临床数据文件 - /// - /// - /// - /// - [AllowAnonymous] - [HttpGet("CommonDocument/DownloadSystemClinicalFile")] - public async Task DownloadSystemClinicalFile(Guid clinicalDataSystemSetId, [FromServices] IRepository _clinicalDataSystemSetRepository) - { - var (filePath, fileName) = await FileStoreHelper.GetSystemClinicalPathAsync(_hostEnvironment, _clinicalDataSystemSetRepository, clinicalDataSystemSetId); - - new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType); - - return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", fileName); - - } - - /// - ///上传项目签名文档 - /// - /// - /// - [HttpPost("TrialDocument/UploadTrialDoc/{trialId:guid}")] - [DisableRequestSizeLimit] - [DisableFormValueModelBinding] - public async Task UploadTrialDoc(Guid trialId) - { - - return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetTrialSignDocPath(_hostEnvironment, trialId, fileName)); - - } - - /// - /// 上传系统签名文档 - /// - /// - [HttpPost("TrialDocument/UploadSystemDoc")] - [DisableRequestSizeLimit] - [DisableFormValueModelBinding] - public async Task UploadSysTemDoc() - { - - return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemSignDocPath(_hostEnvironment, fileName)); - - } /// @@ -1208,19 +872,6 @@ namespace IRaCIS.Core.API.Controllers } - /// - /// 上传系统通知文档 - /// - /// - [HttpPost("SystemNotice/UploadSystemNoticeDoc")] - [DisableRequestSizeLimit] - [DisableFormValueModelBinding] - public async Task UploadSystemNoticeDoc() - { - - return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemNoticePath(_hostEnvironment, fileName)); - - } public enum UploadFileType { diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj index 787cd194b..28ac6a452 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj +++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj @@ -159,7 +159,7 @@ - + diff --git a/IRaCIS.Core.API/appsettings.Development.json b/IRaCIS.Core.API/appsettings.Development.json index a71d2d214..868d9187d 100644 --- a/IRaCIS.Core.API/appsettings.Development.json +++ b/IRaCIS.Core.API/appsettings.Development.json @@ -17,9 +17,9 @@ "Endpoint": "https://oss-cn-shanghai.aliyuncs.com", "AccessKeyId": "LTAI5tKvzs7ed3UfSpNk3xwQ", "AccessKeySecret": "zTIceGEShlZDGnLrCFfIGFE7TXVRio", - "BucketName": "zy-sir-test-store", + "BucketName": "zyypacs", "RoleArn": "acs:ram::1899121822495495:role/oss-upload", - "ViewEndpoint": "https://zy-sir-test-store.oss-cn-shanghai.aliyuncs.com", + "ViewEndpoint": "https://zyypacs.oss-cn-shanghai.aliyuncs.com", "Region": "oss-cn-shanghai" }, "BasicSystemConfig": {