Merge branch 'Test_IRC_Net8' of https://gitea.frp.extimaging.com/XCKJ/irc-netcore-api into Test_IRC_Net8
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
commit
2f2f49c6c7
|
|
@ -31,6 +31,8 @@ public class SegmentationService(IRepository<Segmentation> _segmentationReposito
|
||||||
IRepository<ReadingTableAnswerRowInfo> _readingTableAnswerRowInfoRepository,
|
IRepository<ReadingTableAnswerRowInfo> _readingTableAnswerRowInfoRepository,
|
||||||
IRepository<ReadingTableQuestionAnswer> _readingTableQuestionAnswerRepository,
|
IRepository<ReadingTableQuestionAnswer> _readingTableQuestionAnswerRepository,
|
||||||
IRepository<Segment> _segmentRepository,
|
IRepository<Segment> _segmentRepository,
|
||||||
|
IRepository<ReadingQuestionTrial> _readingQuestionTrialRepository,
|
||||||
|
IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository,
|
||||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService, ISegmentationService
|
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService, ISegmentationService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -347,14 +349,20 @@ public class SegmentationService(IRepository<Segmentation> _segmentationReposito
|
||||||
|
|
||||||
foreach (var binding in bindings)
|
foreach (var binding in bindings)
|
||||||
{
|
{
|
||||||
|
var visited = new HashSet<Guid>();
|
||||||
|
|
||||||
// 处理问题
|
// 处理问题
|
||||||
if (binding.RowId != null && binding.TableQuestionId != null)
|
if (binding.RowId != null && binding.TableQuestionId != null)
|
||||||
{
|
{
|
||||||
await _readingTableQuestionAnswerRepository.DeleteFromQueryAsync(x => x.VisitTaskId == binding.VisitTaskId && x.RowId == binding.RowId && x.TableQuestionId == binding.TableQuestionId);
|
await _readingTableQuestionAnswerRepository.DeleteFromQueryAsync(x => x.VisitTaskId == binding.VisitTaskId && x.RowId == binding.RowId && x.TableQuestionId == binding.TableQuestionId);
|
||||||
|
|
||||||
|
await DeleteDependentAnswersAsync(binding.TableQuestionId.Value, binding.VisitTaskId, binding.RowId, visited);
|
||||||
}
|
}
|
||||||
else if (binding.QuestionId != null)
|
else if (binding.QuestionId != null)
|
||||||
{
|
{
|
||||||
await _readingTaskQuestionAnswerRepository.DeleteFromQueryAsync(x => x.VisitTaskId == binding.VisitTaskId && x.ReadingQuestionTrialId == binding.QuestionId);
|
await _readingTaskQuestionAnswerRepository.DeleteFromQueryAsync(x => x.VisitTaskId == binding.VisitTaskId && x.ReadingQuestionTrialId == binding.QuestionId);
|
||||||
|
|
||||||
|
await DeleteDependentAnswersAsync(binding.QuestionId.Value, binding.VisitTaskId, null, visited);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -369,6 +377,42 @@ public class SegmentationService(IRepository<Segmentation> _segmentationReposito
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 递归清除依赖此问题的计算问题答案
|
||||||
|
/// </summary>
|
||||||
|
private async Task DeleteDependentAnswersAsync(Guid sourceQuestionId, Guid visitTaskId, Guid? rowId, HashSet<Guid> visited)
|
||||||
|
{
|
||||||
|
if (visited.Contains(sourceQuestionId)) return;
|
||||||
|
visited.Add(sourceQuestionId);
|
||||||
|
|
||||||
|
var sourceQuestionIdStr = sourceQuestionId.ToString();
|
||||||
|
|
||||||
|
var dependentTableQuestions = await _readingTableQuestionTrialRepository
|
||||||
|
.Where(x => x.DataSource == DataSources.Automatic && x.Type == "number" && x.CalculateQuestions.Contains(sourceQuestionIdStr))
|
||||||
|
.Select(x => x.Id)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
foreach (var tableQuestionId in dependentTableQuestions)
|
||||||
|
{
|
||||||
|
if (rowId != null)
|
||||||
|
{
|
||||||
|
await _readingTableQuestionAnswerRepository.DeleteFromQueryAsync(x => x.VisitTaskId == visitTaskId && x.RowId == rowId && x.TableQuestionId == tableQuestionId);
|
||||||
|
}
|
||||||
|
await DeleteDependentAnswersAsync(tableQuestionId, visitTaskId, rowId, visited);
|
||||||
|
}
|
||||||
|
|
||||||
|
var dependentTaskQuestions = await _readingQuestionTrialRepository
|
||||||
|
.Where(x => x.DataSource == DataSources.Automatic && x.Type == "number" && x.CalculateQuestions.Contains(sourceQuestionIdStr))
|
||||||
|
.Select(x => x.Id)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
foreach (var taskQuestionId in dependentTaskQuestions)
|
||||||
|
{
|
||||||
|
await _readingTaskQuestionAnswerRepository.DeleteFromQueryAsync(x => x.VisitTaskId == visitTaskId && x.ReadingQuestionTrialId == taskQuestionId);
|
||||||
|
await DeleteDependentAnswersAsync(taskQuestionId, visitTaskId, rowId, visited);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue