修改一版
This commit is contained in:
@@ -64,6 +64,8 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||
{
|
||||
[NotDefault]
|
||||
public Guid ReadingQuestionCriterionTrialId { get; set; }
|
||||
|
||||
public Guid? VisitTaskId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -151,6 +153,11 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||
/// </summary>
|
||||
public string TypeValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 答案
|
||||
/// </summary>
|
||||
public string Answer { get; set; }
|
||||
|
||||
public List<GetTrialReadingQuestionOutDto> Childrens { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -150,9 +150,30 @@ namespace IRaCIS.Application.Services
|
||||
[HttpPost]
|
||||
public async Task<List<GetTrialReadingQuestionOutDto>> GetTrialReadingQuestion(GetTrialReadingQuestionInDto inDto)
|
||||
{
|
||||
var qusetionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == inDto.ReadingQuestionCriterionTrialId).OrderBy(x=>x.ShowOrder).ToListAsync();
|
||||
var query= from data in _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId==inDto.ReadingQuestionCriterionTrialId )
|
||||
join questionAnswer in _readingTaskQuestionAnswerRepository.Where(x=>x.VisitTaskId==inDto.VisitTaskId) on data.Id equals questionAnswer.ReadingQuestionTrialId into questionAnswerTemp
|
||||
from leftquestionAnswer in questionAnswerTemp.DefaultIfEmpty()
|
||||
select new GetTrialReadingQuestionOutDto()
|
||||
{
|
||||
ReadingQuestionTrialId=data.Id,
|
||||
ReadingQuestionCriterionTrialId=data.ReadingQuestionCriterionTrialId,
|
||||
TrialId=data.TrialId,
|
||||
Type=data.Type,
|
||||
ParentTriggerValue=data.ParentTriggerValue,
|
||||
GroupName=data.GroupName,
|
||||
QuestionName=data.QuestionName,
|
||||
IsRequired=data.IsRequired,
|
||||
ShowOrder=data.ShowOrder,
|
||||
ParentId=data.ParentId,
|
||||
TypeValue=data.TypeValue,
|
||||
Answer= leftquestionAnswer.Answer
|
||||
};
|
||||
|
||||
List<GetTrialReadingQuestionOutDto> groupList = _mapper.Map<List<GetTrialReadingQuestionOutDto>>(qusetionList.Where(x => x.ParentId == null));
|
||||
var qusetionList =await query.ToListAsync();
|
||||
|
||||
|
||||
|
||||
List<GetTrialReadingQuestionOutDto> groupList = qusetionList.Where(x => x.ParentId == null).ToList();
|
||||
groupList.ForEach(x =>
|
||||
{
|
||||
FindChildQuestion(x, qusetionList);
|
||||
@@ -167,9 +188,9 @@ namespace IRaCIS.Application.Services
|
||||
/// <param name="trialReadingQuestion"></param>
|
||||
/// <param name="questionlists"></param>
|
||||
|
||||
private void FindChildQuestion(GetTrialReadingQuestionOutDto trialReadingQuestion, List<ReadingQuestionTrial> questionlists)
|
||||
private void FindChildQuestion(GetTrialReadingQuestionOutDto trialReadingQuestion, List<GetTrialReadingQuestionOutDto> questionlists)
|
||||
{
|
||||
trialReadingQuestion.Childrens = _mapper.Map<List<GetTrialReadingQuestionOutDto>>(questionlists.Where(x => x.ParentId == trialReadingQuestion.ReadingQuestionTrialId));
|
||||
trialReadingQuestion.Childrens = questionlists.Where(x => x.ParentId == trialReadingQuestion.ReadingQuestionTrialId).ToList();
|
||||
if (trialReadingQuestion.Childrens != null && trialReadingQuestion.Childrens.Count != 0)
|
||||
{
|
||||
trialReadingQuestion.Childrens.ForEach(x =>
|
||||
@@ -179,18 +200,16 @@ namespace IRaCIS.Application.Services
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 提交问题
|
||||
/// 保存任务问题
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[NonDynamicMethod]
|
||||
public async Task<IResponseOutput> SubmitVisitTaskQuestions(SubmitVisitTaskQuestionsInDto inDto)
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> SaveVisitTaskQuestions(SubmitVisitTaskQuestionsInDto inDto)
|
||||
{
|
||||
var subjectId =await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => x.SubjectId).FirstOrDefaultAsync();
|
||||
var subjectId = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => x.SubjectId).FirstOrDefaultAsync();
|
||||
await _readingTaskQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.ReadingQuestionCriterionTrialId == inDto.ReadingQuestionCriterionTrialId);
|
||||
List<ReadingTaskQuestionAnswer> readingTaskAnswerList = inDto.AnswerList.Select(x => new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Id = NewId.NextGuid(),
|
||||
@@ -202,6 +221,26 @@ namespace IRaCIS.Application.Services
|
||||
TrialId = inDto.TrialId
|
||||
}).ToList();
|
||||
await _readingTaskQuestionAnswerRepository.AddRangeAsync(readingTaskAnswerList);
|
||||
|
||||
|
||||
var result = await _visitTaskRepository.SaveChangesAsync();
|
||||
return ResponseOutput.Ok(result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 提交问题
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> SubmitVisitTaskQuestions(SubmitVisitTaskQuestionsInDto inDto)
|
||||
{
|
||||
await this.SaveVisitTaskQuestions(inDto);
|
||||
await _visitTaskRepository.UpdatePartialFromQueryAsync(x => x.Id == inDto.VisitTaskId, x => new VisitTask()
|
||||
{
|
||||
ReadingTaskState = ReadingTaskState.HaveSigned
|
||||
|
||||
Reference in New Issue
Block a user