Merge branch 'S02-轨迹中台第二部分' into test
This commit is contained in:
commit
ff641362c9
@ -7,15 +7,15 @@ public class GetPageTrackOrderInput : PageInfoInput
|
||||
/// </summary>
|
||||
public int SubSystemId { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 单号
|
||||
///// </summary>
|
||||
//public List<string>? OrderNos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单号
|
||||
/// </summary>
|
||||
public string? OrderNos { get; set; }
|
||||
public List<string>? OrderNos { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 单号
|
||||
///// </summary>
|
||||
//public string? OrderNos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// tab标签类型 0 全部, 1 异常 2 预警
|
||||
@ -136,7 +136,7 @@ public class TrackOrderDto
|
||||
/// <summary>
|
||||
/// 子系统
|
||||
/// </summary>
|
||||
public string SubSystem { get; set; }
|
||||
public string? SubSystem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子系统id
|
||||
@ -153,13 +153,13 @@ public class TrackOrderDto
|
||||
/// </summary>
|
||||
public string? QuestionTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
||||
/// </summary>
|
||||
public int ProblemDescription { get; set; }
|
||||
///// <summary>
|
||||
///// 问题描述(主数据枚举TrackProblemDescription)
|
||||
///// </summary>
|
||||
//public int ProblemDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述名称
|
||||
/// </summary>
|
||||
public string? ProblemDescriptionName { get; set; }
|
||||
///// <summary>
|
||||
///// 问题描述名称
|
||||
///// </summary>
|
||||
//public string? ProblemDescriptionName { get; set; }
|
||||
}
|
||||
@ -15,6 +15,16 @@ public class TrackPushConfigDto
|
||||
|
||||
public class TrackPushContentConfigDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否自动推送
|
||||
/// </summary>
|
||||
public bool IsAutoPush { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否支持更新
|
||||
/// </summary>
|
||||
public bool IsCanUpdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商code
|
||||
/// </summary>
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
namespace SJZY.Track.Application.Contract.Dtos.TrackOrder;
|
||||
|
||||
public class GetTrackCounterOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 总条数
|
||||
/// </summary>
|
||||
public int TotalCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 异常数
|
||||
/// </summary>
|
||||
public int ErrorCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预警数
|
||||
/// </summary>
|
||||
public int WarnCount { get; set; }
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
namespace SJZY.Track.Application.Contract.Dtos.TrackOrder;
|
||||
|
||||
public class TrackPushRecordItem
|
||||
{
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
|
||||
public class TrackRefreshAttach
|
||||
{
|
||||
public TrackRefreshAttach(int serviceProviderId, string serviceProviderCode, int subSystemId, int orderType)
|
||||
{
|
||||
ServiceProviderId = serviceProviderId;
|
||||
ServiceProviderCode = serviceProviderCode;
|
||||
SubSystemId = subSystemId;
|
||||
OrderType = orderType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 服务商id
|
||||
/// </summary>
|
||||
public int ServiceProviderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商code
|
||||
/// </summary>
|
||||
public string ServiceProviderCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单类型(主数据枚举TrackOrderType)
|
||||
/// </summary>
|
||||
public int OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子系统id
|
||||
/// </summary>
|
||||
public int SubSystemId { get; set; }
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
|
||||
namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
|
||||
public class TrackRefreshDto : OrderNoInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务商id
|
||||
/// </summary>
|
||||
public int ServiceProviderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子系统id
|
||||
/// </summary>
|
||||
public int SubSystemId { get; set; }
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
namespace SJZY.Track.Application.Contract.Events;
|
||||
|
||||
public class TrackPushAfterUpdateOrderEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作类型
|
||||
/// </summary>
|
||||
public OptionType OptionType { get; set; } = OptionType.新增;
|
||||
|
||||
/// <summary>
|
||||
/// 订单Id
|
||||
/// </summary>
|
||||
public int OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容id
|
||||
/// </summary>
|
||||
public int TrackContentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型
|
||||
/// </summary>
|
||||
public bool IsSuccess { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述
|
||||
/// </summary>
|
||||
public string? Message { get; set; }
|
||||
}
|
||||
89
src/SJZY.Track.Application.Contract/Events/TrackPushEvent.cs
Normal file
89
src/SJZY.Track.Application.Contract/Events/TrackPushEvent.cs
Normal file
@ -0,0 +1,89 @@
|
||||
namespace SJZY.Track.Application.Contract.Events;
|
||||
|
||||
public class TrackPushEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作类型
|
||||
/// </summary>
|
||||
public OptionType OptionType { get; set; } = OptionType.新增;
|
||||
|
||||
/// <summary>
|
||||
/// 服务商code
|
||||
/// </summary>
|
||||
public string ServiceProviderCode { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 订单id
|
||||
/// </summary>
|
||||
public int OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
public string OrderNo { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容id
|
||||
/// </summary>
|
||||
public int TrackContentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态
|
||||
/// </summary>
|
||||
public string TrackStatus { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容代码
|
||||
/// </summary>
|
||||
public string TrackCode { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容
|
||||
/// </summary>
|
||||
public string TrackContent { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地
|
||||
/// </summary>
|
||||
public string TrackPlace { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时间
|
||||
/// </summary>
|
||||
public DateTime TrackTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时区
|
||||
/// </summary>
|
||||
public float TrackTimeZone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹代码参数值
|
||||
/// </summary>
|
||||
public string? TrackContentCodeValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容参数值
|
||||
/// </summary>
|
||||
public string? TrackContentValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容英文参数值
|
||||
/// </summary>
|
||||
public string? TrackEnContentValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态参数值
|
||||
/// </summary>
|
||||
public string? TrackStatusValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扩展字段参数值
|
||||
/// </summary>
|
||||
public string? ExpandFieldsValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作人
|
||||
/// </summary>
|
||||
public string? OperationMan { get; set; }
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
namespace SJZY.Track.Application.Contract.Events;
|
||||
|
||||
public class UpdateOrderTrackEvent
|
||||
public class TrackUpsertAfterUpdateOrderEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单Id
|
||||
@ -9,6 +9,11 @@ public class TrackUpsertEvent : UpsertTrackInput
|
||||
/// </summary>
|
||||
public int OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单是否完成
|
||||
/// </summary>
|
||||
public bool IsCompleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户id
|
||||
/// </summary>
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
using AutoMapper;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Order;
|
||||
using SJZY.Track.Domain.Enums;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using Volo.Abp.AutoMapper;
|
||||
|
||||
namespace SJZY.Track.Application.AutoMapper;
|
||||
@ -20,7 +25,10 @@ public class OrderAutoMapperProfile : Profile
|
||||
CreateMap<OrderFlightInfo, OrderFlightEntity>(MemberList.None);
|
||||
|
||||
CreateMap<GetPageTrackOrderInput, GetPageTrackOrderInputVO>(MemberList.None);
|
||||
CreateMap<TrackOrderVO, TrackOrderDto>(MemberList.None);
|
||||
CreateMap<TrackOrderVO, TrackOrderDto>(MemberList.None)
|
||||
.ForMember(dest => dest.OrderTypeName, opt => opt.MapFrom(source => GetEnumDescription(2, source.OrderType)))
|
||||
.ForMember(dest => dest.QuestionTypeName, opt => opt.MapFrom(source => GetEnumDescription(1, source.QuestionType)));
|
||||
|
||||
CreateMap<UnifyPageResultDto<TrackOrderVO>, UnifyPageResultDto<TrackOrderDto>>(MemberList.None);
|
||||
CreateMap<TrackDetailsIndex, TrackOrderDetailDto>(MemberList.None).Ignore(dest => dest.TrackTimeZone)
|
||||
.ForMember(dest => dest.Id, opt => opt.Ignore())
|
||||
@ -29,4 +37,34 @@ public class OrderAutoMapperProfile : Profile
|
||||
.ForMember(dest => dest.EnContent, opt => opt.MapFrom(m => m.TrackEnContent))
|
||||
.ForMember(dest => dest.TrackTimeZoneValue, opt => opt.MapFrom(m => m.TrackTimeZone));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过类型int获取枚举描述
|
||||
/// </summary>
|
||||
/// <param name="type">1 问题类型枚举 2 订单枚举</param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetEnumDescription(int type, int value)
|
||||
{
|
||||
string enumDescription = string.Empty;
|
||||
if (type == 1)
|
||||
{
|
||||
TrackProblemType trackProblem = (TrackProblemType)value; // 将int值转换为枚举
|
||||
if (trackProblem.GetDescription().IsNullOrWhiteSpace())
|
||||
enumDescription = "";
|
||||
else
|
||||
enumDescription = trackProblem.GetDescription(); // 获取描述标记
|
||||
}
|
||||
else
|
||||
{
|
||||
OrderType orderType = (OrderType)value; // 将int值转换为枚举
|
||||
if (orderType.GetDescription().IsNullOrWhiteSpace())
|
||||
enumDescription = "";
|
||||
else
|
||||
enumDescription = orderType.GetDescription(); // 获取描述标记
|
||||
|
||||
}
|
||||
|
||||
return enumDescription;
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
using SJZY.Track.Application.Contract.Events;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.EventHandlers;
|
||||
|
||||
@ -3,6 +3,7 @@ using SJZY.Expand.ABP.Core.Logger;
|
||||
using SJZY.Track.Application.Contract.Events;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
@ -63,12 +64,12 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
|
||||
{
|
||||
var track = await _trackDetailsRepository.GetLatestAsync(@event.OrderId);
|
||||
var updateOrderEvent = track == default
|
||||
? new UpdateOrderTrackEvent
|
||||
? new TrackUpsertAfterUpdateOrderEvent
|
||||
{
|
||||
OrderId = @event.OrderId,
|
||||
IsDelete = true
|
||||
}
|
||||
: new UpdateOrderTrackEvent
|
||||
: new TrackUpsertAfterUpdateOrderEvent
|
||||
{
|
||||
OrderId = @event.OrderId,
|
||||
IsCompleted = track.IsCompleted,
|
||||
@ -79,7 +80,7 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
|
||||
TrackTimeZone = track.TrackTimeZone,
|
||||
IsDelete = true
|
||||
};
|
||||
await _capPublisher.PublishAsync(GlobalConst.UpdateOrderTrackSubscribe, updateOrderEvent);
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertAfterUpdateOrderSubscribe, updateOrderEvent);
|
||||
}
|
||||
|
||||
// 根据订单关联关系异步向下刷
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
using DotNetCore.CAP;
|
||||
using SJZY.Track.Application.Contract.Events;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
using SJZY.Track.Domain.Enums;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.EventHandlers;
|
||||
|
||||
public class TrackPushAfterUpdateOrderEventHandler : ITransientDependency, ICapSubscribe
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
|
||||
public TrackPushAfterUpdateOrderEventHandler(IOrderRepository orderRepository)
|
||||
{
|
||||
_orderRepository = orderRepository;
|
||||
}
|
||||
|
||||
[CapSubscribe(GlobalConst.TrackPushAfterUpdateOrderSubscribe)]
|
||||
public async Task ConsumerAsync(TrackPushAfterUpdateOrderEvent @event)
|
||||
{
|
||||
var order = await _orderRepository.GetFirstAsync(x => x.Id == @event.OrderId);
|
||||
if (order == default) return;
|
||||
|
||||
/*
|
||||
* 异常:最近一条推送是失败
|
||||
*/
|
||||
if (!@event.IsSuccess)
|
||||
{
|
||||
order.QuestionType = (int)TrackProblemType.Error;
|
||||
order.ProblemDescription = @event.Message;
|
||||
}
|
||||
else
|
||||
{
|
||||
order.QuestionType = (int)TrackProblemType.None;
|
||||
if (@event.OptionType == OptionType.新增)
|
||||
{
|
||||
// tips:只有新增会影响推送进度?
|
||||
order.LatestPushTrackContentId = @event.TrackContentId;
|
||||
order.LatestPushTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
await _orderRepository.UpdateColumnAsync(order, x => new
|
||||
{
|
||||
x.LatestPushTrackContentId, x.QuestionType, x.ProblemDescription, x.LatestPushTime
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,139 @@
|
||||
using DotNetCore.CAP;
|
||||
using SJZY.InterfaceRelay.Application.Contracts;
|
||||
using SJZY.Track.Application.Contract.Events;
|
||||
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Http.Client.DynamicProxying;
|
||||
|
||||
namespace SJZY.Track.Application.EventHandlers;
|
||||
|
||||
public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
|
||||
{
|
||||
private readonly IHttpClientProxy<IInterfaceForwardServiceV2> _httpClientProxy;
|
||||
private readonly ITrackPushRecordsRepository _trackPushRecordsRepository;
|
||||
private readonly ICapPublisher _capPublisher;
|
||||
|
||||
public TrackPushEventHandler(IHttpClientProxy<IInterfaceForwardServiceV2> httpClientProxy,
|
||||
ITrackPushRecordsRepository trackPushRecordsRepository, ICapPublisher capPublisher)
|
||||
{
|
||||
_httpClientProxy = httpClientProxy;
|
||||
_trackPushRecordsRepository = trackPushRecordsRepository;
|
||||
_capPublisher = capPublisher;
|
||||
}
|
||||
|
||||
[CapSubscribe(GlobalConst.TrackPushSubscribe)]
|
||||
public async Task ConsumerAsync(TrackPushEvent @event)
|
||||
{
|
||||
InterfaceRelayUnifyResultDto res = null!;
|
||||
switch (@event.OptionType)
|
||||
{
|
||||
case OptionType.无:
|
||||
return;
|
||||
case OptionType.新增:
|
||||
res = await PushAddAsync(@event);
|
||||
break;
|
||||
case OptionType.删除:
|
||||
break;
|
||||
case OptionType.修改:
|
||||
res = await PushUpdateAsync(@event);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
var isSuccess = res.Code == InterfaceRelayConst.SuccessCode;
|
||||
|
||||
// 写推送日志
|
||||
await _trackPushRecordsRepository.AddAsync(new TrackPushRecordIndex
|
||||
{
|
||||
IndexName = $"{GlobalConst.TrackPushRecordsIndex}-{DateTime.Now:yyyy.MM.dd}",
|
||||
RequestId = res.RequestId,
|
||||
Message = res.Msg,
|
||||
OptionType = @event.OptionType.ToString(),
|
||||
TrackStatus = @event.TrackStatus,
|
||||
TrackCode = @event.TrackCode,
|
||||
TrackContent = @event.TrackContent,
|
||||
TrackPlace = @event.TrackPlace,
|
||||
TrackTime = @event.TrackTime,
|
||||
TrackTimeZone = @event.TrackTimeZone,
|
||||
TrackContentCodeValue = @event.TrackContentCodeValue,
|
||||
TrackContentValue = @event.TrackContentValue,
|
||||
TrackEnContentValue = @event.TrackEnContentValue,
|
||||
TrackStatusValue = @event.TrackStatusValue,
|
||||
ExpandFieldsValue = @event.ExpandFieldsValue,
|
||||
IsSuccess = isSuccess,
|
||||
CreateUser = @event.OperationMan ?? "系统",
|
||||
CreateTime = DateTime.Now
|
||||
});
|
||||
|
||||
// 更新订单主表(异步)
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackPushAfterUpdateOrderSubscribe,
|
||||
new TrackPushAfterUpdateOrderEvent
|
||||
{
|
||||
OptionType = @event.OptionType,
|
||||
OrderId = @event.OrderId,
|
||||
TrackContentId = @event.TrackContentId,
|
||||
IsSuccess = isSuccess,
|
||||
Message = res.Msg
|
||||
});
|
||||
}
|
||||
|
||||
private async Task<InterfaceRelayUnifyResultDto> PushAddAsync(TrackPushEvent @event)
|
||||
{
|
||||
var data = new
|
||||
{
|
||||
orderNo = @event.OrderNo,
|
||||
data = new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
// 推真实的发生地和发生时间(时间是计算后的)
|
||||
location = @event.TrackPlace,
|
||||
date = @event.TrackTime,
|
||||
timeZone = @event.TrackTimeZone,
|
||||
description = @event.TrackEnContentValue,
|
||||
description_cn = @event.TrackContentValue,
|
||||
code = @event.TrackContentCodeValue,
|
||||
status = @event.TrackStatusValue,
|
||||
extra = @event.ExpandFieldsValue
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var res = await _httpClientProxy.Service.ForwardWithSubscribeAsync(InterfaceRelayConst.PushTrackInterfaceCode,
|
||||
@event.ServiceProviderCode, data);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private async Task<InterfaceRelayUnifyResultDto> PushUpdateAsync(TrackPushEvent @event)
|
||||
{
|
||||
var data = new
|
||||
{
|
||||
orderNo = @event.OrderNo,
|
||||
data = new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
// 推真实的发生地和发生时间
|
||||
location = @event.TrackPlace,
|
||||
date = @event.TrackTime,
|
||||
timeZone = @event.TrackTimeZone,
|
||||
description = @event.TrackEnContentValue,
|
||||
description_cn = @event.TrackContentValue,
|
||||
code = @event.TrackContentCodeValue,
|
||||
status = @event.TrackStatusValue,
|
||||
extra = @event.ExpandFieldsValue
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var res = await _httpClientProxy.Service.ForwardWithSubscribeAsync(InterfaceRelayConst.TrackUpdateInterfaceCode,
|
||||
@event.ServiceProviderCode, data);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@ -9,6 +9,7 @@ using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
using SJZY.Track.Application.Contract.Events;
|
||||
using SJZY.Track.Application.Contract.Services;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
using SJZY.Track.Domain.Enums;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
@ -28,15 +29,13 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
||||
_trackPullCacheService = trackPullCacheService;
|
||||
}
|
||||
|
||||
[CapSubscribe(GlobalConst.TrackRefreshSubscribe)]
|
||||
[CapSubscribe(GlobalConst.TrackRefreshSubscribe, Group = GlobalConst.TrackRefreshSubscribe)]
|
||||
public async Task ConsumerAsync(InterfaceRelayForwardReplayEvent @event)
|
||||
{
|
||||
// tips:attach返回的是服务商id,必有
|
||||
var refreshDto = JsonConvert.DeserializeObject<List<TrackRefreshDto>>(@event.RequestParams)?.FirstOrDefault();
|
||||
if (refreshDto is null) return;
|
||||
var config =
|
||||
await _trackPullCacheService.GetPullParamWithContentConfigAsync(refreshDto.SubSystemId,
|
||||
refreshDto.ServiceProviderId);
|
||||
var attach = JsonConvert.DeserializeObject<TrackRefreshAttach>(@event.Attach);
|
||||
if (attach is null) return;
|
||||
var config = await _trackPullCacheService.GetPullParamWithContentConfigAsync(attach.SubSystemId,
|
||||
attach.ServiceProviderId);
|
||||
|
||||
var data = JObject.Parse(@event.Data.ToString()!);
|
||||
var orderToken = data[config.ParamConfig.OrderPath];
|
||||
@ -44,12 +43,12 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
||||
{
|
||||
foreach (var token in orderTokens)
|
||||
{
|
||||
await HandleOrderAsync(token, config, refreshDto.OrderType);
|
||||
await HandleOrderAsync(token, config, attach.OrderType);
|
||||
}
|
||||
}
|
||||
else if (orderToken is JObject)
|
||||
{
|
||||
await HandleOrderAsync(orderToken, config, refreshDto.OrderType);
|
||||
await HandleOrderAsync(orderToken, config, attach.OrderType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,21 +1,22 @@
|
||||
using DotNetCore.CAP;
|
||||
using SJZY.Track.Application.Contract.Events;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.EventHandlers;
|
||||
|
||||
public class UpdateOrderTrackEventHandler : ITransientDependency, ICapSubscribe
|
||||
public class TrackUpsertAfterUpdateOrderEventHandler : ITransientDependency, ICapSubscribe
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
|
||||
public UpdateOrderTrackEventHandler(IOrderRepository orderRepository)
|
||||
public TrackUpsertAfterUpdateOrderEventHandler(IOrderRepository orderRepository)
|
||||
{
|
||||
_orderRepository = orderRepository;
|
||||
}
|
||||
|
||||
[CapSubscribe(GlobalConst.UpdateOrderTrackSubscribe)]
|
||||
public async Task ConsumerAsync(UpdateOrderTrackEvent @event)
|
||||
[CapSubscribe(GlobalConst.TrackUpsertAfterUpdateOrderSubscribe)]
|
||||
public async Task ConsumerAsync(TrackUpsertAfterUpdateOrderEvent @event)
|
||||
{
|
||||
var order = await _orderRepository.GetFirstAsync(x => x.Id == @event.OrderId);
|
||||
if (order == default) return;
|
||||
@ -37,14 +38,20 @@ public class UpdateOrderTrackEventHandler : ITransientDependency, ICapSubscribe
|
||||
|
||||
// 删除引发的回退更新
|
||||
if (order.LatestTrackTime != null &&
|
||||
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) ==
|
||||
@event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone))) return;
|
||||
@event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone)) ==
|
||||
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else // upsert引发的更新
|
||||
{
|
||||
if (order.LatestTrackTime != null &&
|
||||
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) >
|
||||
@event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone))) return;
|
||||
@event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone)) <
|
||||
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
order.IsCompleted = @event.IsCompleted;
|
||||
@ -1,10 +1,13 @@
|
||||
using DotNetCore.CAP;
|
||||
using System.Diagnostics;
|
||||
using DotNetCore.CAP;
|
||||
using SJZY.Expand.ABP.Core.Logger;
|
||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Application.Contract.Events;
|
||||
using SJZY.Track.Application.Contract.Services;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
using SJZY.UserCenter.HttpApi.Services;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
@ -57,15 +60,52 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
@event.TrackCode = mapCode;
|
||||
}
|
||||
|
||||
await UpsertTrackAsync(@event);
|
||||
}
|
||||
|
||||
private async Task UpsertTrackAsync(TrackUpsertEvent @event)
|
||||
{
|
||||
// 不存在则新增轨迹,存在则更新
|
||||
var track = await _trackDetailsRepository.GetFirstOrDefaultAsync(@event.OrderId, @event.TrackCode);
|
||||
|
||||
var orderIsCompleted = false;
|
||||
// step1、upsert es轨迹
|
||||
await UpsertTrackAsync(track, @event);
|
||||
Debug.Assert(track != null, nameof(track) + " != null");
|
||||
|
||||
// step2、触发轨迹推送事件(异步)
|
||||
await HandleTrackPushAsync(@event, track);
|
||||
|
||||
// step3、触发订单主表更新事件(异步)
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertAfterUpdateOrderSubscribe,
|
||||
new TrackUpsertAfterUpdateOrderEvent
|
||||
{
|
||||
OrderId = track.OrderId,
|
||||
IsCompleted = track.IsCompleted,
|
||||
TrackCode = track.TrackCode,
|
||||
TrackContent = track.TrackContent,
|
||||
TrackEnContent = track.TrackEnContent,
|
||||
TrackPlace = track.TrackPlace,
|
||||
TrackTime = track.TrackTime,
|
||||
TrackTimeZone = track.TrackTimeZone
|
||||
});
|
||||
|
||||
// step4、根据订单关联关系异步向下刷(异步)
|
||||
var linkedOrders = await _orderRepository.GetLinkedOrdersAsync(@event.OrderId);
|
||||
foreach (var linkedOrder in linkedOrders)
|
||||
{
|
||||
var nextEvent = @event.DeepCopy();
|
||||
nextEvent.OrderId = linkedOrder.OrderId;
|
||||
nextEvent.OrderType = linkedOrder.OrderType;
|
||||
nextEvent.OrderNo = linkedOrder.OrderNo;
|
||||
nextEvent.SubSystemId = linkedOrder.SubSystemId;
|
||||
nextEvent.LatestPushTrackContentId = linkedOrder.LatestPushTrackContentId;
|
||||
nextEvent.CustomId = linkedOrder.CustomId;
|
||||
nextEvent.UpSubSystemId = @event.SubSystemId;
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, nextEvent);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 不存在则新增轨迹,存在则更新
|
||||
/// </summary>
|
||||
/// <param name="track"></param>
|
||||
/// <param name="event"></param>
|
||||
private async Task UpsertTrackAsync(TrackDetailsIndex? track, TrackUpsertEvent @event)
|
||||
{
|
||||
if (track == default)
|
||||
{
|
||||
//todo:可以优化
|
||||
@ -73,12 +113,10 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
var trackContent = await _provideQueries.MatchTrackContentAsync(@event.OrderId, @event.TrackCode);
|
||||
if (trackContent == default)
|
||||
{
|
||||
//throw new BusinessException(message: $"订单:{@event.OrderNo} 所绑定的模板,没有一条内容可以匹配轨迹代码:{@event.TrackCode}");
|
||||
// 订单所绑定的模板,没有一条内容可以匹配发生的轨迹
|
||||
return;
|
||||
}
|
||||
|
||||
orderIsCompleted = trackContent.IsCompleted;
|
||||
|
||||
track = new TrackDetailsIndex
|
||||
{
|
||||
IndexName = $"{GlobalConst.TrackIndex}-{DateTime.Now:yyyy.MM.dd}",
|
||||
@ -89,7 +127,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
TrackCode = @event.TrackCode,
|
||||
TrackContent = trackContent.Content,
|
||||
TrackContentId = trackContent.Id,
|
||||
IsCompleted = orderIsCompleted,
|
||||
IsCompleted = trackContent.IsCompleted,
|
||||
TrackEnContent = trackContent.EnContent,
|
||||
TrackPlace = @event.TrackPlace,
|
||||
TrackTime = @event.TrackTime!.Value,
|
||||
@ -108,44 +146,60 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
track.UpdateTime = DateTime.Now;
|
||||
}
|
||||
|
||||
// upsert es轨迹
|
||||
await _trackDetailsRepository.UpsertAsync(track);
|
||||
}
|
||||
|
||||
// 触发轨迹推送事件
|
||||
var content = await _trackPushCacheService.InferNextPushContentOrNullAsync(
|
||||
@event.SubSystemId, @event.CustomId, @event.LatestPushTrackContentId);
|
||||
if (content != default && content.TrackContentId == track.TrackContentId &&
|
||||
content.OrderType == @event.OrderType)
|
||||
/// <summary>
|
||||
/// 处理轨迹自动推送
|
||||
/// </summary>
|
||||
/// <param name="event"></param>
|
||||
/// <param name="track"></param>
|
||||
private async Task HandleTrackPushAsync(TrackUpsertEvent @event, TrackDetailsIndex track)
|
||||
{
|
||||
TrackPushContentConfigDto? config;
|
||||
OptionType optionType = OptionType.修改;
|
||||
// 推送更新
|
||||
if (!track.Id.IsNullOrWhiteSpace())
|
||||
{
|
||||
//await PushTrack(content);
|
||||
config = await _trackPushCacheService.GetPushContentConfigAsync(
|
||||
@event.SubSystemId, @event.CustomId, track.TrackContentId);
|
||||
if (!config.IsCanUpdate) return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 推送新增,需要根据上一次的推送 推断 本次推送 是否可行
|
||||
config = await _trackPushCacheService.InferNextPushContentOrNullAsync(
|
||||
@event.SubSystemId, @event.CustomId, @event.LatestPushTrackContentId);
|
||||
|
||||
if (config == null || !config.IsAutoPush) return;
|
||||
|
||||
// 当前发生的轨迹就是要推送的
|
||||
if (config.TrackContentId != track.TrackContentId) return;
|
||||
|
||||
optionType = OptionType.新增;
|
||||
}
|
||||
|
||||
// 触发订单主表更新事件
|
||||
await _capPublisher.PublishAsync(GlobalConst.UpdateOrderTrackSubscribe, new UpdateOrderTrackEvent
|
||||
if (config.OrderType != @event.OrderType) return;
|
||||
|
||||
var trackPushEvent = new TrackPushEvent
|
||||
{
|
||||
OrderId = track.OrderId,
|
||||
IsCompleted = orderIsCompleted,
|
||||
OptionType = optionType,
|
||||
ServiceProviderCode = config.ServiceProviderCode,
|
||||
OrderNo = track.OrderNo,
|
||||
TrackContentId = config.TrackContentId,
|
||||
TrackStatus = track.TrackStatus,
|
||||
TrackCode = track.TrackCode,
|
||||
TrackContent = track.TrackContent,
|
||||
TrackEnContent = track.TrackEnContent,
|
||||
TrackPlace = track.TrackPlace,
|
||||
TrackTime = track.TrackTime,
|
||||
TrackTimeZone = track.TrackTimeZone
|
||||
});
|
||||
TrackTime = track.TrackTime.AddHours(config.TrackTimeZone ?? track.TrackTimeZone - track.TrackTimeZone),
|
||||
TrackTimeZone = (float)(config.TrackTimeZone ?? track.TrackTimeZone),
|
||||
TrackContentCodeValue = config.TrackContentCodeValue,
|
||||
TrackContentValue = config.TrackContentValue,
|
||||
TrackEnContentValue = config.TrackEnContentValue,
|
||||
TrackStatusValue = config.TrackStatusValue,
|
||||
ExpandFieldsValue = config.ExpandFieldsValue
|
||||
};
|
||||
|
||||
// 根据订单关联关系异步向下刷
|
||||
var linkedOrders = await _orderRepository.GetLinkedOrdersAsync(@event.OrderId);
|
||||
foreach (var linkedOrder in linkedOrders)
|
||||
{
|
||||
var nextEvent = @event.DeepCopy();
|
||||
nextEvent.OrderId = linkedOrder.OrderId;
|
||||
nextEvent.OrderType = linkedOrder.OrderType;
|
||||
nextEvent.OrderNo = linkedOrder.OrderNo;
|
||||
nextEvent.SubSystemId = linkedOrder.SubSystemId;
|
||||
nextEvent.LatestPushTrackContentId = linkedOrder.LatestPushTrackContentId;
|
||||
nextEvent.CustomId = linkedOrder.CustomId;
|
||||
nextEvent.UpSubSystemId = @event.SubSystemId;
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, nextEvent);
|
||||
}
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackPushSubscribe, trackPushEvent);
|
||||
}
|
||||
}
|
||||
@ -8,7 +8,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SJZY.InterfaceRelay.Application.Contracts" Version="7.1.6"/>
|
||||
<None Include="..\..\.editorconfig" Link=".editorconfig" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SJZY.InterfaceRelay.Application.Contracts" Version="7.1.6" />
|
||||
<PackageReference Include="Volo.Abp.Http.Client" Version="7.0.2" />
|
||||
<PackageReference Include="Volo.Abp.FluentValidation" Version="7.0.2" />
|
||||
<PackageReference Include="SJZY.UserCenter.HttpApi" Version="3.0.3-alpha8" />
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Application.Contract.Events;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
|
||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Newtonsoft.Json;
|
||||
using SJZY.Expand.ABP.Core;
|
||||
using SJZY.InterfaceRelay.Application.Contracts;
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
using SJZY.Track.Application.Contract.Services;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
using Volo.Abp.Http.Client.DynamicProxying;
|
||||
|
||||
@ -40,27 +42,27 @@ public class TrackPullService : ApplicationService
|
||||
// todo:罚时?
|
||||
input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空
|
||||
|
||||
// 这里没有区分订单类型,就算的不同类型的单一起刷新了也无所谓
|
||||
// tips:这里没有区分订单类型,就算的不同类型的单一起刷新了也无所谓
|
||||
var orders = await _provideQueries.FindOrderWithServiceProviderAsync(input.OrderNos);
|
||||
|
||||
if (orders.Count == 0)
|
||||
{
|
||||
throw new BusinessException(message: "一个拉取配置都不存在");
|
||||
// tips:可能是没有配置、或者所有单都刷完了、或者单不存在
|
||||
throw new BusinessException(message: "一个能更新的都没有");
|
||||
}
|
||||
|
||||
foreach (var group in orders.GroupBy(x => x.ServiceProviderCode))
|
||||
foreach (var group in orders.GroupBy(x =>
|
||||
new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId, x.OrderType)))
|
||||
{
|
||||
var data = group.Select(x => new TrackRefreshDto
|
||||
var data = group.Select(x => new
|
||||
{
|
||||
OrderType = x.OrderType,
|
||||
OrderNo = x.OrderNo,
|
||||
ServiceProviderId = x.ServiceProviderId,
|
||||
SubSystemId = x.SubSystemId
|
||||
x.OrderNo
|
||||
}).ToList();
|
||||
|
||||
// 批量获取轨迹
|
||||
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
|
||||
"A012", group.Key, data, GlobalConst.TrackRefreshSubscribe);
|
||||
"A012", group.Key.ServiceProviderCode, data,
|
||||
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -72,7 +74,7 @@ public class TrackPullService : ApplicationService
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpPost("Track/RefreshForTask")]
|
||||
public async Task<bool> RefreshTrackAsync()
|
||||
public async Task<bool> RefreshForTaskAsync()
|
||||
{
|
||||
var configs = await _trackPullCacheService.GetAllPullConfigsAsync();
|
||||
foreach (var config in configs)
|
||||
@ -85,19 +87,19 @@ public class TrackPullService : ApplicationService
|
||||
|
||||
var orders = await _provideQueries.FindOrderWithServiceProviderAsync(config.ServiceProviderId);
|
||||
|
||||
foreach (var group in orders.GroupBy(x => x.ServiceProviderCode))
|
||||
foreach (var group in orders.GroupBy(x =>
|
||||
new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId,
|
||||
x.OrderType)))
|
||||
{
|
||||
var data = group.Select(x => new TrackRefreshDto
|
||||
var data = group.Select(x => new
|
||||
{
|
||||
OrderType = x.OrderType,
|
||||
OrderNo = x.OrderNo,
|
||||
ServiceProviderId = x.ServiceProviderId,
|
||||
SubSystemId = x.SubSystemId
|
||||
x.OrderNo
|
||||
}).ToList();
|
||||
|
||||
// 批量获取轨迹
|
||||
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
|
||||
"A012", group.Key, data, GlobalConst.TrackRefreshSubscribe);
|
||||
InterfaceRelayConst.GetTrackInterfaceCode, group.Key.ServiceProviderCode, data,
|
||||
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
|
||||
}
|
||||
|
||||
await RedisHelper.Client.SetExAsync(redisKey, config.PullInterval * 60, 1);
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
using SJZY.InterfaceRelay.Application.Contracts;
|
||||
using DotNetCore.CAP;
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Application.Contract.Events;
|
||||
using SJZY.Track.Application.Contract.Services;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using Volo.Abp.Http.Client.DynamicProxying;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
using SJZY.Track.Domain.Enums;
|
||||
using SJZY.UserCenter.HttpApi.Services;
|
||||
|
||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
|
||||
@ -17,16 +20,17 @@ public class TrackPushService : ApplicationService
|
||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly ITrackPushCacheService _pushCacheService;
|
||||
private readonly IHttpClientProxy<IInterfaceForwardServiceV2> _httpClientProxy;
|
||||
private readonly ICapPublisher _capPublisher;
|
||||
|
||||
public TrackPushService(
|
||||
IHttpClientProxy<IInterfaceForwardServiceV2> httpClientProxy, ITrackPushCacheService pushCacheService,
|
||||
ITrackDetailsRepository trackDetailsRepository, IOrderRepository orderRepository)
|
||||
public TrackPushService(ITrackPushCacheService pushCacheService,
|
||||
ITrackDetailsRepository trackDetailsRepository
|
||||
, IOrderRepository orderRepository
|
||||
, ICapPublisher capPublisher)
|
||||
{
|
||||
_httpClientProxy = httpClientProxy;
|
||||
_pushCacheService = pushCacheService;
|
||||
_trackDetailsRepository = trackDetailsRepository;
|
||||
_orderRepository = orderRepository;
|
||||
_capPublisher = capPublisher;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -35,11 +39,10 @@ public class TrackPushService : ApplicationService
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Track/Push")]
|
||||
public async Task<bool> PushTrackAsync(PushTrackInput input)
|
||||
public async Task<string> PushTrackAsync(PushTrackInput input)
|
||||
{
|
||||
input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空
|
||||
|
||||
|
||||
var orders = await _orderRepository.GetListAsync(x =>
|
||||
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo), x => new
|
||||
{
|
||||
@ -53,6 +56,13 @@ public class TrackPushService : ApplicationService
|
||||
|
||||
var tracks = await _trackDetailsRepository.GetListAsync(input.OrderType, input.OrderNos, input.TrackCode);
|
||||
|
||||
if (tracks.Count == 0)
|
||||
{
|
||||
throw new BusinessException(message: "一个能推的轨迹都不存在");
|
||||
}
|
||||
|
||||
var res = 0;
|
||||
|
||||
foreach (var order in orders)
|
||||
{
|
||||
// 如果没有轨迹,就不需要推
|
||||
@ -64,30 +74,50 @@ public class TrackPushService : ApplicationService
|
||||
await _pushCacheService.GetPushContentConfigAsync(order.SubSystemId, order.CustomId,
|
||||
track.TrackContentId);
|
||||
|
||||
var data = new
|
||||
var trackPushEvent = new TrackPushEvent
|
||||
{
|
||||
order.OrderNo,
|
||||
data = new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
// 推真实的发生地和发生时间
|
||||
location = track.TrackPlace,
|
||||
date = track.TrackTime.AddHours(config.TrackTimeZone ??
|
||||
track.TrackTimeZone - track.TrackTimeZone),
|
||||
timeZone = config.TrackTimeZone ?? track.TrackTimeZone,
|
||||
description = config.TrackEnContentValue,
|
||||
description_cn = config.TrackContentValue,
|
||||
code = config.TrackContentCodeValue,
|
||||
status = config.TrackStatusValue,
|
||||
extra = config.ExpandFieldsValue
|
||||
}
|
||||
}
|
||||
ServiceProviderCode = config.ServiceProviderCode,
|
||||
OrderNo = order.OrderNo,
|
||||
TrackContentId = config.TrackContentId,
|
||||
TrackStatus = track.TrackStatus,
|
||||
TrackCode = track.TrackCode,
|
||||
TrackContent = track.TrackContent,
|
||||
TrackPlace = track.TrackPlace,
|
||||
TrackTime = track.TrackTime.AddHours(config.TrackTimeZone ??
|
||||
track.TrackTimeZone - track.TrackTimeZone),
|
||||
TrackTimeZone = (float)(config.TrackTimeZone ?? track.TrackTimeZone),
|
||||
TrackContentCodeValue = config.TrackContentCodeValue,
|
||||
TrackContentValue = config.TrackContentValue,
|
||||
TrackEnContentValue = config.TrackEnContentValue,
|
||||
TrackStatusValue = config.TrackStatusValue,
|
||||
ExpandFieldsValue = config.ExpandFieldsValue,
|
||||
OperationMan = CurrentUserRequest.CurrentUser.Name,
|
||||
};
|
||||
|
||||
await _httpClientProxy.Service.ForwardWithSubscribeAsync("A024", config.ServiceProviderCode, data);
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackPushSubscribe, trackPushEvent);
|
||||
|
||||
res++;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $"即将推送轨迹代码{input.TrackCode}给{res}个订单";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 定时任务推送预警(》12小时没有推送的)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Track/PushWarnForTask")]
|
||||
public async Task<string> PushWarnForTaskAsync()
|
||||
{
|
||||
var time = DateTime.Now.Subtract(TimeSpan.FromHours(12));
|
||||
var orders = await _orderRepository.GetListAsync(x =>
|
||||
!x.IsCompleted && x.QuestionType == 0 && x.LatestPushTime < time);
|
||||
|
||||
orders.ForEach(x => { x.QuestionType = (int)TrackProblemType.Warn; });
|
||||
|
||||
await _orderRepository.UpdateRangeAsync(orders, x => new { x.QuestionType });
|
||||
|
||||
return $"成功将{orders.Select(x => x.OrderNo).JoinAsString(",")}置为预警单";
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ using SJZY.Track.Application.Contract.Events;
|
||||
using SJZY.Track.Application.Contract.Services;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
|
||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
@ -41,7 +42,7 @@ public partial class TrackService : ApplicationService, ITrackService
|
||||
var order = await _orderRepository.GetFirstAsync(x =>
|
||||
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new
|
||||
{
|
||||
x.Id, x.SubSystemId, x.LatestPushTrackContentId, x.CustomId
|
||||
x.Id, x.SubSystemId, x.LatestPushTrackContentId, x.CustomId, x.IsCompleted
|
||||
});
|
||||
if (order == default)
|
||||
{
|
||||
@ -54,6 +55,7 @@ public partial class TrackService : ApplicationService, ITrackService
|
||||
@event.SubSystemId = order.SubSystemId;
|
||||
@event.LatestPushTrackContentId = order.LatestPushTrackContentId;
|
||||
@event.CustomId = order.CustomId;
|
||||
@event.IsCompleted = order.IsCompleted;
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using System.Diagnostics;
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Application.Contract.Dtos.TrackOrder;
|
||||
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Order;
|
||||
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
using SJZY.Track.Domain.Enums;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
|
||||
namespace SJZY.Track.Application.Services.TrackOrders;
|
||||
@ -14,16 +18,19 @@ public class TrackOrderService : ApplicationService
|
||||
private readonly ITrackOrderQueries _trackOrderQueries;
|
||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||
private readonly ITrackContentRepository _trackContentRepository;
|
||||
private readonly ITrackPushRecordsRepository _trackPushRecordsRepository;
|
||||
|
||||
public TrackOrderService(
|
||||
ITrackOrderQueries trackOrderQueries,
|
||||
ITrackDetailsRepository trackDetailsRepository,
|
||||
ITrackContentRepository trackContentRepository
|
||||
ITrackContentRepository trackContentRepository,
|
||||
ITrackPushRecordsRepository trackPushRecordsRepository
|
||||
)
|
||||
{
|
||||
_trackOrderQueries = trackOrderQueries;
|
||||
_trackDetailsRepository = trackDetailsRepository;
|
||||
_trackContentRepository = trackContentRepository;
|
||||
_trackPushRecordsRepository = trackPushRecordsRepository;
|
||||
}
|
||||
|
||||
#region 轨迹订单明细
|
||||
@ -42,25 +49,31 @@ public class TrackOrderService : ApplicationService
|
||||
var list = ObjectMapper.Map<List<TrackDetailsIndex>, List<TrackOrderDetailDto>>(trackDetails);
|
||||
var trackCodes = list.Where(a => !a.Code.IsNullOrWhiteSpace()).Select(a => a.Code).Distinct().ToList();
|
||||
|
||||
var trackContents = await _trackContentRepository.GetTrackContentAttributeValue(new GetTemplateContentAttributeValueInputVO
|
||||
{
|
||||
SubSystemId = input.SubSystemId,
|
||||
TrackTemplateIds = input.TrackTemplateIds,
|
||||
TrackCodes = trackCodes
|
||||
});
|
||||
var trackContents = await _trackContentRepository.GetTrackContentAttributeValue(
|
||||
new GetTemplateContentAttributeValueInputVO
|
||||
{
|
||||
SubSystemId = input.SubSystemId,
|
||||
TrackTemplateIds = input.TrackTemplateIds,
|
||||
TrackCodes = trackCodes
|
||||
});
|
||||
Debug.Assert(input.TrackTemplateIds != null, "input.TrackTemplateIds != null");
|
||||
input.TrackTemplateIds = input.TrackTemplateIds.Where(a => a > 0).ToList();
|
||||
int id = 1;
|
||||
list.ForEach(a =>
|
||||
{
|
||||
a.Id = id++;
|
||||
|
||||
var trackContentsOfTemplates = trackContents.Where(b => b.SubSystemId == input.SubSystemId && b.TrackCode == a.Code
|
||||
&& input.TrackTemplateIds.Contains(b.TrackTemplateId));
|
||||
GetTemplateContentAttributeValueVO trackContent = null;
|
||||
var insertData = input.TrackTemplateIds.Intersect(trackContentsOfTemplates.Select(aa => aa.TrackTemplateId)).ToList();
|
||||
var trackContentsOfTemplates = trackContents.Where(b => b.SubSystemId == input.SubSystemId &&
|
||||
b.TrackCode == a.Code
|
||||
&& input.TrackTemplateIds.Contains(
|
||||
b.TrackTemplateId)).ToList();
|
||||
GetTemplateContentAttributeValueVO? trackContent = null;
|
||||
var insertData = input.TrackTemplateIds
|
||||
.Intersect(trackContentsOfTemplates.Select(aa => aa.TrackTemplateId)).ToList();
|
||||
if (!insertData.IsNullOrEmpty())
|
||||
{
|
||||
trackContent = trackContentsOfTemplates.FirstOrDefault(a => a.TrackTemplateId == insertData.FirstOrDefault());
|
||||
trackContent =
|
||||
trackContentsOfTemplates.FirstOrDefault(it =>
|
||||
it.TrackTemplateId == insertData.FirstOrDefault());
|
||||
}
|
||||
|
||||
if (trackContent != null)
|
||||
@ -68,14 +81,10 @@ public class TrackOrderService : ApplicationService
|
||||
a.IsCanDelete = trackContent.IsCanDelete;
|
||||
a.IsExternal = trackContent.IsExternal;
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// a.IsCanDelete=false;
|
||||
// a.IsExternal=false;
|
||||
//}
|
||||
|
||||
if (a.TrackTimeZoneValue == 0f)
|
||||
{
|
||||
a.TrackTimeZone = $"GTM{" "}+00:00";
|
||||
a.TrackTimeZone = "GTM +00:00";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -85,11 +94,10 @@ public class TrackOrderService : ApplicationService
|
||||
TimeSpan offset = new TimeSpan(hours, minutes, 0);
|
||||
string timeZoneStr = offset.ToString();
|
||||
string flag = a.TrackTimeZoneValue > 0f ? "+" : "";
|
||||
a.TrackTimeZone = $"GTM{" "}{flag}{timeZoneStr.RemovePostFix(":00")}";
|
||||
a.TrackTimeZone = $"GTM {flag}{timeZoneStr.RemovePostFix(":00")}";
|
||||
}
|
||||
});
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
return new List<TrackOrderDetailDto>();
|
||||
@ -115,4 +123,32 @@ public class TrackOrderService : ApplicationService
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 获取轨迹计数器
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<GetTrackCounterOutput> GetTrackCounterAsync()
|
||||
{
|
||||
var counts = await _trackOrderQueries.GetTrackProblemCountsAsync();
|
||||
|
||||
return new GetTrackCounterOutput
|
||||
{
|
||||
TotalCount = counts.Sum(x => x.Count),
|
||||
ErrorCount = counts.FirstOrDefault(x => x.ProblemType == (int)TrackProblemType.Error)?.Count ?? 0,
|
||||
WarnCount = counts.FirstOrDefault(x => x.ProblemType == (int)TrackProblemType.Warn)?.Count ?? 0,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取轨迹推送记录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <param name="orderId">订单id</param>
|
||||
[HttpGet]
|
||||
public async Task<List<TrackPushRecordIndex>> GetTrackPushRecordsAsync(int orderId)
|
||||
{
|
||||
return await _trackPushRecordsRepository.GetTrackPushRecordsAsync(orderId);
|
||||
}
|
||||
}
|
||||
@ -3,12 +3,12 @@ using SJZY.Expand.ABP.Core;
|
||||
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
using SJZY.Track.Application.Contract.Services;
|
||||
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
using SJZY.Track.Domain.Dtos.TrackPull;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.Services.TrackPull;
|
||||
|
||||
public class TrackPullCacheService : ApplicationService, ITrackPullCacheService, ITransientDependency
|
||||
public class TrackPullCacheService : ApplicationService, ITrackPullCacheService
|
||||
{
|
||||
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
||||
|
||||
|
||||
@ -9,7 +9,6 @@ using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Common;
|
||||
using SJZY.Track.Domain.Dtos.TrackPull;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.Services.TrackPull;
|
||||
|
||||
@ -18,7 +17,7 @@ namespace SJZY.Track.Application.Services.TrackPull;
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "轨迹拉取")]
|
||||
[Route("/Track/PullConfig")]
|
||||
public class TrackPullService : ApplicationService, ITransientDependency
|
||||
public class TrackPullService : ApplicationService
|
||||
{
|
||||
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
|
||||
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
||||
@ -100,52 +99,57 @@ public class TrackPullService : ApplicationService, ITransientDependency
|
||||
switch (input.Options)
|
||||
{
|
||||
case OptionTypeNoNull.新增:
|
||||
{
|
||||
var trackPullEntity = ObjectMapper.Map<EditTrackPullConfigInput, TrackPullConfigEntity>(input);
|
||||
var trackPullParamsEntity =
|
||||
ObjectMapper.Map<EditTrackPullConfigInput, TrackPushPullParamsConfigEntity>(input);
|
||||
|
||||
int id;
|
||||
|
||||
using (var ts = TransactionScopeHelper.Create())
|
||||
{
|
||||
var trackPullEntity = ObjectMapper.Map<EditTrackPullConfigInput, TrackPullConfigEntity>(input);
|
||||
var trackPullParamsEntity = ObjectMapper.Map<EditTrackPullConfigInput, TrackPushPullParamsConfigEntity>(input);
|
||||
id = await _trackPullConfigRepository.InsertReturnIdentityAsync(trackPullEntity);
|
||||
|
||||
int id = 0;
|
||||
trackPullParamsEntity.PullOrPushConfigId = id;
|
||||
await _trackPullConfigRepository.InsertParamsAsync(trackPullParamsEntity);
|
||||
|
||||
using (var ts = TransactionScopeHelper.Create())
|
||||
{
|
||||
id = await _trackPullConfigRepository.InsertReturnIdentityAsync(trackPullEntity);
|
||||
|
||||
trackPullParamsEntity.PullOrPushConfigId = id;
|
||||
await _trackPullConfigRepository.InsertParamsAsync(trackPullParamsEntity);
|
||||
|
||||
ts.Complete();
|
||||
}
|
||||
|
||||
await _trackPullCacheService.SetPullConfigAsync(id);
|
||||
ts.Complete();
|
||||
}
|
||||
|
||||
await _trackPullCacheService.SetPullConfigAsync(id);
|
||||
}
|
||||
break;
|
||||
|
||||
case OptionTypeNoNull.修改:
|
||||
{
|
||||
var oldTrackPullEntity = await _trackPullConfigRepository.GetFirstAsync(x => x.Id == input.Id) ??
|
||||
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||
|
||||
var oldTrackPullParamsEntity =
|
||||
await _trackPullConfigRepository.GetParamsSingleAsync(x =>
|
||||
x.PullOrPushConfigId == input.Id && !x.IsPush);
|
||||
|
||||
ObjectMapper.Map(input, oldTrackPullEntity);
|
||||
ObjectMapper.Map(input, oldTrackPullParamsEntity);
|
||||
|
||||
using (var ts = TransactionScopeHelper.Create())
|
||||
{
|
||||
var oldTrackPullEntity = await _trackPullConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||
await _trackPullConfigRepository.UpdateAsync(oldTrackPullEntity);
|
||||
await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPullParamsEntity);
|
||||
|
||||
var oldTrackPullParamsEntity = await _trackPullConfigRepository.GetParamsSingleAsync(x => x.PullOrPushConfigId == input.Id && !x.IsPush);
|
||||
|
||||
ObjectMapper.Map(input, oldTrackPullEntity);
|
||||
ObjectMapper.Map(input, oldTrackPullParamsEntity);
|
||||
|
||||
using (var ts = TransactionScopeHelper.Create())
|
||||
{
|
||||
await _trackPullConfigRepository.UpdateAsync(oldTrackPullEntity);
|
||||
await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPullParamsEntity);
|
||||
|
||||
ts.Complete();
|
||||
}
|
||||
|
||||
await _trackPullCacheService.SetPullConfigAsync(input.Id);
|
||||
ts.Complete();
|
||||
}
|
||||
|
||||
await _trackPullCacheService.SetPullConfigAsync(input.Id);
|
||||
}
|
||||
break;
|
||||
|
||||
case OptionTypeNoNull.删除:
|
||||
using (var ts = TransactionScopeHelper.Create())
|
||||
{
|
||||
await _trackPullConfigRepository.SoftDeleteAsync(x => x.Id == input.Id);
|
||||
await _trackPullConfigRepository.SoftDeleteParamsAsync(x => x.PullOrPushConfigId == input.Id && !x.IsPush);
|
||||
await _trackPullConfigRepository.SoftDeleteParamsAsync(x =>
|
||||
x.PullOrPushConfigId == input.Id && !x.IsPush);
|
||||
await _trackPullConfigRepository.SoftDeleteContentAsync(x => x.TrackPullConfigId == input.Id);
|
||||
|
||||
ts.Complete();
|
||||
@ -171,21 +175,32 @@ public class TrackPullService : ApplicationService, ITransientDependency
|
||||
{
|
||||
if (input.Options != OptionTypeNoNull.删除)
|
||||
{
|
||||
Expression<Func<TrackPullContentConfigEntity, bool>> isContentAnyExp = x => x.TrackPullConfigId == input.TrackPullConfigId;
|
||||
Expression<Func<TrackPullContentConfigEntity, bool>> isContentAnyExp = x =>
|
||||
x.TrackPullConfigId == input.TrackPullConfigId;
|
||||
if (input.Options == OptionTypeNoNull.修改) isContentAnyExp = isContentAnyExp.And(x => x.Id != input.Id);
|
||||
|
||||
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentId == input.TrackContentId)))
|
||||
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||
x.TrackContentId == input.TrackContentId)))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentAny"]);
|
||||
else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentCodeValue == input.TrackContentCodeValue)))
|
||||
else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() &&
|
||||
await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||
x.TrackContentCodeValue == input.TrackContentCodeValue)))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentCodeValueAny"]);
|
||||
else if (!input.TrackStatusValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackStatusValue == input.TrackStatusValue)))
|
||||
else if (!input.TrackStatusValue.IsNullOrWhiteSpace() &&
|
||||
await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||
x.TrackStatusValue == input.TrackStatusValue)))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentStatusValueAny"]);
|
||||
else if (!input.TrackContentValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentValue == input.TrackContentValue)))
|
||||
else if (!input.TrackContentValue.IsNullOrWhiteSpace() &&
|
||||
await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||
x.TrackContentValue == input.TrackContentValue)))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentValueAny"]);
|
||||
else if (!input.TrackKeywords.IsNullOrEmpty())
|
||||
{
|
||||
Expression<Func<TrackPullContentConfigEntity, bool>> trackKeywordExp = _ => false;
|
||||
input.TrackKeywords!.ForEach(item => { trackKeywordExp = trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item)); });
|
||||
input.TrackKeywords!.ForEach(item =>
|
||||
{
|
||||
trackKeywordExp = trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item));
|
||||
});
|
||||
|
||||
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(trackKeywordExp)))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentKeywordsAny"]);
|
||||
@ -195,38 +210,38 @@ public class TrackPullService : ApplicationService, ITransientDependency
|
||||
switch (input.Options)
|
||||
{
|
||||
case OptionTypeNoNull.新增:
|
||||
{
|
||||
var entity = ObjectMapper.Map<EditTrackPullContentInput, TrackPullContentConfigEntity>(input);
|
||||
{
|
||||
var entity = ObjectMapper.Map<EditTrackPullContentInput, TrackPullContentConfigEntity>(input);
|
||||
|
||||
await _trackPullConfigRepository.InsertContentAsync(entity);
|
||||
await _trackPullCacheService.SetPullConfigAsync(input.TrackPullConfigId);
|
||||
await _trackPullConfigRepository.InsertContentAsync(entity);
|
||||
await _trackPullCacheService.SetPullConfigAsync(input.TrackPullConfigId);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case OptionTypeNoNull.修改:
|
||||
{
|
||||
var oldTrackPullContentEntity = await _trackPullConfigRepository.GetContentByIdAsync(input.Id!.Value) ??
|
||||
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||
{
|
||||
var oldTrackPullContentEntity = await _trackPullConfigRepository.GetContentByIdAsync(input.Id!.Value) ??
|
||||
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||
|
||||
ObjectMapper.Map(input, oldTrackPullContentEntity);
|
||||
ObjectMapper.Map(input, oldTrackPullContentEntity);
|
||||
|
||||
await _trackPullConfigRepository.UpdateContentAsync(oldTrackPullContentEntity);
|
||||
await _trackPullCacheService.SetPullConfigAsync(oldTrackPullContentEntity.TrackPullConfigId);
|
||||
await _trackPullConfigRepository.UpdateContentAsync(oldTrackPullContentEntity);
|
||||
await _trackPullCacheService.SetPullConfigAsync(oldTrackPullContentEntity.TrackPullConfigId);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case OptionTypeNoNull.删除:
|
||||
{
|
||||
var oldTrackPullContentEntity = await _trackPullConfigRepository.GetContentByIdAsync(input.Id!.Value) ??
|
||||
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||
{
|
||||
var oldTrackPullContentEntity = await _trackPullConfigRepository.GetContentByIdAsync(input.Id!.Value) ??
|
||||
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||
|
||||
await _trackPullConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id);
|
||||
await _trackPullCacheService.SetPullConfigAsync(oldTrackPullContentEntity.TrackPullConfigId);
|
||||
await _trackPullConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id);
|
||||
await _trackPullCacheService.SetPullConfigAsync(oldTrackPullContentEntity.TrackPullConfigId);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum,
|
||||
|
||||
@ -3,11 +3,11 @@ using SJZY.Expand.ABP.Core;
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Application.Contract.Services;
|
||||
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
|
||||
namespace SJZY.Track.Application.Services.TrackPush;
|
||||
|
||||
public class TrackPushCacheService : ApplicationService, ITrackPushCacheService, ITransientDependency
|
||||
public class TrackPushCacheService : ApplicationService, ITrackPushCacheService
|
||||
{
|
||||
private readonly ITrackPushConfigRepository _trackPushConfigRepository;
|
||||
|
||||
|
||||
@ -48,6 +48,12 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
[SugarColumn(ColumnName = "LatestPushTrackContentId")]
|
||||
public int? LatestPushTrackContentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最新推送时间(异步维护)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LatestPushTime")]
|
||||
public DateTime? LatestPushTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最新轨迹内容(异步维护)
|
||||
/// </summary>
|
||||
@ -115,10 +121,10 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
public int QuestionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
||||
/// 问题描述
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "ProblemDescription")]
|
||||
public int ProblemDescription { get; set; }
|
||||
public string? ProblemDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 起运港口
|
||||
|
||||
@ -23,8 +23,6 @@ public interface ITrackDetailsRepository
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleteTrackAsync(int orderId, List<string> trackCodes);
|
||||
|
||||
Task<List<TrackDetailsIndex>?> GetListAsync(List<int> orderIds);
|
||||
|
||||
/// <summary>
|
||||
/// 获取最近一条发生的轨迹
|
||||
/// </summary>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using Nest;
|
||||
using SJZY.Expand.ElasticSearch;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
|
||||
@ -11,11 +12,6 @@ public class TrackDetailsIndex : IdBaseIndex
|
||||
/// </summary>
|
||||
public int OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商code
|
||||
/// </summary>
|
||||
public string? ServiceProviderCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
@ -36,11 +32,6 @@ public class TrackDetailsIndex : IdBaseIndex
|
||||
/// </summary>
|
||||
public string TrackStatus { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 原轨迹状态
|
||||
/// </summary>
|
||||
public string? OriginTrackStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容代码
|
||||
/// </summary>
|
||||
@ -57,10 +48,15 @@ public class TrackDetailsIndex : IdBaseIndex
|
||||
public int TrackContentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否意味着完成
|
||||
/// 这条轨迹是否意味着完成(删除回退需要用到)
|
||||
/// </summary>
|
||||
public bool IsCompleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 原轨迹状态
|
||||
/// </summary>
|
||||
public string? OriginTrackStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 原轨迹内容
|
||||
/// </summary>
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||
|
||||
public interface ITrackPushRecordsRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// 添加推送记录
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
Task AddAsync(TrackPushRecordIndex index);
|
||||
|
||||
/// <summary>
|
||||
/// 获取轨迹推送记录
|
||||
/// </summary>
|
||||
/// <param name="orderId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<TrackPushRecordIndex>> GetTrackPushRecordsAsync(int orderId);
|
||||
}
|
||||
@ -0,0 +1,100 @@
|
||||
using Nest;
|
||||
using SJZY.Expand.ElasticSearch;
|
||||
using SJZY.Track.Domain.Consts;
|
||||
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||
|
||||
[ElasticsearchType(RelationName = GlobalConst.TrackPushRecordsIndex)]
|
||||
public class TrackPushRecordIndex : IdBaseIndex
|
||||
{
|
||||
/// <summary>
|
||||
/// 索引名称
|
||||
/// </summary>
|
||||
public string IndexName { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 订单Id
|
||||
/// </summary>
|
||||
public int OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 接口通请求Id
|
||||
/// </summary>
|
||||
public Guid RequestId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 信息
|
||||
/// </summary>
|
||||
public string Message { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 操作类型
|
||||
/// </summary>
|
||||
public string OptionType { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态
|
||||
/// </summary>
|
||||
public string TrackStatus { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容代码
|
||||
/// </summary>
|
||||
public string TrackCode { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容
|
||||
/// </summary>
|
||||
public string TrackContent { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地
|
||||
/// </summary>
|
||||
public string TrackPlace { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时间
|
||||
/// </summary>
|
||||
public DateTime TrackTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时区
|
||||
/// </summary>
|
||||
public float TrackTimeZone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否成功
|
||||
/// </summary>
|
||||
public bool IsSuccess { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹代码参数值
|
||||
/// </summary>
|
||||
public string? TrackContentCodeValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容参数值
|
||||
/// </summary>
|
||||
public string? TrackContentValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容英文参数值
|
||||
/// </summary>
|
||||
public string? TrackEnContentValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态参数值
|
||||
/// </summary>
|
||||
public string? TrackStatusValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扩展字段参数值
|
||||
/// </summary>
|
||||
public string? ExpandFieldsValue { get; set; }
|
||||
|
||||
/// <summary>创建人</summary>
|
||||
public string? CreateUser { get; set; }
|
||||
|
||||
/// <summary>创建时间</summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
||||
14
src/SJZY.Track.Domain/Consts/GlobalConst.ES.cs
Normal file
14
src/SJZY.Track.Domain/Consts/GlobalConst.ES.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace SJZY.Track.Domain.Consts;
|
||||
|
||||
public partial class GlobalConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹明细 es索引名称(模板)
|
||||
/// </summary>
|
||||
public const string TrackIndex = "sjzy_track_details";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹推送记录 es索引名称(模板)
|
||||
/// </summary>
|
||||
public const string TrackPushRecordsIndex = "sjzy_track_push_records";
|
||||
}
|
||||
39
src/SJZY.Track.Domain/Consts/GlobalConst.MQ.cs
Normal file
39
src/SJZY.Track.Domain/Consts/GlobalConst.MQ.cs
Normal file
@ -0,0 +1,39 @@
|
||||
namespace SJZY.Track.Domain.Consts;
|
||||
|
||||
public partial class GlobalConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹新增/更新
|
||||
/// </summary>
|
||||
public const string TrackUpsertSubscribe = "SJZY.Track.TrackUpsert";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹删除
|
||||
/// </summary>
|
||||
public const string TrackDeleteSubscribe = "SJZY.Track.TrackDelete";
|
||||
|
||||
/// <summary>
|
||||
/// 接口通批量轨迹刷新
|
||||
/// </summary>
|
||||
public const string TrackRefreshSubscribe = "SJZY.Track.TrackRefresh";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹推送
|
||||
/// </summary>
|
||||
public const string TrackPushSubscribe = "SJZY.Track.TrackPush";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹新增/更新后触发更新订单主表
|
||||
/// </summary>
|
||||
public const string TrackUpsertAfterUpdateOrderSubscribe = "SJZY.Track.TrackUpsertAfterUpdateOrder";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹推送后触发更新订单主表
|
||||
/// </summary>
|
||||
public const string TrackPushAfterUpdateOrderSubscribe = "SJZY.Traack.TrackPushAfterUpdateOrder";
|
||||
|
||||
/// <summary>
|
||||
/// 关联订单后补轨迹
|
||||
/// </summary>
|
||||
public const string OrderLinkAfterFillTrack = "SJZY.Track.OrderLinkAfterFillTrack";
|
||||
}
|
||||
24
src/SJZY.Track.Domain/Consts/GlobalConst.Redis.cs
Normal file
24
src/SJZY.Track.Domain/Consts/GlobalConst.Redis.cs
Normal file
@ -0,0 +1,24 @@
|
||||
namespace SJZY.Track.Domain.Consts;
|
||||
|
||||
public partial class GlobalConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹要推送的客户redis key前缀
|
||||
/// </summary>
|
||||
public const string TrackPushKeyPrefix = "TrackPush";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹推送内容配置redis key前缀
|
||||
/// </summary>
|
||||
public const string TrackPushContentKeyPrefix = "TrackPushContent";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹拉取配置信息redis key前缀
|
||||
/// </summary>
|
||||
public const string TrackPullKeyPrefix = "TrackPull";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹拉取配置信息redis key前缀
|
||||
/// </summary>
|
||||
public const string TrackPullContentKeyPrefix = "TrackPullContent";
|
||||
}
|
||||
27
src/SJZY.Track.Domain/Consts/InterfaceRelayConst.cs
Normal file
27
src/SJZY.Track.Domain/Consts/InterfaceRelayConst.cs
Normal file
@ -0,0 +1,27 @@
|
||||
namespace SJZY.Track.Domain.Consts;
|
||||
|
||||
/// <summary>
|
||||
/// 接口通常量
|
||||
/// </summary>
|
||||
public class InterfaceRelayConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 接口通成功代码
|
||||
/// </summary>
|
||||
public const string SuccessCode = "200";
|
||||
|
||||
/// <summary>
|
||||
/// 获取轨迹接口代码
|
||||
/// </summary>
|
||||
public const string GetTrackInterfaceCode = "A012";
|
||||
|
||||
/// <summary>
|
||||
/// 推送轨迹接口代码
|
||||
/// </summary>
|
||||
public const string PushTrackInterfaceCode = "A024";
|
||||
|
||||
/// <summary>
|
||||
/// 更新轨迹接口代码
|
||||
/// </summary>
|
||||
public const string TrackUpdateInterfaceCode = "A040";
|
||||
}
|
||||
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SJZY.Track.Domain.Dtos.Order
|
||||
namespace SJZY.Track.Domain.Dtos.Order
|
||||
{
|
||||
public class GetPageTrackOrderInputVO : PageInfoInput
|
||||
{
|
||||
@ -13,21 +7,11 @@ namespace SJZY.Track.Domain.Dtos.Order
|
||||
/// </summary>
|
||||
public int SubSystemId { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 单号
|
||||
///// </summary>
|
||||
//public List<string>? OrderNos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当tab选中 0 默认不传 1 直接写死传值 [1,4] 2 传 [2,4]
|
||||
/// 当tab选中 0 全部 1 异常 2 警告
|
||||
/// </summary>
|
||||
public int TabType { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 当tab选中 1 直接写死传值 [1,4] 2 传 [2,4]
|
||||
///// </summary>
|
||||
//public List<int>? QuestionTypeIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
@ -38,10 +22,15 @@ namespace SJZY.Track.Domain.Dtos.Order
|
||||
/// </summary>
|
||||
public int? CustomerId { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 单号
|
||||
///// </summary>
|
||||
//public string? OrderNos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单号
|
||||
/// </summary>
|
||||
public string? OrderNos { get; set; }
|
||||
public List<string>? OrderNos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间开始
|
||||
@ -137,7 +126,7 @@ namespace SJZY.Track.Domain.Dtos.Order
|
||||
/// <summary>
|
||||
/// 子系统
|
||||
/// </summary>
|
||||
public string SubSystem { get; set; }
|
||||
public string? SubSystem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子系统id
|
||||
@ -158,15 +147,5 @@ namespace SJZY.Track.Domain.Dtos.Order
|
||||
/// 问题类型名称
|
||||
/// </summary>
|
||||
public string? QuestionTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
||||
/// </summary>
|
||||
public int ProblemDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述名称
|
||||
/// </summary>
|
||||
public string? ProblemDescriptionName { get; set; }
|
||||
}
|
||||
}
|
||||
14
src/SJZY.Track.Domain/Dtos/Order/GetTrackCounterVO.cs
Normal file
14
src/SJZY.Track.Domain/Dtos/Order/GetTrackCounterVO.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace SJZY.Track.Domain.Dtos.Order;
|
||||
|
||||
public class GetTrackCounterVO
|
||||
{
|
||||
/// <summary>
|
||||
/// 问题类型
|
||||
/// </summary>
|
||||
public int ProblemType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总条数
|
||||
/// </summary>
|
||||
public int Count { get; set; }
|
||||
}
|
||||
@ -31,4 +31,9 @@ public class LinkedOrderVO
|
||||
/// 客户id
|
||||
/// </summary>
|
||||
public int CustomId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单是否完成
|
||||
/// </summary>
|
||||
public bool IsCompleted { get; set; }
|
||||
}
|
||||
18
src/SJZY.Track.Domain/Enums/OrderType.cs
Normal file
18
src/SJZY.Track.Domain/Enums/OrderType.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace SJZY.Track.Domain.Enums;
|
||||
|
||||
public enum OrderType
|
||||
{
|
||||
[Description("干线提单")]
|
||||
干线提单 = 1,
|
||||
|
||||
[Description("小包运单")]
|
||||
小包运单 = 2,
|
||||
|
||||
[Description("箱/袋单")]
|
||||
箱袋单 = 3,
|
||||
|
||||
[Description("FBA订单")]
|
||||
FBA订单 = 4,
|
||||
}
|
||||
@ -1,15 +1,25 @@
|
||||
namespace SJZY.Track.Domain.Enums;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace SJZY.Track.Domain.Enums;
|
||||
|
||||
[Flags]
|
||||
public enum TrackProblemType
|
||||
{
|
||||
/// <summary>
|
||||
/// 没问题
|
||||
/// </summary>
|
||||
[Description("无")]
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 异常
|
||||
/// </summary>
|
||||
[Description("异常")]
|
||||
Error = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 预警
|
||||
/// </summary>
|
||||
[Description("预警")]
|
||||
Warn = 2,
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
namespace SJZY.Track.Domain;
|
||||
|
||||
public class GlobalConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹明细 es索引名称
|
||||
/// </summary>
|
||||
public const string TrackIndex = "sjzy_track_details";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹新增/更新 mq订阅名称
|
||||
/// </summary>
|
||||
public const string TrackUpsertSubscribe = "SJZY.Track.TrackUpsert";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹删除 mq订阅名称
|
||||
/// </summary>
|
||||
public const string TrackDeleteSubscribe = "SJZY.Track.TrackDelete";
|
||||
|
||||
/// <summary>
|
||||
/// 接口通批量轨迹刷新 mq订阅名称
|
||||
/// </summary>
|
||||
public const string TrackRefreshSubscribe = "SJZY.Track.TrackRefresh";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹新增/更新后触发更新订单轨迹 mq订阅名称
|
||||
/// </summary>
|
||||
public const string UpdateOrderTrackSubscribe = "SJZY.Track.UpdateOrderTrack";
|
||||
|
||||
/// <summary>
|
||||
/// 关联订单后补轨迹 mq订阅名称
|
||||
/// </summary>
|
||||
public const string OrderLinkAfterFillTrack = "SJZY.Track.OrderLinkAfterFillTrack";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹要推送的客户redis key前缀
|
||||
/// </summary>
|
||||
public const string TrackPushKeyPrefix = "TrackPush";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹推送内容配置redis key前缀
|
||||
/// </summary>
|
||||
public const string TrackPushContentKeyPrefix = "TrackPushContent";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹拉取配置信息redis key前缀
|
||||
/// </summary>
|
||||
public const string TrackPullKeyPrefix = "TrackPull";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹拉取配置信息redis key前缀
|
||||
/// </summary>
|
||||
public const string TrackPullContentKeyPrefix = "TrackPullContent";
|
||||
}
|
||||
@ -10,4 +10,10 @@ public interface ITrackOrderQueries
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<UnifyPageResultDto<TrackOrderVO>> GetPageTrackOrder(GetPageTrackOrderInputVO input);
|
||||
|
||||
/// <summary>
|
||||
/// 获取轨迹各个问题数
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<GetTrackCounterVO>> GetTrackProblemCountsAsync();
|
||||
}
|
||||
@ -113,7 +113,7 @@ public class ProvideQueries : ISugarRepository, IProvideQueries,
|
||||
return await Context.Queryable<OrderEntity>()
|
||||
.LeftJoin<OrderTemplateEntity>((a, b) => a.Id == b.OrderId)
|
||||
.LeftJoin<VServiceProviderEntity>((a, b, c) => b.ServiceProviderId == c.Id)
|
||||
.Where(a => orderNos.Contains(a.OrderNo))
|
||||
.Where(a => !a.IsCompleted && orderNos.Contains(a.OrderNo))
|
||||
.Select((a, b, c) => new OrderWithServiceProviderVO
|
||||
{
|
||||
OrderNo = a.OrderNo,
|
||||
|
||||
@ -24,30 +24,11 @@ public class TrackOrderQueries : ISugarRepository, ITrackOrderQueries,
|
||||
/// <returns></returns>
|
||||
public async Task<UnifyPageResultDto<TrackOrderVO>> GetPageTrackOrder(GetPageTrackOrderInputVO input)
|
||||
{
|
||||
List<string> orderNoList = new List<string>();
|
||||
List<int> questionTypeIds = new List<int>();
|
||||
int ques = 0;
|
||||
if (!input.OrderNos.IsNullOrWhiteSpace())
|
||||
{
|
||||
orderNoList = input.OrderNos!.Split(new[] { ',', ',', ':', ':' }).ToList();
|
||||
}
|
||||
|
||||
if (input.TabType == 1)
|
||||
{
|
||||
questionTypeIds = new List<int> { 1, 4 };
|
||||
ques = questionTypeIds.Sum();
|
||||
}
|
||||
else if (input.TabType == 2)
|
||||
{
|
||||
questionTypeIds = new List<int> { 2, 4 };
|
||||
ques = questionTypeIds.Sum();
|
||||
}
|
||||
|
||||
var pageList = await Context.Queryable<OrderEntity>()
|
||||
.LeftJoin<VExternalSubjectEntity>((a, b) => a.CustomId == b.Id && b.IsDeleted == false)
|
||||
.LeftJoin<VSystemEntity>((a, b, c) => a.SubSystemId == c.Id && c.IsDeleted == false)
|
||||
.WhereIF(input.SubSystemId > 0, (a, b, c) => a.SubSystemId == input.SubSystemId)
|
||||
.WhereIF(!orderNoList.IsNullOrEmpty(), (a, b, c) => orderNoList.Contains(a.OrderNo))
|
||||
.WhereIF(!input.OrderNos.IsNullOrEmpty(), (a, b, c) => input.OrderNos!.Contains(a.OrderNo))
|
||||
.WhereIF(input.CreateTimeStart.HasValue && input.CreateTimeEnd.HasValue,
|
||||
(a, b, c) => a.CreateTime >= input.CreateTimeStart && a.CreateTime <= input.CreateTimeEnd)
|
||||
.WhereIF(input.CreateTimeStart.HasValue && (!input.CreateTimeEnd.HasValue),
|
||||
@ -56,32 +37,17 @@ public class TrackOrderQueries : ISugarRepository, ITrackOrderQueries,
|
||||
(a, b, c) => a.CreateTime <= input.CreateTimeEnd)
|
||||
.WhereIF(input.CustomerId > 0, (a, b, c) => a.CustomId == input.CustomerId)
|
||||
.WhereIF(input.TrackOrderType > 0, (a, b, c) => a.OrderType == input.TrackOrderType)
|
||||
.WhereIF(input.TabType > 0 && !questionTypeIds.IsNullOrEmpty(), (a, b, c) => (a.QuestionType & ques) > 0)
|
||||
.WhereIF(input.TabType > 0, (a, b, c) => a.QuestionType == input.TabType)
|
||||
.OrderByDescending((a, b, c) => a.CreateTime)
|
||||
.Select((a, b, c) => new TrackOrderVO
|
||||
{
|
||||
Id = a.Id,
|
||||
OrderNumber = a.OrderNo,
|
||||
OrderType = a.OrderType,
|
||||
OrderTypeName = SqlFunc.IF(a.OrderType == 1).Return("干线提单").ElseIF(a.OrderType == 2).Return("小包运单")
|
||||
.ElseIF(a.OrderType == 3)
|
||||
.Return("箱/袋单").ElseIF(a.OrderType == 4).Return("FBA订单").End(""),
|
||||
QuestionType = a.QuestionType,
|
||||
CustomerShortName = b.Abbreviation,
|
||||
CustomerCode = b.Code,
|
||||
CustomerId = a.CustomId,
|
||||
QuestionType = a.QuestionType,
|
||||
QuestionTypeName = SqlFunc.IF(a.QuestionType == 1).Return("异常").ElseIF(a.QuestionType == 2).Return("预警")
|
||||
.End(""),
|
||||
ProblemDescription = a.ProblemDescription,
|
||||
ProblemDescriptionName = SqlFunc.IF(a.ProblemDescription == 1).Return("推送异常")
|
||||
.ElseIF(a.ProblemDescription == 2).Return("推送预警").End(""),
|
||||
//TrackTemplateNames = SqlFunc.Subqueryable<OrderTemplateEntity>()
|
||||
// .LeftJoin<TrackTemplateEntity>((aa, bb) => aa.TrackTemplateId == bb.Id)
|
||||
// .Where((aa, bb) => a.Id == aa.OrderId).SelectStringJoin((aa, bb) => bb.Name, ","),
|
||||
|
||||
//TrackTemplateIds = SqlFunc.Subqueryable<OrderTemplateEntity>()
|
||||
// .LeftJoin<TrackTemplateEntity>((aa, bb) => aa.TrackTemplateId == bb.Id)
|
||||
// .Where((aa, bb) => a.Id == aa.OrderId).SelectStringJoin((aa, bb) => bb.Id, ","),
|
||||
NewestTrackContent = a.LatestTrackContent,
|
||||
NewestTrackEnContent = a.LatestTrackEnContent,
|
||||
NewestTrackPlace = a.LatestTrackPlace,
|
||||
@ -114,4 +80,16 @@ public class TrackOrderQueries : ISugarRepository, ITrackOrderQueries,
|
||||
|
||||
return pageList;
|
||||
}
|
||||
|
||||
public async Task<List<GetTrackCounterVO>> GetTrackProblemCountsAsync()
|
||||
{
|
||||
return await Context.Queryable<OrderEntity>()
|
||||
.GroupBy(x => x.QuestionType)
|
||||
.Select(x => new GetTrackCounterVO
|
||||
{
|
||||
ProblemType = x.QuestionType,
|
||||
Count = SqlFunc.AggregateCount(1)
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
@ -67,7 +67,8 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
OrderNo = b.OrderNo,
|
||||
SubSystemId = b.SubSystemId,
|
||||
LatestPushTrackContentId = b.LatestPushTrackContentId,
|
||||
CustomId = b.CustomId
|
||||
CustomId = b.CustomId,
|
||||
IsCompleted = b.IsCompleted
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
|
||||
CreateUser = e.Name,
|
||||
UpdateTime = a.UpdateTime,
|
||||
UpdateUser = f.Name,
|
||||
IsFinish= a.IsCompleted
|
||||
IsFinish = a.IsCompleted
|
||||
})
|
||||
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||
|
||||
@ -97,21 +97,21 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
|
||||
public async Task<List<GetTemplateContentAttributeValueVO>> GetTrackContentAttributeValue(GetTemplateContentAttributeValueInputVO input)
|
||||
{
|
||||
var list = await Context.Queryable<TrackContentEntity>()
|
||||
.LeftJoin<TrackTemplateContentEntity>((a, b) => a.Id==b.TrackContentId&& b.TrackTemplateId>0 && b.IsDeleted==false)
|
||||
.LeftJoin<TrackTemplateEntity>((a, b, c) => b.TrackTemplateId==c.Id&& c.IsDeleted==false)
|
||||
.WhereIF(!input.TrackCodes.IsNullOrEmpty(), (a, b, c) => input.TrackCodes.Contains(a.Code))
|
||||
.WhereIF(input.SubSystemId>0, (a, b, c) => a.SubSystemId==input.SubSystemId)
|
||||
.WhereIF(!input.TrackTemplateIds.IsNullOrEmpty(), (a, b, c) => input.TrackTemplateIds.Contains(c.Id))
|
||||
.Where((a, b, c) => c.Id>0)
|
||||
.LeftJoin<TrackTemplateContentEntity>((a, b) => a.Id == b.TrackContentId && b.TrackTemplateId > 0 && b.IsDeleted == false)
|
||||
.LeftJoin<TrackTemplateEntity>((a, b, c) => b.TrackTemplateId == c.Id && c.IsDeleted == false)
|
||||
.WhereIF(!input.TrackCodes.IsNullOrEmpty(), (a, b, c) => input.TrackCodes!.Contains(a.Code))
|
||||
.WhereIF(input.SubSystemId > 0, (a, b, c) => a.SubSystemId == input.SubSystemId)
|
||||
.WhereIF(!input.TrackTemplateIds.IsNullOrEmpty(), (a, b, c) => input.TrackTemplateIds!.Contains(c.Id))
|
||||
.Where((a, b, c) => c.Id > 0)
|
||||
//.OrderByIF(!input.TrackTemplateIds.IsNullOrEmpty(), (a, b, c) => SqlFunc.IIF(input.TrackTemplateIds.Contains(a.Id), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), c.CreateTime), OrderByType.Desc)
|
||||
.Select((a, b, c) => new GetTemplateContentAttributeValueVO
|
||||
{
|
||||
IsCanDelete=b.IsCanDelete,
|
||||
IsExternal=b.IsExternal,
|
||||
SubSystemId= a.SubSystemId,
|
||||
TrackCode= a.Code,
|
||||
TrackContenId= a.Id,
|
||||
TrackTemplateId=c.Id
|
||||
IsCanDelete = b.IsCanDelete,
|
||||
IsExternal = b.IsExternal,
|
||||
SubSystemId = a.SubSystemId,
|
||||
TrackCode = a.Code,
|
||||
TrackContenId = a.Id,
|
||||
TrackTemplateId = c.Id
|
||||
}).ToListAsync();
|
||||
|
||||
return list;
|
||||
@ -125,9 +125,9 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
|
||||
public async Task<bool> GetTemplateIsExist(int trackContentId)
|
||||
{
|
||||
//var trackTemplateContents = await _trackTemplateContentBasicQuery.GetListAsync(a => a.TrackContentId == input.Id);
|
||||
var trackContentEntities = await Context.Queryable<TrackContentEntity>().LeftJoin<TrackTemplateContentEntity>((a, b) => a.Id==b.TrackContentId && b.IsDeleted==false)
|
||||
.LeftJoin<TrackTemplateEntity>((a, b, c) => b.TrackTemplateId==c.Id&& c.IsDeleted==false)
|
||||
.Where((a, b, c) => a.Id==trackContentId)
|
||||
var trackContentEntities = await Context.Queryable<TrackContentEntity>().LeftJoin<TrackTemplateContentEntity>((a, b) => a.Id == b.TrackContentId && b.IsDeleted == false)
|
||||
.LeftJoin<TrackTemplateEntity>((a, b, c) => b.TrackTemplateId == c.Id && c.IsDeleted == false)
|
||||
.Where((a, b, c) => a.Id == trackContentId)
|
||||
.Select((a, b, c) => new
|
||||
{
|
||||
TrackContentId = a.Id,
|
||||
@ -135,7 +135,7 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
if (trackContentEntities.Any(a => a.TemplateId>0))
|
||||
if (trackContentEntities.Any(a => a.TemplateId > 0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -87,9 +87,30 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
return data.Documents.ToList();
|
||||
}
|
||||
|
||||
public Task<List<TrackDetailsIndex>> GetListAsync(int orderType, List<string> orderNos, string trackCode)
|
||||
public async Task<List<TrackDetailsIndex>> GetListAsync(int orderType, List<string> orderNos, string trackCode)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (orderNos.Count < 1) return new List<TrackDetailsIndex>();
|
||||
|
||||
var data = await Context.SearchAsync<TrackDetailsIndex>(x => x
|
||||
.Source(s => s.Includes(fd => fd
|
||||
.Field(f => f.OrderNo)
|
||||
.Field(f => f.TrackStatus)
|
||||
.Field(f => f.TrackCode)
|
||||
.Field(f => f.TrackContent)
|
||||
.Field(f => f.TrackPlace)
|
||||
.Field(f => f.TrackTime)
|
||||
.Field(f => f.TrackTimeZone)
|
||||
))
|
||||
.Query(q =>
|
||||
q.Terms(t => t
|
||||
.Field(f => f.OrderNo.Suffix("keyword"))
|
||||
.Terms(orderNos))
|
||||
&& q.Term(f => f.OrderType, orderType)
|
||||
&& q.Term(f => f.TrackCode.Suffix("keyword"), trackCode)
|
||||
)
|
||||
);
|
||||
|
||||
return data.Documents.ToList();
|
||||
}
|
||||
|
||||
public async Task<List<TrackDetailsIndex>> GetListAsync(int orderId)
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
using Nest;
|
||||
using SJZY.Expand.ABP.Core.Logger;
|
||||
using SJZY.Expand.ElasticSearch.Services;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||
|
||||
namespace SJZY.Track.Repository.Repositories;
|
||||
|
||||
public class TrackPushRecordsRepository : ElasticSearchContextAbstract<TrackDetailsIndex>, ITrackPushRecordsRepository,
|
||||
ITransientDependency
|
||||
{
|
||||
public TrackPushRecordsRepository(ConnectionFactory connectionFactory) : base(connectionFactory)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task AddAsync(TrackPushRecordIndex index)
|
||||
{
|
||||
// 按天写入es
|
||||
var r = await Context.IndexAsync(index, request => request
|
||||
.Index(index.IndexName)
|
||||
//.Refresh(Refresh.True) // 可选:立即刷新索引使更改立即可见
|
||||
);
|
||||
|
||||
if (!r.IsValid)
|
||||
{
|
||||
LogHelper.Error($"轨迹推送记录写入es失败,原因:{r.DebugInformation}。");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<TrackPushRecordIndex>> GetTrackPushRecordsAsync(int orderId)
|
||||
{
|
||||
var data = await Context.SearchAsync<TrackPushRecordIndex>(x => x
|
||||
.Query(q =>
|
||||
q.Term(t => t.OrderId, orderId)
|
||||
)
|
||||
.Size(1000)
|
||||
.Sort(s => s.Field(f => f.CreateTime, SortOrder.Descending)));
|
||||
|
||||
return data.Documents.ToList();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user