Merge remote-tracking branch 'origin/S03-轨迹中台优化项' into test
This commit is contained in:
commit
34d2469067
@ -65,8 +65,14 @@ public class TrackPushCompletedEventHandler : ITransientDependency, ICapSubscrib
|
||||
|
||||
private async Task TrackPushAfterUpdateOrderAsync(TrackPushRecordIndex log)
|
||||
{
|
||||
var order = new OrderEntity();
|
||||
order.Id = log.OrderId;
|
||||
// tips:只有新增会影响推送进度?
|
||||
if (log.OptionType != OptionType.新增.ToString()) return;
|
||||
|
||||
var order = new OrderEntity
|
||||
{
|
||||
Id = log.OrderId
|
||||
};
|
||||
|
||||
/*
|
||||
* 异常:最近一条推送是失败
|
||||
*/
|
||||
@ -74,27 +80,22 @@ public class TrackPushCompletedEventHandler : ITransientDependency, ICapSubscrib
|
||||
{
|
||||
order.QuestionType = (int)TrackProblemType.Error;
|
||||
order.LatestPushError = log.Message;
|
||||
}
|
||||
else
|
||||
{
|
||||
order.QuestionType = (int)TrackProblemType.None;
|
||||
order.LatestPushError = null;
|
||||
if (log.OptionType == OptionType.新增.ToString())
|
||||
{
|
||||
// tips:只有新增会影响推送进度?
|
||||
order.LatestPushTrackCode = log.TrackCode;
|
||||
order.LatestPushTime = DateTime.Now;
|
||||
await _orderRepository.UpdateColumnAsync(order, x => new
|
||||
{
|
||||
x.LatestPushTrackCode, x.LatestPushTime, x.QuestionType, x.LatestPushError
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await _orderRepository.UpdateColumnAsync(order, x => new
|
||||
{
|
||||
x.QuestionType, x.LatestPushError
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// 还原成正常态
|
||||
order.QuestionType = (int)TrackProblemType.None;
|
||||
order.LatestPushError = null;
|
||||
order.LatestPushTrackCode = log.TrackCode;
|
||||
order.LatestPushTime = log.CreateTime;
|
||||
await _orderRepository.UpdateColumnAsync(order, x => new
|
||||
{
|
||||
x.LatestPushTrackCode, x.LatestPushTime, x.QuestionType, x.LatestPushError
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -44,9 +44,8 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
|
||||
if (pushConfigs == null || pushConfigs.Count == 0) return;
|
||||
_pushConfigs = pushConfigs;
|
||||
|
||||
var errorType = (int)TrackProblemType.Error;
|
||||
var orders = await _orderRepository.GetListAsync(x =>
|
||||
@event.OrderIds.Contains(x.Id) && x.QuestionType != errorType, x => new OrderEntity
|
||||
@event.OrderIds.Contains(x.Id), x => new OrderEntity
|
||||
{
|
||||
Id = x.Id, OrderNo = x.OrderNo, LatestPushTrackCode = x.LatestPushTrackCode,
|
||||
OrderType = x.OrderType
|
||||
@ -80,6 +79,7 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
|
||||
{
|
||||
foreach (var order in _orders)
|
||||
{
|
||||
if (order.QuestionType == (int)TrackProblemType.Error) continue; // 系统不推异常单,只能人工操作
|
||||
// 推送新增,需要根据上一次的推送 推断 本次推送 是否可行
|
||||
config = GetValidPushConfigAsync(_pushConfigs, order.LatestPushTrackCode, @event.TrackCode);
|
||||
if (config == null) continue;
|
||||
@ -114,6 +114,7 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
|
||||
|
||||
if (tracks.Count == 0) return; // 一个能推的轨迹都不存在
|
||||
|
||||
// tips:人工推送只要能推就推了,不会校验已推和顺序问题,因为可能是更新
|
||||
foreach (var track in tracks)
|
||||
{
|
||||
var order = _orders.First(x => x.Id == track.OrderId);
|
||||
@ -144,12 +145,18 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
|
||||
}
|
||||
}
|
||||
|
||||
string asciiString = Base64Helper.SerializeObject(OptionType.新增.ToString());
|
||||
|
||||
if (items.Count == 0) return;
|
||||
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(InterfaceRelayConst.PushTrackInterfaceCode,
|
||||
|
||||
string asciiString = Base64Helper.SerializeObject(OptionType.新增.ToString());
|
||||
var r = await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
|
||||
InterfaceRelayConst.PushTrackInterfaceCode,
|
||||
_pushConfigs.First().ServiceProviderCode, items, GlobalConst.TrackPushCompletedSubscribe,
|
||||
attach: asciiString);
|
||||
|
||||
if (r.Code != InterfaceRelayConst.SuccessCode)
|
||||
{
|
||||
throw new BusinessException(message: r.Msg);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DoUpdateAsync(TrackPushEvent @event)
|
||||
@ -179,9 +186,17 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
|
||||
}
|
||||
|
||||
if (items.Count == 0) return;
|
||||
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(InterfaceRelayConst.TrackUpdateInterfaceCode,
|
||||
|
||||
string asciiString = Base64Helper.SerializeObject(OptionType.修改.ToString());
|
||||
var r = await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
|
||||
InterfaceRelayConst.TrackUpdateInterfaceCode,
|
||||
_pushConfigs.First().ServiceProviderCode, items, GlobalConst.TrackPushCompletedSubscribe,
|
||||
attach: OptionType.修改.ToString());
|
||||
attach: asciiString);
|
||||
|
||||
if (r.Code != InterfaceRelayConst.SuccessCode)
|
||||
{
|
||||
throw new BusinessException(message: r.Msg);
|
||||
}
|
||||
}
|
||||
|
||||
private TrackUpdateInput BuiltUpdateItem(TrackPushContentConfigDto config, TrackPushRecordIndex log)
|
||||
|
||||
@ -39,25 +39,33 @@ public class TrackPushService : ApplicationService
|
||||
{
|
||||
input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空
|
||||
|
||||
var orderIds = await _orderRepository.GetArrayAsync(x =>
|
||||
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo), x => x.Id);
|
||||
var orders = await _orderRepository.GetArrayAsync(x =>
|
||||
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo), x => new
|
||||
{
|
||||
x.Id, x.SubSystemId, x.CustomId
|
||||
});
|
||||
|
||||
if (!orderIds.Any())
|
||||
if (!orders.Any())
|
||||
{
|
||||
throw new BusinessException(message: "一个订单都不存在");
|
||||
}
|
||||
|
||||
foreach (var group in orders.GroupBy(x => new { x.SubSystemId, x.CustomId }))
|
||||
{
|
||||
var trackPushEvent = new TrackPushEvent
|
||||
{
|
||||
OptionType = OptionType.新增,
|
||||
OrderIds = orderIds,
|
||||
SubSystemId = group.Key.SubSystemId,
|
||||
CustomId = group.Key.CustomId,
|
||||
OrderIds = group.Select(x => x.Id).ToArray(),
|
||||
TrackCode = input.TrackCode,
|
||||
OperationMan = CurrentUserRequest.CurrentUser.Name,
|
||||
};
|
||||
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackPushSubscribe, trackPushEvent);
|
||||
}
|
||||
|
||||
return $"即将推送轨迹代码{input.TrackCode}给{orderIds.Length}个订单";
|
||||
return $"即将推送轨迹代码{input.TrackCode}给{orders.Length}个订单";
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user