Merge branch 'S02-轨迹中台' into test
# Conflicts: # src/SJZY.Track.Application/Services/TrackOrders/TrackOrderService.cs
This commit is contained in:
commit
7fedecd37c
@ -0,0 +1,44 @@
|
|||||||
|
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
|
|
||||||
|
public class TrackPushContentConfigDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 扩展字段参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? ExpandFieldsValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推送单号类型(主数据枚举TrackOrderType)
|
||||||
|
/// </summary>
|
||||||
|
public int OrderType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹代码参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackContentCodeValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容id
|
||||||
|
/// </summary>
|
||||||
|
public int TrackContentId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackContentValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容英文参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackEnContentValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹状态参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackStatusValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹时区GMT
|
||||||
|
/// </summary>
|
||||||
|
public double? TrackTimeZone { get; set; }
|
||||||
|
}
|
||||||
@ -1,8 +1,19 @@
|
|||||||
namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
|
namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||||
|
|
||||||
public class TrackPullConfigDto
|
public class TrackPullConfigDto
|
||||||
{
|
{
|
||||||
public TrackPullParamConfigDto ParamConfig { get; set; }
|
/// <summary>
|
||||||
|
/// 服务商拉取频率(分钟)
|
||||||
|
/// </summary>
|
||||||
|
public int PullInterval { get; set; }
|
||||||
|
|
||||||
public List<TrackPullContentConfigDto> ContentConfigs { get; set; }
|
/// <summary>
|
||||||
|
/// 服务商id
|
||||||
|
/// </summary>
|
||||||
|
public int ServiceProviderId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 子系统id
|
||||||
|
/// </summary>
|
||||||
|
public int SubSystemId { get; set; }
|
||||||
}
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||||
|
|
||||||
|
public class TrackPullParamWithContentConfigDto
|
||||||
|
{
|
||||||
|
public TrackPullParamConfigDto ParamConfig { get; set; }
|
||||||
|
|
||||||
|
public List<TrackPullContentConfigDto> ContentConfigs { get; set; }
|
||||||
|
}
|
||||||
@ -20,9 +20,9 @@ public class TrackUpsertEvent : UpsertTrackInput
|
|||||||
public int SubSystemId { get; set; }
|
public int SubSystemId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 订单是否推送完成(异步维护)
|
/// 最新推送代码(异步维护)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsPushCompleted { get; set; }
|
public int? LatestPushTrackContentId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上游子系统id
|
/// 上游子系统id
|
||||||
|
|||||||
@ -41,4 +41,9 @@ public class UpdateOrderTrackEvent
|
|||||||
/// 轨迹时区
|
/// 轨迹时区
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float TrackTimeZone { get; set; }
|
public float TrackTimeZone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹代码
|
||||||
|
/// </summary>
|
||||||
|
public string TrackCode { get; set; } = null!;
|
||||||
}
|
}
|
||||||
@ -4,13 +4,22 @@ namespace SJZY.Track.Application.Contract.Services;
|
|||||||
|
|
||||||
public interface ITrackPullCacheService
|
public interface ITrackPullCacheService
|
||||||
{
|
{
|
||||||
|
string TrackPullKey(int subSystemId, int serviceProviderId);
|
||||||
|
string TrackPullContentKey(int subSystemId, int serviceProviderId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有拉取配置
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<TrackPullConfigDto>> GetAllPullConfigsAsync();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取服务商拉取配置
|
/// 获取服务商拉取配置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="subSystemId">子系统id</param>
|
/// <param name="subSystemId">子系统id</param>
|
||||||
/// <param name="serviceProviderId">服务商id</param>
|
/// <param name="serviceProviderId">服务商id</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<TrackPullConfigDto> GetPullConfigAsync(int subSystemId, int serviceProviderId);
|
Task<TrackPullParamWithContentConfigDto> GetPullParamWithContentConfigAsync(int subSystemId, int serviceProviderId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置拉取配置缓存
|
/// 设置拉取配置缓存
|
||||||
@ -19,5 +28,6 @@ public interface ITrackPullCacheService
|
|||||||
/// <param name="subSystemId">子系统id</param>
|
/// <param name="subSystemId">子系统id</param>
|
||||||
/// <param name="serviceProviderId">服务商id</param>
|
/// <param name="serviceProviderId">服务商id</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<TrackPullConfigDto> SetPullConfigAsync(int? id = null, int? subSystemId = null, int? serviceProviderId = null);
|
Task<TrackPullParamWithContentConfigDto> SetPullConfigAsync(int? id = null, int? subSystemId = null,
|
||||||
|
int? serviceProviderId = null);
|
||||||
}
|
}
|
||||||
@ -1,4 +1,6 @@
|
|||||||
namespace SJZY.Track.Application.Contract.Services;
|
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Application.Contract.Services;
|
||||||
|
|
||||||
public interface ITrackPushCacheService
|
public interface ITrackPushCacheService
|
||||||
{
|
{
|
||||||
@ -9,6 +11,24 @@ public interface ITrackPushCacheService
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> IsPushAsync(int customId);
|
Task<bool> IsPushAsync(int customId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取服务商拉取配置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="subSystemId">子系统id</param>
|
||||||
|
/// <param name="customId">服务商id</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<TrackPushContentConfigDto>> GetPushContentConfigsAsync(int subSystemId, int customId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据轨迹代码推断下一个(升序)要推送的内容,如果找不到或者已经是最后一个了,返回null
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="subSystemId"></param>
|
||||||
|
/// <param name="customId"></param>
|
||||||
|
/// <param name="trackContentId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<TrackPushContentConfigDto?> InferNextPushContentOrNullAsync(int subSystemId, int customId,
|
||||||
|
int? trackContentId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新缓存
|
/// 更新缓存
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -31,7 +31,7 @@ public class OrderLinkAfterFillTrackHandler : ITransientDependency, ICapSubscrib
|
|||||||
var order = await _orderRepository.GetFirstAsync(x =>
|
var order = await _orderRepository.GetFirstAsync(x =>
|
||||||
x.Id == linkOrderId, x => new
|
x.Id == linkOrderId, x => new
|
||||||
{
|
{
|
||||||
x.OrderType, x.OrderNo, x.CustomId, x.IsPushCompleted, x.SubSystemId
|
x.OrderType, x.OrderNo, x.CustomId, LatestPushCode = x.LatestPushTrackContentId, x.SubSystemId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (order == default) continue;
|
if (order == default) continue;
|
||||||
@ -50,7 +50,7 @@ public class OrderLinkAfterFillTrackHandler : ITransientDependency, ICapSubscrib
|
|||||||
OrderId = linkOrderId,
|
OrderId = linkOrderId,
|
||||||
CustomId = order.CustomId,
|
CustomId = order.CustomId,
|
||||||
SubSystemId = order.SubSystemId,
|
SubSystemId = order.SubSystemId,
|
||||||
IsPushCompleted = order.IsPushCompleted,
|
LatestPushTrackContentId = order.LatestPushCode,
|
||||||
UpSubSystemId = @event.SubSystemId,
|
UpSubSystemId = @event.SubSystemId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,9 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
// tips:attach返回的是服务商id,必有
|
// tips:attach返回的是服务商id,必有
|
||||||
var attach = JsonConvert.DeserializeObject<TrackRefreshAttach>(@event.Attach);
|
var attach = JsonConvert.DeserializeObject<TrackRefreshAttach>(@event.Attach);
|
||||||
if (attach is null) return;
|
if (attach is null) return;
|
||||||
var config = await _trackPullCacheService.GetPullConfigAsync(attach.SubSystemId, attach.ServiceProviderId);
|
var config =
|
||||||
|
await _trackPullCacheService.GetPullParamWithContentConfigAsync(attach.SubSystemId,
|
||||||
|
attach.ServiceProviderId);
|
||||||
|
|
||||||
var data = JObject.Parse(@event.Data.ToString()!);
|
var data = JObject.Parse(@event.Data.ToString()!);
|
||||||
var orderToken = data[config.ParamConfig.OrderPath];
|
var orderToken = data[config.ParamConfig.OrderPath];
|
||||||
@ -51,16 +53,17 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task HandleOrderAsync(JToken orderToken, TrackPullConfigDto config, int orderType)
|
private async Task HandleOrderAsync(JToken orderToken, TrackPullParamWithContentConfigDto paramWithContentConfig,
|
||||||
|
int orderType)
|
||||||
{
|
{
|
||||||
var paramConfig = config.ParamConfig;
|
var paramConfig = paramWithContentConfig.ParamConfig;
|
||||||
var orderNo = orderToken[paramConfig.OrderNoName]?.Value<string>();
|
var orderNo = orderToken[paramConfig.OrderNoName]?.Value<string>();
|
||||||
if (orderNo.IsNullOrWhiteSpace()) return;
|
if (orderNo.IsNullOrWhiteSpace()) return;
|
||||||
|
|
||||||
var order = await _orderRepository.GetFirstAsync(x =>
|
var order = await _orderRepository.GetFirstAsync(x =>
|
||||||
x.OrderType == orderType && x.OrderNo == orderNo, x => new
|
x.OrderType == orderType && x.OrderNo == orderNo, x => new
|
||||||
{
|
{
|
||||||
x.Id, x.SubSystemId, x.IsPushCompleted, x.CustomId
|
x.Id, x.SubSystemId, LatestPushCode = x.LatestPushTrackContentId, x.CustomId
|
||||||
});
|
});
|
||||||
if (order == default) return;
|
if (order == default) return;
|
||||||
|
|
||||||
@ -70,7 +73,7 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
{
|
{
|
||||||
OrderId = order.Id,
|
OrderId = order.Id,
|
||||||
SubSystemId = order.SubSystemId,
|
SubSystemId = order.SubSystemId,
|
||||||
IsPushCompleted = order.IsPushCompleted,
|
LatestPushTrackContentId = order.LatestPushCode,
|
||||||
CustomId = order.CustomId,
|
CustomId = order.CustomId,
|
||||||
OrderType = orderType,
|
OrderType = orderType,
|
||||||
OrderNo = orderNo!,
|
OrderNo = orderNo!,
|
||||||
@ -80,21 +83,21 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
{
|
{
|
||||||
foreach (var item in trackTokens)
|
foreach (var item in trackTokens)
|
||||||
{
|
{
|
||||||
await HandleTrackAsync(item, config, trackUpsertEvent);
|
await HandleTrackAsync(item, paramWithContentConfig, trackUpsertEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (orderToken is JObject)
|
else if (orderToken is JObject)
|
||||||
{
|
{
|
||||||
await HandleTrackAsync(orderToken, config, trackUpsertEvent);
|
await HandleTrackAsync(orderToken, paramWithContentConfig, trackUpsertEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task HandleTrackAsync(JToken trackToken, TrackPullConfigDto config,
|
private async Task HandleTrackAsync(JToken trackToken, TrackPullParamWithContentConfigDto paramWithContentConfig,
|
||||||
TrackUpsertEvent @event)
|
TrackUpsertEvent @event)
|
||||||
{
|
{
|
||||||
var trackUpsertEvent = @event.DeepCopy();
|
var trackUpsertEvent = @event.DeepCopy();
|
||||||
var paramConfig = config.ParamConfig;
|
var paramConfig = paramWithContentConfig.ParamConfig;
|
||||||
var contentConfigs = config.ContentConfigs;
|
var contentConfigs = paramWithContentConfig.ContentConfigs;
|
||||||
TrackPullContentConfigDto? matchedContentConfig = null;
|
TrackPullContentConfigDto? matchedContentConfig = null;
|
||||||
|
|
||||||
// 1、匹配轨迹代码
|
// 1、匹配轨迹代码
|
||||||
|
|||||||
@ -88,6 +88,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
TrackStatus = trackContent.Status,
|
TrackStatus = trackContent.Status,
|
||||||
TrackCode = @event.TrackCode,
|
TrackCode = @event.TrackCode,
|
||||||
TrackContent = trackContent.Content,
|
TrackContent = trackContent.Content,
|
||||||
|
TrackContentId = trackContent.Id,
|
||||||
IsCompleted = orderIsCompleted,
|
IsCompleted = orderIsCompleted,
|
||||||
TrackEnContent = trackContent.EnContent,
|
TrackEnContent = trackContent.EnContent,
|
||||||
TrackPlace = @event.TrackPlace,
|
TrackPlace = @event.TrackPlace,
|
||||||
@ -97,12 +98,6 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
CreateUser = CurrentUserRequest.CurrentUser.Name,
|
CreateUser = CurrentUserRequest.CurrentUser.Name,
|
||||||
CreateTime = DateTime.Now
|
CreateTime = DateTime.Now
|
||||||
};
|
};
|
||||||
|
|
||||||
// todo:推送只做新增的,更新和删除的不做先
|
|
||||||
if (!@event.IsPushCompleted && await _trackPushCacheService.IsPushAsync(@event.CustomId))
|
|
||||||
{
|
|
||||||
//await PushTrack();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -113,13 +108,24 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
track.UpdateTime = DateTime.Now;
|
track.UpdateTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// upsert es轨迹
|
||||||
await _trackDetailsRepository.UpsertAsync(track);
|
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)
|
||||||
|
{
|
||||||
|
//await PushTrack(content);
|
||||||
|
}
|
||||||
|
|
||||||
// 触发订单主表更新事件
|
// 触发订单主表更新事件
|
||||||
await _capPublisher.PublishAsync(GlobalConst.UpdateOrderTrackSubscribe, new UpdateOrderTrackEvent
|
await _capPublisher.PublishAsync(GlobalConst.UpdateOrderTrackSubscribe, new UpdateOrderTrackEvent
|
||||||
{
|
{
|
||||||
OrderId = track.OrderId,
|
OrderId = track.OrderId,
|
||||||
IsCompleted = orderIsCompleted,
|
IsCompleted = orderIsCompleted,
|
||||||
|
TrackCode = track.TrackCode,
|
||||||
TrackContent = track.TrackContent,
|
TrackContent = track.TrackContent,
|
||||||
TrackEnContent = track.TrackEnContent,
|
TrackEnContent = track.TrackEnContent,
|
||||||
TrackPlace = track.TrackPlace,
|
TrackPlace = track.TrackPlace,
|
||||||
@ -136,7 +142,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
nextEvent.OrderType = linkedOrder.OrderType;
|
nextEvent.OrderType = linkedOrder.OrderType;
|
||||||
nextEvent.OrderNo = linkedOrder.OrderNo;
|
nextEvent.OrderNo = linkedOrder.OrderNo;
|
||||||
nextEvent.SubSystemId = linkedOrder.SubSystemId;
|
nextEvent.SubSystemId = linkedOrder.SubSystemId;
|
||||||
nextEvent.IsPushCompleted = linkedOrder.IsPushCompleted;
|
nextEvent.LatestPushTrackContentId = linkedOrder.LatestPushTrackContentId;
|
||||||
nextEvent.CustomId = linkedOrder.CustomId;
|
nextEvent.CustomId = linkedOrder.CustomId;
|
||||||
nextEvent.UpSubSystemId = @event.SubSystemId;
|
nextEvent.UpSubSystemId = @event.SubSystemId;
|
||||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, nextEvent);
|
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, nextEvent);
|
||||||
|
|||||||
@ -25,7 +25,9 @@ public class UpdateOrderTrackEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
if (@event.TrackTime == default)
|
if (@event.TrackTime == default)
|
||||||
{
|
{
|
||||||
if (order.LatestTrackTime == null) return;
|
if (order.LatestTrackTime == null) return;
|
||||||
|
|
||||||
// 删除全部轨迹导致的重置行为
|
// 删除全部轨迹导致的重置行为
|
||||||
|
// tips:订单是支持从已完成态到未完成态的
|
||||||
order.ResetTrackInfo();
|
order.ResetTrackInfo();
|
||||||
}
|
}
|
||||||
else if (order.LatestTrackTime != null &&
|
else if (order.LatestTrackTime != null &&
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using SJZY.Expand.ABP.Core;
|
||||||
using SJZY.InterfaceRelay.Application.Contracts;
|
using SJZY.InterfaceRelay.Application.Contracts;
|
||||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||||
|
using SJZY.Track.Application.Contract.Services;
|
||||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||||
using Volo.Abp.Http.Client.DynamicProxying;
|
using Volo.Abp.Http.Client.DynamicProxying;
|
||||||
|
|
||||||
@ -16,22 +18,26 @@ public class TrackPushPullService : ApplicationService
|
|||||||
{
|
{
|
||||||
private readonly IOrderRepository _orderRepository;
|
private readonly IOrderRepository _orderRepository;
|
||||||
private readonly IHttpClientProxy<IInterfaceForwardServiceV2> _httpClientProxy;
|
private readonly IHttpClientProxy<IInterfaceForwardServiceV2> _httpClientProxy;
|
||||||
|
private readonly ITrackPullCacheService _trackPullCacheService;
|
||||||
|
|
||||||
public TrackPushPullService(IOrderRepository orderRepository,
|
public TrackPushPullService(IOrderRepository orderRepository,
|
||||||
IHttpClientProxy<IInterfaceForwardServiceV2> httpClientProxy)
|
IHttpClientProxy<IInterfaceForwardServiceV2> httpClientProxy,
|
||||||
|
ITrackPullCacheService trackPullCacheService)
|
||||||
{
|
{
|
||||||
_orderRepository = orderRepository;
|
_orderRepository = orderRepository;
|
||||||
_httpClientProxy = httpClientProxy;
|
_httpClientProxy = httpClientProxy;
|
||||||
|
_trackPullCacheService = trackPullCacheService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 刷新轨迹
|
/// 手动刷新轨迹
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("Track/Refresh")]
|
[HttpPost("Track/Refresh")]
|
||||||
public async Task<bool> RefreshTrackAsync(RefreshTrackInput input)
|
public async Task<bool> RefreshTrackAsync(RefreshTrackInput input)
|
||||||
{
|
{
|
||||||
|
// todo:罚时?
|
||||||
if (input.OrderNos.Count == 0)
|
if (input.OrderNos.Count == 0)
|
||||||
{
|
{
|
||||||
throw new BusinessException(message: "订单号数组不能为空");
|
throw new BusinessException(message: "订单号数组不能为空");
|
||||||
@ -39,7 +45,8 @@ public class TrackPushPullService : ApplicationService
|
|||||||
|
|
||||||
input.OrderNos = input.OrderNos.Distinct().ToList();
|
input.OrderNos = input.OrderNos.Distinct().ToList();
|
||||||
|
|
||||||
var orderTemplates = await _orderRepository.GetOrderTemplatesAsync(input.OrderNos);
|
// 这里没有区分订单类型,就算的不同类型的单一起刷新了也无所谓
|
||||||
|
var orderTemplates = await _orderRepository.FindServiceProviderByOrderAsync(input.OrderNos);
|
||||||
|
|
||||||
foreach (var group in orderTemplates.GroupBy(x =>
|
foreach (var group in orderTemplates.GroupBy(x =>
|
||||||
new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId, x.OrderType)))
|
new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId, x.OrderType)))
|
||||||
@ -50,11 +57,51 @@ public class TrackPushPullService : ApplicationService
|
|||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
// 批量获取轨迹
|
// 批量获取轨迹
|
||||||
var requestId = await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
|
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
|
||||||
"A012", group.Key.ServiceProviderCode, data,
|
"A012", group.Key.ServiceProviderCode, data,
|
||||||
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
|
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 定时任务刷新轨迹
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("Track/RefreshForTask")]
|
||||||
|
public async Task<bool> RefreshTrackAsync()
|
||||||
|
{
|
||||||
|
var configs = await _trackPullCacheService.GetAllPullConfigsAsync();
|
||||||
|
foreach (var config in configs)
|
||||||
|
{
|
||||||
|
var redisKey = _trackPullCacheService.TrackPullKey(config.SubSystemId, config.ServiceProviderId);
|
||||||
|
if (await RedisHelper.Client.ExistsAsync(redisKey))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var orders = await _orderRepository.FindOrderByServiceProviderAsync(config.ServiceProviderId);
|
||||||
|
|
||||||
|
foreach (var group in orders.GroupBy(x =>
|
||||||
|
new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId,
|
||||||
|
x.OrderType)))
|
||||||
|
{
|
||||||
|
var data = group.Select(x => new
|
||||||
|
{
|
||||||
|
x.OrderNo
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
// 批量获取轨迹
|
||||||
|
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
|
||||||
|
"A012", group.Key.ServiceProviderCode, data,
|
||||||
|
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
|
||||||
|
}
|
||||||
|
|
||||||
|
await RedisHelper.Client.SetExAsync(redisKey, config.PullInterval * 60, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ public partial class TrackService : ApplicationService, ITrackService
|
|||||||
var order = await _orderRepository.GetFirstAsync(x =>
|
var order = await _orderRepository.GetFirstAsync(x =>
|
||||||
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new
|
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new
|
||||||
{
|
{
|
||||||
x.Id, x.SubSystemId, x.IsPushCompleted, x.CustomId
|
x.Id, x.SubSystemId, LatestPushCode = x.LatestPushTrackContentId, x.CustomId
|
||||||
});
|
});
|
||||||
if (order == default)
|
if (order == default)
|
||||||
{
|
{
|
||||||
@ -52,7 +52,7 @@ public partial class TrackService : ApplicationService, ITrackService
|
|||||||
var @event = ObjectMapper.Map<UpsertTrackInput, TrackUpsertEvent>(input);
|
var @event = ObjectMapper.Map<UpsertTrackInput, TrackUpsertEvent>(input);
|
||||||
@event.OrderId = order.Id;
|
@event.OrderId = order.Id;
|
||||||
@event.SubSystemId = order.SubSystemId;
|
@event.SubSystemId = order.SubSystemId;
|
||||||
@event.IsPushCompleted = order.IsPushCompleted;
|
@event.LatestPushTrackContentId = order.LatestPushCode;
|
||||||
@event.CustomId = order.CustomId;
|
@event.CustomId = order.CustomId;
|
||||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
|
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
|
||||||
return true;
|
return true;
|
||||||
@ -76,7 +76,7 @@ public partial class TrackService : ApplicationService, ITrackService
|
|||||||
var orders = await _orderRepository.GetListAsync(x =>
|
var orders = await _orderRepository.GetListAsync(x =>
|
||||||
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo), x => new
|
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo), x => new
|
||||||
{
|
{
|
||||||
x.Id, x.OrderNo, x.SubSystemId, x.IsPushCompleted, x.CustomId
|
x.Id, x.OrderNo, x.SubSystemId, LatestPushCode = x.LatestPushTrackContentId, x.CustomId
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var order in orders)
|
foreach (var order in orders)
|
||||||
@ -92,7 +92,7 @@ public partial class TrackService : ApplicationService, ITrackService
|
|||||||
OrderNo = order.OrderNo,
|
OrderNo = order.OrderNo,
|
||||||
OrderId = order.Id,
|
OrderId = order.Id,
|
||||||
SubSystemId = order.SubSystemId,
|
SubSystemId = order.SubSystemId,
|
||||||
IsPushCompleted = order.IsPushCompleted,
|
LatestPushTrackContentId = order.LatestPushCode,
|
||||||
CustomId = order.CustomId
|
CustomId = order.CustomId
|
||||||
};
|
};
|
||||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
|
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
|
||||||
|
|||||||
@ -1,120 +1,118 @@
|
|||||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
|
||||||
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||||
using SJZY.Track.Domain.Dtos.Order;
|
using SJZY.Track.Domain.Dtos.Order;
|
||||||
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||||
using System;
|
using SJZY.Track.Domain.Queries;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Volo.Abp.DependencyInjection;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Services.TrackOrders
|
namespace SJZY.Track.Application.Services.TrackOrders;
|
||||||
|
|
||||||
|
[ApiExplorerSettings(GroupName = "轨迹订单")]
|
||||||
|
[Route("/Track/Order")]
|
||||||
|
public class TrackOrderService : ApplicationService
|
||||||
{
|
{
|
||||||
[ApiExplorerSettings(GroupName = "轨迹订单")]
|
private readonly ITrackOrderQueries _trackOrderQueries;
|
||||||
[Route("/Track/Order")]
|
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||||
public class TrackOrderService : ApplicationService, ITransientDependency
|
private readonly ITrackContentRepository _trackContentRepository;
|
||||||
|
|
||||||
|
public TrackOrderService(
|
||||||
|
ITrackOrderQueries trackOrderQueries,
|
||||||
|
ITrackDetailsRepository trackDetailsRepository,
|
||||||
|
ITrackContentRepository trackContentRepository
|
||||||
|
)
|
||||||
{
|
{
|
||||||
private readonly IOrderRepository _orderRepository;
|
_trackOrderQueries = trackOrderQueries;
|
||||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
_trackDetailsRepository = trackDetailsRepository;
|
||||||
private readonly ITrackContentRepository _trackContentRepository;
|
_trackContentRepository = trackContentRepository;
|
||||||
|
|
||||||
public TrackOrderService(
|
|
||||||
IOrderRepository orderRepository,
|
|
||||||
ITrackDetailsRepository trackDetailsRepository,
|
|
||||||
ITrackContentRepository trackContentRepository
|
|
||||||
)
|
|
||||||
{
|
|
||||||
this._orderRepository=orderRepository;
|
|
||||||
this._trackDetailsRepository=trackDetailsRepository;
|
|
||||||
this._trackContentRepository=trackContentRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 轨迹订单明细
|
|
||||||
/// <summary>
|
|
||||||
/// 根据轨迹订单id获取轨迹订单明细列表
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("GetDetails")]
|
|
||||||
public async Task<List<TrackOrderDetailDto>> GetOrderDetails(GetOrderDetailsInput input)
|
|
||||||
{
|
|
||||||
var trackDetails = await _trackDetailsRepository.GetListAsync(input.OrderId);
|
|
||||||
if (!trackDetails.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
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
|
|
||||||
});
|
|
||||||
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();
|
|
||||||
if (!insertData.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
trackContent =trackContentsOfTemplates.FirstOrDefault(a => a.TrackTemplateId==insertData.FirstOrDefault());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trackContent!=null)
|
|
||||||
{
|
|
||||||
a.IsCanDelete=trackContent.IsCanDelete;
|
|
||||||
a.IsExternal = trackContent.IsExternal;
|
|
||||||
}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// a.IsCanDelete=false;
|
|
||||||
// a.IsExternal=false;
|
|
||||||
//}
|
|
||||||
if (a.TrackTimeZoneValue==0f)
|
|
||||||
{
|
|
||||||
a.TrackTimeZone=$"GTM{" "}+00:00";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 将小数形式的小时转换为时区偏移量
|
|
||||||
int hours = (int)a.TrackTimeZoneValue; // 提取整数部分作为小时
|
|
||||||
int minutes = (int)((a.TrackTimeZoneValue - hours) * 60); // 将小数部分乘以 60 转换为分钟
|
|
||||||
TimeSpan offset = new TimeSpan(hours, minutes, 0);
|
|
||||||
string timeZoneStr = offset.ToString();
|
|
||||||
string flag = a.TrackTimeZoneValue>0f ? "+" : "";
|
|
||||||
a.TrackTimeZone = $"GTM{" "}{flag}{timeZoneStr.RemovePostFix(":00")}";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new List<TrackOrderDetailDto>();
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 轨迹订单列表
|
|
||||||
/// <summary>
|
|
||||||
/// 获取分页的轨迹订单
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("GetTrackOrderList")]
|
|
||||||
public async Task<UnifyPageResultDto<TrackOrderDto>> GetPageTrackOrder(GetPageTrackOrderInput input)
|
|
||||||
{
|
|
||||||
var vo = ObjectMapper.Map<GetPageTrackOrderInput, GetPageTrackOrderInputVO>(input);
|
|
||||||
var pageList = await _orderRepository.GetPageTrackOrder(vo);
|
|
||||||
var pageResultDto =
|
|
||||||
ObjectMapper.Map<UnifyPageResultDto<TrackOrderVO>, UnifyPageResultDto<TrackOrderDto>>(pageList);
|
|
||||||
return pageResultDto;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 轨迹订单明细
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据轨迹订单id获取轨迹订单明细列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("GetDetails")]
|
||||||
|
public async Task<List<TrackOrderDetailDto>> GetOrderDetails(GetOrderDetailsInput input)
|
||||||
|
{
|
||||||
|
var trackDetails = await _trackDetailsRepository.GetListAsync(input.OrderId);
|
||||||
|
if (!trackDetails.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
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
|
||||||
|
});
|
||||||
|
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();
|
||||||
|
if (!insertData.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
trackContent = trackContentsOfTemplates.FirstOrDefault(a => a.TrackTemplateId == insertData.FirstOrDefault());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trackContent != null)
|
||||||
|
{
|
||||||
|
a.IsCanDelete = trackContent.IsCanDelete;
|
||||||
|
a.IsExternal = trackContent.IsExternal;
|
||||||
|
}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// a.IsCanDelete=false;
|
||||||
|
// a.IsExternal=false;
|
||||||
|
//}
|
||||||
|
if (a.TrackTimeZoneValue == 0f)
|
||||||
|
{
|
||||||
|
a.TrackTimeZone = $"GTM{" "}+00:00";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 将小数形式的小时转换为时区偏移量
|
||||||
|
int hours = (int)a.TrackTimeZoneValue; // 提取整数部分作为小时
|
||||||
|
int minutes = (int)((a.TrackTimeZoneValue - hours) * 60); // 将小数部分乘以 60 转换为分钟
|
||||||
|
TimeSpan offset = new TimeSpan(hours, minutes, 0);
|
||||||
|
string timeZoneStr = offset.ToString();
|
||||||
|
string flag = a.TrackTimeZoneValue > 0f ? "+" : "";
|
||||||
|
a.TrackTimeZone = $"GTM{" "}{flag}{timeZoneStr.RemovePostFix(":00")}";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return list;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return new List<TrackOrderDetailDto>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 轨迹订单列表
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取分页的轨迹订单
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("GetTrackOrderList")]
|
||||||
|
public async Task<UnifyPageResultDto<TrackOrderDto>> GetPageTrackOrder(GetPageTrackOrderInput input)
|
||||||
|
{
|
||||||
|
var vo = ObjectMapper.Map<GetPageTrackOrderInput, GetPageTrackOrderInputVO>(input);
|
||||||
|
var pageList = await _trackOrderQueries.GetPageTrackOrder(vo);
|
||||||
|
var pageResultDto =
|
||||||
|
ObjectMapper.Map<UnifyPageResultDto<TrackOrderVO>, UnifyPageResultDto<TrackOrderDto>>(pageList);
|
||||||
|
return pageResultDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
@ -1,18 +1,21 @@
|
|||||||
using SJZY.Expand.ABP.Core;
|
using System.Linq.Expressions;
|
||||||
|
using SJZY.Expand.ABP.Core;
|
||||||
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||||
using SJZY.Track.Application.Contract.Services;
|
using SJZY.Track.Application.Contract.Services;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||||
using SJZY.Track.Domain.Dtos.TrackPull;
|
using SJZY.Track.Domain.Dtos.TrackPull;
|
||||||
using System.Linq.Expressions;
|
|
||||||
using Volo.Abp.DependencyInjection;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Services.TrackPull;
|
namespace SJZY.Track.Application.Services.TrackPull;
|
||||||
|
|
||||||
public class TrackPullCacheService : ApplicationService, ITrackPullCacheService, ITransientDependency
|
public class TrackPullCacheService : ApplicationService, ITrackPullCacheService
|
||||||
{
|
{
|
||||||
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
||||||
|
|
||||||
private string RedisKey(int subSystemId, int serviceProviderId) => GlobalConst.TrackPushKeyPrefix + subSystemId + ":" + serviceProviderId;
|
public string TrackPullKey(int subSystemId, int serviceProviderId) =>
|
||||||
|
$"{GlobalConst.TrackPullKeyPrefix}:{subSystemId}:{serviceProviderId}";
|
||||||
|
|
||||||
|
public string TrackPullContentKey(int subSystemId, int serviceProviderId) =>
|
||||||
|
$"{GlobalConst.TrackPullContentKeyPrefix}:{subSystemId}:{serviceProviderId}";
|
||||||
|
|
||||||
public TrackPullCacheService(ITrackPullConfigRepository trackPullConfigRepository)
|
public TrackPullCacheService(ITrackPullConfigRepository trackPullConfigRepository)
|
||||||
{
|
{
|
||||||
@ -20,9 +23,23 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService,
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public async Task<TrackPullConfigDto> GetPullConfigAsync(int subSystemId, int serviceProviderId)
|
public async Task<List<TrackPullConfigDto>> GetAllPullConfigsAsync()
|
||||||
{
|
{
|
||||||
var data = await RedisHelper.Client.GetAsync<TrackPullConfigDto>(RedisKey(subSystemId, serviceProviderId));
|
return await _trackPullConfigRepository.GetListAsync(x => true, x => new TrackPullConfigDto
|
||||||
|
{
|
||||||
|
SubSystemId = x.SubSystemId,
|
||||||
|
ServiceProviderId = x.ServiceProviderId,
|
||||||
|
PullInterval = x.PullInterval
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
public async Task<TrackPullParamWithContentConfigDto> GetPullParamWithContentConfigAsync(int subSystemId,
|
||||||
|
int serviceProviderId)
|
||||||
|
{
|
||||||
|
var data = await RedisHelper.Client.GetAsync<TrackPullParamWithContentConfigDto>(TrackPullContentKey(
|
||||||
|
subSystemId,
|
||||||
|
serviceProviderId));
|
||||||
|
|
||||||
data ??= await SetPullConfigAsync(subSystemId: subSystemId, serviceProviderId: serviceProviderId);
|
data ??= await SetPullConfigAsync(subSystemId: subSystemId, serviceProviderId: serviceProviderId);
|
||||||
|
|
||||||
@ -30,9 +47,10 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService,
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public async Task<TrackPullConfigDto> SetPullConfigAsync(int? id = null, int? subSystemId = null, int? serviceProviderId = null)
|
public async Task<TrackPullParamWithContentConfigDto> SetPullConfigAsync(int? id = null, int? subSystemId = null,
|
||||||
|
int? serviceProviderId = null)
|
||||||
{
|
{
|
||||||
var data = new TrackPullConfigDto();
|
var data = new TrackPullParamWithContentConfigDto();
|
||||||
|
|
||||||
Expression<Func<TrackPullConfigEntity, bool>> exp = x => true;
|
Expression<Func<TrackPullConfigEntity, bool>> exp = x => true;
|
||||||
if (id.HasValue) exp = x => x.Id == id;
|
if (id.HasValue) exp = x => x.Id == id;
|
||||||
@ -41,16 +59,20 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService,
|
|||||||
|
|
||||||
var trackPullConfigEntity = await _trackPullConfigRepository.GetFirstAsync(exp);
|
var trackPullConfigEntity = await _trackPullConfigRepository.GetFirstAsync(exp);
|
||||||
if (trackPullConfigEntity == null) return data;
|
if (trackPullConfigEntity == null) return data;
|
||||||
|
|
||||||
var trackPullConfigDetail = await _trackPullConfigRepository.GetDetailAsync(trackPullConfigEntity.Id);
|
var trackPullConfigDetail = await _trackPullConfigRepository.GetDetailAsync(trackPullConfigEntity.Id);
|
||||||
if (trackPullConfigDetail is null) return data;
|
if (trackPullConfigDetail is null) return data;
|
||||||
var trackPullContentList = await _trackPullConfigRepository.GetContentListCacheAsync(trackPullConfigEntity.Id);
|
var trackPullContentList = await _trackPullConfigRepository.GetContentListCacheAsync(trackPullConfigEntity.Id);
|
||||||
if (trackPullContentList.Count == 0) return data;
|
if (trackPullContentList.Count == 0) return data;
|
||||||
|
|
||||||
data.ParamConfig = ObjectMapper.Map<GetTrackPullConfigDetailOutputVO, TrackPullParamConfigDto>(trackPullConfigDetail);
|
data.ParamConfig =
|
||||||
data.ContentConfigs = ObjectMapper.Map<List<GetTrackPullContentListCacheVO>, List<TrackPullContentConfigDto>>(trackPullContentList);
|
ObjectMapper.Map<GetTrackPullConfigDetailOutputVO, TrackPullParamConfigDto>(trackPullConfigDetail);
|
||||||
|
data.ContentConfigs =
|
||||||
|
ObjectMapper.Map<List<GetTrackPullContentListCacheVO>, List<TrackPullContentConfigDto>>(
|
||||||
|
trackPullContentList);
|
||||||
|
|
||||||
await RedisHelper.Client.SetAsync(RedisKey(trackPullConfigEntity.SubSystemId, trackPullConfigEntity.ServiceProviderId), data, 86400);
|
await RedisHelper.Client.SetAsync(
|
||||||
|
TrackPullContentKey(trackPullConfigEntity.SubSystemId, trackPullConfigEntity.ServiceProviderId), data,
|
||||||
|
86400);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using SJZY.Expand.ABP.Core;
|
using SJZY.Expand.ABP.Core;
|
||||||
|
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
using SJZY.Track.Application.Contract.Services;
|
using SJZY.Track.Application.Contract.Services;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||||
using SJZY.Track.Domain.Queries;
|
using SJZY.Track.Domain.Queries;
|
||||||
@ -10,26 +11,27 @@ public class TrackPushCacheService : ITrackPushCacheService, ITransientDependenc
|
|||||||
{
|
{
|
||||||
private readonly IBasicQuery<TrackPushConfigEntity> _trackPushConfigQuery;
|
private readonly IBasicQuery<TrackPushConfigEntity> _trackPushConfigQuery;
|
||||||
|
|
||||||
private string RedisKey(int customId) => GlobalConst.TrackPushKeyPrefix + customId;
|
private string RedisKey(int customId) => $"{GlobalConst.TrackPushKeyPrefix}:{customId}";
|
||||||
|
|
||||||
public TrackPushCacheService(IBasicQuery<TrackPushConfigEntity> trackPushConfigQuery)
|
public TrackPushCacheService(IBasicQuery<TrackPushConfigEntity> trackPushConfigQuery)
|
||||||
{
|
{
|
||||||
_trackPushConfigQuery = trackPushConfigQuery;
|
_trackPushConfigQuery = trackPushConfigQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> IsPushAsync(int customId)
|
public Task<bool> IsPushAsync(int customId)
|
||||||
{
|
{
|
||||||
var isPush =
|
throw new NotImplementedException();
|
||||||
await RedisHelper.Client.GetAsync<bool?>(RedisKey(customId));
|
}
|
||||||
|
|
||||||
if (isPush == null)
|
public Task<List<TrackPushContentConfigDto>> GetPushContentConfigsAsync(int subSystemId, int customId)
|
||||||
{
|
{
|
||||||
isPush = await _trackPushConfigQuery.GetFirstAsync(x => x.CustomId == customId,
|
throw new NotImplementedException();
|
||||||
x => x.IsAutoPush);
|
}
|
||||||
await RedisHelper.Client.SetAsync(RedisKey(customId), isPush);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (bool)isPush;
|
public Task<TrackPushContentConfigDto?> InferNextPushContentOrNullAsync(int subSystemId, int customId,
|
||||||
|
int? trackContentId)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateAsync(int customId, bool isPush)
|
public async Task UpdateAsync(int customId, bool isPush)
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Extensions.Localization;
|
using System.Linq.Expressions;
|
||||||
|
using Microsoft.Extensions.Localization;
|
||||||
using SJZY.Expand.ABP.Core.Localization;
|
using SJZY.Expand.ABP.Core.Localization;
|
||||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||||
using SJZY.Track.Application.Contract.Dtos.TrackPush;
|
using SJZY.Track.Application.Contract.Dtos.TrackPush;
|
||||||
@ -9,9 +10,6 @@ using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
|||||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||||
using SJZY.Track.Domain.Dtos.Common;
|
using SJZY.Track.Domain.Dtos.Common;
|
||||||
using SJZY.Track.Domain.Dtos.TrackPush;
|
using SJZY.Track.Domain.Dtos.TrackPush;
|
||||||
using SqlSugar;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using Volo.Abp.DependencyInjection;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Services.TrackPush;
|
namespace SJZY.Track.Application.Services.TrackPush;
|
||||||
|
|
||||||
@ -20,11 +18,10 @@ namespace SJZY.Track.Application.Services.TrackPush;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[ApiExplorerSettings(GroupName = "轨迹推送")]
|
[ApiExplorerSettings(GroupName = "轨迹推送")]
|
||||||
[Route("/Track/PushConfig")]
|
[Route("/Track/PushConfig")]
|
||||||
public class TrackPushService : ApplicationService, ITransientDependency
|
public class TrackPushService : ApplicationService
|
||||||
{
|
{
|
||||||
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
|
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
|
||||||
private readonly ITrackPushConfigRepository _trackPushConfigRepository;
|
private readonly ITrackPushConfigRepository _trackPushConfigRepository;
|
||||||
private readonly ITrackTemplateRepository _trackTemplateRepository;
|
|
||||||
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
||||||
private readonly ITrackPushCacheService _trackPushCacheService;
|
private readonly ITrackPushCacheService _trackPushCacheService;
|
||||||
|
|
||||||
@ -37,7 +34,6 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
{
|
{
|
||||||
_stringLocalizer = stringLocalizer;
|
_stringLocalizer = stringLocalizer;
|
||||||
_trackPushConfigRepository = trackPushConfigRepository;
|
_trackPushConfigRepository = trackPushConfigRepository;
|
||||||
_trackTemplateRepository = trackTemplateRepository;
|
|
||||||
_trackPullConfigRepository = trackPullConfigRepository;
|
_trackPullConfigRepository = trackPullConfigRepository;
|
||||||
_trackPushCacheService = trackPushCacheService;
|
_trackPushCacheService = trackPushCacheService;
|
||||||
}
|
}
|
||||||
@ -59,7 +55,8 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("GetContentPage")]
|
[HttpPost("GetContentPage")]
|
||||||
public async Task<UnifyPageResultDto<GetTrackPushContentPageOutputVO>> GetContentPageAsync([FromBody] GetTrackPushContentPageInputVO input)
|
public async Task<UnifyPageResultDto<GetTrackPushContentPageOutputVO>> GetContentPageAsync(
|
||||||
|
[FromBody] GetTrackPushContentPageInputVO input)
|
||||||
{
|
{
|
||||||
return await _trackPushConfigRepository.GetContentPageAsync(input);
|
return await _trackPushConfigRepository.GetContentPageAsync(input);
|
||||||
}
|
}
|
||||||
@ -97,71 +94,79 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
if (input.Options != OptionTypeNoNull.删除)
|
if (input.Options != OptionTypeNoNull.删除)
|
||||||
{
|
{
|
||||||
Expression<Func<TrackPushConfigEntity, bool>> isAnyExp = x =>
|
Expression<Func<TrackPushConfigEntity, bool>> isAnyExp = x =>
|
||||||
x.SubSystemId == input.SubSystemId && x.CustomId == input.CustomId && x.ServiceProviderId == input.ServiceProviderId;
|
x.SubSystemId == input.SubSystemId && x.CustomId == input.CustomId &&
|
||||||
|
x.ServiceProviderId == input.ServiceProviderId;
|
||||||
if (input.Options == OptionTypeNoNull.修改) isAnyExp = isAnyExp.And(x => x.Id != input.Id);
|
if (input.Options == OptionTypeNoNull.修改) isAnyExp = isAnyExp.And(x => x.Id != input.Id);
|
||||||
|
|
||||||
if (await _trackPushConfigRepository.IsAnyAsync(isAnyExp)) throw new BusinessException(message: _stringLocalizer["IsTrackPushConfigAny"]);
|
if (await _trackPushConfigRepository.IsAnyAsync(isAnyExp))
|
||||||
|
throw new BusinessException(message: _stringLocalizer["IsTrackPushConfigAny"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (input.Options)
|
switch (input.Options)
|
||||||
{
|
{
|
||||||
case OptionTypeNoNull.新增:
|
case OptionTypeNoNull.新增:
|
||||||
|
{
|
||||||
|
var trackPushEntity = ObjectMapper.Map<EditTrackPushConfigInput, TrackPushConfigEntity>(input);
|
||||||
|
var trackPushParamsEntity =
|
||||||
|
ObjectMapper.Map<EditTrackPushConfigInput, TrackPushPullParamsConfigEntity>(input);
|
||||||
|
|
||||||
|
using (var ts = TransactionScopeHelper.Create())
|
||||||
{
|
{
|
||||||
var trackPushEntity = ObjectMapper.Map<EditTrackPushConfigInput, TrackPushConfigEntity>(input);
|
int id = await _trackPushConfigRepository.InsertReturnIdentityAsync(trackPushEntity);
|
||||||
var trackPushParamsEntity = ObjectMapper.Map<EditTrackPushConfigInput, TrackPushPullParamsConfigEntity>(input);
|
|
||||||
|
|
||||||
using (var ts = TransactionScopeHelper.Create())
|
trackPushParamsEntity.PullOrPushConfigId = id;
|
||||||
{
|
await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity);
|
||||||
int id = await _trackPushConfigRepository.InsertReturnIdentityAsync(trackPushEntity);
|
|
||||||
|
|
||||||
trackPushParamsEntity.PullOrPushConfigId = id;
|
if (input.IsAutoPush!.Value) await _trackPushCacheService.IsPushAsync(input.CustomId!.Value);
|
||||||
await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity);
|
|
||||||
|
|
||||||
if (input.IsAutoPush!.Value) await _trackPushCacheService.IsPushAsync(input.CustomId!.Value);
|
ts.Complete();
|
||||||
|
|
||||||
ts.Complete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionTypeNoNull.修改:
|
case OptionTypeNoNull.修改:
|
||||||
|
{
|
||||||
|
var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ??
|
||||||
|
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||||
|
|
||||||
|
int oldCustomId = oldTrackPushEntity.CustomId;
|
||||||
|
|
||||||
|
var oldTrackPushParamsEntity =
|
||||||
|
await _trackPullConfigRepository.GetParamsSingleAsync(x =>
|
||||||
|
x.PullOrPushConfigId == input.Id && x.IsPush);
|
||||||
|
|
||||||
|
ObjectMapper.Map(input, oldTrackPushEntity);
|
||||||
|
ObjectMapper.Map(input, oldTrackPushParamsEntity);
|
||||||
|
|
||||||
|
using (var ts = TransactionScopeHelper.Create())
|
||||||
{
|
{
|
||||||
var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
await _trackPushConfigRepository.UpdateAsync(oldTrackPushEntity);
|
||||||
|
await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity);
|
||||||
|
|
||||||
int oldCustomId = oldTrackPushEntity.CustomId;
|
await _trackPushCacheService.UpdateAsync(oldCustomId, false);
|
||||||
|
if (input.IsAutoPush!.Value) await _trackPushCacheService.IsPushAsync(input.CustomId!.Value);
|
||||||
|
|
||||||
var oldTrackPushParamsEntity = await _trackPullConfigRepository.GetParamsSingleAsync(x => x.PullOrPushConfigId == input.Id && x.IsPush);
|
ts.Complete();
|
||||||
|
|
||||||
ObjectMapper.Map(input, oldTrackPushEntity);
|
|
||||||
ObjectMapper.Map(input, oldTrackPushParamsEntity);
|
|
||||||
|
|
||||||
using (var ts = TransactionScopeHelper.Create())
|
|
||||||
{
|
|
||||||
await _trackPushConfigRepository.UpdateAsync(oldTrackPushEntity);
|
|
||||||
await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity);
|
|
||||||
|
|
||||||
await _trackPushCacheService.UpdateAsync(oldCustomId, false);
|
|
||||||
if (input.IsAutoPush!.Value) await _trackPushCacheService.IsPushAsync(input.CustomId!.Value);
|
|
||||||
|
|
||||||
ts.Complete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionTypeNoNull.删除:
|
case OptionTypeNoNull.删除:
|
||||||
|
{
|
||||||
|
var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ??
|
||||||
|
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||||
|
|
||||||
|
using (var ts = TransactionScopeHelper.Create())
|
||||||
{
|
{
|
||||||
var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
await _trackPushConfigRepository.SoftDeleteAsync(x => x.Id == input.Id);
|
||||||
|
await _trackPullConfigRepository.SoftDeleteParamsAsync(x =>
|
||||||
|
x.PullOrPushConfigId == input.Id && x.IsPush);
|
||||||
|
await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id);
|
||||||
|
await _trackPushCacheService.UpdateAsync(oldTrackPushEntity.CustomId, false);
|
||||||
|
|
||||||
using (var ts = TransactionScopeHelper.Create())
|
ts.Complete();
|
||||||
{
|
|
||||||
await _trackPushConfigRepository.SoftDeleteAsync(x => x.Id == input.Id);
|
|
||||||
await _trackPullConfigRepository.SoftDeleteParamsAsync(x => x.PullOrPushConfigId == input.Id && x.IsPush);
|
|
||||||
await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id);
|
|
||||||
await _trackPushCacheService.UpdateAsync(oldTrackPushEntity.CustomId, false);
|
|
||||||
|
|
||||||
ts.Complete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -182,62 +187,76 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
{
|
{
|
||||||
if (input.Options != OptionTypeNoNull.删除)
|
if (input.Options != OptionTypeNoNull.删除)
|
||||||
{
|
{
|
||||||
Expression<Func<TrackPushContentConfigEntity, bool>> isContentAnyExp = x => x.TrackPushConfigId == input.TrackPushConfigId;
|
Expression<Func<TrackPushContentConfigEntity, bool>> isContentAnyExp = x =>
|
||||||
|
x.TrackPushConfigId == input.TrackPushConfigId;
|
||||||
if (input.Options == OptionTypeNoNull.修改) isContentAnyExp = isContentAnyExp.And(x => x.Id != input.Id);
|
if (input.Options == OptionTypeNoNull.修改) isContentAnyExp = isContentAnyExp.And(x => x.Id != input.Id);
|
||||||
|
|
||||||
if (await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentId == input.TrackContentId)))
|
if (await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||||
|
x.TrackContentId == input.TrackContentId)))
|
||||||
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentAny"]);
|
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentAny"]);
|
||||||
else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentCodeValue == input.TrackContentCodeValue)))
|
else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() &&
|
||||||
|
await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||||
|
x.TrackContentCodeValue == input.TrackContentCodeValue)))
|
||||||
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentCodeValueAny"]);
|
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentCodeValueAny"]);
|
||||||
else if (!input.TrackStatusValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackStatusValue == input.TrackStatusValue)))
|
else if (!input.TrackStatusValue.IsNullOrWhiteSpace() &&
|
||||||
|
await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||||
|
x.TrackStatusValue == input.TrackStatusValue)))
|
||||||
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentStatusValueAny"]);
|
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentStatusValueAny"]);
|
||||||
else if (!input.TrackContentValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentValue == input.TrackContentValue)))
|
else if (!input.TrackContentValue.IsNullOrWhiteSpace() &&
|
||||||
|
await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||||
|
x.TrackContentValue == input.TrackContentValue)))
|
||||||
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentValueAny"]);
|
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentValueAny"]);
|
||||||
else if (!input.TrackEnContentValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackEnContentValue == input.TrackEnContentValue)))
|
else if (!input.TrackEnContentValue.IsNullOrWhiteSpace() &&
|
||||||
|
await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||||
|
x.TrackEnContentValue == input.TrackEnContentValue)))
|
||||||
throw new BusinessException(message: _stringLocalizer["IsTrackPushEnContentValueAny"]);
|
throw new BusinessException(message: _stringLocalizer["IsTrackPushEnContentValueAny"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (input.Options)
|
switch (input.Options)
|
||||||
{
|
{
|
||||||
case OptionTypeNoNull.新增:
|
case OptionTypeNoNull.新增:
|
||||||
{
|
{
|
||||||
int maxSort = await _trackPushConfigRepository.ContentMaxAsync(x => x.Sort, x => x.TrackPushConfigId == input.TrackPushConfigId);
|
int maxSort = await _trackPushConfigRepository.ContentMaxAsync(x => x.Sort,
|
||||||
|
x => x.TrackPushConfigId == input.TrackPushConfigId);
|
||||||
|
|
||||||
var entity = ObjectMapper.Map<EditTrackPushContentInput, TrackPushContentConfigEntity>(input);
|
var entity = ObjectMapper.Map<EditTrackPushContentInput, TrackPushContentConfigEntity>(input);
|
||||||
entity.Sort = maxSort + 1;
|
entity.Sort = maxSort + 1;
|
||||||
|
|
||||||
await _trackPushConfigRepository.InsertContentAsync(entity);
|
await _trackPushConfigRepository.InsertContentAsync(entity);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case OptionTypeNoNull.修改:
|
case OptionTypeNoNull.修改:
|
||||||
{
|
{
|
||||||
var entity = await _trackPushConfigRepository.GetContentByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
var entity = await _trackPushConfigRepository.GetContentByIdAsync(input.Id!.Value) ??
|
||||||
|
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||||
|
|
||||||
ObjectMapper.Map(input, entity);
|
ObjectMapper.Map(input, entity);
|
||||||
|
|
||||||
await _trackPushConfigRepository.UpdateContentAsync(entity);
|
await _trackPushConfigRepository.UpdateContentAsync(entity);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case OptionTypeNoNull.删除:
|
case OptionTypeNoNull.删除:
|
||||||
|
{
|
||||||
|
var entity = await _trackPushConfigRepository.GetContentByIdAsync(input.Id!.Value) ??
|
||||||
|
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||||
|
|
||||||
|
using (var ts = TransactionScopeHelper.Create())
|
||||||
{
|
{
|
||||||
var entity = await _trackPushConfigRepository.GetContentByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id);
|
||||||
|
|
||||||
using (var ts = TransactionScopeHelper.Create())
|
await _trackPushConfigRepository.UpdateContentAsync(x => x.Sort == x.Sort - 1,
|
||||||
{
|
x => x.TrackPushConfigId == entity.TrackPushConfigId && x.Sort > entity.Sort);
|
||||||
await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id);
|
|
||||||
|
|
||||||
await _trackPushConfigRepository.UpdateContentAsync(x => x.Sort == x.Sort - 1, x => x.TrackPushConfigId == entity.TrackPushConfigId && x.Sort > entity.Sort);
|
ts.Complete();
|
||||||
|
|
||||||
ts.Complete();
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum,
|
throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum,
|
||||||
nameof(EditTrackPushContentInput.Options)]);
|
nameof(EditTrackPushContentInput.Options)]);
|
||||||
|
|||||||
@ -11,13 +11,6 @@ public interface IOrderRepository : IBasicRepository<OrderEntity>
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task CreateOrderAsync(OrderEntity order);
|
Task CreateOrderAsync(OrderEntity order);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取分页的轨迹订单
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<UnifyPageResultDto<TrackOrderVO>> GetPageTrackOrder(GetPageTrackOrderInputVO input);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新订单
|
/// 更新订单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -60,9 +53,16 @@ public interface IOrderRepository : IBasicRepository<OrderEntity>
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取订单模板列表
|
/// 根据订单模板找对应服务商
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="orderNos"></param>
|
/// <param name="orderNos"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<OrderTemplateVO>> GetOrderTemplatesAsync(List<string> orderNos);
|
Task<List<OrderServiceProviderVO>> FindServiceProviderByOrderAsync(List<string> orderNos);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取服务商下所有单(未完成的)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serviceProvider"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<OrderServiceProviderVO>> FindOrderByServiceProviderAsync(int serviceProvider);
|
||||||
}
|
}
|
||||||
@ -43,10 +43,10 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
|||||||
public bool IsCompleted { get; set; }
|
public bool IsCompleted { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 订单是否推送完成(异步维护)
|
/// 最新推送轨迹内容id(异步维护)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnName = "IsPushCompleted")]
|
[SugarColumn(ColumnName = "LatestPushTrackContentId")]
|
||||||
public bool IsPushCompleted { get; set; }
|
public int? LatestPushTrackContentId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 最新轨迹内容(异步维护)
|
/// 最新轨迹内容(异步维护)
|
||||||
@ -112,7 +112,7 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
|||||||
/// 问题类型(主数据枚举TrackQuestionType)
|
/// 问题类型(主数据枚举TrackQuestionType)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnName = "QuestionType")]
|
[SugarColumn(ColumnName = "QuestionType")]
|
||||||
public int QuestionType { get; set; }
|
public int QuestionType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
/// 问题描述(主数据枚举TrackProblemDescription)
|
||||||
|
|||||||
@ -46,6 +46,11 @@ public class TrackDetailsIndex : IdBaseIndex
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string TrackContent { get; set; } = null!;
|
public string TrackContent { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容Id
|
||||||
|
/// </summary>
|
||||||
|
public int TrackContentId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否意味着完成
|
/// 是否意味着完成
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -23,9 +23,9 @@ public class LinkedOrderVO
|
|||||||
public int SubSystemId { get; set; }
|
public int SubSystemId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 订单是否推送完成(异步维护)
|
/// 最新推送轨迹内容id(异步维护)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsPushCompleted { get; set; }
|
public int? LatestPushTrackContentId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 客户id
|
/// 客户id
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
namespace SJZY.Track.Domain.Dtos.Order;
|
namespace SJZY.Track.Domain.Dtos.Order;
|
||||||
|
|
||||||
public class OrderTemplateVO
|
public class OrderServiceProviderVO
|
||||||
{
|
{
|
||||||
public string OrderNo { get; set; } = null!;
|
public string OrderNo { get; set; } = null!;
|
||||||
|
|
||||||
@ -9,8 +9,6 @@ public class OrderTemplateVO
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int OrderType { get; set; }
|
public int OrderType { get; set; }
|
||||||
|
|
||||||
public int TemplateId { get; set; }
|
|
||||||
|
|
||||||
public int ServiceProviderId { get; set; }
|
public int ServiceProviderId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
public class MatchTrackContentDto
|
public class MatchTrackContentDto
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容id
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 轨迹内容
|
/// 轨迹内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
15
src/SJZY.Track.Domain/Enums/TrackProblemType.cs
Normal file
15
src/SJZY.Track.Domain/Enums/TrackProblemType.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
namespace SJZY.Track.Domain.Enums;
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum TrackProblemType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 异常
|
||||||
|
/// </summary>
|
||||||
|
Error = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 预警
|
||||||
|
/// </summary>
|
||||||
|
Warn = 2,
|
||||||
|
}
|
||||||
@ -27,11 +27,6 @@ public class GlobalConst
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const string UpdateOrderTrackSubscribe = "SJZY.Track.UpdateOrderTrack";
|
public const string UpdateOrderTrackSubscribe = "SJZY.Track.UpdateOrderTrack";
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 轨迹删除后触发更新订单轨迹 mq订阅名称
|
|
||||||
/// </summary>
|
|
||||||
public const string DeleteTrackAfterUpdateOrderSubscribe = "SJZY.Track.DeleteTrackAfterUpdateOrder";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 关联订单后补轨迹 mq订阅名称
|
/// 关联订单后补轨迹 mq订阅名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -40,10 +35,20 @@ public class GlobalConst
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 轨迹要推送的客户redis key前缀
|
/// 轨迹要推送的客户redis key前缀
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string TrackPushKeyPrefix = "TrackPush:";
|
public const string TrackPushKeyPrefix = "TrackPush";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹推送内容配置redis key前缀
|
||||||
|
/// </summary>
|
||||||
|
public const string TrackPushContentKeyPrefix = "TrackPushContent";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 轨迹拉取配置信息redis key前缀
|
/// 轨迹拉取配置信息redis key前缀
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string TrackPullConfigInfoKeyPrefix = "TrackPullConfigInfo:";
|
public const string TrackPullKeyPrefix = "TrackPull";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹拉取配置信息redis key前缀
|
||||||
|
/// </summary>
|
||||||
|
public const string TrackPullContentKeyPrefix = "TrackPullContent";
|
||||||
}
|
}
|
||||||
13
src/SJZY.Track.Domain/Queries/ITrackOrderQueries.cs
Normal file
13
src/SJZY.Track.Domain/Queries/ITrackOrderQueries.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using SJZY.Track.Domain.Dtos.Order;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Domain.Queries;
|
||||||
|
|
||||||
|
public interface ITrackOrderQueries
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取分页的轨迹订单
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<UnifyPageResultDto<TrackOrderVO>> GetPageTrackOrder(GetPageTrackOrderInputVO input);
|
||||||
|
}
|
||||||
@ -70,6 +70,7 @@ public class ProvideQueries : ISugarRepository, IProvideQueries,
|
|||||||
.Where((x, a, b) => x.OrderId == orderId && b.Code == code)
|
.Where((x, a, b) => x.OrderId == orderId && b.Code == code)
|
||||||
.Select((x, a, b, c) => new MatchTrackContentDto
|
.Select((x, a, b, c) => new MatchTrackContentDto
|
||||||
{
|
{
|
||||||
|
Id = b.Id,
|
||||||
Content = b.Content,
|
Content = b.Content,
|
||||||
EnContent = b.EnContent,
|
EnContent = b.EnContent,
|
||||||
Status = c.Status,
|
Status = c.Status,
|
||||||
|
|||||||
117
src/SJZY.Track.Repository/Queries/TrackOrderQueries.cs
Normal file
117
src/SJZY.Track.Repository/Queries/TrackOrderQueries.cs
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||||
|
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||||
|
using SJZY.Track.Domain.Dtos.Order;
|
||||||
|
using SJZY.Track.Domain.Queries;
|
||||||
|
using SJZY.Track.Domain.VEntities;
|
||||||
|
using SJZY.Track.Repository.VData.Entitys;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Repository.Queries;
|
||||||
|
|
||||||
|
public class TrackOrderQueries : ISugarRepository, ITrackOrderQueries,
|
||||||
|
ITransientDependency
|
||||||
|
{
|
||||||
|
public ISqlSugarClient Context { get; set; }
|
||||||
|
|
||||||
|
public TrackOrderQueries()
|
||||||
|
{
|
||||||
|
Context = SqlsugarScopeBasic.GetContextSafely("default");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取分页的轨迹订单
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <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.CreateTimeStart.HasValue && input.CreateTimeEnd.HasValue,
|
||||||
|
(a, b, c) => a.CreateTime >= input.CreateTimeStart && a.CreateTime <= input.CreateTimeEnd)
|
||||||
|
.WhereIF(input.CreateTimeStart.HasValue && (!input.CreateTimeEnd.HasValue),
|
||||||
|
(a, b, c) => a.CreateTime >= input.CreateTimeStart)
|
||||||
|
.WhereIF((!input.CreateTimeStart.HasValue) && input.CreateTimeEnd.HasValue,
|
||||||
|
(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)
|
||||||
|
.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(""),
|
||||||
|
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,
|
||||||
|
NewestTrackTime = a.LatestTrackTime,
|
||||||
|
IsFinish = a.IsCompleted,
|
||||||
|
CreateTime = a.CreateTime,
|
||||||
|
SubSystem = c.CnName,
|
||||||
|
SubSystemId = c.Id
|
||||||
|
})
|
||||||
|
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||||
|
|
||||||
|
if (pageList.List.Any())
|
||||||
|
{
|
||||||
|
//查询也需要最新的轨迹
|
||||||
|
var orderIds = pageList.List.Select(a => a.Id).ToList();
|
||||||
|
//查询轨迹模版
|
||||||
|
var trackTemplateList = await Context.Queryable<OrderTemplateEntity>()
|
||||||
|
.LeftJoin<TrackTemplateEntity>((a, b) => a.TrackTemplateId == b.Id)
|
||||||
|
.Where((a, b) => orderIds.Contains(a.OrderId))
|
||||||
|
.Select((a, b) => new { a.OrderId, b.Name, TemplateId = b.Id })
|
||||||
|
.ToListAsync();
|
||||||
|
pageList.List.ForEach(a =>
|
||||||
|
{
|
||||||
|
a.TrackTemplateNames = trackTemplateList.Where(b => b.OrderId == a.Id).Select(x => x.Name)
|
||||||
|
.JoinAsString(",");
|
||||||
|
a.TrackTemplateIds = trackTemplateList.Where(b => b.OrderId == a.Id).Where(b => b.TemplateId > 0)
|
||||||
|
.Select(x => x.TemplateId).ToList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return pageList;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,25 +1,12 @@
|
|||||||
using SJZY.Track.Domain;
|
using SJZY.Track.Domain;
|
||||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
|
||||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
|
||||||
using SJZY.Track.Domain.Dtos.Order;
|
using SJZY.Track.Domain.Dtos.Order;
|
||||||
using SJZY.Track.Domain.VEntities;
|
using SJZY.Track.Domain.VEntities;
|
||||||
using SJZY.Track.Repository.VData.Entitys;
|
|
||||||
using SqlSugar;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Repository.Repositories;
|
namespace SJZY.Track.Repository.Repositories;
|
||||||
|
|
||||||
public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, ITransientDependency
|
public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, ITransientDependency
|
||||||
{
|
{
|
||||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
|
||||||
|
|
||||||
public OrderRepository(
|
|
||||||
ITrackDetailsRepository trackDetailsRepository
|
|
||||||
)
|
|
||||||
{
|
|
||||||
this._trackDetailsRepository = trackDetailsRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task CreateOrderAsync(OrderEntity order)
|
public async Task CreateOrderAsync(OrderEntity order)
|
||||||
{
|
{
|
||||||
using var tran = TransactionHelper.GetReadCommitted();
|
using var tran = TransactionHelper.GetReadCommitted();
|
||||||
@ -80,7 +67,7 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
|||||||
OrderType = b.OrderType,
|
OrderType = b.OrderType,
|
||||||
OrderNo = b.OrderNo,
|
OrderNo = b.OrderNo,
|
||||||
SubSystemId = b.SubSystemId,
|
SubSystemId = b.SubSystemId,
|
||||||
IsPushCompleted = b.IsPushCompleted,
|
LatestPushTrackContentId = b.LatestPushTrackContentId,
|
||||||
CustomId = b.CustomId
|
CustomId = b.CustomId
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
@ -98,180 +85,33 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 轨迹订单明细
|
public async Task<List<OrderServiceProviderVO>> FindServiceProviderByOrderAsync(List<string> orderNos)
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 根据轨迹订单id获取轨迹明细列表
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="input"></param>
|
|
||||||
///// <returns></returns>
|
|
||||||
//public async Task<List<TrackOrderDetailVO>> GetOrderDetails(GetOrderDetailsInputVO input)
|
|
||||||
//{
|
|
||||||
// return null;
|
|
||||||
//}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 轨迹订单分页
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取分页的轨迹订单
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <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 char[] { ',', ',', ':', ':' }).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.CreateTimeStart.HasValue && input.CreateTimeEnd.HasValue,
|
|
||||||
(a, b, c) => a.CreateTime >= input.CreateTimeStart && a.CreateTime <= input.CreateTimeEnd)
|
|
||||||
.WhereIF(input.CreateTimeStart.HasValue && (!input.CreateTimeEnd.HasValue),
|
|
||||||
(a, b, c) => a.CreateTime >= input.CreateTimeStart)
|
|
||||||
.WhereIF((!input.CreateTimeStart.HasValue) && input.CreateTimeEnd.HasValue,
|
|
||||||
(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)
|
|
||||||
.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(""),
|
|
||||||
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,
|
|
||||||
NewestTrackTime = a.LatestTrackTime,
|
|
||||||
IsFinish = a.IsCompleted,
|
|
||||||
CreateTime = a.CreateTime,
|
|
||||||
SubSystem = c.CnName,
|
|
||||||
SubSystemId = c.Id
|
|
||||||
})
|
|
||||||
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
|
||||||
|
|
||||||
if (pageList.List.Any())
|
|
||||||
{
|
|
||||||
//查询也需要最新的轨迹
|
|
||||||
var orderIds = pageList.List.Select(a => a.Id).ToList();
|
|
||||||
//查询轨迹模版
|
|
||||||
var trackTemplateList = await Context.Queryable<OrderTemplateEntity>()
|
|
||||||
.LeftJoin<TrackTemplateEntity>((a, b) => a.TrackTemplateId == b.Id)
|
|
||||||
.Where((a, b) => orderIds.Contains(a.OrderId))
|
|
||||||
.Select((a, b) => new { OrderId = a.OrderId, Name = b.Name, TemplateId = b.Id })
|
|
||||||
.ToListAsync();
|
|
||||||
var esTrackDetails = await _trackDetailsRepository.GetListAsync(orderIds);
|
|
||||||
pageList.List.ForEach(a =>
|
|
||||||
{
|
|
||||||
var esDetails = esTrackDetails?.Where(b => b.OrderId == a.Id).OrderByDescending(b => b.TrackTime);
|
|
||||||
var trackDetail = esDetails?.FirstOrDefault();
|
|
||||||
if (trackDetail != null)
|
|
||||||
{
|
|
||||||
if (trackDetail.TrackContent != a.NewestTrackContent)
|
|
||||||
{
|
|
||||||
a.NewestTrackContent = trackDetail.TrackContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trackDetail.TrackEnContent != a.NewestTrackEnContent)
|
|
||||||
{
|
|
||||||
a.NewestTrackEnContent = trackDetail.TrackEnContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trackDetail.TrackPlace != a.NewestTrackPlace)
|
|
||||||
{
|
|
||||||
a.NewestTrackPlace = trackDetail.TrackPlace;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trackDetail.TrackTime != a.NewestTrackTime)
|
|
||||||
{
|
|
||||||
a.NewestTrackTime = trackDetail.TrackTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
a.TrackTemplateNames = trackTemplateList.Where(b => b.OrderId == a.Id).Select(a => a.Name)
|
|
||||||
.JoinAsString(",");
|
|
||||||
a.TrackTemplateIds = trackTemplateList.Where(b => b.OrderId == a.Id).Where(b => b.TemplateId>0).Select(a => a.TemplateId).ToList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#region 暂时注释
|
|
||||||
|
|
||||||
//if (pageList.List.Any())
|
|
||||||
//{
|
|
||||||
// var orderIds = pageList.List.Select(a => a.Id);
|
|
||||||
// //查询轨迹模版
|
|
||||||
|
|
||||||
|
|
||||||
// var trackTemplateList = await Context.Queryable<OrderTemplateEntity>()
|
|
||||||
// .LeftJoin<TrackTemplateEntity>((a, b) => a.TrackTemplateId==b.Id)
|
|
||||||
// .Where((a, b) => orderIds.Contains(a.OrderId))
|
|
||||||
// .Select((a, b) => new { OrderId = a.OrderId, Name = b.Name })
|
|
||||||
// .ToListAsync();
|
|
||||||
|
|
||||||
// pageList.List.ForEach(a =>
|
|
||||||
// {
|
|
||||||
// var templateListOfOrderId = trackTemplateList.Where(b => b.OrderId== a.Id);
|
|
||||||
// a.TrackTemplateNames = templateListOfOrderId.Select(c => c.Name).JoinAsString(",");
|
|
||||||
// });
|
|
||||||
//}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
return pageList;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
public async Task<List<OrderTemplateVO>> GetOrderTemplatesAsync(List<string> orderNos)
|
|
||||||
{
|
{
|
||||||
return await Context.Queryable<OrderEntity>()
|
return await Context.Queryable<OrderEntity>()
|
||||||
.LeftJoin<OrderTemplateEntity>((a, b) => a.Id == b.OrderId)
|
.LeftJoin<OrderTemplateEntity>((a, b) => a.Id == b.OrderId)
|
||||||
.LeftJoin<VServiceProviderEntity>((a, b, c) => b.ServiceProviderId == c.Id)
|
.LeftJoin<VServiceProviderEntity>((a, b, c) => b.ServiceProviderId == c.Id)
|
||||||
.Where(a => orderNos.Contains(a.OrderNo))
|
.Where(a => orderNos.Contains(a.OrderNo))
|
||||||
.Select((a, b, c) => new OrderTemplateVO
|
.Select((a, b, c) => new OrderServiceProviderVO
|
||||||
|
{
|
||||||
|
OrderNo = a.OrderNo,
|
||||||
|
OrderType = a.OrderType,
|
||||||
|
ServiceProviderId = b.ServiceProviderId,
|
||||||
|
ServiceProviderCode = c.Code,
|
||||||
|
SubSystemId = a.SubSystemId
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<OrderServiceProviderVO>> FindOrderByServiceProviderAsync(int serviceProvider)
|
||||||
|
{
|
||||||
|
return await Context.Queryable<OrderEntity>()
|
||||||
|
.RightJoin<OrderTemplateEntity>((a, b) => a.Id == b.OrderId)
|
||||||
|
.LeftJoin<VServiceProviderEntity>((a, b, c) => b.ServiceProviderId == c.Id)
|
||||||
|
.Where((a, b) => b.ServiceProviderId == serviceProvider && !a.IsCompleted)
|
||||||
|
.Select((a, b, c) => new OrderServiceProviderVO
|
||||||
{
|
{
|
||||||
OrderNo = a.OrderNo,
|
OrderNo = a.OrderNo,
|
||||||
OrderType = a.OrderType,
|
OrderType = a.OrderType,
|
||||||
TemplateId = b.TrackTemplateId,
|
|
||||||
ServiceProviderId = b.ServiceProviderId,
|
ServiceProviderId = b.ServiceProviderId,
|
||||||
ServiceProviderCode = c.Code,
|
ServiceProviderCode = c.Code,
|
||||||
SubSystemId = a.SubSystemId
|
SubSystemId = a.SubSystemId
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user