Merge pull request 'S01-轨迹中台' (#52) from S01-轨迹中台 into dev
Reviewed-on: http://192.168.80.50:3000/Dotnet/SJZY.Track.Api/pulls/52
This commit is contained in:
commit
118e383d1e
@ -11,29 +11,34 @@
|
||||
public class TrackOrderDetailDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹订单id
|
||||
/// Id es主键
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹订单id
|
||||
/// </summary>
|
||||
public int OrderId { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹代码
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
public string? Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
public string? Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容英文
|
||||
/// </summary>
|
||||
public string EnContent { get; set; }
|
||||
public string? EnContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地
|
||||
/// </summary>
|
||||
public string TrackPlace { get; set; }
|
||||
public string? TrackPlace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时间
|
||||
@ -43,6 +48,6 @@
|
||||
/// <summary>
|
||||
/// 轨迹发生时区
|
||||
/// </summary>
|
||||
public string TrackTimeZone { get; set; }
|
||||
public string? TrackTimeZone { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
|
||||
public class GetTrackInput
|
||||
@ -5,6 +7,8 @@ public class GetTrackInput
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Range(1, int.MaxValue)]
|
||||
public int OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -14,12 +18,14 @@ public class GetTrackInput
|
||||
|
||||
/// <summary>
|
||||
/// 时区 +8 +8.25 -8.5 -9
|
||||
/// 不传默认+8
|
||||
/// </summary>
|
||||
public float TimeZone { get; set; }
|
||||
public float? TimeZone { get; set; } = 8;
|
||||
|
||||
/// <summary>
|
||||
/// 排序方式
|
||||
/// </summary>
|
||||
[Required]
|
||||
public SortMethod SortMethod { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ public class UpsertOrderInput : UpdateOrderInput
|
||||
/// <summary>
|
||||
/// 客户id
|
||||
/// </summary>
|
||||
[Required]
|
||||
public int CustomId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,8 @@ public class OrderAutoMapperProfile : Profile
|
||||
CreateMap<GetPageTrackOrderInput, GetPageTrackOrderInputVO>(MemberList.None);
|
||||
CreateMap<TrackOrderVO, TrackOrderDto>(MemberList.None);
|
||||
CreateMap<UnifyPageResultDto<TrackOrderVO>, UnifyPageResultDto<TrackOrderDto>>(MemberList.None);
|
||||
CreateMap<TrackDetailsIndex, TrackOrderDetailDto>(MemberList.None).ForMember(dest => dest.Id, opt => opt.MapFrom(m => m.OrderId))
|
||||
CreateMap<TrackDetailsIndex, TrackOrderDetailDto>(MemberList.None)
|
||||
.ForMember(dest => dest.Id, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Code, opt => opt.MapFrom(m => m.TrackCode))
|
||||
.ForMember(dest => dest.Content, opt => opt.MapFrom(m => m.TrackContent))
|
||||
.ForMember(dest => dest.EnContent, opt => opt.MapFrom(m => m.TrackEnContent))
|
||||
|
||||
@ -43,8 +43,8 @@ public class OrderLinkService : ApplicationService
|
||||
|
||||
if (input.LinkOrderNos.Count < 1 || input.LinkOrderType == 0) return true;
|
||||
|
||||
// 单号去重
|
||||
input.LinkOrderNos = input.LinkOrderNos.Distinct().ToList();
|
||||
// 单号去重,去空
|
||||
input.LinkOrderNos = input.LinkOrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList();
|
||||
|
||||
// 解绑
|
||||
if (!input.IsLink) return await UnLinkOrderAsync(input);
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Order;
|
||||
using SJZY.UserCenter.HttpApi.Services;
|
||||
|
||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
|
||||
@ -42,7 +43,7 @@ public class OrderService : ApplicationService
|
||||
}
|
||||
|
||||
order = ObjectMapper.Map<UpsertOrderInput, OrderEntity>(input);
|
||||
order.SubSystemId = 1;
|
||||
order.SubSystemId = CurrentUserRequest.SubSystemId;
|
||||
order.OrderTemplates = ObjectMapper.Map<List<OrderTemplateInfo>, List<OrderTemplateEntity>>(input.Templates!);
|
||||
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos!);
|
||||
|
||||
@ -85,6 +86,11 @@ public class OrderService : ApplicationService
|
||||
if (!trackDetails.IsNullOrEmpty())
|
||||
{
|
||||
var list = ObjectMapper.Map<List<TrackDetailsIndex>, List<TrackOrderDetailDto>>(trackDetails);
|
||||
int id = 1;
|
||||
list.ForEach(a =>
|
||||
{
|
||||
a.Id = id++;
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ public class TrackQueryService : ApplicationService
|
||||
IProvideQueries provideQueries)
|
||||
{
|
||||
_trackDetailsRepository = trackDetailsRepository;
|
||||
_orderRepository=orderRepository;
|
||||
_orderRepository = orderRepository;
|
||||
_provideQueries = provideQueries;
|
||||
}
|
||||
|
||||
@ -44,7 +44,6 @@ public class TrackQueryService : ApplicationService
|
||||
input.OrderNos = input.OrderNos.Distinct().ToList(); // 单号去重
|
||||
var details = await _trackDetailsRepository.GetListAsync(input.OrderType, input.OrderNos);
|
||||
|
||||
var isTurn = input.TimeZone != 0;
|
||||
foreach (var group in details.GroupBy(x => x.OrderId))
|
||||
{
|
||||
var item = new GetTrackOutput();
|
||||
@ -57,8 +56,8 @@ public class TrackQueryService : ApplicationService
|
||||
Status = x.TrackStatus,
|
||||
Content = x.TrackContent,
|
||||
Location = x.TrackPlace,
|
||||
Time = isTurn ? x.TrackTime.AddHours(input.TimeZone - x.TraceTimeZone) : x.TrackTime,
|
||||
TimeZone = isTurn ? input.TimeZone : x.TraceTimeZone
|
||||
Time = x.TrackTime.AddHours(input.TimeZone!.Value - x.TraceTimeZone),
|
||||
TimeZone = input.TimeZone!.Value
|
||||
}).ToList();
|
||||
|
||||
res.Add(item);
|
||||
@ -69,43 +68,6 @@ public class TrackQueryService : ApplicationService
|
||||
return res;
|
||||
}
|
||||
|
||||
#region 轨迹订单明细列表
|
||||
/// <summary>
|
||||
/// 根据轨迹订单id获取轨迹订单明细列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("/Track/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);
|
||||
return list;
|
||||
}
|
||||
|
||||
return new List<TrackOrderDetailDto>();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 轨迹订单分页
|
||||
/// <summary>
|
||||
/// 获取分页的轨迹订单
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("/Track/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
|
||||
|
||||
private async Task TrackDetailSort(List<GetTrackOutput> list, GetTrackInput input)
|
||||
{
|
||||
switch (input.SortMethod)
|
||||
|
||||
@ -0,0 +1,74 @@
|
||||
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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.Services.TrackOrders
|
||||
{
|
||||
[ApiExplorerSettings(GroupName = "轨迹订单")]
|
||||
[Route("/Track/Order")]
|
||||
public class TrackOrderService : ApplicationService, ITransientDependency
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||
|
||||
public TrackOrderService(
|
||||
IOrderRepository orderRepository,
|
||||
ITrackDetailsRepository trackDetailsRepository
|
||||
)
|
||||
{
|
||||
this._orderRepository=orderRepository;
|
||||
this._trackDetailsRepository=trackDetailsRepository;
|
||||
|
||||
}
|
||||
|
||||
#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);
|
||||
int id = 1;
|
||||
list.ForEach(a =>
|
||||
{
|
||||
a.Id = id++;
|
||||
});
|
||||
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
|
||||
}
|
||||
}
|
||||
@ -222,7 +222,7 @@ public class TrackPullService : ApplicationService, ITransientDependency
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentValueAny"]);
|
||||
else if (!input.TrackKeywords.IsNullOrEmpty())
|
||||
{
|
||||
Expression<Func<TrackPullContentConfigEntity, bool>> trackKeywordExp = _ => true;
|
||||
Expression<Func<TrackPullContentConfigEntity, bool>> trackKeywordExp = _ => false;
|
||||
input.TrackKeywords!.ForEach(item => { trackKeywordExp = trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item)); });
|
||||
|
||||
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(trackKeywordExp)))
|
||||
|
||||
@ -56,7 +56,7 @@ public class ProvideQueries : ISugarRepository, IProvideQueries,
|
||||
.OrderBy(a => a.Sort)
|
||||
.Select((a, b) => new OrderedTrackCodeDto
|
||||
{
|
||||
TemplateId = a.Id,
|
||||
TemplateId = a.TrackTemplateId,
|
||||
Code = b.Code
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
@ -61,17 +61,16 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
public async Task<List<LinkedOrderVO>> GetLinkedOrdersAsync(int orderId)
|
||||
{
|
||||
return await Context.Queryable<OrderLinkEntity>()
|
||||
.LeftJoin<OrderLinkEntity>((a, b) => a.Id == b.OrderId)
|
||||
.LeftJoin<OrderEntity>((a, b, c) => b.LinkOrderId == c.Id)
|
||||
.Where(a => a.Id == orderId)
|
||||
.Select((a, b, c) => new LinkedOrderVO
|
||||
.LeftJoin<OrderEntity>((a, b) => a.LinkOrderId == b.Id)
|
||||
.Where(a => a.OrderId == orderId)
|
||||
.Select((a, b) => new LinkedOrderVO
|
||||
{
|
||||
OrderId = c.Id,
|
||||
OrderType = c.OrderType,
|
||||
OrderNo = c.OrderNo,
|
||||
SubSystemId = c.SubSystemId,
|
||||
IsPushCompleted = c.IsPushCompleted,
|
||||
CustomId = c.CustomId
|
||||
OrderId = b.Id,
|
||||
OrderType = b.OrderType,
|
||||
OrderNo = b.OrderNo,
|
||||
SubSystemId = b.SubSystemId,
|
||||
IsPushCompleted = b.IsPushCompleted,
|
||||
CustomId = b.CustomId
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
|
||||
if (!r.IsValid)
|
||||
{
|
||||
LogHelper.Error($"轨迹数据新增失败,原因:{r.DebugInformation}。");
|
||||
LogHelper.Error($"轨迹新增失败,原因:{r.DebugInformation}。");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -52,12 +52,12 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
var r = await Context.UpdateAsync<TrackDetailsIndex>(index.Id, u => u
|
||||
.Index(index.IndexName)
|
||||
.Doc(index)
|
||||
//.Refresh(Refresh.True) // 可选:立即刷新索引使更改立即可见
|
||||
//.Refresh(Refresh.True) // 可选:立即刷新索引使更改立即可见
|
||||
);
|
||||
|
||||
if (!r.IsValid)
|
||||
{
|
||||
LogHelper.Error($"轨迹数据更新失败,原因:{r.DebugInformation}。");
|
||||
LogHelper.Error($"轨迹更新失败,原因:{r.DebugInformation}。");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -68,6 +68,7 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
|
||||
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)
|
||||
@ -89,22 +90,26 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
|
||||
public async Task<List<TrackDetailsIndex>?> GetListAsync(int orderId)
|
||||
{
|
||||
var data = await Context.SearchAsync<TrackDetailsIndex>(x => x.Query(q => q.Term(t => t.OrderId, orderId)).Size(1000)
|
||||
.Sort(s => s.Field(f => f.TrackTime, SortOrder.Descending)));
|
||||
var data = await Context.SearchAsync<TrackDetailsIndex>(x => x.Query(q => q.Term(t => t.OrderId, orderId))
|
||||
.Size(1000)
|
||||
.Sort(s => s.Field(f => f.TrackTime, SortOrder.Descending)));
|
||||
|
||||
return data?.Documents?.ToList();
|
||||
}
|
||||
|
||||
public async Task DeleteTrackAsync(int orderId, List<string> trackCodes)
|
||||
{
|
||||
await Context.UpdateByQueryAsync<TrackDetailsIndex>(x => x
|
||||
var r = await Context.UpdateByQueryAsync<TrackDetailsIndex>(x => x
|
||||
.Query(
|
||||
q =>
|
||||
q.Term(t => t.OrderId, orderId)
|
||||
&& q.Terms(t => t.Field(f => f.TrackCode).Terms(trackCodes)))
|
||||
&& q.Terms(t => t.Field(f => f.TrackCode.Suffix("keyword")).Terms(trackCodes)))
|
||||
.Script(s => s
|
||||
.Source("ctx._source.isDeleted = true"))
|
||||
);
|
||||
|
||||
if (!r.IsValid)
|
||||
throw new Exception($"轨迹数据删除失败,原因:{r.DebugInformation}");
|
||||
}
|
||||
|
||||
public async Task<(List<TrackDetailsIndex> list, long total)> GetListAsync(TrackDetailsQueryInput input)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user