Compare commits
No commits in common. "27bdc95f6e505b59b525beeb17bdb28fb2a1fc91" and "10f8039b1b5d3847137afc8410e047e7cb4a356a" have entirely different histories.
27bdc95f6e
...
10f8039b1b
|
|
@ -31,8 +31,6 @@ public class SegmentationService(IRepository<Segmentation> _segmentationReposito
|
|||
IRepository<ReadingTableAnswerRowInfo> _readingTableAnswerRowInfoRepository,
|
||||
IRepository<ReadingTableQuestionAnswer> _readingTableQuestionAnswerRepository,
|
||||
IRepository<Segment> _segmentRepository,
|
||||
IRepository<ReadingQuestionTrial> _readingQuestionTrialRepository,
|
||||
IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository,
|
||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService, ISegmentationService
|
||||
{
|
||||
|
||||
|
|
@ -349,20 +347,14 @@ public class SegmentationService(IRepository<Segmentation> _segmentationReposito
|
|||
|
||||
foreach (var binding in bindings)
|
||||
{
|
||||
var visited = new HashSet<Guid>();
|
||||
|
||||
// 处理问题
|
||||
if (binding.RowId != null && binding.TableQuestionId != null)
|
||||
{
|
||||
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)
|
||||
{
|
||||
await _readingTaskQuestionAnswerRepository.DeleteFromQueryAsync(x => x.VisitTaskId == binding.VisitTaskId && x.ReadingQuestionTrialId == binding.QuestionId);
|
||||
|
||||
await DeleteDependentAnswersAsync(binding.QuestionId.Value, binding.VisitTaskId, null, visited);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -377,42 +369,6 @@ 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