From 22ebcda4244f834d7a3c601a4f48472163128dcf Mon Sep 17 00:00:00 2001 From: xiaolipro <2357729423@qq.com> Date: Sun, 15 Sep 2024 11:13:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BE=9B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GetTrackTemplateListInput.cs | 19 ++++ .../Dtos/ProvideServices/RefreshTrackInput.cs | 5 + .../TrackTemplateContentDto.cs | 47 ++++++++ .../Dtos/ProvideServices/UpdateOrderInput.cs | 2 + .../UpdateServiceProviderPullConfigsInput.cs | 18 +++ .../Dtos/TrackPush/TrackPushContentDto.cs | 36 ++++++ .../{ => ProvideServices}/IOrderService.cs | 9 +- .../ProvideServices/ITrackPullService.cs | 14 +++ .../ProvideServices/ITrackPushService.cs | 23 ++++ .../{ => ProvideServices}/ITrackService.cs | 2 +- .../ProvideServices/ITrackTemplateService.cs | 7 ++ .../AutoMapper/OrderAutoMapperProfile.cs | 4 +- .../TrackPushConfigAutoMapperProfile.cs | 5 +- .../TrackTemplateAutoMapperProfile.cs | 7 +- .../OrderPullStatusScanner.cs | 2 +- .../OrderService.PullConfigs.cs | 33 ++++++ .../Services/ProvideServices/OrderService.cs | 32 ++++-- .../ProvideServices/TrackPullService.cs | 5 +- .../ProvideServices/TrackPushService.cs | 21 +++- .../Services/ProvideServices/TrackService.cs | 2 +- .../ProvideServices/TrackTemplateService.cs | 36 ++++++ .../OrderAggregate/IOrderRepository.cs | 9 +- .../Aggregates/OrderAggregate/OrderEntity.cs | 6 + .../OrderAggregate/TrackPullStatus.cs | 8 ++ .../TrackNodeAggregate/TrackNodeEntity.cs | 4 +- .../ITrackPushConfigRepository.cs | 1 + .../ITrackTemplateRepository.cs | 4 +- ...rderPullConfigForServiceProviderInputVo.cs | 34 ++++++ .../TrackPush/GetTrackPushContentListVo.cs | 36 ++++++ .../GetTrackTemplateListInputVo.cs | 19 ++++ .../TrackTemplate/TrackTemplateOutputVo.cs | 57 ++++++++++ .../Queries/IProvideQueries.cs | 3 +- .../Queries/ProvideQueries.cs | 11 +- .../Repositories/OrderRepository.cs | 105 +++++++++++------- .../Repositories/TrackPushConfigRepository.cs | 20 ++++ .../Repositories/TrackTemplateRepository.cs | 49 +++++++- 36 files changed, 619 insertions(+), 76 deletions(-) create mode 100644 src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetTrackTemplateListInput.cs create mode 100644 src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackTemplateContentDto.cs create mode 100644 src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpdateServiceProviderPullConfigsInput.cs create mode 100644 src/SJZY.Track.Application.Contract/Dtos/TrackPush/TrackPushContentDto.cs rename src/SJZY.Track.Application.Contract/Services/{ => ProvideServices}/IOrderService.cs (69%) create mode 100644 src/SJZY.Track.Application.Contract/Services/ProvideServices/ITrackPullService.cs create mode 100644 src/SJZY.Track.Application.Contract/Services/ProvideServices/ITrackPushService.cs rename src/SJZY.Track.Application.Contract/Services/{ => ProvideServices}/ITrackService.cs (93%) create mode 100644 src/SJZY.Track.Application.Contract/Services/ProvideServices/ITrackTemplateService.cs create mode 100644 src/SJZY.Track.Application/Services/ProvideServices/OrderService.PullConfigs.cs create mode 100644 src/SJZY.Track.Application/Services/ProvideServices/TrackTemplateService.cs create mode 100644 src/SJZY.Track.Domain/Dtos/Order/UpdateOrderPullConfigForServiceProviderInputVo.cs create mode 100644 src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushContentListVo.cs create mode 100644 src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateListInputVo.cs create mode 100644 src/SJZY.Track.Domain/Dtos/TrackTemplate/TrackTemplateOutputVo.cs diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetTrackTemplateListInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetTrackTemplateListInput.cs new file mode 100644 index 00000000..269a1a0e --- /dev/null +++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetTrackTemplateListInput.cs @@ -0,0 +1,19 @@ +namespace SJZY.Track.Application.Contract.Dtos.ProvideServices; + +public class GetTrackTemplateListInput +{ + /// + /// 子系统id + /// + public int SubSystemId { get; set; } + + /// + /// 客户id + /// + public int? CustomerId { get; set; } + + /// + /// 模版分类 + /// + public int? TemplateType { get; set; } +} diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/RefreshTrackInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/RefreshTrackInput.cs index 7ac71ffb..6197fe26 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/RefreshTrackInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/RefreshTrackInput.cs @@ -2,6 +2,11 @@ namespace SJZY.Track.Application.Contract.Dtos.ProvideServices; public class RefreshTrackInput { + /// + /// 子系统id + /// + public int SubSystemId { get; set; } + /// /// 订单号 /// diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackTemplateContentDto.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackTemplateContentDto.cs new file mode 100644 index 00000000..5e673fa4 --- /dev/null +++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackTemplateContentDto.cs @@ -0,0 +1,47 @@ +namespace SJZY.Track.Application.Contract.Dtos.ProvideServices; + +public class TrackTemplateOutput +{ + /// + /// 模版名称 + /// + public string TemplateName { get; set; } + + /// + /// 模版code + /// + public string TemplateCode { get; set; } + + /// + /// 模版内容 + /// + public List TemplateContents { get; set; } +} + +public class TemplateContentDto +{ + /// + /// 轨迹code + /// + public string Code { get; set; } + + /// + /// 轨迹内容中文 + /// + public string ContentCn { get; set; } + + /// + /// 轨迹内容中文 + /// + public string ContentEn { get; set; } + + /// + /// 轨迹状态 + /// + public string Status { get; set; } + + /// + /// 轨迹节点 + /// + public string Node { 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 2d6e3115..7db4c7c0 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpdateOrderInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpdateOrderInput.cs @@ -65,6 +65,8 @@ public class UpdateOrderInput : OrderNoInfo /// /// 业务key /// + [Required] + [MaxLength(64)] public string Key { get; set; } /// diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpdateServiceProviderPullConfigsInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpdateServiceProviderPullConfigsInput.cs new file mode 100644 index 00000000..0b4069ed --- /dev/null +++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpdateServiceProviderPullConfigsInput.cs @@ -0,0 +1,18 @@ +using System.ComponentModel.DataAnnotations; + +namespace SJZY.Track.Application.Contract.Dtos.ProvideServices; + +public class UpdateServiceProviderPullConfigsInput : PullConfigInfo +{ + /// + /// 子系统id + /// + [Required] + public int SubSystemId { get; set; } + + /// + /// 业务唯一key + /// + [Required] + public string Key { get; set; } +} diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPush/TrackPushContentDto.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/TrackPushContentDto.cs new file mode 100644 index 00000000..dab24a5e --- /dev/null +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/TrackPushContentDto.cs @@ -0,0 +1,36 @@ +namespace SJZY.Track.Application.Contract.Dtos.TrackPush; + +public class TrackPushContentDto +{ + public int Id { get; set; } + + /// + /// 轨迹代码 + /// + 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/Services/IOrderService.cs b/src/SJZY.Track.Application.Contract/Services/ProvideServices/IOrderService.cs similarity index 69% rename from src/SJZY.Track.Application.Contract/Services/IOrderService.cs rename to src/SJZY.Track.Application.Contract/Services/ProvideServices/IOrderService.cs index f36dc7da..6caf7487 100644 --- a/src/SJZY.Track.Application.Contract/Services/IOrderService.cs +++ b/src/SJZY.Track.Application.Contract/Services/ProvideServices/IOrderService.cs @@ -1,7 +1,7 @@ using SJZY.Track.Application.Contract.Dtos.ProvideServices; using Volo.Abp; -namespace SJZY.Track.Application.Contract.Services; +namespace SJZY.Track.Application.Contract.Services.ProvideServices; public interface IOrderService : IRemoteService { @@ -25,4 +25,11 @@ public interface IOrderService : IRemoteService /// /// Task LinkOrderAsync(LinkOrderInput input); + + /// + /// 修改服务商拉取信息 + /// + /// + /// + public Task UpdateServiceProviderPullConfigsAsync(UpdateServiceProviderPullConfigsInput input); } diff --git a/src/SJZY.Track.Application.Contract/Services/ProvideServices/ITrackPullService.cs b/src/SJZY.Track.Application.Contract/Services/ProvideServices/ITrackPullService.cs new file mode 100644 index 00000000..744f195f --- /dev/null +++ b/src/SJZY.Track.Application.Contract/Services/ProvideServices/ITrackPullService.cs @@ -0,0 +1,14 @@ +using SJZY.Track.Application.Contract.Dtos.ProvideServices; +using Volo.Abp; + +namespace SJZY.Track.Application.Contract.Services.ProvideServices; + +public interface ITrackPullService : IRemoteService +{ + /// + /// 刷新轨迹 + /// + /// + /// + public Task RefreshTrackAsync(RefreshTrackInput input); +} diff --git a/src/SJZY.Track.Application.Contract/Services/ProvideServices/ITrackPushService.cs b/src/SJZY.Track.Application.Contract/Services/ProvideServices/ITrackPushService.cs new file mode 100644 index 00000000..a108aac2 --- /dev/null +++ b/src/SJZY.Track.Application.Contract/Services/ProvideServices/ITrackPushService.cs @@ -0,0 +1,23 @@ +using SJZY.Track.Application.Contract.Dtos.ProvideServices; +using SJZY.Track.Application.Contract.Dtos.TrackPush; +using Volo.Abp; + +namespace SJZY.Track.Application.Contract.Services.ProvideServices; + +public interface ITrackPushService : IRemoteService +{ + /// + /// 推送轨迹 + /// + /// + /// + public Task PushTrackAsync(PushTrackInput input); + + /// + /// 获取轨迹推送内容 + /// + /// + /// 子系统id + /// 客户id + public Task> GetTrackPushContentListAsync(int subSystemId, int customerId); +} diff --git a/src/SJZY.Track.Application.Contract/Services/ITrackService.cs b/src/SJZY.Track.Application.Contract/Services/ProvideServices/ITrackService.cs similarity index 93% rename from src/SJZY.Track.Application.Contract/Services/ITrackService.cs rename to src/SJZY.Track.Application.Contract/Services/ProvideServices/ITrackService.cs index 4d2b26c9..8cafa4b1 100644 --- a/src/SJZY.Track.Application.Contract/Services/ITrackService.cs +++ b/src/SJZY.Track.Application.Contract/Services/ProvideServices/ITrackService.cs @@ -1,7 +1,7 @@ using SJZY.Track.Application.Contract.Dtos.ProvideServices; using Volo.Abp; -namespace SJZY.Track.Application.Contract.Services; +namespace SJZY.Track.Application.Contract.Services.ProvideServices; public interface ITrackService : IRemoteService { diff --git a/src/SJZY.Track.Application.Contract/Services/ProvideServices/ITrackTemplateService.cs b/src/SJZY.Track.Application.Contract/Services/ProvideServices/ITrackTemplateService.cs new file mode 100644 index 00000000..d6e10e87 --- /dev/null +++ b/src/SJZY.Track.Application.Contract/Services/ProvideServices/ITrackTemplateService.cs @@ -0,0 +1,7 @@ +using Volo.Abp; + +namespace SJZY.Track.Application.Contract.Services.ProvideServices; + +public interface ITrackTemplateService : IRemoteService +{ +} diff --git a/src/SJZY.Track.Application/AutoMapper/OrderAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/OrderAutoMapperProfile.cs index 8fc8a9d4..c02103b2 100644 --- a/src/SJZY.Track.Application/AutoMapper/OrderAutoMapperProfile.cs +++ b/src/SJZY.Track.Application/AutoMapper/OrderAutoMapperProfile.cs @@ -15,7 +15,9 @@ public class OrderAutoMapperProfile : Profile { public OrderAutoMapperProfile() { - CreateMap(MemberList.None); + CreateMap(MemberList.None) + .ForMember(dest => dest.BusinessKey, + opt => opt.MapFrom(source => source.Key)); CreateMap(MemberList.None); CreateMap(MemberList.None); diff --git a/src/SJZY.Track.Application/AutoMapper/TrackPushConfigAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackPushConfigAutoMapperProfile.cs index e6f4ad15..f6141b70 100644 --- a/src/SJZY.Track.Application/AutoMapper/TrackPushConfigAutoMapperProfile.cs +++ b/src/SJZY.Track.Application/AutoMapper/TrackPushConfigAutoMapperProfile.cs @@ -1,5 +1,6 @@ -using AutoMapper; +using AutoMapper; using SJZY.Track.Application.Contract.Dtos.ProvideServices; +using SJZY.Track.Application.Contract.Dtos.TrackPush; using SJZY.Track.Domain.Dtos.TrackPush; namespace SJZY.Track.Application.AutoMapper; @@ -10,5 +11,7 @@ public class TrackPushConfigAutoMapperProfile : Profile { CreateMap(MemberList.None); CreateMap(MemberList.None); + + CreateMap(MemberList.None); } } diff --git a/src/SJZY.Track.Application/AutoMapper/TrackTemplateAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackTemplateAutoMapperProfile.cs index bb999c90..850ff421 100644 --- a/src/SJZY.Track.Application/AutoMapper/TrackTemplateAutoMapperProfile.cs +++ b/src/SJZY.Track.Application/AutoMapper/TrackTemplateAutoMapperProfile.cs @@ -1,4 +1,5 @@ -using AutoMapper; +using AutoMapper; +using SJZY.Track.Application.Contract.Dtos.ProvideServices; using SJZY.Track.Application.Contract.Dtos.TrackTemplates; using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; using SJZY.Track.Domain.Dtos.TrackTemplate; @@ -19,5 +20,9 @@ public class TrackTemplateAutoMapperProfile : Profile CreateMap(MemberList.None); CreateMap, UnifyPageResultDto>(MemberList .None); + + CreateMap(MemberList.None); + CreateMap(MemberList.None); + CreateMap(MemberList.None); } } diff --git a/src/SJZY.Track.Application/BackgroundServices/OrderPullStatusScanner.cs b/src/SJZY.Track.Application/BackgroundServices/OrderPullStatusScanner.cs index 8e935e3b..b28ac929 100644 --- a/src/SJZY.Track.Application/BackgroundServices/OrderPullStatusScanner.cs +++ b/src/SJZY.Track.Application/BackgroundServices/OrderPullStatusScanner.cs @@ -22,7 +22,7 @@ public class OrderPullStatusScanner : BackgroundService } // real del - count = await _orderRepository.ClearPullStatus(); + count = await _orderRepository.ClearPullStatusAsync(); LogHelper.Info($"{nameof(OrderPullStatusScanner)}本次扫描删除了{count}条订单拉取状态"); await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken); diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.PullConfigs.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.PullConfigs.cs new file mode 100644 index 00000000..df25b1a5 --- /dev/null +++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.PullConfigs.cs @@ -0,0 +1,33 @@ +using SJZY.Expand.ABP.Core.Logger; +using SJZY.Expand.ABP.Core.PublicMethords; +using SJZY.Track.Application.Contract.Dtos.ProvideServices; +using SJZY.Track.Domain.Dtos.Order; +using SJZY.UserCenter.HttpApi.Services; + +namespace SJZY.Track.Application.Services.ProvideServices; + +public partial class OrderService +{ + /// + /// 修改服务商拉取信息(轻易勿动) + /// + /// + /// + [HttpPost("Order/UpdateServiceProviderPullConfigs")] + public async Task UpdateServiceProviderPullConfigsAsync(UpdateServiceProviderPullConfigsInput input) + { + var orderIds = await _orderRepository.GetArrayAsync( + x => x.SubSystemId == input.SubSystemId && x.BusinessKey == input.Key, + x => x.Id); + var inputVo = ObjectMapper + .Map(input); + inputVo.OrderIds = orderIds; + var cnt = await _orderRepository.UpdateOrderPullConfigForServiceProviderAsync(inputVo); + + LogHelper.Warn( + $"{CurrentUserRequest.CurrentUser.UserId}正在修改服务商拉取信息,本次共计影响了{orderIds.Length}个订单、{cnt}段拉取,请求参数是:{input.ToJson()}", + true); + + return new UnifyResultDto(true); + } +} diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs index dd1a8c78..3df4aa48 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs @@ -1,7 +1,7 @@ using DotNetCore.CAP; using SJZY.Expand.ABP.Core.PublicMethords; using SJZY.Track.Application.Contract.Dtos.ProvideServices; -using SJZY.Track.Application.Contract.Services; +using SJZY.Track.Application.Contract.Services.ProvideServices; using SJZY.Track.Domain.Aggregates.OrderAggregate; using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate; using SJZY.Track.Domain.Queries; @@ -125,16 +125,28 @@ public partial class OrderService : ApplicationService, IOrderService { if (pullConfigInfos == null) return new List(); - return pullConfigInfos.Select(x => new OrderPullStatusEntity + return pullConfigInfos.Select(x => { - ServiceProviderCode = x.ServiceCode, - PullStatus = TrackPullStatus.Init, - StartTrackCode = x.StartCode ?? GlobalConst.EmptyString, - EndTrackCode = x.EndCode ?? GlobalConst.EmptyString, - SilenceBeforeStart = x.SilenceTime, - SilenceAfterEnd = x.StopTime, - StartTime = GlobalConst.MaxDateTime, - EndTime = GlobalConst.MaxDateTime, + var status = new OrderPullStatusEntity + { + ServiceProviderCode = x.ServiceCode, + PullStatus = TrackPullStatus.Init, + StartTrackCode = x.StartCode ?? GlobalConst.EmptyString, + EndTrackCode = x.EndCode ?? GlobalConst.EmptyString, + SilenceBeforeStart = x.SilenceTime, + SilenceAfterEnd = x.StopTime, + StartTime = GlobalConst.MaxDateTime, + EndTime = GlobalConst.MaxDateTime, + }; + + // 没有开始轨迹则立即进入拉取前静默期 + if (x.StartCode == null) + { + status.PullStatus = TrackPullStatus.SilenceBeforeStart; // 会被定时任务扫描到并启动 + status.StartTime = DateTime.Now.AddHours(x.SilenceTime); + } + + return status; }).ToList(); } } diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs index 59d127e5..5c6ef940 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs @@ -6,6 +6,7 @@ using SJZY.InterfaceRelay.Application.Contracts; using SJZY.Track.Application.Contract.Dtos.ProvideServices; using SJZY.Track.Application.Contract.Dtos.TrackPull; using SJZY.Track.Application.Contract.Services; +using SJZY.Track.Application.Contract.Services.ProvideServices; using SJZY.Track.Application.Helpers; using SJZY.Track.Application.Rabbit; using SJZY.Track.Application.Track2InterfaceRelay; @@ -20,7 +21,7 @@ namespace SJZY.Track.Application.Services.ProvideServices; /// [ApiExplorerSettings(GroupName = "提供接口")] [Route("/ProviderService")] -public class TrackPullService : ApplicationService +public class TrackPullService : ApplicationService, ITrackPullService { private readonly IHttpClientProxy _httpClientProxy; private readonly IProvideQueries _provideQueries; @@ -47,7 +48,7 @@ public class TrackPullService : ApplicationService input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空 // tips:这里没有区分订单类型,就算的不同类型的单一起刷新了也无所谓 - var orders = await _provideQueries.FindOrderWithServiceProviderAsync(input.OrderNos); + var orders = await _provideQueries.FindOrderWithServiceProviderAsync(input.SubSystemId, input.OrderNos); if (orders.Count == 0) { diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs index 2d5c9605..bf4f95ff 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs @@ -3,9 +3,12 @@ using Microsoft.AspNetCore.Authorization; using SJZY.Expand.ABP.Core; using SJZY.Expand.ABP.Core.Logger; using SJZY.Track.Application.Contract.Dtos.ProvideServices; +using SJZY.Track.Application.Contract.Dtos.TrackPush; using SJZY.Track.Application.Contract.Events; +using SJZY.Track.Application.Contract.Services.ProvideServices; using SJZY.Track.Domain.Aggregates.OrderAggregate; using SJZY.Track.Domain.Aggregates.TrackPushAggregate; +using SJZY.Track.Domain.Dtos.TrackPush; using SJZY.UserCenter.HttpApi.Services; using Volo.Abp.Http.Client.DynamicProxying; @@ -16,22 +19,25 @@ namespace SJZY.Track.Application.Services.ProvideServices; /// [ApiExplorerSettings(GroupName = "提供接口")] [Route("/ProviderService")] -public class TrackPushService : ApplicationService +public class TrackPushService : ApplicationService, ITrackPushService { private readonly ICapPublisher _capPublisher; private readonly IOrderRepository _orderRepository; private readonly IHttpClientProxy _requestCurrentUserService; + private readonly ITrackPushConfigRepository _trackPushConfigRepository; private readonly ITrackPushRecordEsRepository _trackPushRecordEsRepository; public TrackPushService(IOrderRepository orderRepository , ICapPublisher capPublisher - , ITrackPushRecordEsRepository trackPushRecordEsRepository, - IHttpClientProxy requestCurrentUserService) + , ITrackPushRecordEsRepository trackPushRecordEsRepository + , IHttpClientProxy requestCurrentUserService + , ITrackPushConfigRepository trackPushConfigRepository) { _orderRepository = orderRepository; _capPublisher = capPublisher; _trackPushRecordEsRepository = trackPushRecordEsRepository; _requestCurrentUserService = requestCurrentUserService; + _trackPushConfigRepository = trackPushConfigRepository; } /// @@ -84,6 +90,15 @@ public class TrackPushService : ApplicationService return $"即将推送轨迹代码{input.TrackCode}给{orders.Length}个订单"; } + public async Task> GetTrackPushContentListAsync(int subSystemId, int customerId) + { + var list = await _trackPushConfigRepository.GetTrackPushContentListAsync(subSystemId, customerId); + + var result = ObjectMapper.Map, List>(list); + + return result; + } + /// /// 定时任务推送预警(》12小时没有推送的) diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs index faa4a04d..f5f42198 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs @@ -1,7 +1,7 @@ using DotNetCore.CAP; using SJZY.Track.Application.Contract.Dtos.ProvideServices; using SJZY.Track.Application.Contract.Events; -using SJZY.Track.Application.Contract.Services; +using SJZY.Track.Application.Contract.Services.ProvideServices; using SJZY.Track.Domain.Aggregates.OrderAggregate; using SJZY.Track.Domain.Aggregates.TrackContentAggregate; using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate; diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackTemplateService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackTemplateService.cs new file mode 100644 index 00000000..838f0397 --- /dev/null +++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackTemplateService.cs @@ -0,0 +1,36 @@ +using SJZY.Track.Application.Contract.Dtos.ProvideServices; +using SJZY.Track.Application.Contract.Services.ProvideServices; +using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; +using SJZY.Track.Domain.Dtos.TrackTemplate; + +namespace SJZY.Track.Application.Services.ProvideServices; + +/// +/// 轨迹模版服务 +/// +[ApiExplorerSettings(GroupName = "提供接口")] +[Route("/ProviderService")] +public class TrackTemplateService : ApplicationService, ITrackTemplateService +{ + private readonly ITrackTemplateRepository _trackTemplateRepository; + + public TrackTemplateService(ITrackTemplateRepository trackTemplateRepository) + { + _trackTemplateRepository = trackTemplateRepository; + } + + /// + /// 获取轨迹模版列表 + /// + /// + /// + /// + [HttpPost("Template/GetTrackTemplateList")] + public async Task> GetTrackTemplateListAsync(GetTrackTemplateListInput input) + { + var inputVo = ObjectMapper.Map(input); + var templates = await _trackTemplateRepository.GetTrackTemplateListAsync(inputVo); + var res = ObjectMapper.Map, List>(templates); + return res; + } +} diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs index f3717861..5747b6eb 100644 --- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs @@ -100,7 +100,14 @@ public interface IOrderRepository : IBasicRepository /// 清理拉取状态 /// /// - Task ClearPullStatus(); + Task ClearPullStatusAsync(); + + /// + /// 更新订单拉取配置,根据服务商 + /// + /// + /// + Task UpdateOrderPullConfigForServiceProviderAsync(UpdateOrderPullConfigForServiceProviderInputVo inputVo); #endregion } diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs index 9a24699e..b582c174 100644 --- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs @@ -168,6 +168,12 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot [SugarColumn(ColumnName = "ArrivalProvince")] public string? ArrivalProvince { get; set; } + /// + /// 业务key(用于区分轨迹拉取配置) + /// + [SugarColumn(ColumnName = "BusinessKey")] + public string BusinessKey { get; set; } + [SugarColumn(IsIgnore = true)] public List OrderFlights { get; set; } [SugarColumn(IsIgnore = true)] public List OrderPullStatus { get; set; } diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/TrackPullStatus.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/TrackPullStatus.cs index 8054353e..6c1ef506 100644 --- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/TrackPullStatus.cs +++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/TrackPullStatus.cs @@ -1,5 +1,13 @@ namespace SJZY.Track.Domain.Aggregates.OrderAggregate; +/* + * 订单轨迹拉取状态: + * 【0初始态,表示订单数据刚刚录入】【1开始前的静默】【2拉取中】【3结束后的静默】【4拉取完成】 + 1.轨迹发生时,将init状态改为silenceBeforeStart,将pulling改为silenceAfterEnd(状态计算及时计算) + 2.定时任务扫描,将符合开始结束的范围订单筛选出来,去拉取轨迹(轨迹拉取最小延迟30min) + 3.定时任务扫描,将silenceBeforeStart改为pulling,将silenceAfterEnd改为completed(状态计算最小延迟1min) + 4.定时任务扫描,将已经拉取完成的订单拉取删除,将开启了30天的订单拉取删除(清理最小延迟1min) + */ public enum TrackPullStatus { /// diff --git a/src/SJZY.Track.Domain/Aggregates/TrackNodeAggregate/TrackNodeEntity.cs b/src/SJZY.Track.Domain/Aggregates/TrackNodeAggregate/TrackNodeEntity.cs index cde19582..2e9432f8 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackNodeAggregate/TrackNodeEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackNodeAggregate/TrackNodeEntity.cs @@ -22,11 +22,11 @@ public class TrackNodeEntity : IFullAuditedBasicEntitys, IAggregateRoot /// 节点名称 /// [SugarColumn(ColumnName = "NodeName", Length = 32, ColumnDescription = "节点名称")] - public string? NodeName { get; set; } + public string NodeName { get; set; } /// /// 节点英文名称 /// [SugarColumn(ColumnName = "NodeEnName", Length = 32, ColumnDescription = "节点英文名称")] - public string? NodeEnName { get; set; } + public string NodeEnName { get; set; } } diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs index 49c8434f..ab97e52f 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs @@ -37,4 +37,5 @@ public interface ITrackPushConfigRepository : IBasicRepository> whereExpression); Task> QueryTrackPullMappingsAsync(QueryTrackPullMappingsInputVO input); + Task> GetTrackPushContentListAsync(int subSystemId, int customerId); } diff --git a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs index 20398c5f..8a104c3c 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs @@ -1,4 +1,4 @@ -using SJZY.Track.Domain.Dtos.TrackTemplate; +using SJZY.Track.Domain.Dtos.TrackTemplate; namespace SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; @@ -43,4 +43,6 @@ public interface ITrackTemplateRepository : IBasicRepository UpdateContentAsync(Expression> columns, Expression> whereExpression); + + Task> GetTrackTemplateListAsync(GetTrackTemplateListInputVo input); } diff --git a/src/SJZY.Track.Domain/Dtos/Order/UpdateOrderPullConfigForServiceProviderInputVo.cs b/src/SJZY.Track.Domain/Dtos/Order/UpdateOrderPullConfigForServiceProviderInputVo.cs new file mode 100644 index 00000000..cc601f12 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/Order/UpdateOrderPullConfigForServiceProviderInputVo.cs @@ -0,0 +1,34 @@ +namespace SJZY.Track.Domain.Dtos.Order; + +public class UpdateOrderPullConfigForServiceProviderInputVo +{ + /// + /// 订单id + /// + public int[] OrderIds { get; set; } + + /// + /// 服务商code + /// + public string ServiceCode { get; set; } + + /// + /// 开始轨迹code + /// + public string? StartCode { get; set; } + + /// + /// 结束轨迹code + /// + public string? EndCode { get; set; } + + /// + /// 静默多久后拉取(小时) + /// + public int SilenceTime { get; set; } + + /// + /// 结束多久后停止拉取(小时) + /// + public int StopTime { get; set; } +} diff --git a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushContentListVo.cs b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushContentListVo.cs new file mode 100644 index 00000000..f2261703 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushContentListVo.cs @@ -0,0 +1,36 @@ +namespace SJZY.Track.Domain.Dtos.TrackPush; + +public class GetTrackPushContentListVo +{ + public int Id { get; set; } + + /// + /// 轨迹代码 + /// + 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.Domain/Dtos/TrackTemplate/GetTrackTemplateListInputVo.cs b/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateListInputVo.cs new file mode 100644 index 00000000..7e0abd82 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateListInputVo.cs @@ -0,0 +1,19 @@ +namespace SJZY.Track.Domain.Dtos.TrackTemplate; + +public class GetTrackTemplateListInputVo +{ + /// + /// 子系统id + /// + public int SubSystemId { get; set; } + + /// + /// 客户id + /// + public int? CustomerId { get; set; } + + /// + /// 模版分类 + /// + public int? TemplateType { get; set; } +} diff --git a/src/SJZY.Track.Domain/Dtos/TrackTemplate/TrackTemplateOutputVo.cs b/src/SJZY.Track.Domain/Dtos/TrackTemplate/TrackTemplateOutputVo.cs new file mode 100644 index 00000000..f84f4294 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackTemplate/TrackTemplateOutputVo.cs @@ -0,0 +1,57 @@ +namespace SJZY.Track.Domain.Dtos.TrackTemplate; + +public class TrackTemplateOutputVo +{ + /// + /// 模版id + /// + public int Id { get; set; } + + /// + /// 模版名称 + /// + public string TemplateName { get; set; } + + /// + /// 模版code + /// + public string TemplateCode { get; set; } + + /// + /// 模版内容 + /// + public List TemplateContents { get; set; } +} + +public class TemplateContentDtoVo +{ + /// + /// 模版id + /// + public int TemplateId { get; set; } + + /// + /// 轨迹code + /// + public string Code { get; set; } + + /// + /// 轨迹内容中文 + /// + public string ContentCn { get; set; } + + /// + /// 轨迹内容中文 + /// + public string ContentEn { get; set; } + + /// + /// 轨迹状态 + /// + public string Status { get; set; } + + /// + /// 轨迹节点 + /// + public string Node { get; set; } +} diff --git a/src/SJZY.Track.Domain/Queries/IProvideQueries.cs b/src/SJZY.Track.Domain/Queries/IProvideQueries.cs index e45e1321..b531eef9 100644 --- a/src/SJZY.Track.Domain/Queries/IProvideQueries.cs +++ b/src/SJZY.Track.Domain/Queries/IProvideQueries.cs @@ -21,9 +21,10 @@ public interface IProvideQueries /// /// 根据订单模板找对应服务商 /// + /// /// /// - Task> FindOrderWithServiceProviderAsync(List orderNos); + Task> FindOrderWithServiceProviderAsync(int subSystemId, List orderNos); /// /// 获取服务商下所有单(未完成的) diff --git a/src/SJZY.Track.Repository/Queries/ProvideQueries.cs b/src/SJZY.Track.Repository/Queries/ProvideQueries.cs index a87f9f6a..63c385b7 100644 --- a/src/SJZY.Track.Repository/Queries/ProvideQueries.cs +++ b/src/SJZY.Track.Repository/Queries/ProvideQueries.cs @@ -34,13 +34,16 @@ public class ProvideQueries : ISugarRepository, IProvideQueries, ITransientDepen } /// - public async Task> FindOrderWithServiceProviderAsync(List orderNos) + public async Task> FindOrderWithServiceProviderAsync(int subSystemId, + List orderNos) { return await Context.Queryable() .InnerJoin((a, b) => a.Id == b.OrderId) .LeftJoin((a, b, c) => b.ServiceProviderCode == c.Code) .LeftJoin((a, b, c, d) => a.SubSystemId == d.Id) - .Where(a => !a.IsCompleted && orderNos.Contains(a.OrderNo)) + .WhereIF(subSystemId > 0, a => a.SubSystemId == subSystemId) + .Where((a, b) => !a.IsCompleted && orderNos.Contains(a.OrderNo) + && b.StartTime <= DateTime.Now && b.EndTime >= DateTime.Now) .Select((a, b, c, d) => new OrderWithServiceProviderVO { OrderNo = a.OrderNo, @@ -53,8 +56,8 @@ public class ProvideQueries : ISugarRepository, IProvideQueries, ITransientDepen .ToListAsync(); } - /// - public async Task> FindOrderWithServiceProviderAsync(int serviceProviderId, + public async Task> FindOrderWithServiceProviderAsync( + int serviceProviderId, int pageIndex, int pageSize = 1000) { return await Context.Queryable() diff --git a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs index 88949984..8a466f0a 100644 --- a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs @@ -161,6 +161,51 @@ public class OrderRepository : BasicRepository, IOrderRepository, I return res.Select(x => (x.Key, x.Id)).ToList(); } + private int UpdateOrderQuestionType(int questionType, IEnumerable ids) + { + var idsString = string.Join(",", ids); + return Context.Ado.ExecuteCommand( + $"UPDATE `t_order` SET `QuestionType` = @questionType ,UpdateTime= current_timestamp WHERE `Id` IN ({idsString})", + new + { + questionType + }); + } + + #region 订单关联 + + public async Task> GetLinkedOrdersAsync(int[] orderIds) + { + return await Context.Queryable() + .LeftJoin((a, b) => a.LinkOrderId == b.Id) + .Where(a => orderIds.Contains(a.OrderId)) + .Select((a, b) => new LinkedOrderVO + { + OwnerOrderId = a.OrderId, + OrderId = b.Id, + OrderNo = b.OrderNo, + OrderType = b.OrderType, + SubSystemId = b.SubSystemId, + CustomId = b.CustomId + }) + .ToListAsync(); + } + + public async Task LinkOrderAsync(List orderLinkEntities) + { + await Context.Insertable(orderLinkEntities).ExecuteCommandAsync(); + } + + public async Task UnLinkByIdsAsync(List linkIds) + { + await Context.Deleteable(linkIds).ExecuteCommandAsync(); + } + + #endregion + + + #region 订单拉取 + public async Task UpdatePullStatusToSilenceAsync(List orderIds, string trackCode) { // var status = await Context.Queryable() @@ -215,65 +260,41 @@ public class OrderRepository : BasicRepository, IOrderRepository, I { var cnt1 = await Context.Updateable() .SetColumns(x => x.PullStatus == TrackPullStatus.Pulling) - .Where(x => x.PullStatus == TrackPullStatus.SilenceBeforeStart && x.StartTime > DateTime.Now) + .Where(x => x.PullStatus == TrackPullStatus.SilenceBeforeStart && x.StartTime < DateTime.Now) .ExecuteCommandAsync(); - LogHelper.Info($"{cnt1}条订单的拉取状态由SilenceBeforeStart更新为Pulling"); + LogHelper.Info( + $"{cnt1}条订单的拉取状态由{nameof(TrackPullStatus.SilenceBeforeStart)}更新为{nameof(TrackPullStatus.Pulling)}"); var cnt2 = await Context.Updateable() .SetColumns(x => x.PullStatus == TrackPullStatus.Completed) .Where(x => x.PullStatus == TrackPullStatus.SilenceAfterEnd && x.EndTime < DateTime.Now) .ExecuteCommandAsync(); - LogHelper.Info($"{cnt2}条订单的拉取状态由SilenceAfterEnd更新为Completed"); + LogHelper.Info( + $"{cnt2}条订单的拉取状态由{nameof(TrackPullStatus.SilenceAfterEnd)}更新为{nameof(TrackPullStatus.Completed)}"); return cnt1 + cnt2; } - public Task ClearPullStatus() + public async Task ClearPullStatusAsync() { var time = DateTime.Now.Subtract(TimeSpan.FromDays(30)); - return Context.Deleteable().Where(x => + return await Context.Deleteable().Where(x => x.PullStatus == TrackPullStatus.Completed || x.StartTime < time) .ExecuteCommandAsync(); } - private int UpdateOrderQuestionType(int questionType, IEnumerable ids) + public async Task UpdateOrderPullConfigForServiceProviderAsync( + UpdateOrderPullConfigForServiceProviderInputVo inputVo) { - var idsString = string.Join(",", ids); - return Context.Ado.ExecuteCommand( - $"UPDATE `t_order` SET `QuestionType` = @questionType ,UpdateTime= current_timestamp WHERE `Id` IN ({idsString})", - new - { - questionType - }); - } - - #region 订单关联 - - public async Task> GetLinkedOrdersAsync(int[] orderIds) - { - return await Context.Queryable() - .LeftJoin((a, b) => a.LinkOrderId == b.Id) - .Where(a => orderIds.Contains(a.OrderId)) - .Select((a, b) => new LinkedOrderVO - { - OwnerOrderId = a.OrderId, - OrderId = b.Id, - OrderNo = b.OrderNo, - OrderType = b.OrderType, - SubSystemId = b.SubSystemId, - CustomId = b.CustomId - }) - .ToListAsync(); - } - - public async Task LinkOrderAsync(List orderLinkEntities) - { - await Context.Insertable(orderLinkEntities).ExecuteCommandAsync(); - } - - public async Task UnLinkByIdsAsync(List linkIds) - { - await Context.Deleteable(linkIds).ExecuteCommandAsync(); + // todo:如此更新,影响范围是否可控?状态是否正确? + return await Context.Updateable() + .SetColumns(x => x.ServiceProviderCode == inputVo.ServiceCode) + .SetColumns(x => x.StartTrackCode == inputVo.StartCode) + .SetColumns(x => x.EndTrackCode == inputVo.EndCode) + .SetColumns(x => x.SilenceBeforeStart == inputVo.SilenceTime) + .SetColumns(x => x.SilenceAfterEnd == inputVo.StopTime) + .Where(x => inputVo.OrderIds.Contains(x.OrderId)) + .ExecuteCommandAsync(); } #endregion diff --git a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs index e7443fb1..a63b5c1e 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs @@ -198,4 +198,24 @@ public class TrackPushConfigRepository : BasicRepository, return result; } + + public async Task> GetTrackPushContentListAsync(int subSystemId, int customerId) + { + return await Context.Queryable() + .LeftJoin((a, b) => a.Id == b.TrackPushConfigId) + .LeftJoin((a, b, c) => b.TrackContentId == c.Id) + .Where(a => a.SubSystemId == subSystemId && a.CustomId == customerId) + .OrderBy((a, b) => b.Sort) + .Select((a, b, c) => new GetTrackPushContentListVo + { + Id = a.Id, + Code = c.Code, + OrderType = b.OrderNoType, + ServiceCode = b.TrackContentCodeValue, + Status = b.TrackStatusValue, + Content = b.TrackContentValue, + ContentEn = b.TrackEnContentValue + }) + .ToListAsync(); + } } diff --git a/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs index d322d4cc..da984be1 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs @@ -2,6 +2,7 @@ using System.Linq.Expressions; using SJZY.Expand.ABP.Core.PublicMethords; using SJZY.Track.Domain.Aggregates.TrackContentAggregate; using SJZY.Track.Domain.Aggregates.TrackFlagAggregate; +using SJZY.Track.Domain.Aggregates.TrackNodeAggregate; using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; using SJZY.Track.Domain.Dtos.TrackTemplate; @@ -43,14 +44,14 @@ public class TrackTemplateRepository : BasicRepository, ITr /// public async Task> GetPageTrackTemplate(GetPageTrackTemplateVO input) { - UnifyPageResultDto pagedList = await Context.Queryable() + var pagedList = await Context.Queryable() .LeftJoin((a, b) => a.SubSystemId == b.Id && b.IsDeleted == false) .WhereIF(input.SubSystemId > 0, (a, b) => a.SubSystemId == input.SubSystemId) .WhereIF(!input.Keywords.IsNullOrWhiteSpace(), - (a, b) => a.Name.Contains(input.Keywords) || a.Code.Contains(input.Keywords)) + (a, b) => a.Name.Contains(input.Keywords!) || a.Code.Contains(input.Keywords!)) .OrderByIF(input.SelectIds.IsNullOrEmpty(), (a, b) => a.CreateTime, OrderByType.Desc) .OrderByIF(!input.SelectIds.IsNullOrEmpty(), - (a, b) => SqlFunc.IIF(input.SelectIds.Contains(a.Id), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), + (a, b) => SqlFunc.IIF(input.SelectIds!.Contains(a.Id), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), a.CreateTime), OrderByType.Desc) .Select((a, b) => new GetTrackTemplateListVO { @@ -182,4 +183,46 @@ public class TrackTemplateRepository : BasicRepository, ITr return await Context.Updateable().SetColumns(columns).Where(whereExpression) .ExecuteCommandHasChangeAsync(); } + + public async Task> GetTrackTemplateListAsync(GetTrackTemplateListInputVo input) + { + var templates = await Context.Queryable() + .Where(x => x.SubSystemId == input.SubSystemId) + .WhereIF(input.CustomerId.HasValue, x => x.CustomerId == input.CustomerId) + .WhereIF(input.TemplateType.HasValue, x => x.CategoryId == input.TemplateType) + .Select(x => new TrackTemplateOutputVo + { + Id = x.Id, + TemplateName = x.Name, + TemplateCode = x.Code, + }) + .ToListAsync(); + + if (templates == default) return new List(); + var templateIds = templates.Select(x => x.Id).ToArray(); + var contents = await Context.Queryable() + .LeftJoin((a, b) => a.TrackContentId == b.Id) + .LeftJoin((a, b, c) => b.TrackStatusId == c.Id) + .LeftJoin((a, b, c, d) => c.Node == d.Id) + .Where(a => templateIds.Contains(a.TrackTemplateId)) + .Select((a, b, c, d) => new TemplateContentDtoVo + { + TemplateId = a.TrackTemplateId, + Code = b.Code, + ContentCn = b.Content, + ContentEn = b.EnContent, + Status = c.Status, + Node = d.NodeName + }) + .ToListAsync(); + + foreach (var template in templates) + { + var templateContents = contents.Where(x => x.TemplateId == template.Id).ToList(); + + template.TemplateContents = templateContents; + } + + return templates; + } }