From 52573a7c1dabba31a417e690a7eef7f493197bde Mon Sep 17 00:00:00 2001 From: hardstylewyl <827778732@qq.com> Date: Mon, 24 Mar 2025 16:55:26 +0800 Subject: [PATCH] =?UTF-8?q?add-validation:=E7=BC=96=E8=BE=91=E8=BF=90?= =?UTF-8?q?=E8=BE=93=E6=97=B6=E6=95=88=E8=A7=84=E5=88=99=E9=85=8D=E7=BD=AE?= =?UTF-8?q?(=E5=85=A8=E9=87=8F)=20=20-=20=E8=A7=84=E5=88=99=E9=97=B4?= =?UTF-8?q?=E8=BD=A8=E8=BF=B9=E7=8A=B6=E6=80=81=E4=B8=8D=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E4=BA=A4=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Warning/ReturnWarningService.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/SJZY.Track.Application/Services/Warning/ReturnWarningService.cs b/src/SJZY.Track.Application/Services/Warning/ReturnWarningService.cs index b109f85e..1a0cee0f 100644 --- a/src/SJZY.Track.Application/Services/Warning/ReturnWarningService.cs +++ b/src/SJZY.Track.Application/Services/Warning/ReturnWarningService.cs @@ -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> sets) + { + var combinedSet = new HashSet(); + var totalElements = 0; + + foreach (var set in sets) + { + totalElements += set.Count; + combinedSet.UnionWith(set); + } + + return combinedSet.Count < totalElements; + } }