Merge branch 'master' of http://192.168.1.2:8033/IRaCIS_Core_Api
commit
cdd0c52182
|
@ -76,7 +76,7 @@ public static class ExcelExportHelper
|
||||||
{
|
{
|
||||||
var beforeValue = itemDic[needTranslateProperty.Name]?.ToString();
|
var beforeValue = itemDic[needTranslateProperty.Name]?.ToString();
|
||||||
|
|
||||||
itemDic[needTranslateProperty.Name] = translateDataList[needTranslateProperty.DicParentCode].Where(t => t.Code.ToLower() == beforeValue?.ToLower()).FirstOrDefault()?.ValueCN ?? String.Empty;
|
itemDic[needTranslateProperty.Name] = translateDataList[needTranslateProperty.DicParentCode].Where(t => t.Code.ToLower() == beforeValue?.ToLower()).Select(t=>data.IsEn_US?t.Value:t.ValueCN).FirstOrDefault() ?? String.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//普通翻译 或者某一标准翻译
|
//普通翻译 或者某一标准翻译
|
||||||
|
@ -85,7 +85,7 @@ public static class ExcelExportHelper
|
||||||
var beforeValue = itemDic[needTranslateProperty.Name]?.ToString();
|
var beforeValue = itemDic[needTranslateProperty.Name]?.ToString();
|
||||||
|
|
||||||
|
|
||||||
itemDic[needTranslateProperty.Name] = translateDataList[needTranslateProperty.DicParentCode].Where(t => t.Code.ToLower() == beforeValue?.ToLower()).FirstOrDefault()?.ValueCN ?? String.Empty;
|
itemDic[needTranslateProperty.Name] = translateDataList[needTranslateProperty.DicParentCode].Where(t => t.Code.ToLower() == beforeValue?.ToLower()).Select(t => data.IsEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,11 +138,11 @@ public static class ExcelExportHelper
|
||||||
{
|
{
|
||||||
if (data.IsEn_US)
|
if (data.IsEn_US)
|
||||||
{
|
{
|
||||||
workbook.RemoveSheetAt(1);
|
workbook.RemoveSheetAt(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
workbook.RemoveSheetAt(0);
|
workbook.RemoveSheetAt(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var memoryStream2 = new MemoryStream();
|
var memoryStream2 = new MemoryStream();
|
||||||
|
@ -153,10 +153,15 @@ public static class ExcelExportHelper
|
||||||
templateStream = memoryStream2;
|
templateStream = memoryStream2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 文件名称 从sheet里面取
|
||||||
|
fileNmae = workbook.GetSheetName(0);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region MiniExcel
|
#region MiniExcel
|
||||||
|
|
||||||
var memoryStream = new MemoryStream();
|
var memoryStream = new MemoryStream();
|
||||||
|
@ -170,38 +175,10 @@ public static class ExcelExportHelper
|
||||||
|
|
||||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
#region 根据中英文 删除sheet
|
|
||||||
//var workbook = new XSSFWorkbook(memoryStream);
|
|
||||||
|
|
||||||
//int sheetCount = workbook.NumberOfSheets;
|
|
||||||
|
|
||||||
//if (sheetCount == 2)
|
|
||||||
//{
|
|
||||||
|
|
||||||
// if (data.IsEn_US)
|
|
||||||
// {
|
|
||||||
// workbook.RemoveSheetAt(0);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// workbook.RemoveSheetAt(1);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// var memoryStream2 = new MemoryStream();
|
|
||||||
// workbook.Write(memoryStream2);
|
|
||||||
|
|
||||||
// memoryStream2.Seek(0, SeekOrigin.Begin);
|
|
||||||
|
|
||||||
// memoryStream = memoryStream2;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||||
{
|
{
|
||||||
FileDownloadName = $"{exportFileNamePrefix}_{fileNmae.Substring(0, fileNmae.LastIndexOf('.'))}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx"
|
FileDownloadName = $"{exportFileNamePrefix}_{fileNmae/*.Substring(0, fileNmae.LastIndexOf('.'))*/}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx"
|
||||||
};
|
};
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -222,10 +199,12 @@ public static class ExcelExportHelper
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static async Task<(MemoryStream, string)> DataExport_NpoiTestAsync(string code, object data, IRepository<CommonDocument> _commonDocumentRepository, IWebHostEnvironment _hostEnvironment, IDictionaryService? _dictionaryService = null, Type? translateType = null, CriterionType? criterionType = null)
|
public static async Task<(MemoryStream, string)> DataExport_NpoiTestAsync(string code, ExcelExportInfo data, IRepository<CommonDocument> _commonDocumentRepository, IWebHostEnvironment _hostEnvironment, IDictionaryService? _dictionaryService = null, Type? translateType = null, CriterionType? criterionType = null)
|
||||||
{
|
{
|
||||||
//判断是否有字典翻译
|
//判断是否有字典翻译
|
||||||
|
|
||||||
|
object translateData = data;
|
||||||
|
|
||||||
if (_dictionaryService != null && translateType != null)
|
if (_dictionaryService != null && translateType != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -273,7 +252,7 @@ public static class ExcelExportHelper
|
||||||
{
|
{
|
||||||
var beforeValue = itemDic[needTranslateProperty.Name]?.ToString();
|
var beforeValue = itemDic[needTranslateProperty.Name]?.ToString();
|
||||||
|
|
||||||
itemDic[needTranslateProperty.Name] = translateDataList[needTranslateProperty.DicParentCode].Where(t => t.Code.ToLower() == beforeValue?.ToLower()).FirstOrDefault()?.ValueCN ?? String.Empty;
|
itemDic[needTranslateProperty.Name] = translateDataList[needTranslateProperty.DicParentCode].Where(t => t.Code.ToLower() == beforeValue?.ToLower()).Select(t => data.IsEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//普通翻译 或者某一标准翻译
|
//普通翻译 或者某一标准翻译
|
||||||
|
@ -282,7 +261,7 @@ public static class ExcelExportHelper
|
||||||
var beforeValue = itemDic[needTranslateProperty.Name]?.ToString();
|
var beforeValue = itemDic[needTranslateProperty.Name]?.ToString();
|
||||||
|
|
||||||
|
|
||||||
itemDic[needTranslateProperty.Name] = translateDataList[needTranslateProperty.DicParentCode].Where(t => t.Code.ToLower() == beforeValue?.ToLower()).FirstOrDefault()?.ValueCN ?? String.Empty;
|
itemDic[needTranslateProperty.Name] = translateDataList[needTranslateProperty.DicParentCode].Where(t => t.Code.ToLower() == beforeValue?.ToLower()).Select(t => data.IsEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,8 +278,8 @@ public static class ExcelExportHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
data = dic;
|
//data = dic;
|
||||||
|
translateData = dic;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,6 +290,43 @@ public static class ExcelExportHelper
|
||||||
//模板路径
|
//模板路径
|
||||||
var tplPath = physicalPath;
|
var tplPath = physicalPath;
|
||||||
|
|
||||||
|
#region 根据中英文 删除模板sheet
|
||||||
|
|
||||||
|
// 打开模板文件
|
||||||
|
var templateFile = new FileStream(tplPath, FileMode.Open, FileAccess.Read);
|
||||||
|
|
||||||
|
// 获取文件流
|
||||||
|
var templateStream = new MemoryStream();
|
||||||
|
templateFile.CopyTo(templateStream);
|
||||||
|
templateStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
var workbook = new XSSFWorkbook(templateStream);
|
||||||
|
|
||||||
|
int sheetCount = workbook.NumberOfSheets;
|
||||||
|
|
||||||
|
if (sheetCount == 2)
|
||||||
|
{
|
||||||
|
if (data.IsEn_US)
|
||||||
|
{
|
||||||
|
workbook.RemoveSheetAt(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
workbook.RemoveSheetAt(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
var memoryStream2 = new MemoryStream();
|
||||||
|
workbook.Write(memoryStream2);
|
||||||
|
|
||||||
|
memoryStream2.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
templateStream = memoryStream2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 文件名称 从sheet里面取
|
||||||
|
fileName = workbook.GetSheetName(0);
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region MiniExcel
|
#region MiniExcel
|
||||||
|
|
||||||
var memoryStream = new MemoryStream();
|
var memoryStream = new MemoryStream();
|
||||||
|
@ -320,7 +336,7 @@ public static class ExcelExportHelper
|
||||||
IgnoreTemplateParameterMissing = true,
|
IgnoreTemplateParameterMissing = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
await MiniExcel.SaveAsByTemplateAsync(memoryStream, tplPath, data, config);
|
await MiniExcel.SaveAsByTemplateAsync(memoryStream, tplPath, translateData, config);
|
||||||
|
|
||||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||||
{
|
{
|
||||||
if (!ReadingDurationTimeSpan.HasValue)
|
if (!ReadingDurationTimeSpan.HasValue)
|
||||||
return "";
|
return "";
|
||||||
else return string.Format("{0}天{1}小时{2}分钟", (SignTime - FirstReadingTime)?.Days, (SignTime - FirstReadingTime)?.Hours, (SignTime - FirstReadingTime)?.Minutes)
|
else return string.Format("{0}d {1}h {2}min", (SignTime - FirstReadingTime)?.Days, (SignTime - FirstReadingTime)?.Hours, (SignTime - FirstReadingTime)?.Minutes)
|
||||||
/*string.Format("{0}分钟", (ReadingDurationTimeSpan)?.TotalMinutes)*/;
|
/*string.Format("{0}分钟", (ReadingDurationTimeSpan)?.TotalMinutes)*/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -338,7 +338,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||||
|
|
||||||
return new FileStreamResult(memoryStream2, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
return new FileStreamResult(memoryStream2, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||||
{
|
{
|
||||||
FileDownloadName = $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}_{fileName.Substring(startIndex: 0, fileName.LastIndexOf('.'))}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx"
|
FileDownloadName = $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}_{fileName/*.Substring(startIndex: 0, fileName.LastIndexOf('.'))*/}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx"
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -399,8 +399,8 @@ namespace IRaCIS.Core.Application.Services
|
||||||
[HttpGet("{trialId:guid}")]
|
[HttpGet("{trialId:guid}")]
|
||||||
public async Task<IResponseOutput> GetTrialDocAndSystemDocType(Guid trialId)
|
public async Task<IResponseOutput> GetTrialDocAndSystemDocType(Guid trialId)
|
||||||
{
|
{
|
||||||
var result = await _trialDocumentRepository.Where(t => t.TrialId == trialId).Select(t => new { FileType = t.FileType.Value, t.FileTypeId })
|
var result = await _trialDocumentRepository.Where(t => t.TrialId == trialId).Select(t => new { FileType = _userInfo.IsEn_Us? t.FileType.Value :t.FileType.ValueCN, t.FileTypeId })
|
||||||
.Union(_systemDocumentRepository.Select(t => new { FileType = t.FileType.Value, t.FileTypeId }))
|
.Union(_systemDocumentRepository.Select(t => new { FileType = _userInfo.IsEn_Us ? t.FileType.Value : t.FileType.ValueCN, t.FileTypeId }))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
return ResponseOutput.Ok(result);
|
return ResponseOutput.Ok(result);
|
||||||
|
|
|
@ -235,7 +235,7 @@ namespace IRaCIS.Core.Application.Contracts.DTO
|
||||||
{
|
{
|
||||||
if (!ClosedTime.HasValue)
|
if (!ClosedTime.HasValue)
|
||||||
return "";
|
return "";
|
||||||
else return string.Format("{0}天{1}小时{2}分钟", (ClosedTime - CreateTime)?.Days, (ClosedTime - CreateTime)?.Hours, (ClosedTime - CreateTime)?.Minutes);
|
else return string.Format("{0}Days{1}Hours{2}Minutes", (ClosedTime - CreateTime)?.Days, (ClosedTime - CreateTime)?.Hours, (ClosedTime - CreateTime)?.Minutes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
{
|
{
|
||||||
if (!ClosedTime.HasValue)
|
if (!ClosedTime.HasValue)
|
||||||
return "";
|
return "";
|
||||||
else return string.Format("{0}天{1}小时{2}分钟", (ClosedTime - CreateTime)?.Days, (ClosedTime - CreateTime)?.Hours, (ClosedTime - CreateTime)?.Minutes);
|
else return string.Format("{0}d {1}h {2}min", (ClosedTime - CreateTime)?.Days, (ClosedTime - CreateTime)?.Hours, (ClosedTime - CreateTime)?.Minutes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1192,7 +1192,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
{
|
{
|
||||||
if (!ClosedTime.HasValue)
|
if (!ClosedTime.HasValue)
|
||||||
return "";
|
return "";
|
||||||
else return string.Format("{0}天{1}小时{2}分钟", (ClosedTime - CreateTime)?.Days, (ClosedTime - CreateTime)?.Hours, (ClosedTime - CreateTime)?.Minutes);
|
else return string.Format("{0}d {1}h {2}min", (ClosedTime - CreateTime)?.Days, (ClosedTime - CreateTime)?.Hours, (ClosedTime - CreateTime)?.Minutes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,35 +74,35 @@ namespace IRaCIS.Core.Application.MediatR.CommandAndQueries
|
||||||
public class CheckViewModel
|
public class CheckViewModel
|
||||||
{
|
{
|
||||||
//[Required(ErrorMessage = "中心编号不能为空")]
|
//[Required(ErrorMessage = "中心编号不能为空")]
|
||||||
[ImporterHeader(Name = "中心编号", AutoTrim = true)]
|
[ImporterHeader(Name = "Site ID", AutoTrim = true)]
|
||||||
[ExcelColumnName("中心编号")]
|
[ExcelColumnIndex("Site ID")]
|
||||||
public string SiteCode { get; set; } = string.Empty;
|
public string SiteCode { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
//[Required(ErrorMessage = "受试者筛选号不能为空")]
|
//[Required(ErrorMessage = "受试者筛选号不能为空")]
|
||||||
[ImporterHeader(Name = "受试者筛选号", AutoTrim = true)]
|
[ImporterHeader(Name = "Subject ID", AutoTrim = true)]
|
||||||
[ExcelColumnName("受试者筛选号")]
|
[ExcelColumnName("Subject ID")]
|
||||||
public string SubjectCode { get; set; } = string.Empty;
|
public string SubjectCode { get; set; } = string.Empty;
|
||||||
|
|
||||||
//[Required(ErrorMessage = "访视名称不能为空")]
|
//[Required(ErrorMessage = "访视名称不能为空")]
|
||||||
[ImporterHeader(Name = "访视名称", AutoTrim = true)]
|
[ImporterHeader(Name = "Visit Name", AutoTrim = true)]
|
||||||
[ExcelColumnName("访视名称")]
|
[ExcelColumnName("Visit Name")]
|
||||||
public string VisitName { get; set; } = string.Empty;
|
public string VisitName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//[Required(ErrorMessage = "检查日期不能为空")]
|
//[Required(ErrorMessage = "检查日期不能为空")]
|
||||||
[CanConvertToTime(ErrorMessage = "检查日期格式有问题")]
|
[CanConvertToTime(ErrorMessage = "Does not conform to Stusy Date format")]
|
||||||
|
|
||||||
[ImporterHeader(Name = "检查日期", AutoTrim = true)]
|
[ImporterHeader(Name = "Stusy Date", AutoTrim = true)]
|
||||||
[ExcelColumnName("检查日期")]
|
[ExcelColumnName("Stusy Date")]
|
||||||
public string StudyDate { get; set; } = string.Empty;
|
public string StudyDate { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//[Required(ErrorMessage = "Modality不能为空")]
|
//[Required(ErrorMessage = "Modality不能为空")]
|
||||||
[ImporterHeader(Name = "检查技术", AutoTrim = true)]
|
[ImporterHeader(Name = "Modality", AutoTrim = true)]
|
||||||
[ExcelColumnName("检查技术")]
|
[ExcelColumnName("Modality")]
|
||||||
public string Modality { get; set; } = string.Empty;
|
public string Modality { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue