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