Uat_Study
he 2022-08-04 15:21:15 +08:00
parent a39052d750
commit 0957d0b1a0
4 changed files with 98 additions and 14 deletions

View File

@ -7,6 +7,37 @@ using System;
using System.Collections.Generic;
namespace IRaCIS.Core.Application.Contracts
{
/// <summary>
///
/// </summary>
public class QCQuestionViewInDto
{
public Guid? TrialId { get; set; }
}
public class QCQuestionView
{
public Guid Id { get; set; }
public string QuestionName { get; set; } = String.Empty;
public bool IsRequired { get; set; }
public bool IsEnable { get; set; }
public string Type { get; set; } = String.Empty;
public string ParentTriggerValue { get; set; }
public Guid? ParentId { get; set; }
public string TypeValue { get; set; } = String.Empty;
public int ShowOrder { get; set; }
public int? ParentShowOrder { get; set; }
public Guid CreateUserId { get; set; }
public DateTime CreateTime { get; set; }
public DateTime UpdateTime { get; set; }
public Guid UpdateUserId { get; set; }
public List<QCQuestionView> ChildList=new List<QCQuestionView>();
}
/// <summary> QCQuestionConfigureView 列表视图模型 </summary>
public class QCQuestionConfigureView
{

View File

@ -16,13 +16,15 @@ namespace IRaCIS.Core.Application.Contracts
public class QCQuestionConfigureService : BaseService, IQCQuestionService
{
private readonly IRepository<QCQuestion> _qcQuestionRepository;
private readonly IRepository<TrialQCQuestion> _trialQCQuestionRepository;
public QCQuestionConfigureService(IRepository<QCQuestion> qcQuestionRepository)
public QCQuestionConfigureService(IRepository<QCQuestion> qcQuestionRepository,
IRepository<TrialQCQuestion> trialQCQuestionRepository
)
{
_qcQuestionRepository = qcQuestionRepository;
this._trialQCQuestionRepository = trialQCQuestionRepository;
}
@ -39,14 +41,14 @@ namespace IRaCIS.Core.Application.Contracts
var initList = await _qcQuestionRepository
.WhereIf(trialQCQuestionFilterSelect.TypeArray.Count() > 0, t => trialQCQuestionFilterSelect.TypeArray.Contains(t.Type))
.OrderBy(t => t.ShowOrder).Select(x=>new TrialQCQuestionSelect() {
ShowOrder=x.ShowOrder,
Id=x.Id,
ParentId=x.ParentId,
QuestionName=x.QuestionName,
TypeValue=x.TypeValue,
.WhereIf(trialQCQuestionFilterSelect.Id != null, t => t.Id != trialQCQuestionFilterSelect.Id && t.ParentId != trialQCQuestionFilterSelect.Id)
.OrderBy(t => t.ShowOrder).Select(x => new TrialQCQuestionSelect() {
ShowOrder = x.ShowOrder,
Id = x.Id,
ParentId = x.ParentId,
QuestionName = x.QuestionName,
TypeValue = x.TypeValue,
}).ToListAsync();
//父亲的序号肯定要比自己小
@ -92,7 +94,7 @@ namespace IRaCIS.Core.Application.Contracts
var QCQuestionQueryable = _qcQuestionRepository
.WhereIf(!string.IsNullOrWhiteSpace(queryQCQuestionConfigure.QuestionName), t => t.QuestionName.Contains(queryQCQuestionConfigure.QuestionName))
.WhereIf(!string.IsNullOrWhiteSpace(queryQCQuestionConfigure.Type), t => t.Type.Contains(queryQCQuestionConfigure.Type))
.WhereIf(queryQCQuestionConfigure.IsEnable!=null, t => t.IsEnable==queryQCQuestionConfigure.IsEnable)
.WhereIf(queryQCQuestionConfigure.IsEnable != null, t => t.IsEnable == queryQCQuestionConfigure.IsEnable)
.ProjectTo<QCQuestionConfigureView>(_mapper.ConfigurationProvider);
return await QCQuestionQueryable.ToListAsync();
@ -118,5 +120,53 @@ namespace IRaCIS.Core.Application.Contracts
}
/// <summary>
/// 获取问题预览
/// </summary>
/// <param name="inDto"></param>
/// <remarks>
/// 传TrialId为获取项目的
/// 不传为获取系统的
/// </remarks>
/// <returns></returns>
public async Task<List<QCQuestionView>> GetQuestionView(QCQuestionViewInDto inDto)
{
var question = new List<QCQuestionView>();
if (inDto.TrialId== null)
{
question = await _trialQCQuestionRepository.Where(x => x.TrialId == inDto.TrialId).OrderBy(x => x.ShowOrder).ProjectTo<QCQuestionView>(_mapper.ConfigurationProvider).ToListAsync();
}
else
{
question=await _qcQuestionRepository.AsQueryable().OrderBy(x => x.ShowOrder).ProjectTo<QCQuestionView>(_mapper.ConfigurationProvider).ToListAsync();
}
var result = question.Where(x => x.ParentId == null).ToList();
result.ForEach(x => {
GetQuestionChild(x, question);
});
return result;
}
public void GetQuestionChild(QCQuestionView parent, List<QCQuestionView> dataList)
{
parent.ChildList = dataList.Where(x => x.ParentId == parent.Id).ToList();
if (parent.ChildList.Count != 0)
{
parent.ChildList.ForEach(x =>
{
GetQuestionChild(x, dataList);
});
}
}
}
}

View File

@ -79,7 +79,7 @@ namespace IRaCIS.Core.Application.Contracts
var initList = await _trialQcQuestionRepository.Where(t => t.TrialId == trialQCQuestionFilterSelect.TrialId)
.WhereIf(trialQCQuestionFilterSelect.TypeArray.Count() > 0, t => trialQCQuestionFilterSelect.TypeArray.Contains(t.Type))
//.WhereIf(trialQCQuestionFilterSelect.Id != null, t => t.Id != trialQCQuestionFilterSelect.Id /*&& t.ParentId != trialQCQuestionFilterSelect.Id*/)
.WhereIf(trialQCQuestionFilterSelect.Id != null, t => t.Id != trialQCQuestionFilterSelect.Id && t.ParentId != trialQCQuestionFilterSelect.Id)
.OrderBy(t => t.ShowOrder).ProjectTo<TrialQCQuestionSelect>(_mapper.ConfigurationProvider).ToListAsync();
//父亲的序号肯定要比自己小

View File

@ -61,6 +61,9 @@ namespace IRaCIS.Core.Application.Service
CreateMap<TrialQCQuestion, TrialQCQuestionSelect>();
CreateMap<TrialQCQuestion, QCQuestionView>();
CreateMap<QCQuestion, QCQuestionView>();
CreateMap<QCQuestion, QCQuestionConfigureView>()
.ForMember(d => d.ParentShowOrder, u => u.MapFrom(s => s.ParentQuestion.ShowOrder)); ;