update: 推送行为限制推送配置的订单类型和要推送的轨迹所属订单的订单类型必须一致

update: 进行删除/推送操作时,订单无轨迹时轨迹代码下拉应该显示为空,
 - 删除过滤外部服务商轨迹
 - 推送过滤订单类型不一致轨迹

 opt: 配置MQ,舰艇和轨迹推送完成回传
This commit is contained in:
hardstylewyl 2024-12-20 15:21:36 +08:00
parent cfa241a36f
commit cc32f5b2fd
4 changed files with 42 additions and 10 deletions

View File

@ -100,7 +100,9 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
// 推送新增,需要根据上一次的推送 推断 本次推送 是否可行 // 推送新增,需要根据上一次的推送 推断 本次推送 是否可行
config = GetValidPushConfigAsync(_pushConfigs, order.LatestPushTrackCode, @event.TrackCode); config = GetValidPushConfigAsync(_pushConfigs, order.LatestPushTrackCode, @event.TrackCode);
if (config == null) continue; if (config == null) continue;
// 是否自动推送
if (!config.IsAutoPush) continue; if (!config.IsAutoPush) continue;
//配置的类型如何和订单类型不一致则不允许推送
if (config.OrderType != order.OrderType) continue; if (config.OrderType != order.OrderType) continue;
var log = new TrackPushRecordIndex var log = new TrackPushRecordIndex
@ -142,6 +144,9 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
if (config == null) continue; if (config == null) continue;
//配置的类型如何和订单类型不一致则不允许推送
if (config.OrderType != order.OrderType) continue;
var log = new TrackPushRecordIndex var log = new TrackPushRecordIndex
{ {
OptionType = @event.OptionType.ToString(), OptionType = @event.OptionType.ToString(),
@ -202,6 +207,9 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
var items = new List<TrackUpdateInput>(); var items = new List<TrackUpdateInput>();
foreach (var order in _orders) foreach (var order in _orders)
{ {
//配置的类型如何和订单类型不一致则不允许推送
if (config.OrderType != order.OrderType) continue;
var log = new TrackPushRecordIndex var log = new TrackPushRecordIndex
{ {
OptionType = @event.OptionType.ToString(), OptionType = @event.OptionType.ToString(),

View File

@ -67,11 +67,11 @@ public class TrackPushCompletedEventHandler : ITransientDependency, IRabbitHandl
var optionType = Base64Helper.DeSerialize<string>(@event.Attach); var optionType = Base64Helper.DeSerialize<string>(@event.Attach);
if (optionType == OptionType.新增.ToString()) if (optionType == OptionType.新增.ToString())
{ {
logStr = JsonConvert.DeserializeObject<TrackPushInput>(@event.RequestParams)!.Log; logStr = JsonConvert.DeserializeObject<List<TrackPushInput>>(@event.RequestParams)!.First().Log;
} }
else if (optionType == OptionType.修改.ToString()) else if (optionType == OptionType.修改.ToString())
{ {
logStr = JsonConvert.DeserializeObject<TrackUpdateInput>(@event.RequestParams)!.Log; logStr = JsonConvert.DeserializeObject<List<TrackUpdateInput>>(@event.RequestParams)!.First().Log;;
} }
if (logStr.IsNullOrEmpty()) throw new InvalidOperationException(); if (logStr.IsNullOrEmpty()) throw new InvalidOperationException();

View File

@ -13,7 +13,6 @@ using SJZY.Track.Domain.Aggregates.TrackFlagAggregate;
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
using SJZY.Track.Domain.Dtos.TrackContents; using SJZY.Track.Domain.Dtos.TrackContents;
using SJZY.Track.Domain.Dtos.TrackTemplate;
using SJZY.Track.Domain.Enums; using SJZY.Track.Domain.Enums;
using SJZY.Track.Domain.Queries; using SJZY.Track.Domain.Queries;
@ -290,6 +289,11 @@ public class TrackContentService : ApplicationService
if (order == default) if (order == default)
throw new BusinessException(message: "订单不存在!"); throw new BusinessException(message: "订单不存在!");
var res = new UnifyResultDto<List<GetAvailableContentOutput>>(true)
{
Data = new List<GetAvailableContentOutput>()
};
//获取轨迹详情 //获取轨迹详情
var trackDetails = await _trackDetailsEsRepository.GetListAsync(order.Id); var trackDetails = await _trackDetailsEsRepository.GetListAsync(order.Id);
@ -298,6 +302,17 @@ public class TrackContentService : ApplicationService
{ {
trackDetails = trackDetails.Where(m => m.Source != (int) TrackSourceEnum.ExternalServiceProvide).ToList(); trackDetails = trackDetails.Where(m => m.Source != (int) TrackSourceEnum.ExternalServiceProvide).ToList();
} }
//进行推送时,匹配订单类型一致的轨迹
if (input.TrackOptionType == TrackOptionType.推送)
{
trackDetails = trackDetails.Where(t => t.OrderType == order.OrderType).ToList();
}
//进行删除和推送行为无任何轨迹内容,直接返回为空即可
if (input.TrackOptionType is TrackOptionType.删除 or TrackOptionType.推送 && trackDetails.Count == 0)
{
return res;
}
//获取当前子系统下所有的轨迹内容 //获取当前子系统下所有的轨迹内容
var contentList = await _trackContentRepository.GetListBySystemIdAsync(input.SystemId); var contentList = await _trackContentRepository.GetListBySystemIdAsync(input.SystemId);
@ -312,11 +327,6 @@ public class TrackContentService : ApplicationService
contentList = contentList.Where(m => template.Contains(m.Code)).ToList(); contentList = contentList.Where(m => template.Contains(m.Code)).ToList();
} }
var res = new UnifyResultDto<List<GetAvailableContentOutput>>(true)
{
Data = new List<GetAvailableContentOutput>()
};
foreach (var item in contentList) foreach (var item in contentList)
{ {
//新增时跳过已存在轨迹内容 //新增时跳过已存在轨迹内容
@ -351,7 +361,7 @@ public class TrackContentService : ApplicationService
} }
//修改操作,查轨迹内容列表反映明细表数据,重新构造响应数据 //修改/删除/推送 操作,查轨迹内容列表反映明细表数据,重新构造响应数据
var matchContent = new List<GetAvailableContentOutput>(); var matchContent = new List<GetAvailableContentOutput>();
var contents = res.Data.Select(x => new var contents = res.Data.Select(x => new
{ {

View File

@ -142,7 +142,8 @@ public class SjzyTrackApplicationModule : AbpModule
options.PoolSize = configuration.GetValue<int>("RabbitMQ:PoolSize"); options.PoolSize = configuration.GetValue<int>("RabbitMQ:PoolSize");
options.Declarations = new List<Action<IDeclaration>>() options.Declarations = new List<Action<IDeclaration>>()
{ {
o=>o.ExchangeDeclare(GlobalConst.TrackChangeExchange, ExchangeType.Topic, true), o => o.ExchangeDeclare(GlobalConst.TrackChangeExchange, ExchangeType.Topic, true),
o => o.ExchangeDeclare(GlobalConst.TrackPushExchange, ExchangeType.Topic, true)
}; };
options.Consumes = new List<ConsumeOptions> options.Consumes = new List<ConsumeOptions>
{ {
@ -158,6 +159,19 @@ public class SjzyTrackApplicationModule : AbpModule
o.QueueBind(GlobalConst.TrackRefreshSubscribe, GlobalConst.InterfaceRelayExchange, o.QueueBind(GlobalConst.TrackRefreshSubscribe, GlobalConst.InterfaceRelayExchange,
GlobalConst.TrackRefreshSubscribe); GlobalConst.TrackRefreshSubscribe);
} }
},
new()
{
Queue = GlobalConst.TrackPushCompletedSubscribe,
FetchCount = configuration.GetValue<ushort>("TrackApp:TrackRefreshFetchCount"),
FailedRequeue = false,
Declaration = o =>
{
o.ExchangeDeclare(GlobalConst.InterfaceRelayExchange, ExchangeType.Direct, true);
o.QueueDeclare(GlobalConst.TrackPushCompletedSubscribe, true);
o.QueueBind(GlobalConst.TrackPushCompletedSubscribe, GlobalConst.InterfaceRelayExchange,
GlobalConst.TrackPushCompletedSubscribe);
}
} }
}; };
}, typeof(SjzyTrackApplicationModule).Assembly); }, typeof(SjzyTrackApplicationModule).Assembly);