From ca35a86407eb0cff47873143e2d855c3bd81b7f7 Mon Sep 17 00:00:00 2001 From: hardstylewyl <827778732@qq.com> Date: Thu, 27 Mar 2025 15:55:35 +0800 Subject: [PATCH] =?UTF-8?q?add-validation:=E8=A1=A5=E5=85=85=E8=BF=90?= =?UTF-8?q?=E8=BE=93=E9=A2=84=E8=AD=A6=E8=A7=84=E5=88=99=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=BC=96=E8=BE=91(=E5=85=A8=E9=87=8F)=E6=A0=A1=E9=AA=8C=20=20-?= =?UTF-8?q?=20=E4=B8=8D=E5=90=8C=E9=A1=B9=E7=9B=AE=E9=97=B4=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E5=AD=98=E5=9C=A8=E8=B5=B7=E5=A7=8B=E5=92=8C=E6=88=AA?= =?UTF-8?q?=E6=AD=A2=E9=83=BD=E9=87=8D=E5=A4=8D=E7=9A=84=20=20-=20?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E9=A1=B9=E7=9B=AE=E7=9A=84=E8=B5=B7=E5=A7=8B?= =?UTF-8?q?=E5=92=8C=E6=88=AA=E6=AD=A2=E4=B8=8D=E5=85=81=E8=AE=B8=E9=87=8D?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Warning/TransportWarningService.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/SJZY.Track.Application/Services/Warning/TransportWarningService.cs b/src/SJZY.Track.Application/Services/Warning/TransportWarningService.cs index 46ed5dc3..4040ea2f 100644 --- a/src/SJZY.Track.Application/Services/Warning/TransportWarningService.cs +++ b/src/SJZY.Track.Application/Services/Warning/TransportWarningService.cs @@ -381,6 +381,20 @@ public class TransportWarningService : ApplicationService } var postRuleItems = TransportWarningSceneRuleItemBO.From(input); + + var tuples = postRuleItems.Select(x => (x.StartTrackStatusId, x.EndTrackStatusId)).ToHashSet(); + // 规则项目间不允许出现起始轨迹和截止轨迹都重复的项目 + if (tuples.Count < postRuleItems.Count) + { + throw new BusinessException(message: "不允许出现轨迹状态和终止轨迹状态都重复的规则项目"); + } + + // 起始和截止不能相同 + if (tuples.Any(x => x.StartTrackStatusId == x.EndTrackStatusId)) + { + throw new BusinessException(message: "同一规则项目起始轨迹状态和截止轨迹状态不能相同"); + } + var sceneBo = TransportWarningSceneBO.From(ruleScene); await _transportWarningHandler.HandleEditAsync(rule, sceneBo, postRuleItems);