perf:根据指导建议优化性能
This commit is contained in:
parent
5e43bf37f8
commit
c5695dda2f
@ -117,7 +117,7 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
|
||||
}
|
||||
}
|
||||
|
||||
private bool CanDelete(TrackDeleteEvent @event)
|
||||
private static bool CanDelete(TrackDeleteEvent @event)
|
||||
{
|
||||
if (@event.OrderIds == null)
|
||||
return true;
|
||||
|
||||
@ -372,7 +372,7 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
|
||||
}
|
||||
|
||||
// 构建更新推送请求体
|
||||
private TrackUpdateInput BuiltUpdateItem(TrackPushContentConfigDto config, TrackPushRecordIndex log)
|
||||
private static TrackUpdateInput BuiltUpdateItem(TrackPushContentConfigDto config, TrackPushRecordIndex log)
|
||||
{
|
||||
var trackDatetime = log.TrackTime.AddHours(config.TrackTimeZone ?? log.TrackTimeZone - log.TrackTimeZone);
|
||||
var trackDateStr = DateTimeFormat(trackDatetime, config.TrackTimeZone ?? log.TrackTimeZone, config);
|
||||
|
||||
@ -130,7 +130,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
}
|
||||
}
|
||||
|
||||
private bool CanDelete(TrackUpsertEvent @event)
|
||||
private static bool CanDelete(TrackUpsertEvent @event)
|
||||
{
|
||||
// 系统创建的轨迹不允许修改
|
||||
if (@event.Visited.IsNullOrEmpty() && @event is { OperationMan: GlobalConst.SystemUser, IsAdd: false })
|
||||
@ -383,7 +383,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
}
|
||||
|
||||
|
||||
private TrackDetailsIndex BuiltUpdateTrack(TrackUpsertEvent @event, TrackDetailsIndex track, OrderIdentifier order,
|
||||
private static TrackDetailsIndex BuiltUpdateTrack(TrackUpsertEvent @event, TrackDetailsIndex track, OrderIdentifier order,
|
||||
TrackContentVO trackContent)
|
||||
{
|
||||
//外部轨迹,轨迹发生地,轨迹发生时间,轨迹发生时区,不允许更改
|
||||
@ -428,7 +428,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
return track;
|
||||
}
|
||||
|
||||
private TrackDetailsIndex BuiltNewTrack(TrackUpsertEvent @event, OrderIdentifier order, TrackContentVO trackContent)
|
||||
private static TrackDetailsIndex BuiltNewTrack(TrackUpsertEvent @event, OrderIdentifier order, TrackContentVO trackContent)
|
||||
{
|
||||
var track = new TrackDetailsIndex
|
||||
{
|
||||
@ -483,7 +483,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
return track;
|
||||
}
|
||||
|
||||
private OrderOperationRecordIndex BuildOrderOperationRecord(TrackUpsertEvent @event, TrackDetailsIndex track, OrderIdentifier order)
|
||||
private static OrderOperationRecordIndex BuildOrderOperationRecord(TrackUpsertEvent @event, TrackDetailsIndex track, OrderIdentifier order)
|
||||
{
|
||||
return new OrderOperationRecordIndex
|
||||
{
|
||||
|
||||
@ -49,7 +49,7 @@ public class TrackWarningCalcEventHandler : ITransientDependency, ICapSubscribe
|
||||
await _forewarningNotifyService.WarningCalculateAsync(BuiltWarningDto(orders, @event));
|
||||
}
|
||||
|
||||
private WarningDto BuiltWarningDto(List<OrderEntity> orders, TrackWarningCalcEvent @event)
|
||||
private static WarningDto BuiltWarningDto(List<OrderEntity> orders, TrackWarningCalcEvent @event)
|
||||
{
|
||||
return new WarningDto
|
||||
{
|
||||
|
||||
@ -204,7 +204,7 @@ public class MySubscribeExecutor : ISubscribeExecutor
|
||||
|
||||
#region tracing
|
||||
|
||||
private long? TracingBefore(Message message, MethodInfo method)
|
||||
private static long? TracingBefore(Message message, MethodInfo method)
|
||||
{
|
||||
if (s_diagnosticListener.IsEnabled(CapDiagnosticListenerNames.BeforeSubscriberInvoke))
|
||||
{
|
||||
@ -224,7 +224,7 @@ public class MySubscribeExecutor : ISubscribeExecutor
|
||||
return null;
|
||||
}
|
||||
|
||||
private void TracingAfter(long? tracingTimestamp, Message message, MethodInfo method)
|
||||
private static void TracingAfter(long? tracingTimestamp, Message message, MethodInfo method)
|
||||
{
|
||||
CapEventCounterSource.Log.WriteInvokeMetrics();
|
||||
if (tracingTimestamp != null &&
|
||||
@ -244,7 +244,7 @@ public class MySubscribeExecutor : ISubscribeExecutor
|
||||
}
|
||||
}
|
||||
|
||||
private void TracingError(long? tracingTimestamp, Message message, MethodInfo? method, Exception ex)
|
||||
private static void TracingError(long? tracingTimestamp, Message message, MethodInfo? method, Exception ex)
|
||||
{
|
||||
if (tracingTimestamp != null &&
|
||||
s_diagnosticListener.IsEnabled(CapDiagnosticListenerNames.ErrorSubscriberInvoke))
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
namespace SJZY.Track.Application.CAP;
|
||||
|
||||
internal class SubscriberExecutionFailedException : Exception
|
||||
internal sealed class SubscriberExecutionFailedException : Exception
|
||||
{
|
||||
private readonly Exception _originException;
|
||||
|
||||
|
||||
@ -476,7 +476,7 @@ public abstract class BasicCacheForPeriodicRefresh<TKey, TValue>
|
||||
|
||||
#endregion
|
||||
|
||||
private class CacheEntry
|
||||
private sealed class CacheEntry
|
||||
{
|
||||
private static readonly DateTime NoExpire = DateTime.MaxValue;
|
||||
public TValue? Data { get; set; }
|
||||
|
||||
@ -30,16 +30,14 @@ public class StringHelper
|
||||
public static string GetHash(string str)
|
||||
{
|
||||
// 将字符串转换为字节
|
||||
byte[] data = Encoding.UTF8.GetBytes(str);
|
||||
var data = Encoding.UTF8.GetBytes(str);
|
||||
|
||||
// 创建SHA256实例
|
||||
using SHA256 sha256 = SHA256.Create();
|
||||
// 计算哈希值
|
||||
byte[] hash = sha256.ComputeHash(data);
|
||||
var hash = SHA256.HashData(data);
|
||||
|
||||
// 将哈希值转换为16进制字符串
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (byte b in hash)
|
||||
var sb = new StringBuilder();
|
||||
foreach (var b in hash)
|
||||
{
|
||||
sb.Append(b.ToString("x2"));
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ public partial class OrderService : ApplicationService, IOrderService
|
||||
}
|
||||
|
||||
|
||||
private List<OrderPullStatusEntity> BuiltOrderPullStatus(List<PullConfigInfo>? pullConfigInfos)
|
||||
private static List<OrderPullStatusEntity> BuiltOrderPullStatus(List<PullConfigInfo>? pullConfigInfos)
|
||||
{
|
||||
if (pullConfigInfos == null) return new List<OrderPullStatusEntity>();
|
||||
|
||||
@ -178,7 +178,7 @@ public partial class OrderService : ApplicationService, IOrderService
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
private List<OrderPlatformNumberEntity> BuiltOrderPlatformNumbers(List<PullConfigInfo>? pullConfigInfos)
|
||||
private static List<OrderPlatformNumberEntity> BuiltOrderPlatformNumbers(List<PullConfigInfo>? pullConfigInfos)
|
||||
{
|
||||
if (pullConfigInfos == null) return new List<OrderPlatformNumberEntity>();
|
||||
|
||||
|
||||
@ -375,7 +375,7 @@ public partial class TrackService
|
||||
}
|
||||
|
||||
|
||||
private class TrackIdxWarp
|
||||
private sealed class TrackIdxWarp
|
||||
{
|
||||
public TrackDetail Track { get; set; }
|
||||
public int Index { get; set; }
|
||||
@ -388,7 +388,7 @@ public partial class TrackService
|
||||
}
|
||||
|
||||
|
||||
private class TrackWrap
|
||||
private sealed class TrackWrap
|
||||
{
|
||||
public TrackDetail Track { get; set; }
|
||||
|
||||
|
||||
@ -312,7 +312,7 @@ public class TrackOrderService : ApplicationService
|
||||
return (long) (time - sTime).TotalMilliseconds;
|
||||
}
|
||||
|
||||
private string GetTimeZoneStr(float timeZone)
|
||||
private static string GetTimeZoneStr(float timeZone)
|
||||
{
|
||||
var time = timeZone.ToString().Split('.');
|
||||
if (time.Length > 1 && time[1] != "0") //如果时区有小数点
|
||||
|
||||
@ -62,6 +62,6 @@ public class TrackPullCacheService : ITransientDependency, ITrackPullCacheServic
|
||||
return data;
|
||||
}
|
||||
|
||||
public string TrackPullContentKey(int subSystemId, string serviceProviderCode) =>
|
||||
public static string TrackPullContentKey(int subSystemId, string serviceProviderCode) =>
|
||||
$"{GlobalConst.TrackPullContentKeyPrefix}:{subSystemId}:{serviceProviderCode}";
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ public class TrackPushCacheService : ITrackPushCacheService, ITransientDependenc
|
||||
return data;
|
||||
}
|
||||
|
||||
private string TrackPushContentKey(int subSystemId, int customId) =>
|
||||
private static string TrackPushContentKey(int subSystemId, int customId) =>
|
||||
$"{GlobalConst.TrackPushContentKeyPrefix}:{subSystemId}:{customId}";
|
||||
|
||||
private async Task<List<TrackPushContentConfigDto>?> DoGetPushContentConfigsAsync(int subSystemId, int customId)
|
||||
|
||||
@ -18,5 +18,5 @@ public partial class GlobalConst
|
||||
|
||||
public const string CapNoRetryErrorCode = "599";
|
||||
|
||||
public static DateTime MaxDateTime = new DateTime(2999, 1, 1, 0, 0, 0);
|
||||
public static readonly DateTime MaxDateTime = new DateTime(2999, 1, 1, 0, 0, 0);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user