清明节前导表预提交
parent
7dad20e6a1
commit
ed2b53192b
|
@ -361,3 +361,4 @@ MigrationBackup/
|
|||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
/UploadFile/Check
|
||||
|
|
|
@ -79,6 +79,8 @@ namespace IRaCIS.Core.API.Controllers
|
|||
}
|
||||
|
||||
new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType);
|
||||
|
||||
|
||||
return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", doc.Name);
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ using IRaCIS.Core.Infra.EFCore;
|
|||
using System.Globalization;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Localization;
|
||||
using Magicodes.ExporterAndImporter.Core.Filters;
|
||||
using IRaCIS.Core.Application.MediatR.CommandAndQueries;
|
||||
|
||||
namespace IRaCIS.Core.API
|
||||
{
|
||||
|
@ -126,6 +128,8 @@ namespace IRaCIS.Core.API
|
|||
services.AddDicomSetup();
|
||||
|
||||
|
||||
//services.AddSingleton<IImportResultFilter, ImportResultFilteTest>();
|
||||
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
|
|
|
@ -50,4 +50,29 @@
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class CanConvertToTimeAttribute : ValidationAttribute
|
||||
{
|
||||
public const string DefaultErrorMessage = "The {0} field is is not a valid DateTime value";
|
||||
public CanConvertToTimeAttribute() : base(DefaultErrorMessage) { }
|
||||
|
||||
public override bool IsValid(object? value)
|
||||
{
|
||||
if (value is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DateTime.TryParse(value.ToString(), out _) == true)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -60,36 +60,37 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
|
||||
<PackageReference Include="Castle.Core.AsyncInterceptor" Version="2.0.0" />
|
||||
<PackageReference Include="EasyCaching.Interceptor.AspectCore" Version="1.4.1" />
|
||||
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.1" />
|
||||
<PackageReference Include="Castle.Core.AsyncInterceptor" Version="2.1.0" />
|
||||
<PackageReference Include="EasyCaching.Interceptor.AspectCore" Version="1.5.1" />
|
||||
<PackageReference Include="Efferent.Native" Version="4.1.0" />
|
||||
<PackageReference Include="ExcelDataReader" Version="3.6.0" />
|
||||
<PackageReference Include="ExcelDataReader.DataSet" Version="3.6.0" />
|
||||
<PackageReference Include="fo-dicom.Codecs" Version="5.0.3" />
|
||||
<PackageReference Include="fo-dicom.Codecs" Version="5.1.0" />
|
||||
<PackageReference Include="fo-dicom.Drawing" Version="4.0.8" />
|
||||
<PackageReference Include="fo-dicom.Imaging.ImageSharp" Version="5.0.2" />
|
||||
<PackageReference Include="Hangfire" Version="1.7.28" />
|
||||
<PackageReference Include="Magicodes.IE.Core" Version="2.6.1" />
|
||||
<PackageReference Include="Magicodes.IE.Excel" Version="2.6.1" />
|
||||
<PackageReference Include="Magicodes.IE.Excel.AspNetCore" Version="2.6.1" />
|
||||
<PackageReference Include="MailKit" Version="3.1.0" />
|
||||
<PackageReference Include="Magicodes.IE.Core" Version="2.6.3" />
|
||||
<PackageReference Include="Magicodes.IE.Csv" Version="2.6.3" />
|
||||
<PackageReference Include="Magicodes.IE.Excel" Version="2.6.3" />
|
||||
<PackageReference Include="Magicodes.IE.Excel.AspNetCore" Version="2.6.3" />
|
||||
<PackageReference Include="MailKit" Version="3.2.0" />
|
||||
<PackageReference Include="MediatR" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="6.0.1" />
|
||||
<PackageReference Include="MimeKit" Version="3.1.0" />
|
||||
<PackageReference Include="MiniExcel" Version="0.19.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="6.0.3" />
|
||||
<PackageReference Include="MimeKit" Version="3.2.0" />
|
||||
<PackageReference Include="MiniExcel" Version="1.24.3" />
|
||||
<PackageReference Include="My.Extensions.Localization.Json" Version="3.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Panda.DynamicWebApi" Version="1.1.2" />
|
||||
<PackageReference Include="Quartz" Version="3.3.3" />
|
||||
<PackageReference Include="SharpCompress" Version="0.30.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
<PackageReference Include="Panda.DynamicWebApi" Version="1.2.0" />
|
||||
<PackageReference Include="Quartz" Version="3.4.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.31.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.2.3" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.15.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.15" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.3.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.16.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.18" />
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
<PackageReference Include="WinSCP" Version="5.19.5" />
|
||||
<PackageReference Include="WinSCP" Version="5.19.6" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -17,6 +17,9 @@ using IRaCIS.Core.Infra.EFCore;
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using WinSCP;
|
||||
using Magicodes.ExporterAndImporter.Excel;
|
||||
using Newtonsoft.Json;
|
||||
using Magicodes.ExporterAndImporter.Csv;
|
||||
|
||||
namespace IRaCIS.Core.Application.Image.QA
|
||||
{
|
||||
|
@ -569,15 +572,59 @@ namespace IRaCIS.Core.Application.Image.QA
|
|||
|
||||
var etcCheckList = new List<CheckViewModel>();
|
||||
|
||||
if (fileName.EndsWith(".csv"))
|
||||
|
||||
|
||||
#region MiniExcel 需要自己验证数据格式规范
|
||||
|
||||
//if (fileName.EndsWith(".csv"))
|
||||
//{
|
||||
// //因为csv 需要加配置文件 不然都是null
|
||||
// etcCheckList = MiniExcel.Query<CheckViewModel>(filePath, null, configuration: config).ToList();
|
||||
//}
|
||||
//else if (fileName.EndsWith(".xlsx"))
|
||||
//{
|
||||
//
|
||||
|
||||
|
||||
// etcCheckList = MiniExcel.Query<CheckViewModel>(filePath).ToList();
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
//Magicodes 支持自定义特性验证
|
||||
if (fileName.EndsWith(".xlsx"))
|
||||
{
|
||||
var Importer = new ExcelImporter();
|
||||
|
||||
var import = await Importer.Import<CheckViewModel>(File.OpenRead(filePath));
|
||||
|
||||
if (import.Exception != null) return ResponseOutput.NotOk(import.Exception.ToString());
|
||||
|
||||
if (import.RowErrors.Count > 0) return ResponseOutput.NotOk(JsonConvert.SerializeObject(import.RowErrors));
|
||||
|
||||
if (import.TemplateErrors.Count > 0) return ResponseOutput.NotOk(JsonConvert.SerializeObject(import.TemplateErrors));
|
||||
|
||||
etcCheckList = import.Data.ToList();
|
||||
}
|
||||
else if (fileName.EndsWith(".csv"))
|
||||
{
|
||||
|
||||
//因为csv 需要加配置文件 不然都是null
|
||||
etcCheckList = MiniExcel.Query<CheckViewModel>(filePath, null, configuration: config).ToList();
|
||||
|
||||
//var Importer = new CsvImporter();
|
||||
|
||||
//var import = await Importer.Import<CheckViewModel>(File.OpenRead(filePath));
|
||||
|
||||
//if (import.Exception != null) return ResponseOutput.NotOk(import.Exception.ToString());
|
||||
|
||||
//if (import.RowErrors.Count > 0) return ResponseOutput.NotOk(JsonConvert.SerializeObject(import.RowErrors));
|
||||
|
||||
//if (import.TemplateErrors.Count > 0) return ResponseOutput.NotOk(JsonConvert.SerializeObject(import.TemplateErrors));
|
||||
|
||||
//etcCheckList = import.Data.ToList();
|
||||
}
|
||||
else if (fileName.EndsWith(".xlsx"))
|
||||
{
|
||||
etcCheckList = MiniExcel.Query<CheckViewModel>(filePath).ToList();
|
||||
}
|
||||
//ExcelReaderFactory 需要自己验证数据 并且从固定列取数据
|
||||
else
|
||||
{
|
||||
//为了支持 xls 引入新的组件库
|
||||
|
|
|
@ -50,8 +50,6 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
|
||||
public Guid? SystemUserId { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ using IRaCIS.Core.Infrastructure.Extention;
|
|||
using IRaCIS.Core.Domain.Share;
|
||||
using Magicodes.ExporterAndImporter.Core;
|
||||
using MiniExcelLibs.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
|
||||
namespace IRaCIS.Application.Contracts
|
||||
{
|
||||
|
@ -12,14 +14,19 @@ namespace IRaCIS.Application.Contracts
|
|||
|
||||
public class UserTrialDTO : UserTrialCommand
|
||||
{
|
||||
[JsonIgnore]
|
||||
public string State => IsDeleted ? "退出" : "加入";
|
||||
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
[ExcelFormat("yyyy-mm-dd hh:mm:ss")]
|
||||
public DateTime? DeletedTime { get; set; }
|
||||
|
||||
public Guid? SiteId { get; set; }
|
||||
public string Phone { get; set; } = String.Empty;
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
[ExcelFormat("yyyy-mm-dd hh:mm:ss")]
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
|
||||
|
@ -38,25 +45,34 @@ namespace IRaCIS.Application.Contracts
|
|||
|
||||
public class TrialMaintenanceDTO : UserTrialCommand
|
||||
{
|
||||
//[ValueMapping(text: "退出", true)]
|
||||
//[ValueMapping(text: "加入", false)]
|
||||
[ExcelFormat("yyyy-mm-dd hh:mm:ss")]
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
//For MiniExcel ExcelFormat
|
||||
public string State => IsDeleted ? "退出" : "加入";
|
||||
|
||||
//[ExporterHeader(Format = "yyyy-mm-dd hh:mm:ss")]
|
||||
|
||||
[ValueMapping(text: "退出", true)]
|
||||
[ValueMapping(text: "加入", false)]
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
[ExporterHeader(Format = "yyyy-mm-DD hh:mm:ss")]
|
||||
[ExcelFormat("yyyy-mm-dd hh:mm:ss")]
|
||||
public DateTime? DeletedTime { get; set; }
|
||||
|
||||
|
||||
[ExporterHeader(Format = "yyyy-mm-DD")]
|
||||
[ExcelFormat("yyyy-mm-dd")]
|
||||
public DateTime? RemoveTime { get; set; }
|
||||
|
||||
[ExcelFormat("yyyy-mm-dd ")]
|
||||
|
||||
[ExporterHeader(Format = "yyyy-mm-DD")]
|
||||
[ExcelFormat("yyyy-mm-DD")]
|
||||
public DateTime? JoinTime { get; set; }
|
||||
|
||||
[ExcelFormat("yyyy-mm-dd hh:mm:ss")]
|
||||
|
||||
[ExporterHeader(Format = "yyyy-mm-DD hh:mm:ss")]
|
||||
[ExcelFormat("yyyy-mm-DD hh:mm:ss")]
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
|
||||
public string Phone { get; set; } = String.Empty;
|
||||
|
||||
public string EMail { get; set; } = string.Empty;
|
||||
|
@ -86,6 +102,34 @@ namespace IRaCIS.Application.Contracts
|
|||
}
|
||||
|
||||
|
||||
public class TrialSiteUserExportDto : TrialSelectDTO
|
||||
{
|
||||
public DateTime CurrentTime { get; set; } = DateTime.Now;
|
||||
|
||||
public List<SiteUserExportDTO> TrialSiteUserList { get; set; } = new List<SiteUserExportDTO>();
|
||||
}
|
||||
public class SiteUserExportDTO : UserTrialDTO
|
||||
{
|
||||
public string TrialSiteCode { get; set; } = String.Empty;
|
||||
public string TrialSiteAliasName { get; set; } = String.Empty;
|
||||
}
|
||||
|
||||
public class TrialSiteUserSummaryExportDto : TrialSelectDTO
|
||||
{
|
||||
public DateTime CurrentTime { get; set; } = DateTime.Now;
|
||||
|
||||
public List<TrialSiteUserSummaryDto> TrialSiteUserList { get; set; } = new List<TrialSiteUserSummaryDto>();
|
||||
|
||||
}
|
||||
|
||||
public class TrialSiteUserSummaryDto: TrialSiteUserSurveyView
|
||||
{
|
||||
public string TrialSiteCode { get; set; } = String.Empty;
|
||||
public string TrialSiteAliasName { get; set; } = String.Empty;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class SiteCRCCommand : UserTrialCommand
|
||||
{
|
||||
public Guid SiteId { get; set; }
|
||||
|
|
|
@ -241,15 +241,21 @@ namespace IRaCIS.Core.Application.Service
|
|||
您好,展影医疗作为 实验方案号:{trialInfo.ResearchProgramNo} 项目的IRC供应商,诚邀您参加该项目IRC相关工作,欢迎您提供指导和建议,非常感谢!
|
||||
</div>
|
||||
|
||||
<form action='#' method='post'>
|
||||
<button type='submit' style='margin-left:60px;font-size:14px;text-decoration: none;display: inline-block;height: 40px;width: 140px;background: #00D1B2;color:#fff;border-radius: 5px;line-height: 40px;text-align: center;border:none;margin-bottom: 100px;cursor: pointer'>查看并确认</button>
|
||||
</form>
|
||||
|
||||
|
||||
<a href=' {sendEmail.RouteUrl + "?Id=" + userInfo.Id + "&IsExternalUser=1"}' style='margin-left:60px;font-size:14px;text-decoration: none;display: inline-block;height: 40px;width: 140px;background: #00D1B2;color:#fff;border-radius: 5px;line-height: 40px;text-align: center;margin-bottom: 100px;'>
|
||||
查看并确认
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>";
|
||||
|
||||
|
||||
//< form action = '#' method = 'post' >
|
||||
|
||||
// < button type = 'submit' style = 'margin-left:60px;font-size:14px;text-decoration: none;display: inline-block;height: 40px;width: 140px;background: #00D1B2;color:#fff;border-radius: 5px;line-height: 40px;text-align: center;border:none;margin-bottom: 100px;cursor: pointer' > 查看并确认 </ button >
|
||||
|
||||
// </ form >
|
||||
messageToSend.Body = builder.ToMessageBody();
|
||||
|
||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
||||
|
|
|
@ -26,6 +26,67 @@ namespace IRaCIS.Application.Services
|
|||
_trialRepository = trialRepository;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> TrialUserListExport(Guid trialId, [FromServices] IRepository<CommonDocument> _commonDocumentRepository)
|
||||
{
|
||||
|
||||
var doc = _commonDocumentRepository.AsQueryable(true).FirstOrDefault(t => t.Code == "TrialUserList_Export");
|
||||
|
||||
if (doc == null)
|
||||
{
|
||||
throw new Exception("当前code 没要找到对应的导出模板文件");
|
||||
}
|
||||
|
||||
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).FullName;
|
||||
|
||||
var filePath = Path.Combine(rootPath, doc.Path.Trim('/'));
|
||||
|
||||
if (!System.IO.File.Exists(filePath))
|
||||
{
|
||||
throw new Exception("服务器本地不存在该路径文件");
|
||||
}
|
||||
|
||||
|
||||
var exportInfo = await _trialRepository.Where(t => t.Id == trialId).IgnoreQueryFilters().ProjectTo<TrialUserExportDTO>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
|
||||
|
||||
|
||||
//模板路径
|
||||
var tplPath = filePath;
|
||||
|
||||
|
||||
#region MiniExcel
|
||||
|
||||
var memoryStream = new MemoryStream();
|
||||
|
||||
MiniExcel.SaveAsByTemplate(memoryStream, tplPath, exportInfo);
|
||||
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
{
|
||||
FileDownloadName = $"{doc.Name}_{DateTime.Now.ToString("yyyy-MM-dd:hh:mm:ss")}.xlsx"
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Magicodes 模板规则不一样
|
||||
|
||||
////创建Excel导出对象
|
||||
//IExportFileByTemplate exporter = new ExcelExporter();
|
||||
|
||||
////根据模板导出
|
||||
//var result = await exporter.ExportBytesByTemplate(exportInfo, tplPath);
|
||||
|
||||
|
||||
//return new XlsxFileResult(bytes: result, fileDownloadName: $"{doc.Name}_{DateTime.Now.ToString("yyyy-MM-dd:hh:mm:ss")}.xlsx");
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Setting页面 获取项目参与人员列表
|
||||
/// </summary>
|
||||
|
@ -49,65 +110,6 @@ namespace IRaCIS.Application.Services
|
|||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> TrialUserListExport(Guid trialId, [FromServices] IRepository<CommonDocument> _commonDocumentRepository)
|
||||
{
|
||||
|
||||
var doc = _commonDocumentRepository.AsQueryable(true).FirstOrDefault(t => t.Code == "Test");
|
||||
|
||||
if (doc == null)
|
||||
{
|
||||
throw new Exception("当前code 没要找到对应的文件");
|
||||
}
|
||||
|
||||
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).FullName;
|
||||
|
||||
var filePath = Path.Combine(rootPath, doc.Path.Trim('/'));
|
||||
|
||||
if (!System.IO.File.Exists(filePath))
|
||||
{
|
||||
throw new Exception("服务器本地不存在该路径文件");
|
||||
}
|
||||
|
||||
|
||||
var exportInfo = await _trialRepository.Where(t => t.Id == trialId).IgnoreQueryFilters().ProjectTo<TrialUserExportDTO>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
|
||||
|
||||
|
||||
//模板路径
|
||||
var tplPath = filePath;
|
||||
|
||||
#region MiniExcel
|
||||
|
||||
var memoryStream = new MemoryStream();
|
||||
|
||||
MiniExcel.SaveAsByTemplate(memoryStream, tplPath, exportInfo);
|
||||
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
{
|
||||
FileDownloadName = $"{doc.Name}_{DateTime.Now.ToString("yyyy-MM-dd:hh:mm:ss")}.xlsx"
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Magicodes
|
||||
|
||||
//创建Excel导出对象
|
||||
IExportFileByTemplate exporter = new ExcelExporter();
|
||||
|
||||
//根据模板导出
|
||||
var result = await exporter.ExportBytesByTemplate(exportInfo, tplPath);
|
||||
|
||||
|
||||
return new XlsxFileResult(bytes: result, fileDownloadName: $"{doc.Name}_{DateTime.Now.ToString("yyyy-MM-dd:hh:mm:ss")}.xlsx");
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using IRaCIS.Core.Application.Contracts.DTO;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Interfaces;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using MiniExcelLibs;
|
||||
|
||||
namespace IRaCIS.Core.Application.Services
|
||||
{
|
||||
|
@ -16,15 +18,95 @@ namespace IRaCIS.Core.Application.Services
|
|||
private readonly IRepository<TrialSite> _trialSiteRepository;
|
||||
private readonly IRepository<TrialSiteUser> _trialSiteUserRepository;
|
||||
private readonly IRepository<Site> _siteRepository;
|
||||
private readonly IRepository<Trial> _trialRepository;
|
||||
|
||||
public TrialMaintenanceService(IRepository<TrialSite> trialSiteRepository, IRepository<TrialSiteUser> trialSiteUserRepository
|
||||
, IRepository<Site> siteRepository)
|
||||
, IRepository<Site> siteRepository, IRepository<Trial> trialRepository)
|
||||
{
|
||||
_trialSiteRepository = trialSiteRepository;
|
||||
_trialSiteUserRepository = trialSiteUserRepository;
|
||||
this._siteRepository = siteRepository;
|
||||
_siteRepository = siteRepository;
|
||||
_trialRepository = trialRepository;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpGet, Route("{trialId:guid}/{isSiteUserNotAll:bool}")]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> TrialSiteUserListExport(Guid trialId, bool isAllSiteUser,
|
||||
[FromServices] IRepository<CommonDocument> _commonDocumentRepository,
|
||||
[FromServices] IRepository<TrialSiteSurvey> _trialSiteSurveyRepository,
|
||||
[FromServices] IRepository<TrialSiteUserSurvey> _trialSiteUserSurveyRepository
|
||||
)
|
||||
{
|
||||
var code = isAllSiteUser ? "TrialSiteUserSummary_Export" : "TrialSiteUserList_Export";
|
||||
|
||||
var doc = _commonDocumentRepository.AsQueryable(true).FirstOrDefault(t => t.Code == code);
|
||||
|
||||
if (doc == null)
|
||||
{
|
||||
throw new Exception("当前code 没要找到对应的导出模板文件");
|
||||
}
|
||||
|
||||
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).FullName;
|
||||
|
||||
var filePath = Path.Combine(rootPath, doc.Path.Trim('/'));
|
||||
|
||||
if (!System.IO.File.Exists(filePath))
|
||||
{
|
||||
throw new Exception("服务器本地不存在该路径文件");
|
||||
}
|
||||
|
||||
object exportInfo = default;
|
||||
|
||||
if (isAllSiteUser == false)
|
||||
{
|
||||
exportInfo = await _trialRepository.Where(t => t.Id == trialId).IgnoreQueryFilters().ProjectTo<TrialSiteUserExportDto>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var data = await _trialRepository.Where(t => t.Id == trialId).IgnoreQueryFilters().ProjectTo<TrialSiteUserSummaryExportDto>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
|
||||
|
||||
var groupSelectIdQuery =
|
||||
_trialSiteSurveyRepository.Where(t => t.TrialId == trialId && t.IsAbandon == false)
|
||||
.GroupBy(t => t.SiteId)
|
||||
.Select(g => g.OrderByDescending(u => u.CreateTime).Select(t => t.Id).First());
|
||||
|
||||
|
||||
var query = _trialSiteUserSurveyRepository
|
||||
.Where(t => groupSelectIdQuery.Contains(t.TrialSiteSurveyId))
|
||||
.ProjectTo<TrialSiteUserSummaryDto>(_mapper.ConfigurationProvider);
|
||||
|
||||
data.TrialSiteUserList = await query.ToListAsync();
|
||||
|
||||
exportInfo = data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//模板路径
|
||||
var tplPath = filePath;
|
||||
|
||||
#region MiniExcel
|
||||
|
||||
var memoryStream = new MemoryStream();
|
||||
|
||||
MiniExcel.SaveAsByTemplate(memoryStream, tplPath, exportInfo);
|
||||
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
{
|
||||
FileDownloadName = $"{doc.Name}_{DateTime.Now.ToString("yyyy-MM-dd:hh:mm:ss")}.xlsx"
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Pannel 进去 SiteTab </summary>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<SiteStatDTO>> GetSiteCRCList(SiteCrcQueryDTO param)
|
||||
|
|
|
@ -204,6 +204,19 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
|
||||
|
||||
CreateMap<Trial, TrialSiteUserExportDto>();
|
||||
CreateMap<TrialSiteUser, SiteUserExportDTO>().IncludeMembers(t=>t.User)
|
||||
.ForMember(t => t.TrialSiteCode, u => u.MapFrom(c => c.TrialSite.TrialSiteCode))
|
||||
.ForMember(t => t.TrialSiteAliasName, u => u.MapFrom(c => c.TrialSite.TrialSiteAliasName))
|
||||
.ForMember(t => t.UserRealName, u => u.MapFrom(c => c.User.LastName + " / " + c.User.FirstName))
|
||||
.ForMember(t => t.UserType, u => u.MapFrom(c => c.User.UserTypeRole.UserTypeShortName));
|
||||
CreateMap<User, SiteUserExportDTO>();
|
||||
|
||||
|
||||
CreateMap<TrialSiteUserSurvey, TrialSiteUserSummaryDto>()
|
||||
.ForMember(t => t.TrialRoleName, u => u.MapFrom(d => d.TrialRoleName.Value))
|
||||
.ForMember(d => d.UserType, u => u.MapFrom(s => s.UserTypeRole.UserTypeShortName)); ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
using Magicodes.ExporterAndImporter.Core;
|
||||
using Magicodes.ExporterAndImporter.Core.Filters;
|
||||
using Magicodes.ExporterAndImporter.Core.Models;
|
||||
using Magicodes.ExporterAndImporter.Excel;
|
||||
using MediatR;
|
||||
using MiniExcelLibs.Attributes;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
|
||||
namespace IRaCIS.Core.Application.MediatR.CommandAndQueries
|
||||
{
|
||||
|
@ -19,19 +24,76 @@ namespace IRaCIS.Core.Application.MediatR.CommandAndQueries
|
|||
public Guid StudyId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class ImportResultFilteTest : IImportResultFilter
|
||||
{
|
||||
|
||||
|
||||
public ImportResult<T> Filter<T>(ImportResult<T> importResult) where T : class, new()
|
||||
{
|
||||
if (typeof(T).IsAssignableFrom(typeof(CheckViewModel)))
|
||||
{
|
||||
var data = (List<CheckViewModel>)importResult.Data;
|
||||
|
||||
var dt = DateTime.Now ;
|
||||
|
||||
foreach (var item in data)
|
||||
{
|
||||
|
||||
var index= data.IndexOf(item);
|
||||
if ( DateTime.TryParse(item.StudyDate, out dt) == false)
|
||||
{
|
||||
importResult.RowErrors.Add(new DataRowErrorInfo() { RowIndex = index, FieldErrors = new Dictionary<string, string> { { "检查技术", "时间格式不对" } } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return importResult;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[ExcelImporter(/*ImportResultFilter = typeof(ImportResultFilteTest),*/ IsLabelingError = true)]
|
||||
|
||||
public class CheckViewModel
|
||||
{
|
||||
[Required(ErrorMessage = "中心编号不能为空")]
|
||||
[ImporterHeader(Name = "中心编号", AutoTrim = true)]
|
||||
[ExcelColumnName("中心编号")]
|
||||
public string SiteCode { get; set; } = string.Empty;
|
||||
|
||||
|
||||
[Required(ErrorMessage = "受试者筛选号不能为空")]
|
||||
[ImporterHeader(Name = "受试者筛选号", AutoTrim = true)]
|
||||
[ExcelColumnName("受试者筛选号")]
|
||||
public string SubjectCode { get; set; } = string.Empty;
|
||||
|
||||
[Required(ErrorMessage = "访视名称不能为空")]
|
||||
[ImporterHeader(Name = "访视名称", AutoTrim = true)]
|
||||
[ExcelColumnName("访视名称")]
|
||||
public string VisitName { get; set; } = string.Empty;
|
||||
|
||||
|
||||
|
||||
[Required(ErrorMessage = "检查日期不能为空")]
|
||||
[CanConvertToTime(ErrorMessage = "检查日期格式有问题")]
|
||||
|
||||
[ImporterHeader(Name = "检查日期", AutoTrim = true)]
|
||||
[ExcelColumnName("检查日期")]
|
||||
public string StudyDate { get; set; } = string.Empty;
|
||||
|
||||
|
||||
|
||||
[Required(ErrorMessage = "Modality不能为空")]
|
||||
[ImporterHeader(Name = "检查技术", AutoTrim = true)]
|
||||
[ExcelColumnName("检查技术")]
|
||||
public string Modality { get; set; } = string.Empty;
|
||||
|
||||
|
||||
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj == null) return false;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace IRaCIS.Core.Domain.Share
|
||||
{
|
||||
public enum TrialExternalUserStateEnum
|
||||
|
@ -21,17 +23,23 @@ namespace IRaCIS.Core.Domain.Share
|
|||
|
||||
public enum TrialSiteUserStateEnum
|
||||
{
|
||||
[Description("待邀请")]
|
||||
//待发送
|
||||
WaitSent = 0,
|
||||
|
||||
[Description("已邀请")]
|
||||
//已发送
|
||||
HasSend = 1,
|
||||
|
||||
[Description("已确认")]
|
||||
//用户已确认
|
||||
UserConfirmed = 2,
|
||||
|
||||
[Description("已拒绝")]
|
||||
//用户已确认
|
||||
UserReject = 3,
|
||||
|
||||
[Description("已超时")]
|
||||
OverTime = 4
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue