diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/QueryTrackPullMappingsInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/QueryTrackPullMappingsInput.cs new file mode 100644 index 00000000..ed0e9da4 --- /dev/null +++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/QueryTrackPullMappingsInput.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SJZY.Track.Application.Contract.Dtos.ProvideServices +{ + /// + /// 查询轨迹推送映射关系入参 + /// + public class QueryTrackPullMappingsInput + { + /// + /// 子系统id + /// + public int SubsystemsId { get; set; } + + /// + /// 客户id + /// + public int CustomerId { get; set; } + } + + /// + /// 查询轨迹推送映射关系返参项 + /// + public class QueryTrackPullMappingsInfo + { + /// + /// 轨迹代码 + /// + public string? Code { get; set; } + + /// + /// 订单类型 + /// + public int OrderType { get; set; } + + /// + /// 服务商轨迹代码 + /// + public string? ServiceCode { get; set; } + + /// + /// 服务商轨迹状态 + /// + public string? Status { get; set; } + + /// + /// 服务商轨迹内容 + /// + public string? Content { get; set; } + + /// + /// 服务商轨迹内容英文 + /// + public string? ContentEn { get; set; } + } +} diff --git a/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj b/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj index 1b129506..7f1f52a3 100644 --- a/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj +++ b/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj @@ -5,7 +5,7 @@ net7.0 True - 7.0.0 + 7.0.1 True diff --git a/src/SJZY.Track.Application/AutoMapper/TrackPushConfigAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackPushConfigAutoMapperProfile.cs new file mode 100644 index 00000000..7cb8ccd2 --- /dev/null +++ b/src/SJZY.Track.Application/AutoMapper/TrackPushConfigAutoMapperProfile.cs @@ -0,0 +1,22 @@ +using AutoMapper; +using SJZY.Track.Application.Contract.Dtos.ProvideServices; +using SJZY.Track.Application.Contract.Dtos.TrackPush; +using SJZY.Track.Domain.Aggregates.TrackPushAggregate; +using SJZY.Track.Domain.Dtos.TrackPush; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SJZY.Track.Application.AutoMapper +{ + public class TrackPushConfigAutoMapperProfile : Profile + { + public TrackPushConfigAutoMapperProfile() + { + CreateMap(MemberList.None); + CreateMap(MemberList.None); + } + } +} diff --git a/src/SJZY.Track.Application/EventHandlers/TrackPushAfterUpdateOrderEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackPushAfterUpdateOrderEventHandler.cs deleted file mode 100644 index a6c65fdd..00000000 --- a/src/SJZY.Track.Application/EventHandlers/TrackPushAfterUpdateOrderEventHandler.cs +++ /dev/null @@ -1,50 +0,0 @@ -using DotNetCore.CAP; -using SJZY.Track.Application.Contract.Dtos.TrackPush; -using SJZY.Track.Domain.Aggregates.OrderAggregate; -using SJZY.Track.Domain.Consts; -using SJZY.Track.Domain.Enums; -using Volo.Abp.DependencyInjection; - -namespace SJZY.Track.Application.EventHandlers; - -public class TrackPushAfterUpdateOrderEventHandler : ITransientDependency, ICapSubscribe -{ - private readonly IOrderRepository _orderRepository; - - public TrackPushAfterUpdateOrderEventHandler(IOrderRepository orderRepository) - { - _orderRepository = orderRepository; - } - - [CapSubscribe(GlobalConst.TrackPushAfterUpdateOrderSubscribe)] - public async Task ConsumerAsync(TrackPushAfterUpdateOrderDto dto) - { - var order = await _orderRepository.GetFirstAsync(x => x.Id == dto.OrderId); - if (order == default) return; - - /* - * 异常:最近一条推送是失败 - */ - if (!dto.IsSuccess) - { - order.QuestionType = (int)TrackProblemType.Error; - order.LatestPushError = dto.Message; - } - else - { - order.QuestionType = (int)TrackProblemType.None; - order.LatestPushError = null; - if (dto.OptionType == OptionType.新增) - { - // tips:只有新增会影响推送进度 - order.LatestPushTrackCode = dto.TrackCode; - order.LatestPushTime = DateTime.Now; - } - } - - await _orderRepository.UpdateColumnAsync(order, x => new - { - x.LatestPushTrackCode, x.QuestionType, x.LatestPushError, x.LatestPushTime - }); - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushConfigService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushConfigService.cs new file mode 100644 index 00000000..4a575526 --- /dev/null +++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushConfigService.cs @@ -0,0 +1,44 @@ +using SJZY.Track.Application.Contract.Dtos.ProvideServices; +using SJZY.Track.Domain.Aggregates.TrackPushAggregate; +using SJZY.Track.Domain.Dtos.TrackPush; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.ObjectMapping; + +namespace SJZY.Track.Application.Services.ProvideServices +{ + /// + /// 轨迹推送配置服务 + /// + [ApiExplorerSettings(GroupName = "提供接口")] + [Route("/ProviderService")] + public class TrackPushConfigService : ApplicationService + { + private readonly ITrackPushConfigRepository _trackPushConfigRepository; + + public TrackPushConfigService( + ITrackPushConfigRepository trackPushConfigRepository + ) + { + _trackPushConfigRepository = trackPushConfigRepository; + } + + /// + /// 查询轨迹推送配置关系 + /// + /// + /// + [HttpPost("Track/QueryTrackPullMappings")] + public async Task QueryTrackPullMappingsAsync(QueryTrackPullMappingsInput input) + { + var vo = ObjectMapper.Map(input); + var result = await _trackPushConfigRepository.QueryTrackPullMappingsAsync(vo); + var output = ObjectMapper.Map, List>(result); + + return new UnifyResultDto(true, output, "操作成功"); + } + } +} diff --git a/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs b/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs index f9f5633a..4e8f5fff 100644 --- a/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs +++ b/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs @@ -84,12 +84,17 @@ namespace SJZY.Track.Application configure.UserName = configuration["RabbitMQ:UserName"]!; configure.Password = configuration["RabbitMQ:Password"]!; configure.Port = configuration.GetValue("RabbitMQ:Port"); + configure.BasicQosOptions = + new RabbitMQOptions.BasicQos(configuration.GetValue("CAP:PrefetchCount")); }); - // options.TopicNamePrefix = "v1"; - options.SucceedMessageExpiredAfter = 6 * 60 * 60; - options.FailedRetryInterval = 60; - options.FailedRetryCount = 3; + options.FailedRetryInterval = configuration.GetValue("CAP:FailedRetryInterval"); + options.FailedRetryCount = configuration.GetValue("CAP:FailedRetryCount"); + options.ConsumerThreadCount = configuration.GetValue("CAP:ConsumerThreadCount"); + options.SucceedMessageExpiredAfter = configuration.GetValue("CAP:SucceedMessageExpiredAfter"); + options.UseDispatchingPerGroup = true; + options.EnableConsumerPrefetch = true; + options.UseDashboard(dashboardOptions => { dashboardOptions.PathBase = System.Diagnostics.Debugger.IsAttached diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs index 641fb386..3983cd7c 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs @@ -35,4 +35,5 @@ public interface ITrackPushConfigRepository : IBasicRepository UpdateContentAsync(Expression> columns, Expression> whereExpression); + Task> QueryTrackPullMappingsAsync(QueryTrackPullMappingsInputVO input); } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackPush/QueryTrackPullMappingsInfoVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPush/QueryTrackPullMappingsInfoVO.cs new file mode 100644 index 00000000..26f7b4a8 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackPush/QueryTrackPullMappingsInfoVO.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SJZY.Track.Domain.Dtos.TrackPush +{ + /// + /// 查询轨迹推送关系入参 + /// + public class QueryTrackPullMappingsInfoVO + { + /// + /// 轨迹代码 + /// + public string? Code { get; set; } + + /// + /// 订单类型 + /// + public int OrderType { get; set; } + + /// + /// 服务商轨迹代码 + /// + public string? ServiceCode { get; set; } + + /// + /// 服务商轨迹状态 + /// + public string? Status { get; set; } + + /// + /// 服务商轨迹内容 + /// + public string? Content { get; set; } + + /// + /// 服务商轨迹内容英文 + /// + public string? ContentEn { get; set; } + } + + /// + /// 查询轨迹推送关系返参项 + /// + public class QueryTrackPullMappingsInputVO + { + /// + /// 子系统id + /// + public int SubsystemsId { get; set; } + + /// + /// 客户id + /// + public int CustomerId { get; set; } + } +} diff --git a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs index 43bbae70..c7e21820 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs @@ -166,4 +166,29 @@ public class TrackPushConfigRepository : BasicRepository, return await Context.Updateable().SetColumns(columns).Where(whereExpression) .ExecuteCommandHasChangeAsync(); } + + /// + /// 查询轨迹推送关系 + /// + /// + /// + public async Task> QueryTrackPullMappingsAsync(QueryTrackPullMappingsInputVO input) + { + var result = await Context.Queryable().LeftJoin((a, b) => a.Id == b.TrackPushConfigId && !b.IsDeleted) + .LeftJoin((a, b, c) => b.TrackContentId == c.Id && !c.IsDeleted) + .Where((a, b, c) => !a.IsDeleted) + .Where((a, b, c) => a.SubSystemId == input.SubsystemsId && a.CustomId == input.CustomerId) + .Select((a, b, c) => new QueryTrackPullMappingsInfoVO + { + Code = c.Code, + OrderType = b.OrderNoType, + ServiceCode = b.TrackContentCodeValue, + Status = b.TrackStatusValue, + Content = b.TrackContentValue, + ContentEn = b.TrackEnContentValue + }) + .ToListAsync(); + + return result; + } } \ No newline at end of file