diff --git a/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs b/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs index dc48dd66e..bb06c55a6 100644 --- a/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs +++ b/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs @@ -74,15 +74,15 @@ public static class ExcelExportHelper { var itemDic = item.ConvertToDictionary(); - //处理集合里面时间类型,根据当前语言将时间转变为字符串 - foreach (var itemValuePair in itemDic) - { - // 临床数据 1,1 会变成2024-01-01 - if (itemValuePair.Value?.ToString().Length > 8 && DateTime.TryParse(itemValuePair.Value?.ToString(), out DateTime result)) - { - itemDic[itemValuePair.Key] = ExportExcelConverterDate.DateTimeInternationalToString(result); - } - } + ////处理集合里面时间类型,根据当前语言将时间转变为字符串 + //foreach (var itemValuePair in itemDic) + //{ + // // 临床数据 1,1 会变成2024-01-01 + // if (itemValuePair.Value?.ToString().Length > 8 && DateTime.TryParse(itemValuePair.Value?.ToString(), out DateTime result)) + // { + // itemDic[itemValuePair.Key] = ExportExcelConverterDate.DateTimeInternationalToString(result); + // } + //} foreach (var needTranslateProperty in needTranslatePropertyList) @@ -335,14 +335,14 @@ public static class ExcelExportHelper //var itemDic = JsonConvert.DeserializeObject>(item.ToJsonNotIgnoreNull()); var itemDic = item.ConvertToDictionary(); - //处理集合里面时间类型,根据当前语言将时间转变为字符串 - foreach (var itemValuePair in itemDic) - { - if (itemValuePair.Value?.ToString().Length > 8 && DateTime.TryParse(itemValuePair.Value?.ToString(), out DateTime result)) - { - itemDic[itemValuePair.Key] = ExportExcelConverterDate.DateTimeInternationalToString(result); - } - } + ////处理集合里面时间类型,根据当前语言将时间转变为字符串 + //foreach (var itemValuePair in itemDic) + //{ + // if (itemValuePair.Value?.ToString().Length > 8 && DateTime.TryParse(itemValuePair.Value?.ToString(), out DateTime result)) + // { + // itemDic[itemValuePair.Key] = ExportExcelConverterDate.DateTimeInternationalToString(result); + // } + //} foreach (var needTranslateProperty in needTranslatePropertyList) { diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 5f91adc12..c9bfa490c 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -933,7 +933,7 @@ - + 裁判一致率导出 diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index d46947b92..2a35844f8 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -8,6 +8,7 @@ using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infra.EFCore.Common; +using IRaCIS.Core.Infra.EFCore.Migrations; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; @@ -2347,6 +2348,7 @@ namespace IRaCIS.Core.Application.Service.Common public async Task GetCommonJudgeRatioList_Export(VisitTaskQuery inQuery, [FromServices] IRepository _commonDocumentRepository, [FromServices] IDictionaryService _dictionaryService, + [FromServices] IRepository _subjectUserRepository, [FromServices] IRepository _trialRepository) { //每次查询必须是单标准的 @@ -2555,17 +2557,33 @@ namespace IRaCIS.Core.Application.Service.Common })) .ToList(); - exportInfo.DoctorSubjectStatList = filteredList.GroupBy(t => new { t.DoctorUserId, t.UserName, t.FullName }).Select(g => new DoctorJudgeRatio() + + + //找到该标准的阅片人 + var armList = new List() { Arm.SingleReadingArm, Arm.DoubleReadingArm1, Arm.DoubleReadingArm2 }; + + exportInfo.DoctorSubjectStatList = _subjectUserRepository.Where(t => t.TrialId == inQuery.TrialId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && armList.Contains(t.ArmEnum)) + .Select(t => new DoctorJudgeRatio() + { + DoctorUserId = t.DoctorUserId, + UserName = t.DoctorUser.UserName, + FullName = t.DoctorUser.FullName, + + TotalJudgeCount = 0, + + JudgeAgreeCount = 0 + + }).Distinct().ToList(); + + foreach (var doctor in exportInfo.DoctorSubjectStatList) { - DoctorUserId = g.Key.DoctorUserId, - UserName = g.Key.UserName, - FullName = g.Key.FullName, + if (filteredList.Any(t => t.DoctorUserId == doctor.DoctorUserId)) + { + doctor.TotalJudgeCount= filteredList.Where(t=>t.DoctorUserId==doctor.DoctorUserId).Count(); - TotalJudgeCount = g.Count(), - - JudgeAgreeCount = g.Count(t => t.JudgeResultTaskId == t.VisitTaskId) - - }).ToList(); + doctor.JudgeAgreeCount= filteredList.Where(t => t.DoctorUserId == doctor.DoctorUserId).Count(t => t.JudgeResultTaskId == t.VisitTaskId); + } + } #endregion diff --git a/IRaCIS.Core.Infrastructure/_IRaCIS/ObjectExtension.cs b/IRaCIS.Core.Infrastructure/_IRaCIS/ObjectExtension.cs index 0e08f7634..56be0b871 100644 --- a/IRaCIS.Core.Infrastructure/_IRaCIS/ObjectExtension.cs +++ b/IRaCIS.Core.Infrastructure/_IRaCIS/ObjectExtension.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Reflection; @@ -8,29 +9,29 @@ namespace IRaCIS.Core.Infrastructure.Extention public static class ObjectExtension { - public static T Clone(this T source) - { - // Don't serialize a null object, simply return the default for that object - if (Object.ReferenceEquals(source, null)) - { - return default(T); - } + public static T Clone(this T source) + { + // Don't serialize a null object, simply return the default for that object + if (Object.ReferenceEquals(source, null)) + { + return default(T); + } - var deserializeSettings = new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling.Replace }; - var serializeSettings = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }; - return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(source, serializeSettings), deserializeSettings); - } + var deserializeSettings = new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling.Replace }; + var serializeSettings = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }; + return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(source, serializeSettings), deserializeSettings); + } - /// - /// 将对象序列化成稽查需要的Json字符串 - /// - /// - /// - public static string ToJsonStr(this object obj) - { - - return JsonConvert.SerializeObject(obj, new JsonSerializerSettings { DateFormatString = "yyyy-MM-dd HH:mm:ss", ReferenceLoopHandling = ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Ignore }); - } + /// + /// 将对象序列化成稽查需要的Json字符串 + /// + /// + /// + public static string ToJsonStr(this object obj) + { + + return JsonConvert.SerializeObject(obj, new JsonSerializerSettings { DateFormatString = "yyyy-MM-dd HH:mm:ss", ReferenceLoopHandling = ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Ignore }); + } /// /// 通过类型参数反序列化 JSON 字符串为指定类型的对象 @@ -55,12 +56,12 @@ namespace IRaCIS.Core.Infrastructure.Extention /// /// public static string ToJsonNotIgnoreNull(this object obj) - { + { - return JsonConvert.SerializeObject(obj, new JsonSerializerSettings { DateFormatString = "yyyy-MM-dd HH:mm:ss", Formatting = Formatting.Indented, ReferenceLoopHandling = ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Include }); - } + return JsonConvert.SerializeObject(obj, new JsonSerializerSettings { DateFormatString = "yyyy-MM-dd HH:mm:ss", Formatting = Formatting.Indented, ReferenceLoopHandling = ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Include }); + } - public static Dictionary ConvertToDictionary(this object obj) + public static Dictionary ConvertToDictionary(this object obj) { if (obj == null) { @@ -77,10 +78,19 @@ namespace IRaCIS.Core.Infrastructure.Extention string propertyName = property.Name; object propertyValue = property.GetValue(obj); // 如果属性的类型是枚举,将其值保留为整数 - if (property.PropertyType.IsEnum || (Nullable.GetUnderlyingType(property.PropertyType)?.IsEnum == true && propertyValue!=null) ) + if (property.PropertyType.IsEnum || (Nullable.GetUnderlyingType(property.PropertyType)?.IsEnum == true && propertyValue != null)) { dictionary.Add(propertyName, (int)propertyValue); } + // 检查属性是否是时间类型 + else if (property.PropertyType == typeof(DateTime) || + property.PropertyType == typeof(DateTime?) && propertyValue != null) + { + DateTime.TryParse(propertyValue.ToString(), out DateTime result); + var dt = ExportExcelConverterDate.DateTimeInternationalToString(result); + // 如果需要,可以对时间值进行特定的处理 + dictionary.Add(propertyName, dt); + } else { dictionary.Add(propertyName, propertyValue);