74 lines
2.7 KiB
C#
74 lines
2.7 KiB
C#
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
|
using SJZY.Track.Domain.Dtos.Forewarning;
|
|
|
|
namespace SJZY.Track.Application.Services.TrackOrders;
|
|
|
|
/// <summary>
|
|
/// 订单预警服务
|
|
/// </summary>
|
|
[ApiExplorerSettings(GroupName = "轨迹订单")]
|
|
[Route("/Track/Order")]
|
|
public class OrderWarningService : ApplicationService
|
|
{
|
|
private readonly IOrderRepository _orderRepository;
|
|
private readonly IWarningRecordEsRepository _warningRecordEsRepository;
|
|
|
|
public OrderWarningService(IWarningRecordEsRepository warningRecordEsRepository, IOrderRepository orderRepository)
|
|
{
|
|
_warningRecordEsRepository = warningRecordEsRepository;
|
|
_orderRepository = orderRepository;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取订单运输时效预警分页列表
|
|
/// </summary>
|
|
/// <param name="inputVo"></param>
|
|
/// <param name="userId"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("GetOrderWarningPageList/{userId:int?}")]
|
|
[HttpPost("GetOrderWarningPageList")]
|
|
public async Task<UnifyPageResultDto<GetOrderWarningPageOutput>> GetOrderWarningPageListAsync(
|
|
[FromBody] GetOrderWarningPageListVo inputVo, [FromQuery] int? userId)
|
|
{
|
|
if (userId != null) inputVo.NotifyUserId = userId;
|
|
var result = await _warningRecordEsRepository.GetOrderWarningPageListAsync(inputVo);
|
|
var orderIds = result.list.Select(x => x.OrderId).ToList();
|
|
var orders = await _orderRepository.GetListAsync(x => orderIds.Contains(x.Id), x => new
|
|
{
|
|
x.Id,
|
|
x.LatestTrackContent,
|
|
x.LatestTrackTime,
|
|
x.LatestTrackPlace
|
|
});
|
|
|
|
var list = new List<GetOrderWarningPageOutput>();
|
|
|
|
result.list.ForEach(x =>
|
|
{
|
|
var item = new GetOrderWarningPageOutput
|
|
{
|
|
SubSystemName = x.SubSystemName,
|
|
Rule = x.Rule,
|
|
Counter = x.Counter,
|
|
IsLast = x.IsLast,
|
|
WarningName = x.WarningName,
|
|
WarningStatus = x.WarningStatus,
|
|
CreateTime = x.CreateTime,
|
|
NotifyUser = x.NotifyUserName,
|
|
CustomName = x.CustomName,
|
|
};
|
|
var order = orders.FirstOrDefault(o => o.Id == x.OrderId);
|
|
if (order == default) return;
|
|
item.LatestTrackTime = order.LatestTrackTime;
|
|
item.LatestTrackPlace = order.LatestTrackPlace;
|
|
item.LatestTrackContent = order.LatestTrackContent;
|
|
|
|
list.Add(item);
|
|
});
|
|
|
|
return new UnifyPageResultDto<GetOrderWarningPageOutput>(list, inputVo.PageIndex, inputVo.PageSize,
|
|
(int) result.total);
|
|
}
|
|
}
|