Merge branch 'S07' into test

This commit is contained in:
hardstylewyl 2025-04-16 11:00:03 +08:00
commit 941147a78e
3 changed files with 24 additions and 2 deletions

View File

@ -5,6 +5,7 @@ using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.InterfaceRelay.Application.Contracts;
using SJZY.OTel;
using SJZY.Track.Application.Contract.Dtos.TrackPush;
using SJZY.Track.Application.Contract.Events;
using SJZY.Track.Application.Contract.Services;
@ -549,6 +550,11 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
//轨迹推送失败(被拦截)
private void TrackPushFailedPublicTopic(string failedMessage, TrackPushEvent @event, OrderEntity order)
{
using var activity = ActivityHelper.CreateSpanActivity("TrackPushEventHandler");
activity.SetTag("TrackPushFailedPublicTopic", failedMessage);
activity.SetTag("failedMessage", failedMessage);
activity.SetTag("@event", @event);
activity.SetTag("order", order);
_broadcastingService.TrackPushFailedPubilcTopic(new TrackPushRecordDto
{
SubSystemCode = @event.SubSystemCode,
@ -581,6 +587,10 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
List<dynamic> pushOrUpdateInputs
)
{
using var activity = ActivityHelper.CreateSpanActivity("TrackPushEventHandler");
activity.SetTag("TrackPushFailedPublicTopic", failedMessage);
activity.SetTag("failedMessage", failedMessage);
activity.SetTag("@event", @event);
foreach (var pushInput in pushOrUpdateInputs)
{
_broadcastingService.TrackPushFailedPubilcTopic(new TrackPushRecordDto

View File

@ -1,8 +1,8 @@
using System.Diagnostics;
using DotNetCore.CAP;
using Microsoft.Extensions.Logging;
using SJZY.Expand.ABP.Core.Logger;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.OTel;
using SJZY.Track.Application.Contract.Events;
using SJZY.Track.Application.Contract.Services;
using SJZY.Track.Application.Services.Warning.Handlers;
@ -11,7 +11,6 @@ using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
using SJZY.Track.Domain.Aggregates.WarningAggregate.Signals;
using SJZY.Track.Domain.Dtos.TrackContents;
using SJZY.Track.Domain.Enums;
using SJZY.Track.Domain.Extensions;
using SJZY.Track.Domain.Queries;
using Volo.Abp.DependencyInjection;
using OrderIdentifier = SJZY.Track.Application.Contract.Events.OrderIdentifier;
@ -309,11 +308,14 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
// 修改了extra,要校验修改后的extra是否存在
|| (!string.IsNullOrWhiteSpace(@event.NewExtra) && x.Extra == @event.NewExtra)).ToList();
using var activity = ActivityHelper.CreateSpanActivity("TrackUpsertEventHandler");
if (@event.IsAdd)
{
if (existTracks.Count > 0)
{
_logger.LogInformation("订单已经存在不允许重复的轨迹,不允许重复添加:{@event}", @event);
activity.SetTag("errorMsg", "订单已经存在不允许重复的轨迹,不允许重复添加");
activity.SetTag("@event", @event);
continue;
}
@ -325,12 +327,16 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
if (existTracks.Count == 0)
{
_logger.LogInformation("订单不存在轨迹,不允许修改:{@event}", @event);
activity.SetTag("errorMsg", "订单不存在轨迹,不允许修改");
activity.SetTag("@event", @event);
continue;
}
if (existTracks.Count > 1)
{
_logger.LogInformation("订单存在多条轨迹不允许修改:{@event}", @event);
activity.SetTag("errorMsg", "订单存在多条轨迹不允许修改");
activity.SetTag("@event", @event);
continue;
}

View File

@ -1,5 +1,7 @@
using DotNetCore.CAP;
using Microsoft.AspNetCore.Http;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.OTel;
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
using SJZY.Track.Application.Contract.Events;
using SJZY.Track.Application.Contract.Services.ProvideServices;
@ -265,6 +267,8 @@ public partial class TrackService : ApplicationService, ITrackService
[HttpPost("Track/Upsert")]
public async Task<UnifyResultDto> UpsertTrackAsync(UpsertTrackInput input)
{
using var activity = ActivityHelper.CreateSpanActivity("UpsertTrack");
activity.SetTag("UpsertTrackInput", input.ToJson());
var order = await _orderRepository.GetFirstAsync(x =>
x.SubSystemId == input.SubSystemId
&& x.OrderType == input.OrderType
@ -338,6 +342,8 @@ public partial class TrackService : ApplicationService, ITrackService
[HttpPost("Track/BatchUpsert")]
public async Task<UnifyResultDto> BatchUpsertTrackAsync(BatchUpsertTrackInput input)
{
using var activity = ActivityHelper.CreateSpanActivity("BatchUpsert");
activity.SetTag("BatchUpsertTrackInput", input.ToJson());
input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空
var orders = await _orderRepository.GetListAsync(x =>
x.SubSystemId == input.SubSystemId