From 198a8601be70d0532e925f8445765c68f94a8f34 Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Mon, 6 Jun 2022 16:20:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.xml | 20 +-- .../Common/DTO/FrontAuditConfigViewModel.cs | 8 +- .../Inspection/FrontAuditConfigService.cs | 115 ++++++++---------- .../Common/AuditingData.cs | 102 +++++++++++----- 4 files changed, 137 insertions(+), 108 deletions(-) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 3365a78e4..8bc5aa0b1 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -269,7 +269,7 @@ - + 获取查询对象 @@ -303,7 +303,7 @@ - + 翻译稽查数据 @@ -350,11 +350,11 @@ - + 获取子数据 - + @@ -371,11 +371,11 @@ - + 获取Description - + @@ -385,11 +385,11 @@ - + 修改排序 - + @@ -1015,12 +1015,12 @@ 完全复制对象 - + 数据来源对象 - + 要赋值到的对象 diff --git a/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs b/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs index 0b6af178a..c4e4865fa 100644 --- a/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs +++ b/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs @@ -56,12 +56,12 @@ namespace IRaCIS.Core.Application.ViewModel /// /// 数据来源对象 /// - public Guid DataFromItemGuid { get; set; } + public Guid FromItemId { get; set; } /// /// 要赋值到的对象 /// - public Guid ThisItemGuid { get; set; } + public Guid ToItemId { get; set; } } @@ -84,7 +84,7 @@ namespace IRaCIS.Core.Application.ViewModel public class GetDescriptionByModuleTypeDto { - public Guid? ModuleType { get; set; } + public Guid ModuleTypeId { get; set; } } ///FrontAuditConfigQuery 列表查询参数模型 @@ -118,7 +118,7 @@ namespace IRaCIS.Core.Application.ViewModel public class ChangeFrontAuditSortDto { - public List SortData { get; set; } + public List SortDataList { get; set; } } public class FrontAuditSort diff --git a/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs b/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs index 64d3b547c..346cda09e 100644 --- a/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs @@ -64,7 +64,7 @@ namespace IRaCIS.Core.Application.Service /// /// [HttpPost] - public async Task> AccessToDialogue(AccessToDialogueInDto inDto) + public async Task> GetDialogList(AccessToDialogueInDto inDto) { List data = new List(); @@ -153,15 +153,15 @@ namespace IRaCIS.Core.Application.Service /// public async Task BatchAddFrontAudit(BatchAddFrontAudit data) { - var maxsort = await _frontAuditConfigRepository.Where(x => x.ParentId == data.ParentId).MaxAsync(x => x.Sort); + var maxSort = await _frontAuditConfigRepository.Where(x => x.ParentId == data.ParentId).MaxAsync(x => x.Sort); List fronts=new List(); foreach (var item in data.Columns) { - maxsort++; + maxSort++; fronts.Add(new FrontAuditConfig() { - Sort = maxsort, + Sort = maxSort, Code = item.Name, ValueCN = item.Remake, IsEnable = true, @@ -180,7 +180,7 @@ namespace IRaCIS.Core.Application.Service [HttpPost] public async Task> SetInspectionEnumValue(SetInspectionEnumValueDto dto) { - return await SetInspectionEnumValueData(dto); + return await SetInspectionEnumValueDataList(dto); } @@ -190,7 +190,7 @@ namespace IRaCIS.Core.Application.Service /// /// 传入Dto /// - private async Task> SetInspectionEnumValueData(SetInspectionEnumValueDto dto) + private async Task> SetInspectionEnumValueDataList(SetInspectionEnumValueDto dto) { var listIdentification = dto.Items.Select(x => x.Identification).ToList(); foreach (var item in dto.Items) @@ -215,9 +215,9 @@ namespace IRaCIS.Core.Application.Service /// /// 稽查数据 /// - private async Task SetDataInspectionDateType(List identification, string json) + private async Task SetDataInspectionDateType(List identificationList, string jsonStr) { - var list = await (from parent in _frontAuditConfigRepository.AsQueryable().Where(x => identification.Contains(x.Identification)) + var list = await (from parent in _frontAuditConfigRepository.AsQueryable().Where(x => identificationList.Contains(x.Identification)) join child in _frontAuditConfigRepository.AsQueryable().Where(x => x.EnumType == "Date" && x.IsEnable ) on parent.Id equals child.ParentId select new DateDto() { @@ -231,28 +231,28 @@ namespace IRaCIS.Core.Application.Service DateType = lst.Max(x => x.DateType), }).ToList(); - var JsonData = JsonConvert.DeserializeObject>(json); + var jsonDataDic = JsonConvert.DeserializeObject>(jsonStr); - if (JsonData == null) + if (jsonDataDic == null) { - return json; + return jsonStr; } - foreach (var item in JsonData.Keys) + foreach (var item in jsonDataDic.Keys) { var datefirst = list.FirstOrDefault(x => x.Code.ToLower() == item.ToLower()); - if (datefirst != null && !IsNullOrEmpty(JsonData[item])) + if (datefirst != null && !IsNullOrEmpty(jsonDataDic[item])) { try { if (datefirst.DateType == "Date") { - JsonData[item] = DateTime.Parse(JsonData[item].ToString()).ToString("yyyy-MM-dd"); + jsonDataDic[item] = DateTime.Parse(jsonDataDic[item].ToString()).ToString("yyyy-MM-dd"); } if (datefirst.DateType == "DateTime") { - JsonData[item] = DateTime.Parse(JsonData[item].ToString()).ToString("yyyy-MM-dd HH:mm:ss"); + jsonDataDic[item] = DateTime.Parse(jsonDataDic[item].ToString()).ToString("yyyy-MM-dd HH:mm:ss"); } } catch (Exception) @@ -263,7 +263,7 @@ namespace IRaCIS.Core.Application.Service } - return JsonConvert.SerializeObject(JsonData); + return JsonConvert.SerializeObject(jsonDataDic); } @@ -276,9 +276,9 @@ namespace IRaCIS.Core.Application.Service /// 要查询的外键值 /// 传入的纸 /// - private async Task GetInspectionEnumValue(List identification, string json) + private async Task GetInspectionEnumValue(List identificationList, string jsonStr) { - var list = await (from u in _frontAuditConfigRepository.Where(x => identification.Contains(x.Identification)) + var list = await (from u in _frontAuditConfigRepository.Where(x => identificationList.Contains(x.Identification)) join p in _frontAuditConfigRepository.Where(x => x.EnumType == "Foreign" && x.IsEnable) on u.Id equals p.ParentId select new { @@ -296,19 +296,19 @@ namespace IRaCIS.Core.Application.Service }).ToList(); - var JsonDataValue = JsonConvert.DeserializeObject>(json); + var jsonDataValueDic = JsonConvert.DeserializeObject>(jsonStr); foreach (var item in list) { - if (!JsonDataValue.ContainsKey(item.Key)) + if (!jsonDataValueDic.ContainsKey(item.Key)) { continue; } string Table = item.ForeignKeyTable; string ForeignKeyValue = item.ForeignKeyValue; string ForeignKeyText = item.ForeignKeyText; - if (JsonDataValue[item.Key] != null) + if (jsonDataValueDic[item.Key] != null) { - string value = JsonDataValue[item.Key].ToString(); + string value = jsonDataValueDic[item.Key].ToString(); string para = string.Empty; string sql = string.Empty; var JsonData = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(new { item = value })); @@ -328,10 +328,10 @@ namespace IRaCIS.Core.Application.Service SqlParameter[] paravalue = new SqlParameter[] { new SqlParameter("@para",para) }; - JsonDataValue[item.Key] = string.Join(",", _frontAuditConfigRepository._dbContext.Database.SqlQuery(sql, paravalue).Select(x => x.Text).ToList()); + jsonDataValueDic[item.Key] = string.Join(",", _frontAuditConfigRepository._dbContext.Database.SqlQuery(sql, paravalue).Select(x => x.Text).ToList()); } } - return JsonConvert.SerializeObject(JsonDataValue); + return JsonConvert.SerializeObject(jsonDataValueDic); } @@ -342,13 +342,13 @@ namespace IRaCIS.Core.Application.Service /// 标识 /// Json对象 /// - private async Task SetEnum(Guid trialId, List identifications, string jsonStr) + private async Task SetEnum(Guid trialId, List identificationList, string jsonStr) { if (jsonStr == null || jsonStr == "null") { return null; } - var list = await (from u in _frontAuditConfigRepository.Where(x => identifications.Contains(x.Identification)) + var list = await (from u in _frontAuditConfigRepository.Where(x => identificationList.Contains(x.Identification)) join p in _frontAuditConfigRepository.Where(x => x.Code != "AuditState" && x.EnumType == "Dictionary" && x.IsEnable) on u.Id equals p.ParentId select new { @@ -376,17 +376,17 @@ namespace IRaCIS.Core.Application.Service Type = lst.Max(x => x.Type), }).ToList(); - var JsonData = JsonConvert.DeserializeObject>(jsonStr); + var jsonDataDic = JsonConvert.DeserializeObject>(jsonStr); foreach (var item in list) { try { - if (!JsonData.ContainsKey(item.Key) || JsonData[item.Key] == null) + if (!jsonDataDic.ContainsKey(item.Key) || jsonDataDic[item.Key] == null) { continue; } - var value = JsonData[item.Key]; + var value = jsonDataDic[item.Key]; if (value.GetType() == typeof(JArray)) { JArray arrays = (JArray)value; @@ -397,7 +397,7 @@ namespace IRaCIS.Core.Application.Service { guids.Add(Guid.Parse(x.ToString())); }); - JsonData[item.Key] = string.Join(',', await _dictionaryRepository.Where(x => guids.Contains(x.Id)).Select(x => x.ValueCN).ToListAsync()); + jsonDataDic[item.Key] = string.Join(',', await _dictionaryRepository.Where(x => guids.Contains(x.Id)).Select(x => x.ValueCN).ToListAsync()); } else if (item.Type.ToLower() == "ChildGroup".ToLower()) { @@ -406,7 +406,7 @@ namespace IRaCIS.Core.Application.Service { guids.Add(x.ToString()); }); - JsonData[item.Key] = string.Join(',', await + jsonDataDic[item.Key] = string.Join(',', await _dictionaryRepository.Where(x => x.Code == item.Code).GroupJoin( _dictionaryRepository.Where(x => guids.Contains(x.ChildGroup)), a => a.Id, b => b.ParentId, (a, b) => new { @@ -424,7 +424,7 @@ namespace IRaCIS.Core.Application.Service { guids.Add(x.ToString()); }); - JsonData[item.Key] = string.Join(',', await + jsonDataDic[item.Key] = string.Join(',', await _dictionaryRepository.Where(x => x.Code == item.Code).GroupJoin( _dictionaryRepository.Where(x => guids.Contains(x.Code)), a => a.Id, b => b.ParentId, (a, b) => new { @@ -441,18 +441,18 @@ namespace IRaCIS.Core.Application.Service if (item.Type.ToLower() == "id".ToLower()) { Guid guid = Guid.Parse(value.ToString()); - JsonData[item.Key] = await _dictionaryRepository.Where(x => guid == x.Id).Select(x => x.ValueCN).FirstOrDefaultAsync(); + jsonDataDic[item.Key] = await _dictionaryRepository.Where(x => guid == x.Id).Select(x => x.ValueCN).FirstOrDefaultAsync(); } else if (item.Type.ToLower() == "ChildGroup".ToLower()) { - JsonData[item.Key] = await _dictionaryRepository.Where(x => x.Code == item.Code).Join(_dictionaryRepository.Where(x => x.ChildGroup == value.ToString()), a => a.Id, b => b.ParentId, (a, b) => new + jsonDataDic[item.Key] = await _dictionaryRepository.Where(x => x.Code == item.Code).Join(_dictionaryRepository.Where(x => x.ChildGroup == value.ToString()), a => a.Id, b => b.ParentId, (a, b) => new { value = b.ValueCN }).Select(x => x.value).FirstOrDefaultAsync(); } else { - JsonData[item.Key] = await _dictionaryRepository.Where(x => x.Code == item.Code).Join(_dictionaryRepository.Where(x => x.Code == value.ToString()), a => a.Id, b => b.ParentId, (a, b) => new + jsonDataDic[item.Key] = await _dictionaryRepository.Where(x => x.Code == item.Code).Join(_dictionaryRepository.Where(x => x.Code == value.ToString()), a => a.Id, b => b.ParentId, (a, b) => new { value = b.ValueCN }).Select(x => x.value).FirstOrDefaultAsync(); @@ -463,7 +463,7 @@ namespace IRaCIS.Core.Application.Service { } } - return JsonConvert.SerializeObject(JsonData); + return JsonConvert.SerializeObject(jsonDataDic); } @@ -537,12 +537,12 @@ namespace IRaCIS.Core.Application.Service /// /// 获取子数据 /// - /// + /// /// - [HttpPost] - public async Task> GetChildrenItem(GetChildrenItem item) + [HttpGet] + public async Task> GetAuditConfigChildList(Guid frontAuditConfigId) { - var list =await (from data in _repository.GetQueryable().Where(x => x.Id == item.Id) + var list =await (from data in _repository.GetQueryable().Where(x => x.Id == frontAuditConfigId) join childrenType in _repository.GetQueryable() on data.Id equals childrenType.ParentId select childrenType).OrderBy(x=>x.Sort).ToListAsync(); return list; @@ -556,12 +556,12 @@ namespace IRaCIS.Core.Application.Service [HttpPost] public async Task FullyReplicated(FullyReplicated fully) { - await _frontAuditConfigRepository.DeleteFromQueryAsync(x => x.ParentId == fully.ThisItemGuid); - var list = await _frontAuditConfigRepository.Where(x => x.ParentId == fully.DataFromItemGuid).ToListAsync(); + await _frontAuditConfigRepository.DeleteFromQueryAsync(x => x.ParentId == fully.ToItemId); + var list = await _frontAuditConfigRepository.Where(x => x.ParentId == fully.FromItemId).ToListAsync(); list.ForEach(x => { x.Id = NewId.NextGuid(); - x.ParentId = fully.ThisItemGuid; + x.ParentId = fully.ToItemId; }); await _frontAuditConfigRepository.AddRangeAsync(list); await _frontAuditConfigRepository.SaveChangesAsync(); @@ -662,12 +662,12 @@ namespace IRaCIS.Core.Application.Service /// /// 获取Description /// - /// + /// /// - [HttpPost] - public async Task> GetDescriptionByModuleType(GetDescriptionByModuleTypeDto dto) + [HttpGet] + public async Task> GetModuleTypeDescriptionList(Guid moduleTypeId) { - var result= await _frontAuditConfigRepository.Where(x=>x.ModuleTypeId== dto.ModuleType&&x.Description!=null &&x.Description!=string.Empty).Select(x=>x.Description).Distinct().ToListAsync(); + var result= await _frontAuditConfigRepository.Where(x=>x.ModuleTypeId== moduleTypeId && x.Description!=string.Empty).Select(x=>x.Description).Distinct().ToListAsync(); return result; } @@ -756,11 +756,11 @@ namespace IRaCIS.Core.Application.Service /// /// 修改排序 /// - /// + /// /// - public async Task ChangeFrontAuditSort(ChangeFrontAuditSortDto sortDto) + public async Task ChangeFrontAuditSort(List sortDataList) { - foreach (var item in sortDto.SortData) + foreach (var item in sortDataList) { await _frontAuditConfigRepository.BatchUpdateNoTrackingAsync(x => x.Id == item.Id, x => new FrontAuditConfig { @@ -778,29 +778,18 @@ namespace IRaCIS.Core.Application.Service /// public async Task AddOrUpdateFrontAuditConfig(FrontAuditConfigAddOrEdit addOrEditFrontAuditConfig) { - // 在此处拷贝automapper 映射 - - //CreateMap(); - - // CreateMap< FrontAuditConfig,FrontAuditConfigAddOrEdit>().ReverseMap(); - + if (await _frontAuditConfigRepository.AnyAsync(x =>x.Identification!=string.Empty&& x.Identification == addOrEditFrontAuditConfig.Identification && x.Id != addOrEditFrontAuditConfig.Id&&x.ConfigType=="M"&& addOrEditFrontAuditConfig.ConfigType== "M")) { return ResponseOutput.NotOk("标识重复"); } - if (await _frontAuditConfigRepository.AnyAsync(x => x.Description == addOrEditFrontAuditConfig.Description && x.Id != addOrEditFrontAuditConfig.Id && x.ConfigType == "M" && addOrEditFrontAuditConfig.ConfigType == "M")) { return ResponseOutput.NotOk("名称重复"); } - addOrEditFrontAuditConfig.CreateTime= DateTime.Now; - addOrEditFrontAuditConfig.UpdateTime= DateTime.Now; - addOrEditFrontAuditConfig.CreateUserId = _userInfo.Id; - addOrEditFrontAuditConfig.UpdateUserId= _userInfo.Id; - - var entity = await _repository.InsertOrUpdateAsync(addOrEditFrontAuditConfig, true); + var entity = await _frontAuditConfigRepository.InsertOrUpdateAsync(addOrEditFrontAuditConfig, true); return ResponseOutput.Ok(entity.Id.ToString()); diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index d9d163944..88644bf6c 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -85,6 +85,46 @@ namespace IRaCIS.Core.Infra.EFCore.Common } } + /// + /// 需要赋值的GeneralId + /// + private List NeedSetGeneralIdList + { + get + { + return new List() + { + typeof(SystemDocument), + typeof(SystemBasicData), + typeof(Trial), + typeof(VisitStage), + typeof(TrialDocument), + typeof(SystemDocConfirmedUser), + typeof(TrialDocUserTypeConfirmedUser), + typeof(Enroll), + typeof(EnrollDetail), + typeof(TrialSite), + typeof(TrialUser), + typeof(TrialSiteUser), + typeof(TrialSiteSurvey), + typeof(TrialQCQuestion), + typeof(DicomStudy), + typeof(DicomSeries), + typeof(NoneDicomStudy), + typeof(CheckChallengeDialog), + typeof(PreviousSurgery), + typeof(PreviousHistory), + typeof(PreviousOther), + typeof(QCChallenge), + typeof(QCChallengeDialog), + typeof(QCQuestion), + typeof(ConsistencyCheckFile), + typeof(DataInspection), + + }; + } + } + /// /// 插入Add的实体 /// @@ -105,21 +145,21 @@ namespace IRaCIS.Core.Infra.EFCore.Common } var userTypeIds = userTypes.Select(x => x.NeedConfirmUserTypeId).ToList(); - var usertypeNames = await _dbContext.UserType.Where(x => userTypeIds.Contains(x.Id)).Select(x => x.UserTypeShortName).ToListAsync(); - var usertypeName = string.Join(",", usertypeNames); - await InsertInspection(item.Entity, type, x => new DataInspection() + var userTypeNameList = await _dbContext.UserType.Where(x => userTypeIds.Contains(x.Id)).Select(x => x.UserTypeShortName).ToListAsync(); + var userTypeName = string.Join(",", userTypeNameList); + await InsertInspection(entity, type, x => new DataInspection() { GeneralId = x.Id }, new { - NeedConfirmedUserType = usertypeName, + NeedConfirmedUserType = userTypeName, }); } // 签名模板 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SystemBasicData))) { - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(item.Entity as SystemBasicData, type, x => new DataInspection() { GeneralId = x.Id, }); @@ -145,7 +185,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common trials = await this._dbContext.Dictionary.Where(x => dictionaryIds.Contains(x.Id)).Select(x => x.ValueCN).ToListAsync(); - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(item.Entity as Trial, type, x => new DataInspection() { TrialId = x.Id, @@ -169,7 +209,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common { VisitPlanStatus = false; } - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(item.Entity as VisitStage, type, x => new DataInspection() { VisitStageId = x.Id, GeneralId = x.Id, @@ -193,7 +233,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common var userTypeIds = userTypes.Select(x => x.NeedConfirmUserTypeId).ToList(); var usertypeNames = await _dbContext.UserType.Where(x => userTypeIds.Contains(x.Id)).Select(x => x.UserTypeShortName).ToListAsync(); var usertypeName = string.Join(",", usertypeNames); - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(entity, type, x => new DataInspection() { GeneralId = x.Id }, new @@ -209,7 +249,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common { var entity = item.Entity as SystemDocConfirmedUser; var systemDocument = await _dbContext.SystemDocument.Where(x => x.Id == entity.SystemDocumentId).FirstOrDefaultAsync(); - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(entity, type, x => new DataInspection() { GeneralId = x.Id, }, new @@ -229,7 +269,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common var trialDocument = await _dbContext.TrialDocument.Where(x => x.Id == entity.TrialDocumentId).FirstOrDefaultAsync(); var trialid = trialDocument.TrialId; - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(entity as TrialDocUserTypeConfirmedUser, type, x => new DataInspection() { TrialId = trialid, GeneralId = x.Id, @@ -245,7 +285,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common // 医生 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Enroll))) { - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(item.Entity as Enroll, type, x => new DataInspection() { GeneralId = x.Id, }); @@ -254,7 +294,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common // 医生详情 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(EnrollDetail))) { - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(item.Entity as EnrollDetail, type, x => new DataInspection() { GeneralId = x.Id, }); @@ -268,7 +308,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common { entity.Site = await _dbContext.Site.Where(x => x.Id == entity.SiteId).FirstOrDefaultAsync(); } - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(entity, type, x => new DataInspection() { GeneralId = x.Id, @@ -289,7 +329,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common var entity = item.Entity as TrialUser; var user = await _dbContext.Users.Include(x => x.UserTypeRole).FirstOrDefaultAsync(x => x.Id == entity.UserId); - await InsertInspection(item.Entity, type, x => new DataInspection + await InsertInspection(entity, type, x => new DataInspection { TrialId = x.TrialId, }, new @@ -336,7 +376,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common UserType userType = new UserType(); userType = await _dbContext.UserType.Where(x => x.Id == user.UserTypeId).FirstOrDefaultAsync(); - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(item.Entity as TrialSiteUser, type, x => new DataInspection() { GeneralId = x.Id, }, new @@ -376,7 +416,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common entity.ReviewerUser = await _dbContext.User.Where(x => x.Id == entity.ReviewerUserId).FirstOrDefaultAsync(); } - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(item.Entity as TrialSiteSurvey, type, x => new DataInspection() { GeneralId = x.Id, @@ -398,7 +438,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common { var entity = item.Entity as TrialQCQuestion; var paretName = await _dbContext.TrialQCQuestionConfigure.Where(x => x.Id == entity.ParentId).Select(x => x.QuestionName).FirstOrDefaultAsync(); - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(entity, type, x => new DataInspection() { GeneralId = x.Id, }, new @@ -421,7 +461,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common var entity = item.Entity as Subject; var FinalSubjectVisitName = await _dbContext.SubjectVisit.AsNoTracking().Where(x => x.Id == entity.FinalSubjectVisitId && entity.FinalSubjectVisitId != null).Select(x => x.VisitName).FirstOrDefaultAsync(); - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(entity, type, x => new DataInspection() { SubjectId = x.Id, SubjectCode = x.Code, @@ -434,7 +474,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common // 检查 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomStudy))) { - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(item.Entity as DicomStudy, type, x => new DataInspection() { GeneralId = x.Id, }); @@ -449,7 +489,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common { dicomStudy = await _dbContext.DicomStudys.AsNoTracking().FirstOrDefaultAsync(x => x.Id == entity.StudyId); } - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(item.Entity as DicomSeries, type, x => new DataInspection() { GeneralId = x.Id, }, new @@ -467,7 +507,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common var filecount = await _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.Id).CountAsync(); - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(item.Entity as NoneDicomStudy, type, x => new DataInspection() { GeneralId = x.Id, }, new @@ -521,7 +561,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common reason = entity.TalkContent.Substring(entity.TalkContent.LastIndexOf(':') + 1); break; } - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(entity, type, x => new DataInspection() { GeneralId = entity.SubjectVisitId, TrialId = subjectvisit.TrialId, @@ -553,7 +593,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common var subjectCode = entity.Subject?.Code; - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(item.Entity as SubjectVisit, type, x => new DataInspection() { SubjectCode = subjectCode, SubjectId = x.SubjectId, @@ -570,7 +610,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common var entity = item.Entity as PreviousSurgery; var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync(); subjectvisit = subjectvisit ?? new SubjectVisit(); - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(entity, type, x => new DataInspection() { GeneralId = x.Id, SiteId = subjectvisit.SiteId, @@ -590,7 +630,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common var entity = item.Entity as PreviousHistory; var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync(); subjectvisit = subjectvisit ?? new SubjectVisit(); - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(entity, type, x => new DataInspection() { GeneralId = x.Id, SiteId = subjectvisit.SiteId, @@ -609,7 +649,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common var entity = item.Entity as PreviousOther; var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync(); subjectvisit = subjectvisit ?? new SubjectVisit(); - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(entity, type, x => new DataInspection() { GeneralId = x.Id, SiteId = subjectvisit.SiteId, @@ -634,7 +674,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common { content = entity.Content; } - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(entity, type, x => new DataInspection() { GeneralId = x.Id, TrialId = x.TrialId, @@ -668,7 +708,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common var qCChallenge = await _dbContext.QCChallenge.Where(x => x.Id == entity.QCChallengeId).FirstOrDefaultAsync(); subjectvisit = subjectvisit ?? new SubjectVisit(); qCChallenge = qCChallenge ?? new QCChallenge(); - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(entity, type, x => new DataInspection() { GeneralId = qCChallenge.Id, TrialId = subjectvisit.TrialId, @@ -694,7 +734,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common //Qc 问题 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCQuestion))) { - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(item.Entity as QCQuestion, type, x => new DataInspection() { GeneralId = x.Id, }); @@ -705,7 +745,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common // 一致性核查文件 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ConsistencyCheckFile))) { - await InsertInspection(item.Entity, type, x => new DataInspection() + await InsertInspection(item.Entity as ConsistencyCheckFile, type, x => new DataInspection() { GeneralId = x.Id, CreateTime=x.CreateTime, @@ -805,7 +845,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common /// 表达式 /// 其他对象 /// - public async Task InsertInspection(object data, string type, Expression> expression = null, object otherItem = null,object originaldata=null) where T : class + public async Task InsertInspection(T data, string type, Expression> expression = null, object otherItem = null,object originaldata=null) where T : class { object entityobj = data; DataInspection inspection = new DataInspection();