diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/OrderNoInfo.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/OrderNoInfo.cs index b4283022..eda65e4a 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/OrderNoInfo.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/OrderNoInfo.cs @@ -8,6 +8,7 @@ public class OrderNoInfo /// 订单类型,必填 /// [Required] + [Range(1, int.MaxValue)] public int OrderType { get; set; } /// diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpdateOrderInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpdateOrderInput.cs index a6faf08b..69ad9a0b 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpdateOrderInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpdateOrderInput.cs @@ -1,4 +1,6 @@ -namespace SJZY.Track.Application.Contract.Dtos.ProvideServices; +using System.ComponentModel.DataAnnotations; + +namespace SJZY.Track.Application.Contract.Dtos.ProvideServices; public class UpdateOrderInput : OrderNoInfo { @@ -15,30 +17,38 @@ public class UpdateOrderInput : OrderNoInfo /// /// 目的国家,必填 /// - public string ArrivalCountry { get; set; } + [Required] + [MaxLength(200)] + public string ArrivalCountry { get; set; } = null!; /// /// 起运国家,必填 /// - public string LeaveCountry { get; set; } + [Required] + [MaxLength(200)] + public string LeaveCountry { get; set; } = null!; /// /// 目的城市,必填 /// - public string ArrivalCity { get; set; } + [Required] + [MaxLength(200)] + public string ArrivalCity { get; set; } = null!; /// /// 起运城市,必填 /// - public string LeaveCity { get; set; } + [Required] + [MaxLength(200)] + public string LeaveCity { get; set; } = null!; /// /// 订单模板(传全量) /// - public List Templates { get; set; } = new(); + public List? Templates { get; set; } = new(); /// /// 订单航班信息 /// - public List FlightInfos { get; set; } = new(); + public List? FlightInfos { get; set; } = new(); } \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertOrderInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertOrderInput.cs index f6c7cb78..880c43a5 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertOrderInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertOrderInput.cs @@ -24,7 +24,7 @@ public class OrderTemplateInfo public int? ServiceProviderId { get; set; } } -public class OrderFligthInfo +public class OrderFlightInfo { /// /// 航班号 diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertTrackInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertTrackInput.cs index ef0e67a4..c2c7b4c6 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertTrackInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertTrackInput.cs @@ -1,24 +1,32 @@ -namespace SJZY.Track.Application.Contract.Dtos.ProvideServices; +using System.ComponentModel.DataAnnotations; + +namespace SJZY.Track.Application.Contract.Dtos.ProvideServices; public class UpsertTrackInput : OrderNoInfo { /// /// 轨迹内容代码 /// + [Required] + [MaxLength(50)] public string TrackCode { get; set; } = null!; /// /// 轨迹发生地 /// + [Required] + [MaxLength(200)] public string TrackPlace { get; set; } = null!; /// /// 轨迹发生时间 /// + [Required] public DateTime TrackTime { get; set; } /// /// 轨迹发生时区 /// + [Required] public float TraceTimeZone { get; set; } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/AutoMapper/OrderAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/OrderAutoMapperProfile.cs index d0ead552..f79ef0b8 100644 --- a/src/SJZY.Track.Application/AutoMapper/OrderAutoMapperProfile.cs +++ b/src/SJZY.Track.Application/AutoMapper/OrderAutoMapperProfile.cs @@ -1,10 +1,8 @@ using AutoMapper; -using AutoMapper.Internal.Mappers; using SJZY.Track.Application.Contract.Dtos.ProvideServices; using SJZY.Track.Domain.Aggregates.OrderAggregate; using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate; using SJZY.Track.Domain.Dtos.Order; -using System.Diagnostics; namespace SJZY.Track.Application.AutoMapper; @@ -18,7 +16,7 @@ public class OrderAutoMapperProfile : Profile CreateMap(MemberList.None) .ForMember(dest => dest.ServiceProviderId, opt => opt.MapFrom(m => m.ServiceProviderId ?? 0)) .ForMember(dest => dest.TrackTemplateId, opt => opt.MapFrom(m => m.TemplateId)); - CreateMap(MemberList.None); + CreateMap(MemberList.None); CreateMap(MemberList.None); CreateMap(MemberList.None); diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs index 42c94f23..b05e3f68 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs @@ -43,8 +43,8 @@ public class OrderService : ApplicationService order = ObjectMapper.Map(input); order.SubSystemId = 1; - order.OrderTemplates = ObjectMapper.Map, List>(input.Templates); - order.OrderFlights = ObjectMapper.Map, List>(input.FlightInfos); + order.OrderTemplates = ObjectMapper.Map, List>(input.Templates!); + order.OrderFlights = ObjectMapper.Map, List>(input.FlightInfos!); await _orderRepository.CreateOrderAsync(order); return "创建成功"; @@ -94,6 +94,7 @@ public class OrderService : ApplicationService #endregion #region 轨迹订单列表 + /// /// 获取分页的轨迹订单 /// @@ -108,13 +109,14 @@ public class OrderService : ApplicationService ObjectMapper.Map, UnifyPageResultDto>(pageList); return pageResultDto; } + #endregion private async Task UpdateOrderAsync(UpdateOrderInput input, OrderEntity order) { order = ObjectMapper.Map(input, order); order.OrderTemplates = ObjectMapper.Map, List>(input.Templates); - order.OrderFlights = ObjectMapper.Map, List>(input.FlightInfos); + order.OrderFlights = ObjectMapper.Map, List>(input.FlightInfos); await _orderRepository.UpdateOrderAsync(order); } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs index 47baadb0..df09c551 100644 --- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs +++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs @@ -1,4 +1,5 @@ -using System.Linq.Expressions; +using System; +using System.Linq.Expressions; using Microsoft.Extensions.Localization; using SJZY.Expand.ABP.Core.Localization; using SJZY.Expand.ABP.Core.PublicMethords; @@ -211,18 +212,22 @@ public class TrackPullService : ApplicationService, ITransientDependency { Expression> isContentAnyExp = 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))) throw new BusinessException(message: _stringLocalizer["IsTrackPullContentAny"]); + else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentCodeValue == input.TrackContentCodeValue))) + throw new BusinessException(message: _stringLocalizer["IsTrackPullContentCodeValueAny"]); + else if (!input.TrackStatusValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackStatusValue == input.TrackStatusValue))) + throw new BusinessException(message: _stringLocalizer["IsTrackPullContentStatusValueAny"]); + else if (!input.TrackContentValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentValue == input.TrackContentValue))) + throw new BusinessException(message: _stringLocalizer["IsTrackPullContentValueAny"]); + else if (!input.TrackKeywords.IsNullOrEmpty()) + { + Expression> trackKeywordExp = _ => true; + input.TrackKeywords!.ForEach(item => { trackKeywordExp = trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item)); }); + + if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(trackKeywordExp))) + 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..1b009a95 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,19 @@ 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)); + Expression> isContentAnyExp = x => x.TrackPushConfigId == input.TrackPushConfigId; if (input.Options == OptionTypeNoNull.修改) isContentAnyExp = isContentAnyExp.And(x => x.Id != input.Id); - if (await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp)) + if (await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentId == input.TrackContentId))) throw new BusinessException(message: _stringLocalizer["IsTrackPushContentAny"]); + else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentCodeValue == input.TrackContentCodeValue))) + throw new BusinessException(message: _stringLocalizer["IsTrackPushContentCodeValueAny"]); + else if (!input.TrackStatusValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackStatusValue == input.TrackStatusValue))) + throw new BusinessException(message: _stringLocalizer["IsTrackPushContentStatusValueAny"]); + else if (!input.TrackContentValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentValue == input.TrackContentValue))) + throw new BusinessException(message: _stringLocalizer["IsTrackPushContentValueAny"]); + else if (!input.TrackEnContentValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackEnContentValue == input.TrackEnContentValue))) + 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); }