From 4b0acb1978c89bdca231b08ad3da0398f50b8d92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Tue, 14 May 2024 17:17:14 +0800
Subject: [PATCH 1/2] =?UTF-8?q?opt=EF=BC=9A=E4=BC=98=E5=8C=96=E8=BD=A8?=
=?UTF-8?q?=E8=BF=B9=E5=88=B7=E6=96=B0=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?=
=?UTF-8?q?=E7=AD=89=E5=BE=85=E8=B6=85=E6=97=B6=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ProvideServices/TrackPullService.cs | 68 ++++++++++---------
1 file changed, 36 insertions(+), 32 deletions(-)
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
index d7f71038..cb7cd5e1 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
@@ -78,46 +78,50 @@ public class TrackPullService : ApplicationService
///
[AllowAnonymous]
[HttpPost("Track/RefreshForTask")]
- public async Task 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;
}
From 505d8e7dc1ed16e2ec52a38046869fd26ec9bb95 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Tue, 14 May 2024 17:17:37 +0800
Subject: [PATCH 2/2] =?UTF-8?q?add=EF=BC=9A=E6=B7=BB=E5=8A=A0cap=E6=9C=AC?=
=?UTF-8?q?=E5=9C=B0=E5=86=85=E5=AD=98debug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/SJZY.Track.Application/SJZY.Track.Application.csproj | 2 ++
src/SJZY.Track.Application/SjzyTrackApplicationModule.cs | 7 ++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/SJZY.Track.Application/SJZY.Track.Application.csproj b/src/SJZY.Track.Application/SJZY.Track.Application.csproj
index b2801d4a..982969a4 100644
--- a/src/SJZY.Track.Application/SJZY.Track.Application.csproj
+++ b/src/SJZY.Track.Application/SJZY.Track.Application.csproj
@@ -21,6 +21,8 @@
+
+
diff --git a/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs b/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs
index 2984ac45..fa522c48 100644
--- a/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs
+++ b/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs
@@ -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("CAP:PrefetchCount"));
});
- // options.TopicNamePrefix = "v1";
+#endif
options.FailedRetryInterval = configuration.GetValue("CAP:FailedRetryInterval");
options.FailedRetryCount = configuration.GetValue("CAP:FailedRetryCount");
options.SucceedMessageExpiredAfter = configuration.GetValue("CAP:SucceedMessageExpiredAfter");