基线配置应用到其他访视
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
40a98048bb
commit
dee6bebcb7
|
|
@ -45,6 +45,12 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||||
public decimal TargetVisitNum { get; set; }
|
public decimal TargetVisitNum { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ApplyBaseLineTrialQuestionVisitJudgeRuleInDto
|
||||||
|
{
|
||||||
|
[NotDefault]
|
||||||
|
public Guid TrialReadingCriterionId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class TrialQuestionVisitJudgeRuleItemDto
|
public class TrialQuestionVisitJudgeRuleItemDto
|
||||||
{
|
{
|
||||||
public Guid ReadingQuestionTrialId { get; set; }
|
public Guid ReadingQuestionTrialId { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -183,6 +183,73 @@ namespace IRaCIS.Core.Application.Service
|
||||||
return ResponseOutput.Result(await _readingQuestionVisitJudgeRuleRepository.SaveChangesAsync());
|
return ResponseOutput.Result(await _readingQuestionVisitJudgeRuleRepository.SaveChangesAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将基线访视(VisitNum = 0)的裁判规则配置应用到其他所有访视。
|
||||||
|
/// 仅复制在基线和目标访视均适用的问题;目标访视不适用的问题保留其已有规则。
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IResponseOutput> ApplyBaseLineTrialQuestionVisitJudgeRule(ApplyBaseLineTrialQuestionVisitJudgeRuleInDto inDto)
|
||||||
|
{
|
||||||
|
var trialCriterion = await _readingQuestionCriterionTrialRepository
|
||||||
|
.Where(x => x.Id == inDto.TrialReadingCriterionId)
|
||||||
|
.FirstNotNullAsync();
|
||||||
|
|
||||||
|
var targetVisitNums = await _visitStageRepository
|
||||||
|
.Where(x => x.TrialId == trialCriterion.TrialId && x.VisitNum != 0)
|
||||||
|
.Select(x => x.VisitNum)
|
||||||
|
.Distinct()
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
// 计划外访视不在 VisitStage 中,也应同步基线规则。
|
||||||
|
targetVisitNums.Add(-1);
|
||||||
|
targetVisitNums = targetVisitNums.Distinct().ToList();
|
||||||
|
|
||||||
|
var rulesToAdd = new List<ReadingQuestionVisitJudgeRule>();
|
||||||
|
foreach (var targetVisitNum in targetVisitNums)
|
||||||
|
{
|
||||||
|
// 仅保留在基线和当前目标访视都显示的问题。
|
||||||
|
var targetQuestionIds = await _readingQuestionTrialRepository
|
||||||
|
.Where(x => x.ReadingQuestionCriterionTrialId == inDto.TrialReadingCriterionId && x.IsJudgeQuestion)
|
||||||
|
.Where(x => x.LimitShow == LimitShow.AllShow
|
||||||
|
|| (x.LimitShow == LimitShow.ExcludeSomeVisits
|
||||||
|
&& !x.ExcludeShowVisitList.Contains(0)
|
||||||
|
&& !x.ExcludeShowVisitList.Contains(targetVisitNum)))
|
||||||
|
.Select(x => x.Id)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
if (targetQuestionIds.Count == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var baseLineRules = await _readingQuestionVisitJudgeRuleRepository
|
||||||
|
.Where(x => x.VisitNum == 0 && targetQuestionIds.Contains(x.ReadingQuestionId))
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
await _readingQuestionVisitJudgeRuleRepository.BatchDeleteNoTrackingAsync(x =>
|
||||||
|
x.VisitNum == targetVisitNum && targetQuestionIds.Contains(x.ReadingQuestionId));
|
||||||
|
|
||||||
|
rulesToAdd.AddRange(baseLineRules.Select(rule => new ReadingQuestionVisitJudgeRule
|
||||||
|
{
|
||||||
|
Id = NewId.NextGuid(),
|
||||||
|
ReadingQuestionId = rule.ReadingQuestionId,
|
||||||
|
VisitNum = targetVisitNum,
|
||||||
|
AnswerGroup = rule.AnswerGroup,
|
||||||
|
AnswerCombination = rule.AnswerCombination,
|
||||||
|
JudgeType = rule.JudgeType,
|
||||||
|
JudgeDifferenceValue = rule.JudgeDifferenceValue,
|
||||||
|
JudgeDifferenceType = rule.JudgeDifferenceType,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rulesToAdd.Count > 0)
|
||||||
|
{
|
||||||
|
await _readingQuestionVisitJudgeRuleRepository.AddRangeAsync(rulesToAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseOutput.Result(await _readingQuestionVisitJudgeRuleRepository.SaveChangesAsync());
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue