diff --git a/IRaCIS.Core.API/Controllers/ExtraController.cs b/IRaCIS.Core.API/Controllers/ExtraController.cs index 1234a2e45..99a32155d 100644 --- a/IRaCIS.Core.API/Controllers/ExtraController.cs +++ b/IRaCIS.Core.API/Controllers/ExtraController.cs @@ -26,6 +26,8 @@ using Aliyun.Acs.Core.Profile; using Aliyun.Acs.Sts.Model.V20150401; using Microsoft.AspNetCore.Hosting; using MassTransit; +using IRaCIS.Core.Application.Helper; +using Microsoft.Extensions.Options; namespace IRaCIS.Api.Controllers { @@ -134,25 +136,77 @@ namespace IRaCIS.Api.Controllers return returnModel; } - [Authorize] - [HttpGet("user/GenerateSTS")] - public IResponseOutput GenerateSTS( [FromServices] IWebHostEnvironment webHostEnvironment) + [HttpGet("user/GetObjectStoreToken")] + public IResponseOutput GetObjectStoreToken([FromServices] IOptionsMonitor options) { - + var serviceOption = options.CurrentValue; - var configuration = new ConfigurationBuilder() - .AddJsonFile($"appsettings.{webHostEnvironment.EnvironmentName}.json") - .Build(); + if (Enum.TryParse(serviceOption.ObjectStoreUse, out var parsedEnum) && parsedEnum == ObjectStoreUse.AliyunOSS) + { + var ossOptions = serviceOption.AliyunOSS; + + IClientProfile profile = DefaultProfile.GetProfile(ossOptions.RegionId, ossOptions.AccessKeyId, ossOptions.AccessKeySecret); + DefaultAcsClient client = new DefaultAcsClient(profile); - IClientProfile profile = DefaultProfile.GetProfile("cn-shanghai", configuration["AliyunOSS:accessKeyId"], configuration["AliyunOSS:accessKeySecret"]); + // 创建一个STS请求 + AssumeRoleRequest request = new AssumeRoleRequest + { + RoleArn = ossOptions.RoleArn, // 角色ARN,需要替换为你的角色ARN + RoleSessionName = $"session-name-{NewId.NextGuid()}", // 角色会话名称,可自定义 + DurationSeconds = 900, // 令牌有效期(单位:秒),这里设置为1小时 + }; + + + AssumeRoleResponse response = client.GetAcsResponse(request); + + // 返回STS令牌信息给前端 + var stsToken = new ObjectStoreDTO() + { + ObjectStoreUse = serviceOption.ObjectStoreUse, + AliyunOSS = new AliyunOSSTempToken() + { + AccessKeyId = response.Credentials.AccessKeyId, + AccessKeySecret = response.Credentials.AccessKeySecret, + SecurityToken = response.Credentials.SecurityToken, + Expiration = response.Credentials.Expiration, + + Region = ossOptions.Region, + BucketName = ossOptions.BucketName, + ViewEndpoint = ossOptions.ViewEndpoint, + + }, + MinIO = serviceOption.MinIO + } + ; + + return ResponseOutput.Ok(stsToken); + } + else if (Enum.TryParse(serviceOption.ObjectStoreUse, out var parsedValue) && parsedValue == ObjectStoreUse.MinIO) + { + return ResponseOutput.Ok(new ObjectStoreDTO() { ObjectStoreUse = serviceOption.ObjectStoreUse, MinIO = serviceOption.MinIO }); + } + else + { + return ResponseOutput.Ok(new ObjectStoreDTO() { ObjectStoreUse = serviceOption.ObjectStoreUse, MinIO = serviceOption.MinIO }); + } + + } + + [HttpGet("user/GenerateSTS")] + public IResponseOutput GenerateSTS([FromServices] IOptionsMonitor options) + { + var ossOptions = options.CurrentValue; + + + IClientProfile profile = DefaultProfile.GetProfile(ossOptions.RegionId, ossOptions.AccessKeyId, ossOptions.AccessKeySecret); DefaultAcsClient client = new DefaultAcsClient(profile); // 创建一个STS请求 AssumeRoleRequest request = new AssumeRoleRequest { - RoleArn = "acs:ram::1899121822495495:role/oss-upload", // 角色ARN,需要替换为你的角色ARN + RoleArn = ossOptions.RoleArn, // 角色ARN,需要替换为你的角色ARN RoleSessionName = $"session-name-{NewId.NextGuid()}", // 角色会话名称,可自定义 DurationSeconds = 900, // 令牌有效期(单位:秒),这里设置为1小时 }; @@ -168,9 +222,9 @@ namespace IRaCIS.Api.Controllers SecurityToken = response.Credentials.SecurityToken, Expiration = response.Credentials.Expiration, - Region= configuration["AliyunOSS:region"], - BucketName = configuration["AliyunOSS:bucketName"], - ViewEndpoint = configuration["AliyunOSS:viewEndpoint"], + Region = ossOptions.Region, + BucketName = ossOptions.BucketName, + ViewEndpoint = ossOptions.ViewEndpoint, }; diff --git a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs index 0a7430625..2d18a2d5a 100644 --- a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs +++ b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs @@ -24,6 +24,7 @@ using Magicodes.ExporterAndImporter.Excel; using MassTransit; using MediatR; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Cors.Infrastructure; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -37,7 +38,7 @@ using Microsoft.Net.Http.Headers; using MiniExcelLibs; using Newtonsoft.Json; using SharpCompress.Archives; -using SharpCompress.Common; +using SkiaSharp; using System; using System.Collections.Generic; using System.Data; @@ -134,6 +135,32 @@ namespace IRaCIS.Core.API.Controllers } } + [Route("base")] + public virtual async Task FileUploadToOSSAsync(Func> toMemoryStreamFunc) + { + var boundary = HeaderUtilities.RemoveQuotes(MediaTypeHeaderValue.Parse(Request.ContentType).Boundary).Value; + + var reader = new MultipartReader(boundary, HttpContext.Request.Body); + + var section = await reader.ReadNextSectionAsync(); + + while (section != null) + { + var hasContentDispositionHeader = ContentDispositionHeaderValue.TryParse(section.ContentDisposition, out var contentDisposition); + if (hasContentDispositionHeader) + { + var fileName = contentDisposition.FileName.Value; + + await toMemoryStreamFunc(fileName, section.Body); + + } + + section = await reader.ReadNextSectionAsync(); + + } + + } + /// 流式上传 Dicom上传 @@ -280,9 +307,6 @@ namespace IRaCIS.Core.API.Controllers - - - if (!HttpContext.Request.HasFormContentType || !MediaTypeHeaderValue.TryParse(HttpContext.Request.ContentType, out var mediaTypeHeader) || string.IsNullOrEmpty(mediaTypeHeader.Boundary.Value)) @@ -756,11 +780,13 @@ namespace IRaCIS.Core.API.Controllers [HttpPost("QCOperation/UploadVisitCheckExcel/{trialId:guid}")] [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] //[Authorize(Policy = IRaCISPolicy.PM_APM)] - public async Task UploadVisitCheckExcel(Guid trialId) + public async Task UploadVisitCheckExcel(Guid trialId, [FromServices] IOSSService oSSService) { - var (serverFilePath, relativePath, fileName) = (string.Empty, string.Empty, string.Empty); - await FileUploadAsync(async (realFileName) => + var fileName = string.Empty; + var templateFileStream = new MemoryStream(); + + await FileUploadToOSSAsync(async (realFileName, fileStream) => { fileName = realFileName; @@ -770,19 +796,16 @@ namespace IRaCIS.Core.API.Controllers throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_SupportedFormats")); } - (serverFilePath, relativePath) = FileStoreHelper.GetTrialCheckFilePath(_hostEnvironment, fileName, trialId); + fileStream.CopyTo(templateFileStream); + templateFileStream.Seek(0, SeekOrigin.Begin); - await _repository.AddAsync(new UserUploadFile() - { - TrialId = trialId, - CreateTime = DateTime.Now, - FileName = fileName, - FilePath = relativePath, - RelativePath = relativePath, - CreateUserId = _userInfo.Id - }); - return serverFilePath; + var ossRelativePath = oSSService.UploadToOSS(fileStream, "InspectionUpload/Check", realFileName); + + await _repository.AddAsync(new InspectionFile() { FileName = realFileName, RelativePath = ossRelativePath, TrialId = trialId }); + + return ossRelativePath; + }); @@ -814,7 +837,7 @@ namespace IRaCIS.Core.API.Controllers { var Importer = new ExcelImporter(); - var import = await Importer.Import(System.IO.File.OpenRead(serverFilePath)); + var import = await Importer.Import(templateFileStream); if (import.Exception != null) return ResponseOutput.NotOk(import.Exception.ToString()); @@ -829,7 +852,7 @@ namespace IRaCIS.Core.API.Controllers #region 临时方案 MiniExcel读取 然后保存为xlsx 再用 Magicodes验证数据 //因为csv 需要加配置文件 不然都是null - etcCheckList = MiniExcel.Query(serverFilePath, null, configuration: new MiniExcelLibs.Csv.CsvConfiguration() + etcCheckList = MiniExcel.Query(templateFileStream, null, configuration: new MiniExcelLibs.Csv.CsvConfiguration() { StreamReaderFunc = (stream) => new StreamReader(stream, Encoding.GetEncoding("gb2312")) }).ToList(); @@ -874,35 +897,35 @@ namespace IRaCIS.Core.API.Controllers else { //为了支持 xls 引入新的组件库 - using (var stream = System.IO.File.Open(serverFilePath, FileMode.Open, FileAccess.Read)) + //using (var stream = System.IO.File.Open(templateFileStream, FileMode.Open, FileAccess.Read)) + //{ + // Auto-detect format, supports: + // - Binary Excel files (2.0-2003 format; *.xls) + // - OpenXml Excel files (2007 format; *.xlsx, *.xlsb) + using (var reader = ExcelReaderFactory.CreateReader(templateFileStream)) { - // Auto-detect format, supports: - // - Binary Excel files (2.0-2003 format; *.xls) - // - OpenXml Excel files (2007 format; *.xlsx, *.xlsb) - using (var reader = ExcelReaderFactory.CreateReader(stream)) + + // 2. Use the AsDataSet extension method + var dateset = reader.AsDataSet(); + + foreach (DataRow col in dateset.Tables[0].Rows) { - // 2. Use the AsDataSet extension method - var dateset = reader.AsDataSet(); - - foreach (DataRow col in dateset.Tables[0].Rows) + etcCheckList.Add(new CheckViewModel() { - - etcCheckList.Add(new CheckViewModel() - { - SiteCode = col[0].ToString(), - SubjectCode = col[1].ToString(), - VisitName = col[2].ToString(), - StudyDate = col[3].ToString(), - Modality = col[4].ToString(), - }); - } - - etcCheckList.Remove(etcCheckList[0]); - - // The result of each spreadsheet is in result.Tables + SiteCode = col[0].ToString(), + SubjectCode = col[1].ToString(), + VisitName = col[2].ToString(), + StudyDate = col[3].ToString(), + Modality = col[4].ToString(), + }); } + + etcCheckList.Remove(etcCheckList[0]); + + // The result of each spreadsheet is in result.Tables } + } if (etcCheckList == null || etcCheckList.Count == 0) @@ -940,7 +963,6 @@ namespace IRaCIS.Core.API.Controllers return ResponseOutput.Ok(); } - } @@ -948,6 +970,8 @@ namespace IRaCIS.Core.API.Controllers + + #region 项目 系统 基本文件 上传 下载 预览 [ApiExplorerSettings(GroupName = "Common")] @@ -980,30 +1004,38 @@ namespace IRaCIS.Core.API.Controllers [DisableFormValueModelBinding] [UnitOfWork] public async Task UploadTrialSiteSurveyUser(Guid trialId, string baseUrl, string routeUrl, - [FromServices] IRepository _trialSiteRepository, - [FromServices] IRepository _usertypeRepository, - [FromServices] ITrialSiteSurveyService _trialSiteSurveyService) + [FromServices] IRepository _trialSiteRepository, + [FromServices] IRepository _usertypeRepository, + [FromServices] ITrialSiteSurveyService _trialSiteSurveyService, + [FromServices] IOSSService oSSService, + [FromServices] IRepository _inspectionFileRepository) { - var (serverFilePath, relativePath, fileName) = (string.Empty, string.Empty, string.Empty); - await FileUploadAsync(async (realFileName) => - { - fileName = realFileName; + var templateFileStream = new MemoryStream(); - if (!fileName.EndsWith(".xlsx", StringComparison.OrdinalIgnoreCase)) + + await FileUploadToOSSAsync(async (realFileName, fileStream) => + { + await fileStream.CopyToAsync(templateFileStream); + templateFileStream.Seek(0, SeekOrigin.Begin); + + if (!realFileName.EndsWith(".xlsx", StringComparison.OrdinalIgnoreCase)) { // 请用提供格式的模板excel上传需要处理的数据 throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_TemplateUploadData")); } - (serverFilePath, relativePath) = FileStoreHelper.GetOtherFileUploadPath(_hostEnvironment, StaticData.Folder.TempFile, fileName); + var ossRelativePath = oSSService.UploadToOSS(fileStream, "InspectionUpload/SiteSurvey", realFileName); - //FileStoreHelper.UploadOOS(serverFilePath, "testc/test", true); + await _inspectionFileRepository.AddAsync(new InspectionFile() { FileName = realFileName, RelativePath = ossRelativePath, TrialId = trialId }); + + + + return ossRelativePath; - return serverFilePath; }); //去掉空白行 - var excelList = MiniExcel.Query(serverFilePath).ToList() + var excelList = MiniExcel.Query(templateFileStream,excelType:ExcelType.XLSX).ToList() .Where(t => !(string.IsNullOrWhiteSpace(t.TrialSiteCode) && string.IsNullOrWhiteSpace(t.FirstName) && string.IsNullOrWhiteSpace(t.LastName) && string.IsNullOrWhiteSpace(t.Email) && string.IsNullOrWhiteSpace(t.Phone) && string.IsNullOrWhiteSpace(t.UserTypeStr) && string.IsNullOrWhiteSpace(t.OrganizationName))).ToList(); @@ -1033,7 +1065,7 @@ namespace IRaCIS.Core.API.Controllers //有邮箱不符合邮箱格式,请核查Excel数据 throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_InvalidEmail")); } - var generateUserTypeList = new List() { "CRC", "SR", "CRA" }; + var generateUserTypeList = new List() { "CRC", "CRA" }; if (excelList.Any(t => !generateUserTypeList.Contains(t.UserTypeStr.ToUpper()))) { @@ -1045,7 +1077,7 @@ namespace IRaCIS.Core.API.Controllers throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_NoValiddata")); } //处理好 用户类型 和用户类型枚举 - var sysUserTypeList = _usertypeRepository.Where(t => t.UserTypeEnum == UserTypeEnum.CRA || t.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator || t.UserTypeEnum == UserTypeEnum.SR).Select(t => new { UserTypeId = t.Id, t.UserTypeEnum }).ToList(); + var sysUserTypeList = _usertypeRepository.Where(t => t.UserTypeEnum == UserTypeEnum.CRA || t.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator ).Select(t => new { UserTypeId = t.Id, t.UserTypeEnum }).ToList(); var siteList = _trialSiteRepository.Where(t => t.TrialId == trialId && siteCodeList.Contains(t.TrialSiteCode)).Select(t => new { t.TrialSiteCode, t.SiteId }).ToList(); foreach (var item in excelList) @@ -1063,10 +1095,7 @@ namespace IRaCIS.Core.API.Controllers item.UserTypeEnum = UserTypeEnum.CRA; break; - case "SR": - item.UserTypeId = sysUserTypeList.FirstOrDefault(t => t.UserTypeEnum == UserTypeEnum.SR).UserTypeId; - item.UserTypeEnum = UserTypeEnum.SR; - break; + } diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.xml b/IRaCIS.Core.API/IRaCIS.Core.API.xml index 4d391ccd8..11819a905 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.xml +++ b/IRaCIS.Core.API/IRaCIS.Core.API.xml @@ -219,7 +219,7 @@ - + 一致性核查 excel上传 支持三种格式 diff --git a/IRaCIS.Core.API/Startup.cs b/IRaCIS.Core.API/Startup.cs index 498b34c37..f7ef89e47 100644 --- a/IRaCIS.Core.API/Startup.cs +++ b/IRaCIS.Core.API/Startup.cs @@ -75,6 +75,8 @@ namespace IRaCIS.Core.API // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { + // + services.AddHealthChecks(); //ػ services.AddJsonLocalization(options => options.ResourcesPath = "Resources"); @@ -97,7 +99,8 @@ namespace IRaCIS.Core.API services.AddOptions().Configure(_configuration.GetSection("SystemEmailSendConfig")); services.AddOptions().Configure(_configuration.GetSection("BasicSystemConfig")); - + services.AddOptions().Configure(_configuration.GetSection("AliyunOSS")); + services.AddOptions().Configure(_configuration.GetSection("ObjectStoreService")); //̬WebApi + UnifiedApiResultFilter ʡ @@ -242,6 +245,8 @@ namespace IRaCIS.Core.API endpoints.MapControllers(); endpoints.MapHub("/UploadHub"); + + endpoints.MapHealthChecks("/health"); }); diff --git a/IRaCIS.Core.API/appsettings.Prod_Study.json b/IRaCIS.Core.API/appsettings.Prod_Study.json index accbb9c34..6765d0dd8 100644 --- a/IRaCIS.Core.API/appsettings.Prod_Study.json +++ b/IRaCIS.Core.API/appsettings.Prod_Study.json @@ -13,6 +13,7 @@ "accessKeyId": "LTAI5tKvzs7ed3UfSpNk3xwQ", "accessKeySecret": "zTIceGEShlZDGnLrCFfIGFE7TXVRio", "bucketName": "zy-sir-store", + "RoleArn": "acs:ram::1899121822495495:role/oss-upload", "viewEndpoint": "https://zy-sir-cache.oss-cn-shanghai.aliyuncs.com" }, diff --git a/IRaCIS.Core.API/appsettings.Test_Study.json b/IRaCIS.Core.API/appsettings.Test_Study.json index eb1ea2b23..02039a204 100644 --- a/IRaCIS.Core.API/appsettings.Test_Study.json +++ b/IRaCIS.Core.API/appsettings.Test_Study.json @@ -13,6 +13,7 @@ "accessKeyId": "LTAI5tKvzs7ed3UfSpNk3xwQ", "accessKeySecret": "zTIceGEShlZDGnLrCFfIGFE7TXVRio", "bucketName": "zy-sir-test-store", + "RoleArn": "acs:ram::1899121822495495:role/oss-upload", "viewEndpoint": "https://zy-sir-test-store.oss-cn-shanghai.aliyuncs.com" }, "ConnectionStrings": { diff --git a/IRaCIS.Core.API/appsettings.Uat_Study.json b/IRaCIS.Core.API/appsettings.Uat_Study.json index d8e06127f..c0e04560d 100644 --- a/IRaCIS.Core.API/appsettings.Uat_Study.json +++ b/IRaCIS.Core.API/appsettings.Uat_Study.json @@ -13,6 +13,7 @@ "accessKeyId": "LTAI5tKvzs7ed3UfSpNk3xwQ", "accessKeySecret": "zTIceGEShlZDGnLrCFfIGFE7TXVRio", "bucketName": "zy-sir-uat-store", + "RoleArn": "acs:ram::1899121822495495:role/oss-upload", "viewEndpoint": "https://zy-sir-uat-store.oss-cn-shanghai.aliyuncs.com" }, "ConnectionStrings": { diff --git a/IRaCIS.Core.Application/Helper/OSSService.cs b/IRaCIS.Core.Application/Helper/OSSService.cs new file mode 100644 index 000000000..c83ec5fc4 --- /dev/null +++ b/IRaCIS.Core.Application/Helper/OSSService.cs @@ -0,0 +1,209 @@ +using Aliyun.OSS; +using IRaCIS.Core.Application.Contracts; +using IRaCIS.Core.Infrastructure; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Options; +using NPOI.HPSF; +using SharpCompress.Common; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Security.AccessControl; +using System.Text; +using System.Threading.Tasks; + +namespace IRaCIS.Core.Application.Helper +{ + public class MinIOOptions + { + public string Endpoint { get; set; } + public string Port { get; set; } + public bool UseSSL { get; set; } + public string AccessKey { get; set; } + public string SecretKey { get; set; } + public string BucketName { get; set; } + } + + public class AliyunOSSOptions + { + public string RegionId { get; set; } + public string AccessKeyId { get; set; } + public string AccessKeySecret { get; set; } + public string EndPoint { get; set; } + public string BucketName { get; set; } + + public string RoleArn { get; set; } + + public string Region { get; set; } + + public string ViewEndpoint { get; set; } + + } + + public class ObjectStoreServiceOptions + { + public string ObjectStoreUse { get; set; } + public AliyunOSSOptions AliyunOSS { get; set; } + public MinIOOptions MinIO { get; set; } + + } + + public class ObjectStoreDTO + { + public string ObjectStoreUse { get; set; } + public AliyunOSSTempToken AliyunOSS { get; set; } + + public MinIOOptions MinIO { get; set; } + + } + + public class AliyunOSSTempToken + { + public string AccessKeyId { get; set; } + public string AccessKeySecret { get; set; } + public string SecurityToken { get; set; } + public string Expiration { get; set; } + + public string Region { get; set; } + public string BucketName { get; set; } + public string ViewEndpoint { get; set; } + } + + + + public enum ObjectStoreUse + { + AliyunOSS = 0, + MinIO = 1, + AWS = 2, + } + + + + + + + public interface IOSSService + { + public string UploadToOSS(Stream fileStream, string oosFolderPath, string fileRealName); + public string UploadToOSS(string localFilePath, string oosFolderPath); + + public void DownLoadFromOSS(string ossRelativePath, string localFilePath); + + + } + public class OSSService : IOSSService + { + + public AliyunOSSOptions _OSSConfig { get; set; } + + public OssClient _ossClient { get; set; } + + + + public OSSService(IOptionsMonitor options) + { + var ossOptions = options.CurrentValue; + + _OSSConfig = ossOptions; + + _ossClient = new OssClient(_OSSConfig.EndPoint, _OSSConfig.AccessKeyId, _OSSConfig.AccessKeySecret); + + } + + /// + /// oosFolderPath 不要 "/ "开头 应该: TempFolder/ChildFolder + /// + /// + /// + /// + /// + /// + public string UploadToOSS(Stream fileStream, string oosFolderPath,string fileRealName) + { + + var ossRelativePath = oosFolderPath + "/" + fileRealName; + + try + { + using (var memoryStream = new MemoryStream()) + { + fileStream.Seek(0, SeekOrigin.Begin); + + fileStream.CopyTo(memoryStream); + + memoryStream.Seek(0, SeekOrigin.Begin); + + // 上传文件 + var result = _ossClient.PutObject(_OSSConfig.BucketName, ossRelativePath, memoryStream); + } + + + return "/" + ossRelativePath; + } + catch (Exception ex) + { + throw new BusinessValidationFailedException("oss上传失败" + ex.Message); + + } + } + + /// + /// oosFolderPath 不要 "/ "开头 应该: TempFolder/ChildFolder + /// + /// + /// + /// + /// + public string UploadToOSS(string localFilePath, string oosFolderPath) + { + var localFileName = Path.GetFileName(localFilePath); + + var ossRelativePath = oosFolderPath + "/" + localFileName; + + + try + { + // 上传文件 + var result = _ossClient.PutObject(_OSSConfig.BucketName, ossRelativePath, localFilePath); + + return ossRelativePath; + } + catch (Exception ex) + { + throw new BusinessValidationFailedException("oss上传失败" + ex.Message); + + } + } + + public void DownLoadFromOSS(string ossRelativePath, string localFilePath) + { + try + { + var result = _ossClient.GetObject(_OSSConfig.BucketName, ossRelativePath); + + // 将下载的文件流保存到本地文件 + using (var fs = File.OpenWrite(localFilePath)) + { + result.Content.CopyTo(fs); + fs.Close(); + } + } + catch (Exception ex) + { + + throw new BusinessValidationFailedException("oss下载失败!" + ex.Message); + } + + + } + + + + + } + + +} diff --git a/IRaCIS.Core.Application/Service/QC/QCListService.cs b/IRaCIS.Core.Application/Service/QC/QCListService.cs index 41c6c8df8..171a83016 100644 --- a/IRaCIS.Core.Application/Service/QC/QCListService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCListService.cs @@ -19,7 +19,7 @@ namespace IRaCIS.Core.Application.Image.QA private readonly IRepository _clinicalDataTrialSet; private readonly IRepository _trialQCQuestionAnswerRepository; private readonly IRepository _trialQCQuestionRepository; - private readonly IRepository _UserUploadFileRepository; + private readonly IRepository _consistencyCheckFileRepository; private IReadingImageTaskService _IReadingImageTaskService; @@ -30,14 +30,14 @@ namespace IRaCIS.Core.Application.Image.QA IRepository trialQCQuestionAnswerRepository, IRepository trialQCQuestionRepository, IReadingImageTaskService IReadingImageTaskService, - IRepository UserUploadFileRepository + IRepository consistencyCheckFileRepository ) { this._IReadingImageTaskService = IReadingImageTaskService; _subjectVisitRepository = subjectVisitRepository; this._trialQCQuestionAnswerRepository = trialQCQuestionAnswerRepository; this._trialQCQuestionRepository = trialQCQuestionRepository; - this._UserUploadFileRepository = UserUploadFileRepository; + this._consistencyCheckFileRepository = consistencyCheckFileRepository; _trialRepository = trialRepository; this._clinicalDataTrialSet = clinicalDataTrialSet; } @@ -851,7 +851,7 @@ namespace IRaCIS.Core.Application.Image.QA [HttpPost] public async Task> GetUserUploadFile(GetUserUploadFileInDto indto) { - var query = _repository.Where(t => t.TrialId == indto.TrialId) + var query = _repository.Where(t => t.TrialId == indto.TrialId) .ProjectTo(_mapper.ConfigurationProvider); return await query.ToPagedListAsync(indto.PageIndex, indto.PageSize, "CreateTime", false); diff --git a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs index f0f5cec09..07f3b8df1 100644 --- a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs @@ -494,7 +494,7 @@ namespace IRaCIS.Core.Application.Service ; // 一致性核查文件 - CreateMap() + CreateMap() .ForMember(d => d.CreateUserName, u => u.MapFrom(t => t.User.FirstName + "/" + t.User.LastName)); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs index 5ae34bee3..a3735827c 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs @@ -204,11 +204,12 @@ namespace IRaCIS.Core.Application ToBeRepliedCount = t.SubjectVisitList.Where(u => u.CheckState == CheckStateEnum.CVIng && u.CheckChallengeDialogList.OrderByDescending(t => t.CreateTime).First().UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).Count(), - }).Where(x => x.ToBeRepliedCount > 0); + }).Where(x => x.ToBeRepliedCount > 0); + var defalutSortArray = new string[] { nameof(CheckToBeDoneDto.UrgentCount) + " desc", nameof(CheckToBeDoneDto.ToBeCheckedCount) + " desc" }; - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(CheckToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); var totalToBeCheckedCount = await _subjectVisitRepository.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) .Where(u => u.CheckState == CheckStateEnum.ToCheck).CountAsync(); @@ -250,7 +251,9 @@ namespace IRaCIS.Core.Application }).Where(x => x.ToBeApprovalCount > 0); - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(ReReadingApplyToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); + var defalutSortArray = new string[] { nameof(ReReadingApplyToBeDoneDto.UrgentCount) + " desc", nameof(ReReadingApplyToBeDoneDto.ToBeApprovalCount) + " desc" }; + + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); var toBeApprovalCount = _visitTaskReReadingRepository @@ -271,7 +274,7 @@ namespace IRaCIS.Core.Application [HttpPost] public async Task>> GetPMClinicalDataToBeDoneList(ReviewerSelectToBeDoneQuery inQuery) { - + var query = _trialRepository .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.Id)) .Select(t => new GetPMClinicalDataToBeDoneListOutDto() @@ -281,14 +284,18 @@ namespace IRaCIS.Core.Application ExperimentName = t.ExperimentName, TrialCode = t.TrialCode, - - ToBeApprovalCount = t.ReadModuleList.Where(u => u.IsCRCConfirm&&!u.IsPMConfirm).Count() + + ToBeApprovalCount = t.ReadModuleList.Where(u => u.IsCRCConfirm && !u.IsPMConfirm).Count() }).Where(x => x.ToBeApprovalCount > 0); - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(ReviewerSelectToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); - - var all =await _trialRepository + var defalutSortArray = new string[] { nameof(GetPMClinicalDataToBeDoneListOutDto.ToBeApprovalCount) + " desc" }; + + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); + + + + var all = await _trialRepository .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.Id)) .Select(t => new GetPMClinicalDataToBeDoneListOutDto() { @@ -297,7 +304,7 @@ namespace IRaCIS.Core.Application ToBeApprovalCount = t.ReadModuleList.Where(u => u.IsCRCConfirm && !u.IsPMConfirm).Count() }).ToListAsync(); - return ResponseOutput.Ok(result, new { ToBeApprovalCount = all.Sum(x=>x.ToBeApprovalCount) }); ; + return ResponseOutput.Ok(result, new { ToBeApprovalCount = all.Sum(x => x.ToBeApprovalCount) }); ; } #endregion @@ -335,7 +342,10 @@ namespace IRaCIS.Core.Application }).Where(x => x.ToBeApprovalCount > 0); - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(ReReadingApprovalToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); + var defalutSortArray = new string[] { nameof(ReReadingApprovalToBeDoneDto.UrgentCount) + " desc", nameof(ReReadingApprovalToBeDoneDto.ToBeApprovalCount) + " desc" }; + + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); + var toBeApprovalCount = _visitTaskReReadingRepository .Where(t => t.OriginalReReadingTask.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) @@ -373,13 +383,15 @@ namespace IRaCIS.Core.Application ExperimentName = t.ExperimentName, TrialCode = t.TrialCode, UrgentCount = t.SubjectVisitList.Where(u => u.IsBaseLine && u.SubmitState != SubmitStateEnum.Submitted && u.IsUrgent).Count(), - ToBeDealedCount = t.ReadingClinicalDataList.Where(x=>!x.IsSign&& x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC && x.ClinicalDataTrialSet.ClinicalDataLevel != ClinicalLevel.SubjectVisit&& x.ClinicalDataTrialSet.ClinicalDataLevel != ClinicalLevel.Subject).Count(), - ToBeVisitCount= t.ReadingClinicalDataList.Where(x => !x.IsSign && x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC && x.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.SubjectVisit).Count(), - ToAllCount= t.ReadingClinicalDataList.Where(x => !x.IsSign && x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC ).Count(), - ReadModuleCount =t.ReadModuleList.Where(x=>!x.IsPMConfirm).Count(), - }).Where(x=>x.ToBeDealedCount > 0); + ToBeDealedCount = t.ReadingClinicalDataList.Where(x => !x.IsSign && x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC && x.ClinicalDataTrialSet.ClinicalDataLevel != ClinicalLevel.SubjectVisit && x.ClinicalDataTrialSet.ClinicalDataLevel != ClinicalLevel.Subject).Count(), + ToBeVisitCount = t.ReadingClinicalDataList.Where(x => !x.IsSign && x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC && x.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.SubjectVisit).Count(), + ToAllCount = t.ReadingClinicalDataList.Where(x => !x.IsSign && x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC).Count(), + ReadModuleCount = t.ReadModuleList.Where(x => !x.IsPMConfirm).Count(), + }).Where(x => x.ToBeDealedCount > 0); - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(ImageClinicalDataToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); + var defalutSortArray = new string[] { nameof(ImageClinicalDataToBeDoneDto.UrgentCount) + " desc", nameof(ImageClinicalDataToBeDoneDto.ReadModuleCount) + " desc" }; + + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); var toBeDealedCount = _subjectVisitRepository //.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id) && t.Trial.clinicalDataTrialSets.Any(t => t.ClinicalDataLevel == ClinicalLevel.Subject && t.IsConfirm)) @@ -418,7 +430,10 @@ namespace IRaCIS.Core.Application ReadModuleCount = t.ReadModuleList.Where(x => !x.IsPMConfirm).Count(), }).Where(x => x.ReadModuleCount > 0); - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(ImageClinicalDataToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); + var defalutSortArray = new string[] { nameof(ImageClinicalDataToBeDoneDto.UrgentCount) + " desc", nameof(ImageClinicalDataToBeDoneDto.ToBeDealedCount) + " desc" }; + + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); + var toBeDealedCount = _subjectVisitRepository //.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id) && t.Trial.clinicalDataTrialSets.Any(t => t.ClinicalDataLevel == ClinicalLevel.Subject && t.IsConfirm)) @@ -461,11 +476,14 @@ namespace IRaCIS.Core.Application ToBeDealedCount = t.SubjectVisitList.Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.Id)) .SelectMany(c => c.QCChallengeList) - .Where(u => u.IsClosed == false && (u.LatestReplyUser.UserTypeEnum == UserTypeEnum.IQC || u.LatestReplyUserId==null)).Count(), + .Where(u => u.IsClosed == false && (u.LatestReplyUser.UserTypeEnum == UserTypeEnum.IQC || u.LatestReplyUserId == null)).Count(), }).Where(x => x.ToBeDealedCount > 0); ; - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(ImageQuestionToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); + var defalutSortArray = new string[] { nameof(ImageQuestionToBeDoneDto.UrgentCount) + " desc", nameof(ImageQuestionToBeDoneDto.ToBeDealedCount) + " desc" }; + + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); + var toBeDealedCount = _subjectVisitRepository .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) @@ -507,9 +525,10 @@ namespace IRaCIS.Core.Application }).Where(x => x.ToBeReplyedCount > 0); + var defalutSortArray = new string[] { nameof(ImageCheckQuestionToBeDoneDto.UrgentCount) + " desc", nameof(ImageCheckQuestionToBeDoneDto.ToBeReplyedCount) + " desc" }; + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(ImageCheckQuestionToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); var toBeDealedCount = _subjectVisitRepository .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) @@ -544,15 +563,18 @@ namespace IRaCIS.Core.Application TrialCode = t.TrialCode, UrgentCount = t.SubjectVisitList .Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.Id)) - .Where(u => u.IsUrgent && ((u.SubmitState == SubmitStateEnum.ToSubmit && u.IsPMBackOrReReading)||u.IsQCConfirmedReupload)).Count(), + .Where(u => u.IsUrgent && ((u.SubmitState == SubmitStateEnum.ToSubmit && u.IsPMBackOrReReading) || u.IsQCConfirmedReupload)).Count(), ToBeReUploadCount = t.SubjectVisitList .Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.Id)) - .Where(u => (u.SubmitState == SubmitStateEnum.ToSubmit && u.IsPMBackOrReReading) ||(u.IsQCConfirmedReupload)).Count(), + .Where(u => (u.SubmitState == SubmitStateEnum.ToSubmit && u.IsPMBackOrReReading) || (u.IsQCConfirmedReupload)).Count(), }).Where(x => x.ToBeReUploadCount > 0); - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(ImageReUploadToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); + + var defalutSortArray = new string[] { nameof(ImageReUploadToBeDoneDto.UrgentCount) + " desc", nameof(ImageReUploadToBeDoneDto.ToBeReUploadCount) + " desc" }; + + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); var toBeDealedCount = _subjectVisitRepository .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) @@ -587,7 +609,7 @@ namespace IRaCIS.Core.Application TrialCode = t.TrialCode, UrgentCount = t.SubjectVisitList .Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.Id)) - .Where(u => u.SubmitState == SubmitStateEnum.ToSubmit && (u.IsEnrollmentConfirm ||u.PDState==PDStateEnum.PDProgress || u.Trial.IsUrgent ||u.Subject.IsUrgent)/*u.IsUrgent*/).Count(), + .Where(u => u.SubmitState == SubmitStateEnum.ToSubmit && (u.IsEnrollmentConfirm || u.PDState == PDStateEnum.PDProgress || u.Trial.IsUrgent || u.Subject.IsUrgent)/*u.IsUrgent*/).Count(), ToBeDealedCount = t.SubjectVisitList @@ -596,7 +618,12 @@ namespace IRaCIS.Core.Application }).Where(x => x.ToBeDealedCount > 0); ; - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(ImageSubmittedToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); + + + var defalutSortArray = new string[] { nameof(ImageSubmittedToBeDoneDto.UrgentCount) + " desc", nameof(ImageSubmittedToBeDoneDto.ToBeDealedCount) + " desc" }; + + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); + var toBeDealedCount = _subjectVisitRepository .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) @@ -647,9 +674,13 @@ namespace IRaCIS.Core.Application //待审核通过,统计从已领取到QC提交之间的 已领取 待审核 审核中 (审核完成 领取人就会清理 所以只用查询当前领取人是自己的就好了) ToBeReviewedCount = t.SubjectVisitList.Where(u => u.CurrentActionUserId == _userInfo.Id).Count() - }).Where(x => x.ToBeClaimedCount+x.ToBeReviewedCount > 0); + }).Where(x => x.ToBeClaimedCount + x.ToBeReviewedCount > 0); + + + var defalutSortArray = new string[] { nameof(ImageQualityToBeDoneDto.UrgentCount) + " desc", nameof(ImageQualityToBeDoneDto.ToBeClaimedCount) + " desc" }; + + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(ImageQualityToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); var toBeClaimedCount = _subjectVisitRepository @@ -694,7 +725,10 @@ namespace IRaCIS.Core.Application }).Where(x => x.ToBeDealedCount > 0); ; - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(ImageQuestionToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); + var defalutSortArray = new string[] { nameof(ImageQuestionToBeDoneDto.UrgentCount) + " desc", nameof(ImageQuestionToBeDoneDto.ToBeDealedCount) + " desc" }; + + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); + var toBeDealedCount = _subjectVisitRepository .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) @@ -835,8 +869,9 @@ namespace IRaCIS.Core.Application #endregion + var defalutSortArray = new string[] { nameof(IRImageReadingToBeDoneDto.UrgentCount) + " desc", nameof(IRImageReadingToBeDoneDto.UnReadCount) + " desc" }; - var result = await newQuery.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(IRImageReadingToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); + var result = await newQuery.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); var toBeDealedCount = _trialRepository .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.Id)) @@ -899,9 +934,14 @@ namespace IRaCIS.Core.Application //ToBeReplyedCount = g.Where(u => // u.ReadingMedicalReviewDialogList.OrderByDescending(l => l.CreateTime).First().UserTypeEnumInt == (int)UserTypeEnum.MIM).Count(), - }); + }).Where(t => t.ToBeReplyedCount > 0); + + + var defalutSortArray = new string[] { nameof(MedicalCommentsToBeDoneDto.UrgentCount) + " desc", nameof(MedicalCommentsToBeDoneDto.ToBeReplyedCount) + " desc" }; + + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); + - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(MedicalCommentsToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); var toBeDealedCount = _taskMedicalReviewRepository .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) @@ -965,20 +1005,23 @@ namespace IRaCIS.Core.Application ToBeReviewedCount = g.Where(u => !u.IsInvalid && u.AuditState != MedicalReviewAuditState.HaveSigned).Count() - }); + }).Where(t => t.ToBeReplyedCount > 0); #endregion + var defalutSortArray = new string[] { nameof(MedicalCommentsToBeDoneDto.UrgentCount) + " desc", nameof(MedicalCommentsToBeDoneDto.ToBeReplyedCount) + " desc" }; + + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); + - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(MedicalCommentsToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); var toBeReplyedQuery = _taskMedicalReviewRepository .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) .Where(t => t.IsClosedDialog == false) .Where(u => u.LatestReplyUser.UserTypeEnum == UserTypeEnum.IndependentReviewer); - - //.Where(u => u.ReadingMedicalReviewDialogList.OrderByDescending(l => l.CreateTime).First().UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer); + + //.Where(u => u.ReadingMedicalReviewDialogList.OrderByDescending(l => l.CreateTime).First().UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer); var toBeReplyedCount = toBeReplyedQuery.Count(); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs index 62849f626..c46592ff5 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs @@ -306,11 +306,15 @@ namespace IRaCIS.Application.Services await _repository.BatchDeleteAsync(o => o.ClinicalForm.TrialId == trialId); await _repository.BatchDeleteAsync(o => o.TrialId == trialId); - await _repository.BatchDeleteAsync(o => o.TrialId == trialId); + await _repository.BatchDeleteAsync(o => o.TrialReadingCriterion.TrialId == trialId); await _repository.BatchDeleteAsync(o => o.TrialReadingCriterion.TrialId == trialId); + await _repository.BatchDeleteAsync(o => o.SubjectVisit.TrialId == trialId); + await _repository.BatchDeleteAsync(o => o.TrialId == trialId); + await _repository.BatchDeleteAsync(o => o.TrialId == trialId); + await _repository.BatchDeleteAsync(o => o.TrialReadingCriterion.TrialId == trialId); await _repository.BatchDeleteAsync(o => o.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.TrialId == trialId); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs index e3dc9b5c9..ed67989ba 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs @@ -323,7 +323,7 @@ namespace IRaCIS.Core.Application.Services { //CRC只看到他负责的 - var list = await _trialSiteRepository.Where(t => t.TrialId == trialId) + var list = await _trialSiteRepository.Where(t => t.TrialId == trialId).IgnoreQueryFilters() .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.CRCUserList.Any(t => t.UserId == _userInfo.Id)) .ProjectTo(_mapper.ConfigurationProvider).OrderBy(t => t.TrialSiteCode).ToListAsync(); diff --git a/IRaCIS.Core.Domain/QC/UserUploadFile.cs b/IRaCIS.Core.Domain/QC/UserUploadFile.cs index 78f34a959..2cc382da9 100644 --- a/IRaCIS.Core.Domain/QC/UserUploadFile.cs +++ b/IRaCIS.Core.Domain/QC/UserUploadFile.cs @@ -7,18 +7,15 @@ namespace IRaCIS.Core.Domain.Models /// /// 一致性核查文件 /// - [Table("UserUploadFile")] - public class UserUploadFile : Entity, IAuditAdd + [Table("InspectionFile")] + public class InspectionFile : Entity, IAuditAdd { /// /// 文件名称 /// public string FileName { get; set; } - /// - /// 文件路径 - /// - public string FilePath { get; set; } + /// /// 相对路径 diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index eff31d601..032dd2f80 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -1130,7 +1130,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common await InsertInspection(entity, type, x => new InspectionConvertDTO() { IsDistinctionInterface = false, - ObjectRelationParentId = x.TrialId + + ObjectRelationParentId = entity.TrialId, + TrialReadingCriterionId = x.TrialReadingCriterionId, + }, new { ParentQuestionName = parentQuestionName }); } @@ -1353,11 +1356,11 @@ namespace IRaCIS.Core.Infra.EFCore.Common // 一致性核查文件 是否需要单独一个表记录? - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(UserUploadFile))) + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(InspectionFile))) { var type = GetEntityAuditOpt(item); - await InsertInspection(item.Entity as UserUploadFile, type, x => new InspectionConvertDTO() + await InsertInspection(item.Entity as InspectionFile, type, x => new InspectionConvertDTO() { ObjectRelationParentId = x.TrialId @@ -1408,6 +1411,30 @@ namespace IRaCIS.Core.Infra.EFCore.Common }); } + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialSiteUserSurvey))) + { + var type = GetEntityAuditOpt(item); + + var entity = item.Entity as TrialSiteUserSurvey; + + await InsertInspection(entity, type, x => new InspectionConvertDTO() + { + IsDistinctionInterface = false + + }); + } + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialSiteEquipmentSurvey))) + { + var type = GetEntityAuditOpt(item); + + var entity = item.Entity as TrialSiteEquipmentSurvey; + + await InsertInspection(entity, type, x => new InspectionConvertDTO() + { + IsDistinctionInterface = false + + }); + } #endregion @@ -1516,6 +1543,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common } await InsertInspection(entity, type, x => new InspectionConvertDTO() { + IsDistinctionInterface= type == AuditOpt.Update ? true : false, TrialId = x.TrialId, ObjectRelationParentId = x.TrialId @@ -1566,6 +1594,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common await InsertInspection(item.Entity as TrialSiteUser, type, x => new InspectionConvertDTO { + IsDistinctionInterface= type == AuditOpt.Update ? true : false, TrialId = x.TrialId, ObjectRelationParentId = entity.TrialSite.Id, ObjectRelationParentId2 = x.UserId, @@ -1709,6 +1738,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common SubjectVisitId = x.Id, SiteId = x.SiteId, + ExtraIndentification = extraIdentification, + }, //兼容之前的配置名 new { SubjectVisitName = entity.VisitName } @@ -2106,12 +2137,12 @@ namespace IRaCIS.Core.Infra.EFCore.Common if (entity.RequestReReadingResultEnum == RequestReReadingResult.Agree) { - extraIdentification = "/" + 1; + extraIdentification = extraIdentification+"/" + 1; } else if (entity.RequestReReadingResultEnum == RequestReReadingResult.Reject) { - extraIdentification = "/" + 2; + extraIdentification = extraIdentification+ "/" + 2; } break; } diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index bf54cfa5a..29e9d87c9 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -466,7 +466,7 @@ namespace IRaCIS.Core.Infra.EFCore public virtual DbSet FrontAuditConfig { get; set; } - public virtual DbSet UserUploadFile { get; set; } + public virtual DbSet InspectionFile { get; set; } public virtual DbSet CommonDocument { get; set; }