修改一版
parent
b38239b926
commit
ac998e8e73
|
@ -9,12 +9,56 @@ using System.Threading.Tasks;
|
||||||
namespace IRaCIS.Core.Application.Service.Reading.Dto
|
namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||||
{
|
{
|
||||||
#region 阅片问题
|
#region 阅片问题
|
||||||
|
|
||||||
|
|
||||||
|
public class ReadingReportDto
|
||||||
|
{
|
||||||
|
public Guid Id
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new Guid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Guid QuestionId { get; set; }
|
||||||
|
|
||||||
|
public Guid TableQuestionId { get; set; }
|
||||||
|
|
||||||
|
public int ShowOrder { get; set; }
|
||||||
|
|
||||||
|
public int RowIndex { get; set; }
|
||||||
|
|
||||||
|
public string GroupName { get; set; }
|
||||||
|
|
||||||
|
public string QuestionName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 序号标记
|
||||||
|
/// </summary>
|
||||||
|
public string OrderMark { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public List<TaskQuestionAnswer> Answer { get; set; } = new List<TaskQuestionAnswer>();
|
||||||
|
|
||||||
|
public List<ReadingReportDto> Childrens { get; set; } = new List<ReadingReportDto>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class TaskQuestionAnswer
|
||||||
|
{
|
||||||
|
public string TaskName { get; set; }
|
||||||
|
|
||||||
|
public Guid VisitTaskId { get; set; }
|
||||||
|
|
||||||
|
public string Answer { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class GetReadingReportEvaluationOutDto
|
public class GetReadingReportEvaluationOutDto
|
||||||
{
|
{
|
||||||
public List<VisitTaskInfo> VisitTaskList { get; set; }
|
public List<VisitTaskInfo> VisitTaskList { get; set; }
|
||||||
|
|
||||||
public List<VisitTaskGroupAnswerDto> TaskQuestions { get; set; }
|
public List<ReadingReportDto> TaskQuestions { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VisitTaskGroupAnswerDto
|
public class VisitTaskGroupAnswerDto
|
||||||
|
@ -29,8 +73,6 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||||
{
|
{
|
||||||
public Guid QuestionId { get; set; }
|
public Guid QuestionId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public string QuestionName { get; set; }
|
public string QuestionName { get; set; }
|
||||||
|
|
||||||
public string GroupName { get; set; }
|
public string GroupName { get; set; }
|
||||||
|
|
|
@ -136,7 +136,7 @@ namespace IRaCIS.Application.Services
|
||||||
|
|
||||||
var criterionId = await _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == indto.TrialId && x.IsConfirm).Select(x => x.Id).FirstOrDefaultAsync();
|
var criterionId = await _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == indto.TrialId && x.IsConfirm).Select(x => x.Id).FirstOrDefaultAsync();
|
||||||
var questionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == criterionId).ToListAsync();
|
var questionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == criterionId).ToListAsync();
|
||||||
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == criterionId).ToListAsync();
|
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == criterionId).OrderBy(x=>x.ShowOrder).ToListAsync();
|
||||||
|
|
||||||
|
|
||||||
var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync();
|
var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync();
|
||||||
|
@ -146,7 +146,7 @@ namespace IRaCIS.Application.Services
|
||||||
// 第一级
|
// 第一级
|
||||||
|
|
||||||
#region 构造问题
|
#region 构造问题
|
||||||
List<VisitTaskGroupInfo> questions = questionList.Where(x => x.Type == "group").OrderBy(x => x.ShowOrder).Select(x => new VisitTaskGroupInfo()
|
List<ReadingReportDto> questions = questionList.Where(x => x.Type == "group").OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto()
|
||||||
{
|
{
|
||||||
QuestionId = x.Id,
|
QuestionId = x.Id,
|
||||||
GroupName = x.GroupName,
|
GroupName = x.GroupName,
|
||||||
|
@ -154,88 +154,88 @@ namespace IRaCIS.Application.Services
|
||||||
ShowOrder = x.ShowOrder,
|
ShowOrder = x.ShowOrder,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
|
// 分组
|
||||||
foreach (var item in questions)
|
foreach (var item in questions)
|
||||||
{
|
{
|
||||||
item.QuestionList = questionList.Where(x => x.GroupName == item.GroupName).OrderBy(x => x.ShowOrder).Select(x => new VisitTaskQuestionInfo()
|
item.Childrens = questionList.Where(x => x.GroupName == item.GroupName&&x.Type!= "group").OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto()
|
||||||
{
|
{
|
||||||
GroupName = x.GroupName,
|
GroupName = x.GroupName,
|
||||||
QuestionId = x.Id,
|
QuestionId = x.Id,
|
||||||
QuestionName = x.QuestionName,
|
QuestionName = x.QuestionName,
|
||||||
ShowOrder = x.ShowOrder,
|
ShowOrder = x.ShowOrder,
|
||||||
|
OrderMark=x.OrderMark,
|
||||||
|
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
foreach (var question in item.QuestionList)
|
// 问题
|
||||||
|
foreach (var question in item.Childrens)
|
||||||
{
|
{
|
||||||
question.TableRowQuestionList = new List<VistTaskTableQuestionRowInfo>()
|
|
||||||
{
|
foreach (var task in taskInfoList)
|
||||||
};
|
|
||||||
VistTaskTableQuestionRowInfo questionInfo = new VistTaskTableQuestionRowInfo()
|
|
||||||
{
|
{
|
||||||
|
|
||||||
RowIndex = 0,
|
question.Answer.Add(new TaskQuestionAnswer()
|
||||||
OrderMark = string.Empty,
|
{
|
||||||
TableQuestionList = tableQuestionList.Where(x => x.ReadingQuestionId == question.QuestionId).OrderBy(x => x.ShowOrder).Select(x => new VistTaskTableQuestionInfo()
|
Answer = answers.Where(x => x.VisitTaskId == task.VisitTaskId && x.ReadingQuestionTrialId == question.Id).Select(x => x.Answer).FirstIsNullReturnEmpty(),
|
||||||
|
TaskName = task.TaskName,
|
||||||
|
VisitTaskId = task.VisitTaskId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构造表格行数据
|
||||||
|
var rowIndexs = tableAnswers.Where(x => x.QuestionId == question.QuestionId).Select(x => x.RowIndex).Distinct().OrderBy(x => x).ToList();
|
||||||
|
|
||||||
|
question.Childrens = rowIndexs.Select(x => new ReadingReportDto()
|
||||||
|
{
|
||||||
|
|
||||||
|
QuestionName = question.OrderMark + x.ToString().PadLeft(2, '0'),
|
||||||
|
RowIndex=x,
|
||||||
|
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var row in question.Childrens)
|
||||||
|
{
|
||||||
|
// tableQuestion
|
||||||
|
row.Childrens = tableQuestionList.Select(x => new ReadingReportDto()
|
||||||
{
|
{
|
||||||
Answer = string.Empty,
|
|
||||||
QuestionId = question.QuestionId,
|
|
||||||
TableQuestionId = x.Id,
|
|
||||||
ShowOrder = x.ShowOrder,
|
|
||||||
QuestionName = x.QuestionName,
|
QuestionName = x.QuestionName,
|
||||||
|
QuestionId = x.ReadingQuestionId,
|
||||||
|
TableQuestionId = x.Id,
|
||||||
|
RowIndex = row.RowIndex,
|
||||||
|
ShowOrder = x.ShowOrder,
|
||||||
|
|
||||||
}).ToList()
|
}).ToList();
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
question.TableRowQuestionList.Add(questionInfo);
|
foreach (var tableQuestion in row.Childrens)
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 构造答案
|
|
||||||
|
|
||||||
result.TaskQuestions = new List<VisitTaskGroupAnswerDto>();
|
|
||||||
foreach (var item in taskInfoList)
|
|
||||||
{
|
|
||||||
var itemQuestions = questions.Clone();
|
|
||||||
foreach (var group in itemQuestions)
|
|
||||||
{
|
|
||||||
group.QuestionList.ForEach(x =>
|
|
||||||
{
|
|
||||||
x.Answer = answers.Where(n => n.VisitTaskId == item.VisitTaskId && x.QuestionId == x.QuestionId).Select(x => x.Answer).FirstOrDefault() ?? String.Empty;
|
|
||||||
var tableQuestionAnswers = tableAnswers.Where(n => n.QuestionId == n.QuestionId && n.VisitTaskId == item.VisitTaskId).GroupBy(y => new { y.RowIndex }).Select(y => new
|
|
||||||
{
|
{
|
||||||
RowIndex = y.Key.RowIndex,
|
foreach (var task in taskInfoList)
|
||||||
Answer = y.ToList(),
|
|
||||||
});
|
|
||||||
List<VistTaskTableQuestionRowInfo> questionRowInfos = new List<VistTaskTableQuestionRowInfo>();
|
|
||||||
var answerModel = x.TableRowQuestionList.FirstOrDefault() ?? new VistTaskTableQuestionRowInfo();
|
|
||||||
tableQuestionAnswers.ForEach(y =>
|
|
||||||
{
|
|
||||||
VistTaskTableQuestionRowInfo rowInfo = answerModel.Clone();
|
|
||||||
rowInfo.RowIndex = y.RowIndex;
|
|
||||||
rowInfo.TableQuestionList.ForEach(z =>
|
|
||||||
{
|
{
|
||||||
z.Answer = y.Answer.Where(n => n.TableQuestionId == z.TableQuestionId && n.QuestionId == z.QuestionId).Select(n => n.Answer).FirstOrDefault() ?? String.Empty;
|
|
||||||
|
|
||||||
});
|
tableQuestion.Answer.Add(new TaskQuestionAnswer()
|
||||||
questionRowInfos.Add(rowInfo);
|
{
|
||||||
});
|
Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.TableQuestionId == tableQuestion.QuestionId&&x.RowIndex==tableQuestion.RowIndex&&x.TableQuestionId== tableQuestion.Id).Select(x => x.Answer).FirstIsNullReturnEmpty(),
|
||||||
|
TaskName = task.TaskName,
|
||||||
|
VisitTaskId = task.VisitTaskId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
x.TableRowQuestionList = questionRowInfos;
|
|
||||||
|
}
|
||||||
|
|
||||||
});
|
|
||||||
}
|
};
|
||||||
|
|
||||||
result.TaskQuestions.Add(new VisitTaskGroupAnswerDto() {
|
|
||||||
|
|
||||||
VisitTaskId=item.VisitTaskId,
|
|
||||||
Questions= itemQuestions
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
result.TaskQuestions = questions;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Linq.Dynamic.Core;
|
using System.Linq.Dynamic.Core;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Infrastructure.Extention
|
namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
{
|
{
|
||||||
|
@ -29,6 +30,25 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询字符串 为null 返回string.Empty
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TSource"></typeparam>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string FirstIsNullReturnEmpty(this IEnumerable<string> source)
|
||||||
|
{
|
||||||
|
var result = source.FirstOrDefault();
|
||||||
|
|
||||||
|
if (result == null || result == string.Empty)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue