修改
continuous-integration/drone/push Build is passing Details

IRC_NewDev
he 2024-09-03 17:07:31 +08:00
parent a2dd550a72
commit 0a581db6d1
1 changed files with 16 additions and 61 deletions

View File

@ -47,78 +47,33 @@ namespace IRaCIS.Application.Services
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<(GetTrialReadingQuestionPageDto, object)> GetTrialReadingQuestion(GetTrialReadingQuestionInDto inDto)
public async Task<(GetReadingTableQuestionOutDto, object)> GetTrialReadingQuestion(GetTrialReadingQuestionInDto inDto)
{
if (inDto.VisitTaskId != null)
{
//await AddDefaultValueToTask(inDto.VisitTaskId.Value);
}
var result = new GetTrialReadingQuestionPageDto();
var readingTaskState = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => x.ReadingTaskState).FirstOrDefaultAsync();
var qusetionList = await GetReadingAnswerView(inDto.ReadingQuestionCriterionTrialId, inDto.VisitTaskId);
var formType = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == inDto.ReadingQuestionCriterionTrialId).Select(x => x.FormType).FirstOrDefaultAsync();
var groupList = new List<GetTrialReadingQuestionOutDto>();
var qusetionIds = qusetionList.Select(x => x.Id).ToList();
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => qusetionIds.Contains(x.ReadingQuestionId))
.ProjectTo<TableQuestionDataInfo>(_mapper.ConfigurationProvider,x=>new {
isEn_Us=_userInfo.IsEn_Us
}).OrderBy(x => x.ShowOrder).ToListAsync();
if (inDto.FormType != null)
{
formType = inDto.FormType.Value;
}
var tableAnswers = await _readingTableQuestionAnswerRepository
.ProjectTo<ReadingTableQuestionAnswerInfo>(_mapper.ConfigurationProvider)
.Where(x => x.VisitTaskId == inDto.VisitTaskId).ToListAsync();
if (formType == FormType.MultiplePage)
var tableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).ProjectTo<TableAnsweRowInfo>(_mapper.ConfigurationProvider).ToListAsync();
var organIds = tableAnsweRowInfos.Where(x => x.OrganInfoId != null).Select(x => x.OrganInfoId).Distinct().ToList();
var organList = await _organInfoRepository.Where(x => organIds.Contains(x.Id)).ToListAsync();
var result=await GetReadingTableQuestion(new GetReadingTableQuestionOrAnswerInDto()
{
qusetionList = qusetionList.Where(x => x.ReadingCriterionPageId != null).ToList();
var readingCriterionPageIds = qusetionList.OrderBy(x => x.PageShowOrder).Select(x => x.ReadingCriterionPageId).Distinct().ToList();
foreach (var item in readingCriterionPageIds)
{
var newPageQusetionList = qusetionList.Where(x => x.ReadingCriterionPageId == item).ToList();
var firstData = newPageQusetionList.FirstOrDefault();
var page = new GetTrialReadingQuestionOutDto()
{
PageName = firstData!.PageName,
IsPage = true,
IsPublicPage = firstData.IsPublicPage,
};
var pageGroupList = newPageQusetionList.Where(x => x.Type == ReadingQestionType.Group || (x.ParentId == null && x.GroupName.IsNullOrEmpty())).ToList();
pageGroupList.ForEach(x =>
{
this.FindChildQuestion(x, newPageQusetionList, tableQuestionList);
});
TrialReadingCriterionId = inDto.ReadingQuestionCriterionTrialId,
TaskId = inDto.VisitTaskId,
TableAnswers = tableAnswers,
TableAnsweRowInfos = tableAnsweRowInfos,
OrganInfos = organList,
QuestionClassify = null,
page.Childrens = pageGroupList.Where(x => !(x.Type == ReadingQestionType.Group && x.Childrens.Count() == 0)).ToList();
groupList.Add(page);
}
result.PublicPage = groupList.Where(x => x.IsPublicPage!.Value).ToList();
result.MultiPage = groupList.Where(x => !x.IsPublicPage!.Value).ToList();
}
else
{
qusetionList = qusetionList.Where(x => x.ReadingCriterionPageId == null).ToList();
groupList = qusetionList.Where(x => x.Type == ReadingQestionType.Group || (x.ParentId == null && x.GroupId==null)).ToList();
groupList.ForEach(x =>
{
this.FindChildQuestion(x, qusetionList, tableQuestionList);
});
groupList = groupList.Where(x => !(x.Type == ReadingQestionType.Group && x.Childrens.Count() == 0)).ToList();
result.SinglePage = groupList;
}
});
return (result, new