Merge branch 'refs/heads/S04轨迹预警' into test

This commit is contained in:
xiaolipro 2024-08-05 16:09:32 +08:00
commit 4590f4f01b
38 changed files with 259 additions and 223 deletions

View File

@ -25,6 +25,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution items", "solution
.gitignore = .gitignore
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SJZY.Track.Shared", "src\SJZY.Track.Shared\SJZY.Track.Shared.csproj", "{CB860739-8617-48C2-80E3-9F1FBC8D6980}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -55,6 +57,10 @@ Global
{073EB297-E752-49AC-BED8-B4AEBAB518F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{073EB297-E752-49AC-BED8-B4AEBAB518F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{073EB297-E752-49AC-BED8-B4AEBAB518F6}.Release|Any CPU.Build.0 = Release|Any CPU
{CB860739-8617-48C2-80E3-9F1FBC8D6980}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB860739-8617-48C2-80E3-9F1FBC8D6980}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB860739-8617-48C2-80E3-9F1FBC8D6980}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB860739-8617-48C2-80E3-9F1FBC8D6980}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -66,6 +72,7 @@ Global
{390A44FB-0DB5-4B66-86AB-7712DC3030F5} = {DAC93270-5A25-40E5-B851-E7CA398DBC31}
{3A53539C-4A85-4E5D-A071-7B4B193AB0E0} = {0E2537C3-6EF3-4085-9BD2-CF923E53F82A}
{073EB297-E752-49AC-BED8-B4AEBAB518F6} = {DAC93270-5A25-40E5-B851-E7CA398DBC31}
{CB860739-8617-48C2-80E3-9F1FBC8D6980} = {DAC93270-5A25-40E5-B851-E7CA398DBC31}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = { 8289A516 - 787C - 4D9D - B972 - E7047BDD206B}

View File

@ -1,9 +0,0 @@
using SJZY.Track.Domain.Dtos.Forewarning;
namespace SJZY.Track.Application.Contract.Dtos.Forewarning;
public class ClearRulCacheEvent
{
public List<RuleAreaBaseInfo> Items { get; set; }
}

View File

@ -1,5 +1,5 @@
using SJZY.Track.Domain.Dtos.Forewarning;
using SJZY.Track.Domain.Enums;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Application.Contract.Dtos.Forewarning;

View File

@ -1,5 +1,5 @@
using SJZY.Track.Domain.Dtos.Forewarning;
using SJZY.Track.Domain.Enums;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Application.Contract.Dtos.Forewarning;

View File

@ -1,5 +1,5 @@
using SJZY.Track.Domain.Dtos.Forewarning;
using SJZY.Track.Domain.Enums;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Application.Contract.Dtos.Forewarning;
@ -25,6 +25,7 @@ public class UpdateWarningInput
/// </summary>
public string NotifyTemplate { get; set; } = null!;
/// <summary>
/// 通知列表
/// </summary>

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json.Linq;
using SJZY.Track.Domain.Enums;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Domain.Dtos.Forewarning;

View File

@ -1,4 +1,4 @@
using SJZY.Track.Domain.Enums;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Application.Contract.Dtos.TrackPush;

View File

@ -1,4 +1,4 @@
using SJZY.Track.Domain.Enums;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Application.Contract.Dtos.TrackPush;

View File

@ -13,7 +13,10 @@
<PackageReference Include="Volo.Abp.Core" Version="7.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SJZY.Track.Domain\SJZY.Track.Domain.csproj" />
<ProjectReference Include="..\SJZY.Track.Shared\SJZY.Track.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Dtos\Common\" />
</ItemGroup>
</Project>

View File

@ -15,7 +15,7 @@ public class TrackPullAutoMapperProfile : Profile
.ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => false));
CreateMap<EditTrackPullContentInput, TrackPullContentConfigEntity>(MemberList.None)
.ForMember(dest => dest.TrackKeyword, opt => opt.MapFrom(src => string.Join(',', src.TrackKeywords)))
.ForMember(dest => dest.TrackZonePlaceValue, opt => opt.MapFrom(src => string.Join(',', src.TrackTimePlaceValue)))
.ForMember(dest => dest.TrackZonePlaceValue, opt => opt.MapFrom(src => src.TrackTimePlaceValue))
.ForMember(dest => dest.TrackKeywordReverse, opt => opt.MapFrom(src => string.Join(',', src.TrackKeywordReverses)));
CreateMap<GetTrackPullConfigDetailOutputVO, TrackPullParamConfigDto>(MemberList.None);
CreateMap<GetTrackPullContentListCacheVO, TrackPullContentConfigDto>(MemberList.None);

View File

@ -1,5 +1,4 @@
using System.Globalization;
using DotNetCore.CAP;
using DotNetCore.CAP;
using Newtonsoft.Json;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.InterfaceRelay.Application.Contracts;
@ -12,6 +11,7 @@ using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
using SJZY.Track.Domain.Consts;
using SJZY.Track.Domain.Enums;
using SJZY.Track.Share.Enums;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.DynamicProxying;
@ -21,11 +21,11 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
{
private readonly IHttpClientProxy<IInterfaceForwardServiceV2> _httpClientProxy;
private readonly IOrderRepository _orderRepository;
private readonly ITrackPushCacheService _trackPushCacheService;
private readonly ITrackDetailsRepository _trackDetailsRepository;
private readonly ITrackPushCacheService _trackPushCacheService;
private readonly ITrackPushRecordsRepository _trackPushRecordsRepository;
private List<TrackPushContentConfigDto> _pushConfigs = null!;
private List<OrderEntity> _orders = null!;
private List<TrackPushContentConfigDto> _pushConfigs = null!;
public TrackPushEventHandler(IHttpClientProxy<IInterfaceForwardServiceV2> httpClientProxy,
IOrderRepository orderRepository, ITrackPushCacheService trackPushCacheService,

View File

@ -2,11 +2,11 @@ using System.Dynamic;
using Nest;
using Newtonsoft.Json.Linq;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.Track.Application.Contract.Dtos.Common;
using SJZY.Track.Application.Contract.Dtos.Forewarning;
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
using SJZY.Track.Domain.Dtos.Common;
using SJZY.Track.Domain.Dtos.Forewarning;
using SJZY.Track.Domain.Enums;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Application.Helpers;

View File

@ -1,11 +1,8 @@
using Microsoft.Extensions.Hosting;
using SJZY.Expand.ABP.Core;
using SJZY.Track.Application.Contract.Dtos.Forewarning;
using SJZY.Track.Application.Contract.Events;
using SJZY.Track.Application.Contract.Services;
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
using SJZY.Track.Domain.Consts;
using SJZY.Track.Domain.Dtos.Forewarning;
using SJZY.UserCenter.SharedModel.Dtos.PHP.User;
namespace SJZY.Track.Application.HostServices;

View File

@ -1,8 +1,7 @@
using System.Collections.Concurrent;
using SJZY.Expand.ABP.Core;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.Track.Application.Contract.Dtos.Forewarning;
using SJZY.Track.Application.Contract.Services;
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
using SJZY.Track.Domain.Aggregates.KPIAreaAggregate;
using SJZY.Track.Domain.Consts;
using SJZY.Track.Domain.Dtos.Forewarning;
@ -13,25 +12,20 @@ namespace SJZY.Track.Application.Services.ForewarningServices;
public class ForewarningCacheService : IForewarningCacheService, ISingletonDependency
{
readonly IKpiAreaRepository _kpiAreaRepository;
private readonly IWarningQueries _warningQueries;
private const string GlobalWaningLockKey = "GlobalWaningLockKey_GlobalLock";
private readonly ConcurrentDictionary<int, List<AreaCacheEntry>> _areas = new();
readonly IKpiAreaRepository _kpiAreaRepository;
private readonly ConcurrentDictionary<string, List<ForewarningRuleCacheEntry>> _rules = new();
private readonly ConcurrentDictionary<int, List<AreaCacheEntry>> _areas = new();
private readonly IWarningQueries _warningQueries;
object _lock = new object();
public ForewarningCacheService(IKpiAreaRepository kpiAreaRepository, IWarningQueries warningQueries)
{
_kpiAreaRepository = kpiAreaRepository;
_warningQueries = warningQueries;
}
string WarningKey(int subSystemId, int customerId) =>
$"{GlobalConst.TrackWarningKeyPrefix}:{subSystemId}:{customerId}";
string AreaKey(int areaId) => $"{GlobalConst.TrackAreaKeyPrefix}:{areaId}";
public async Task<List<ForewarningRuleCacheEntry>?> GetRulesAsync(int subSystemId, int customerId)
{
var key = WarningKey(subSystemId, customerId);
@ -43,6 +37,58 @@ public class ForewarningCacheService : IForewarningCacheService, ISingletonDepen
return await GetRules(subSystemId, customerId);
}
public Task DeleteRulesAsync(int subSystemId, int customerId)
{
_rules.Remove(WarningKey(subSystemId, customerId),out _);
return Task.CompletedTask;
}
public Task Clear(ClearRulCacheEvent @event)
{
foreach (var item in @event.Items)
{
DeleteRulesAsync(item.SystemId, item.CustomerId);
}
return Task.CompletedTask;
}
public async Task ClearRedisBySystemIdAndCustomer(int subSystemId,int customerId)
{
await RedisHelper.Client.DelAsync(WarningKey(subSystemId, customerId));
var eventModel = new ClearRulCacheEvent
{
Items = new List<RuleAreaBaseInfo>()
{
new RuleAreaBaseInfo(subSystemId, customerId)
}
};
await PublishEvent(eventModel);
}
public async Task ClearRedisByAreaId(int areaId)
{
var baseInfos = await _warningQueries.GetWarningRuleByAreaId(areaId);
if(baseInfos==null||baseInfos.Count==0) return;
baseInfos = baseInfos.DistinctBy(val => WarningKey(val.SystemId, val.CustomerId)).ToList();
var willDelKeys = baseInfos.Select(val => WarningKey(val.SystemId, val.CustomerId)).ToArray();
await RedisHelper.Client.DelAsync(willDelKeys);
await RedisHelper.Client.DelAsync(AreaKey(areaId));
var eventModel = new ClearRulCacheEvent
{
Items = baseInfos
};
await PublishEvent(eventModel);
}
string WarningKey(int subSystemId, int customerId) =>
$"{GlobalConst.TrackWarningKeyPrefix}:{subSystemId}:{customerId}";
string AreaKey(int areaId) => $"{GlobalConst.TrackAreaKeyPrefix}:{areaId}";
private List<ForewarningRuleCacheEntry> WriteRules(List<WarningRuleCacheDto> rules)
{
List<ForewarningRuleCacheEntry> result = new List<ForewarningRuleCacheEntry>();
@ -118,13 +164,6 @@ public class ForewarningCacheService : IForewarningCacheService, ISingletonDepen
}
}
public Task DeleteRulesAsync(int subSystemId, int customerId)
{
_rules.Remove(WarningKey(subSystemId, customerId),out _);
return Task.CompletedTask;
}
private List<AreaCacheEntry>? GetAreaInfoByAreaId(int areaId)
{
if (_areas.TryGetValue(areaId, out var areaInfos)) return areaInfos;
@ -176,46 +215,6 @@ public class ForewarningCacheService : IForewarningCacheService, ISingletonDepen
return result;
}
public Task Clear(ClearRulCacheEvent @event)
{
foreach (var item in @event.Items)
{
DeleteRulesAsync(item.SystemId, item.CustomerId);
}
return Task.CompletedTask;
}
public async Task ClearRedisBySystemIdAndCustomer(int subSystemId,int customerId)
{
await RedisHelper.Client.DelAsync(WarningKey(subSystemId, customerId));
var eventModel = new ClearRulCacheEvent
{
Items = new List<RuleAreaBaseInfo>()
{
new RuleAreaBaseInfo(subSystemId, customerId)
}
};
await PublishEvent(eventModel);
}
public async Task ClearRedisByAreaId(int areaId)
{
var baseInfos = await _warningQueries.GetWarningRuleByAreaId(areaId);
if(baseInfos==null||baseInfos.Count==0) return;
baseInfos = baseInfos.DistinctBy(val => WarningKey(val.SystemId, val.CustomerId)).ToList();
var willDelKeys = baseInfos.Select(val => WarningKey(val.SystemId, val.CustomerId)).ToArray();
await RedisHelper.Client.DelAsync(willDelKeys);
await RedisHelper.Client.DelAsync(AreaKey(areaId));
var eventModel = new ClearRulCacheEvent
{
Items = baseInfos
};
await PublishEvent(eventModel);
}
private async Task PublishEvent(ClearRulCacheEvent @event)
{
await RedisHelper.Client.PublishAsync(GlobalConst.PublishNotifyChannelKey, @event.ToJson());

View File

@ -3,7 +3,9 @@ using FreeRedis;
using SJZY.Expand.ABP.Core;
using SJZY.Track.Application.Contract.Dtos.Forewarning;
using SJZY.Track.Application.Contract.Services;
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
using SJZY.Track.Domain.Consts;
using SJZY.Track.Domain.Dtos.Forewarning;
using SJZY.Track.Domain.Queries;
using Volo.Abp.DependencyInjection;
@ -78,6 +80,50 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
if (res == null) throw new BusinessException(message: "轨迹预警计算失败");
}
public async Task SendNotificationAsync()
{
var max = GetTimestamp(DateTime.Now);
var set = await RedisHelper.Client.ZRangeByScoreAsync(GlobalConst.ForewarningNotifyKey, 0, max);
if (set.IsNullOrEmpty()) return;
var entries = set.Select(x => new WarningNotifyCacheEntry(x)).ToList();
var ruleIds = entries.Select(x => x.RuleId).ToList();
var notifyRules = await _warningQueries.GetWarningNotifyRulesAsync(ruleIds);
/*
*
预警名称:字节全程时效
预警规则:
{起飞-落地+普货+12345678+美国 时效9,预警时效7,次数3} 命中订单总数:124,详情点击https://middlebusiness.pet.shijizhongyun.com/trajectoryCenter/trajectoryOrder
{清关-提货+普货+12345678+美国 时效4,预警时效3,次数1} 命中订单总数:3250,详情点击https://middlebusiness.pet.shijizhongyun.com/trajectoryCenter/trajectoryOrder
预警名称:字节全程时效
预警规则:
{起飞-落地+普货+12345678+美国 时效9,预警时效7,次数3} 命中订单总数:124,详情点击https://middlebusiness.pet.shijizhongyun.com/trajectoryCenter/trajectoryOrder
{清关-提货+普货+12345678+美国 时效4,预警时效3,次数1} 命中订单总数:3250,详情点击https://middlebusiness.pet.shijizhongyun.com/trajectoryCenter/trajectoryOrder
*/
foreach (var group in notifyRules.GroupBy(x => new { x.NotifyMode, x.NotifyUserId }))
{
var notifyContent = new StringBuilder();
foreach (var warningGroup in group.GroupBy(x => x.WarningName))
{
notifyContent.AppendLine($"预警名称:{warningGroup.Key}");
notifyContent.AppendLine($"预警规则:");
foreach (var rule in warningGroup.ToList())
{
var cnt = entries.Count(x => x.RuleId == rule.RuleId);
if (cnt > 0)
{
notifyContent.AppendLine(
$"{rule.ToString()} 命中订单总数:{cnt},详情点击https://middlebusiness.pet.shijizhongyun.com/trajectoryCenter/trajectoryOrder");
}
}
}
}
}
private static List<ForewarningRuleCacheEntry> MatchRule(List<ForewarningRuleCacheEntry> rules,
WarningOrderDto order)
{
@ -137,50 +183,6 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
return res;
}
public async Task SendNotificationAsync()
{
var max = GetTimestamp(DateTime.Now);
var set = await RedisHelper.Client.ZRangeByScoreAsync(GlobalConst.ForewarningNotifyKey, 0, max);
if (set.IsNullOrEmpty()) return;
var entries = set.Select(x => new WarningNotifyCacheEntry(x)).ToList();
var ruleIds = entries.Select(x => x.RuleId).ToList();
var notifyRules = await _warningQueries.GetWarningNotifyRulesAsync(ruleIds);
/*
*
预警名称:字节全程时效
预警规则:
{起飞-落地+普货+12345678+美国 时效9,预警时效7,次数3} 命中订单总数:124,详情点击https://middlebusiness.pet.shijizhongyun.com/trajectoryCenter/trajectoryOrder
{清关-提货+普货+12345678+美国 时效4,预警时效3,次数1} 命中订单总数:3250,详情点击https://middlebusiness.pet.shijizhongyun.com/trajectoryCenter/trajectoryOrder
预警名称:字节全程时效
预警规则:
{起飞-落地+普货+12345678+美国 时效9,预警时效7,次数3} 命中订单总数:124,详情点击https://middlebusiness.pet.shijizhongyun.com/trajectoryCenter/trajectoryOrder
{清关-提货+普货+12345678+美国 时效4,预警时效3,次数1} 命中订单总数:3250,详情点击https://middlebusiness.pet.shijizhongyun.com/trajectoryCenter/trajectoryOrder
*/
foreach (var group in notifyRules.GroupBy(x => new { x.NotifyMode, x.NotifyUserId }))
{
var notifyContent = new StringBuilder();
foreach (var warningGroup in group.GroupBy(x => x.WarningName))
{
notifyContent.AppendLine($"预警名称:{warningGroup.Key}");
notifyContent.AppendLine($"预警规则:");
foreach (var rule in warningGroup.ToList())
{
var cnt = entries.Count(x => x.RuleId == rule.RuleId);
if (cnt > 0)
{
notifyContent.AppendLine(
$"{rule.ToString()} 命中订单总数:{cnt},详情点击https://middlebusiness.pet.shijizhongyun.com/trajectoryCenter/trajectoryOrder");
}
}
}
}
}
private static long GetTimestamp(DateTime dateTime)
{
return new DateTimeOffset(dateTime).ToUnixTimeSeconds();

View File

@ -1,10 +1,10 @@
using System.ComponentModel.DataAnnotations;
using SJZY.Track.Application.Contract.Dtos.Common;
using SJZY.Track.Application.Contract.Dtos.Forewarning;
using SJZY.Track.Application.Contract.Services;
using SJZY.Track.Application.Helpers;
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
using SJZY.Track.Domain.Dtos.Common;
using SJZY.Track.Domain.Dtos.Forewarning;
using SJZY.Track.Domain.Dtos.TrackStatus;
using SJZY.Track.Domain.Queries;

View File

@ -1,4 +1,4 @@
using SJZY.Track.Application.Contract.Services;
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
using SJZY.Track.Domain.Aggregates.KPIAreaAggregate;
using SJZY.Track.Domain.Dtos.Forewarning;

View File

@ -1,5 +1,8 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Logging;
using SJZY.Expand.ABP.Core;
using SJZY.Expand.ABP.Core.Logger;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.InterfaceRelay.Application.Contracts;
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
using SJZY.Track.Application.Contract.Dtos.TrackPull;
@ -78,51 +81,44 @@ public class TrackPullService : ApplicationService
/// <returns></returns>
[AllowAnonymous]
[HttpPost("Track/RefreshForTask")]
public bool RefreshForTaskAsync()
public async Task<bool> RefreshForTaskAsync()
{
Task.Run(async () =>
{
var configs = await _trackPullCacheService.GetAllPullConfigsAsync();
foreach (var config in configs)
{
var redisKey = _trackPullCacheService.TrackPullKey(config.SubSystemId, config.ServiceProviderId);
if (await RedisHelper.Client.ExistsAsync(redisKey))
{
continue;
}
var page = 1;
var orders = await _provideQueries.FindOrderWithServiceProviderAsync(config.ServiceProviderId, page);
while (orders.Any())
{
var serviceProviderCode = orders.FirstOrDefault()?.ServiceProviderCode;
var serviceProviderName = orders.FirstOrDefault()?.ServiceProviderName;
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);
}
});
var configs = await _trackPullCacheService.GetAllPullConfigsAsync();
var tasks = configs.Select(RefreshForConfigAsync).ToArray();
await Task.WhenAll(tasks);
return true;
}
private async Task RefreshForConfigAsync(TrackPullConfigDto config)
{
var redisKey = _trackPullCacheService.TrackPullKey(config.SubSystemId, config.ServiceProviderId);
if (await RedisHelper.Client.ExistsAsync(redisKey))
{
return;
}
var page = 1;
var orders = await _provideQueries.FindOrderWithServiceProviderAsync(config.ServiceProviderId, page, 2000);
while (orders.Any())
{
var serviceProviderCode = orders.FirstOrDefault()?.ServiceProviderCode;
var serviceProviderName = orders.FirstOrDefault()?.ServiceProviderName;
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));
var res = await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(InterfaceRelayConst.GetTrackInterfaceCode, serviceProviderCode, data, GlobalConst.TrackRefreshSubscribe, attach);
if (res.Code != InterfaceRelayConst.SuccessCode)
{
LogHelper.Error($"刷新轨迹失败:{res.ToJson()}");
}
}
orders = await _provideQueries.FindOrderWithServiceProviderAsync(config.ServiceProviderId, ++page);
}
await RedisHelper.Client.SetExAsync(redisKey, config.PullInterval * 60, orders.Count);
}
}

View File

@ -32,7 +32,6 @@ public class TrackPushService : ApplicationService
_capPublisher = capPublisher;
_trackPushRecordsRepository = trackPushRecordsRepository;
_requestCurrentUserService = requestCurrentUserService;
}
/// <summary>
@ -92,7 +91,7 @@ public class TrackPushService : ApplicationService
[HttpPost("Track/PushWarnForTask")]
public async Task<string> PushWarnForTaskAsync()
{
int total = 0, pageSize = 1000,waitTime = 1000;
int total = 0, pageSize = 1000, waitTime = 1000;
var dateTimes = Enumerable.Range(1, 12).Select(val => DateTime.Now.AddHours(-val)).ToList();
foreach (var dateTime in dateTimes)
@ -101,11 +100,11 @@ public class TrackPushService : ApplicationService
var pageindex = 1;
do
{
rows = await _orderRepository.PushWarnOrdersAsync(pageSize,pageindex,dateTime);
total+=rows;
rows = await _orderRepository.PushWarnOrdersAsync(pageSize, pageindex, dateTime);
total += rows;
pageindex++;
await Task.Delay(waitTime);
}while (rows!= pageSize);
} while (rows != pageSize);
}
return $"本次预警扫描了:{total}个订单";

View File

@ -1,6 +1,6 @@
using SJZY.Track.Application.Contract.Dtos.Forewarning;
using SJZY.Track.Domain.Dtos.Forewarning;
namespace SJZY.Track.Application.Contract.Services;
namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate;
public interface IForewarningCacheService
{

View File

@ -1,4 +1,4 @@
using SJZY.Track.Domain.Enums;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate;

View File

@ -1,4 +1,5 @@
using SJZY.Track.Domain.Enums;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate;

View File

@ -1,3 +1,5 @@
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate;
[SugarTable("t_warning_rule")]
@ -92,4 +94,16 @@ public class WarningRuleEntity : IFullAuditedBasicEntitys, IEntity
/// </summary>
[SugarColumn(ColumnName = "ProductCode")]
public string? ProductCode { get; set; }
/// <summary>
/// 通知方式
/// </summary>
[SugarColumn(ColumnName = "NotifyMode")]
public NotifyMode NotifyMode { get; set; }
/// <summary>
/// 通知人
/// </summary>
[SugarColumn(ColumnName = "NotifyUserId")]
public int NotifyUserId { get; set; }
}

View File

@ -1,4 +1,4 @@
using SJZY.Track.Domain.Enums;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Domain.Aggregates.TrackPushAggregate;

View File

@ -1,4 +1,4 @@
namespace SJZY.Track.Application.Contract.Dtos.Common;
namespace SJZY.Track.Domain.Dtos.Common;
public class IdWithNameDto
{

View File

@ -1,4 +1,4 @@
namespace SJZY.Track.Application.Contract.Dtos.Forewarning;
namespace SJZY.Track.Domain.Dtos.Forewarning;
public class AreaCacheEntry
{

View File

@ -0,0 +1,7 @@
namespace SJZY.Track.Domain.Dtos.Forewarning;
public class ClearRulCacheEvent
{
public List<RuleAreaBaseInfo> Items { get; set; }
}

View File

@ -1,4 +1,4 @@
namespace SJZY.Track.Application.Contract.Dtos.Forewarning;
namespace SJZY.Track.Domain.Dtos.Forewarning;
public class ForewarningRuleCacheEntry
{

View File

@ -1,6 +1,6 @@
using System.Text;
using NUglify.Helpers;
using SJZY.Track.Domain.Enums;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Domain.Dtos.Forewarning;

View File

@ -1,4 +1,4 @@
using SJZY.Track.Domain.Enums;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Domain.Dtos.TrackPush;

View File

@ -17,4 +17,8 @@
<Compile Remove="Aggregates\ForewarningAggregate\RuleAreaEntity.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SJZY.Track.Shared\SJZY.Track.Shared.csproj" />
</ItemGroup>
</Project>

View File

@ -6,6 +6,7 @@ using SJZY.Track.Domain.Dtos.Common;
using SJZY.Track.Domain.Dtos.TrackPush;
using SJZY.Track.Domain.Enums;
using SJZY.Track.Domain.VEntities;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Repository.Repositories;

View File

@ -15,6 +15,7 @@
<ItemGroup>
<ProjectReference Include="..\SJZY.Track.Domain\SJZY.Track.Domain.csproj" />
<ProjectReference Include="..\SJZY.Track.Shared\SJZY.Track.Shared.csproj" />
</ItemGroup>
<ItemGroup>

View File

@ -1,4 +1,4 @@
namespace SJZY.Track.Domain.Enums;
namespace SJZY.Track.Share.Enums;
/// <summary>
/// 时间样式枚举

View File

@ -1,4 +1,4 @@
namespace SJZY.Track.Domain.Enums;
namespace SJZY.Track.Share.Enums;
public enum NotifyMode
{

View File

@ -1,4 +1,4 @@
namespace SJZY.Track.Domain.Enums;
namespace SJZY.Track.Share.Enums;
/// <summary>

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../../common.props" />
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>SJZY.Track.Share</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>