Merge branch 'S07' into test
This commit is contained in:
commit
33c3df11b0
@ -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"));
|
||||
}
|
||||
|
||||
@ -70,6 +70,7 @@ public sealed class WarningCalcBackgroundService : BackgroundService
|
||||
{
|
||||
_activity?.SetTag("HandleTime", _stopwatch.ElapsedMilliseconds);
|
||||
_activity?.Dispose();
|
||||
_activity = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,8 +98,6 @@ public sealed class WarningCalcBackgroundService : BackgroundService
|
||||
|
||||
// 提交内存中所有的偏移到服务器,适用于EnableAutoCommit为false的手动提交场景
|
||||
_consumer.Commit();
|
||||
_activity.Dispose();
|
||||
_activity = null;
|
||||
}
|
||||
|
||||
private async ValueTask MessageHandler(IEnumerable<Message<WarningSignalKey, WarningSignal>> messages, CancellationToken ct)
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
using Nest;
|
||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
using SJZY.Expand.ElasticSearch.Services;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
using SJZY.Track.Domain.Dtos.TrackDetails;
|
||||
using SJZY.Track.Domain.Enums;
|
||||
@ -851,12 +853,35 @@ public class TrackDetailsEsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
|
||||
public async Task MigrateAsync()
|
||||
{
|
||||
await Context.MapAsync<TrackDetailsIndex>(m => m
|
||||
.AutoMap());
|
||||
//字段迁移,isVisibility => isExternal
|
||||
await Context.UpdateByQueryAsync<TrackDetailsIndex>(u => u
|
||||
.Query(q => q.MatchAll())
|
||||
.Script(s => s.Source("ctx._source.isExternal = ctx._source.isVisibility"))
|
||||
var indexName1 = $"{GlobalConst.TrackDetailsIndex}-{DateTime.Now:yyyy.MM.dd}";
|
||||
var indexName2 = $"{GlobalConst.TrackPushRecordIndex}-{DateTime.Now:yyyy.MM.dd}";
|
||||
var indexName3 = $"{GlobalConst.OrderOperationRecordIndex}-{DateTime.Now:yyyy.MM.dd}";
|
||||
|
||||
var exists1 = await Context.Indices.ExistsAsync(indexName1);
|
||||
if (!exists1.Exists)
|
||||
{
|
||||
await Context.Indices.CreateAsync(indexName1);
|
||||
await Context.MapAsync<TrackDetailsIndex>(m => m.Index(indexName1).AutoMap());
|
||||
}
|
||||
|
||||
var exists2 = await Context.Indices.ExistsAsync(indexName2);
|
||||
if (!exists2.Exists)
|
||||
{
|
||||
await Context.Indices.CreateAsync(indexName2);
|
||||
await Context.MapAsync<TrackPushRecordIndex>(m => m.Index(indexName2).AutoMap());
|
||||
}
|
||||
|
||||
var exists3 = await Context.Indices.ExistsAsync(indexName3);
|
||||
if (!exists3.Exists)
|
||||
{
|
||||
await Context.Indices.CreateAsync(indexName3);
|
||||
await Context.MapAsync<OrderOperationRecordIndex>(m => m.Index(indexName3).AutoMap());
|
||||
}
|
||||
|
||||
var r = await Context.Indices.BulkAliasAsync(b =>
|
||||
b.Add(a => a.Alias(GlobalConst.TrackDetailsIndex).Index(indexName1))
|
||||
.Add(a => a.Alias(GlobalConst.TrackPushRecordIndex).Index(indexName2))
|
||||
.Add(a => a.Alias(GlobalConst.OrderOperationRecordIndex).Index(indexName3))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user