diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs index 745cdf56..e0331cb9 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs @@ -44,6 +44,11 @@ public class EditTrackPushConfigInput /// public bool? IsAllPush { get; set; } + /// + /// 是否全量推送 + /// + public bool? IsAllPushWithLatest { get; set; } + /// /// 时间格式枚举 /// diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPush/TrackPushContentConfigDto.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/TrackPushContentConfigDto.cs index 345bec99..7c1c1568 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/TrackPush/TrackPushContentConfigDto.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/TrackPushContentConfigDto.cs @@ -17,6 +17,11 @@ public class TrackPushContentConfigDto /// public bool IsAllPush { get; set; } + /// + /// 是否全量推送(最新轨迹) + /// + public bool IsAllPushWithLatest { get; set; } + /// /// 是否支持删除 /// diff --git a/src/SJZY.Track.Application/CAP/EventHandlers/TrackPushEventHandler.cs b/src/SJZY.Track.Application/CAP/EventHandlers/TrackPushEventHandler.cs index 14d063bc..59a4a215 100644 --- a/src/SJZY.Track.Application/CAP/EventHandlers/TrackPushEventHandler.cs +++ b/src/SJZY.Track.Application/CAP/EventHandlers/TrackPushEventHandler.cs @@ -23,7 +23,6 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe private readonly IHttpClientProxy _httpClientProxy; private readonly IOptionsMonitor _options; private readonly IOrderRepository _orderRepository; - private readonly ITrackDetailsEsRepository _trackDetailsEsRepository; private readonly ITrackPushCacheService _trackPushCacheService; private readonly ITrackPushRecordEsRepository _trackPushRecordEsRepository; private List _orders = null!; @@ -31,13 +30,12 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe public TrackPushEventHandler(IHttpClientProxy httpClientProxy, IOrderRepository orderRepository, ITrackPushCacheService trackPushCacheService, - ITrackDetailsEsRepository trackDetailsEsRepository, ITrackPushRecordEsRepository trackPushRecordEsRepository, + ITrackPushRecordEsRepository trackPushRecordEsRepository, IOptionsMonitor options) { _httpClientProxy = httpClientProxy; _orderRepository = orderRepository; _trackPushCacheService = trackPushCacheService; - _trackDetailsEsRepository = trackDetailsEsRepository; _trackPushRecordEsRepository = trackPushRecordEsRepository; _options = options; } @@ -285,7 +283,7 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe { OrderNo = log.OrderNo, }; - var dict = new Dictionary() + var cur = new Dictionary() { // 推真实的发生地和发生时间(时间是计算后的) { "location", log.TrackPlace }, @@ -297,7 +295,7 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe { "status", config.TrackStatusValue }, { "extra", DeserializeForTextJson(extraJson) } }; - body.Data.Add(dict); + body.Data.Add(cur); if (config.IsAllPush) { @@ -305,7 +303,15 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe if (history != default) { body = DeserializeForTextJson(history.PushContent); - body!.Data.Add(dict); + if (config.IsAllPushWithLatest) + { + var last = body!.Data.Last(); + if (cur["code"] == last["code"]) + { + body.Data.Remove(last); + } + } + body!.Data.Add(cur); } } diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs index eb4c6388..5b64b496 100644 --- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs +++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs @@ -51,6 +51,7 @@ public class TrackPushCacheService : ITrackPushCacheService, ITransientDependenc x.Id, x.IsAutoPush, x.IsAllPush, + x.IsAllPushWithLatest, x.IsCanDelete, x.IsCanUpdate, x.SubSystemId, @@ -76,6 +77,7 @@ public class TrackPushCacheService : ITrackPushCacheService, ITransientDependenc IsAutoPush = trackPushConfig.IsAutoPush, IsCanUpdate = trackPushConfig.IsCanUpdate, IsAllPush = trackPushConfig.IsAllPush, + IsAllPushWithLatest = trackPushConfig.IsAllPushWithLatest, IsCanDelete = trackPushConfig.IsCanDelete, DateTimeFormatType = (int) trackPushConfig.DateTimeFormatType, DateTimeFormat = trackPushConfig.DateTimeFormat, @@ -89,6 +91,7 @@ public class TrackPushCacheService : ITrackPushCacheService, ITransientDependenc TrackContentValue = item.TrackContentValue, TrackEnContentValue = item.TrackEnContentValue, TrackTimeZone = item.TrackTimeZone, + // todo:废弃字段如果没有外部子系统依赖,可以逐步删除 ExpandFieldsValue = item.ExpandFieldsValue, }).ToList(); diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/TrackPushConfigEntity.cs b/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/TrackPushConfigEntity.cs index e029921e..8dc04097 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/TrackPushConfigEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/TrackPushConfigEntity.cs @@ -56,6 +56,12 @@ public class TrackPushConfigEntity : IFullAuditedBasicEntitys, IAggregateRoot [SugarColumn(ColumnName = "IsAllPush")] public bool IsAllPush { get; set; } + /// + /// 是否全量推送(最新轨迹) + /// + [SugarColumn(ColumnName = "IsAllPushWithLatest")] + public bool IsAllPushWithLatest { get; set; } + /// /// 日期时间格式类型 /// diff --git a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs index 42de155e..f8cff929 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs @@ -51,6 +51,11 @@ public class GetTrackPushConfigDetailOutputVO /// public bool IsAllPush { get; set; } + /// + /// 是否全量推送(最新轨迹) + /// + public bool IsAllPushWithLatest { get; set; } + /// /// 时间格式枚举 ///