add-validation:编辑运输时效规则配置(全量)
- 规则间轨迹状态不允许存在交集
This commit is contained in:
parent
a4c5ad619c
commit
52573a7c1d
@ -213,8 +213,28 @@ public class ReturnWarningService : ApplicationService
|
||||
}
|
||||
|
||||
var bos = ReturnWarningRuleItemBO.From(input);
|
||||
// 要求规则项目中轨迹状态集合不允许存在交集
|
||||
if (CheckForIntersection(bos.Select(x => x.TrackStatusIds).ToList()))
|
||||
{
|
||||
throw new BusinessException("运输预警规则项目间,轨迹状态不允许存在交集!");
|
||||
}
|
||||
|
||||
await _returnWarningHandler.HandleEditAsync(rule, bos);
|
||||
|
||||
return new UnifyResultDto(true);
|
||||
}
|
||||
|
||||
private static bool CheckForIntersection(List<HashSet<int>> sets)
|
||||
{
|
||||
var combinedSet = new HashSet<int>();
|
||||
var totalElements = 0;
|
||||
|
||||
foreach (var set in sets)
|
||||
{
|
||||
totalElements += set.Count;
|
||||
combinedSet.UnionWith(set);
|
||||
}
|
||||
|
||||
return combinedSet.Count < totalElements;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user