From ec04a43d44d5f5bf44dbd071e6a831176a7ff51f Mon Sep 17 00:00:00 2001
From: xiaolipro <2357729423@qq.com>
Date: Tue, 8 Oct 2024 10:35:43 +0800
Subject: [PATCH] try
---
.../SJZY.Track.Application.csproj | 2 +-
.../Services/DebugApis/OTelService.cs | 7 +++----
.../ForewarningNotifyService.cs | 14 ++++++++------
.../Services/TrackOrders/OrderWarningService.cs | 3 +++
.../SjzyTrackApplicationModule.cs | 6 ------
.../Dtos/Forewarning/GetWarningNotifiesVo.cs | 6 +++++-
.../Queries/WarningQueries.cs | 1 +
7 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/src/SJZY.Track.Application/SJZY.Track.Application.csproj b/src/SJZY.Track.Application/SJZY.Track.Application.csproj
index d64b7d17..926a7d69 100644
--- a/src/SJZY.Track.Application/SJZY.Track.Application.csproj
+++ b/src/SJZY.Track.Application/SJZY.Track.Application.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/src/SJZY.Track.Application/Services/DebugApis/OTelService.cs b/src/SJZY.Track.Application/Services/DebugApis/OTelService.cs
index 8e2a9ddf..7770d26f 100644
--- a/src/SJZY.Track.Application/Services/DebugApis/OTelService.cs
+++ b/src/SJZY.Track.Application/Services/DebugApis/OTelService.cs
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Authorization;
-using SJZY.OTel;
using SJZY.Track.Domain.Aggregates.OrderAggregate;
namespace SJZY.Track.Application.Services.DebugApis;
@@ -15,7 +14,7 @@ public class OTelService : ApplicationService
_orderRepository = orderRepository;
}
- [OTel]
+ // [OTel]
public async Task Hello(string name)
{
var order = await _orderRepository.GetFirstAsync(x => true);
@@ -29,7 +28,7 @@ public class OTelService : ApplicationService
return $"hello {name}";
}
- [OTel]
+ // [OTel]
private async Task DoSomethingAsync(OrderEntity order)
{
var order2 = await _orderRepository.GetFirstAsync(x => true);
@@ -43,7 +42,7 @@ public class OTelService : ApplicationService
await DoWorkAsync();
}
- [OTel]
+ // [OTel]
private async Task DoWorkAsync()
{
await Task.Delay(1000);
diff --git a/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningNotifyService.cs b/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningNotifyService.cs
index 6c6b16ae..c6019cfd 100644
--- a/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningNotifyService.cs
+++ b/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningNotifyService.cs
@@ -67,7 +67,7 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
var interval = (rule.TotalTimeSpan - rule.WarnTimeSpan) / rule.WarnCount;
var startTime = order.TrackTime.AddHours(rule.WarnTimeSpan);
- for (var i = 0; i < rule.WarnCount; i++)
+ for (var i = 1; i <= rule.WarnCount; i++)
{
var timestamp = GetTimestamp(startTime);
startTime = startTime.AddHours(interval);
@@ -83,7 +83,7 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
order
).ForEach(rule =>
{
- for (var i = 0; i < rule.WarnCount; i++)
+ for (var i = 1; i <= rule.WarnCount; i++)
{
dels.Add((rule.Id, order.Id, i));
}
@@ -135,12 +135,13 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
// 写入es预警记录
var warningRecords = await WriteWarningRecordAsync(entries, notifyRules);
- // 发通知
- await SendCoreAsync(subSystemId, entries, notifyRules);
-
// 移除已处理的预警
await RedisHelper.Client.ZRemRangeByScoreAsync(redisKey, 0, timestamp);
+ // 发通知
+ // tips:通知发送失败不应该影响预警记录的写入,可以进入重试队列
+ await SendCoreAsync(subSystemId, entries, notifyRules);
+
return warningRecords.Count;
}
@@ -161,6 +162,7 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
SubSystemId = rule.SubSystemId,
SubSystemName = rule.SubSystemName,
WarningName = rule.WarningName,
+ CustomId = rule.CustomId,
CustomName = rule.CustomName,
RuleId = entry.RuleId,
Rule = rule.ToString(),
@@ -275,7 +277,7 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
{
// todo:失败是否上报重试?
LogHelper.Error(
- $"{nameof(ForewarningNotifyService)} 发送{mode.ToString()}通知失败,用户:{userId},内容:\n{msgContent}\n失败报文:{res.ToJson()}");
+ $"{nameof(ForewarningNotifyService)} 发送{mode.ToString()}通知失败,用户:{userId}\n内容:\n{msgContent}\n失败报文:{res.ToJson()}");
}
}
diff --git a/src/SJZY.Track.Application/Services/TrackOrders/OrderWarningService.cs b/src/SJZY.Track.Application/Services/TrackOrders/OrderWarningService.cs
index 309c83a8..3afedec2 100644
--- a/src/SJZY.Track.Application/Services/TrackOrders/OrderWarningService.cs
+++ b/src/SJZY.Track.Application/Services/TrackOrders/OrderWarningService.cs
@@ -26,6 +26,7 @@ public class OrderWarningService : ApplicationService
///
///
///
+ [HttpGet("GetOrderWarningPageList/{userId:int?}")]
[HttpPost("GetOrderWarningPageList")]
public async Task> GetOrderWarningPageListAsync(
[FromBody] GetOrderWarningPageListVo inputVo, [FromQuery] int? userId)
@@ -64,6 +65,8 @@ public class OrderWarningService : ApplicationService
item.LatestTrackTime = order.LatestTrackTime;
item.LatestTrackPlace = order.LatestTrackPlace;
item.LatestTrackContent = order.LatestTrackContent;
+
+ list.Add(item);
});
return new UnifyPageResultDto(list, inputVo.PageIndex, inputVo.PageSize,
diff --git a/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs b/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs
index bf5d1ede..9a8cc79b 100644
--- a/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs
+++ b/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs
@@ -3,7 +3,6 @@ using DotNetCore.CAP;
using DotNetCore.CAP.Internal;
using Microsoft.Extensions.Configuration;
using RabbitMQ.Client;
-using Savorboard.CAP.InMemoryMessageQueue;
using SJZY.Expand.ABP.Core.Localization;
using SJZY.Expand.ABP.Core.Logger;
using SJZY.Expand.ABP.Core.PublicMethords;
@@ -84,10 +83,6 @@ public class SjzyTrackApplicationModule : AbpModule
context.Services.AddCapTableNameService();
context.Services.AddCap(options =>
{
-#if DEBUG
- options.UseInMemoryStorage();
- options.UseInMemoryMessageQueue();
-#else
options.UseMySql(configuration["ConnectionStrings:DefaultConnection"]!);
options.UseRabbitMQ(configure =>
{
@@ -98,7 +93,6 @@ public class SjzyTrackApplicationModule : AbpModule
configure.BasicQosOptions =
new RabbitMQOptions.BasicQos(configuration.GetValue("CAP:PrefetchCount"));
});
-#endif
options.FailedRetryInterval = configuration.GetValue("CAP:FailedRetryInterval");
options.FailedRetryCount = configuration.GetValue("CAP:FailedRetryCount");
options.SucceedMessageExpiredAfter = configuration.GetValue("CAP:SucceedMessageExpiredAfter");
diff --git a/src/SJZY.Track.Domain/Dtos/Forewarning/GetWarningNotifiesVo.cs b/src/SJZY.Track.Domain/Dtos/Forewarning/GetWarningNotifiesVo.cs
index e5bf5290..1d917c96 100644
--- a/src/SJZY.Track.Domain/Dtos/Forewarning/GetWarningNotifiesVo.cs
+++ b/src/SJZY.Track.Domain/Dtos/Forewarning/GetWarningNotifiesVo.cs
@@ -26,6 +26,11 @@ public class GetWarningNotifiesVo
///
public string WarningName { get; set; } = null!;
+ ///
+ /// 客户id
+ ///
+ public int CustomId { get; set; }
+
///
/// 客户简称
///
@@ -103,7 +108,6 @@ public class GetWarningNotifiesVo
///
public string FactorTypeSort { get; set; } = null!;
-
public override string ToString()
{
// {起飞-落地+普货+1/2/3/4+美国 时效9,预警时效7,次数3}
diff --git a/src/SJZY.Track.Repository/Queries/WarningQueries.cs b/src/SJZY.Track.Repository/Queries/WarningQueries.cs
index dbc92f75..7554e5f7 100644
--- a/src/SJZY.Track.Repository/Queries/WarningQueries.cs
+++ b/src/SJZY.Track.Repository/Queries/WarningQueries.cs
@@ -30,6 +30,7 @@ public class WarningQueries : ISugarRepository, IWarningQueries,
SubSystemName = system.CnName,
RuleId = wr.Id,
WarningName = w.Name,
+ CustomId = w.CustomerId,
CustomName = cus.Name,
TotalTimeSpan = wr.TotalTimeSpan,
WarnTimeSpan = wr.WarnTimeSpan,