Compare commits
3 Commits
ae83c753cb
...
6e22515603
| Author | SHA1 | Date |
|---|---|---|
|
|
6e22515603 | |
|
|
abd5c8942d | |
|
|
3decef7693 |
|
|
@ -24,6 +24,7 @@ using Magicodes.ExporterAndImporter.Excel;
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Cors.Infrastructure;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
@ -37,7 +38,7 @@ using Microsoft.Net.Http.Headers;
|
||||||
using MiniExcelLibs;
|
using MiniExcelLibs;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using SharpCompress.Archives;
|
using SharpCompress.Archives;
|
||||||
using SharpCompress.Common;
|
using SkiaSharp;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
|
@ -134,6 +135,32 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Route("base")]
|
||||||
|
public virtual async Task FileUploadToOSSAsync(Func<string, Stream, Task<string>> 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();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary> 流式上传 Dicom上传 </summary>
|
/// <summary> 流式上传 Dicom上传 </summary>
|
||||||
|
|
@ -280,9 +307,6 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!HttpContext.Request.HasFormContentType ||
|
if (!HttpContext.Request.HasFormContentType ||
|
||||||
!MediaTypeHeaderValue.TryParse(HttpContext.Request.ContentType, out var mediaTypeHeader) ||
|
!MediaTypeHeaderValue.TryParse(HttpContext.Request.ContentType, out var mediaTypeHeader) ||
|
||||||
string.IsNullOrEmpty(mediaTypeHeader.Boundary.Value))
|
string.IsNullOrEmpty(mediaTypeHeader.Boundary.Value))
|
||||||
|
|
@ -756,11 +780,13 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
[HttpPost("QCOperation/UploadVisitCheckExcel/{trialId:guid}")]
|
[HttpPost("QCOperation/UploadVisitCheckExcel/{trialId:guid}")]
|
||||||
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
||||||
//[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
//[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
||||||
public async Task<IResponseOutput> UploadVisitCheckExcel(Guid trialId)
|
public async Task<IResponseOutput> UploadVisitCheckExcel(Guid trialId, [FromServices] IOSSService oSSService)
|
||||||
{
|
{
|
||||||
|
|
||||||
var (serverFilePath, relativePath, fileName) = (string.Empty, string.Empty, string.Empty);
|
var fileName = string.Empty;
|
||||||
await FileUploadAsync(async (realFileName) =>
|
var templateFileStream = new MemoryStream();
|
||||||
|
|
||||||
|
await FileUploadToOSSAsync(async (realFileName, fileStream) =>
|
||||||
{
|
{
|
||||||
fileName = realFileName;
|
fileName = realFileName;
|
||||||
|
|
||||||
|
|
@ -770,19 +796,16 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_SupportedFormats"));
|
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/SiteSurvey", 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 Importer = new ExcelImporter();
|
||||||
|
|
||||||
var import = await Importer.Import<CheckViewModel>(System.IO.File.OpenRead(serverFilePath));
|
var import = await Importer.Import<CheckViewModel>(templateFileStream);
|
||||||
|
|
||||||
if (import.Exception != null) return ResponseOutput.NotOk(import.Exception.ToString());
|
if (import.Exception != null) return ResponseOutput.NotOk(import.Exception.ToString());
|
||||||
|
|
||||||
|
|
@ -829,7 +852,7 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
#region 临时方案 MiniExcel读取 然后保存为xlsx 再用 Magicodes验证数据
|
#region 临时方案 MiniExcel读取 然后保存为xlsx 再用 Magicodes验证数据
|
||||||
|
|
||||||
//因为csv 需要加配置文件 不然都是null
|
//因为csv 需要加配置文件 不然都是null
|
||||||
etcCheckList = MiniExcel.Query<CheckViewModel>(serverFilePath, null, configuration: new MiniExcelLibs.Csv.CsvConfiguration()
|
etcCheckList = MiniExcel.Query<CheckViewModel>(templateFileStream, null, configuration: new MiniExcelLibs.Csv.CsvConfiguration()
|
||||||
{
|
{
|
||||||
StreamReaderFunc = (stream) => new StreamReader(stream, Encoding.GetEncoding("gb2312"))
|
StreamReaderFunc = (stream) => new StreamReader(stream, Encoding.GetEncoding("gb2312"))
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
@ -874,35 +897,35 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//为了支持 xls 引入新的组件库
|
//为了支持 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)
|
// 2. Use the AsDataSet extension method
|
||||||
// - OpenXml Excel files (2007 format; *.xlsx, *.xlsb)
|
var dateset = reader.AsDataSet();
|
||||||
using (var reader = ExcelReaderFactory.CreateReader(stream))
|
|
||||||
|
foreach (DataRow col in dateset.Tables[0].Rows)
|
||||||
{
|
{
|
||||||
|
|
||||||
// 2. Use the AsDataSet extension method
|
etcCheckList.Add(new CheckViewModel()
|
||||||
var dateset = reader.AsDataSet();
|
|
||||||
|
|
||||||
foreach (DataRow col in dateset.Tables[0].Rows)
|
|
||||||
{
|
{
|
||||||
|
SiteCode = col[0].ToString(),
|
||||||
etcCheckList.Add(new CheckViewModel()
|
SubjectCode = col[1].ToString(),
|
||||||
{
|
VisitName = col[2].ToString(),
|
||||||
SiteCode = col[0].ToString(),
|
StudyDate = col[3].ToString(),
|
||||||
SubjectCode = col[1].ToString(),
|
Modality = col[4].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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
etcCheckList.Remove(etcCheckList[0]);
|
||||||
|
|
||||||
|
// The result of each spreadsheet is in result.Tables
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (etcCheckList == null || etcCheckList.Count == 0)
|
if (etcCheckList == null || etcCheckList.Count == 0)
|
||||||
|
|
@ -940,7 +963,6 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
return ResponseOutput.Ok();
|
return ResponseOutput.Ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -948,6 +970,8 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region 项目 系统 基本文件 上传 下载 预览
|
#region 项目 系统 基本文件 上传 下载 预览
|
||||||
|
|
||||||
[ApiExplorerSettings(GroupName = "Common")]
|
[ApiExplorerSettings(GroupName = "Common")]
|
||||||
|
|
@ -980,30 +1004,38 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
[DisableFormValueModelBinding]
|
[DisableFormValueModelBinding]
|
||||||
[UnitOfWork]
|
[UnitOfWork]
|
||||||
public async Task<IResponseOutput> UploadTrialSiteSurveyUser(Guid trialId, string baseUrl, string routeUrl,
|
public async Task<IResponseOutput> UploadTrialSiteSurveyUser(Guid trialId, string baseUrl, string routeUrl,
|
||||||
[FromServices] IRepository<TrialSite> _trialSiteRepository,
|
[FromServices] IRepository<TrialSite> _trialSiteRepository,
|
||||||
[FromServices] IRepository<UserType> _usertypeRepository,
|
[FromServices] IRepository<UserType> _usertypeRepository,
|
||||||
[FromServices] ITrialSiteSurveyService _trialSiteSurveyService)
|
[FromServices] ITrialSiteSurveyService _trialSiteSurveyService,
|
||||||
|
[FromServices] IOSSService oSSService,
|
||||||
|
[FromServices] IRepository<InspectionFile> _inspectionFileRepository)
|
||||||
{
|
{
|
||||||
var (serverFilePath, relativePath, fileName) = (string.Empty, string.Empty, string.Empty);
|
var templateFileStream = new MemoryStream();
|
||||||
await FileUploadAsync(async (realFileName) =>
|
|
||||||
{
|
|
||||||
fileName = realFileName;
|
|
||||||
|
|
||||||
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上传需要处理的数据
|
// 请用提供格式的模板excel上传需要处理的数据
|
||||||
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_TemplateUploadData"));
|
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<SiteSurveyUserImportDto>(serverFilePath).ToList()
|
var excelList = MiniExcel.Query<SiteSurveyUserImportDto>(templateFileStream,excelType:ExcelType.XLSX).ToList()
|
||||||
.Where(t => !(string.IsNullOrWhiteSpace(t.TrialSiteCode) && string.IsNullOrWhiteSpace(t.FirstName) && string.IsNullOrWhiteSpace(t.LastName) && string.IsNullOrWhiteSpace(t.Email)
|
.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();
|
&& string.IsNullOrWhiteSpace(t.Phone) && string.IsNullOrWhiteSpace(t.UserTypeStr) && string.IsNullOrWhiteSpace(t.OrganizationName))).ToList();
|
||||||
|
|
||||||
|
|
@ -1033,7 +1065,7 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
//有邮箱不符合邮箱格式,请核查Excel数据
|
//有邮箱不符合邮箱格式,请核查Excel数据
|
||||||
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_InvalidEmail"));
|
throw new BusinessValidationFailedException(StaticData.International("UploadDownLoad_InvalidEmail"));
|
||||||
}
|
}
|
||||||
var generateUserTypeList = new List<string>() { "CRC", "SR", "CRA" };
|
var generateUserTypeList = new List<string>() { "CRC", "CRA" };
|
||||||
|
|
||||||
if (excelList.Any(t => !generateUserTypeList.Contains(t.UserTypeStr.ToUpper())))
|
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"));
|
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();
|
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)
|
foreach (var item in excelList)
|
||||||
|
|
@ -1063,10 +1095,7 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
item.UserTypeEnum = UserTypeEnum.CRA;
|
item.UserTypeEnum = UserTypeEnum.CRA;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "SR":
|
|
||||||
item.UserTypeId = sysUserTypeList.FirstOrDefault(t => t.UserTypeEnum == UserTypeEnum.SR).UserTypeId;
|
|
||||||
item.UserTypeEnum = UserTypeEnum.SR;
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@
|
||||||
<param name="_noneDicomStudyRepository"></param>
|
<param name="_noneDicomStudyRepository"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:IRaCIS.Core.API.Controllers.StudyController.UploadVisitCheckExcel(System.Guid)">
|
<member name="M:IRaCIS.Core.API.Controllers.StudyController.UploadVisitCheckExcel(System.Guid,IRaCIS.Core.Application.Helper.IOSSService)">
|
||||||
<summary>
|
<summary>
|
||||||
一致性核查 excel上传 支持三种格式
|
一致性核查 excel上传 支持三种格式
|
||||||
</summary>
|
</summary>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,194 @@
|
||||||
|
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<AliyunOSSOptions> options)
|
||||||
|
{
|
||||||
|
var ossOptions = options.CurrentValue;
|
||||||
|
|
||||||
|
_OSSConfig = ossOptions;
|
||||||
|
|
||||||
|
_ossClient = new OssClient(_OSSConfig.EndPoint, _OSSConfig.AccessKeyId, _OSSConfig.AccessKeySecret);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -19,7 +19,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||||
private readonly IRepository<ClinicalDataTrialSet> _clinicalDataTrialSet;
|
private readonly IRepository<ClinicalDataTrialSet> _clinicalDataTrialSet;
|
||||||
private readonly IRepository<TrialQCQuestionAnswer> _trialQCQuestionAnswerRepository;
|
private readonly IRepository<TrialQCQuestionAnswer> _trialQCQuestionAnswerRepository;
|
||||||
private readonly IRepository<TrialQCQuestion> _trialQCQuestionRepository;
|
private readonly IRepository<TrialQCQuestion> _trialQCQuestionRepository;
|
||||||
private readonly IRepository<UserUploadFile> _UserUploadFileRepository;
|
private readonly IRepository<InspectionFile> _consistencyCheckFileRepository;
|
||||||
|
|
||||||
private IReadingImageTaskService _IReadingImageTaskService;
|
private IReadingImageTaskService _IReadingImageTaskService;
|
||||||
|
|
||||||
|
|
@ -30,14 +30,14 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||||
IRepository<TrialQCQuestionAnswer> trialQCQuestionAnswerRepository,
|
IRepository<TrialQCQuestionAnswer> trialQCQuestionAnswerRepository,
|
||||||
IRepository<TrialQCQuestion> trialQCQuestionRepository,
|
IRepository<TrialQCQuestion> trialQCQuestionRepository,
|
||||||
IReadingImageTaskService IReadingImageTaskService,
|
IReadingImageTaskService IReadingImageTaskService,
|
||||||
IRepository<UserUploadFile> UserUploadFileRepository
|
IRepository<InspectionFile> consistencyCheckFileRepository
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this._IReadingImageTaskService = IReadingImageTaskService;
|
this._IReadingImageTaskService = IReadingImageTaskService;
|
||||||
_subjectVisitRepository = subjectVisitRepository;
|
_subjectVisitRepository = subjectVisitRepository;
|
||||||
this._trialQCQuestionAnswerRepository = trialQCQuestionAnswerRepository;
|
this._trialQCQuestionAnswerRepository = trialQCQuestionAnswerRepository;
|
||||||
this._trialQCQuestionRepository = trialQCQuestionRepository;
|
this._trialQCQuestionRepository = trialQCQuestionRepository;
|
||||||
this._UserUploadFileRepository = UserUploadFileRepository;
|
this._consistencyCheckFileRepository = consistencyCheckFileRepository;
|
||||||
_trialRepository = trialRepository;
|
_trialRepository = trialRepository;
|
||||||
this._clinicalDataTrialSet = clinicalDataTrialSet;
|
this._clinicalDataTrialSet = clinicalDataTrialSet;
|
||||||
}
|
}
|
||||||
|
|
@ -851,7 +851,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<PageOutput<GetUserUploadFileDto>> GetUserUploadFile(GetUserUploadFileInDto indto)
|
public async Task<PageOutput<GetUserUploadFileDto>> GetUserUploadFile(GetUserUploadFileInDto indto)
|
||||||
{
|
{
|
||||||
var query = _repository.Where<UserUploadFile>(t => t.TrialId == indto.TrialId)
|
var query = _repository.Where<InspectionFile>(t => t.TrialId == indto.TrialId)
|
||||||
.ProjectTo<GetUserUploadFileDto>(_mapper.ConfigurationProvider);
|
.ProjectTo<GetUserUploadFileDto>(_mapper.ConfigurationProvider);
|
||||||
|
|
||||||
return await query.ToPagedListAsync(indto.PageIndex, indto.PageSize, "CreateTime", false);
|
return await query.ToPagedListAsync(indto.PageIndex, indto.PageSize, "CreateTime", false);
|
||||||
|
|
|
||||||
|
|
@ -494,7 +494,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
;
|
;
|
||||||
|
|
||||||
// 一致性核查文件
|
// 一致性核查文件
|
||||||
CreateMap<UserUploadFile, GetUserUploadFileDto>()
|
CreateMap<InspectionFile, GetUserUploadFileDto>()
|
||||||
.ForMember(d => d.CreateUserName, u => u.MapFrom(t => t.User.FirstName + "/" + t.User.LastName));
|
.ForMember(d => d.CreateUserName, u => u.MapFrom(t => t.User.FirstName + "/" + t.User.LastName));
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -265,38 +265,6 @@ namespace IRaCIS.Core.Application
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///PM 阅片人筛选 -- PM APM 待办
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="inQuery"></param>
|
|
||||||
/// <param name="_enrollRepository"></param>
|
|
||||||
/// <param name="_trialRepository"></param>
|
|
||||||
/// <returns></returns> vvv
|
|
||||||
[HttpPost]
|
|
||||||
public async Task<IResponseOutput<PageOutput<ReviewerSelectToBeDoneDto>>> GetPM_ReviewerSelectToBeDoneList(ReviewerSelectToBeDoneQuery inQuery
|
|
||||||
, [FromServices] IRepository<Enroll> _enrollRepository,
|
|
||||||
[FromServices] IRepository<Trial> _trialRepository)
|
|
||||||
{
|
|
||||||
var query = _trialRepository
|
|
||||||
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.Id))
|
|
||||||
.Select(t => new ReviewerSelectToBeDoneDto()
|
|
||||||
{
|
|
||||||
TrialId = t.Id,
|
|
||||||
ResearchProgramNo = t.ResearchProgramNo,
|
|
||||||
ExperimentName = t.ExperimentName,
|
|
||||||
TrialCode = t.TrialCode,
|
|
||||||
|
|
||||||
IsUrgent = t.IsUrgent || t.IsSubjectExpeditedView,
|
|
||||||
ToBeApprovalCount = t.EnrollList.Where(u => u.EnrollStatus == EnrollStatus.InviteIntoGroup).Count()
|
|
||||||
}).Where(x => x.ToBeApprovalCount > 0);
|
|
||||||
|
|
||||||
var defalutSortArray = new string[] { nameof(ReviewerSelectToBeDoneDto.IsUrgent) + " 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 = await _enrollRepository.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id))
|
|
||||||
.Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).CountAsync();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取PM核对临床数据
|
/// 获取PM核对临床数据
|
||||||
|
|
@ -344,43 +312,6 @@ namespace IRaCIS.Core.Application
|
||||||
|
|
||||||
#region SPM CPM 待办
|
#region SPM CPM 待办
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///SPM 阅片人筛选
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="inQuery"></param>
|
|
||||||
/// <param name="_enrollRepository"></param>
|
|
||||||
/// <param name="_trialRepository"></param>
|
|
||||||
/// <returns></returns> vvv
|
|
||||||
[HttpPost]
|
|
||||||
public async Task<IResponseOutput<PageOutput<ReviewerSelectToBeDoneDto>>> GetSPM_ReviewerSelectToBeDoneList(ReviewerSelectToBeDoneQuery inQuery
|
|
||||||
, [FromServices] IRepository<Enroll> _enrollRepository,
|
|
||||||
[FromServices] IRepository<Trial> _trialRepository)
|
|
||||||
{
|
|
||||||
var query = _trialRepository
|
|
||||||
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.Id))
|
|
||||||
.Select(t => new ReviewerSelectToBeDoneDto()
|
|
||||||
{
|
|
||||||
TrialId = t.Id,
|
|
||||||
ResearchProgramNo = t.ResearchProgramNo,
|
|
||||||
ExperimentName = t.ExperimentName,
|
|
||||||
TrialCode = t.TrialCode,
|
|
||||||
|
|
||||||
IsUrgent = t.IsUrgent || t.IsSubjectExpeditedView,
|
|
||||||
ToBeApprovalCount = t.EnrollList.Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).Count()
|
|
||||||
}).Where(x => x.ToBeApprovalCount > 0);
|
|
||||||
|
|
||||||
|
|
||||||
var defalutSortArray = new string[] { nameof(ReviewerSelectToBeDoneDto.IsUrgent) + " desc", nameof(ReviewerSelectToBeDoneDto.ToBeApprovalCount) + " desc" };
|
|
||||||
|
|
||||||
var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray);
|
|
||||||
|
|
||||||
|
|
||||||
var toBeApprovalCount = await _enrollRepository.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id))
|
|
||||||
.Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).CountAsync();
|
|
||||||
|
|
||||||
return ResponseOutput.Ok(result, new { TotalToBeApprovalCount = toBeApprovalCount }); ;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// SPM 重阅审批
|
/// SPM 重阅审批
|
||||||
|
|
@ -992,7 +923,7 @@ namespace IRaCIS.Core.Application
|
||||||
#region 不能对包含聚合或子查询的表达式执行聚合函数
|
#region 不能对包含聚合或子查询的表达式执行聚合函数
|
||||||
|
|
||||||
|
|
||||||
UrgentCount = g.Where(u => u.VisitTask.IsUrgent && u.LatestReplyUser.UserTypeEnum == UserTypeEnum.MIM).Count(),
|
UrgentCount = g.Where(u => u.VisitTask.IsUrgent && u.LatestReplyUser.UserTypeEnum== UserTypeEnum.MIM).Count(),
|
||||||
|
|
||||||
ToBeReplyedCount = g.Where(u => u.LatestReplyUser.UserTypeEnum == UserTypeEnum.MIM).Count(),
|
ToBeReplyedCount = g.Where(u => u.LatestReplyUser.UserTypeEnum == UserTypeEnum.MIM).Count(),
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -306,11 +306,15 @@ namespace IRaCIS.Application.Services
|
||||||
await _repository.BatchDeleteAsync<ClinicalQuestionAnswer>(o => o.ClinicalForm.TrialId == trialId);
|
await _repository.BatchDeleteAsync<ClinicalQuestionAnswer>(o => o.ClinicalForm.TrialId == trialId);
|
||||||
await _repository.BatchDeleteAsync<ClinicalForm>(o => o.TrialId == trialId);
|
await _repository.BatchDeleteAsync<ClinicalForm>(o => o.TrialId == trialId);
|
||||||
|
|
||||||
await _repository.BatchDeleteAsync<UserUploadFile>(o => o.TrialId == trialId);
|
|
||||||
await _repository.BatchDeleteAsync<CriterionNidusSystem>(o => o.TrialReadingCriterion.TrialId == trialId);
|
await _repository.BatchDeleteAsync<CriterionNidusSystem>(o => o.TrialReadingCriterion.TrialId == trialId);
|
||||||
|
|
||||||
await _repository.BatchDeleteAsync<CriterionNidusTrial>(o => o.TrialReadingCriterion.TrialId == trialId);
|
await _repository.BatchDeleteAsync<CriterionNidusTrial>(o => o.TrialReadingCriterion.TrialId == trialId);
|
||||||
|
|
||||||
|
await _repository.BatchDeleteAsync<CheckChallengeDialog>(o => o.SubjectVisit.TrialId == trialId);
|
||||||
|
await _repository.BatchDeleteAsync<ClinicalDataTrialSet>(o => o.TrialId == trialId);
|
||||||
|
await _repository.BatchDeleteAsync<InspectionFile>(o => o.TrialId == trialId);
|
||||||
|
await _repository.BatchDeleteAsync<CriterionNidusSystem>(o => o.TrialReadingCriterion.TrialId == trialId);
|
||||||
await _repository.BatchDeleteAsync<DataInspection>(o => o.TrialId == trialId);
|
await _repository.BatchDeleteAsync<DataInspection>(o => o.TrialId == trialId);
|
||||||
await _repository.BatchDeleteAsync<DicomStudy>(t => t.TrialId == trialId);
|
await _repository.BatchDeleteAsync<DicomStudy>(t => t.TrialId == trialId);
|
||||||
await _repository.BatchDeleteAsync<StudyMonitor>(t => t.TrialId == trialId);
|
await _repository.BatchDeleteAsync<StudyMonitor>(t => t.TrialId == trialId);
|
||||||
|
|
|
||||||
|
|
@ -7,18 +7,15 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
///<summary>
|
///<summary>
|
||||||
/// 一致性核查文件
|
/// 一致性核查文件
|
||||||
///</summary>
|
///</summary>
|
||||||
[Table("UserUploadFile")]
|
[Table("InspectionFile")]
|
||||||
public class UserUploadFile : Entity, IAuditAdd
|
public class InspectionFile : Entity, IAuditAdd
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件名称
|
/// 文件名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FileName { get; set; }
|
public string FileName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 文件路径
|
|
||||||
/// </summary>
|
|
||||||
public string FilePath { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 相对路径
|
/// 相对路径
|
||||||
|
|
|
||||||
|
|
@ -1356,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);
|
var type = GetEntityAuditOpt(item);
|
||||||
|
|
||||||
await InsertInspection<UserUploadFile>(item.Entity as UserUploadFile, type, x => new InspectionConvertDTO()
|
await InsertInspection<InspectionFile>(item.Entity as InspectionFile, type, x => new InspectionConvertDTO()
|
||||||
{
|
{
|
||||||
ObjectRelationParentId = x.TrialId
|
ObjectRelationParentId = x.TrialId
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -466,7 +466,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
|
|
||||||
public virtual DbSet<FrontAuditConfig> FrontAuditConfig { get; set; }
|
public virtual DbSet<FrontAuditConfig> FrontAuditConfig { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<UserUploadFile> UserUploadFile { get; set; }
|
public virtual DbSet<InspectionFile> InspectionFile { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<CommonDocument> CommonDocument { get; set; }
|
public virtual DbSet<CommonDocument> CommonDocument { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue