【4.对外轨迹查询轨迹的接口】

https://www.tapd.cn/60863849/prong/tasks/view/1160863849001027880
This commit is contained in:
xiaolipro 2024-09-03 17:41:33 +08:00
parent 9754923c63
commit fae534a256
4 changed files with 43 additions and 14 deletions

View File

@ -34,9 +34,4 @@ public enum SortMethod
/// 按轨迹发生时间降序
/// </summary>
ByTrackTimeDesc,
/// <summary>
/// 按订单模板排序
/// </summary>
ByTemplate
}

View File

@ -17,6 +17,19 @@ public class TrackDetail
public string? Content { get; set; }
public string? OriginContent { get; set; }
public string Location { get; set; } = null!;
/// <summary>
/// 发生时间
/// </summary>
public DateTime Time { get; set; }
/// <summary>
/// 轨迹时区
/// </summary>
public float? TimeZone { get; set; }
/// <summary>
/// 是否对外
/// </summary>
public bool IsDisplay { get; set; }
}

View File

@ -1,6 +1,7 @@
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
using SJZY.Track.Domain.Consts;
using SJZY.UserCenter.HttpApi.Services;
namespace SJZY.Track.Application.Services.ProvideServices;
@ -25,11 +26,32 @@ public partial class TrackService
throw new BusinessException(message: "最多只能查询500单");
}
var subSystemId = CurrentUserRequest.SubSystemId;
var res = new List<GetTrackOutput>();
input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空
var details = await _trackDetailsRepository.GetListAsync(input.OrderType, input.OrderNos);
// 是否对外
var trackCodes = details.Select(x => x.TrackCode)
.Where(x => x != GlobalConst.EmptyString)
.Distinct()
.ToList();
var trackContentDic = new Dictionary<string, bool>();
if (!trackCodes.IsNullOrEmpty())
{
var trackContents = await _trackContentRepository.GetListAsync(x =>
x.SubSystemId == subSystemId && trackCodes.Contains(x.Code),
x => new
{
x.Code,
x.IsExternal
});
trackContents.ForEach(x => trackContentDic.Add(x.Code, x.IsExternal));
}
foreach (var group in details.GroupBy(x => x.OrderId))
{
var item = new GetTrackOutput();
@ -48,12 +70,14 @@ public partial class TrackService
: x.ZeroTrackTime.AddHours(input.TimeZone ?? 8),
TimeZone = Math.Abs(x.TrackTimeZone - GlobalConst.NoneTrackTimeZone) < 1
? null
: input.TimeZone ?? 8
: input.TimeZone ?? 8,
IsDisplay = trackContentDic.TryGetValue(x.TrackCode, out var isExternal) && isExternal
}).ToList();
res.Add(item);
}
// 排序
TracksOrdered(res, input);
return new UnifyResultDto<List<GetTrackOutput>>(true, res, "操作成功");
@ -70,8 +94,6 @@ public partial class TrackService
case SortMethod.ByTrackTimeDesc:
list.ForEach(item => item.TrackDetails.Sort((a, b) => b.Time.CompareTo(a.Time)));
break;
case SortMethod.ByTemplate:
break;
default:
throw new ArgumentOutOfRangeException(nameof(input.SortMethod), input.SortMethod, "不支持的排序方式");
}

View File

@ -3,9 +3,9 @@ using SJZY.Track.Application.Contract.Dtos.ProvideServices;
using SJZY.Track.Application.Contract.Events;
using SJZY.Track.Application.Contract.Services;
using SJZY.Track.Domain.Aggregates.OrderAggregate;
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
using SJZY.Track.Domain.Consts;
using SJZY.Track.Domain.Queries;
using SJZY.UserCenter.HttpApi.Services;
using Volo.Abp.Http.Client.DynamicProxying;
@ -20,17 +20,16 @@ public partial class TrackService : ApplicationService, ITrackService
{
private readonly ICapPublisher _capPublisher;
private readonly IOrderRepository _orderRepository;
private readonly IProvideQueries _provideQueries;
private readonly IHttpClientProxy<IRequestCurrentUserService> _requestCurrentUserService;
private readonly ITrackContentRepository _trackContentRepository;
public TrackService(IOrderRepository orderRepository, IProvideQueries provideQueries, ICapPublisher capPublisher,
ITrackDetailsRepository trackDetailsRepository,
public TrackService(IOrderRepository orderRepository, ICapPublisher capPublisher,
ITrackDetailsRepository trackDetailsRepository, ITrackContentRepository trackContentRepository,
IHttpClientProxy<IRequestCurrentUserService> requestCurrentUserService)
{
_orderRepository = orderRepository;
_provideQueries = provideQueries;
_provideQueries = provideQueries;
_capPublisher = capPublisher;
_trackContentRepository = trackContentRepository;
_requestCurrentUserService = requestCurrentUserService;
_trackDetailsRepository = trackDetailsRepository;
}