From 4b46eb92bd4af2ae77ee20269b1a09eef3a4efcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com> Date: Mon, 4 Mar 2024 12:00:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8E=A8=E6=8B=89=E5=81=9A=E4=B8=8D?= =?UTF-8?q?=E4=BA=86=EF=BC=8C=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../appsettings.Development.json | 5 ++ .../Dtos/ProvideServices/RefreshTrackInput.cs | 9 +++ .../Events/UpdateOrderTrackEvent.cs | 5 ++ .../InterfaceRelayTrackRefreshEventHandler.cs | 35 ++++++++++++ .../EventHandlers/TrackUpsertEventHandler.cs | 10 ++-- .../UpdateOrderTrackEventHandler.cs | 7 ++- .../SJZY.Track.Application.csproj | 1 + .../ProvideServices/TrackPullService.cs | 56 +++++++++++++++++++ .../ProvideServices/TrackQueryService.cs | 10 ++-- .../SjzyTrackApplicationModule.cs | 7 +++ .../OrderAggregate/IOrderRepository.cs | 8 +++ .../Aggregates/OrderAggregate/OrderEntity.cs | 6 ++ .../TrackPullContentConfigEntity.cs | 12 ++-- .../Dtos/Order/OrderTemplateVO.cs | 15 +++++ .../Dtos/Order/TrackPullContentConfigVO.cs | 44 +++++++++++++++ src/SJZY.Track.Domain/GlobalConst.cs | 5 ++ .../{ITrackQueries.cs => IProvideQueries.cs} | 10 +++- .../{TrackQueries.cs => ProvideQueries.cs} | 23 +++++++- .../Repositories/OrderRepository.cs | 25 +++++++-- 19 files changed, 267 insertions(+), 26 deletions(-) create mode 100644 src/SJZY.Track.Application.Contract/Dtos/ProvideServices/RefreshTrackInput.cs create mode 100644 src/SJZY.Track.Application/EventHandlers/InterfaceRelayTrackRefreshEventHandler.cs create mode 100644 src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs create mode 100644 src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs create mode 100644 src/SJZY.Track.Domain/Dtos/Order/TrackPullContentConfigVO.cs rename src/SJZY.Track.Domain/Queries/{ITrackQueries.cs => IProvideQueries.cs} (81%) rename src/SJZY.Track.Repository/Queries/{TrackQueries.cs => ProvideQueries.cs} (79%) diff --git a/src/SJZY.Track.Api/appsettings.Development.json b/src/SJZY.Track.Api/appsettings.Development.json index 900166d1..671ae998 100644 --- a/src/SJZY.Track.Api/appsettings.Development.json +++ b/src/SJZY.Track.Api/appsettings.Development.json @@ -68,6 +68,11 @@ "RemoteServices": { "UserCenter": { "BaseUrl": "http://192.168.80.55:5020/" + }, + "InterfaceForward": { + "BaseUrl": "http://192.168.80.55:5041/", //开发环境80.55,测试环境80.57 + "AppKey": "从接口通应用获取", + "AppSecret": "从接口通应用获取" } } } diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/RefreshTrackInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/RefreshTrackInput.cs new file mode 100644 index 00000000..4e6e2955 --- /dev/null +++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/RefreshTrackInput.cs @@ -0,0 +1,9 @@ +namespace SJZY.Track.Application.Contract.Dtos.ProvideServices; + +public class RefreshTrackInput +{ + /// + /// 订单号 + /// + public List OrderNos { get; set; } = new(); +} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Events/UpdateOrderTrackEvent.cs b/src/SJZY.Track.Application.Contract/Events/UpdateOrderTrackEvent.cs index a92678d7..f04cd86c 100644 --- a/src/SJZY.Track.Application.Contract/Events/UpdateOrderTrackEvent.cs +++ b/src/SJZY.Track.Application.Contract/Events/UpdateOrderTrackEvent.cs @@ -31,4 +31,9 @@ public class UpdateOrderTrackEvent /// 轨迹发生时间 /// public DateTime TrackTime { get; set; } + + /// + /// 轨迹时区 + /// + public float TrackTimeZone { get; set; } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/EventHandlers/InterfaceRelayTrackRefreshEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/InterfaceRelayTrackRefreshEventHandler.cs new file mode 100644 index 00000000..099b1b99 --- /dev/null +++ b/src/SJZY.Track.Application/EventHandlers/InterfaceRelayTrackRefreshEventHandler.cs @@ -0,0 +1,35 @@ +using DotNetCore.CAP; +using Newtonsoft.Json; +using SJZY.InterfaceRelay.Application.Contracts; +using SJZY.Track.Application.Contract.Dtos.ProvideServices; +using SJZY.Track.Domain.Aggregates.OrderAggregate; +using SJZY.Track.Domain.Queries; +using Volo.Abp.DependencyInjection; + +namespace SJZY.Track.Application.EventHandlers; + +public class InterfaceRelayTrackRefreshEventHandler : ITransientDependency, ICapSubscribe +{ + private readonly IOrderRepository _orderRepository; + private readonly IProvideQueries _provideQueries; + + public InterfaceRelayTrackRefreshEventHandler(IOrderRepository orderRepository, IProvideQueries provideQueries) + { + _orderRepository = orderRepository; + _provideQueries = provideQueries; + } + + [CapSubscribe(GlobalConst.InterfaceRelayTrackRefreshSubscribe)] + public async Task ConsumerAsync(InterfaceRelayTrackRefreshEvent @event) + { + if (@event.RequestParams is List requestParams) + { + var orderNos = requestParams.Select(x => x.OrderNo).ToList(); + + // tips:attach返回的是服务商id,必有 + var pullContentConfigs = await _provideQueries.GetPullContentConfigsAsync(int.Parse(@event.Attach)); + + // 轨迹清洗入库 + } + } +} \ No newline at end of file diff --git a/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs index 5f8d9466..f354d19b 100644 --- a/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs +++ b/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs @@ -13,18 +13,18 @@ namespace SJZY.Track.Application.EventHandlers; public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe { private readonly IOrderRepository _orderRepository; - private readonly ITrackQueries _trackQueries; + private readonly IProvideQueries _provideQueries; private readonly ITrackDetailsRepository _trackDetailsRepository; private readonly ITrackPushCacheService _trackPushCacheService; private readonly ICapPublisher _capPublisher; public TrackUpsertEventHandler(IOrderRepository orderRepository, ICapPublisher capPublisher, - ITrackQueries trackQueries, ITrackDetailsRepository trackDetailsRepository, + IProvideQueries provideQueries, ITrackDetailsRepository trackDetailsRepository, ITrackPushCacheService trackPushCacheService) { _orderRepository = orderRepository; _capPublisher = capPublisher; - _trackQueries = trackQueries; + _provideQueries = provideQueries; _trackDetailsRepository = trackDetailsRepository; _trackPushCacheService = trackPushCacheService; } @@ -35,7 +35,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe // 不同子系统需要做内容映射 if (@event.UpSubSystemId != @event.SubSystemId) { - var mapCode = await _trackQueries + var mapCode = await _provideQueries .MapTrackContentCodeAsync(@event.UpSubSystemId, @event.SubSystemId, @event.TrackCode); if (mapCode == default) @@ -59,7 +59,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe if (track == default) { // 根据轨迹code在订单模板内容中寻找匹配的 - var trackContent = await _trackQueries.MatchTrackContentAsync(@event.OrderId, @event.TrackCode); + var trackContent = await _provideQueries.MatchTrackContentAsync(@event.OrderId, @event.TrackCode); if (trackContent == default) { //throw new BusinessException(message: $"订单:{@event.OrderNo} 所绑定的模板,没有一条内容可以匹配轨迹代码:{@event.TrackCode}"); diff --git a/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs index b9ec2dd6..dfbafc42 100644 --- a/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs +++ b/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs @@ -21,14 +21,15 @@ public class UpdateOrderTrackEventHandler : ITransientDependency, ICapSubscribe if (order == default) return; if (order.IsCompleted) return; - - if (order.LatestTrackTime > @event.TrackTime) return; - order.LatestTrackContent = @event.TrackContent; order.LatestTrackEnContent = @event.TrackEnContent; order.LatestTrackPlace = @event.TrackPlace; order.LatestTrackTime = @event.TrackTime; + order.LatestTrackTimeZone = @event.TrackTimeZone; if (@event.IsCompleted) order.IsCompleted = true; + else if (order.LatestTrackTime != null && + order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) > + @event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone))) return; await _orderRepository.UpdateColumnAsync(order, x => new { diff --git a/src/SJZY.Track.Application/SJZY.Track.Application.csproj b/src/SJZY.Track.Application/SJZY.Track.Application.csproj index cb744d89..1e027d10 100644 --- a/src/SJZY.Track.Application/SJZY.Track.Application.csproj +++ b/src/SJZY.Track.Application/SJZY.Track.Application.csproj @@ -8,6 +8,7 @@ + diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs new file mode 100644 index 00000000..07dd84d3 --- /dev/null +++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs @@ -0,0 +1,56 @@ +using SJZY.InterfaceRelay.Application.Contracts; +using SJZY.Track.Application.Contract.Dtos.ProvideServices; +using SJZY.Track.Domain.Aggregates.OrderAggregate; +using Volo.Abp.Http.Client.DynamicProxying; + +namespace SJZY.Track.Application.Services.ProvideServices; + +/// +/// 轨迹拉取服务 +/// +[ApiExplorerSettings(GroupName = "提供接口")] +public class TrackPullService : ApplicationService +{ + private readonly IOrderRepository _orderRepository; + private readonly IHttpClientProxy _httpClientProxy; + + public TrackPullService(IOrderRepository orderRepository, + IHttpClientProxy httpClientProxy) + { + _orderRepository = orderRepository; + _httpClientProxy = httpClientProxy; + } + + /// + /// 刷新轨迹 + /// + /// + /// + [HttpPost("Track/Refresh")] + public async Task RefreshTrackAsync(RefreshTrackInput input) + { + if (input.OrderNos.Count == 0) + { + throw new BusinessException(message: "订单号数组不能为空"); + } + + input.OrderNos = input.OrderNos.Distinct().ToList(); + + var orderTemplates = await _orderRepository.GetOrderTemplatesAsync(input.OrderNos); + + foreach (var group in orderTemplates.GroupBy(x => x.ServiceProviderId)) + { + var data = group.Select(x => new OrderNoInfo + { + OrderType = x.OrderType, + OrderNo = x.OrderNo + }).ToList(); + + await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync( + "A012", "yicang", 42, data, GlobalConst.InterfaceRelayTrackRefreshSubscribe + , group.Key.ToString()); + } + + return true; + } +} \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs index 79f0cb2e..02f6d9b0 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs @@ -11,13 +11,13 @@ namespace SJZY.Track.Application.Services.ProvideServices; public class TrackQueryService : ApplicationService { private readonly ITrackDetailsRepository _trackDetailsRepository; - private readonly ITrackQueries _trackQueries; + private readonly IProvideQueries _provideQueries; public TrackQueryService(ITrackDetailsRepository trackDetailsRepository, - ITrackQueries trackQueries) + IProvideQueries provideQueries) { _trackDetailsRepository = trackDetailsRepository; - _trackQueries = trackQueries; + _provideQueries = provideQueries; } /// @@ -75,10 +75,10 @@ public class TrackQueryService : ApplicationService list.ForEach(item => item.TrackDetails.Sort((a, b) => b.Time.CompareTo(a.Time))); break; case SortMethod.ByTemplate: - var orderTemplates = await _trackQueries + var orderTemplates = await _provideQueries .GetOrderTemplateLinksAsync(input.OrderType, input.OrderNos); var distinctTemplateIds = orderTemplates.Select(x => x.TemplateId).Distinct().ToList(); - var templateContent = await _trackQueries.GetOrderedTrackCodesAsync(distinctTemplateIds); + var templateContent = await _provideQueries.GetOrderedTrackCodesAsync(distinctTemplateIds); list.ForEach(item => { var codes = new List(); diff --git a/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs b/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs index 97b9337f..3c9197f2 100644 --- a/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs +++ b/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs @@ -1,4 +1,5 @@ using SJZY.Expand.ABP.Core.Localization; +using SJZY.InterfaceRelay.Application.Contracts; using SJZY.Track.Application.Contract; using SJZY.Track.Application.Localization; using SJZY.UserCenter.Contracts; @@ -21,6 +22,7 @@ namespace SJZY.Track.Application typeof(AbpVirtualFileSystemModule), typeof(AbpHttpClientModule), typeof(SjzyUserCenterHttpApiModule), + typeof(SJZYInterfaceRelayApplicationContractsModule), typeof(SjzyTrackDomainModule), typeof(SjzyTrackApplicationContractModule) )] @@ -58,6 +60,11 @@ namespace SJZY.Track.Application //用户中心 context.Services.AddHttpClientProxies(typeof(SjzyUserCenterHttpApiModule).Assembly, "UserCenter", false); + context.Services.AddHttpClient("InterfaceForward").AddHttpMessageHandler(); + context.Services.AddHttpClientProxy( + remoteServiceConfigurationName: "InterfaceForward", + asDefaultService: false + ); } public override void PreConfigureServices(ServiceConfigurationContext context) diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs index 225605cc..e039c01e 100644 --- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs @@ -59,4 +59,12 @@ public interface IOrderRepository : IBasicRepository Task UnLinkByIdsAsync(List linkIds); #endregion + + + /// + /// 获取订单模板列表 + /// + /// + /// + Task> GetOrderTemplatesAsync(List orderNos); } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs index 88de3765..e21d6a04 100644 --- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs @@ -65,6 +65,12 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot /// [SugarColumn(ColumnName = "LatestTrackTime")] public DateTime? LatestTrackTime { get; set; } + + /// + /// 最新轨迹时区(异步维护) + /// + [SugarColumn(ColumnName = "LatestTrackTimeZone")] + public float? LatestTrackTimeZone { get; set; } /// /// 最新轨迹发生地(异步维护) diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPullContentConfigEntity.cs b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPullContentConfigEntity.cs index 2a9d53ab..13d74a83 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPullContentConfigEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPullContentConfigEntity.cs @@ -16,7 +16,7 @@ public class TrackPullContentConfigEntity : IFullAuditedBasicEntitys, IEntity /// 服务商轨迹代码参数值 /// [SugarColumn(ColumnName = "TrackContentCodeValue")] - public string TrackContentCodeValue { get; set; } + public string? TrackContentCodeValue { get; set; } /// /// 轨迹内容id @@ -28,19 +28,19 @@ public class TrackPullContentConfigEntity : IFullAuditedBasicEntitys, IEntity /// 服务商轨迹内容参数值 /// [SugarColumn(ColumnName = "TrackContentValue")] - public string TrackContentValue { get; set; } + public string? TrackContentValue { get; set; } /// /// 轨迹关键词(正向),多个逗分隔 /// [SugarColumn(ColumnName = "TrackKeyword")] - public string TrackKeyword { get; set; } + public string? TrackKeyword { get; set; } /// /// 轨迹关键词(反向),多个逗分隔 /// [SugarColumn(ColumnName = "TrackKeywordReverse")] - public string TrackKeywordReverse { get; set; } + public string? TrackKeywordReverse { get; set; } /// /// 轨迹发生地参数值(主数据枚举) @@ -58,11 +58,11 @@ public class TrackPullContentConfigEntity : IFullAuditedBasicEntitys, IEntity /// 服务商轨迹状态参数值 /// [SugarColumn(ColumnName = "TrackStatusValue")] - public string TrackStatusValue { get; set; } + public string? TrackStatusValue { get; set; } /// /// 轨迹时区GMT /// [SugarColumn(ColumnName = "TrackTimeZone")] - public double? TrackTimeZone { get; set; } + public float? TrackTimeZone { get; set; } } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs b/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs new file mode 100644 index 00000000..9360db40 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs @@ -0,0 +1,15 @@ +namespace SJZY.Track.Domain.Dtos.Order; + +public class OrderTemplateVO +{ + public string OrderNo { get; set; } = null!; + + /// + /// 订单类型(主数据枚举TrackOrderType) + /// + public int OrderType { get; set; } + + public int TemplateId { get; set; } + + public int ServiceProviderId { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/Order/TrackPullContentConfigVO.cs b/src/SJZY.Track.Domain/Dtos/Order/TrackPullContentConfigVO.cs new file mode 100644 index 00000000..1f82cbe6 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/Order/TrackPullContentConfigVO.cs @@ -0,0 +1,44 @@ +namespace SJZY.Track.Domain.Dtos.Order; + +public class TrackPullContentConfigVO +{ + /// + /// 轨迹内容id + /// + public int TrackContentId { get; set; } + + /// + /// 服务商轨迹代码参数值 + /// + public string? TrackContentCodeValue { get; set; } + + /// + /// 服务商轨迹内容参数值 + /// + public string? TrackContentValue { get; set; } + + /// + /// 轨迹关键词(正向),多个逗分隔 + /// + public string? TrackKeyword { get; set; } + + /// + /// 轨迹关键词(反向),多个逗分隔 + /// + public string? TrackKeywordReverse { get; set; } + + /// + /// 轨迹发生地参数值(主数据枚举) + /// + public int? TrackPlaceValue { get; set; } + + /// + /// 服务商轨迹状态参数值 + /// + public string? TrackStatusValue { get; set; } + + /// + /// 轨迹时区GMT + /// + public double? TrackTimeZone { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/GlobalConst.cs b/src/SJZY.Track.Domain/GlobalConst.cs index fcf3d893..6e2969e0 100644 --- a/src/SJZY.Track.Domain/GlobalConst.cs +++ b/src/SJZY.Track.Domain/GlobalConst.cs @@ -12,6 +12,11 @@ public class GlobalConst /// public const string TrackUpsertSubscribe = "SJZY.Track.TrackUpsert"; + /// + /// 接口通批量轨迹刷新订阅 + /// + public const string InterfaceRelayTrackRefreshSubscribe = "SJZY.Track.TrackRefresh"; + /// /// 轨迹新增/更新后触发更新订单轨迹 mq订阅名称 /// diff --git a/src/SJZY.Track.Domain/Queries/ITrackQueries.cs b/src/SJZY.Track.Domain/Queries/IProvideQueries.cs similarity index 81% rename from src/SJZY.Track.Domain/Queries/ITrackQueries.cs rename to src/SJZY.Track.Domain/Queries/IProvideQueries.cs index 53a9720e..7814e949 100644 --- a/src/SJZY.Track.Domain/Queries/ITrackQueries.cs +++ b/src/SJZY.Track.Domain/Queries/IProvideQueries.cs @@ -1,3 +1,4 @@ +using SJZY.Track.Domain.Aggregates.TrackPullAggregate; using SJZY.Track.Domain.Dtos.Order; using SJZY.Track.Domain.Dtos.TrackDetails; using SJZY.Track.Domain.Dtos.TrackTemplate; @@ -7,7 +8,7 @@ namespace SJZY.Track.Domain.Queries; /// /// 提供接口专用查询 /// -public interface ITrackQueries +public interface IProvideQueries { /// /// 根据订单号,获取订单模板 @@ -40,4 +41,11 @@ public interface ITrackQueries /// /// Task MapTrackContentCodeAsync(int upSubSystemId, int subSystemId, string trackCode); + + /// + /// 获取服务商模板配置 + /// + /// + /// + Task> GetPullContentConfigsAsync(int serviceProviderId); } \ No newline at end of file diff --git a/src/SJZY.Track.Repository/Queries/TrackQueries.cs b/src/SJZY.Track.Repository/Queries/ProvideQueries.cs similarity index 79% rename from src/SJZY.Track.Repository/Queries/TrackQueries.cs rename to src/SJZY.Track.Repository/Queries/ProvideQueries.cs index 814649fe..07daaf0e 100644 --- a/src/SJZY.Track.Repository/Queries/TrackQueries.cs +++ b/src/SJZY.Track.Repository/Queries/ProvideQueries.cs @@ -1,6 +1,7 @@ using SJZY.Track.Domain.Aggregates.OrderAggregate; using SJZY.Track.Domain.Aggregates.TrackContentAggregate; using SJZY.Track.Domain.Aggregates.TrackFlagAggregate; +using SJZY.Track.Domain.Aggregates.TrackPullAggregate; using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; using SJZY.Track.Domain.Dtos.Order; @@ -10,12 +11,12 @@ using SJZY.Track.Domain.Queries; namespace SJZY.Track.Repository.Queries; -public class TrackQueries : ISugarRepository, ITrackQueries, +public class ProvideQueries : ISugarRepository, IProvideQueries, ITransientDependency { public ISqlSugarClient Context { get; set; } - public TrackQueries() + public ProvideQueries() { Context = SqlsugarScopeBasic.GetContextSafely("default"); } @@ -87,4 +88,22 @@ public class TrackQueries : ISugarRepository, ITrackQueries, .Select(x => x.MapTrackContentCode) .FirstAsync(); } + + public async Task> GetPullContentConfigsAsync(int serviceProviderId) + { + return await Context.Queryable() + .LeftJoin((a, b) => a.Id == b.TrackPullConfigId) + .Where(a => a.ServiceProviderId == serviceProviderId) + .Select(x => new TrackPullContentConfigVO + { + TrackContentId = 0, + TrackContentCodeValue = null, + TrackContentValue = null, + TrackKeyword = null, + TrackKeywordReverse = null, + TrackPlaceValue = null, + TrackStatusValue = null, + TrackTimeZone = null + }).ToListAsync(); + } } \ No newline at end of file diff --git a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs index 05c154ff..f8cd7136 100644 --- a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs @@ -56,10 +56,10 @@ public class OrderRepository : BasicRepository, IOrderRepository, I public async Task> GetLinkedOrdersAsync(int orderId) { return await Context.Queryable() - .LeftJoin((a , b) => a.Id == b.OrderId) + .LeftJoin((a, b) => a.Id == b.OrderId) .LeftJoin((a, b, c) => b.LinkOrderId == c.Id) .Where(a => a.Id == orderId) - .Select((a, b,c) => new LinkedOrderVO + .Select((a, b, c) => new LinkedOrderVO { OrderId = c.Id, OrderType = c.OrderType, @@ -109,7 +109,7 @@ public class OrderRepository : BasicRepository, IOrderRepository, I List orderNoList = new List(); if (!input.OrderNos.IsNullOrWhiteSpace()) { - orderNoList = input.OrderNos.Split(new char[] { ',', ',', ':', ':' }).ToList(); + orderNoList = input.OrderNos.Split(new char[] { ',', ',', ':', ':' }).ToList(); } var pageList = await Context.Queryable() @@ -129,7 +129,8 @@ public class OrderRepository : BasicRepository, IOrderRepository, I Id = a.Id, OrderNumber = a.OrderNo, OrderType = a.OrderType, - OrderTypeName = SqlFunc.IF(a.OrderType == 1).Return("干线提单").ElseIF(a.OrderType == 2).Return("小包运单").ElseIF(a.OrderType == 3) + OrderTypeName = SqlFunc.IF(a.OrderType == 1).Return("干线提单").ElseIF(a.OrderType == 2).Return("小包运单") + .ElseIF(a.OrderType == 3) .Return("箱/袋单").ElseIF(a.OrderType == 4).Return("FBA订单").End(""), CustomerShortName = b.Abbreviation, CustomerCode = b.Code, @@ -173,4 +174,20 @@ public class OrderRepository : BasicRepository, IOrderRepository, I } #endregion + + + public async Task> GetOrderTemplatesAsync(List orderNos) + { + return await Context.Queryable() + .LeftJoin((a, b) => a.Id == b.OrderId) + .Where(a => orderNos.Contains(a.OrderNo)) + .Select((a, b) => new OrderTemplateVO + { + OrderNo = a.OrderNo, + OrderType = a.OrderType, + TemplateId = b.TrackTemplateId, + ServiceProviderId = b.ServiceProviderId + }) + .ToListAsync(); + } } \ No newline at end of file From 8e5ffc06521a3a98dfb28cf9377c6eb14bb3f146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com> Date: Mon, 4 Mar 2024 14:51:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EditTrackContentMapInputValidation.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SJZY.Track.Application/Validations/TrackContents/EditTrackContentMapInputValidation.cs b/src/SJZY.Track.Application/Validations/TrackContents/EditTrackContentMapInputValidation.cs index 90a334a9..b4cf3ed8 100644 --- a/src/SJZY.Track.Application/Validations/TrackContents/EditTrackContentMapInputValidation.cs +++ b/src/SJZY.Track.Application/Validations/TrackContents/EditTrackContentMapInputValidation.cs @@ -12,7 +12,7 @@ public class EditTrackContentMapInputValidation : AbstractValidator x.Options).IsInEnum().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum, nameof(EditTrackContentMapInput.Options)]); - //RuleFor(x => x.Id).GreaterThan(0).WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_GreaterThan, nameof(EditTrackContentMapInput.Id), 0]); + RuleFor(x => x.Id).GreaterThan(0).WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_GreaterThan, nameof(EditTrackContentMapInput.Id), 0]); RuleFor(x => x.MapSubSystemId).GreaterThan(0).WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_GreaterThan, nameof(EditTrackContentMapInput.MapSubSystemId), 0]); @@ -22,10 +22,10 @@ public class EditTrackContentMapInputValidation : AbstractValidator x.TrackContentId).GreaterThan(0).WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_GreaterThan, nameof(EditTrackContentMapInput.TrackContentId), 0]); - //When(x => x.Options != OptionTypeNoNull.新增, () => - //{ - // RuleFor(x => x.Id).NotNull().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotNull, nameof(EditTrackContentMapInput.Id)]); - //}); + When(x => x.Options != OptionTypeNoNull.新增, () => + { + RuleFor(x => x.Id).NotNull().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotNull, nameof(EditTrackContentMapInput.Id)]); + }); When(x => x.Options != OptionTypeNoNull.删除, () => { From 5d5c7843b7c87ef1ab40e5d54aedfe2732f351fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com> Date: Mon, 4 Mar 2024 15:05:03 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/TrackPull/TrackPullService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs index f1bc092a..47baadb0 100644 --- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs +++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs @@ -169,7 +169,7 @@ public class TrackPullService : ApplicationService, ITransientDependency await _trackPullConfigRepository.UpdateAsync(oldTrackPullEntity); await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPullParamsEntity); - if (oldTrackPullEntity.TrackTemplateId != input.TrackTemplateId) + if (trackPullContentEntities.Count > 0) { await _trackPullConfigRepository.SoftDeleteContentAsync(x => x.TrackPullConfigId == input.Id); await _trackPullConfigRepository.InsertContentRangeAsync(trackPullContentEntities);