diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs index 3ca2a9992..a36df3a7f 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs @@ -831,52 +831,45 @@ namespace IRaCIS.Application.Services { if (trialCriterion.ReadingQuestionCriterionSystemId != null) { - + // 先找到项目系统问题Id和项目问题Id的对应关系 + var questionRelation = _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == trialCriterion.Id).ToDictionary( + x => x.ReadingQuestionSystemId??default(Guid), + x => x.Id + ); + // 将系统里面的问题转为项目问题 var newTrialQuestionList = await _readingQuestionSystemRepository.Where(x => x.ReadingQuestionCriterionSystemId == trialCriterion.ReadingQuestionCriterionSystemId) .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); newTrialQuestionList.ForEach(x => { - x.Id = NewId.NextGuid(); + if (questionRelation.ContainsKey(x.Id)) + { + x.Id = questionRelation[x.Id]; + } + else + { + var newid= NewId.NextGuid(); + questionRelation.Add(x.Id, newid); + x.Id = newid; + } + x.ReadingQuestionCriterionTrialId = trialCriterion.Id; x.TrialId = trialCriterion.TrialId; }); var copyNewQuestionList = newTrialQuestionList.Clone(); var trialQuestionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == trialCriterion.Id).ToListAsync(); - var needAddDatas = new List(); foreach (var x in newTrialQuestionList) { var question = x.Clone(); - - var firstQuestion = trialQuestionList.Where(y => y.ReadingQuestionSystemId == x.ReadingQuestionSystemId).FirstOrDefault(); - if (firstQuestion != null) - { - var systemData = _mapper.Map(x); - if (firstQuestion.IsJudgeQuestion) - { - if (firstQuestion.TypeValue != x.TypeValue) - { - firstQuestion.AnswerCombination = string.Empty; - firstQuestion.AnswerGroup = string.Empty; - firstQuestion.JudgeType = JudgeTypeEnum.None; - } - } - var newData = _mapper.Map(systemData, firstQuestion); - newData.Id = x.Id; - newData.ReadingQuestionSystemId = x.ReadingQuestionSystemId; - question = newData.Clone(); - } - // 最大问题数 - question.MaxQuestionCount = x.MaxQuestionCount; if (question.ParentId != null) { - question.ParentId = copyNewQuestionList.Where(y => x.ParentId == y.ReadingQuestionSystemId).Select(y => y.Id).FirstOrDefault(); + question.ParentId = questionRelation[question.ParentId??default(Guid)]; } if (question.RelevanceId != null) { - question.RelevanceId = copyNewQuestionList.Where(y => x.RelevanceId == y.ReadingQuestionSystemId).Select(y => y.Id).FirstOrDefault(); + question.RelevanceId = questionRelation[question.RelevanceId ?? default(Guid)]; } @@ -898,19 +891,35 @@ namespace IRaCIS.Application.Services }) ; - - - - - #region 表格问题 + + // 先找到项目系统问题Id和项目问题Id的对应关系 + + var questionIds = needAddDatas.Select(x => x.Id).ToList(); + + + var tableQuestionRelation = _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId== trialCriterion.Id).ToDictionary( + x => x.SystemTableQuestionId ?? default(Guid), + x => x.Id + ); + + var newTrialTableQuestionList = await _readingTableQuestionSystemRepository.Where(x => x.SystemCriterionId == trialCriterion.ReadingQuestionCriterionSystemId) .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); newTrialTableQuestionList.ForEach(x => { - x.Id = NewId.NextGuid(); + if (tableQuestionRelation.ContainsKey(x.Id)) + { + x.Id = tableQuestionRelation[x.Id]; + } + else + { + var newid = NewId.NextGuid(); + tableQuestionRelation.Add(x.Id, newid); + x.Id = newid; + } }); var copyNewTrialTableQuestionList = newTrialTableQuestionList.Clone(); @@ -945,24 +954,6 @@ namespace IRaCIS.Application.Services await _readingTableQuestionTrialRepository.AddRangeAsync(needAddTableDatas); #endregion - - //#region 标准字典 移到别处去了 - //await _readingCriterionDictionaryRepository.BatchDeleteNoTrackingAsync(x => x.CriterionId == trialCriterion.Id); - //var criterionDictionaryList = await _readingCriterionDictionaryRepository.Where(x => x.CriterionId == trialCriterion.ReadingQuestionCriterionSystemId.Value). - // Select(x => new ReadingCriterionDictionary() { - // CriterionId = trialCriterion.Id, - // DictionaryId = x.DictionaryId, - // IsSystemCriterion = false, - // ParentCode = x.ParentCode, - - // }).ToListAsync(); - - //await _readingCriterionDictionaryRepository.AddRangeAsync(criterionDictionaryList); - //await _readingCriterionDictionaryRepository.SaveChangesAsync(); - //#endregion - - - await _readingQuestionTrialRepository.SaveChangesAsync(); } } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs index e13107003..b841e7a38 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs @@ -617,10 +617,10 @@ namespace IRaCIS.Application.Services /// /// [HttpPost] - public async Task<(GetReadingTableQuestionOutDto, bool)> GetCustomTableQuestionAnswer(GetCustomTableQuestionAnswerInDto inDto) + public async Task<(GetReadingTableQuestionOutDto, object)> GetCustomTableQuestionAnswer(GetCustomTableQuestionAnswerInDto inDto) { - var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync(); + var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x=>x.SourceSubjectVisit).FirstNotNullAsync(); var tableAnswers = await _readingTableQuestionAnswerRepository .ProjectTo(_mapper.ConfigurationProvider) @@ -644,7 +644,9 @@ namespace IRaCIS.Application.Services } - ), true); + ),new { + IsBaseline= taskInfo.SourceSubjectVisit!=null&&taskInfo.SourceSubjectVisit.IsBaseLine + }); } diff --git a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs index e0d240324..f3e1a3ce0 100644 --- a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs @@ -152,7 +152,8 @@ namespace IRaCIS.Core.Application.Service CreateMap() .ForMember(dest => dest.DependParentQuestion, opt => opt.Ignore()) - .ForMember(d => d.OriginalId, u => u.MapFrom(s => s.Id)); + .ForMember(d => d.OriginalId, u => u.MapFrom(s => s.Id)) + .ForMember(d => d.SystemTableQuestionId, u => u.MapFrom(s => s.Id)); CreateMap() .ForMember(d => d.OriginalId, u => u.MapFrom(s => s.Id)); diff --git a/IRaCIS.Core.Domain/Reading/ReadingCriterionQuestion/ReadingTableQuestionTrial.cs b/IRaCIS.Core.Domain/Reading/ReadingCriterionQuestion/ReadingTableQuestionTrial.cs index 1507fc301..4efe88217 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingCriterionQuestion/ReadingTableQuestionTrial.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingCriterionQuestion/ReadingTableQuestionTrial.cs @@ -198,6 +198,11 @@ namespace IRaCIS.Core.Domain.Models /// public bool IsCopy { get; set; } = false; + /// + /// 系统表格问题Id + /// + public Guid? SystemTableQuestionId { get; set; } + [NotMapped] public List ParentTriggerValueList