From 4de2da6ba27c0c83352a935f8673fca232e1710a Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Fri, 26 Aug 2022 11:36:14 +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 --- .../IRaCIS.Core.Application.xml | 4 +- .../Reading/Dto/ReadingImageTaskViewModel.cs | 13 +++- .../Reading/ReadingImageTaskService.cs | 64 ++++++++++++++----- .../Reading/ReadingTableAnswerRowInfo.cs | 56 ++++++++++++++++ .../Reading/ReadingTableQuestionAnswer.cs | 2 +- .../Context/IRaCISDBContext.cs | 2 +- IRaCIS.Core.Test/DbHelper.ttinclude | 2 +- 7 files changed, 120 insertions(+), 23 deletions(-) create mode 100644 IRaCIS.Core.Domain/Reading/ReadingTableAnswerRowInfo.cs diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 0bb742381..43a39ea58 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -1690,7 +1690,7 @@ 裁判结果的备注 - + 任务Id @@ -6969,7 +6969,7 @@ - + 获取子元素 diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs index 48d58ff69..bca5a42a2 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs @@ -55,7 +55,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto { public List Questions { get; set; } - public List> Answers { get; set; } + public List> Answers { get; set; } } public class GetReadingQuestionAndAnswerInDto @@ -603,13 +603,15 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto /// /// 任务Id /// - public Guid TaskId { get; set; } + public Guid VisitTaskId { get; set; } /// /// 项目Id /// public Guid TrialId { get; set; } + public string MeasureData { get; set; } + public List AnswerList { get; set; } @@ -742,6 +744,11 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public class TableQuestionDataInfo { + /// + /// + /// + public Guid Id { get; set; } + /// /// 问题ID /// @@ -968,7 +975,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto - public List TableQuestions { get; set; } + //public List TableQuestions { get; set; } public List Childrens { get; set; } } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs index a6a6c450a..8a1b17371 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs @@ -41,6 +41,7 @@ namespace IRaCIS.Application.Services private readonly IRepository _readingCriterionPageRepository; private readonly IRepository _readingJudgeInfoRepository; private readonly IRepository _readModuleRepository; + private readonly IRepository _readingTableAnswerRowInfoRepository; private readonly IRepository _readingTableQuestionSystemRepository; private readonly IRepository _readingTableQuestionTrialRepository; private readonly IRepository _readingTaskQuestionAnswerRepository; @@ -66,6 +67,7 @@ namespace IRaCIS.Application.Services IRepository readingCriterionPageRepository, IRepository readingJudgeInfoRepository, IRepository readModuleRepository, + IRepository readingTableAnswerRowInfoRepository, IRepository readingTableQuestionSystemRepository, IRepository readingTableQuestionTrialRepository, IRepository readingTaskQuestionAnswerRepository, @@ -90,6 +92,7 @@ namespace IRaCIS.Application.Services this._readingCriterionPageRepository = readingCriterionPageRepository; this._readingJudgeInfoRepository = readingJudgeInfoRepository; this._readModuleRepository = readModuleRepository; + this._readingTableAnswerRowInfoRepository = readingTableAnswerRowInfoRepository; this._readingTableQuestionSystemRepository = readingTableQuestionSystemRepository; this._readingTableQuestionTrialRepository = readingTableQuestionTrialRepository; this._readingTaskQuestionAnswerRepository = readingTaskQuestionAnswerRepository; @@ -148,8 +151,6 @@ namespace IRaCIS.Application.Services x.Answer = answers.Where(y => y.ReadingQuestionTrialId == x.Id).Select(x => x.Answer).FirstOrDefault() ?? string.Empty; }); - - #endregion var formType = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == criterion.Id).Select(x => x.FormType).FirstOrDefaultAsync(); @@ -162,8 +163,9 @@ namespace IRaCIS.Application.Services var tableAnswers = await _readingTableQuestionAnswerRepository .ProjectTo(_mapper.ConfigurationProvider) - .Where(x => x.TaskId == inDto.VisitTaskId).ToListAsync(); - + .Where(x => x.VisitTaskId == inDto.VisitTaskId).ToListAsync(); + + var tableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).ToListAsync(); if (formType == FormType.MultiplePage) { @@ -183,7 +185,7 @@ namespace IRaCIS.Application.Services var pageGroupList = newPageQusetionList.Where(x => x.Type == "group" || (x.ParentId == null && x.GroupName.IsNullOrEmpty())).ToList(); pageGroupList.ForEach(x => { - this.FindChildQuestion(x, newPageQusetionList, tableQuestionList, tableAnswers); + this.FindChildQuestion(x, newPageQusetionList, tableQuestionList, tableAnswers, tableAnsweRowInfos); }); page.Childrens = pageGroupList.Where(x => !(x.Type == "group" && x.Childrens.Count() == 0)).ToList(); @@ -200,7 +202,7 @@ namespace IRaCIS.Application.Services groupList = qusetionList.Where(x => x.Type == "group" || (x.ParentId == null && x.GroupName.IsNullOrEmpty())).ToList(); groupList.ForEach(x => { - this.FindChildQuestion(x, qusetionList, tableQuestionList, tableAnswers); + this.FindChildQuestion(x, qusetionList, tableQuestionList, tableAnswers, tableAnsweRowInfos); }); groupList = groupList.Where(x => !(x.Type == "group" && x.Childrens.Count() == 0)).ToList(); @@ -226,7 +228,7 @@ namespace IRaCIS.Application.Services /// /// /// - private void FindChildQuestion(TrialReadQuestionData item, List questionlists, List tableQuestionLists,List tableAnswers) + private void FindChildQuestion(TrialReadQuestionData item, List questionlists, List tableQuestionLists,List tableAnswers,List tableAnsweRowInfos) { item.Childrens = questionlists.Where(x => x.ParentId == item.Id || (item.Type == "group" && x.Type != "group" && x.ParentId == null && x.GroupName == item.GroupName)).ToList(); item.TableQuestions = new TrialReadTableQuestion(); @@ -234,17 +236,20 @@ namespace IRaCIS.Application.Services item.TableQuestions.Questions = tableQuestionLists.Where(x => x.ReadingQuestionId == item.Id).OrderBy(x=>x.ShowOrder).ToList(); var thisAnswer = tableAnswers.Where(x => x.QuestionId == item.Id).ToList(); var orders = thisAnswer.Select(x => x.RowIndex).Distinct().OrderBy(x => x).ToList(); - item.TableQuestions.Answers = new List>(); + item.TableQuestions.Answers = new List>(); orders.ForEach(x => { - Dictionary answers = new Dictionary(); + Dictionary answers = new Dictionary(); var rowAnswer = thisAnswer.Where(y => y.RowIndex == x).OrderBy(y => y.ShowOrder).ToList(); rowAnswer.ForEach(z => { - - answers.Add(z.TableQuestionId, z.Answer); + answers.Add(z.TableQuestionId.ToString(), z.Answer); }); + var rowInfo = tableAnsweRowInfos.Where(y => y.RowIndex == x && y.QuestionId == item.Id).FirstOrDefault(); + + answers.Add("MeasureData", rowInfo==null?string.Empty:rowInfo.MeasureData); + item.TableQuestions.Answers.Add(answers); }); @@ -252,7 +257,7 @@ namespace IRaCIS.Application.Services { item.Childrens.ForEach(x => { - this.FindChildQuestion(x, questionlists, tableQuestionLists, tableAnswers); + this.FindChildQuestion(x, questionlists, tableQuestionLists, tableAnswers, tableAnsweRowInfos); }); } } @@ -1039,7 +1044,23 @@ namespace IRaCIS.Application.Services public void FindSystemChildQuestion(GetSystemReadingQuestionOutDto item, List questionlists,List tableQuestions) { item.Childrens = questionlists.Where(x => x.ParentId == item.Id || (item.Type == "group" && x.Type != "group" && x.ParentId == null && x.GroupName == item.GroupName)).ToList(); - item.TableQuestions = tableQuestions.Where(x => x.ReadingQuestionId == item.Id).ToList(); + + + + + item.Childrens.AddRange(tableQuestions.Where(x => x.ReadingQuestionId == item.Id).Select(x => new GetSystemReadingQuestionOutDto + { + Childrens = new List(), + ShowOrder = x.ShowOrder, + GroupName = String.Empty, + Id = x.Id, + ImageCount = 0, + ParentId = item.Id, + QuestionName = x.QuestionName, + Remark = x.Remark, + + })); + if (item.Childrens != null && item.Childrens.Count != 0) { item.Childrens.ForEach(x => @@ -1373,7 +1394,8 @@ namespace IRaCIS.Application.Services [HttpPost] public async Task SubmitTableQuestion(SubmitTableQuestionInDto inDto) { - await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.TaskId == inDto.TaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId); + await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex); + await _readingTableAnswerRowInfoRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex); List answerList = inDto.AnswerList.Select(x => new ReadingTableQuestionAnswer() { Answer=x.Answer, @@ -1382,8 +1404,20 @@ namespace IRaCIS.Application.Services QuestionId=inDto.QuestionId, TableQuestionId=x.TableQuestionId, RowIndex=inDto.RowIndex, - TaskId=inDto.TaskId + VisitTaskId = inDto.VisitTaskId }).ToList(); + + await _readingTableAnswerRowInfoRepository.AddAsync(new ReadingTableAnswerRowInfo() + { + Id = NewId.NextGuid(), + TrialId = inDto.TrialId, + QuestionId = inDto.QuestionId, + MeasureData = inDto.MeasureData, + RowIndex = inDto.RowIndex, + VisitTaskId = inDto.VisitTaskId, + + + }); await _readingTableQuestionAnswerRepository.AddRangeAsync(answerList); await _readingTableQuestionAnswerRepository.SaveChangesAsync(); return ResponseOutput.Ok(true); diff --git a/IRaCIS.Core.Domain/Reading/ReadingTableAnswerRowInfo.cs b/IRaCIS.Core.Domain/Reading/ReadingTableAnswerRowInfo.cs new file mode 100644 index 000000000..6f2aba2d0 --- /dev/null +++ b/IRaCIS.Core.Domain/Reading/ReadingTableAnswerRowInfo.cs @@ -0,0 +1,56 @@ + +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 byzhouhang 20210918 +// 生成时间 2022-08-26 10:38:09 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +using System; +using IRaCIS.Core.Domain.Share; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +namespace IRaCIS.Core.Domain.Models +{ + /// + /// 表格问题答案行数据 + /// + [Table("ReadingTableAnswerRowInfo")] + public class ReadingTableAnswerRowInfo : Entity, IAuditAdd + { + /// + /// QuestionId + /// + public Guid QuestionId { get; set; } + + /// + /// VisitTaskId + /// + public Guid VisitTaskId { get; set; } + + /// + /// TrialId + /// + public Guid TrialId { get; set; } + + /// + /// RowIndex + /// + public int RowIndex { get; set; } + + /// + /// MeasureData + /// + public string MeasureData { get; set; } + + /// + /// CreateTime + /// + public DateTime CreateTime { get; set; } + + /// + /// CreateUserId + /// + public Guid CreateUserId { get; set; } + + } + + +} diff --git a/IRaCIS.Core.Domain/Reading/ReadingTableQuestionAnswer.cs b/IRaCIS.Core.Domain/Reading/ReadingTableQuestionAnswer.cs index 531d911e1..5ceb1f6c2 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingTableQuestionAnswer.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingTableQuestionAnswer.cs @@ -29,7 +29,7 @@ namespace IRaCIS.Core.Domain.Models /// /// 任务Id /// - public Guid TaskId { get; set; } + public Guid VisitTaskId { get; set; } /// /// 项目Id diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 0a7c642c4..4ae6e0008 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -207,7 +207,7 @@ namespace IRaCIS.Core.Infra.EFCore #region Reading public virtual DbSet OrganInfo { get; set; } - + public virtual DbSet ReadingTableAnswerRowInfo { get; set; } public virtual DbSet OrganTrialInfo { get; set; } public virtual DbSet ReadingTableQuestionSystem { get; set; } public virtual DbSet ReadingPeriodSet { get; set; } diff --git a/IRaCIS.Core.Test/DbHelper.ttinclude b/IRaCIS.Core.Test/DbHelper.ttinclude index 5949de3bd..344620e80 100644 --- a/IRaCIS.Core.Test/DbHelper.ttinclude +++ b/IRaCIS.Core.Test/DbHelper.ttinclude @@ -4,7 +4,7 @@ public static readonly string ConnectionString = "Server=123.56.94.154,1433\\MSSQLSERVER;Database=IRaCIS_New_Tet;User ID=sa;Password=dev123456DEV;TrustServerCertificate=true"; public static readonly string DbDatabase = "IRaCIS_New_Tet"; //ַ,ƴ - public static readonly string TableName = "TumorAssessment"; + public static readonly string TableName = "ReadingTableAnswerRowInfo"; //ļ service Ƿҳ } #>