add-validation:完整预警规则编辑增加验证

- 多个预警规则项目中检查点轨迹状态不允许重复
This commit is contained in:
hardstylewyl 2025-03-27 15:26:41 +08:00
parent 78cfd9c083
commit 8fff0bf03d

View File

@ -216,9 +216,6 @@ public class CompleteWarningService : ApplicationService
// 构建缺失轨迹状态
List<RequireTrackStatusItem> BuildMissingTrackStatus(CompleteWarningDetailsIndex detail)
{
// return detail.GetMissingTrackStatusIdGroups()
// .Select(g => g.ToDictionary(id => id.ToString(), id => trackStatusDict.GetValueOrDefault(id, GlobalConst.EmptyString)))
// .ToList();
return detail.GetMissingTrackStatusIdGroups()
.Select(g => new RequireTrackStatusItem
{
@ -246,6 +243,13 @@ public class CompleteWarningService : ApplicationService
}
var bos = CompleteWarningRuleItemBO.From(input);
// 同一个主体下,规则项目的检查点不能重复
var checkPointTrackStatusIds = bos.Select(x => x.CheckPointTrackStatusId).ToHashSet();
if (checkPointTrackStatusIds.Count < bos.Count)
{
throw new BusinessException(message: "完整预警规则项目检查点不能重复!");
}
await _completeWarningHandler.HandleEditAsync(rule, bos);
return new UnifyResultDto(true);
}