From 041efdb83137110ef8475618d2c0304d0b279644 Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Thu, 18 Aug 2022 09:30:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reading/Dto/ReadingQuestionViewModel.cs | 10 ++++ .../Interface/IReadingQuestionService.cs | 2 + .../Service/Reading/ReadingQuestionService.cs | 56 +++++++++++++++++-- .../Service/Reading/_MapConfig.cs | 3 + .../TrialSiteUser/TrialConfigService.cs | 8 +++ .../Reading/ReadingTableQuestionSystem.cs | 5 ++ .../Reading/ReadingTableQuestionTrial.cs | 10 +++- 7 files changed, 88 insertions(+), 6 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs index cdc9397ac..bb9089bde 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs @@ -96,6 +96,12 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public Guid? DependParentId { get; set; } + /// + /// 系统标准Id + /// + public Guid SystemCriterionId { get; set; } + + } @@ -157,6 +163,10 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto } + public class ReadingTrialTableQuestionData : ReadingTableQuestionTrial + { + public Guid OriginalId { get; set; } + } public class SynchronizeCriterionInDto { [NotDefault] diff --git a/IRaCIS.Core.Application/Service/Reading/Interface/IReadingQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/Interface/IReadingQuestionService.cs index 69c064667..1c223cb32 100644 --- a/IRaCIS.Core.Application/Service/Reading/Interface/IReadingQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/Interface/IReadingQuestionService.cs @@ -13,5 +13,7 @@ namespace IRaCIS.Core.Application.Contracts { Task SetSystemCriterionDisable(Guid dictionaryId, Guid? parentId); + Task SynchronizeCriterion(SynchronizeCriterionInDto inDto); + } } \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs index 9606096cd..10a6e6421 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs @@ -316,6 +316,9 @@ namespace IRaCIS.Application.Services question.RelevanceId = copeNewQuestionList.Where(y => x.RelevanceId == y.ReadingQuestionSystemId).Select(y => y.Id).FirstOrDefault(); } + + + needAddDatas.Add(question); }; @@ -327,7 +330,50 @@ namespace IRaCIS.Application.Services }); - //var trial + + + #region 表格问题 + var newTrialTableQuestionList = await _readingTableQuestionSystemRepository.Where(x => x.SystemCriterionId == trialCriterion.ReadingQuestionCriterionSystemId) + .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + + var copenewTrialTableQuestionList = newTrialTableQuestionList.Clone(); + + var needAddTableDatas = new List(); + foreach (var x in newTrialTableQuestionList) + { + var tableQuestion = x.Clone(); + tableQuestion.TrialId = inDto.TrialId; + tableQuestion.TrialCriterionId = trialCriterion.Id; + tableQuestion.Id = NewId.NextGuid(); + + + if (tableQuestion.ParentId != null) + { + tableQuestion.ParentId = copenewTrialTableQuestionList.Where(y => x.ParentId == y.OriginalId).Select(y => y.Id).FirstOrDefault(); + } + if (tableQuestion.RelevanceId != null) + { + tableQuestion.RelevanceId = copenewTrialTableQuestionList.Where(y => x.RelevanceId == y.OriginalId).Select(y => y.Id).FirstOrDefault(); + } + + if (tableQuestion.DependParentId != null) + { + tableQuestion.DependParentId = copenewTrialTableQuestionList.Where(y => x.DependParentId == y.OriginalId).Select(y => y.Id).FirstOrDefault(); + } + + needAddTableDatas.Add(tableQuestion); + } + + + await _readingTableQuestionTrialRepository.BatchDeleteNoTrackingAsync(x => x.TrialCriterionId == trialCriterion.Id); + await _readingTableQuestionTrialRepository.AddRangeAsync(needAddTableDatas); + #endregion + + + + + + await _readingQuestionTrialRepository.SaveChangesAsync(); } } @@ -781,10 +827,12 @@ namespace IRaCIS.Application.Services Id = NewId.NextGuid(), }; List systemQuestionList = x.ReadingQuestionSystemList.Clone(); - List readingQuestionTrialList = new List(); - SetChildParentQuestion(criterion.Id, trialId, systemQuestionList, readingQuestionTrialList); + + // 同步问题暂时注释 + //List readingQuestionTrialList = new List(); + //SetChildParentQuestion(criterion.Id, trialId, systemQuestionList, readingQuestionTrialList); needAddCriterionList.Add(criterion); - needAddQuestionList.AddRange(readingQuestionTrialList); + //needAddQuestionList.AddRange(readingQuestionTrialList); }); await _readingQuestionCriterionTrialRepository.AddRangeAsync(needAddCriterionList); await _readingQuestionTrialRepository.AddRangeAsync(needAddQuestionList); diff --git a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs index 5d37305b1..b689a7f76 100644 --- a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs @@ -63,6 +63,9 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.ReadingQuestionSystemId, u => u.MapFrom(s => s.Id)); + CreateMap() + .ForMember(d => d.OriginalId, u => u.MapFrom(s => s.Id)); + CreateMap(); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs index 3a89dea4d..3ca662fb5 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs @@ -244,11 +244,19 @@ namespace IRaCIS.Core.Application if (trialCriterion.SynchronizeOriginalTime == null && trialCriterion.ReadingQuestionCriterionSystemId != null) { + // 同步器官 await _iOrganInfoService.SynchronizeSystemOrganToTrial(new SynchronizeSystemOrganToTrialInDto() { TrialId = inDto.TrialId, SystemCriterionId = trialCriterion.ReadingQuestionCriterionSystemId }); + + // 同步问题 + await iReadingQuestionService.SynchronizeCriterion(new SynchronizeCriterionInDto() + { + + TrialId = inDto.TrialId + }); } }; diff --git a/IRaCIS.Core.Domain/Reading/ReadingTableQuestionSystem.cs b/IRaCIS.Core.Domain/Reading/ReadingTableQuestionSystem.cs index 7b9f74e1c..33da868c6 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingTableQuestionSystem.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingTableQuestionSystem.cs @@ -122,6 +122,11 @@ namespace IRaCIS.Core.Domain.Models /// public TableQuestionType TableQuestionType { get; set; } + /// + /// 系统标准Id + /// + public Guid SystemCriterionId { get; set; } + } diff --git a/IRaCIS.Core.Domain/Reading/ReadingTableQuestionTrial.cs b/IRaCIS.Core.Domain/Reading/ReadingTableQuestionTrial.cs index b7c181a47..ef175242e 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingTableQuestionTrial.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingTableQuestionTrial.cs @@ -124,8 +124,14 @@ namespace IRaCIS.Core.Domain.Models /// IsDepend /// public int IsDepend { get; set; } - - } + + + /// + /// 项目标准Id + /// + public Guid TrialCriterionId { get; set; } + + } }