diff --git a/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs b/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs index f1f07ff5d..4142a62b5 100644 --- a/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs +++ b/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs @@ -28,7 +28,7 @@ public static class ExcelExportHelper /// /// /// - public static async Task DataExportAsync(string code, ExcelExportInfo data, string exportFileNamePrefix, IRepository _commonDocumentRepository, IWebHostEnvironment _hostEnvironment, IDictionaryService? _dictionaryService = null, Type? translateType = null, CriterionType? criterionType = null) + public static async Task DataExportAsync(string code, ExcelExportInfo data, string exportFileNamePrefix, IRepository _commonDocumentRepository, IWebHostEnvironment _hostEnvironment, IDictionaryService? _dictionaryService = null, Type? translateType = null, CriterionType? criterionType = null, List removeExcelIndexList = null) { var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US; @@ -158,6 +158,17 @@ public static class ExcelExportHelper workbook.Worksheets.Delete(2); // 删除第2个(索引2) } + if (removeExcelIndexList != null) + { + var worksheet = workbook.Worksheet(1); // 索引从1开始 + foreach (int colIndex in removeExcelIndexList.OrderByDescending(t=>t)) + { + // 删除整列 + worksheet.Column(colIndex).Delete(); + } + } + + //中文替换项目术语 if (data.TrialObjectNameList?.Count > 0) { @@ -932,14 +943,14 @@ public static class ExcelExportHelper //if (sheetCount == 2) //{ - if (inDto.IsEnglish) - { - workbook.Worksheet(1).Delete(); // 删除第一个工作表 - } - else - { - workbook.Worksheet(2).Delete(); // 删除第二个工作表 - } + if (inDto.IsEnglish) + { + workbook.Worksheet(1).Delete(); // 删除第一个工作表 + } + else + { + workbook.Worksheet(2).Delete(); // 删除第二个工作表 + } //} #endregion diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 79e078ea1..54c4ee799 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -43,7 +43,7 @@ - + @@ -855,6 +855,20 @@ 裁决日期 CODTC + + + 获取中心设备信息 + + + + + + + 调研表基本信息 + + + + 质控问题答案导出 diff --git a/IRaCIS.Core.Application/Service/Common/Export/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/Export/ExcelExportService.cs index f814ddc5d..f33aeb28a 100644 --- a/IRaCIS.Core.Application/Service/Common/Export/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/Export/ExcelExportService.cs @@ -10,6 +10,7 @@ using IRaCIS.Core.Infra.EFCore.Common; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; using System.Reflection; using System.Text; using static IRaCIS.Core.Application.Service.ExcelExportHelper; @@ -40,6 +41,162 @@ namespace IRaCIS.Core.Application.Service.Common IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IWebHostEnvironment _hostEnvironment) : BaseService { + + #region 中心调研导出 + + [HttpPost] + public async Task GetTrialSiteSurveyList_Export(TrialSiteSurveyQueryDTO inQuery, + [FromServices] IRepository _trialSiteSurveyRepository, + [FromServices] IDictionaryService _dictionaryService) + { + var trialSiteSurveyQueryable = _trialSiteSurveyRepository.Where(t => t.TrialId == inQuery.TrialId).IgnoreQueryFilters() + .WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId) + .WhereIf(inQuery.IsDeleted != null, t => t.IsDeleted == inQuery.IsDeleted) + .WhereIf(!string.IsNullOrWhiteSpace(inQuery.UserKeyInfo), t => t.UserName.Contains(inQuery.UserKeyInfo) || t.Phone.Contains(inQuery.UserKeyInfo) || t.Email.Contains(inQuery.UserKeyInfo)) + .WhereIf(inQuery.State != null, t => t.State == inQuery.State) + .WhereIf(inQuery.UpdateTimeBegin != null, t => t.UpdateTime >= inQuery.UpdateTimeBegin) + .WhereIf(inQuery.UpdateTimeEnd != null, t => t.UpdateTime <= inQuery.UpdateTimeEnd) + + .ProjectTo(_mapper.ConfigurationProvider, new { isEn_Us = _userInfo.IsEn_Us }) + .WhereIf(!string.IsNullOrWhiteSpace(inQuery.PreliminaryUserName), t => t.PreliminaryUser.RealName.Contains(inQuery.PreliminaryUserName)) + .WhereIf(!string.IsNullOrWhiteSpace(inQuery.ReviewerUserName), t => t.ReviewerUser.RealName.Contains(inQuery.ReviewerUserName)) + ; + + //var defalutSortArray = new string[] { /*nameof(TrialSiteSurveyView.LanguageType) + " desc", nameof(TrialSiteSurveyView.ShowOrder)*/ }; + + + var list = await trialSiteSurveyQueryable.SortToListAsync(inQuery /*,defalutSortArray*/); + + var exportInfo = new ExcelExportInfo(); + + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); + exportInfo.CurrentTime = ExportExcelConverterDate.DateTimeInternationalToString(DateTime.Now, _userInfo.TimeZoneId); + + return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialSiteSurvey_BasicInfo_Export, exportInfo, exportInfo.TrialCode, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(TrialSiteSurveyView)); + + } + + + /// + /// 获取中心设备信息 + /// + /// + /// + [HttpPost] + public async Task GetSiteSurveyEquipmentList_Export(SiteSurveyEquipmentQuery inQuery, + [FromServices] IRepository _trialSiteEquipmentSurveyRepository, + [FromServices] IDictionaryService _dictionaryService) + { + var query = _trialSiteEquipmentSurveyRepository.Where(t => t.TrialSiteSurvey.TrialId == inQuery.TrialId) + .WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteSurvey.TrialSiteId == inQuery.TrialSiteId) + .WhereIf(inQuery.TrialSiteCode.IsNotNullOrEmpty(), t => t.TrialSiteSurvey.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode)) + .WhereIf(inQuery.TrialSiteName.IsNotNullOrEmpty(), t => t.TrialSiteSurvey.TrialSite.TrialSiteAliasName.Contains(inQuery.TrialSiteName) || + t.TrialSiteSurvey.TrialSite.TrialSiteName.Contains(inQuery.TrialSiteName)) + .ProjectTo(_mapper.ConfigurationProvider); + + var siteSurveryConfig = _trialRepository.Where(t => t.Id == inQuery.TrialId).Select(t => t.TrialExtraConfigJsonStr).FirstOrDefault() ?? string.Empty; + + var config = JsonConvert.DeserializeObject(siteSurveryConfig) ?? new TrialExtraConfig(); + + + var fields = new List<(string FieldName, int excelIndex)>() + { + + ("Parameters", 5), + ("ManufacturerType", 6), + ("ScannerType", 7), + ("MagneticFieldStrengthType", 8), + ("BodyCoilChannelCount", 9), + ("HasDedicatedPdfFatQuantificationSequence", 10), + ("PdfFatQuantificationSequenceType", 11), + ("OtherSequenceSpecification", 11), + ("HasT2R2Correction", 12), + ("CanFullyExportPdfParameterMapsAndRawDicom", 13), + ("Note", 14), + }; + + + var viewNameList = config.EquipmentControlFieldList.Where(t => t.IsView == true).Select(t => t.FiledName).ToList(); + + var columnsToDelete = fields.Where(f => !viewNameList.Any(t=>f.FieldName==t)).Select(f => f.excelIndex).Distinct().OrderByDescending(i => i).ToList(); + + + //var defalutSortArray = new string[] { /*nameof(TrialSiteSurveyView.LanguageType) + " desc", nameof(TrialSiteSurveyView.ShowOrder)*/ }; + + + var list = await query.SortToListAsync(inQuery /*,defalutSortArray*/); + + var exportInfo = new ExcelExportInfo(); + + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); + exportInfo.CurrentTime = ExportExcelConverterDate.DateTimeInternationalToString(DateTime.Now, _userInfo.TimeZoneId); + + return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialSiteSurvey_Equipment_Export, exportInfo, exportInfo.TrialCode, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(SiteSurveyEquipmentDto), removeExcelIndexList: columnsToDelete); + + } + + /// + /// 调研表基本信息 + /// + /// + /// + [HttpPost] + public async Task GetSiteSurveyInfoList_Export(SiteSurveyInfoQuery inQuery, + [FromServices] IRepository _trialSiteSurveyRepository, + [FromServices] IDictionaryService _dictionaryService) + { + var query = _trialSiteSurveyRepository.Where(t => t.TrialId == inQuery.TrialId) + .WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId) + .WhereIf(inQuery.TrialSiteCode.IsNotNullOrEmpty(), t => t.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode)) + .WhereIf(inQuery.TrialSiteName.IsNotNullOrEmpty(), t => t.TrialSite.TrialSiteAliasName.Contains(inQuery.TrialSiteName) || + t.TrialSite.TrialSiteName.Contains(inQuery.TrialSiteName)) + + .ProjectTo(_mapper.ConfigurationProvider); + + + var siteSurveryConfig = _trialRepository.Where(t => t.Id == inQuery.TrialId).Select(t => t.TrialExtraConfigJsonStr).FirstOrDefault() ?? string.Empty; + + var config = JsonConvert.DeserializeObject(siteSurveryConfig) ?? new TrialExtraConfig(); + + + var fields = new List<(string FieldName, int excelIndex)>() + { + + ("Parameters", 5), + ("ManufacturerType", 6), + ("ScannerType", 7), + ("MagneticFieldStrengthType", 8), + ("BodyCoilChannelCount", 9), + ("HasDedicatedPdfFatQuantificationSequence", 10), + ("PdfFatQuantificationSequenceType", 11), + ("OtherSequenceSpecification", 11), + ("HasT2R2Correction", 12), + ("CanFullyExportPdfParameterMapsAndRawDicom", 13), + ("Note", 14), + }; + + + var viewNameList = config.EquipmentControlFieldList.Where(t => t.IsView == true).Select(t => t.FiledName).ToList(); + + var columnsToDelete = fields.Where(f => !viewNameList.Any(t => f.FieldName == t)).Select(f => f.excelIndex).Distinct().OrderByDescending(i => i).ToList(); + + + //var defalutSortArray = new string[] { /*nameof(TrialSiteSurveyView.LanguageType) + " desc", nameof(TrialSiteSurveyView.ShowOrder)*/ }; + + + var list = await query.SortToListAsync(inQuery /*,defalutSortArray*/); + + var exportInfo = new ExcelExportInfo(); + + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); + exportInfo.CurrentTime = ExportExcelConverterDate.DateTimeInternationalToString(DateTime.Now, _userInfo.TimeZoneId); + + return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialSiteSurvey_Info_Export, exportInfo, exportInfo.TrialCode, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(SiteSurveyEquipmentDto)); + + } + + #endregion + /// /// 质控问题答案导出 /// @@ -1197,7 +1354,7 @@ namespace IRaCIS.Core.Application.Service.Common t.VisitTaskList.Where(t => t.TaskState == TaskState.Effect && t.TrialReadingCriterionId == dto.TrialReadingCriterionId && t.TaskAllocationState == TaskAllocationState.Allocated && t.IsAnalysisCreate == false && t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState == ReadingTaskState.HaveSigned).Count() == (int)trialReadingCriterion.ReadingType ? ReadingStatusEnum.ReadCompleted : t.VisitTaskList.Where(t => t.TaskState == TaskState.Effect && t.TrialReadingCriterionId == dto.TrialReadingCriterionId && t.IsAnalysisCreate == false && t.ReadingCategory == ReadingCategory.Visit && t.TaskAllocationState == TaskAllocationState.Allocated).Count() == (int)trialReadingCriterion.ReadingType ? ReadingStatusEnum.ImageReading : t.ReadingStatus - }).OrderBy(t=>t.VisitTaskNum).ToList(), + }).OrderBy(t => t.VisitTaskNum).ToList(), ModuleList = subject.ReadModuleList.Where(t => t.TrialReadingCriterionId == dto.TrialReadingCriterionId).Select(t => new SubjectProgressDto.MouduleProgress() { @@ -2863,7 +3020,7 @@ namespace IRaCIS.Core.Application.Service.Common { //仲裁阅片 才有裁判阅片明细表 同时要把模板里面的三列给去掉 //removeColumnIndexList = new List() { 6, 7, 8 }; - removeColumnIndexList = new List() { 7, 8 ,9}; + removeColumnIndexList = new List() { 7, 8, 9 }; } //阅片结果表 和阅片结果明细表 没有肿瘤学的时候需要移除肿瘤学三个字段 diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteEquipmentSurveyViewModel.cs b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteEquipmentSurveyViewModel.cs index 1b383906d..74a79c5b2 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteEquipmentSurveyViewModel.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteEquipmentSurveyViewModel.cs @@ -3,6 +3,8 @@ // 生成时间 2021-12-23 13:21:04 // 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 //-------------------------------------------------------------------- +using IRaCIS.Core.Application.Helper; + namespace IRaCIS.Core.Application.Contracts { /// TrialSiteEquipmentSurveyView 列表视图模型 @@ -49,33 +51,44 @@ namespace IRaCIS.Core.Application.Contracts public string ScannerType { get; set; } = string.Empty; public string Note { get; set; } = string.Empty; - + [DictionaryTranslate("SiteSurvey_ScanEquipmentType")] [Comment("扫描设备-New")] public int? EquipmentTypeEnum { get; set; } public string OtherEquipmentType { get; set; } [Comment("扫描设备厂商")] + [DictionaryTranslate("ManufacturerType")] public int? ManufacturerType { get; set; } [Comment("磁场强度 (1.5T / 3.0T)")] + [DictionaryTranslate("MagneticFieldStrengthType")] public int? MagneticFieldStrengthType { get; set; } + + [DictionaryTranslate("BodyCoilChannelCount")] [Comment("体部线圈通道数 (≥16 或 <16)")] public int? BodyCoilChannelCount { get; set; } + [DictionaryTranslate("YesOrNo")] [Comment("是否具备专用的PDFF脂肪定量序列(CSE-MRI序列)")] public bool? HasDedicatedPdfFatQuantificationSequence { get; set; } + [DictionaryTranslate("PdfFatQuantificationSequenceType")] + [Comment("专用的PDFF脂肪定量序列类型 (当 HasDedicatedPdfFatQuantificationSequence = true 时有效)")] public int? PdfFatQuantificationSequenceType { get; set; } [Comment("其他序列详细说明 (当 PdfFatQuantificationSequenceType = Other 时建议填写)")] public string OtherSequenceSpecification { get; set; } + [DictionaryTranslate("YesOrNo")] [Comment("是否包含 T2/R2 校正(用于铁沉积校正)")] public bool? HasT2R2Correction { get; set; } + + + [DictionaryTranslate("YesOrNo")] [Comment("是否可完整导出 PDFF 参数图及全部原始 DICOM 数据")] public bool? CanFullyExportPdfParameterMapsAndRawDicom { get; set; } } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs index da5af4862..2bca8a9a7 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs @@ -5,6 +5,7 @@ //-------------------------------------------------------------------- using IRaCIS.Application.Contracts; +using IRaCIS.Core.Application.Helper; using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Domain.Share; using System.ComponentModel.DataAnnotations; @@ -138,6 +139,8 @@ namespace IRaCIS.Core.Application.Contracts public string TrialSiteAliasName { get; set; } = String.Empty; public string SiteName { get; set; } = string.Empty; + + [DictionaryTranslate("YesOrNo")] public bool IsDeleted { get; set; } public DateTime CreateTime { get; set; } @@ -145,7 +148,7 @@ namespace IRaCIS.Core.Application.Contracts public DateTime UpdateTime { get; set; } public Guid UpdateUserId { get; set; } - + [DictionaryTranslate("ResearchRecord")] public TrialSiteSurveyEnum State { get; set; } public string LatestBackReason { get; set; } = string.Empty; diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index ca8c375f3..4460662bf 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -525,11 +525,12 @@ namespace IRaCIS.Core.Application.Contracts } - var info = await GetSiteSurveyInfo(trialSiteSurveyId, trialId); - await _siteSurveyLogRepository.AddAsync(new SiteSurveyLog() { TrialSiteSurveyId = trialSiteSurveyId, Name = _userInfo.FullName, UserType = (UserTypeEnum)_userInfo.UserTypeEnumInt, OptType = SiteSurveyOptTyp.Reject, Reason = survey.LatestBackReason, Json = info.ToJsonStr() }); - + } + var info = await GetSiteSurveyInfo(trialSiteSurveyId, trialId); + await _siteSurveyLogRepository.AddAsync(new SiteSurveyLog() { TrialSiteSurveyId = trialSiteSurveyId, Name = _userInfo.FullName, UserType = (UserTypeEnum)_userInfo.UserTypeEnumInt, OptType = SiteSurveyOptTyp.Reject, Reason = survey.LatestBackReason, Json = info.ToJsonStr() }); + await _trialSiteSurveyRepository.SaveChangesAsync(); return ResponseOutput.Ok(); diff --git a/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs b/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs index 3a9b203c3..76e97c0af 100644 --- a/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs +++ b/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs @@ -325,7 +325,11 @@ public static class StaticData public const string TrialVisit_InfluenceStudys_Export = "TrialVisit_InfluenceStudys_Export"; - + public const string TrialSiteSurvey_BasicInfo_Export = "TrialSiteSurvey_BasicInfo_Export"; + + public const string TrialSiteSurvey_Info_Export = "TrialSiteSurvey_Info_Export"; + + public const string TrialSiteSurvey_Equipment_Export = "TrialSiteSurvey_Equipment_Export"; }