fix:轨迹刷新
This commit is contained in:
parent
a3c4199a30
commit
5a90c99f51
@ -1,5 +1,8 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SJZY.Expand.ABP.Core;
|
||||
using SJZY.Expand.ABP.Core.Logger;
|
||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
using SJZY.InterfaceRelay.Application.Contracts;
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
@ -78,42 +81,39 @@ public class TrackPullService : ApplicationService
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpPost("Track/RefreshForTask")]
|
||||
public bool RefreshForTaskAsync()
|
||||
{
|
||||
Task.Run(async () =>
|
||||
public async Task<bool> RefreshForTaskAsync()
|
||||
{
|
||||
var configs = await _trackPullCacheService.GetAllPullConfigsAsync();
|
||||
var tasks = configs.Select(RefreshForConfigAsync).ToArray();
|
||||
await Task.WhenAll(tasks);
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (var config in configs)
|
||||
private async Task RefreshForConfigAsync(TrackPullConfigDto config)
|
||||
{
|
||||
var redisKey = _trackPullCacheService.TrackPullKey(config.SubSystemId, config.ServiceProviderId);
|
||||
if (await RedisHelper.Client.ExistsAsync(redisKey))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
var page = 1;
|
||||
var orders = await _provideQueries.FindOrderWithServiceProviderAsync(config.ServiceProviderId, page);
|
||||
var orders = await _provideQueries.FindOrderWithServiceProviderAsync(config.ServiceProviderId, page, 2000);
|
||||
while (orders.Any())
|
||||
{
|
||||
var serviceProviderCode = orders.FirstOrDefault()?.ServiceProviderCode;
|
||||
var serviceProviderName = orders.FirstOrDefault()?.ServiceProviderName;
|
||||
|
||||
foreach (var group in orders.GroupBy(x =>
|
||||
new { x.SubSystemId, x.OrderType }))
|
||||
foreach (var group in orders.GroupBy(x => new { x.SubSystemId, x.OrderType }))
|
||||
{
|
||||
var data = group.Select(x => new
|
||||
{
|
||||
x.OrderNo
|
||||
}).ToList();
|
||||
var data = group.Select(x => new { x.OrderNo }).ToList();
|
||||
var attach = Base64Helper.SerializeObject(new TrackRefreshAttach(config.ServiceProviderId, serviceProviderName!, group.Key.SubSystemId, group.Key.OrderType));
|
||||
var res = await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(InterfaceRelayConst.GetTrackInterfaceCode, serviceProviderCode, data, GlobalConst.TrackRefreshSubscribe, attach);
|
||||
|
||||
var attach = Base64Helper.SerializeObject(new TrackRefreshAttach(config.ServiceProviderId,
|
||||
serviceProviderName!,
|
||||
group.Key.SubSystemId, group.Key.OrderType));
|
||||
// 批量获取轨迹
|
||||
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
|
||||
InterfaceRelayConst.GetTrackInterfaceCode, serviceProviderCode, data,
|
||||
GlobalConst.TrackRefreshSubscribe, attach);
|
||||
if (res.Code != InterfaceRelayConst.SuccessCode)
|
||||
{
|
||||
LogHelper.Error($"刷新轨迹失败:{res.ToJson()}");
|
||||
}
|
||||
}
|
||||
|
||||
orders = await _provideQueries.FindOrderWithServiceProviderAsync(config.ServiceProviderId, ++page);
|
||||
@ -121,8 +121,4 @@ public class TrackPullService : ApplicationService
|
||||
|
||||
await RedisHelper.Client.SetExAsync(redisKey, config.PullInterval * 60, orders.Count);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -32,7 +32,6 @@ public class TrackPushService : ApplicationService
|
||||
_capPublisher = capPublisher;
|
||||
_trackPushRecordsRepository = trackPushRecordsRepository;
|
||||
_requestCurrentUserService = requestCurrentUserService;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user