From 9d8cdadc9c52dd759238738c9848d453f84f559f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com> Date: Tue, 5 Mar 2024 10:50:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=AE=E9=A2=98=E5=92=8C?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/TrackPull/TrackPullService.cs | 29 +++++++++++-------- .../Services/TrackPush/TrackPushService.cs | 23 ++++++++------- .../GetTrackPushContentDetailOutputVO.cs | 2 +- .../Enums/EnumPropertyEnums.cs | 5 ++++ .../Repositories/TrackPushConfigRepository.cs | 12 +++++--- 5 files changed, 44 insertions(+), 27 deletions(-) diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs index 47baadb0..a562670d 100644 --- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs +++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs @@ -209,20 +209,25 @@ public class TrackPullService : ApplicationService, ITransientDependency [HttpPost("UpdateContent")] public async Task UpdateContentAsync([FromBody] UpdateTrackPullContentInput input) { - Expression> isContentAnyExp = x => x.Id != input.Id && x.TrackPullConfigId == input.TrackPullConfigId; + var isContentAnyExp = Expressionable.Create() + .And(x => x.Id != input.Id && x.TrackPullConfigId == input.TrackPullConfigId); - var trackKeywordExp = Expressionable.Create() - .And(x => x.TrackContentId == input.TrackContentId - || (input.TrackContentCodeValue != null && x.TrackContentCodeValue == input.TrackContentCodeValue) - || (input.TrackStatusValue != null && x.TrackStatusValue == input.TrackStatusValue) - || (input.TrackContentValue != null && x.TrackContentValue == input.TrackContentValue)); - - input.TrackKeywords?.ForEach(item => { trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item)); }); - - isContentAnyExp = isContentAnyExp.And(trackKeywordExp.ToExpression()); - - if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp)) + if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentId == input.TrackContentId).ToExpression())) throw new BusinessException(message: _stringLocalizer["IsTrackPullContentAny"]); + else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentCodeValue == input.TrackContentCodeValue).ToExpression())) + throw new BusinessException(message: _stringLocalizer["IsTrackPullContentCodeValueAny"]); + else if (!input.TrackStatusValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackStatusValue == input.TrackStatusValue).ToExpression())) + throw new BusinessException(message: _stringLocalizer["IsTrackPullContentStatusValueAny"]); + else if (!input.TrackContentValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentValue == input.TrackContentValue).ToExpression())) + throw new BusinessException(message: _stringLocalizer["IsTrackPullContentValueAny"]); + else if (!input.TrackKeywords.IsNullOrEmpty()) + { + var trackKeywordExp = Expressionable.Create(); + input.TrackKeywords!.ForEach(item => { trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item)); }); + + if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(trackKeywordExp.ToExpression()).ToExpression())) + throw new BusinessException(message: _stringLocalizer["IsTrackPullContentKeywordsAny"]); + } var oldTrackPullContentEntity = await _trackPullConfigRepository.GetContentByIdAsync(input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]); diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs index fa106f23..a66a58c0 100644 --- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs +++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs @@ -111,7 +111,7 @@ public class TrackPushService : ApplicationService, ITransientDependency if (input.Options == OptionTypeNoNull.修改) isAnyExp = isAnyExp.And(x => x.Id != input.Id); var trackTemplateIdExp = Expressionable.Create(); - foreach (var trackTemplateId in input.TrackTemplateIds) { trackTemplateIdExp.Or(x => SqlFunc.SplitIn(x.TrackTemplateId, trackTemplateId.ToString())); } + input.TrackTemplateIds?.ForEach(item => { trackTemplateIdExp.Or(x => SqlFunc.SplitIn(x.TrackTemplateId, item.ToString())); }); isAnyExp = isAnyExp.And(trackTemplateIdExp.ToExpression()); @@ -202,17 +202,20 @@ public class TrackPushService : ApplicationService, ITransientDependency { if (input.Options != OptionTypeNoNull.删除) { - Expression> isContentAnyExp = x => - x.TrackPushConfigId == input.TrackPushConfigId - && (x.TrackContentId == input.TrackContentId - || (input.TrackContentCodeValue != null && x.TrackContentCodeValue == input.TrackContentCodeValue) - || (input.TrackStatusValue != null && x.TrackStatusValue == input.TrackStatusValue) - || (input.TrackContentValue != null && x.TrackContentValue == input.TrackContentValue) - || (input.TrackEnContentValue != null && x.TrackEnContentValue == input.TrackEnContentValue)); - if (input.Options == OptionTypeNoNull.修改) isContentAnyExp = isContentAnyExp.And(x => x.Id != input.Id); + var isContentAnyExp = Expressionable.Create() + .And(x => x.TrackPushConfigId == input.TrackPushConfigId); + if (input.Options == OptionTypeNoNull.修改) isContentAnyExp.And(x => x.Id != input.Id); - if (await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp)) + if (await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentId == input.TrackContentId).ToExpression())) throw new BusinessException(message: _stringLocalizer["IsTrackPushContentAny"]); + else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentCodeValue == input.TrackContentCodeValue).ToExpression())) + throw new BusinessException(message: _stringLocalizer["IsTrackPushContentCodeValueAny"]); + else if (!input.TrackStatusValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackStatusValue == input.TrackStatusValue).ToExpression())) + throw new BusinessException(message: _stringLocalizer["IsTrackPushContentStatusValueAny"]); + else if (!input.TrackContentValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentValue == input.TrackContentValue).ToExpression())) + throw new BusinessException(message: _stringLocalizer["IsTrackPushContentValueAny"]); + else if (!input.TrackEnContentValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackEnContentValue == input.TrackEnContentValue).ToExpression())) + throw new BusinessException(message: _stringLocalizer["IsTrackPushEnContentValueAny"]); } switch (input.Options) diff --git a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushContentDetailOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushContentDetailOutputVO.cs index f0980524..ace2b3df 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushContentDetailOutputVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushContentDetailOutputVO.cs @@ -47,7 +47,7 @@ public class GetTrackPushContentDetailOutputVO /// /// 轨迹推送配置id /// - public int TrackPullConfigId { get; set; } + public int TrackPushConfigId { get; set; } /// /// 推送轨迹状态 diff --git a/src/SJZY.Track.Domain/Enums/EnumPropertyEnums.cs b/src/SJZY.Track.Domain/Enums/EnumPropertyEnums.cs index e1c08aaf..a0b74b22 100644 --- a/src/SJZY.Track.Domain/Enums/EnumPropertyEnums.cs +++ b/src/SJZY.Track.Domain/Enums/EnumPropertyEnums.cs @@ -11,4 +11,9 @@ public enum EnumPropertyEnums /// 节点 /// [Description("ServiceNode")] 节点, + + /// + /// 单号类型 + /// + [Description("TrackOrderType")] 单号类型 } \ No newline at end of file diff --git a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs index 2531f141..f6a325fd 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs @@ -1,9 +1,11 @@ -using SJZY.Track.Domain.Aggregates.TrackContentAggregate; +using SJZY.Expand.ABP.Core.PublicMethords; +using SJZY.Track.Domain.Aggregates.TrackContentAggregate; using SJZY.Track.Domain.Aggregates.TrackPullAggregate; using SJZY.Track.Domain.Aggregates.TrackPushAggregate; using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; using SJZY.Track.Domain.Dtos.Common; using SJZY.Track.Domain.Dtos.TrackPush; +using SJZY.Track.Domain.Enums; using SJZY.Track.Domain.VEntities; using SJZY.Track.Repository.VData.Entitys; using System.Linq.Expressions; @@ -44,12 +46,14 @@ public class TrackPushConfigRepository : BasicRepository, { return await Context.Queryable() .InnerJoin((pushContent, trackContent) => pushContent.TrackContentId == trackContent.Id) + .LeftJoin((pushContent, trackContent, enumValue) => enumValue.Property == EnumPropertyEnums.单号类型.GetDescription() && pushContent.OrderNoType == enumValue.Enumkey && !enumValue.IsDeleted) .Where(pushContent => pushContent.TrackPushConfigId == input.TrackPushConfigId) - .OrderBy((pushContent, trackContent) => pushContent.Sort) - .Select((pushContent, trackContent) => new GetTrackPushContentPageOutputVO + .OrderBy(pushContent => pushContent.Sort) + .Select((pushContent, trackContent, enumValue) => new GetTrackPushContentPageOutputVO { Id = pushContent.Id, - Sort = pushContent.Sort + Sort = pushContent.Sort, + OrderNoType = enumValue.Disp }, true) .ToPagedListAsync(input.PageIndex, input.PageSize); }