From fe3316f7a8023101adde9d015d6940defb5bb6ac Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Thu, 18 Aug 2022 13:47:08 +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 | 18 +++++ .../Service/Reading/OrganInfoService.cs | 6 +- .../Service/Reading/ReadingQuestionService.cs | 79 +++++++++++++++++-- .../Service/Reading/_MapConfig.cs | 6 ++ 4 files changed, 97 insertions(+), 12 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs index bb9089bde..17abf130f 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs @@ -8,6 +8,14 @@ using System.Threading.Tasks; namespace IRaCIS.Core.Application.Service.Reading.Dto { + public class CopySystemCriterionDataInDto + { + public Guid SourceSystemCriterionId { get; set; } + + public Guid NewSystemCriterionId { get; set; } + } + + public class GetSystemCriterionListOutDto { public Guid CriterionId { get; set; } @@ -163,6 +171,16 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto } + public class ReadingQuestionSystemData : ReadingQuestionSystem + { + public Guid OriginalId { get; set; } + } + + public class ReadingTableQuestionSystemData : ReadingTableQuestionSystem + { + public Guid OriginalId { get; set; } + } + public class ReadingTrialTableQuestionData : ReadingTableQuestionTrial { public Guid OriginalId { get; set; } diff --git a/IRaCIS.Core.Application/Service/Reading/OrganInfoService.cs b/IRaCIS.Core.Application/Service/Reading/OrganInfoService.cs index 4079c179c..e64f81b9b 100644 --- a/IRaCIS.Core.Application/Service/Reading/OrganInfoService.cs +++ b/IRaCIS.Core.Application/Service/Reading/OrganInfoService.cs @@ -93,7 +93,7 @@ namespace IRaCIS.Core.Application.Service var organInfoQueryable = _organInfoRepository .Where(x=>x.SystemCriterionId==inQuery.SystemCriterionId) .WhereIf(inQuery.LesionType != null, x => x.LesionType == inQuery.LesionType) - .ProjectTo(_mapper.ConfigurationProvider); + .ProjectTo(_mapper.ConfigurationProvider); return await organInfoQueryable.ToListAsync(); } @@ -173,10 +173,6 @@ namespace IRaCIS.Core.Application.Service join trialData in _organTrialInfoRepository.WhereIf(inDto.IsEnable != null, x => x.IsEnable == inDto.IsEnable) .Where(x => x.TrialId == inDto.TrialId) on data.Id equals trialData.OrganInfoId - - - - select new GetTrialOrganListOutDto() { Id = trialData.Id, diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs index 10a6e6421..5c3e21ca4 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs @@ -71,6 +71,71 @@ namespace IRaCIS.Application.Services this._previousPDFRepository = previousPDFRepository; } + /// + /// 赋值一个系统标准到另一系统标准 + /// + /// + /// + [HttpPost] + public async Task CopySystemCriterionData(CopySystemCriterionDataInDto inDto) + { + var newSystemQuestionList = await _readingQuestionSystemRepository.Where(x => x.ReadingQuestionCriterionSystemId == inDto.SourceSystemCriterionId) + .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + newSystemQuestionList.ForEach(x => + { + x.Id = NewId.NextGuid(); + x.ReadingQuestionCriterionSystemId = inDto.NewSystemCriterionId; + }); + var copyNewQuestionList = newSystemQuestionList.Clone(); + var needAddDatas = new List(); + foreach (var x in newSystemQuestionList) + { + var question = x.Clone(); + if (question.ParentId != null) + { + question.ParentId = copyNewQuestionList.Where(y => x.ParentId == y.OriginalId).Select(y => y.Id).FirstOrDefault(); + } + if (question.RelevanceId != null) + { + question.RelevanceId = copyNewQuestionList.Where(y => x.RelevanceId == y.OriginalId).Select(y => y.Id).FirstOrDefault(); + } + needAddDatas.Add(question); + }; + + await _readingQuestionSystemRepository.BatchDeleteNoTrackingAsync(x => x.ReadingQuestionCriterionSystemId == inDto.NewSystemCriterionId); + await _readingQuestionSystemRepository.AddRangeAsync(needAddDatas); + + #region 表格问题 + var newSystemTableQuestionList = await _readingTableQuestionSystemRepository.Where(x => x.SystemCriterionId == inDto.SourceSystemCriterionId) + .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + var copeNewSystemTableQuestionList = newSystemTableQuestionList.Clone(); + var needAddTableDatas = new List(); + foreach (var x in newSystemTableQuestionList) + { + var tableQuestion = x.Clone(); + tableQuestion.SystemCriterionId =inDto.NewSystemCriterionId; + tableQuestion.Id = NewId.NextGuid(); + if (tableQuestion.ParentId != null) + { + tableQuestion.ParentId = copeNewSystemTableQuestionList.Where(y => x.ParentId == y.OriginalId).Select(y => y.Id).FirstOrDefault(); + } + if (tableQuestion.RelevanceId != null) + { + tableQuestion.RelevanceId = copeNewSystemTableQuestionList.Where(y => x.RelevanceId == y.OriginalId).Select(y => y.Id).FirstOrDefault(); + } + if (tableQuestion.DependParentId != null) + { + tableQuestion.DependParentId = copeNewSystemTableQuestionList.Where(y => x.DependParentId == y.OriginalId).Select(y => y.Id).FirstOrDefault(); + } + needAddTableDatas.Add(tableQuestion); + } + await _readingTableQuestionSystemRepository.BatchDeleteNoTrackingAsync(x => x.SystemCriterionId == inDto.NewSystemCriterionId); + await _readingTableQuestionSystemRepository.AddRangeAsync(needAddTableDatas); + #endregion + await _readingTableQuestionSystemRepository.SaveChangesAsync(); + return ResponseOutput.Ok(); + } + /// /// 获取获取系统阅片标准下拉 /// @@ -279,7 +344,7 @@ namespace IRaCIS.Application.Services x.ReadingQuestionCriterionTrialId = trialCriterion.Id; x.TrialId = trialCriterion.TrialId; }); - var copeNewQuestionList = newTrialQuestionList.Clone(); + var copyNewQuestionList = newTrialQuestionList.Clone(); var trialQuestionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == trialCriterion.Id).ToListAsync(); var needAddDatas = new List(); @@ -309,11 +374,11 @@ namespace IRaCIS.Application.Services if (question.ParentId != null) { - question.ParentId = copeNewQuestionList.Where(y => x.ParentId == y.ReadingQuestionSystemId).Select(y => y.Id).FirstOrDefault(); + question.ParentId = copyNewQuestionList.Where(y => x.ParentId == y.ReadingQuestionSystemId).Select(y => y.Id).FirstOrDefault(); } if (question.RelevanceId != null) { - question.RelevanceId = copeNewQuestionList.Where(y => x.RelevanceId == y.ReadingQuestionSystemId).Select(y => y.Id).FirstOrDefault(); + question.RelevanceId = copyNewQuestionList.Where(y => x.RelevanceId == y.ReadingQuestionSystemId).Select(y => y.Id).FirstOrDefault(); } @@ -336,7 +401,7 @@ namespace IRaCIS.Application.Services var newTrialTableQuestionList = await _readingTableQuestionSystemRepository.Where(x => x.SystemCriterionId == trialCriterion.ReadingQuestionCriterionSystemId) .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - var copenewTrialTableQuestionList = newTrialTableQuestionList.Clone(); + var copyNewTrialTableQuestionList = newTrialTableQuestionList.Clone(); var needAddTableDatas = new List(); foreach (var x in newTrialTableQuestionList) @@ -349,16 +414,16 @@ namespace IRaCIS.Application.Services if (tableQuestion.ParentId != null) { - tableQuestion.ParentId = copenewTrialTableQuestionList.Where(y => x.ParentId == y.OriginalId).Select(y => y.Id).FirstOrDefault(); + tableQuestion.ParentId = copyNewTrialTableQuestionList.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(); + tableQuestion.RelevanceId = copyNewTrialTableQuestionList.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(); + tableQuestion.DependParentId = copyNewTrialTableQuestionList.Where(y => x.DependParentId == y.OriginalId).Select(y => y.Id).FirstOrDefault(); } needAddTableDatas.Add(tableQuestion); diff --git a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs index 3c3372405..4b72db7a3 100644 --- a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs @@ -59,6 +59,12 @@ namespace IRaCIS.Core.Application.Service CreateMap(); + CreateMap() + .ForMember(d => d.OriginalId, u => u.MapFrom(s => s.Id)); + + CreateMap() + .ForMember(d => d.OriginalId, u => u.MapFrom(s => s.Id)); + CreateMap() .ForMember(d => d.ReadingQuestionSystemId, u => u.MapFrom(s => s.Id));