Merge remote-tracking branch 'origin/S03-轨迹中台优化项' into test
This commit is contained in:
commit
2e67b13756
@ -21,6 +21,8 @@
|
||||
<PackageReference Include="DotNetCore.CAP.Dashboard" Version="8.1.2"/>
|
||||
<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="8.1.2"/>
|
||||
<PackageReference Include="DotNetCore.CAP.MySql" Version="8.1.2"/>
|
||||
<PackageReference Include="DotNetCore.CAP.InMemoryStorage" Version="8.1.2"/>
|
||||
<PackageReference Include="Savorboard.CAP.InMemoryMessageQueue" Version="7.0.0"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -78,46 +78,50 @@ public class TrackPullService : ApplicationService
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpPost("Track/RefreshForTask")]
|
||||
public async Task<bool> RefreshForTaskAsync()
|
||||
public bool RefreshForTaskAsync()
|
||||
{
|
||||
var configs = await _trackPullCacheService.GetAllPullConfigsAsync();
|
||||
foreach (var config in configs)
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var redisKey = _trackPullCacheService.TrackPullKey(config.SubSystemId, config.ServiceProviderId);
|
||||
if (await RedisHelper.Client.ExistsAsync(redisKey))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var configs = await _trackPullCacheService.GetAllPullConfigsAsync();
|
||||
|
||||
var page = 1;
|
||||
var orders = await _provideQueries.FindOrderWithServiceProviderAsync(config.ServiceProviderId, page);
|
||||
while (orders.Any())
|
||||
foreach (var config in configs)
|
||||
{
|
||||
var serviceProviderCode = orders.FirstOrDefault()?.ServiceProviderCode;
|
||||
var serviceProviderName = orders.FirstOrDefault()?.ServiceProviderName;
|
||||
|
||||
foreach (var group in orders.GroupBy(x =>
|
||||
new { x.SubSystemId, x.OrderType }))
|
||||
var redisKey = _trackPullCacheService.TrackPullKey(config.SubSystemId, config.ServiceProviderId);
|
||||
if (await RedisHelper.Client.ExistsAsync(redisKey))
|
||||
{
|
||||
var data = group.Select(x => new
|
||||
{
|
||||
x.OrderNo
|
||||
}).ToList();
|
||||
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
|
||||
orders = await _provideQueries.FindOrderWithServiceProviderAsync(config.ServiceProviderId, ++page);
|
||||
}
|
||||
var page = 1;
|
||||
var orders = await _provideQueries.FindOrderWithServiceProviderAsync(config.ServiceProviderId, page);
|
||||
while (orders.Any())
|
||||
{
|
||||
var serviceProviderCode = orders.FirstOrDefault()?.ServiceProviderCode;
|
||||
var serviceProviderName = orders.FirstOrDefault()?.ServiceProviderName;
|
||||
|
||||
await RedisHelper.Client.SetExAsync(redisKey, config.PullInterval * 60, orders.Count);
|
||||
}
|
||||
foreach (var group in orders.GroupBy(x =>
|
||||
new { x.SubSystemId, x.OrderType }))
|
||||
{
|
||||
var data = group.Select(x => new
|
||||
{
|
||||
x.OrderNo
|
||||
}).ToList();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
orders = await _provideQueries.FindOrderWithServiceProviderAsync(config.ServiceProviderId, ++page);
|
||||
}
|
||||
|
||||
await RedisHelper.Client.SetExAsync(redisKey, config.PullInterval * 60, orders.Count);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using DotNetCore.CAP;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Savorboard.CAP.InMemoryMessageQueue;
|
||||
using SJZY.Expand.ABP.Core.Localization;
|
||||
using SJZY.Expand.ABP.Core.Logger;
|
||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
@ -76,6 +77,10 @@ namespace SJZY.Track.Application
|
||||
context.Services.AddCapTableNameService();
|
||||
context.Services.AddCap(options =>
|
||||
{
|
||||
#if DEBUG
|
||||
options.UseInMemoryStorage();
|
||||
options.UseInMemoryMessageQueue();
|
||||
#else
|
||||
options.UseMySql(configuration["ConnectionStrings:DefaultConnection"]!);
|
||||
options.UseRabbitMQ(configure =>
|
||||
{
|
||||
@ -86,7 +91,7 @@ namespace SJZY.Track.Application
|
||||
configure.BasicQosOptions =
|
||||
new RabbitMQOptions.BasicQos(configuration.GetValue<ushort>("CAP:PrefetchCount"));
|
||||
});
|
||||
// options.TopicNamePrefix = "v1";
|
||||
#endif
|
||||
options.FailedRetryInterval = configuration.GetValue<int>("CAP:FailedRetryInterval");
|
||||
options.FailedRetryCount = configuration.GetValue<int>("CAP:FailedRetryCount");
|
||||
options.SucceedMessageExpiredAfter = configuration.GetValue<int>("CAP:SucceedMessageExpiredAfter");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user