Uat_Study
he 2022-08-18 14:18:25 +08:00
parent 81a0a7d02d
commit d461ceaa21
2 changed files with 76 additions and 51 deletions

View File

@ -13,6 +13,8 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
public Guid SourceSystemCriterionId { get; set; } public Guid SourceSystemCriterionId { get; set; }
public Guid NewSystemCriterionId { get; set; } public Guid NewSystemCriterionId { get; set; }
public bool IsCopyQuestion { get; set; }
} }

View File

@ -34,6 +34,7 @@ namespace IRaCIS.Application.Services
private readonly IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository; private readonly IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository;
private readonly IRepository<ReadingCriterionPage> _readingCriterionPageRepository; private readonly IRepository<ReadingCriterionPage> _readingCriterionPageRepository;
private readonly IRepository<Trial> _trialRepository; private readonly IRepository<Trial> _trialRepository;
private readonly IRepository<OrganInfo> _organInfoRepository;
private readonly IRepository<ReadingTableQuestionSystem> _readingTableQuestionSystemRepository; private readonly IRepository<ReadingTableQuestionSystem> _readingTableQuestionSystemRepository;
private readonly IRepository<ReadingTaskQuestionAnswer> _readingTaskQuestionAnswer; private readonly IRepository<ReadingTaskQuestionAnswer> _readingTaskQuestionAnswer;
private readonly IRepository<PreviousPDF> _previousPDFRepository; private readonly IRepository<PreviousPDF> _previousPDFRepository;
@ -47,11 +48,12 @@ namespace IRaCIS.Application.Services
IRepository<ClinicalDataTrialSet> ClinicalDataTrialSetRepository, IRepository<ClinicalDataTrialSet> ClinicalDataTrialSetRepository,
IRepository<ClinicalDataSystemSet> ClinicalDataSystemSetRepository, IRepository<ClinicalDataSystemSet> ClinicalDataSystemSetRepository,
IRepository<Dictionary> dictionaryRepository, IRepository<Dictionary> dictionaryRepository,
IRepository<ReadingTableQuestionTrial> readingTableQuestionTrialRepository, IRepository<ReadingTableQuestionTrial> readingTableQuestionTrialRepository,
IRepository<ReadingCriterionPage> readingCriterionPageRepository, IRepository<ReadingCriterionPage> readingCriterionPageRepository,
IRepository<Trial> trialRepository, IRepository<Trial> trialRepository,
IRepository<ReadingTableQuestionSystem> readingTableQuestionSystemRepository, IRepository<OrganInfo> organInfoRepository,
IRepository<ReadingTaskQuestionAnswer> readingTaskQuestionAnswer, IRepository<ReadingTableQuestionSystem> readingTableQuestionSystemRepository,
IRepository<ReadingTaskQuestionAnswer> readingTaskQuestionAnswer,
IRepository<PreviousPDF> previousPDFRepository IRepository<PreviousPDF> previousPDFRepository
) )
{ {
@ -66,6 +68,7 @@ namespace IRaCIS.Application.Services
this._readingTableQuestionTrialRepository = readingTableQuestionTrialRepository; this._readingTableQuestionTrialRepository = readingTableQuestionTrialRepository;
this._readingCriterionPageRepository = readingCriterionPageRepository; this._readingCriterionPageRepository = readingCriterionPageRepository;
this._trialRepository = trialRepository; this._trialRepository = trialRepository;
this._organInfoRepository = organInfoRepository;
this._readingTableQuestionSystemRepository = readingTableQuestionSystemRepository; this._readingTableQuestionSystemRepository = readingTableQuestionSystemRepository;
this._readingTaskQuestionAnswer = readingTaskQuestionAnswer; this._readingTaskQuestionAnswer = readingTaskQuestionAnswer;
this._previousPDFRepository = previousPDFRepository; this._previousPDFRepository = previousPDFRepository;
@ -79,59 +82,79 @@ namespace IRaCIS.Application.Services
[HttpPost] [HttpPost]
public async Task<IResponseOutput> CopySystemCriterionData(CopySystemCriterionDataInDto inDto) public async Task<IResponseOutput> CopySystemCriterionData(CopySystemCriterionDataInDto inDto)
{ {
var newSystemQuestionList = await _readingQuestionSystemRepository.Where(x => x.ReadingQuestionCriterionSystemId == inDto.SourceSystemCriterionId) if (inDto.IsCopyQuestion)
.ProjectTo<ReadingQuestionSystemData>(_mapper.ConfigurationProvider).ToListAsync();
newSystemQuestionList.ForEach(x =>
{ {
x.Id = NewId.NextGuid(); var newSystemQuestionList = await _readingQuestionSystemRepository.Where(x => x.ReadingQuestionCriterionSystemId == inDto.SourceSystemCriterionId)
x.ReadingQuestionCriterionSystemId = inDto.NewSystemCriterionId; .ProjectTo<ReadingQuestionSystemData>(_mapper.ConfigurationProvider).ToListAsync();
}); newSystemQuestionList.ForEach(x =>
var copyNewQuestionList = newSystemQuestionList.Clone();
var needAddDatas = new List<ReadingQuestionSystemData>();
foreach (var x in newSystemQuestionList)
{
var question = x.Clone();
if (question.ParentId != null)
{ {
question.ParentId = copyNewQuestionList.Where(y => x.ParentId == y.OriginalId).Select(y => y.Id).FirstOrDefault(); x.Id = NewId.NextGuid();
} x.ReadingQuestionCriterionSystemId = inDto.NewSystemCriterionId;
if (question.RelevanceId != null) });
var copyNewQuestionList = newSystemQuestionList.Clone();
var needAddDatas = new List<ReadingQuestionSystemData>();
foreach (var x in newSystemQuestionList)
{ {
question.RelevanceId = copyNewQuestionList.Where(y => x.RelevanceId == y.OriginalId).Select(y => y.Id).FirstOrDefault(); var question = x.Clone();
} if (question.ParentId != null)
needAddDatas.Add(question); {
}; question.ParentId = copyNewQuestionList.Where(y => x.ParentId == y.OriginalId).Select(y => y.Id).FirstOrDefault();
}
if (question.RelevanceId != null)
{
question.RelevanceId = copyNewQuestionList.Where(y => x.RelevanceId == y.OriginalId).Select(y => y.Id).FirstOrDefault();
}
needAddDatas.Add(question);
};
await _readingQuestionSystemRepository.BatchDeleteNoTrackingAsync(x => x.ReadingQuestionCriterionSystemId == inDto.NewSystemCriterionId); await _readingQuestionSystemRepository.BatchDeleteNoTrackingAsync(x => x.ReadingQuestionCriterionSystemId == inDto.NewSystemCriterionId);
await _readingQuestionSystemRepository.AddRangeAsync(needAddDatas); await _readingQuestionSystemRepository.AddRangeAsync(needAddDatas);
#region 表格问题 #region 表格问题
var newSystemTableQuestionList = await _readingTableQuestionSystemRepository.Where(x => x.SystemCriterionId == inDto.SourceSystemCriterionId) var newSystemTableQuestionList = await _readingTableQuestionSystemRepository.Where(x => x.SystemCriterionId == inDto.SourceSystemCriterionId)
.ProjectTo<ReadingTableQuestionSystemData>(_mapper.ConfigurationProvider).ToListAsync(); .ProjectTo<ReadingTableQuestionSystemData>(_mapper.ConfigurationProvider).ToListAsync();
var copeNewSystemTableQuestionList = newSystemTableQuestionList.Clone(); var copeNewSystemTableQuestionList = newSystemTableQuestionList.Clone();
var needAddTableDatas = new List<ReadingTableQuestionSystemData>(); var needAddTableDatas = new List<ReadingTableQuestionSystemData>();
foreach (var x in newSystemTableQuestionList) foreach (var x in newSystemTableQuestionList)
{
var tableQuestion = x.Clone();
tableQuestion.SystemCriterionId =inDto.NewSystemCriterionId;
tableQuestion.Id = NewId.NextGuid();
if (tableQuestion.ParentId != null)
{ {
tableQuestion.ParentId = copeNewSystemTableQuestionList.Where(y => x.ParentId == y.OriginalId).Select(y => y.Id).FirstOrDefault(); var tableQuestion = x.Clone();
tableQuestion.SystemCriterionId = inDto.NewSystemCriterionId;
tableQuestion.Id = NewId.NextGuid();
if (tableQuestion.ParentId != null)
{
tableQuestion.ParentId = copeNewSystemTableQuestionList.Where(y => x.ParentId == y.OriginalId).Select(y => y.Id).FirstOrDefault();
}
if (tableQuestion.RelevanceId != null)
{
tableQuestion.RelevanceId = copeNewSystemTableQuestionList.Where(y => x.RelevanceId == y.OriginalId).Select(y => y.Id).FirstOrDefault();
}
if (tableQuestion.DependParentId != null)
{
tableQuestion.DependParentId = copeNewSystemTableQuestionList.Where(y => x.DependParentId == y.OriginalId).Select(y => y.Id).FirstOrDefault();
}
needAddTableDatas.Add(tableQuestion);
} }
if (tableQuestion.RelevanceId != null) await _readingTableQuestionSystemRepository.BatchDeleteNoTrackingAsync(x => x.SystemCriterionId == inDto.NewSystemCriterionId);
{ await _readingTableQuestionSystemRepository.AddRangeAsync(needAddTableDatas);
tableQuestion.RelevanceId = copeNewSystemTableQuestionList.Where(y => x.RelevanceId == y.OriginalId).Select(y => y.Id).FirstOrDefault(); #endregion
}
if (tableQuestion.DependParentId != null)
{
tableQuestion.DependParentId = copeNewSystemTableQuestionList.Where(y => x.DependParentId == y.OriginalId).Select(y => y.Id).FirstOrDefault();
}
needAddTableDatas.Add(tableQuestion);
} }
await _readingTableQuestionSystemRepository.BatchDeleteNoTrackingAsync(x => x.SystemCriterionId == inDto.NewSystemCriterionId); else
await _readingTableQuestionSystemRepository.AddRangeAsync(needAddTableDatas); {
#endregion var organData = await _organInfoRepository.Where(x => x.SystemCriterionId == inDto.SourceSystemCriterionId).ToListAsync();
organData.ForEach(x => {
x.Id = NewId.NextGuid();
x.SystemCriterionId = inDto.NewSystemCriterionId;
});
await _organInfoRepository.BatchDeleteNoTrackingAsync(x => x.SystemCriterionId == inDto.NewSystemCriterionId);
await _organInfoRepository.AddRangeAsync(organData);
}
await _readingTableQuestionSystemRepository.SaveChangesAsync(); await _readingTableQuestionSystemRepository.SaveChangesAsync();
return ResponseOutput.Ok(); return ResponseOutput.Ok();
} }