diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs index 5e2a335d7..25585215a 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs @@ -1822,6 +1822,61 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto } + public class SetTrialQuestionExportResultInDto + { + public List QuestionList = new List(); + + public List TableQuestionList = new List(); + } + + + public class SetTrialQuestionExport + { + public Guid QuestionId { get; set; } + + public Guid TableQuestionId { get; set; } + + + public List ExportResult { get; set; } + } + + public class GetTrialQuestionExportResultInDto + { + [NotDefault] + public Guid TrialReadingCriterionId { get; set; } + } + + public class GetTrialQuestionExportResultOutDto + { + public List QuestionList = new List(); + + public List DicList = new List(); + } + + public class TrialQuestionExport + { + public Guid QuestionId { get; set; } + + public Guid TableQuestionId { get; set; } + + public string QuestionName { get; set; } + + public List ExportResult { get; set; } + + public int ShowOrder { get; set; } + + public List Children { get; set; } = new List(); + } + + public class TrialQuestionExportDic + { + public int Code { get; set; } + + public string Value { get; set; } + + public string ValueCN { get; set; } + } + public class GetCustomQuestionPreviewInDto { [NotDefault] diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs index 59e746a5e..23d304239 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs @@ -48,7 +48,89 @@ namespace IRaCIS.Core.Application.Service // return (await _iReadingImageTaskService.GetReadingQuestion(inDto.TrialReadingCriterionId, null),true); //} + /// + /// 设置项目问题导出 + /// + /// + /// + [HttpPost] + public async Task SetTrialQuestionExportResult(SetTrialQuestionExportResultInDto inDto) + { + foreach (var item in inDto.QuestionList) + { + var ExportResultStr=JsonConvert.SerializeObject(item.ExportResult); + await _readingQuestionTrialRepository.UpdatePartialFromQueryAsync(x => x.Id == item.QuestionId, x => new ReadingQuestionTrial() + { + ExportResultStr = ExportResultStr + }); + } + + foreach (var item in inDto.TableQuestionList) + { + + var ExportResultStr = JsonConvert.SerializeObject(item.ExportResult); + await _readingTableQuestionTrialRepository.UpdatePartialFromQueryAsync(x => x.Id == item.TableQuestionId, x => new ReadingTableQuestionTrial() + { + ExportResultStr = ExportResultStr + }); + } + + return await _readingTableQuestionTrialRepository.SaveChangesAsync(); + } + + /// + /// 获取项目的导出信息 + /// + /// + /// + [HttpPost] + public async Task GetTrialQuestionExportResult(GetTrialQuestionExportResultInDto inDto) + { + var questionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == inDto.TrialReadingCriterionId) + .OrderBy(x => x.ShowOrder).Select(x => new TrialQuestionExport() + { + QuestionId = x.Id, + QuestionName = _userInfo.IsEn_Us ? x.QuestionEnName : x.QuestionName, + ExportResult = x.ExportResult, + ShowOrder=x.ShowOrder, + + }).ToListAsync(); + + var questionid = questionList.Select(x => x.QuestionId).ToList(); + + var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => questionid.Contains(x.ReadingQuestionId)) + .OrderBy(x => x.ShowOrder).Select(x => new TrialQuestionExport() + { + QuestionId = x.ReadingQuestionId, + TableQuestionId=x.Id, + QuestionName = _userInfo.IsEn_Us ? x.QuestionEnName : x.QuestionName, + ExportResult = x.ExportResult, + ShowOrder=x.ShowOrder, + }).ToListAsync(); + + questionList.ForEach(x => + { + x.Children = tableQuestionList.Where(y => y.QuestionId == x.QuestionId).OrderBy(y => y.ShowOrder).ToList(); + }); + + var dicList = await _dictionaryRepository.Where(x => x.Parent.Code == "ExportResult") + .OrderBy(x => x.ShowOrder) + .Select(x => new TrialQuestionExportDic() + { + + Code = int.Parse(x.Code), + Value = x.Value, + + ValueCN = x.ValueCN + }).ToListAsync(); + + return new GetTrialQuestionExportResultOutDto() + { + DicList = dicList, + QuestionList = questionList + }; + }