From 4e21dc843273ebc53088ec366a134e738be81fde Mon Sep 17 00:00:00 2001 From: "{872297557@qq.com}" <872297557@qq.com> Date: Tue, 6 Dec 2022 18:08:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A8=BD=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReadingTableAnswerRowInfo.cs | 11 ++-- .../ReadingTableQuestionAnswer.cs | 3 ++ .../Common/AuditingData.cs | 50 +++++++++++++++++-- 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/IRaCIS.Core.Domain/Reading/ReadingFormAnswer/ReadingTableAnswerRowInfo.cs b/IRaCIS.Core.Domain/Reading/ReadingFormAnswer/ReadingTableAnswerRowInfo.cs index c2b033d3..1546a135 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingFormAnswer/ReadingTableAnswerRowInfo.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingFormAnswer/ReadingTableAnswerRowInfo.cs @@ -16,7 +16,7 @@ namespace IRaCIS.Core.Domain.Models public class ReadingTableAnswerRowInfo : Entity, IAuditAdd { /// - /// QuestionId + /// 第一层的Question /// public Guid QuestionId { get; set; } @@ -101,15 +101,20 @@ namespace IRaCIS.Core.Domain.Models /// public Guid CreateUserId { get; set; } + [JsonIgnore] [ForeignKey("SplitRowId")] public ReadingTableAnswerRowInfo SplitRow { get; set; } - + [JsonIgnore] [ForeignKey("MergeRowId")] public ReadingTableAnswerRowInfo MergeRow { get; set; } - + [JsonIgnore] [ForeignKey("QuestionId")] public ReadingQuestionTrial ReadingQuestionTrial { get; set; } + + + + } diff --git a/IRaCIS.Core.Domain/Reading/ReadingFormAnswer/ReadingTableQuestionAnswer.cs b/IRaCIS.Core.Domain/Reading/ReadingFormAnswer/ReadingTableQuestionAnswer.cs index 5156b254..f1ca0080 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingFormAnswer/ReadingTableQuestionAnswer.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingFormAnswer/ReadingTableQuestionAnswer.cs @@ -63,10 +63,13 @@ namespace IRaCIS.Core.Domain.Models public Guid RowId { get; set; } + [JsonIgnore] [ForeignKey("QuestionId")] public ReadingQuestionTrial ReadingQuestionTrial { get; set; } + + [JsonIgnore] [ForeignKey("TableQuestionId")] public ReadingTableQuestionTrial ReadingTableQuestionTrial { get; set; } diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index c9b2fa88..f447e3bd 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -575,7 +575,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common #endregion - await InsertInspection(entity, type, x => new InspectionConvertDTO() { VisitTaskId = x.Id, @@ -637,13 +636,58 @@ namespace IRaCIS.Core.Infra.EFCore.Common } //病灶这里操作 - if(entitys.Any(x => x.Entity.GetType() == typeof(ReadingTaskQuestionAnswer))) + if(entitys.Any(x => x.Entity.GetType() == typeof(ReadingTableQuestionAnswer))) { + + + + //var type = GetEntityAuditOpt(item); + //删除病灶接口 - if(_userInfo.RequestUrl == "ReadingImageTask/deleteReadingRowAnswer") + if (_userInfo.RequestUrl == "ReadingImageTask/deleteReadingRowAnswer") { + + + } + + //添加/修改病灶接口 + if (_userInfo.RequestUrl == "ReadingImageTask/submitTableQuestion") + { + //区分是添加还是删除操作 + var type = GetEntityAuditOpt(entitys.Where(x => x.Entity.GetType() == typeof(ReadingTableQuestionAnswer)).FirstOrDefault()); + + var tableQuestionAnswerList = entitys.Where(x => x.Entity.GetType() == typeof(ReadingTableQuestionAnswer)).Select(t => t.Entity as ReadingTableQuestionAnswer).ToList(); + + + //获取问题名称 组合成数组 + var tableQuesionList = await _dbContext.ReadingTableQuestionTrial.Where(t => tableQuestionAnswerList.Select(k => k.TableQuestionId).Contains(t.Id)).Select(t => new { TrialReadingCriterionId = t.ReadingQuestionTrial.ReadingQuestionCriterionTrialId, Type = t.ReadingQuestionTrial.QuestionName, t.QuestionName, QuestionId = t.Id, t.ShowOrder }).OrderBy(t => t.ShowOrder).ToListAsync(); + + var trialReadingCriterionId = tableQuesionList.FirstOrDefault()?.TrialReadingCriterionId; + + var firstEntity = tableQuestionAnswerList.First(); + + var cloneEntity = firstEntity.Clone(); + + //保证Id 唯一 用于区分病灶 + cloneEntity.Id = firstEntity.RowId; + + await InsertInspection(cloneEntity, type, x => new InspectionConvertDTO() + { + VisitTaskId = x.VisitTaskId, + + ObjectRelationParentId = x.VisitTaskId, + + TrialReadingCriterionId = trialReadingCriterionId + + }, new { QuestionAnswerList = + + //需要手动添加病灶类型 + tableQuestionAnswerList.Join(tableQuesionList, t => t.TableQuestionId, u => u.QuestionId, (t, u) => new { t.Answer, u.QuestionName, u.ShowOrder }).OrderBy(t => t.ShowOrder).ToList() }); + + + } }