Merge branch 'Test_IRC_Net8' of https://gitea.frp.extimaging.com/XCKJ/irc-netcore-api into Test_IRC_Net8
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
commit
ce32d7eea8
|
@ -42,11 +42,14 @@ namespace IRaCIS.Core.API.Controllers
|
|||
{
|
||||
|
||||
#region 上传基类封装
|
||||
|
||||
[DisableFormValueModelBinding]
|
||||
public abstract class UploadBaseController : ControllerBase
|
||||
{
|
||||
/// <summary> 流式上传 直接返回</summary>
|
||||
[Route("base")]
|
||||
[Route("SingleFileUpload")]
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
|
||||
public virtual async Task<IResponseOutput> SingleFileUploadAsync(Func<string, (string, string)> filePathFunc)
|
||||
{
|
||||
var boundary = HeaderUtilities.RemoveQuotes(MediaTypeHeaderValue.Parse(Request.ContentType).Boundary).Value;
|
||||
|
@ -81,7 +84,9 @@ namespace IRaCIS.Core.API.Controllers
|
|||
|
||||
|
||||
/// <summary> 流式上传 通用封装 不返回任何数据,后续还有事情处理 </summary>
|
||||
[Route("base")]
|
||||
[Route("FileUpload")]
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
|
||||
public virtual async Task FileUploadAsync(Func<string, Task<string>> filePathFunc)
|
||||
{
|
||||
var boundary = HeaderUtilities.RemoveQuotes(MediaTypeHeaderValue.Parse(Request.ContentType).Boundary).Value;
|
||||
|
@ -124,7 +129,9 @@ namespace IRaCIS.Core.API.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
[Route("base")]
|
||||
[Route("FileUploadToOSS")]
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
|
||||
public virtual async Task FileUploadToOSSAsync(Func<string, Stream, Task<string>> toMemoryStreamFunc)
|
||||
{
|
||||
var boundary = HeaderUtilities.RemoveQuotes(MediaTypeHeaderValue.Parse(Request.ContentType).Boundary).Value;
|
||||
|
@ -150,10 +157,10 @@ namespace IRaCIS.Core.API.Controllers
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary> 流式上传 Dicom上传 </summary>
|
||||
[Route("base")]
|
||||
[Route("DicomFileUpload")]
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
|
||||
public virtual async Task DicomFileUploadAsync(Func<string, Stream, int, Task> filePathFunc, string boundary)
|
||||
{
|
||||
|
||||
|
@ -215,9 +222,42 @@ namespace IRaCIS.Core.API.Controllers
|
|||
#endregion
|
||||
|
||||
#region Dicom 影像上传 临床数据 非diocm
|
||||
public class UploadNoneDicomFileCommand
|
||||
{
|
||||
[NotDefault]
|
||||
public Guid SubjectVisitId { get; set; }
|
||||
|
||||
[ApiExplorerSettings(GroupName = "Image")]
|
||||
[ApiController]
|
||||
|
||||
[NotDefault]
|
||||
public Guid StudyMonitorId { get; set; }
|
||||
|
||||
|
||||
public Guid? NoneDicomStudyId { get; set; }
|
||||
|
||||
//IR 上传的时候跟任务绑定
|
||||
public Guid? VisitTaskId { get; set; }
|
||||
|
||||
public string RecordPath { get; set; }
|
||||
|
||||
public int FailedFileCount { get; set; }
|
||||
|
||||
public long FileSize { get; set; }
|
||||
|
||||
|
||||
public List<OSSFileDTO> UploadedFileList { get; set; } = new List<OSSFileDTO>();
|
||||
|
||||
|
||||
public class OSSFileDTO
|
||||
{
|
||||
public string FilePath { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public int FileFize { get; set; }
|
||||
|
||||
public string FileType { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
[ApiController, ApiExplorerSettings(GroupName = "Image")]
|
||||
public class StudyController(
|
||||
IMediator _mediator,
|
||||
QCCommon _qCCommon,
|
||||
|
@ -228,9 +268,6 @@ namespace IRaCIS.Core.API.Controllers
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>Dicom 归档</summary>
|
||||
[HttpPost, Route("Study/ArchiveStudy")]
|
||||
[DisableFormValueModelBinding]
|
||||
|
@ -382,41 +419,6 @@ namespace IRaCIS.Core.API.Controllers
|
|||
}
|
||||
|
||||
|
||||
public class UploadNoneDicomFileCommand
|
||||
{
|
||||
[NotDefault]
|
||||
public Guid SubjectVisitId { get; set; }
|
||||
|
||||
|
||||
[NotDefault]
|
||||
public Guid StudyMonitorId { get; set; }
|
||||
|
||||
|
||||
public Guid? NoneDicomStudyId { get; set; }
|
||||
|
||||
//IR 上传的时候跟任务绑定
|
||||
public Guid? VisitTaskId { get; set; }
|
||||
|
||||
public string RecordPath { get; set; }
|
||||
|
||||
public int FailedFileCount { get; set; }
|
||||
|
||||
public long FileSize { get; set; }
|
||||
|
||||
|
||||
public List<OSSFileDTO> UploadedFileList { get; set; } = new List<OSSFileDTO>();
|
||||
|
||||
|
||||
public class OSSFileDTO
|
||||
{
|
||||
public string FilePath { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public int FileFize { get; set; }
|
||||
|
||||
public string FileType { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 非dicom 上传预上传接口
|
||||
/// </summary>
|
||||
|
@ -462,7 +464,6 @@ namespace IRaCIS.Core.API.Controllers
|
|||
/// <returns></returns>
|
||||
[HttpPost("NoneDicomStudy/UploadNoneDicomFile")]
|
||||
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
||||
|
||||
public async Task<IResponseOutput> UploadNoneDicomFile(UploadNoneDicomFileCommand incommand,
|
||||
[FromServices] IRepository<NoneDicomStudy> _noneDicomStudyRepository,
|
||||
[FromServices] IRepository<StudyMonitor> _studyMonitorRepository,
|
||||
|
@ -747,146 +748,13 @@ namespace IRaCIS.Core.API.Controllers
|
|||
|
||||
#endregion
|
||||
|
||||
#region 医生文件上传下载
|
||||
|
||||
|
||||
#region DTO
|
||||
public class DoctorDownloadInfo
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ReviewerCode { get; set; }
|
||||
|
||||
public List<DownloadFileInfo> FileList { get; set; }
|
||||
}
|
||||
public class DownloadFileInfo
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
|
||||
public string Path { get; set; }
|
||||
}
|
||||
|
||||
public class GetDoctorPathCommand
|
||||
{
|
||||
public int Language { get; set; }
|
||||
|
||||
public List<Guid> DoctorIdList { get; set; }
|
||||
}
|
||||
|
||||
public class GetDoctoreAttachPathCommand
|
||||
{
|
||||
public Guid DoctorId { get; set; }
|
||||
public List<Guid> AttachmentIdList { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>医生文件上传下载</summary>
|
||||
[ApiExplorerSettings(GroupName = "Common")]
|
||||
[ApiController]
|
||||
public class FileController : UploadBaseController
|
||||
{
|
||||
public IMapper _mapper { get; set; }
|
||||
public IUserInfo _userInfo { get; set; }
|
||||
|
||||
|
||||
private readonly IWebHostEnvironment _hostEnvironment;
|
||||
|
||||
private readonly IFileService _fileService;
|
||||
|
||||
|
||||
public FileController(IMapper mapper, IUserInfo userInfo, IWebHostEnvironment hostEnvironment, IFileService fileService)
|
||||
{
|
||||
_fileService = fileService;
|
||||
_hostEnvironment = hostEnvironment;
|
||||
_mapper = mapper;
|
||||
_userInfo = userInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// New 医生首页 多选 获取多个医生信息+文件路径列表 医生压缩包名称 doctorCode + "_" + doctorName _(时间戳或者随机的Guid)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("file/GetOfficialResume")]
|
||||
public async Task<IResponseOutput<List<DoctorDownloadInfo>>> GetOfficialResume(GetDoctorPathCommand command,
|
||||
[FromServices] IRepository<Attachment> _attachmentrepository)
|
||||
{
|
||||
|
||||
var list = await _attachmentrepository.Where(t => command.DoctorIdList.Contains(t.DoctorId) && command.Language == t.Language).GroupBy(t => new { Name = t.Doctor.FirstName + "_" + t.Doctor.LastName, ReviewerCode = t.Doctor.ReviewerCode, t.DoctorId })
|
||||
.Select(g => new DoctorDownloadInfo()
|
||||
{
|
||||
Id = g.Key.DoctorId,
|
||||
Name = g.Key.Name,
|
||||
ReviewerCode = g.Key.ReviewerCode,
|
||||
FileList = g.Select(t => new DownloadFileInfo() { FileName = t.FileName, Path = t.Path }).ToList()
|
||||
}).ToListAsync();
|
||||
|
||||
return ResponseOutput.Ok(list);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// New 项目入组 勾选获取简历路径
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <param name="_doctorService"></param>
|
||||
/// <param name="_attachmentrepository"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("file/GetTrialDoctorOfficialResume")]
|
||||
public async Task<IResponseOutput<List<DoctorDownloadInfo>>> GetTrialDoctorOfficialResume(GetDoctorPathCommand command,
|
||||
[FromServices] IDoctorService _doctorService,
|
||||
[FromServices] IRepository<Attachment> _attachmentrepository)
|
||||
{
|
||||
|
||||
var list = await _attachmentrepository.Where(t => command.DoctorIdList.Contains(t.DoctorId) && command.Language == t.Language && t.IsOfficial && t.Type.Equals("Resume")).GroupBy(t => new { Name = t.Doctor.FirstName + "_" + t.Doctor.LastName, ReviewerCode = t.Doctor.ReviewerCode, t.DoctorId })
|
||||
.Select(g => new DoctorDownloadInfo()
|
||||
{
|
||||
Id = g.Key.DoctorId,
|
||||
Name = g.Key.Name,
|
||||
ReviewerCode = g.Key.ReviewerCode,
|
||||
FileList = g.Select(t => new DownloadFileInfo() { FileName = t.FileName, Path = t.Path }).ToList()
|
||||
}).ToListAsync();
|
||||
|
||||
return ResponseOutput.Ok(list);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// new 医生详情 勾选或者下载文件路径
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <param name="_doctorService"></param>
|
||||
/// <param name="_attachmentrepository"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("file/GetDoctorAttachment")]
|
||||
public async Task<IResponseOutput<DoctorDownloadInfo>> GetDoctorAttachment(GetDoctoreAttachPathCommand command,
|
||||
[FromServices] IDoctorService _doctorService,
|
||||
[FromServices] IRepository<Attachment> _attachmentrepository)
|
||||
{
|
||||
|
||||
var find = await _attachmentrepository.Where(t => command.DoctorId == t.DoctorId && command.AttachmentIdList.Contains(t.Id)).GroupBy(t => new { Name = t.Doctor.FirstName + "_" + t.Doctor.LastName, ReviewerCode = t.Doctor.ReviewerCode, t.DoctorId })
|
||||
.Select(g => new DoctorDownloadInfo()
|
||||
{
|
||||
Id = g.Key.DoctorId,
|
||||
Name = g.Key.Name,
|
||||
ReviewerCode = g.Key.ReviewerCode,
|
||||
FileList = g.Select(t => new DownloadFileInfo() { FileName = t.FileName, Path = t.Path }).ToList()
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
return ResponseOutput.Ok(find);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 项目 系统 基本文件 上传 下载 预览
|
||||
|
||||
[ApiExplorerSettings(GroupName = "Common")]
|
||||
[ApiController]
|
||||
[ApiController, ApiExplorerSettings(GroupName = "Common")]
|
||||
|
||||
public class UploadDownLoadController : UploadBaseController
|
||||
{
|
||||
public IMapper _mapper { get; set; }
|
||||
|
|
|
@ -290,7 +290,7 @@
|
|||
<param name="_studyMonitorRepository"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.API.Controllers.StudyController.UploadNoneDicomFile(IRaCIS.Core.API.Controllers.StudyController.UploadNoneDicomFileCommand,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.NoneDicomStudy},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.StudyMonitor},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.NoneDicomStudyFile})">
|
||||
<member name="M:IRaCIS.Core.API.Controllers.StudyController.UploadNoneDicomFile(IRaCIS.Core.API.Controllers.UploadNoneDicomFileCommand,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.NoneDicomStudy},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.StudyMonitor},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.NoneDicomStudyFile})">
|
||||
<summary>
|
||||
上传非Dicom 文件 支持压缩包 多文件上传
|
||||
</summary>
|
||||
|
@ -310,33 +310,6 @@
|
|||
<returns></returns>
|
||||
<exception cref="T:IRaCIS.Core.Infrastructure.BusinessValidationFailedException"></exception>
|
||||
</member>
|
||||
<member name="T:IRaCIS.Core.API.Controllers.FileController">
|
||||
<summary>医生文件上传下载</summary>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.API.Controllers.FileController.GetOfficialResume(IRaCIS.Core.API.Controllers.GetDoctorPathCommand,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Attachment})">
|
||||
<summary>
|
||||
New 医生首页 多选 获取多个医生信息+文件路径列表 医生压缩包名称 doctorCode + "_" + doctorName _(时间戳或者随机的Guid)
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.API.Controllers.FileController.GetTrialDoctorOfficialResume(IRaCIS.Core.API.Controllers.GetDoctorPathCommand,IRaCIS.Application.Interfaces.IDoctorService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Attachment})">
|
||||
<summary>
|
||||
New 项目入组 勾选获取简历路径
|
||||
</summary>
|
||||
<param name="command"></param>
|
||||
<param name="_doctorService"></param>
|
||||
<param name="_attachmentrepository"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.API.Controllers.FileController.GetDoctorAttachment(IRaCIS.Core.API.Controllers.GetDoctoreAttachPathCommand,IRaCIS.Application.Interfaces.IDoctorService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Attachment})">
|
||||
<summary>
|
||||
new 医生详情 勾选或者下载文件路径
|
||||
</summary>
|
||||
<param name="command"></param>
|
||||
<param name="_doctorService"></param>
|
||||
<param name="_attachmentrepository"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.API.Controllers.UploadDownLoadController.DownloadCommonFile(System.String,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.CommonDocument})">
|
||||
<summary> 通用文件下载 </summary>
|
||||
</member>
|
||||
|
|
|
@ -108,7 +108,7 @@ builder.Services.AddEFSetup(_configuration, enviromentName);
|
|||
//Http 响应压缩
|
||||
builder.Services.AddResponseCompressionSetup();
|
||||
//Swagger Api 文档
|
||||
builder.Services.AddSwaggerSetupOld();
|
||||
builder.Services.AddSwaggerSetup();
|
||||
//JWT Token 验证
|
||||
builder.Services.AddJWTAuthSetup(_configuration);
|
||||
|
||||
|
|
|
@ -128,17 +128,6 @@ public static class SwaggerSetup
|
|||
// 接口排序
|
||||
options.OrderActionsBy(o => o.GroupName);
|
||||
|
||||
options.DocInclusionPredicate((docName, apiDes) =>
|
||||
{
|
||||
if (!apiDes.TryGetMethodInfo(out MethodInfo methodInfo)) return false;
|
||||
var versions = methodInfo.DeclaringType.GetCustomAttributes(true)
|
||||
.OfType<ApiExplorerSettingsAttribute>()
|
||||
.Select(attr => attr.GroupName);
|
||||
|
||||
return versions.Any(v => v.ToString() == docName);
|
||||
});
|
||||
|
||||
|
||||
//添加注释
|
||||
var basePath = AppContext.BaseDirectory;
|
||||
var xmlPath1 = Path.Combine(basePath, "IRaCIS.Core.Application.xml");
|
||||
|
|
|
@ -986,19 +986,28 @@
|
|||
ExploreRecommendService
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.FileService.CreateOfficialResumeZip(System.Int32,System.Guid[])">
|
||||
<member name="M:IRaCIS.Core.Application.Service.FileService.GetOfficialResume(IRaCIS.Core.Application.Service.GetDoctorPathCommand,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Attachment})">
|
||||
<summary>
|
||||
打包医生官方简历
|
||||
New 医生首页 多选 获取多个医生信息+文件路径列表 医生压缩包名称 doctorCode + "_" + doctorName _(时间戳或者随机的Guid)
|
||||
</summary>
|
||||
<param name="language"></param>
|
||||
<param name="doctorIds"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.FileService.CreateDoctorsAllAttachmentZip(System.Guid[])">
|
||||
<member name="M:IRaCIS.Core.Application.Service.FileService.GetTrialDoctorOfficialResume(IRaCIS.Core.Application.Service.GetDoctorPathCommand,IRaCIS.Application.Interfaces.IDoctorService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Attachment})">
|
||||
<summary>
|
||||
打包医生的所有附件
|
||||
New 项目入组 勾选获取简历路径
|
||||
</summary>
|
||||
<param name="doctorIds"></param>
|
||||
<param name="command"></param>
|
||||
<param name="_doctorService"></param>
|
||||
<param name="_attachmentrepository"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.FileService.GetDoctorAttachment(IRaCIS.Core.Application.Service.GetDoctoreAttachPathCommand,IRaCIS.Application.Interfaces.IDoctorService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Attachment})">
|
||||
<summary>
|
||||
new 医生详情 勾选或者下载文件路径
|
||||
</summary>
|
||||
<param name="command"></param>
|
||||
<param name="_doctorService"></param>
|
||||
<param name="_attachmentrepository"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:IRaCIS.Core.Application.Service.InternationalizationService">
|
||||
|
|
|
@ -2,203 +2,122 @@
|
|||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.Text;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
public class FileService(
|
||||
IDoctorService _doctorService,
|
||||
IAttachmentService _attachmentService,
|
||||
IWebHostEnvironment _hostEnvironment) : IFileService
|
||||
|
||||
[ApiExplorerSettings(GroupName = "Common")]
|
||||
public class FileService : BaseService
|
||||
{
|
||||
private string defaultUploadFilePath = FileStoreHelper.GetIRaCISRootPath(_hostEnvironment);
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 打包医生官方简历
|
||||
/// New 医生首页 多选 获取多个医生信息+文件路径列表 医生压缩包名称 doctorCode + "_" + doctorName _(时间戳或者随机的Guid)
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="doctorIds"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> CreateOfficialResumeZip(int language, Guid[] doctorIds)
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput<List<DoctorDownloadInfo>>> GetOfficialResume(GetDoctorPathCommand command,
|
||||
[FromServices] IRepository<Attachment> _attachmentrepository)
|
||||
{
|
||||
|
||||
//准备下载文件的临时路径
|
||||
var guidStr = Guid.NewGuid().ToString();
|
||||
|
||||
string uploadFolderPath = Path.Combine(FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment), "UploadFile");
|
||||
|
||||
|
||||
|
||||
var tempSavePath = Path.Combine(uploadFolderPath, "temp", guidStr); //待压缩的文件夹,将需要下载的文件拷贝到此文件夹
|
||||
if (!Directory.Exists(tempSavePath))
|
||||
{
|
||||
Directory.CreateDirectory(tempSavePath);
|
||||
}
|
||||
|
||||
//找到服务器简历路径 循环拷贝简历到临时路径
|
||||
foreach (var doctorId in doctorIds)
|
||||
{
|
||||
var doctor = await _doctorService.GetBasicInfo(doctorId);
|
||||
var doctorName = doctor.FirstName + "_" + doctor.LastName;
|
||||
|
||||
//找官方简历存在服务器的相对路径
|
||||
var sourceCvPath = await _attachmentService.GetDoctorOfficialCV(language, doctorId);
|
||||
if (!string.IsNullOrWhiteSpace(sourceCvPath))
|
||||
var list = await _attachmentrepository.Where(t => command.DoctorIdList.Contains(t.DoctorId) && command.Language == t.Language).GroupBy(t => new { Name = t.Doctor.FirstName + "_" + t.Doctor.LastName, ReviewerCode = t.Doctor.ReviewerCode, t.DoctorId })
|
||||
.Select(g => new DoctorDownloadInfo()
|
||||
{
|
||||
//服务器简历文件实际路径
|
||||
//var sourceCvFullPath = HostingEnvironment.MapPath(sourceCvPath);
|
||||
var sourceCvPathTemp = sourceCvPath.Substring(1, sourceCvPath.Length - 1);//.Replace('/','\\');
|
||||
string sourceCvFullPath = Path.Combine(defaultUploadFilePath, sourceCvPathTemp);
|
||||
Id = g.Key.DoctorId,
|
||||
Name = g.Key.Name,
|
||||
ReviewerCode = g.Key.ReviewerCode,
|
||||
FileList = g.Select(t => new DownloadFileInfo() { FileName = t.FileName, Path = t.Path }).ToList()
|
||||
}).ToListAsync();
|
||||
|
||||
var arr = sourceCvPath.Split('.');
|
||||
string extensionName = arr[arr.Length - 1]; //得到扩展名
|
||||
return ResponseOutput.Ok(list);
|
||||
|
||||
//需要拷贝到的路径
|
||||
var doctorPath = Path.Combine(tempSavePath, doctor.ReviewerCode.ToString() + "_" + doctorName + "." + extensionName);
|
||||
|
||||
if (File.Exists(sourceCvFullPath))
|
||||
{
|
||||
File.Copy(sourceCvFullPath, doctorPath, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//创建ZIP
|
||||
DateTime now = DateTime.Now;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(now.Year).Append(now.Month.ToString().PadLeft(2, '0')).Append(now.Day.ToString().PadLeft(2, '0'))
|
||||
.Append(now.Hour.ToString().PadLeft(2, '0')).Append(now.Minute.ToString().PadLeft(2, '0'))
|
||||
.Append(now.Second.ToString().PadLeft(2, '0')).Append(now.Millisecond.ToString().PadLeft(3, '0'));
|
||||
|
||||
string targetZipPath = Path.Combine(uploadFolderPath, "CV_" + sb.ToString() + ".zip");
|
||||
ZipHelper.CreateZip(tempSavePath, targetZipPath);
|
||||
|
||||
//返回Zip路径
|
||||
return Path.Combine("/IRaCISData/UploadFile/", "CV_" + sb.ToString() + ".zip");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打包医生的所有附件
|
||||
/// New 项目入组 勾选获取简历路径
|
||||
/// </summary>
|
||||
/// <param name="doctorIds"></param>
|
||||
/// <param name="command"></param>
|
||||
/// <param name="_doctorService"></param>
|
||||
/// <param name="_attachmentrepository"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> CreateDoctorsAllAttachmentZip(Guid[] doctorIds)
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput<List<DoctorDownloadInfo>>> GetTrialDoctorOfficialResume(GetDoctorPathCommand command,
|
||||
[FromServices] IDoctorService _doctorService,
|
||||
[FromServices] IRepository<Attachment> _attachmentrepository)
|
||||
{
|
||||
#region 老版本 存储在服务器
|
||||
//准备下载文件的临时路径
|
||||
var guidStr = Guid.NewGuid().ToString();
|
||||
//string uploadFolderPath = HostingEnvironment.MapPath("/UploadFile/");
|
||||
string uploadFolderPath = Path.Combine(FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment), "UploadFile");
|
||||
var tempSavePath = Path.Combine(uploadFolderPath, "temp", guidStr); //待压缩的文件夹,将需要下载的文件拷贝到此文件夹
|
||||
if (!Directory.Exists(tempSavePath))
|
||||
{
|
||||
Directory.CreateDirectory(tempSavePath);
|
||||
}
|
||||
|
||||
|
||||
foreach (var doctorId in doctorIds)
|
||||
{
|
||||
//获取医生基本信息
|
||||
var doctor = await _doctorService.GetBasicInfo(doctorId);
|
||||
var doctorName = doctor.FirstName + "_" + doctor.LastName;
|
||||
var doctorCode = doctor.ReviewerCode;
|
||||
|
||||
var doctorDestPath = Path.Combine(tempSavePath, doctorCode + "_" + doctorName);
|
||||
if (!Directory.Exists(doctorDestPath))
|
||||
var list = await _attachmentrepository.Where(t => command.DoctorIdList.Contains(t.DoctorId) && command.Language == t.Language && t.IsOfficial && t.Type.Equals("Resume")).GroupBy(t => new { Name = t.Doctor.FirstName + "_" + t.Doctor.LastName, ReviewerCode = t.Doctor.ReviewerCode, t.DoctorId })
|
||||
.Select(g => new DoctorDownloadInfo()
|
||||
{
|
||||
Directory.CreateDirectory(doctorDestPath);
|
||||
}
|
||||
Id = g.Key.DoctorId,
|
||||
Name = g.Key.Name,
|
||||
ReviewerCode = g.Key.ReviewerCode,
|
||||
FileList = g.Select(t => new DownloadFileInfo() { FileName = t.FileName, Path = t.Path }).ToList()
|
||||
}).ToListAsync();
|
||||
|
||||
//服务器上传后的源路径
|
||||
string doctorFileSourcePath = Path.Combine(uploadFolderPath, doctorId.ToString());
|
||||
|
||||
if (Directory.Exists(doctorFileSourcePath))
|
||||
{
|
||||
CopyDirectory(doctorFileSourcePath, doctorDestPath);
|
||||
}
|
||||
}
|
||||
string target = Guid.NewGuid().ToString();
|
||||
string targetPath = Path.Combine(uploadFolderPath, target + ".zip");
|
||||
ZipHelper.CreateZip(tempSavePath, targetPath);
|
||||
return Path.Combine("/IRaCISData/UploadFile/", target + ".zip");
|
||||
#endregion
|
||||
return ResponseOutput.Ok(list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public async Task<string> CreateZipPackageByAttachment(Guid doctorId, Guid[] attachmentIds)
|
||||
{
|
||||
var doctor = await _doctorService.GetBasicInfo(doctorId);
|
||||
var doctorName = doctor.FirstName + "_" + doctor.LastName;
|
||||
|
||||
Guid temp = Guid.NewGuid();
|
||||
//string root = HostingEnvironment.MapPath("/UploadFile/"); //文件根目录
|
||||
string root = Path.Combine(defaultUploadFilePath, "UploadFile");
|
||||
|
||||
var tempPath = Path.Combine(root, "temp", temp.ToString(), doctor.ReviewerCode + doctorName); //待压缩的文件夹,将需要下载的文件拷贝到此文件夹
|
||||
var packagePath = Path.Combine(root, "temp", temp.ToString()); //打包目录
|
||||
if (!Directory.Exists(tempPath))
|
||||
{
|
||||
Directory.CreateDirectory(tempPath);
|
||||
}
|
||||
var attachemnts = (await _attachmentService.GetAttachments(doctorId)).Where(a => attachmentIds.Contains(a.Id));
|
||||
|
||||
foreach (var item in attachemnts)
|
||||
{
|
||||
var arr = item.Path.Trim().Split('/');
|
||||
var myPath = string.Empty;
|
||||
var myFile = string.Empty;
|
||||
//需要改进
|
||||
if (arr.Length > 0)
|
||||
{
|
||||
myFile = arr[arr.Length - 1];
|
||||
foreach (var arrItem in arr)
|
||||
{
|
||||
if (arrItem != string.Empty && !"UploadFile".Equals(arrItem))
|
||||
{
|
||||
myPath += (arrItem + "/");
|
||||
}
|
||||
}
|
||||
myPath = myPath.TrimEnd('/');
|
||||
}
|
||||
var sourcePath = Path.Combine(root, myPath);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(sourcePath) && File.Exists(sourcePath))
|
||||
{
|
||||
File.Copy(sourcePath, Path.Combine(tempPath, myFile), true);
|
||||
}
|
||||
}
|
||||
string target = Guid.NewGuid().ToString();
|
||||
string targetPath = Path.Combine(root, target + ".zip");
|
||||
ZipHelper.CreateZip(packagePath, targetPath);
|
||||
|
||||
return Path.Combine("/IRaCISData/UploadFile/", target + ".zip");
|
||||
}
|
||||
|
||||
private static void CopyDirectory(string srcPath, string destPath)
|
||||
/// <summary>
|
||||
/// new 医生详情 勾选或者下载文件路径
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <param name="_doctorService"></param>
|
||||
/// <param name="_attachmentrepository"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput<DoctorDownloadInfo>> GetDoctorAttachment(GetDoctoreAttachPathCommand command,
|
||||
[FromServices] IDoctorService _doctorService,
|
||||
[FromServices] IRepository<Attachment> _attachmentrepository)
|
||||
{
|
||||
|
||||
DirectoryInfo dir = new DirectoryInfo(srcPath);
|
||||
FileSystemInfo[] fileInfoArray = dir.GetFileSystemInfos(); //获取目录下(不包含子目录)的文件和子目录
|
||||
foreach (FileSystemInfo fileInfo in fileInfoArray)
|
||||
{
|
||||
if (fileInfo is DirectoryInfo) //判断是否文件夹
|
||||
var find = await _attachmentrepository.Where(t => command.DoctorId == t.DoctorId && command.AttachmentIdList.Contains(t.Id)).GroupBy(t => new { Name = t.Doctor.FirstName + "_" + t.Doctor.LastName, ReviewerCode = t.Doctor.ReviewerCode, t.DoctorId })
|
||||
.Select(g => new DoctorDownloadInfo()
|
||||
{
|
||||
if (!Directory.Exists(destPath + "\\" + fileInfo.Name))
|
||||
{
|
||||
Directory.CreateDirectory(destPath + "\\" + fileInfo.Name); //目标目录下不存在此文件夹即创建子文件夹
|
||||
}
|
||||
CopyDirectory(fileInfo.FullName, destPath + "\\" + fileInfo.Name); //递归调用复制子文件夹
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Copy(fileInfo.FullName, destPath + "\\" + fileInfo.Name, true); //不是文件夹即复制文件,true表示可以覆盖同名文件
|
||||
}
|
||||
}
|
||||
Id = g.Key.DoctorId,
|
||||
Name = g.Key.Name,
|
||||
ReviewerCode = g.Key.ReviewerCode,
|
||||
FileList = g.Select(t => new DownloadFileInfo() { FileName = t.FileName, Path = t.Path }).ToList()
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
return ResponseOutput.Ok(find);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region DTO
|
||||
public class DoctorDownloadInfo
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ReviewerCode { get; set; }
|
||||
|
||||
public List<DownloadFileInfo> FileList { get; set; }
|
||||
}
|
||||
public class DownloadFileInfo
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
|
||||
public string Path { get; set; }
|
||||
}
|
||||
|
||||
public class GetDoctorPathCommand
|
||||
{
|
||||
public int Language { get; set; }
|
||||
|
||||
public List<Guid> DoctorIdList { get; set; }
|
||||
}
|
||||
|
||||
public class GetDoctoreAttachPathCommand
|
||||
{
|
||||
public Guid DoctorId { get; set; }
|
||||
public List<Guid> AttachmentIdList { get; set; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue