解决冲突
This commit is contained in:
commit
bfd9f3afd3
@ -18,14 +18,14 @@ public class GetPageTrackOrderInput : PageInfoInput
|
||||
public string? OrderNos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// tab标签类型 0 全部, 1 异常 2 预警
|
||||
/// </summary>
|
||||
public int? TrackOrderType { get; set; }
|
||||
public int TabType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户id
|
||||
/// 当tab选中 0 默认不传 1 直接写死传值 [1,4] 2 传 [2,4]
|
||||
/// </summary>
|
||||
public int? CustomerId { get; set; }
|
||||
public List<int>? QuestionTypeIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间开始
|
||||
@ -128,5 +128,28 @@ public class TrackOrderDto
|
||||
/// </summary>
|
||||
public string SubSystem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子系统id
|
||||
/// </summary>
|
||||
public int SubSystemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型(主数据枚举TrackQuestionType)
|
||||
/// </summary>
|
||||
public int QuestionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型名称
|
||||
/// </summary>
|
||||
public string? QuestionTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
||||
/// </summary>
|
||||
public int ProblemDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述名称
|
||||
/// </summary>
|
||||
public string? ProblemDescriptionName { get; set; }
|
||||
}
|
||||
@ -7,11 +7,16 @@ public class UpdateOrderTrackEvent
|
||||
/// </summary>
|
||||
public int OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否删除引起的更新
|
||||
/// </summary>
|
||||
public bool IsDelete { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 此次发生的轨迹是否意味完成
|
||||
/// </summary>
|
||||
public bool IsCompleted { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容
|
||||
/// </summary>
|
||||
@ -21,7 +26,7 @@ public class UpdateOrderTrackEvent
|
||||
/// 轨迹内容英文
|
||||
/// </summary>
|
||||
public string TrackEnContent { get; set; } = null!;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地
|
||||
/// </summary>
|
||||
@ -31,7 +36,7 @@ public class UpdateOrderTrackEvent
|
||||
/// 轨迹发生时间
|
||||
/// </summary>
|
||||
public DateTime TrackTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹时区
|
||||
/// </summary>
|
||||
|
||||
@ -56,7 +56,30 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
|
||||
private async Task DeleteTrackAsync(TrackDeleteEvent @event)
|
||||
{
|
||||
// 删除轨迹
|
||||
await _trackDetailsRepository.DeleteTrackAsync(@event.OrderId, @event.TrackCodes);
|
||||
var isOk = await _trackDetailsRepository.DeleteTrackAsync(@event.OrderId, @event.TrackCodes);
|
||||
|
||||
// 触发订单主表更新事件
|
||||
if (isOk)
|
||||
{
|
||||
var track = await _trackDetailsRepository.GetLatestAsync(@event.OrderId);
|
||||
var updateOrderEvent = track == default
|
||||
? new UpdateOrderTrackEvent
|
||||
{
|
||||
OrderId = @event.OrderId,
|
||||
IsDelete = true
|
||||
}
|
||||
: new UpdateOrderTrackEvent
|
||||
{
|
||||
OrderId = @event.OrderId,
|
||||
IsCompleted = track.IsCompleted,
|
||||
TrackContent = track.TrackContent,
|
||||
TrackEnContent = track.TrackEnContent,
|
||||
TrackPlace = track.TrackPlace,
|
||||
TrackTime = track.TrackTime,
|
||||
TrackTimeZone = track.TrackTimeZone
|
||||
};
|
||||
await _capPublisher.PublishAsync(GlobalConst.UpdateOrderTrackSubscribe, updateOrderEvent);
|
||||
}
|
||||
|
||||
// 根据订单关联关系异步向下刷
|
||||
var linkedOrders = await _orderRepository.GetLinkedOrdersAsync(@event.OrderId);
|
||||
|
||||
@ -88,7 +88,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
TrackStatus = trackContent.Status,
|
||||
TrackCode = @event.TrackCode,
|
||||
TrackContent = trackContent.Content,
|
||||
|
||||
IsCompleted = orderIsCompleted,
|
||||
TrackEnContent = trackContent.EnContent,
|
||||
TrackPlace = @event.TrackPlace,
|
||||
TrackTime = @event.TrackTime!.Value,
|
||||
|
||||
@ -20,16 +20,28 @@ public class UpdateOrderTrackEventHandler : ITransientDependency, ICapSubscribe
|
||||
var order = await _orderRepository.GetFirstAsync(x => x.Id == @event.OrderId);
|
||||
if (order == default) return;
|
||||
|
||||
if (order.IsCompleted) return;
|
||||
if (@event.IsDelete)
|
||||
{
|
||||
if (@event.TrackTime == default)
|
||||
{
|
||||
// 删除全部轨迹导致的重置行为
|
||||
order.ResetTrackInfo();
|
||||
}
|
||||
else if (@event.TrackTime == order.LatestTrackTime) return;
|
||||
}
|
||||
else // upsert引发的更新,需要校验发生时间是否大于最新时间
|
||||
{
|
||||
if (order.LatestTrackTime != null &&
|
||||
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) >
|
||||
@event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone))) return;
|
||||
}
|
||||
|
||||
order.IsCompleted = @event.IsCompleted;
|
||||
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
|
||||
{
|
||||
|
||||
@ -49,9 +49,9 @@ public class TrackPushPullService : ApplicationService
|
||||
x.OrderNo
|
||||
}).ToList();
|
||||
|
||||
// 批量获取轨迹
|
||||
// 批量获取轨迹 这里报错了,我先随便给个 写死的主体值
|
||||
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
|
||||
"A012", group.Key.ServiceProviderCode, data,
|
||||
"A012", group.Key.ServiceProviderCode, 42, data,
|
||||
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
|
||||
}
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "IsCompleted")]
|
||||
public bool IsCompleted { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 订单是否推送完成(异步维护)
|
||||
/// </summary>
|
||||
@ -65,7 +65,7 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LatestTrackTime")]
|
||||
public DateTime? LatestTrackTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 最新轨迹时区(异步维护)
|
||||
/// </summary>
|
||||
@ -108,14 +108,34 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
[SugarColumn(ColumnName = "LeaveCountry")]
|
||||
public string LeaveCountry { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型(主数据枚举TrackQuestionType)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "QuestionType")]
|
||||
public int QuestionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "ProblemDescription")]
|
||||
public int ProblemDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 起运港口
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LeavePort")]
|
||||
public string? LeavePort { get; set; }
|
||||
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<OrderFlightEntity> OrderFlights { get; set; }
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<OrderTemplateEntity> OrderTemplates { get; set; }
|
||||
[SugarColumn(IsIgnore = true)] public List<OrderFlightEntity> OrderFlights { get; set; }
|
||||
[SugarColumn(IsIgnore = true)] public List<OrderTemplateEntity> OrderTemplates { get; set; }
|
||||
|
||||
public void ResetTrackInfo()
|
||||
{
|
||||
IsCompleted = false;
|
||||
LatestTrackContent = null;
|
||||
LatestTrackEnContent = null;
|
||||
LatestTrackTime = null;
|
||||
LatestTrackPlace = null;
|
||||
LatestTrackTimeZone = null;
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,14 @@ public interface ITrackDetailsRepository
|
||||
/// <param name="orderId"></param>
|
||||
/// <param name="trackCodes"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteTrackAsync(int orderId, List<string> trackCodes);
|
||||
Task<bool> DeleteTrackAsync(int orderId, List<string> trackCodes);
|
||||
|
||||
Task<List<TrackDetailsIndex>?> GetListAsync(List<int> orderIds);
|
||||
|
||||
/// <summary>
|
||||
/// 获取最近一条发生的轨迹
|
||||
/// </summary>
|
||||
/// <param name="orderId"></param>
|
||||
/// <returns></returns>
|
||||
Task<TrackDetailsIndex?> GetLatestAsync(int orderId);
|
||||
}
|
||||
@ -46,6 +46,11 @@ public class TrackDetailsIndex : IdBaseIndex
|
||||
/// </summary>
|
||||
public string TrackContent { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 是否意味着完成
|
||||
/// </summary>
|
||||
public bool IsCompleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 原轨迹内容
|
||||
/// </summary>
|
||||
|
||||
@ -18,6 +18,15 @@ namespace SJZY.Track.Domain.Dtos.Order
|
||||
///// </summary>
|
||||
//public List<string>? OrderNos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当tab选中 0 默认不传 1 直接写死传值 [1,4] 2 传 [2,4]
|
||||
/// </summary>
|
||||
public int TabType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当tab选中 1 直接写死传值 [1,4] 2 传 [2,4]
|
||||
/// </summary>
|
||||
public List<int>? QuestionTypeIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单号
|
||||
@ -139,5 +148,25 @@ namespace SJZY.Track.Domain.Dtos.Order
|
||||
/// 轨迹模板Id数组
|
||||
/// </summary>
|
||||
public List<int>? TrackTemplateIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型(主数据枚举TrackQuestionType)
|
||||
/// </summary>
|
||||
public int QuestionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型名称
|
||||
/// </summary>
|
||||
public string? QuestionTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
||||
/// </summary>
|
||||
public int ProblemDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述名称
|
||||
/// </summary>
|
||||
public string? ProblemDescriptionName { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +27,11 @@ public class GlobalConst
|
||||
/// </summary>
|
||||
public const string UpdateOrderTrackSubscribe = "SJZY.Track.UpdateOrderTrack";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹删除后触发更新订单轨迹 mq订阅名称
|
||||
/// </summary>
|
||||
public const string DeleteTrackAfterUpdateOrderSubscribe = "SJZY.Track.DeleteTrackAfterUpdateOrder";
|
||||
|
||||
/// <summary>
|
||||
/// 关联订单后补轨迹 mq订阅名称
|
||||
/// </summary>
|
||||
|
||||
@ -139,6 +139,7 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
(a, b, c) => a.CreateTime <= input.CreateTimeEnd)
|
||||
.WhereIF(input.CustomerId>0, (a, b, c) => a.CustomId==input.CustomerId)
|
||||
.WhereIF(input.TrackOrderType>0, (a, b, c) => a.OrderType==input.TrackOrderType)
|
||||
.WhereIF(input.TabType>0 && (!input.QuestionTypeIds.IsNullOrEmpty()), (a, b, c) => input.QuestionTypeIds.Contains(a.QuestionType))
|
||||
.OrderByDescending((a, b, c) => a.CreateTime)
|
||||
.Select((a, b, c) => new TrackOrderVO
|
||||
{
|
||||
@ -151,6 +152,10 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
CustomerShortName = b.Abbreviation,
|
||||
CustomerCode = b.Code,
|
||||
CustomerId = a.CustomId,
|
||||
QuestionType = a.QuestionType,
|
||||
QuestionTypeName = SqlFunc.IF(a.QuestionType == 1).Return("异常").ElseIF(a.QuestionType == 2).Return("预警").End(""),
|
||||
ProblemDescription = a.ProblemDescription,
|
||||
ProblemDescriptionName =SqlFunc.IF(a.ProblemDescription == 1).Return("推送异常").ElseIF(a.ProblemDescription == 2).Return("推送预警").End(""),
|
||||
//TrackTemplateNames = SqlFunc.Subqueryable<OrderTemplateEntity>()
|
||||
// .LeftJoin<TrackTemplateEntity>((aa, bb) => aa.TrackTemplateId == bb.Id)
|
||||
// .Where((aa, bb) => a.Id == aa.OrderId).SelectStringJoin((aa, bb) => bb.Name, ","),
|
||||
@ -209,7 +214,7 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
|
||||
a.TrackTemplateNames = trackTemplateList.Where(b => b.OrderId == a.Id).Select(a => a.Name)
|
||||
.JoinAsString(",");
|
||||
a.TrackTemplateIds = trackTemplateList.Where(b => b.OrderId == a.Id).Select(a => a.TemplateId).ToList();
|
||||
a.TrackTemplateIds = trackTemplateList.Where(b => b.OrderId == a.Id).Where(b => b.TemplateId>0).Select(a => a.TemplateId).ToList();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -110,7 +110,28 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
return data?.Documents?.ToList();
|
||||
}
|
||||
|
||||
public async Task DeleteTrackAsync(int orderId, List<string> trackCodes)
|
||||
public async Task<TrackDetailsIndex?> GetLatestAsync(int orderId)
|
||||
{
|
||||
var data = await Context.SearchAsync<TrackDetailsIndex>(x => x
|
||||
.Source(s => s.Includes(fd => fd
|
||||
.Field(f => f.IsCompleted)
|
||||
.Field(f => f.TrackEnContent)
|
||||
.Field(f => f.TrackContent)
|
||||
.Field(f => f.TrackPlace)
|
||||
.Field(f => f.TrackTime)
|
||||
.Field(f => f.TrackTimeZone)
|
||||
))
|
||||
.Query(q =>
|
||||
q.Term(f => f.OrderId, orderId)
|
||||
)
|
||||
.Sort(s => s.Field(f => f.TrackTime, SortOrder.Descending))
|
||||
.Size(1)
|
||||
);
|
||||
|
||||
return data.Documents.FirstOrDefault();
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteTrackAsync(int orderId, List<string> trackCodes)
|
||||
{
|
||||
var r = await Context.DeleteByQueryAsync<TrackDetailsIndex>(x => x
|
||||
.Query(
|
||||
@ -122,6 +143,8 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
|
||||
if (!r.IsValid)
|
||||
throw new Exception($"轨迹数据删除失败,原因:{r.DebugInformation}");
|
||||
|
||||
return r.Deleted > 0;
|
||||
}
|
||||
|
||||
public async Task<(List<TrackDetailsIndex> list, long total)> GetListAsync(TrackDetailsQueryInput input)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user