diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs index 568141ade..eac8ee38d 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs @@ -660,6 +660,8 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public List BeforeQuestionList { get; set; } + public List AgreeOrNot { get; set; } + public List AfterQuestionList { get; set; } } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs index 3ed900e1a..08447a9c7 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs @@ -1158,11 +1158,25 @@ namespace IRaCIS.Application.Services }).ToList(); - List questionTypes = new List() + x.AgreeOrNot = new List() { - new GetGlobalQuestionType (){GlobalAnswerType=GlobalAnswerType.Reason,QuestionName="原因" }, - new GetGlobalQuestionType (){GlobalAnswerType=GlobalAnswerType.AgreeOrNot,QuestionName="是否同意访视结果" }, + new GlobalQuestionInfo() + { + Answer = globalReadingQuestion.Where(y => y.TaskId == x.VisitTaskId && y.GlobalAnswerType == GlobalAnswerType.AgreeOrNot).Select(x => x.Answer).FirstOrDefault() ?? String.Empty, + QuestionName = "是否同意访视结果", + Type = "input", + GlobalAnswerType=GlobalAnswerType.AgreeOrNot, + + } + + }; + + List questionTypes = new List() + { new GetGlobalQuestionType (){GlobalAnswerType=GlobalAnswerType.UpdateType,QuestionName="评估更新类型" }, + new GetGlobalQuestionType (){GlobalAnswerType=GlobalAnswerType.Reason,QuestionName="原因" }, + //new GetGlobalQuestionType (){GlobalAnswerType=GlobalAnswerType.AgreeOrNot,QuestionName="是否同意访视结果" }, + }; @@ -2129,34 +2143,36 @@ namespace IRaCIS.Application.Services throw new BusinessValidationFailedException($"相同问题传入两次!"); } - var questionInfo = await _readingQuestionTrialRepository.Where(x => x.Id == inDto.QuestionId).FirstNotNullAsync(); - if (questionInfo.MaxQuestionCount!=null) + if (inDto.RowIndex % 1 == 0) { - if (questionInfo.MaxQuestionCount < - ( - (await _readingTableAnswerRowInfoRepository.Where(x => x.RowIndex != inDto.RowIndex && ((x.RowIndex % 1) == 0) && x.VisitTaskId == inDto.VisitTaskId - && x.QuestionId == inDto.QuestionId - ).CountAsync()) + 1)) + var questionInfo = await _readingQuestionTrialRepository.Where(x => x.Id == inDto.QuestionId).FirstNotNullAsync(); + if (questionInfo.MaxQuestionCount != null) { - throw new BusinessValidationFailedException($"当前提交问题最大问题数为{questionInfo.MaxQuestionCount}!"); + if (questionInfo.MaxQuestionCount < + ( + (await _readingTableAnswerRowInfoRepository.Where(x => x.RowIndex != inDto.RowIndex && ((x.RowIndex % 1) == 0) && x.VisitTaskId == inDto.VisitTaskId + && x.QuestionId == inDto.QuestionId + ).CountAsync()) + 1)) + { + throw new BusinessValidationFailedException($"当前提交问题最大问题数为{questionInfo.MaxQuestionCount}!"); + } + } + + + var tableQuestions = await _readingTableQuestionTrialRepository.Where(x => tableQuestionIds.Contains(x.Id) && x.MaxRowCount != null && x.MaxRowCount != 0).ToListAsync(); + + foreach (var item in tableQuestions) + { + var answer = inDto.AnswerList.Where(x => x.TableQuestionId == item.Id).Select(x => x.Answer).FirstOrDefault(); + + var rowCount = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.TableQuestionId == item.Id && ((x.RowIndex % 1) == 0) && x.Answer == answer && x.RowIndex != inDto.RowIndex).CountAsync(); + + if (rowCount > item.MaxRowCount.Value - 1) + { + throw new BusinessValidationFailedException($"问题{item.QuestionName}最大相同问题数为{item.MaxRowCount.Value},当前已存在{rowCount}条!"); + } } } - - - var tableQuestions = await _readingTableQuestionTrialRepository.Where(x => tableQuestionIds.Contains(x.Id) && x.MaxRowCount != null && x.MaxRowCount != 0).ToListAsync(); - - foreach (var item in tableQuestions) - { - var answer = inDto.AnswerList.Where(x => x.TableQuestionId == item.Id).Select(x => x.Answer).FirstOrDefault(); - - var rowCount = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.TableQuestionId == item.Id&& ((x.RowIndex % 1) == 0) && x.Answer == answer && x.RowIndex != inDto.RowIndex).CountAsync(); - - if (rowCount > item.MaxRowCount.Value - 1) - { - throw new BusinessValidationFailedException($"问题{item.QuestionName}最大相同问题数为{item.MaxRowCount.Value},当前已存在{rowCount}条!"); - } - } - var isCurrentTaskAddList = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex).Select(x => x.IsCurrentTaskAdd).ToListAsync(); bool isCurrentTaskAdd = true; if (isCurrentTaskAddList.Count() > 0)