diff --git a/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs b/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs index cc94a4302..58223c3bf 100644 --- a/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs +++ b/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs @@ -64,7 +64,7 @@ public static class ExcelExportHelper foreach (var key in dic.Keys) { //是数组 那么找到对应的属性 进行翻译 - if (dic[key]!=null && dic[key].GetType().GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IList<>))) + if (dic[key] != null && dic[key].GetType().GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IList<>))) { var newObjList = new List(); @@ -255,9 +255,13 @@ public static class ExcelExportHelper /// public int AutoColumnTitleRowIndex { get; set; } - + /// + /// 模板列最后的索引 + /// public int TempalteLastColumnIndex { get; set; } + public List CDISCList { get; set; } = new List(); + /// /// 动态的列名 /// @@ -639,6 +643,311 @@ public static class ExcelExportHelper } + public static async Task<(MemoryStream, string)> CDISC_DataExport_Async(string code, ExcelExportInfo data, IRepository _commonDocumentRepository, IWebHostEnvironment _hostEnvironment, IDictionaryService? _dictionaryService = null, Type? translateType = null, CriterionType? criterionType = null, DynamicColumnConfig? dynamicColumnConfig = null) + { + var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US; + //判断是否有字典翻译 + + object translateData = data; + + Dictionary translatedDic = default; + + if (_dictionaryService != null && translateType != null) + { + + //一个值 对应不同的字典翻译 + var needTranslatePropertyList = translateType.GetProperties().Where(t => t.IsDefined(typeof(DictionaryTranslateAttribute), true)) + .SelectMany(c => + c.GetCustomAttributes(typeof(DictionaryTranslateAttribute), false).Select(f => (DictionaryTranslateAttribute?)f).Where(t => t.CriterionType == criterionType || t.CriterionType == null) + .Select(k => new { c.Name, k.DicParentCode, k.IsTranslateDenpendOtherProperty, k.DependPropertyName, k.DependPropertyValueStr }) + ).ToList(); + + + + //字典表查询出所有需要翻译的数据 + + var translateDataList = await _dictionaryService.GetBasicDataSelect(needTranslatePropertyList.Select(t => t.DicParentCode).Distinct().ToArray()); + + var dic = data.ConvertToDictionary(); + //var dic = (JsonConvert.DeserializeObject>(data.ToJsonNotIgnoreNull())).IfNullThrowException(); + + foreach (var key in dic.Keys) + { + //是数组 那么找到对应的属性 进行翻译 + if (dic[key] != null && dic[key].GetType().GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IList<>))) + //if (dic[key].GetType().IsAssignableFrom(typeof(JArray))) + { + + var newObjList = new List(); + var no = 1; + foreach (var item in dic[key] as IList) + //foreach (var item in dic[key] as JArray) + { + //var itemDic = JsonConvert.DeserializeObject>(item.ToJsonNotIgnoreNull()); + var itemDic = item.ConvertToDictionary(); + + foreach (var needTranslateProperty in needTranslatePropertyList) + { + if (itemDic.Keys.Any(t => t == needTranslateProperty.Name)) + { + //翻译的属性依赖其他属性 + if (needTranslateProperty.IsTranslateDenpendOtherProperty) + { + if (itemDic[needTranslateProperty.DependPropertyName]?.ToString().ToLower() == needTranslateProperty.DependPropertyValueStr.ToLower()) + { + var beforeValue = itemDic[needTranslateProperty.Name]?.ToString(); + + itemDic[needTranslateProperty.Name] = translateDataList[needTranslateProperty.DicParentCode].Where(t => t.Code.ToLower() == beforeValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty; + } + } + //普通翻译 或者某一标准翻译 + else + { + var beforeValue = itemDic[needTranslateProperty.Name]?.ToString(); + + + itemDic[needTranslateProperty.Name] = translateDataList[needTranslateProperty.DicParentCode].Where(t => t.Code.ToLower() == beforeValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty; + } + } + + + + + } + + itemDic.Add("No", no++); + newObjList.Add(itemDic); + } + + dic[key] = newObjList; + + } + } + + + //data = dic; + translateData = dic; + translatedDic = dic; + + } + + + var (physicalPath, fileName) = await FileStoreHelper.GetCommonDocPhysicalFilePathAsync(_hostEnvironment, _commonDocumentRepository, code); + + + //模板路径 + 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 (isEn_US) + { + workbook.RemoveSheetAt(0); + } + else + { + workbook.RemoveSheetAt(1); + } + + if (dynamicColumnConfig != null) + { + var sheet = workbook.GetSheetAt(0); + + + var cdicsRow = sheet.GetRow(dynamicColumnConfig.AutoColumnTitleRowIndex - 1); + var titelRow = sheet.GetRow(dynamicColumnConfig.AutoColumnTitleRowIndex); + var templateRow = sheet.GetRow(dynamicColumnConfig.AutoColumnTitleRowIndex + 1); + + //动态移除列的数量 + var dynamicRemoveColunmCount = dynamicColumnConfig.RemoveColunmIndexList.Count(); + + //在动态列开始前移除的数量 + var beforeDynamicRemoveCount = dynamicColumnConfig.RemoveColunmIndexList.Where(t => t < dynamicColumnConfig.AutoColumnStartIndex).Count(); + + //动态添加列的数量 + var needAddCount = dynamicColumnConfig.ColumnNameList.Count; + + //原始表 最终索引 + var originTotalEndIndex = dynamicColumnConfig.TempalteLastColumnIndex; + + //减去动态移除后原始结束索引 + var originRemoveEndIndex = originTotalEndIndex - dynamicRemoveColunmCount; + + //最终表 动态列开始索引 + var dynamicColunmStartIndex = dynamicColumnConfig.AutoColumnStartIndex - beforeDynamicRemoveCount; + + //最终表 动态列的终止索引 + var dynamicColunmEndIndex = dynamicColunmStartIndex + needAddCount - 1; + + //最终表 最终索引 + var totalColunmEndIndex = originTotalEndIndex + needAddCount - dynamicRemoveColunmCount; + + + //动态列后需要移动的数量 + var backMoveCount = totalColunmEndIndex - dynamicColunmEndIndex; + + //删除需要动态删除的列 从大到小移除,否则索引会变 + foreach (var removeIndex in dynamicColumnConfig.RemoveColunmIndexList.OrderByDescending(t => t)) + { + //将后面的列向前移动 + for (var i = 0; i < originTotalEndIndex - removeIndex; i++) + { + Console.WriteLine(titelRow.GetCell(removeIndex + i + 1).StringCellValue); + titelRow.GetCell(removeIndex + i).SetCellValue(titelRow.GetCell(removeIndex + i + 1).StringCellValue); + templateRow.GetCell(removeIndex + i).SetCellValue(templateRow.GetCell(removeIndex + i + 1).StringCellValue); + + //后面的数据要清空 + titelRow.GetCell(removeIndex + i + 1).SetCellValue(""); + templateRow.GetCell(removeIndex + i + 1).SetCellValue(""); + + } + + } + + //创建新的列 + for (int i = originTotalEndIndex; i < originTotalEndIndex + needAddCount; i++) + { + cdicsRow.CreateCell(i + 1); + titelRow.CreateCell(i + 1); + templateRow.CreateCell(i + 1); + } + //移动Title 和下面的模板标识 + + var gap = totalColunmEndIndex - originRemoveEndIndex; + + for (int i = totalColunmEndIndex; i > dynamicColunmEndIndex; i--) + { + + titelRow.GetCell(i).SetCellValue(titelRow.GetCell(i - gap).StringCellValue); + + templateRow.GetCell(i).SetCellValue(templateRow.GetCell(i - gap).StringCellValue); + } + + + + //设置动态Tilte + + for (int i = dynamicColunmStartIndex; i < dynamicColunmStartIndex + needAddCount; i++) + { + var name = dynamicColumnConfig.ColumnNameList[i - dynamicColunmStartIndex]; + + var cdicsCode= dynamicColumnConfig.CDISCList[i - dynamicColunmStartIndex]; + + cdicsRow.GetCell(i).SetCellValue(cdicsCode); + titelRow.GetCell(i).SetCellValue(name); + templateRow.GetCell(i).SetCellValue(""); + } + } + + using (var memoryStream2 = new MemoryStream()) + { + workbook.Write(memoryStream2, true); + + memoryStream2.Seek(0, SeekOrigin.Begin); + + templateStream = memoryStream2; + } + + } + + #endregion + + #region MiniExcel + + var memoryStream = new MemoryStream(); + + var config = new OpenXmlConfiguration() + { + IgnoreTemplateParameterMissing = true, + }; + + await MiniExcel.SaveAsByTemplateAsync(memoryStream, templateStream.ToArray(), translateData, config); + + memoryStream.Seek(0, SeekOrigin.Begin); + + if (dynamicColumnConfig != null) + { + var dynamicTranslateDataList = await _dictionaryService.GetBasicDataSelect(dynamicColumnConfig.TranslateDicNameList.ToArray()); + + // 使用NPOI 进行二次处理 + var wb = new XSSFWorkbook(memoryStream); + var sheet = wb.GetSheetAt(0); + + var list = translatedDic["List"] as IList; + + foreach (var itemResult in list) + { + var index = list.IndexOf(itemResult); + + //从第四行开始处理动态列 + var row = sheet.GetRow(index + dynamicColumnConfig.AutoColumnTitleRowIndex + 1); + + var itemDic = itemResult.ToDictionary(); + + var itemList = itemDic[dynamicColumnConfig.DynamicListName] as IList; + + //这个数组是动态的,有的多,有的少,所以在此对比Title 一致才赋值 + foreach (var itemObj in itemList) + { + + var iteObjDic = itemObj.ToDictionary(); + + var itemDicName = iteObjDic[dynamicColumnConfig.DynamicItemDicName]?.ToString(); + var itemValue = iteObjDic[dynamicColumnConfig.DynamicItemValueName]?.ToString(); + + //var writeIndex = itemList.IndexOf(itemObj) + dynamicColumnConfig.AutoColumnStartIndex; + + var writeIndex = dynamicColumnConfig.ColumnNameList.IndexOf(iteObjDic[dynamicColumnConfig.DynamicItemTitleName].ToString()) + dynamicColumnConfig.AutoColumnStartIndex; + + if (itemDicName.IsNotNullOrEmpty()) + { + + var translatedItemData = dynamicTranslateDataList[itemDicName].Where(t => t.Code.ToLower() == itemValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty; + + row.GetCell(writeIndex).SetCellValue(translatedItemData); + } + else + { + row.GetCell(writeIndex).SetCellValue(itemValue); + + } + + } + } + + var memoryStream2 = new MemoryStream(); + wb.Write(memoryStream2, true); + memoryStream2.Seek(0, SeekOrigin.Begin); + + memoryStream = memoryStream2; + + } + + + return (memoryStream, fileName); + + + + + #endregion + } + + + /// /// 导出文件模板 /// diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index a464a5c18..e355cc746 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -67,6 +67,11 @@ 动态列开始的行index 从0开始 + + + 模板列最后的索引 + + 动态的列名 @@ -15292,11 +15297,6 @@ 组件一致性和原Arm2是否有差异 - - - 最终导出的病灶信息 - - QCChallengeId diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index 0d6cc4f25..70692f8d6 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -1989,6 +1989,10 @@ namespace IRaCIS.Core.Application.Service.Common { list.Add(new ExportDocumentDes() { Code = StaticData.Export.OCT_ReadingLession_Export, ExportCatogory = ExportResult.OCT_ReadingLession_Export }); } + else if (criterion.CriterionType == CriterionType.SelfDefine) + { + list.Add(new ExportDocumentDes() { Code = StaticData.Export.CDISC_Reading_Export, ExportCatogory = ExportResult.CDISC }); + } switch (criterion.ArbitrationRule) { @@ -2120,13 +2124,16 @@ namespace IRaCIS.Core.Application.Service.Common { //病灶明细表 export_Template = StaticData.Export.ReadingLession_Export; - } else if (inQuery.ReadingExportType == ExportResult.OCT_ReadingLession_Export) { //OCT export_Template = StaticData.Export.OCT_ReadingLession_Export; - + } + else + { + //CDISC + export_Template = StaticData.Export.CDISC_Reading_Export; } @@ -2252,7 +2259,59 @@ namespace IRaCIS.Core.Application.Service.Common else if (inQuery.ReadingExportType == ExportResult.CDISC) { // 配置在外层问题 或者表格问题上 + var taskList = await query.ProjectTo(_mapper.ConfigurationProvider, + new + { + readingExportType = inQuery.ReadingExportType, + criterionType = criterion.CriterionType, + arbitrationRule = criterion.ArbitrationRule, + trialReadingCriterionId = inQuery.TrialReadingCriterionId, + isEn_Us = _userInfo.IsEn_Us + }).ToListAsync(); + //动态列,以不同的病灶配置的问题取并集 + var lessionAnserList = taskList.Where(t => t.LesionList.Count() > 0).FirstOrDefault()?.LesionList.FirstOrDefault()?.LessionAnswerList ?? new List(); + + //通过问题标识取并集 + + var dynamicTitleList = lessionAnserList.Select(t => new DymamicQuestionInfo { QuestionMark = t.QuestionMark, QuestionName = t.QuestionName, TranslateDicName = t.TranslateDicName }).Distinct(); + + //最终的病灶列表 要把裁判的也要加进去,需要处理裁判标记 + list = new List(); + + foreach (var item in taskList.OrderBy(t => t.SubjectCode).ThenBy(t => t.ArmEnum).ThenBy(t => t.VisitTaskNum)) + { + if (item.LesionList.Count > 0) + { + foreach (var lession in item.LesionList.OrderBy(t => t.LessionType).ThenBy(t => t.LessionCode)) + { + + var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionName = t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode }); + + + //有三部分组成 外层问题+ 没有配置病灶编号和类型+ 动态的表格问题 + var dynamicLessionInfoList = item.QuestionAnswerList.Union(dynamicPartialLessionInfoList).ToList(); + + //OCT 多个表格,但是只导出一个表格,有的问题答案就是空的 + if (dynamicLessionInfoList.Count > 0) + { + + var cloneItem = item.Clone(); + cloneItem.QuestionAnswerList = dynamicLessionInfoList; + + list.Add(cloneItem); + } + + } + } + else + { + //要把裁判任务加进去 裁判任务上没有病灶 + + list.Add(item); + } + + } } @@ -2261,111 +2320,160 @@ namespace IRaCIS.Core.Application.Service.Common list = list.OrderBy(t => t.SubjectCode).ThenBy(t => t.ArmEnum).ThenBy(t => t.VisitTaskNum).ToList(); + //处理裁判标记 + list = DealJudgeMark(criterion.ArbitrationRule, criterion.IsGlobalReading, list); + + //合并之前获取翻译的字典名,否则有的没法翻译 + var translateDicNameList = list.SelectMany(t => t.QuestionAnswerList).Where(t => t.TranslateDicName.IsNotNullOrEmpty()).Select(t => t.TranslateDicName).Distinct().ToList(); + + + if (inQuery.ReadingExportType != ExportResult.CDISC) + { + #region 系统标准处理整体肿瘤评估合并 + + //针对1.1 整体肿瘤评估 有的两列要合并一列 + if (criterion.CriterionType == CriterionType.RECIST1Point1 || criterion.CriterionType == CriterionType.RECIST1Pointt1_MB || criterion.CriterionType == CriterionType.IRECIST1Point1) + { + foreach (var item in list) + { + //处理合并表头 + + var questionType = item.IsBaseline == true ? QuestionType.ExistDisease : QuestionType.Tumor; + + var findItem = item.QuestionAnswerList.Where(t => t.QuestionType == questionType).FirstOrDefault(); + + if (findItem != null) + { + findItem.QuestionName = _userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估"; + } + + + if (item.IsBaseline == true) + { + item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.Tumor).ToList(); + } + else + { + item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.ExistDisease).ToList(); + } + } + } + else if (criterion.CriterionType == CriterionType.Lugano2014 || criterion.CriterionType == CriterionType.Lugano2014WithoutPET) + { + + foreach (var item in list) + { + //处理合并表头 + + var questionType = item.IsBaseline == true ? QuestionType.ExistDisease : QuestionType.ImgOncology; + + var findItem = item.QuestionAnswerList.Where(t => t.QuestionType == questionType).FirstOrDefault(); + + if (findItem != null) + { + findItem.QuestionName = _userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估"; + } + + if (item.IsBaseline == true) + { + item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.ImgOncology).ToList(); + } + else + { + item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.ExistDisease).ToList(); + } + } + } + else if (criterion.CriterionType == CriterionType.PCWG3) + { + + } + + + if (export_Template == StaticData.Export.CommonJudgeReadingDetail_Export) + { + //裁判产生标记为空的数据过滤掉 + list = list.Where(t => t.IsTrigerJudge != null).ToList(); + } + + #endregion + + } + + + + var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); exportInfo.CriterionName = criterion.CriterionName; - //处理裁判标记 - list = DealJudgeMark(criterion.ArbitrationRule, criterion.IsGlobalReading, list); - - - #region 系统标准处理整体肿瘤评估合并 - - var translateDicNameList = list.SelectMany(t => t.QuestionAnswerList).Where(t => t.TranslateDicName.IsNotNullOrEmpty()).Select(t => t.TranslateDicName).Distinct().ToList(); - - - //针对1.1 整体肿瘤评估 有的两列要合并一列 - if (criterion.CriterionType == CriterionType.RECIST1Point1 || criterion.CriterionType == CriterionType.RECIST1Pointt1_MB || criterion.CriterionType == CriterionType.IRECIST1Point1) - { - foreach (var item in list) - { - //处理合并表头 - - var questionType = item.IsBaseline == true ? QuestionType.ExistDisease : QuestionType.Tumor; - - var findItem = item.QuestionAnswerList.Where(t => t.QuestionType == questionType).FirstOrDefault(); - - if (findItem != null) - { - findItem.QuestionName = _userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估"; - } - - - if (item.IsBaseline == true) - { - item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.Tumor).ToList(); - } - else - { - item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.ExistDisease).ToList(); - } - } - } - else if (criterion.CriterionType == CriterionType.Lugano2014 || criterion.CriterionType == CriterionType.Lugano2014WithoutPET) - { - - foreach (var item in list) - { - //处理合并表头 - - var questionType = item.IsBaseline == true ? QuestionType.ExistDisease : QuestionType.ImgOncology; - - var findItem = item.QuestionAnswerList.Where(t => t.QuestionType == questionType).FirstOrDefault(); - - if (findItem != null) - { - findItem.QuestionName = _userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估"; - } - - if (item.IsBaseline == true) - { - item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.ImgOncology).ToList(); - } - else - { - item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.ExistDisease).ToList(); - } - } - } - else if (criterion.CriterionType == CriterionType.PCWG3) - { - - } - - var columNameList = list.SelectMany(t => t.QuestionAnswerList).Where(t => t.QuestionName.IsNotNullOrEmpty()).Select(t => t.QuestionName).Distinct().ToList(); - - #endregion - - if (export_Template == StaticData.Export.CommonJudgeReadingDetail_Export) - { - //裁判产生标记为空的数据过滤掉 - list = list.Where(t => t.IsTrigerJudge != null).ToList(); - } - exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list.Where(t => t.ReadingCategory != ReadingCategory.Global).ToList(), _userInfo.TimeZoneId); exportInfo.CurrentTime = ExportExcelConverterDate.DateTimeInternationalToString(DateTime.Now, _userInfo.TimeZoneId); - var dynamicColumnConfig = new DynamicColumnConfig() + var dynamicColumnConfig = new DynamicColumnConfig(); + + if (inQuery.ReadingExportType != ExportResult.CDISC) { - AutoColumnTitleRowIndex = 2, - AutoColumnStartIndex = 6, - TempalteLastColumnIndex = 8, - DynamicItemDicName = "TranslateDicName", - DynamicItemValueName = "QuestionValue", - DynamicItemTitleName = "QuestionName", - DynamicListName = "QuestionAnswerList", - RemoveColunmIndexList = removeColumnIndexList, - ColumnNameList = columNameList ?? new List(), - TranslateDicNameList = translateDicNameList ?? new List() - }; + //合并之后获取最后的列名 + var columNameList = list.SelectMany(t => t.QuestionAnswerList).Where(t => t.QuestionName.IsNotNullOrEmpty()).Select(t => t.QuestionName).Distinct().ToList(); - var (memoryStream, fileName) = await ExcelExportHelper.DataExport_NpoiTestAsync(export_Template, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(CommonEvaluationExport), criterion.CriterionType, dynamicColumnConfig); + dynamicColumnConfig = new DynamicColumnConfig() + { + AutoColumnTitleRowIndex = 2, + AutoColumnStartIndex = 6, + TempalteLastColumnIndex = 8, + DynamicItemDicName = "TranslateDicName", + DynamicItemValueName = "QuestionValue", + DynamicItemTitleName = "QuestionName", + DynamicListName = "QuestionAnswerList", + RemoveColunmIndexList = removeColumnIndexList, + ColumnNameList = columNameList ?? new List(), + TranslateDicNameList = translateDicNameList ?? new List() + }; - return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") + var (memoryStream, fileName) = await ExcelExportHelper.DataExport_NpoiTestAsync(export_Template, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(CommonEvaluationExport), criterion.CriterionType, dynamicColumnConfig); + + return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") + { + FileDownloadName = $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}_{fileName}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx" + }; + + } + else { - FileDownloadName = $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}_{fileName}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx" - }; + + var nameList = list.SelectMany(t => t.QuestionAnswerList).Where(t => t.QuestionName.IsNotNullOrEmpty() && t.CDISCCode.IsNotNullOrEmpty()).Select(t => new { t.QuestionName, t.CDISCCode }).Distinct().ToList(); + + var columNameList = nameList.Select(t => t.QuestionName).Distinct().ToList(); + var cdiscCodeList = nameList.Select(t => t.CDISCCode).Distinct().ToList(); + + dynamicColumnConfig = new DynamicColumnConfig() + { + AutoColumnTitleRowIndex = 1, + AutoColumnStartIndex = 6, + TempalteLastColumnIndex = 10, + DynamicItemDicName = "TranslateDicName", + DynamicItemValueName = "QuestionValue", + DynamicItemTitleName = "QuestionName", + DynamicListName = "QuestionAnswerList", + RemoveColunmIndexList = removeColumnIndexList, + ColumnNameList = columNameList ?? new List(), + CDISCList = cdiscCodeList, + TranslateDicNameList = translateDicNameList ?? new List() + }; + + var (memoryStream, fileName) = await ExcelExportHelper.CDISC_DataExport_Async(export_Template, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(CommonEvaluationExport), criterion.CriterionType, dynamicColumnConfig); + + return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") + { + FileDownloadName = $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}_{fileName}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx" + }; + } + + + + } diff --git a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs index ffe5176de..9ac293710 100644 --- a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs +++ b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs @@ -302,18 +302,20 @@ namespace IRaCIS.Core.Application.Contracts public string LatestReplyUserName { get; set; } = String.Empty; public string Content { get; set; } = string.Empty; - public string ContentReplaced { + public string ContentReplaced + { - get { - - var msg= Content.Replace("
", "").Replace("
", ""); + get + { + + var msg = Content.Replace("
", "").Replace("
", ""); string[] substrings = msg.Split(new string[] { "
", "
" }, StringSplitOptions.None); return string.Join("\n\n", substrings); } - - } + + } [DictionaryTranslateAttribute("ChallengeIsClosed")] public bool IsClosed { get; set; } @@ -1220,6 +1222,10 @@ namespace IRaCIS.Core.Application.Contracts #region CDISC_阅片结果表 + public string TrialCode { get; set; } + + public string TrialSiteSubjectCode => TrialSiteCode + SubjectCode; + //最晚拍片日期 public DateTime? LatestScanDate { get; set; } diff --git a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs index 241024ac7..87d69ffea 100644 --- a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs @@ -264,6 +264,8 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.SubjectCriterionReadingPeriodVisitNumList, t => t.MapFrom(u => u.Subject.ReadModuleList.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.ReadingSetType == ReadingSetType.ImageReading).Select(c => c.SubjectVisit.VisitNum))) + + .ForMember(o => o.TrialCode, t => t.MapFrom(u => u.Trial.TrialCode)) .ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.Subject.TrialSite.TrialSiteCode)) .ForMember(o => o.LatestScanDate, t => t.MapFrom(u => u.SourceSubjectVisit.LatestScanDate)) .ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.Subject.Code)) @@ -277,7 +279,7 @@ namespace IRaCIS.Core.Application.Service QuestionName = isEn_Us ? c.ReadingQuestionTrial.QuestionEnName : c.ReadingQuestionTrial.QuestionName, QuestionValue = c.IsGlobalChange ? c.GlobalChangeAnswer : c.Answer, TranslateDicName = c.ReadingQuestionTrial.DictionaryCode, - CDISCCode=c.ReadingQuestionTrial.CDISCCode + CDISCCode = c.ReadingQuestionTrial.CDISCCode }))) ; diff --git a/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs b/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs index d73a3cea9..c337afc0f 100644 --- a/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs +++ b/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs @@ -280,7 +280,7 @@ public static class StaticData public const string OCT_ReadingLession_Export = "OCT_ReadingLession_Export"; - + public const string CDISC_Reading_Export = "CDISC_Reading_Export"; public const string IVUSTheMeasuredValueOfEachMatchedFragment = "IVUS_TheMeasuredValueOfEachMatchedFragment";