diff --git a/src/SJZY.Track.Api/SjzyTrackApiModule.cs b/src/SJZY.Track.Api/SjzyTrackApiModule.cs index 443495ce..102be9d7 100644 --- a/src/SJZY.Track.Api/SjzyTrackApiModule.cs +++ b/src/SJZY.Track.Api/SjzyTrackApiModule.cs @@ -37,6 +37,7 @@ namespace SJZY.Track.Api var environment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); context.Services.AddSwagger(); + //过滤器相关配置 context.Services.AddMvc(options => { @@ -60,7 +61,6 @@ namespace SJZY.Track.Api Configure(options => options.OutputDateTimeFormat = "yyyy-MM-dd HH:mm:ss"); Configure(options => { options.IsEnabled = false; }); - context.Services.AddRedis(); } diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackUpsertEvent.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackUpsertEvent.cs new file mode 100644 index 00000000..b6f64a7a --- /dev/null +++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackUpsertEvent.cs @@ -0,0 +1,6 @@ +namespace SJZY.Track.Application.Contract.Dtos.ProvideServices; + +public class TrackUpsertEvent +{ + public int Order { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackCustomer.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackCustomer.cs index d4c57f4c..9f722217 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/TrackCustomer.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackCustomer.cs @@ -5,5 +5,5 @@ namespace SJZY.Track.Application.Services.ProvideServices; public class TrackCustomer : ITransientDependency, ICapSubscribe { - public const string CapSubscribe = "SJZY.FMC.VoucherRedundantCalc"; + public const string CapSubscribe = "SJZY.Track.Upsert"; } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs index a6a5f932..0210a0ac 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs @@ -81,6 +81,7 @@ public class TrackService : ApplicationService } // 根据订单关联关系向下刷,不同子系统还需要做内容映射 + var links = await _orderRepository.GetLinkedOrderIdsAsync(orderId); // 推送 return true; diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs index 93d162e2..136375c5 100644 --- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs @@ -20,6 +20,30 @@ public interface IOrderRepository : IBasicRepository /// Task> GetPageTrackOrder(GetPageTrackOrderInputVO input); + /// + /// 更新订单 + /// + /// + /// + Task UpdateOrderAsync(OrderEntity order); + + /// + /// 删除订单 + /// + /// + /// + Task DeleteOrderAsync(int orderId); + + + #region 订单关联 + + /// + /// 根据订单id,获取关联的订单id集合 + /// + /// + /// + Task> GetLinkedOrderIdsAsync(int orderId); + /// /// 关联订单 /// @@ -34,17 +58,5 @@ public interface IOrderRepository : IBasicRepository /// Task UnLinkByIdsAsync(List linkIds); - /// - /// 更新订单 - /// - /// - /// - Task UpdateOrderAsync(OrderEntity order); - - /// - /// 删除订单 - /// - /// - /// - Task DeleteOrderAsync(int orderId); + #endregion } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderLinkEntity.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderLinkEntity.cs index 112fc472..71231e99 100644 --- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderLinkEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderLinkEntity.cs @@ -12,6 +12,18 @@ public class OrderLinkEntity : ICreateBaicEntity, ISoftDeleteBasicEntity, IEntit [SugarColumn(ColumnName = "Id", IsPrimaryKey = true, IsIdentity = true)] public int Id { get; set; } + /// + /// 订单id + /// + [SugarColumn(ColumnName = "OrderId")] + public int OrderId { get; set; } + + /// + /// 关联的订单id + /// + [SugarColumn(ColumnName = "LinkOrderId")] + public int LinkOrderId { get; set; } + /// /// 订单类型 /// @@ -24,6 +36,7 @@ public class OrderLinkEntity : ICreateBaicEntity, ISoftDeleteBasicEntity, IEntit [SugarColumn(ColumnName = "OrderNo")] public string OrderNo { get; set; } = null!; + /// /// 关联的订单类型 /// diff --git a/src/SJZY.Track.Domain/Dtos/Common/KeywordsInputVO.cs b/src/SJZY.Track.Domain/Dtos/Common/KeywordsInputVO.cs index 9cf11c60..2e58c378 100644 --- a/src/SJZY.Track.Domain/Dtos/Common/KeywordsInputVO.cs +++ b/src/SJZY.Track.Domain/Dtos/Common/KeywordsInputVO.cs @@ -10,7 +10,7 @@ public class KeywordsInputVO : PageInfoInput /// /// 关键字 /// - public string Keywords { get; set; } + public string? Keywords { get; set; } /// /// 选中项 diff --git a/src/SJZY.Track.Infrastructure/Repositories/OrderRepository.cs b/src/SJZY.Track.Infrastructure/Repositories/OrderRepository.cs index 2771e10c..7fb36b99 100644 --- a/src/SJZY.Track.Infrastructure/Repositories/OrderRepository.cs +++ b/src/SJZY.Track.Infrastructure/Repositories/OrderRepository.cs @@ -1,5 +1,4 @@ -using Nest; -using SJZY.Track.Domain; +using SJZY.Track.Domain; using SJZY.Track.Domain.Aggregates.OrderAggregate; using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; using SJZY.Track.Domain.Dtos.Order; @@ -18,16 +17,6 @@ public class OrderRepository : BasicRepository, IOrderRepository, I .ExecuteCommandAsync(); } - public async Task LinkOrderAsync(List orderLinkEntities) - { - await Context.Insertable(orderLinkEntities).ExecuteCommandAsync(); - } - - public async Task UnLinkByIdsAsync(List linkIds) - { - await Context.Deleteable(linkIds).ExecuteCommandAsync(); - } - public async Task UpdateOrderAsync(OrderEntity order) { using var tran = TransactionHelper.GetReadCommitted(); @@ -62,6 +51,29 @@ public class OrderRepository : BasicRepository, IOrderRepository, I tran.Complete(); } + #region 订单关联 + + public async Task> GetLinkedOrderIdsAsync(int orderId) + { + return await Context.Queryable() + .LeftJoin((a, b) => a.Id == b.OrderId) + .Where(a => a.Id == orderId) + .Select((a, b) => b.LinkOrderId) + .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 轨迹订单明细 /// @@ -86,31 +98,37 @@ public class OrderRepository : BasicRepository, IOrderRepository, I public async Task> GetPageTrackOrder(GetPageTrackOrderInputVO input) { var pageList = await Context.Queryable() - .LeftJoin((a, b) => a.CustomId==b.Id) - .LeftJoin((a, b, c) => a.SubSystemId==c.Id) - .WhereIF(input.SubSystemId > 0, (a, b, c) => a.SubSystemId == input.SubSystemId) - .WhereIF(!input.OrderNos.IsNullOrEmpty(), (a, b, c) => input.OrderNos.Contains(a.OrderNo)) - .WhereIF(input.CreateTimeStart.HasValue&& input.CreateTimeEnd.HasValue, (a, b, c) => a.CreateTime>= input.CreateTimeStart && a.CreateTime<= input.CreateTimeEnd) - .WhereIF(input.CreateTimeStart.HasValue&& (!input.CreateTimeEnd.HasValue), (a, b, c) => a.CreateTime>= input.CreateTimeStart) - .WhereIF((!input.CreateTimeStart.HasValue)&& input.CreateTimeEnd.HasValue, (a, b, c) => a.CreateTime<= input.CreateTimeEnd) - .Select((a, b, c) => new TrackOrderVO - { - Id = a.Id, - OrderNumber= a.OrderNo, - OrderType = a.OrderType, - CustomerShortName= b.Abbreviation, - CustomerCode= b.Code, - TrackTemplateNames = SqlFunc.Subqueryable().LeftJoin((aa, bb) => aa.TrackTemplateId==bb.Id) - .Where((aa, bb) => a.Id==aa.OrderId).SelectStringJoin((aa, bb) => bb.Name, ","), - NewestTrackContent= a.LatestTrackContent, - NewestTrackEnContent= a.LatestTrackEnContent, - NewestTrackPlace= a.LatestTrackPlace, - IsFinish=a.IsCompleted, - CreateTime=a.CreateTime, - SubSystem= c.CnName - }) - .ToPagedListAsync(input.PageIndex, input.PageSize); + .LeftJoin((a, b) => a.CustomId == b.Id) + .LeftJoin((a, b, c) => a.SubSystemId == c.Id) + .WhereIF(input.SubSystemId > 0, (a, b, c) => a.SubSystemId == input.SubSystemId) + .WhereIF(!input.OrderNos.IsNullOrEmpty(), (a, b, c) => input.OrderNos.Contains(a.OrderNo)) + .WhereIF(input.CreateTimeStart.HasValue && input.CreateTimeEnd.HasValue, + (a, b, c) => a.CreateTime >= input.CreateTimeStart && a.CreateTime <= input.CreateTimeEnd) + .WhereIF(input.CreateTimeStart.HasValue && (!input.CreateTimeEnd.HasValue), + (a, b, c) => a.CreateTime >= input.CreateTimeStart) + .WhereIF((!input.CreateTimeStart.HasValue) && input.CreateTimeEnd.HasValue, + (a, b, c) => a.CreateTime <= input.CreateTimeEnd) + .Select((a, b, c) => new TrackOrderVO + { + Id = a.Id, + OrderNumber = a.OrderNo, + OrderType = a.OrderType, + CustomerShortName = b.Abbreviation, + CustomerCode = b.Code, + TrackTemplateNames = SqlFunc.Subqueryable() + .LeftJoin((aa, bb) => aa.TrackTemplateId == bb.Id) + .Where((aa, bb) => a.Id == aa.OrderId).SelectStringJoin((aa, bb) => bb.Name, ","), + NewestTrackContent = a.LatestTrackContent, + NewestTrackEnContent = a.LatestTrackEnContent, + NewestTrackPlace = a.LatestTrackPlace, + IsFinish = a.IsCompleted, + CreateTime = a.CreateTime, + SubSystem = c.CnName + }) + .ToPagedListAsync(input.PageIndex, input.PageSize); + #region 暂时注释 + //if (pageList.List.Any()) //{ // var orderIds = pageList.List.Select(a => a.Id); @@ -129,7 +147,9 @@ public class OrderRepository : BasicRepository, IOrderRepository, I // a.TrackTemplateNames = templateListOfOrderId.Select(c => c.Name).JoinAsString(","); // }); //} + #endregion + return pageList; } diff --git a/src/SJZY.Track.Infrastructure/SJZY.Track.Infrastructure.csproj b/src/SJZY.Track.Infrastructure/SJZY.Track.Infrastructure.csproj index f9bee800..938fe9a1 100644 --- a/src/SJZY.Track.Infrastructure/SJZY.Track.Infrastructure.csproj +++ b/src/SJZY.Track.Infrastructure/SJZY.Track.Infrastructure.csproj @@ -4,6 +4,7 @@ net7.0 True preview + SJZY.Track.Repository