From 31f56a39a5ff85c21e69c51de0af1c017ce1ab4b Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 21 Jan 2025 19:00:01 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=AF=BC=E8=A1=A8=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Common/ExcelExportService.cs | 3 ++- IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index b03622dab..9128348ad 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -2343,7 +2343,8 @@ namespace IRaCIS.Core.Application.Service.Common TableName = "", QuestionName = _userInfo.IsEn_Us ? t.QuestionEnName : t.QuestionName, CDISCCode = t.CDISCCode, - TranslateDicName = t.DictionaryCode + TranslateDicName = t.DictionaryCode, + GroupName = _userInfo.IsEn_Us ? t.GroupInfo.GroupEnName:t.GroupInfo.GroupName }).ToList(); diff --git a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs index bbe11f7b9..c2f2b4557 100644 --- a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs +++ b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs @@ -1176,6 +1176,8 @@ namespace IRaCIS.Core.Application.Contracts public string QuestionName { get; set; } public string TranslateDicName { get; set; } public string CDISCCode { get; set; } + + public string GroupName { get; set; } } @@ -1193,6 +1195,10 @@ namespace IRaCIS.Core.Application.Contracts public string TranslateDicName { get; set; } public string CDISCCode { get; set; } + + //外层问题会重复,所以需要分组名 + + public string Group { get; set; } } public class CommonEvaluationExport { From fb478aa5f2dac9dbafea31130f70a0288a1ee2cc Mon Sep 17 00:00:00 2001 From: hang <87227557@qq.com> Date: Tue, 21 Jan 2025 22:23:45 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=BC=E8=A1=A8?= =?UTF-8?q?=E5=A1=AB=E5=85=85=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FileDocProcess/ExcelExportHelper.cs | 81 ++++++++++++++--- .../IRaCIS.Core.Application.xml | 4 +- .../Service/Common/ExcelExportService.cs | 90 +++++++++++++------ 3 files changed, 136 insertions(+), 39 deletions(-) diff --git a/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs b/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs index 58223c3bf..8baf7789d 100644 --- a/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs +++ b/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs @@ -263,9 +263,9 @@ public static class ExcelExportHelper public List CDISCList { get; set; } = new List(); /// - /// 动态的列名 + /// 动态的列名 如果Id 重复,那么就按照名称填充,否则就按照Id 填充列数据 /// - public List ColumnNameList { get; set; } = new List(); + public List ColumnIdNameList { get; set; } /// /// 动态翻译的字典名 @@ -292,7 +292,18 @@ public static class ExcelExportHelper /// public string DynamicItemTitleName { get; set; } + public string DynamicItemTitleId { get; set; } + public List RemoveColunmIndexList { get; set; } = new List(); + + public class ColumItem + { + public Guid Id { get; set; } + public string Name { get; set; } + } + + public List ColumnIdList => ColumnIdNameList == null ? new List() : ColumnIdNameList.Select(t => t.Id.ToString()).ToList(); + public List ColumnNameList => ColumnIdNameList == null ? new List() : ColumnIdNameList.Select(t => t.Name).ToList(); } @@ -467,8 +478,11 @@ public static class ExcelExportHelper if (dynamicColumnConfig != null) { + var isCdics = dynamicColumnConfig.CDISCList.Count > 0; + 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); @@ -479,7 +493,7 @@ public static class ExcelExportHelper var beforeDynamicRemoveCount = dynamicColumnConfig.RemoveColunmIndexList.Where(t => t < dynamicColumnConfig.AutoColumnStartIndex).Count(); //动态添加列的数量 - var needAddCount = dynamicColumnConfig.ColumnNameList.Count; + var needAddCount = dynamicColumnConfig.ColumnIdNameList.Count; //原始表 最终索引 var originTotalEndIndex = dynamicColumnConfig.TempalteLastColumnIndex; @@ -521,8 +535,14 @@ public static class ExcelExportHelper //创建新的列 for (int i = originTotalEndIndex; i < originTotalEndIndex + needAddCount; i++) { + titelRow.CreateCell(i + 1); templateRow.CreateCell(i + 1); + + if (isCdics) + { + cdicsRow.CreateCell(i + 1); + } } //移动Title 和下面的模板标识 @@ -542,10 +562,17 @@ public static class ExcelExportHelper for (int i = dynamicColunmStartIndex; i < dynamicColunmStartIndex + needAddCount; i++) { - var name = dynamicColumnConfig.ColumnNameList[i - dynamicColunmStartIndex]; + var name = dynamicColumnConfig.ColumnIdNameList[i - dynamicColunmStartIndex].Name; titelRow.GetCell(i).SetCellValue(name); templateRow.GetCell(i).SetCellValue(""); + + if (isCdics) + { + var cdicsCode = dynamicColumnConfig.CDISCList[i - dynamicColunmStartIndex]; + + cdicsRow.GetCell(i).SetCellValue(cdicsCode); + } } } @@ -577,6 +604,9 @@ public static class ExcelExportHelper if (dynamicColumnConfig != null) { + //Excel 列是按照名称填充 还是Id 填充 + var isExcelAddDataWithName = dynamicColumnConfig.ColumnIdNameList.Select(t => t.Id).Distinct().Count() == 1; + var dynamicTranslateDataList = await _dictionaryService.GetBasicDataSelect(dynamicColumnConfig.TranslateDicNameList.ToArray()); // 使用NPOI 进行二次处理 @@ -607,7 +637,17 @@ public static class ExcelExportHelper //var writeIndex = itemList.IndexOf(itemObj) + dynamicColumnConfig.AutoColumnStartIndex; - var writeIndex = dynamicColumnConfig.ColumnNameList.IndexOf(iteObjDic[dynamicColumnConfig.DynamicItemTitleName].ToString()) + dynamicColumnConfig.AutoColumnStartIndex; + var writeIndex = 0; + + if (isExcelAddDataWithName) + { + writeIndex = dynamicColumnConfig.ColumnNameList.IndexOf(iteObjDic[dynamicColumnConfig.DynamicItemTitleName].ToString()) + dynamicColumnConfig.AutoColumnStartIndex; + } + else + { + writeIndex = dynamicColumnConfig.ColumnIdList.IndexOf(iteObjDic[dynamicColumnConfig.DynamicItemTitleId].ToString()) + dynamicColumnConfig.AutoColumnStartIndex; + } + if (itemDicName.IsNotNullOrEmpty()) { @@ -642,7 +682,18 @@ public static class ExcelExportHelper #endregion } - + /// + /// 暂时废弃--合并到上面 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// 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; @@ -779,7 +830,7 @@ public static class ExcelExportHelper var beforeDynamicRemoveCount = dynamicColumnConfig.RemoveColunmIndexList.Where(t => t < dynamicColumnConfig.AutoColumnStartIndex).Count(); //动态添加列的数量 - var needAddCount = dynamicColumnConfig.ColumnNameList.Count; + var needAddCount = dynamicColumnConfig.ColumnIdNameList.Count; //原始表 最终索引 var originTotalEndIndex = dynamicColumnConfig.TempalteLastColumnIndex; @@ -843,9 +894,9 @@ public static class ExcelExportHelper for (int i = dynamicColunmStartIndex; i < dynamicColunmStartIndex + needAddCount; i++) { - var name = dynamicColumnConfig.ColumnNameList[i - dynamicColunmStartIndex]; + var name = dynamicColumnConfig.ColumnIdNameList[i - dynamicColunmStartIndex].Name; - var cdicsCode= dynamicColumnConfig.CDISCList[i - dynamicColunmStartIndex]; + var cdicsCode = dynamicColumnConfig.CDISCList[i - dynamicColunmStartIndex]; cdicsRow.GetCell(i).SetCellValue(cdicsCode); titelRow.GetCell(i).SetCellValue(name); @@ -881,6 +932,8 @@ public static class ExcelExportHelper if (dynamicColumnConfig != null) { + var isExcelAddDataWithName = dynamicColumnConfig.ColumnIdNameList.Select(t => t.Id).Count() == 1; + var dynamicTranslateDataList = await _dictionaryService.GetBasicDataSelect(dynamicColumnConfig.TranslateDicNameList.ToArray()); // 使用NPOI 进行二次处理 @@ -911,7 +964,15 @@ public static class ExcelExportHelper //var writeIndex = itemList.IndexOf(itemObj) + dynamicColumnConfig.AutoColumnStartIndex; - var writeIndex = dynamicColumnConfig.ColumnNameList.IndexOf(iteObjDic[dynamicColumnConfig.DynamicItemTitleName].ToString()) + dynamicColumnConfig.AutoColumnStartIndex; + var writeIndex = 0; + if (isExcelAddDataWithName) + { + writeIndex = dynamicColumnConfig.ColumnNameList.IndexOf(iteObjDic[dynamicColumnConfig.DynamicItemTitleName].ToString()) + dynamicColumnConfig.AutoColumnStartIndex; + } + else + { + writeIndex = dynamicColumnConfig.ColumnIdList.IndexOf(iteObjDic[dynamicColumnConfig.DynamicItemTitleId].ToString()) + dynamicColumnConfig.AutoColumnStartIndex; + } if (itemDicName.IsNotNullOrEmpty()) { diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index fac96eb68..2c7525ff9 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -72,9 +72,9 @@ 模板列最后的索引 - + - 动态的列名 + 动态的列名 如果Id 重复,那么就按照名称填充,否则就按照Id 填充列数据 diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index 9128348ad..cad7b972b 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -2077,7 +2077,7 @@ namespace IRaCIS.Core.Application.Service.Common DynamicItemTitleName = "QuestionName", DynamicListName = "QuestionAnswerList", RemoveColunmIndexList = new List() { }, - ColumnNameList = columNameList ?? new List(), + ColumnIdNameList = columNameList.Select(t => new DynamicColumnConfig.ColumItem() { Id = Guid.Empty, Name = t }).ToList(), TranslateDicNameList = translateDicNameList ?? new List() }; @@ -2344,14 +2344,30 @@ namespace IRaCIS.Core.Application.Service.Common QuestionName = _userInfo.IsEn_Us ? t.QuestionEnName : t.QuestionName, CDISCCode = t.CDISCCode, TranslateDicName = t.DictionaryCode, - GroupName = _userInfo.IsEn_Us ? t.GroupInfo.GroupEnName:t.GroupInfo.GroupName + GroupName = _userInfo.IsEn_Us ? t.GroupInfo.GroupEnName : t.GroupInfo.GroupName }).ToList(); + //外层问题有重复,针对重复的加上组名 + foreach (var item in trialConfigQuestionList.GroupBy(t => t.QuestionName).Where(g => g.Count() > 1)) + { + var qName = item.Key; + + foreach (var configQuestion in trialConfigQuestionList) + { + if (configQuestion.QuestionName == qName) + { + configQuestion.QuestionName = $"{configQuestion.GroupName}_{configQuestion.QuestionName}"; + } + } + + } + + if (inQuery.ReadingExportType != ExportResult.CDISC) { //最终EXCEL 列 - var configCoumNameList = new List(); + var configCoumNameList = new List(); //最终翻译字典 var translateDicNameList = new List(); @@ -2370,7 +2386,7 @@ namespace IRaCIS.Core.Application.Service.Common #region 外层问题 可能存在合并 - var fistLeveLNameList = new List(); + var fistLeveLNameList = new List(); //肿瘤评估,非CDISC 导出 if (criterion.CriterionGroup == CriterionGroup.Tumor) @@ -2378,8 +2394,11 @@ namespace IRaCIS.Core.Application.Service.Common if (criterion.CriterionType == CriterionType.RECIST1Point1 || criterion.CriterionType == CriterionType.RECIST1Pointt1_MB || criterion.CriterionType == CriterionType.IRECIST1Point1) { - fistLeveLNameList = trialConfigQuestionList.Select(t => - (t.QuestionType == QuestionType.ExistDisease || t.QuestionType == QuestionType.Tumor) ? (_userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估") : t.QuestionName).Distinct().ToList(); + fistLeveLNameList = trialConfigQuestionList.Select(t => new DynamicColumnConfig.ColumItem() + { + Id = Guid.Empty, + Name = (t.QuestionType == QuestionType.ExistDisease || t.QuestionType == QuestionType.Tumor) ? (_userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估") : t.QuestionName + }).ToList(); @@ -2387,13 +2406,22 @@ namespace IRaCIS.Core.Application.Service.Common } else if (criterion.CriterionType == CriterionType.Lugano2014 || criterion.CriterionType == CriterionType.Lugano2014WithoutPET) { - fistLeveLNameList = trialConfigQuestionList.Select(t => - (t.QuestionType == QuestionType.ExistDisease || t.QuestionType == QuestionType.ImgOncology) ? (_userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估") : t.QuestionName).Distinct().ToList(); + + fistLeveLNameList = trialConfigQuestionList.Select(t => new DynamicColumnConfig.ColumItem() + { + Id = Guid.Empty, + Name = (t.QuestionType == QuestionType.ExistDisease || t.QuestionType == QuestionType.ImgOncology) ? (_userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估") : t.QuestionName + }).ToList(); } else if (criterion.CriterionType == CriterionType.PCWG3) { - fistLeveLNameList = trialConfigQuestionList.Select(t => t.QuestionName).ToList(); + fistLeveLNameList = trialConfigQuestionList.Select(t => new DynamicColumnConfig.ColumItem() + { + Id = Guid.Empty, + Name = t.QuestionName + }).ToList(); + } var exTralDicNameList = new List() { "LesionType" }; @@ -2403,7 +2431,11 @@ namespace IRaCIS.Core.Application.Service.Common else //非肿瘤评估,非CDISC 导出 { - fistLeveLNameList = trialConfigQuestionList.Select(t => t.QuestionName).ToList(); + fistLeveLNameList = trialConfigQuestionList.Select(t => new DynamicColumnConfig.ColumItem() + { + Id = t.QuestionId, + Name = t.QuestionName + }).ToList(); translateDicNameList = trialConfigQuestionList.Union(trialConfigTableQuestionList).Where(t => t.TranslateDicName.IsNotNullOrEmpty()).Select(t => t.TranslateDicName).Distinct().ToList(); @@ -2416,7 +2448,7 @@ namespace IRaCIS.Core.Application.Service.Common //肿瘤 表格问题直接去重、同时添加一些列 外层问题合并一些列 if (criterion.CriterionGroup == CriterionGroup.Tumor) { - var extralNameList = new List() { }; + var extralNameList = new List(); if (criterion.CriterionType == CriterionType.RECIST1Point1 || criterion.CriterionType == CriterionType.RECIST1Pointt1_MB || criterion.CriterionType == CriterionType.IRECIST1Point1 || criterion.CriterionType == CriterionType.Lugano2014 || criterion.CriterionType == CriterionType.Lugano2014WithoutPET) @@ -2424,8 +2456,8 @@ namespace IRaCIS.Core.Application.Service.Common //if(inQuery.ReadingExportType == ExportResult.DetailedTableOfLesions) { - extralNameList.Add(_userInfo.IsEn_Us ? "Lesion ID" : "病灶编号"); - extralNameList.Add(_userInfo.IsEn_Us ? "Lesion Type" : "病灶类型"); + extralNameList.Add(new DynamicColumnConfig.ColumItem() { Id = Guid.Empty, Name = _userInfo.IsEn_Us ? "Lesion ID" : "病灶编号" }); + extralNameList.Add(new DynamicColumnConfig.ColumItem() { Id = Guid.Empty, Name = _userInfo.IsEn_Us ? "Lesion Type" : "病灶类型" }); } } @@ -2433,13 +2465,13 @@ namespace IRaCIS.Core.Application.Service.Common { //if (inQuery.ReadingExportType == ExportResult.DetailedTableOfLesions) { - extralNameList.Add(_userInfo.IsEn_Us ? "Lesion Type" : "病灶类型"); + extralNameList.Add(new DynamicColumnConfig.ColumItem() { Id = Guid.Empty, Name = _userInfo.IsEn_Us ? "Lesion Type" : "病灶类型" }); } } - //肿瘤评估标准目前是去重 - var tableQuestionNameList = trialConfigTableQuestionList.Select(t => t.QuestionName).Distinct().ToList(); + //肿瘤评估标准目前是去重 按照问题名称填充 不是Id + var tableQuestionNameList = trialConfigTableQuestionList.Select(t => t.QuestionName).Distinct().Select(t => new DynamicColumnConfig.ColumItem() { Id = Guid.Empty, Name = t }).Distinct().ToList(); //有表格问题 那么就是三部分,否则就是外层问题 configCoumNameList = tableQuestionNameList.Count == 0 ? fistLeveLNameList : fistLeveLNameList.Union(extralNameList).Union(tableQuestionNameList).ToList(); @@ -2565,9 +2597,10 @@ namespace IRaCIS.Core.Application.Service.Common //多表格问题 if (isMutiTable) { - var extralNameList = new List() { _userInfo.IsEn_Us ? "Table Name" : "表格名称" }; + //多表格,增加的一列,就用Guid.Empty 标识 + var extralNameList = new List() { new DynamicColumnConfig.ColumItem() { Id = Guid.Empty, Name = _userInfo.IsEn_Us ? "Table Name" : "表格名称" } }; - var tableQuestionNameList = trialConfigTableQuestionList.Select(t => t.TableName + "_" + t.QuestionName).ToList(); + var tableQuestionNameList = trialConfigTableQuestionList.Select(t => new DynamicColumnConfig.ColumItem() { Id = t.QuestionId, Name = t.TableName + "_" + t.QuestionName }).ToList(); configCoumNameList = fistLeveLNameList.Union(extralNameList).Union(tableQuestionNameList).ToList(); } @@ -2575,7 +2608,7 @@ namespace IRaCIS.Core.Application.Service.Common { //单表格问题(直接用表格问题名称) 或者没有表格问题 - var tableNameList = trialConfigTableQuestionList.Select(t => t.QuestionName).Distinct().ToList(); + var tableNameList = trialConfigTableQuestionList.Select(t => new DynamicColumnConfig.ColumItem() { Id = t.QuestionId, Name = t.QuestionName }).ToList(); configCoumNameList = fistLeveLNameList.Union(tableNameList).ToList(); } @@ -2583,7 +2616,7 @@ namespace IRaCIS.Core.Application.Service.Common - #region 扩展病灶 + #region 扩展表格问题 //最终的病灶列表 要把裁判的也要加进去,需要处理裁判标记 @@ -2605,7 +2638,7 @@ namespace IRaCIS.Core.Application.Service.Common { var addLessionInfoList = new List(); - addLessionInfoList.Add(new CommonQuesionInfo() { QuestionName = _userInfo.IsEn_Us ? "Table Name" : "表格名称", QuestionValue = firstLessionAnser.TableName }); + addLessionInfoList.Add(new CommonQuesionInfo() { QuestionId = Guid.Empty, QuestionName = _userInfo.IsEn_Us ? "Table Name" : "表格名称", QuestionValue = firstLessionAnser.TableName }); var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionName = t.TableName + "_" + t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode }); @@ -2653,9 +2686,11 @@ namespace IRaCIS.Core.Application.Service.Common DynamicItemDicName = "TranslateDicName", DynamicItemValueName = "QuestionValue", DynamicItemTitleName = "QuestionName", + DynamicItemTitleId = "QuestionId", DynamicListName = "QuestionAnswerList", RemoveColunmIndexList = removeColumnIndexList, - ColumnNameList = configCoumNameList, + ColumnIdNameList = configCoumNameList, + CDISCList=new List(), TranslateDicNameList = translateDicNameList }; @@ -2665,11 +2700,11 @@ namespace IRaCIS.Core.Application.Service.Common else { - //CDISC 导出 只到外层问题级别 + //CDISC 导出 只到外层问题级别 使用Id 填充Excel var totalConfigCoumNameList = trialConfigQuestionList.ToList(); - var configCoumNameList = totalConfigCoumNameList.Select(t => t.QuestionName).ToList(); + var configCoumNameList = totalConfigCoumNameList.Select(t => new DynamicColumnConfig.ColumItem() { Id = t.QuestionId, Name = t.QuestionName }).ToList(); var translateDicList = totalConfigCoumNameList.Where(t => t.TranslateDicName.IsNotNullOrEmpty()).Select(t => t.TranslateDicName).Distinct().ToList(); @@ -2684,9 +2719,10 @@ namespace IRaCIS.Core.Application.Service.Common DynamicItemDicName = "TranslateDicName", DynamicItemValueName = "QuestionValue", DynamicItemTitleName = "QuestionName", + DynamicItemTitleId = "QuestionId", DynamicListName = "QuestionAnswerList", RemoveColunmIndexList = removeColumnIndexList, - ColumnNameList = configCoumNameList, + ColumnIdNameList = configCoumNameList, CDISCList = cdiscCodeList, TranslateDicNameList = translateDicList }; @@ -2704,7 +2740,7 @@ namespace IRaCIS.Core.Application.Service.Common //R1 R2 两个人的访视都阅片完成了才可以,去除只有一个人阅片完成的访视 //找到只有一个人阅片的受试者 和访视 var exceptVisit = list.Where(t => t.ReadingCategory == ReadingCategory.Visit) - .GroupBy(t => new { t.SubjectCode, t.TaskName}).Where(g => g.Count() == 1).Select(g => new { g.Key.SubjectCode, g.Key.TaskName }).ToList(); + .GroupBy(t => new { t.SubjectCode, t.TaskName }).Where(g => g.Count() == 1).Select(g => new { g.Key.SubjectCode, g.Key.TaskName }).ToList(); list = list.Where(t => !exceptVisit.Any(ev => ev.SubjectCode == t.SubjectCode && ev.TaskName == t.TaskName)).ToList(); @@ -2738,7 +2774,7 @@ namespace IRaCIS.Core.Application.Service.Common if (inQuery.ReadingExportType == ExportResult.CDISC) { - (memoryStream, fileName) = await ExcelExportHelper.CDISC_DataExport_Async(export_Template, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(CommonEvaluationExport), criterion.CriterionType, dynamicColumnConfig); + (memoryStream, fileName) = await ExcelExportHelper.DataExport_NpoiTestAsync(export_Template, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(CommonEvaluationExport), criterion.CriterionType, dynamicColumnConfig); } else From 7885cd151a84adb5c522918427a7ecd73682515e Mon Sep 17 00:00:00 2001 From: hang <87227557@qq.com> Date: Tue, 21 Jan 2025 22:54:23 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.xml | 14 ++++ .../Service/Common/ExcelExportService.cs | 70 +++++++++---------- 2 files changed, 47 insertions(+), 37 deletions(-) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 2c7525ff9..07e7bc1c8 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -102,6 +102,20 @@ Excel Title Name + + + 暂时废弃--合并到上面 + + + + + + + + + + + 导出文件模板 diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index cad7b972b..0860e05a1 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -2347,21 +2347,21 @@ namespace IRaCIS.Core.Application.Service.Common GroupName = _userInfo.IsEn_Us ? t.GroupInfo.GroupEnName : t.GroupInfo.GroupName }).ToList(); - //外层问题有重复,针对重复的加上组名 - foreach (var item in trialConfigQuestionList.GroupBy(t => t.QuestionName).Where(g => g.Count() > 1)) - { - var qName = item.Key; + #region 外层问题有重复,针对重复的加上组名 - foreach (var configQuestion in trialConfigQuestionList) - { - if (configQuestion.QuestionName == qName) - { - configQuestion.QuestionName = $"{configQuestion.GroupName}_{configQuestion.QuestionName}"; - } - } - - } + //foreach (var item in trialConfigQuestionList.GroupBy(t => t.QuestionName).Where(g => g.Count() > 1)) + //{ + // var qName = item.Key; + // foreach (var configQuestion in trialConfigQuestionList) + // { + // if (configQuestion.QuestionName == qName) + // { + // configQuestion.QuestionName = $"{configQuestion.GroupName}_{configQuestion.QuestionName}"; + // } + // } + //} + #endregion if (inQuery.ReadingExportType != ExportResult.CDISC) @@ -2384,13 +2384,15 @@ namespace IRaCIS.Core.Application.Service.Common TranslateDicName = t.DictionaryCode }).ToList(); - #region 外层问题 可能存在合并 + var fistLeveLNameList = new List(); //肿瘤评估,非CDISC 导出 if (criterion.CriterionGroup == CriterionGroup.Tumor) { + #region 外层问题处理 + if (criterion.CriterionType == CriterionType.RECIST1Point1 || criterion.CriterionType == CriterionType.RECIST1Pointt1_MB || criterion.CriterionType == CriterionType.IRECIST1Point1) { @@ -2424,30 +2426,13 @@ namespace IRaCIS.Core.Application.Service.Common } + #endregion + var exTralDicNameList = new List() { "LesionType" }; translateDicNameList = trialConfigQuestionList.Union(trialConfigTableQuestionList).Where(t => t.TranslateDicName.IsNotNullOrEmpty()).Select(t => t.TranslateDicName).Union(exTralDicNameList).Distinct().ToList(); - } - else - //非肿瘤评估,非CDISC 导出 - { - fistLeveLNameList = trialConfigQuestionList.Select(t => new DynamicColumnConfig.ColumItem() - { - Id = t.QuestionId, - Name = t.QuestionName - }).ToList(); - translateDicNameList = trialConfigQuestionList.Union(trialConfigTableQuestionList).Where(t => t.TranslateDicName.IsNotNullOrEmpty()).Select(t => t.TranslateDicName).Distinct().ToList(); - - } - - #endregion - - #region 表格问题 处理增加列 - - //肿瘤 表格问题直接去重、同时添加一些列 外层问题合并一些列 - if (criterion.CriterionGroup == CriterionGroup.Tumor) - { + #region 表格问题处理 肿瘤 表格问题直接去重、同时添加一些列 var extralNameList = new List(); if (criterion.CriterionType == CriterionType.RECIST1Point1 || criterion.CriterionType == CriterionType.RECIST1Pointt1_MB @@ -2587,10 +2572,21 @@ namespace IRaCIS.Core.Application.Service.Common #endregion + #endregion } - //非肿瘤的 问题名称是 表格名称_表格子问题名 else + //非肿瘤评估,非CDISC 导出 { + //外层问题处理 + fistLeveLNameList = trialConfigQuestionList.Select(t => new DynamicColumnConfig.ColumItem() + { + Id = t.QuestionId, + Name = t.QuestionName + }).ToList(); + + translateDicNameList = trialConfigQuestionList.Union(trialConfigTableQuestionList).Where(t => t.TranslateDicName.IsNotNullOrEmpty()).Select(t => t.TranslateDicName).Distinct().ToList(); + + #region 表格问题处理 问题名称是 表格名称_表格子问题名 var isMutiTable = trialConfigTableQuestionList.Select(t => t.TableName).Distinct().Count() > 1; @@ -2673,10 +2669,10 @@ namespace IRaCIS.Core.Application.Service.Common #endregion + #endregion } - #endregion dynamicColumnConfig = new DynamicColumnConfig() { @@ -2690,7 +2686,7 @@ namespace IRaCIS.Core.Application.Service.Common DynamicListName = "QuestionAnswerList", RemoveColunmIndexList = removeColumnIndexList, ColumnIdNameList = configCoumNameList, - CDISCList=new List(), + CDISCList = new List(), TranslateDicNameList = translateDicNameList }; From 23d759872268f0fc3bffa1e7560b8b0a48326c2b Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Wed, 22 Jan 2025 09:25:49 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.xml | 2 +- .../Reading/Dto/ReadingQuestionViewModel.cs | 3 +++ .../ReadingQuestionService.cs | 22 ++++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 5cc51e341..fac96eb68 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -13203,7 +13203,7 @@ - + 用户多账号,初次维护数据 diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs index d6b881d70..a1e57dd8c 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs @@ -1896,6 +1896,9 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public List ExportResult { get; set; } + + public Guid? GroupId { get; set; } + /// /// 导出的CDISCName /// diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs index b098f7af3..14b9c9378 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs @@ -127,10 +127,25 @@ namespace IRaCIS.Core.Application.Service List notShowType=new List() { ReadingQestionType.Group, ReadingQestionType.Screenshot, ReadingQestionType.Summary, ReadingQestionType.Upload }; var criterionInfo = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == inDto.TrialReadingCriterionId).FirstNotNullAsync(); + + var groupList = await _readingQuestionTrialRepository.Where(x => x.Type== ReadingQestionType.Group && x.ReadingQuestionCriterionTrialId == inDto.TrialReadingCriterionId) + .OrderBy(x => x.ShowOrder).Select(x => new TrialQuestionExport() + { + QuestionId = x.Id, + QuestionName = _userInfo.IsEn_Us ? x.GroupEnName : x.GroupName, + ExportResult = x.ExportResult, + GroupId= x.GroupId, + ShowOrder = x.ShowOrder, + IsTableQuestion = false, + CDISCCode = x.CDISCCode, + }).ToListAsync(); + + var questionList = await _readingQuestionTrialRepository.Where(x => !notShowType.Contains(x.Type) && x.ReadingQuestionCriterionTrialId == inDto.TrialReadingCriterionId) .OrderBy(x => x.ShowOrder).Select(x => new TrialQuestionExport() { QuestionId = x.Id, + GroupId=x.GroupId, QuestionName = _userInfo.IsEn_Us ? x.QuestionEnName : x.QuestionName, ExportResult = x.ExportResult, ShowOrder = x.ShowOrder, @@ -158,6 +173,11 @@ namespace IRaCIS.Core.Application.Service x.Children = tableQuestionList.Where(y => y.QuestionId == x.QuestionId).OrderBy(y => y.ShowOrder).ToList(); }); + groupList.ForEach(x => + { + x.Children = questionList.Where(y => y.GroupId == x.QuestionId).OrderBy(y => y.ShowOrder).ToList(); + }); + List dicCode = new List() { "1","2","8" }; var dicList = await _dictionaryRepository.Where(x => x.Parent.Code == "ExportResult") .Where(x=> dicCode.Contains(x.Code)) @@ -175,7 +195,7 @@ namespace IRaCIS.Core.Application.Service CriterionType = criterionInfo.CriterionType, CriterionGroup = criterionInfo.CriterionGroup, DicList = dicList, - QuestionList = questionList + QuestionList = groupList }; } From 48a98de7cc68a6538356b9752a9a51bbddff1081 Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Wed, 22 Jan 2025 09:27:24 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Reading/Dto/ReadingQuestionViewModel.cs | 2 ++ .../Service/Reading/ReadingCriterion/ReadingQuestionService.cs | 1 + 2 files changed, 3 insertions(+) diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs index a1e57dd8c..19da4238b 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs @@ -1899,6 +1899,8 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public Guid? GroupId { get; set; } + public bool IsGroup { get; set; } = false; + /// /// 导出的CDISCName /// diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs index 14b9c9378..bc7e18ec3 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs @@ -135,6 +135,7 @@ namespace IRaCIS.Core.Application.Service QuestionName = _userInfo.IsEn_Us ? x.GroupEnName : x.GroupName, ExportResult = x.ExportResult, GroupId= x.GroupId, + IsGroup= true, ShowOrder = x.ShowOrder, IsTableQuestion = false, CDISCCode = x.CDISCCode, From f76b66c35d1645215770d20a4dc68b993990e1d4 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 22 Jan 2025 10:14:38 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=86=85=E5=A4=96?= =?UTF-8?q?=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Service/Common/ExcelExportService.cs | 4 ++-- .../Service/TrialSiteUser/TrialMaintenanceService.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index 0860e05a1..ccbf5e4d1 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -2636,14 +2636,14 @@ namespace IRaCIS.Core.Application.Service.Common addLessionInfoList.Add(new CommonQuesionInfo() { QuestionId = Guid.Empty, QuestionName = _userInfo.IsEn_Us ? "Table Name" : "表格名称", QuestionValue = firstLessionAnser.TableName }); - var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionName = t.TableName + "_" + t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode }); + var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId=t.TableQuesionId, QuestionName = t.TableName + "_" + t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode }); //有三部分组成 外层问题+ 固定列表格名称 + 动态的表格问题 dynamicLessionInfoList = item.QuestionAnswerList.Union(addLessionInfoList).Union(dynamicPartialLessionInfoList).ToList(); } else { - var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionName = t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode }); + var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId = t.TableQuesionId, QuestionName = t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode }); //两部分组成 外层问题+ 动态的表格问题 dynamicLessionInfoList = item.QuestionAnswerList.Union(dynamicPartialLessionInfoList).ToList(); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs index eb25733da..a470d02b2 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs @@ -161,10 +161,10 @@ namespace IRaCIS.Core.Application.Service var query = _userRoleRepository.Where(t => t.UserTypeEnum != UserTypeEnum.SuperAdmin && t.IdentityUser.Status == UserStateEnum.Enable).IgnoreQueryFilters() //正式或者培训的项目 不能允许测试用户(必须正式用户) 同时必须是内部的用户 - .WhereIf(trialType == TrialType.OfficialTrial || trialType == TrialType.Training, t => t.IdentityUser.IsTestUser == false && t.IdentityUser.IsZhiZhun) + .WhereIf(trialType == TrialType.OfficialTrial || trialType == TrialType.Training, t => t.IdentityUser.IsTestUser == false /*&& t.IdentityUser.IsZhiZhun*/) //测试项目 可以加入 测试用户 或者内部正式用户 - .WhereIf(trialType == TrialType.NoneOfficial, t => t.IdentityUser.IsTestUser == true || (t.IdentityUser.IsTestUser == false && t.IdentityUser.IsZhiZhun)) + .WhereIf(trialType == TrialType.NoneOfficial, t => t.IdentityUser.IsTestUser == true /*|| (t.IdentityUser.IsTestUser == false && t.IdentityUser.IsZhiZhun)*/) .Where(t => userTypeEnums.Contains(t.UserTypeEnum)) .WhereIf(inQuery.UserTypeEnum != null, t => t.UserTypeEnum == inQuery.UserTypeEnum) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.UserRealName), t => t.IdentityUser.FullName.Contains(inQuery.UserRealName)) From 43ae270eb74f73e5d442aad40e7764b1d0f28623 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 22 Jan 2025 10:40:43 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MassTransit/Consumer/SubjectVisitQCAndCheckConsumer.cs | 4 ++-- .../Service/Document/TrialEmailNoticeConfigService.cs | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/IRaCIS.Core.Application/MassTransit/Consumer/SubjectVisitQCAndCheckConsumer.cs b/IRaCIS.Core.Application/MassTransit/Consumer/SubjectVisitQCAndCheckConsumer.cs index d3a64309c..650a53cff 100644 --- a/IRaCIS.Core.Application/MassTransit/Consumer/SubjectVisitQCAndCheckConsumer.cs +++ b/IRaCIS.Core.Application/MassTransit/Consumer/SubjectVisitQCAndCheckConsumer.cs @@ -586,8 +586,8 @@ public class CheckStateChangedToAuditEventConsumer( var topicStr = string.Format(input.topicStr, trialInfo.ResearchProgramNo, subjectCode, subjectVisit.VisitName); var htmlBodyStr = string.Format( CommonEmailHelper.ReplaceCompanyName(_systemEmailConfig, input.htmlBodyStr), - trialInfo.ExperimentName, // 项目 {1} - userinfo.FullName, // 用户名 {1} + userinfo.FullName, // 姓名 {0} + trialInfo.ExperimentName, // 项目 {1} subjectCode, // 受试者 {2} subjectVisit.VisitName, // 访视 {3} dictionValue[0], // 核查状态 {4} diff --git a/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs b/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs index c08126828..c532f86ed 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs @@ -281,8 +281,7 @@ namespace IRaCIS.Core.Application.Service { var topicStr = string.Format(isEn_us ? trialEmailConfig.EmailTopic : trialEmailConfig.EmailTopicCN, taskInfo.ResearchProgramNo, taskInfo.SubjectCode); - var htmlBodyStr = string.Format(isEn_us ? trialEmailConfig.EmailHtmlContent : trialEmailConfig.EmailHtmlContentCN, - StaticData.EmailSend.EmailNamePlaceholder, taskInfo.ResearchProgramNo, taskInfo.SubjectCode); + var htmlBodyStr = isEn_us ? trialEmailConfig.EmailHtmlContent : trialEmailConfig.EmailHtmlContentCN; return (topicStr, htmlBodyStr, isEn_us, null);