using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Options;
using SJZY.Expand.ABP.Core.Logger;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.InterfaceRelay.Application.Contracts;
using TrackCenter.Application.Contract.Dtos.ProvideServices;
using TrackCenter.Application.Contract.Dtos.TrackPull;
using TrackCenter.Application.Contract.Services.ProvideServices;
using TrackCenter.Application.Helpers;
using TrackCenter.Application.Options;
using TrackCenter.Application.Rabbit;
using TrackCenter.Application.Track2InterfaceRelay;
using TrackCenter.Domain.Queries;
using Volo.Abp.Http.Client.DynamicProxying;
namespace TrackCenter.Application.Services.ProvideServices;
///
/// 轨迹刷新服务
///
[ApiExplorerSettings(GroupName = "提供接口")]
[Route("/ProviderService")]
public class TrackPullService : ApplicationService, ITrackPullService
{
private readonly IHttpClientProxy _httpClientProxy;
private readonly IOptionsMonitor _options;
private readonly IProvideQueries _provideQueries;
public TrackPullService(IProvideQueries provideQueries,
IHttpClientProxy httpClientProxy,
IOptionsMonitor options)
{
_provideQueries = provideQueries;
_httpClientProxy = httpClientProxy;
_options = options;
}
///
/// 手动刷新轨迹
///
///
///
[HttpPost("Track/Refresh")]
public async Task RefreshTrackAsync(RefreshTrackInput input)
{
// todo:罚时?
input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空
// tips:这里没有区分订单类型,就算的不同类型的单一起刷新了也无所谓
var orders = await _provideQueries.FindOrderWithServiceProviderAsync(input.SubSystemId, input.OrderNos);
if (orders.Count == 0)
{
// tips:可能是没有配置、或者所有单都刷完了、或者单不存在
throw new BusinessException(message: "一个能更新的都没有");
}
foreach (var group in orders.GroupBy(x =>
new
{
x.ServiceProviderCode,
x.SubSystemId,
x.SubSystemCode,
x.OrderType
}))
{
var data = new List