解决冲突
This commit is contained in:
parent
2603cd1ac4
commit
2e125f8662
@ -1,5 +1,4 @@
|
||||
using AutoMapper;
|
||||
using AutoMapper.Internal.Mappers;
|
||||
using SJZY.Track.Application.Dtos.ProvideServices;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Order;
|
||||
@ -10,15 +9,14 @@ public class OrderAutoMapperProfile : Profile
|
||||
{
|
||||
public OrderAutoMapperProfile()
|
||||
{
|
||||
CreateMap<CreateOrderInput, OrderEntity>(MemberList.None);
|
||||
CreateMap<UpsertOrderInput, OrderEntity>(MemberList.None);
|
||||
CreateMap<UpdateOrderInput, OrderEntity>(MemberList.None);
|
||||
|
||||
CreateMap<OrderTemplateInfo, OrderTemplateEntity>(MemberList.None)
|
||||
.ForMember(dest => dest.ServiceProviderId, opt => opt.MapFrom(m => m.ServiceProviderId ?? 0))
|
||||
.ForMember(dest => dest.TrackTemplateId, opt => opt.MapFrom(m => m.TemplateId));
|
||||
CreateMap<OrderFligthInfo, OrderFlightEntity>(MemberList.None);
|
||||
|
||||
CreateMap<GetPageTrackOrderInput, GetPageTrackOrderInputVO>(MemberList.None);
|
||||
|
||||
CreateMap<GetPageTrackOrderInput, GetPageTrackOrderInputVO>(MemberList.None);
|
||||
}
|
||||
}
|
||||
@ -1,23 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SJZY.Track.Application.Dtos.ProvideServices;
|
||||
namespace SJZY.Track.Application.Dtos.ProvideServices;
|
||||
|
||||
public class DeleteOrderInput : OrderNoInfo
|
||||
{
|
||||
}
|
||||
|
||||
public class OrderNoInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单类型,必填
|
||||
/// </summary>
|
||||
[Required]
|
||||
public int OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号,必填
|
||||
/// </summary>
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string OrderNo { get; set; } = null!;
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SJZY.Track.Application.Dtos.ProvideServices;
|
||||
|
||||
public class OrderNoInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单类型,必填
|
||||
/// </summary>
|
||||
[Required]
|
||||
public int OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号,必填
|
||||
/// </summary>
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string OrderNo { get; set; } = null!;
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SJZY.Track.Application.Dtos.ProvideServices;
|
||||
|
||||
public class CreateOrderInput : UpdateOrderInput
|
||||
public class UpsertOrderInput : UpdateOrderInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 客户id
|
||||
@ -0,0 +1,24 @@
|
||||
namespace SJZY.Track.Application.Dtos.ProvideServices;
|
||||
|
||||
public class UpsertTrackInput : OrderNoInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹内容代码
|
||||
/// </summary>
|
||||
public string TrackCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地
|
||||
/// </summary>
|
||||
public string TrackPlace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时间
|
||||
/// </summary>
|
||||
public DateTime TrackTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时区
|
||||
/// </summary>
|
||||
public float TraceTimeZone { get; set; }
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
using SJZY.Track.Application.Dtos.ProvideServices;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
|
||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
|
||||
|
||||
@ -23,8 +23,8 @@ public class OrderService : ApplicationService
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessException"></exception>
|
||||
[HttpPost("Order/CreateOrUpdate")]
|
||||
public async Task<string> CreateOrUpdateOrderAsync(CreateOrderInput input)
|
||||
[HttpPost("Order/Upsert")]
|
||||
public async Task<string> UpsertAsync(UpsertOrderInput input)
|
||||
{
|
||||
var order = await _orderRepository.GetFirstAsync(x =>
|
||||
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo);
|
||||
@ -35,7 +35,7 @@ public class OrderService : ApplicationService
|
||||
return "更新成功";
|
||||
}
|
||||
|
||||
order = ObjectMapper.Map<CreateOrderInput, OrderEntity>(input);
|
||||
order = ObjectMapper.Map<UpsertOrderInput, OrderEntity>(input);
|
||||
order.SubSystemId = 1;
|
||||
order.OrderTemplates = ObjectMapper.Map<List<OrderTemplateInfo>, List<OrderTemplateEntity>>(input.Templates);
|
||||
order.OrderFlights = ObjectMapper.Map<List<OrderFligthInfo>, List<OrderFlightEntity>>(input.FlightInfos);
|
||||
@ -60,12 +60,13 @@ public class OrderService : ApplicationService
|
||||
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
|
||||
}
|
||||
|
||||
await _orderRepository.SoftDeleteAsync(x => x.Id == orderId);
|
||||
await _orderRepository.DeleteOrderAsync(orderId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#region 轨迹订单明细
|
||||
|
||||
/// <summary>
|
||||
/// 根据轨迹订单id获取轨迹订单明细列表
|
||||
/// </summary>
|
||||
@ -76,9 +77,11 @@ public class OrderService : ApplicationService
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 轨迹订单列表
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页的轨迹订单
|
||||
/// </summary>
|
||||
@ -92,6 +95,7 @@ public class OrderService : ApplicationService
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private async Task UpdateOrderAsync(UpdateOrderInput input, OrderEntity order)
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using SJZY.Track.Application.Dtos.ProvideServices;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
|
||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
|
||||
@ -12,15 +11,13 @@ namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
public class TrackQueryService : ApplicationService
|
||||
{
|
||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly ITrackTemplateRepository _trackTemplateRepository;
|
||||
private readonly ITrackQueries _trackQueries;
|
||||
|
||||
public TrackQueryService(ITrackDetailsRepository trackDetailsRepository, IOrderRepository orderRepository,
|
||||
ITrackTemplateRepository trackTemplateRepository)
|
||||
public TrackQueryService(ITrackDetailsRepository trackDetailsRepository,
|
||||
ITrackQueries trackQueries)
|
||||
{
|
||||
_trackDetailsRepository = trackDetailsRepository;
|
||||
_orderRepository = orderRepository;
|
||||
_trackTemplateRepository = trackTemplateRepository;
|
||||
_trackQueries = trackQueries;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -29,8 +26,8 @@ public class TrackQueryService : ApplicationService
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessException"></exception>
|
||||
[HttpPost("TrackQuery/GetByOrderNos")]
|
||||
public async Task<List<GetTrackOutput>> GetByOrderNosAsync(GetTrackInput input)
|
||||
[HttpPost("Track/Query")]
|
||||
public async Task<List<GetTrackOutput>> QueryAsync(GetTrackInput input)
|
||||
{
|
||||
if (input.OrderNos.Count > 500)
|
||||
{
|
||||
@ -38,8 +35,8 @@ public class TrackQueryService : ApplicationService
|
||||
}
|
||||
|
||||
var res = new List<GetTrackOutput>();
|
||||
input.OrderNos = input.OrderNos.Distinct().ToList();
|
||||
var details = await _trackDetailsRepository.GetListAsync(input.OrderNos);
|
||||
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))
|
||||
@ -78,18 +75,21 @@ public class TrackQueryService : ApplicationService
|
||||
list.ForEach(item => item.TrackDetails.Sort((a, b) => b.Time.CompareTo(a.Time)));
|
||||
break;
|
||||
case SortMethod.ByTemplate:
|
||||
var orderTemplates = await _orderRepository.GetOrderTemplatesAsync(input.OrderType, input.OrderNos);
|
||||
var orderTemplates = await _trackQueries
|
||||
.GetOrderTemplateLinksAsync(input.OrderType, input.OrderNos);
|
||||
var distinctTemplateIds = orderTemplates.Select(x => x.TemplateId).Distinct().ToList();
|
||||
var templateContent =
|
||||
await _trackTemplateRepository.GetTemplateContentOrderlyAsync(distinctTemplateIds);
|
||||
var templateContent = await _trackQueries.GetOrderedTrackCodesAsync(distinctTemplateIds);
|
||||
list.ForEach(item =>
|
||||
{
|
||||
var template = orderTemplates.FirstOrDefault(x => x.OrderNo == item.OrderNo);
|
||||
if (template == default) return;
|
||||
var codes = templateContent
|
||||
.Where(x => x.TemplateId == template.TemplateId)
|
||||
.Select(x => x.Code)
|
||||
.ToList();
|
||||
var codes = new List<string>();
|
||||
// 多模板拼接显示
|
||||
foreach (var orderTemplate in orderTemplates.Where(x => x.OrderNo == item.OrderNo))
|
||||
{
|
||||
codes.AddRange(templateContent
|
||||
.Where(t => t.TemplateId == orderTemplate.TemplateId)
|
||||
.Select(t => t.Code));
|
||||
}
|
||||
|
||||
item.TrackDetails = item.TrackDetails
|
||||
.Where(x => codes.Contains(x.Code)) // 剔除不在模板内容中的元素
|
||||
.OrderBy(x => codes.IndexOf(x.Code)) // 按照在模板内容的位置排序
|
||||
|
||||
@ -1,5 +1,85 @@
|
||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
using SJZY.Track.Application.Dtos.ProvideServices;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
using SJZY.UserCenter.HttpApi.Services;
|
||||
|
||||
public class TrackService
|
||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹服务
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "提供接口")]
|
||||
public class TrackService : ApplicationService
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||
private readonly ITrackQueries _trackQueries;
|
||||
|
||||
public TrackService(ITrackQueries trackQueries, IOrderRepository orderRepository,
|
||||
ITrackDetailsRepository trackDetailsRepository)
|
||||
{
|
||||
_trackQueries = trackQueries;
|
||||
_orderRepository = orderRepository;
|
||||
_trackDetailsRepository = trackDetailsRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增/更新订单轨迹接口
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessException"></exception>
|
||||
[HttpPost("Track/Upsert")]
|
||||
public async Task<bool> UpsertTrackAsync(UpsertTrackInput input)
|
||||
{
|
||||
var orderId = await _orderRepository.GetFirstAsync(x =>
|
||||
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => x.Id);
|
||||
if (orderId == default)
|
||||
{
|
||||
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
|
||||
}
|
||||
|
||||
// 不存在则新增轨迹,存在则更新
|
||||
var track = await _trackDetailsRepository.GetFirstOrDefaultAsync(orderId, input.TrackCode);
|
||||
if (track == default)
|
||||
{
|
||||
var trackContent = await _trackQueries.MatchTrackContentAsync(orderId, input.TrackCode);
|
||||
if (trackContent == default)
|
||||
{
|
||||
throw new BusinessException(message: $"订单:{input.OrderNo} 所绑定的模板,没有一条内容可以匹配轨迹代码:{input.TrackCode}");
|
||||
}
|
||||
|
||||
track = new TrackDetailsIndex
|
||||
{
|
||||
OrderId = orderId,
|
||||
OrderNo = input.OrderNo,
|
||||
OrderType = input.OrderType,
|
||||
TrackStatus = trackContent.Status,
|
||||
TrackCode = input.TrackCode,
|
||||
TrackContent = trackContent.Content,
|
||||
TrackEnContent = trackContent.EnContent,
|
||||
TrackPlace = input.TrackPlace,
|
||||
TrackTime = input.TrackTime,
|
||||
TraceTimeZone = input.TraceTimeZone,
|
||||
CreateUserId = CurrentUserRequest.CurrentUser.UserId,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
await _trackDetailsRepository.CreateAsync(track);
|
||||
}
|
||||
else
|
||||
{
|
||||
track.UpdateUserId = CurrentUserRequest.CurrentUser.UserId;
|
||||
track.UpdateTime = DateTime.Now;
|
||||
track.TrackPlace = input.TrackPlace;
|
||||
track.TrackTime = input.TrackTime;
|
||||
track.TraceTimeZone = input.TraceTimeZone;
|
||||
await _trackDetailsRepository.UpdateAsync(track);
|
||||
}
|
||||
|
||||
// 根据订单关联关系向下刷,不同子系统还需要做内容映射
|
||||
|
||||
// 推送
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -10,15 +10,8 @@ public interface IOrderRepository : IBasicRepository<OrderEntity>
|
||||
/// <param name="order"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> CreateOrderAsync(OrderEntity order);
|
||||
Task<List<TrackOrderDetailVO>> GetOrderDetails(GetOrderDetailsInputVO input);
|
||||
|
||||
/// <summary>
|
||||
/// 根据订单号,获取订单模板
|
||||
/// </summary>
|
||||
/// <param name="orderType">订单类型</param>
|
||||
/// <param name="distinctOrderNumbers"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<OrderTemplateDto>> GetOrderTemplatesAsync(int orderType, List<string> distinctOrderNumbers);
|
||||
Task<List<TrackOrderDetailVO>> GetOrderDetails(GetOrderDetailsInputVO input);
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页的轨迹订单
|
||||
@ -47,4 +40,11 @@ public interface IOrderRepository : IBasicRepository<OrderEntity>
|
||||
/// <param name="order"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateOrderAsync(OrderEntity order);
|
||||
|
||||
/// <summary>
|
||||
/// 删除订单
|
||||
/// </summary>
|
||||
/// <param name="orderId"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteOrderAsync(int orderId);
|
||||
}
|
||||
@ -4,7 +4,7 @@
|
||||
/// 订单航班表(1:N)
|
||||
/// </summary>
|
||||
[SugarTable("t_order_flight")]
|
||||
public class OrderFlightEntity : ICreateBaicEntity, IEntity
|
||||
public class OrderFlightEntity : ICreateBaicEntity, ISoftDeleteBasicEntity, IEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
@ -33,10 +33,18 @@ public class OrderFlightEntity : ICreateBaicEntity, IEntity
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateUserId")]
|
||||
public int CreateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateTime")]
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否删除
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "IsDeleted")]
|
||||
public bool IsDeleted { get; set; }
|
||||
}
|
||||
@ -4,7 +4,7 @@
|
||||
/// 轨迹订单关联表(1:N)
|
||||
/// </summary>
|
||||
[SugarTable("t_order_link")]
|
||||
public class OrderLinkEntity : ICreateBaicEntity, IEntity
|
||||
public class OrderLinkEntity : ICreateBaicEntity, ISoftDeleteBasicEntity, IEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
@ -39,10 +39,18 @@ public class OrderLinkEntity : ICreateBaicEntity, IEntity
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateUserId")]
|
||||
public int CreateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateTime")]
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否删除
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "IsDeleted")]
|
||||
public bool IsDeleted { get; set; }
|
||||
}
|
||||
@ -4,7 +4,7 @@
|
||||
/// 轨迹订单模板表(1:N)
|
||||
/// </summary>
|
||||
[SugarTable("t_order_template")]
|
||||
public class OrderTemplateEntity : ICreateBaicEntity, IEntity
|
||||
public class OrderTemplateEntity : ICreateBaicEntity, ISoftDeleteBasicEntity, IEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
@ -30,6 +30,21 @@ public class OrderTemplateEntity : ICreateBaicEntity, IEntity
|
||||
[SugarColumn(ColumnName = "TrackTemplateId")]
|
||||
public int TrackTemplateId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateUserId")]
|
||||
public int CreateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateTime")]
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否删除
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "IsDeleted")]
|
||||
public bool IsDeleted { get; set; }
|
||||
}
|
||||
@ -16,19 +16,19 @@ public class TrackContentEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
/// 轨迹内容代码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Code")]
|
||||
public string Code { get; set; }
|
||||
public string Code { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Content")]
|
||||
public string Content { get; set; }
|
||||
public string Content { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容英文
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EnContent")]
|
||||
public string EnContent { get; set; }
|
||||
public string EnContent { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 子系统id
|
||||
|
||||
@ -4,9 +4,13 @@ namespace SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
|
||||
public interface ITrackDetailsRepository
|
||||
{
|
||||
Task WriteTrack(TrackDetailsIndex index);
|
||||
Task<TrackDetailsIndex?> GetFirstOrDefaultAsync(int orderId, string inputTrackCode);
|
||||
|
||||
Task<List<TrackDetailsIndex>> GetListAsync(List<string> orderNos);
|
||||
Task UpdateAsync(TrackDetailsIndex index);
|
||||
|
||||
Task CreateAsync(TrackDetailsIndex index);
|
||||
|
||||
Task<List<TrackDetailsIndex>> GetListAsync(int orderType, List<string> orderNos);
|
||||
|
||||
Task<(List<TrackDetailsIndex> list, long total)> GetListAsync(TrackDetailsQueryInput input);
|
||||
}
|
||||
@ -21,7 +21,7 @@ public class TrackDetailsIndex : IdBaseIndex
|
||||
/// <summary>
|
||||
/// 订单类型(主数据枚举TrackOrderType)
|
||||
/// </summary>
|
||||
public string OrderType { get; set; }
|
||||
public int OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态
|
||||
|
||||
@ -16,13 +16,13 @@ public class TrackStatusEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
/// 轨迹状态代码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Code")]
|
||||
public string Code { get; set; }
|
||||
public string Code { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态英文
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EnStatus")]
|
||||
public string EnStatus { get; set; }
|
||||
public string EnStatus { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 所属节点(主数据枚举ServiceNode)
|
||||
@ -34,7 +34,7 @@ public class TrackStatusEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
/// 轨迹状态
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Status")]
|
||||
public string Status { get; set; }
|
||||
public string Status { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 子系统id
|
||||
|
||||
@ -4,8 +4,6 @@ namespace SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
|
||||
public interface ITrackTemplateRepository : IBasicRepository<TrackTemplateEntity>
|
||||
{
|
||||
Task<List<TemplateContentOrderlyDto>> GetTemplateContentOrderlyAsync(List<int> distinctTemplateIds);
|
||||
|
||||
Task<GetTrackTemplateDetailVO?> GetDetailAsync(int id);
|
||||
|
||||
Task<UnifyPageResultDto<GetTrackTemplateListVO>> GetPageTrackTemplate(GetPageTrackTemplateVO input);
|
||||
@ -35,5 +33,6 @@ public interface ITrackTemplateRepository : IBasicRepository<TrackTemplateEntity
|
||||
|
||||
Task<bool> SoftDeleteContentAsync(int id);
|
||||
|
||||
Task<List<TrackTemplateContentEntity>> GetContentListAsync(Expression<Func<TrackTemplateContentEntity, bool>> whereExpression);
|
||||
Task<List<TrackTemplateContentEntity>> GetContentListAsync(
|
||||
Expression<Func<TrackTemplateContentEntity, bool>> whereExpression);
|
||||
}
|
||||
23
src/SJZY.Track.Domain/Dtos/Order/OrderIdentifier.cs
Normal file
23
src/SJZY.Track.Domain/Dtos/Order/OrderIdentifier.cs
Normal file
@ -0,0 +1,23 @@
|
||||
namespace SJZY.Track.Domain.Dtos.Order;
|
||||
|
||||
/// <summary>
|
||||
/// 订单标识符
|
||||
/// </summary>
|
||||
public readonly struct OrderIdentifier
|
||||
{
|
||||
public OrderIdentifier(int orderType, string orderNo)
|
||||
{
|
||||
OrderType = orderType;
|
||||
OrderNo = orderNo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
public int OrderType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
public string OrderNo { get; }
|
||||
}
|
||||
@ -1,11 +1,11 @@
|
||||
namespace SJZY.Track.Domain.Dtos.Order;
|
||||
|
||||
public class OrderTemplateDto
|
||||
public class OrderTemplateLinkDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
public string OrderNo { get; set; }
|
||||
public string OrderNo { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 模板id
|
||||
@ -0,0 +1,19 @@
|
||||
namespace SJZY.Track.Domain.Dtos.TrackDetails;
|
||||
|
||||
public class MatchTrackContentDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹内容
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容英文
|
||||
/// </summary>
|
||||
public string EnContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态
|
||||
/// </summary>
|
||||
public string Status { get; set; }
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
namespace SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
|
||||
public class TemplateContentOrderlyDto
|
||||
public class OrderedTrackCodeDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 模板id
|
||||
@ -1,4 +1,6 @@
|
||||
namespace SJZY.Track.Domain;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
|
||||
namespace SJZY.Track.Domain;
|
||||
|
||||
public interface IBasicRepository<T> : IBasicQuery<T> where T : IAggregateRoot
|
||||
{
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
namespace SJZY.Track.Domain;
|
||||
namespace SJZY.Track.Domain.Queries;
|
||||
|
||||
public interface IBasicQuery<T> where T : IEntity
|
||||
{
|
||||
34
src/SJZY.Track.Domain/Queries/ITrackQueries.cs
Normal file
34
src/SJZY.Track.Domain/Queries/ITrackQueries.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using SJZY.Track.Domain.Dtos.Order;
|
||||
using SJZY.Track.Domain.Dtos.TrackDetails;
|
||||
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
|
||||
namespace SJZY.Track.Domain.Queries;
|
||||
|
||||
/// <summary>
|
||||
/// 提供接口专用查询
|
||||
/// </summary>
|
||||
public interface ITrackQueries
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据订单号,获取订单模板
|
||||
/// </summary>
|
||||
/// <param name="orderType">订单类型</param>
|
||||
/// <param name="orderNumbers">订单号</param>
|
||||
/// <returns></returns>
|
||||
Task<List<OrderTemplateLinkDto>> GetOrderTemplateLinksAsync(int orderType, List<string> orderNumbers);
|
||||
|
||||
/// <summary>
|
||||
/// 根据订单模板,获取有序的轨迹code
|
||||
/// </summary>
|
||||
/// <param name="templateIds">模板id</param>
|
||||
/// <returns></returns>
|
||||
Task<List<OrderedTrackCodeDto>> GetOrderedTrackCodesAsync(List<int> templateIds);
|
||||
|
||||
/// <summary>
|
||||
/// 根据订单id找到订单模板,匹配模板命中的轨迹内容
|
||||
/// </summary>
|
||||
/// <param name="orderId">订单id</param>
|
||||
/// <param name="code">轨迹代码</param>
|
||||
/// <returns></returns>
|
||||
Task<MatchTrackContentDto?> MatchTrackContentAsync(int orderId, string code);
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
using System.Linq.Expressions;
|
||||
using SJZY.Track.Domain;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
using SJZY.Track.Domain.SeedWork;
|
||||
|
||||
namespace SJZY.Track.Repository;
|
||||
|
||||
@ -1,77 +1,77 @@
|
||||
#pragma warning disable 1591
|
||||
using SJZY.UserCenter.HttpApi.Services;
|
||||
using SJZY.UserCenter.HttpApi.Services;
|
||||
|
||||
namespace SJZY.Track.Repository
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace SJZY.Track.Repository;
|
||||
|
||||
/// <summary>
|
||||
/// Sqlsugar 上下文对象
|
||||
/// </summary>
|
||||
public class DataBaseContext
|
||||
{
|
||||
/// <summary>
|
||||
/// Sqlsugar 上下文对象
|
||||
/// </summary>
|
||||
public class DataBaseContext
|
||||
#region 审计属性自动赋值
|
||||
|
||||
public static void OnExcutingAction(object oldValue, DataFilterModel entityInfo)
|
||||
{
|
||||
//过滤掉 "v_" 开头的表
|
||||
if (entityInfo.EntityColumnInfo.DbTableName.StartsWith("v_", StringComparison.OrdinalIgnoreCase))
|
||||
throw new Exception("非法的操作,不允许编辑映射表");
|
||||
|
||||
#region 审计属性自动赋值
|
||||
|
||||
public static void OnExcutingAction(object oldValue, DataFilterModel entityInfo)
|
||||
//新增
|
||||
if (entityInfo.OperationType == DataFilterType.InsertByObject)
|
||||
{
|
||||
//过滤掉 "v_" 开头的表
|
||||
if (entityInfo.EntityColumnInfo.DbTableName.StartsWith("v_", StringComparison.OrdinalIgnoreCase))
|
||||
throw new Exception("非法的操作,不允许编辑映射表");
|
||||
|
||||
//新增
|
||||
if (entityInfo.OperationType == DataFilterType.InsertByObject)
|
||||
if (entityInfo.PropertyName == nameof(ICreateBaicEntity.CreateTime))
|
||||
entityInfo.SetValue(DateTime.Now);
|
||||
if (entityInfo.PropertyName == nameof(ICreateBaicEntity.CreateUserId))
|
||||
{
|
||||
if (entityInfo.PropertyName == nameof(ICreateBaicEntity.CreateTime))
|
||||
entityInfo.SetValue(DateTime.Now);
|
||||
if (entityInfo.PropertyName == nameof(ICreateBaicEntity.CreateUserId))
|
||||
if (oldValue == null || (int)oldValue == 0)
|
||||
{
|
||||
if (oldValue == null || (int)oldValue == 0)
|
||||
try
|
||||
{
|
||||
entityInfo.SetValue(CurrentUserRequest.CurrentUser?.UserId);
|
||||
}
|
||||
catch
|
||||
{
|
||||
try
|
||||
{
|
||||
entityInfo.SetValue(CurrentUserRequest.CurrentUser?.UserId);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
//entityInfo.SetValue(CurrentUserRequest.CurrentUser.UserId);
|
||||
}
|
||||
//entityInfo.SetValue(CurrentUserRequest.CurrentUser.UserId);
|
||||
}
|
||||
//修改
|
||||
else if (entityInfo.OperationType == DataFilterType.UpdateByObject)
|
||||
}
|
||||
//修改
|
||||
else if (entityInfo.OperationType == DataFilterType.UpdateByObject)
|
||||
{
|
||||
if (entityInfo.PropertyName == nameof(IUpdateBasicEntity.UpdateTime))
|
||||
entityInfo.SetValue(DateTime.Now);
|
||||
else if (entityInfo.PropertyName == nameof(IUpdateBasicEntity.UpdateUserId))
|
||||
{
|
||||
if (entityInfo.PropertyName == nameof(IUpdateBasicEntity.UpdateTime))
|
||||
entityInfo.SetValue(DateTime.Now);
|
||||
else if (entityInfo.PropertyName == nameof(IUpdateBasicEntity.UpdateUserId))
|
||||
if (oldValue == null || (int)oldValue == 1)
|
||||
{
|
||||
if (oldValue == null || (int)oldValue == 1)
|
||||
try
|
||||
{
|
||||
entityInfo.SetValue(CurrentUserRequest.CurrentUser.UserId);
|
||||
}
|
||||
catch
|
||||
{
|
||||
try
|
||||
{
|
||||
entityInfo.SetValue(CurrentUserRequest.CurrentUser.UserId);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
//entityInfo.SetValue(CurrentUserRequest.CurrentUser.UserId);
|
||||
}
|
||||
//删除
|
||||
else if (entityInfo.PropertyName == nameof(IDeleteBasicEntity.IsDeleted))
|
||||
//entityInfo.SetValue(CurrentUserRequest.CurrentUser.UserId);
|
||||
}
|
||||
//删除
|
||||
else if (entityInfo.PropertyName == nameof(IDeleteBasicEntity.IsDeleted))
|
||||
{
|
||||
var currentType = entityInfo.EntityValue.GetType();
|
||||
bool.TryParse(
|
||||
currentType.GetProperty(entityInfo.PropertyName)?.GetValue(entityInfo.EntityValue)?.ToString(),
|
||||
out bool isdelete);
|
||||
if (isdelete)
|
||||
{
|
||||
var currentType = entityInfo.EntityValue.GetType();
|
||||
bool.TryParse(currentType.GetProperty(entityInfo.PropertyName)?.GetValue(entityInfo.EntityValue)?.ToString(), out bool isdelete);
|
||||
if (isdelete)
|
||||
{
|
||||
//currentType.GetProperty(nameof(IDeleteBasicEntity.DeleteUserId))?.SetValue(entityInfo.EntityValue, 5);
|
||||
currentType.GetProperty(nameof(IDeleteBasicEntity.DeleteTime))?.SetValue(entityInfo.EntityValue, DateTime.Now);
|
||||
}
|
||||
//currentType.GetProperty(nameof(IDeleteBasicEntity.DeleteUserId))?.SetValue(entityInfo.EntityValue, 5);
|
||||
currentType.GetProperty(nameof(IDeleteBasicEntity.DeleteTime))
|
||||
?.SetValue(entityInfo.EntityValue, DateTime.Now);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 审计属性自动赋值
|
||||
}
|
||||
|
||||
#endregion 审计属性自动赋值
|
||||
}
|
||||
@ -1,7 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SJZY.Track.Domain;
|
||||
using SJZY.Track.Domain;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Order;
|
||||
|
||||
namespace SJZY.Track.Repository;
|
||||
@ -16,20 +14,6 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
public async Task<List<OrderTemplateDto>> GetOrderTemplatesAsync(int orderType,
|
||||
List<string> distinctOrderNumbers)
|
||||
{
|
||||
return await AsQueryable()
|
||||
.LeftJoin<OrderTemplateEntity>((a, b) => a.Id == b.OrderId)
|
||||
.Where(a => a.OrderType == orderType && distinctOrderNumbers.Contains(a.OrderNo))
|
||||
.Select((a, b) => new OrderTemplateDto
|
||||
{
|
||||
OrderNo = a.OrderNo,
|
||||
TemplateId = b.TrackTemplateId
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task LinkOrderAsync(List<OrderLinkEntity> orderLinkEntities)
|
||||
{
|
||||
await Context.Insertable(orderLinkEntities).ExecuteCommandAsync();
|
||||
@ -60,6 +44,20 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
tran.Complete();
|
||||
}
|
||||
|
||||
public async Task DeleteOrderAsync(int orderId)
|
||||
{
|
||||
using var tran = TransactionHelper.GetReadCommitted();
|
||||
|
||||
// 软删订单主表
|
||||
await SoftDeleteAsync(x => x.Id == orderId);
|
||||
|
||||
// 软删订单模板
|
||||
// 软删订单航班
|
||||
// 软删订单关联关系
|
||||
|
||||
tran.Complete();
|
||||
}
|
||||
|
||||
#region 轨迹订单明细
|
||||
|
||||
/// <summary>
|
||||
@ -71,9 +69,11 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 轨迹订单分页
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页的轨迹订单
|
||||
/// </summary>
|
||||
@ -105,5 +105,6 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
78
src/SJZY.Track.Repository/Queries/TrackQueries.cs
Normal file
78
src/SJZY.Track.Repository/Queries/TrackQueries.cs
Normal file
@ -0,0 +1,78 @@
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Order;
|
||||
using SJZY.Track.Domain.Dtos.TrackDetails;
|
||||
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
|
||||
namespace SJZY.Track.Repository.Queries;
|
||||
|
||||
public class TrackQueries : ISugarRepository, ITrackQueries,
|
||||
ITransientDependency
|
||||
{
|
||||
public ISqlSugarClient Context { get; set; }
|
||||
|
||||
public TrackQueries()
|
||||
{
|
||||
Context = SqlsugarScopeBasic.GetContextSafely("default");
|
||||
}
|
||||
|
||||
public async Task<List<OrderTemplateLinkDto>> GetOrderTemplateLinksAsync(int orderType,
|
||||
params string[] orderNumbers)
|
||||
{
|
||||
return await Context.Queryable<OrderEntity>()
|
||||
.LeftJoin<OrderTemplateEntity>((a, b) => a.Id == b.OrderId)
|
||||
.Where(a => a.OrderType == orderType && orderNumbers.Contains(a.OrderNo))
|
||||
.Select((a, b) => new OrderTemplateLinkDto
|
||||
{
|
||||
OrderNo = a.OrderNo,
|
||||
TemplateId = b.TrackTemplateId
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<OrderTemplateLinkDto>> GetOrderTemplateLinksAsync(int orderType, List<string> orderNumbers)
|
||||
{
|
||||
return await Context.Queryable<OrderEntity>()
|
||||
.LeftJoin<OrderTemplateEntity>((a, b) => a.Id == b.OrderId)
|
||||
.Where(a => a.OrderType == orderType && orderNumbers.Contains(a.OrderNo))
|
||||
.Select((a, b) => new OrderTemplateLinkDto
|
||||
{
|
||||
OrderNo = a.OrderNo,
|
||||
TemplateId = b.TrackTemplateId
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<OrderedTrackCodeDto>> GetOrderedTrackCodesAsync(List<int> templateIds)
|
||||
{
|
||||
return await Context.Queryable<TrackTemplateContentEntity>()
|
||||
.LeftJoin<TrackContentEntity>((a, b) => a.TrackContentId == b.Id)
|
||||
.Where(a => templateIds.Contains(a.TrackTemplateId))
|
||||
.OrderBy(a => a.Sort)
|
||||
.Select((a, b) => new OrderedTrackCodeDto
|
||||
{
|
||||
TemplateId = a.Id,
|
||||
Code = b.Code
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<MatchTrackContentDto?> MatchTrackContentAsync(int orderId, string code)
|
||||
{
|
||||
return await Context.Queryable<OrderTemplateEntity>()
|
||||
.LeftJoin<TrackTemplateContentEntity>((x, a) => x.TrackTemplateId == a.TrackTemplateId)
|
||||
.LeftJoin<TrackContentEntity>((x, a, b) => a.TrackContentId == b.Id)
|
||||
.LeftJoin<TrackStatusEntity>((x, a, b, c) => b.TrackStatusId == c.Id)
|
||||
.Where((x, a, b) => x.OrderId == orderId && b.Code == code)
|
||||
.Select((x, a, b, c) => new MatchTrackContentDto
|
||||
{
|
||||
Content = b.Content,
|
||||
EnContent = b.EnContent,
|
||||
Status = c.Status
|
||||
})
|
||||
.FirstAsync();
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using SJZY.Expand.ABP.Core.SqlSugar.Options;
|
||||
using SJZY.Expand.ElasticSearch;
|
||||
using SJZY.Track.Domain;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
using Volo.Abp.Autofac;
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
@ -44,9 +45,6 @@ public class SJZYTrackRepositoryModule : AbpModule
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
context.Services.AddTransient(typeof(IBasicQuery<>), typeof(BasicQuery<>));
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
using Nest;
|
||||
using SJZY.Expand.ABP.Core.Logger;
|
||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
using SJZY.Expand.ElasticSearch.Services;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Dtos.TrackDetails;
|
||||
@ -10,26 +8,49 @@ namespace SJZY.Track.Repository;
|
||||
internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetailsIndex>, ITrackDetailsRepository,
|
||||
ITransientDependency
|
||||
{
|
||||
public string IndexName => $"{TrackDetailsIndex.IndexName}-{DateTime.Now:yyyy.MM.dd}";
|
||||
|
||||
public TrackDetailsRepository(ConnectionFactory connectionFactory) : base(connectionFactory)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task WriteTrack(TrackDetailsIndex index)
|
||||
public async Task<TrackDetailsIndex?> GetFirstOrDefaultAsync(int orderId, string trackCode)
|
||||
{
|
||||
try
|
||||
var r = await Context.SearchAsync<TrackDetailsIndex>(s => s
|
||||
.Index($"{TrackDetailsIndex.IndexName}-{DateTime.Now:yyyy.MM.dd}")
|
||||
.Query(q =>
|
||||
q.Term(t => t.Field(f => f.OrderId).Value(orderId))
|
||||
&& q.Term(t => t.Field(f => f.TrackCode).Value(trackCode))
|
||||
)
|
||||
);
|
||||
|
||||
if (r.IsValid)
|
||||
{
|
||||
//await Context.IndexDocumentAsync(idx);
|
||||
var response = await Context.IndexAsync(index,
|
||||
request => request.Index($"{TrackDetailsIndex.IndexName}-{DateTime.Now:yyyy.MM.dd}"));
|
||||
if (!response.IsValid) LogHelper.Error("数据添加失败,原因:" + response.DebugInformation);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"日志插入ES失败:{ex.Message}。{index.ToJson()}");
|
||||
return r.Documents.FirstOrDefault();
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
public async Task<List<TrackDetailsIndex>> GetListAsync(List<string> orderNos)
|
||||
public async Task UpdateAsync(TrackDetailsIndex index)
|
||||
{
|
||||
var response = await Context.UpdateAsync<TrackDetailsIndex>(index.Id, u => u
|
||||
.Index(IndexName)
|
||||
.Doc(index)
|
||||
//.Refresh(Refresh.True) // 可选:立即刷新索引使更改立即可见
|
||||
);
|
||||
if (!response.IsValid)
|
||||
throw new Exception($"数据修改失败,原因:{response.DebugInformation}");
|
||||
}
|
||||
|
||||
public async Task CreateAsync(TrackDetailsIndex index)
|
||||
{
|
||||
var response = await Context.IndexAsync(index, request => request.Index(IndexName));
|
||||
if (!response.IsValid)
|
||||
throw new Exception($"数据添加失败,原因:{response.DebugInformation}");
|
||||
}
|
||||
|
||||
public async Task<List<TrackDetailsIndex>> GetListAsync(int orderType, List<string> orderNos)
|
||||
{
|
||||
if (orderNos.Count < 1) return new List<TrackDetailsIndex>();
|
||||
|
||||
@ -42,9 +63,11 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
.Field(f => f.TrackTime)
|
||||
.Field(f => f.TraceTimeZone)
|
||||
))
|
||||
.Query(q => q.Terms(t => t
|
||||
.Field(f => f.OrderNo)
|
||||
.Terms(orderNos)))
|
||||
.Query(q =>
|
||||
q.Terms(t => t
|
||||
.Field(f => f.OrderNo)
|
||||
.Terms(orderNos))
|
||||
&& q.Term(f => f.OrderType, orderType))
|
||||
);
|
||||
|
||||
return data.Documents.ToList();
|
||||
|
||||
@ -10,24 +10,8 @@ using SJZY.Track.Repository.Enum;
|
||||
|
||||
namespace SJZY.Track.Repository;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITrackTemplateRepository, IScopedDependency
|
||||
{
|
||||
public async Task<List<TemplateContentOrderlyDto>> GetTemplateContentOrderlyAsync(List<int> distinctTemplateIds)
|
||||
{
|
||||
return await Context.Queryable<TrackTemplateEntity>()
|
||||
.LeftJoin<TrackTemplateContentEntity>((a, b) => a.Id == b.TrackTemplateId)
|
||||
.LeftJoin<TrackContentEntity>((a, b, c) => b.TrackContentId == c.Id)
|
||||
.Where(a => distinctTemplateIds.Contains(a.Id))
|
||||
.OrderBy((a, b) => b.Sort)
|
||||
.Select((a, b, c) => new TemplateContentOrderlyDto
|
||||
{
|
||||
TemplateId = a.Id,
|
||||
Code = c.Code
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取轨迹模版明细
|
||||
/// </summary>
|
||||
@ -40,13 +24,13 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
|
||||
.Where((a, b) => a.Id == id)
|
||||
.Select((a, b) => new
|
||||
GetTrackTemplateDetailVO
|
||||
{
|
||||
Id = a.Id,
|
||||
Code = a.Code,
|
||||
Name = a.Name,
|
||||
SubSystemId = a.SubSystemId,
|
||||
SubSystem = b.CnName
|
||||
}).FirstAsync();
|
||||
{
|
||||
Id = a.Id,
|
||||
Code = a.Code,
|
||||
Name = a.Name,
|
||||
SubSystemId = a.SubSystemId,
|
||||
SubSystem = b.CnName
|
||||
}).FirstAsync();
|
||||
|
||||
return detail;
|
||||
}
|
||||
@ -58,13 +42,14 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
|
||||
/// <returns></returns>
|
||||
public async Task<UnifyPageResultDto<GetTrackTemplateListVO>> GetPageTrackTemplate(GetPageTrackTemplateVO input)
|
||||
{
|
||||
UnifyPageResultDto<GetTrackTemplateListVO> pagedList = new UnifyPageResultDto<GetTrackTemplateListVO>();
|
||||
pagedList = await Context.Queryable<TrackTemplateEntity>()
|
||||
UnifyPageResultDto<GetTrackTemplateListVO> pagedList = await Context.Queryable<TrackTemplateEntity>()
|
||||
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
|
||||
.WhereIF(input.SubSystemId > 0, (a, b) => a.SubSystemId == input.SubSystemId)
|
||||
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(),
|
||||
(a, b) => a.Name.Contains(input.Keywords) || a.Code.Contains(input.Keywords))
|
||||
.OrderByIF(input.TrackTemplateId > 0, (a, b) => SqlFunc.IIF(a.Id == input.TrackTemplateId, SqlFunc.DateAdd(SqlFunc.GetDate(), 1), a.CreateTime), OrderByType.Desc)
|
||||
.OrderByIF(input.TrackTemplateId > 0,
|
||||
(a, b) => SqlFunc.IIF(a.Id == input.TrackTemplateId, SqlFunc.DateAdd(SqlFunc.GetDate(), 1),
|
||||
a.CreateTime), OrderByType.Desc)
|
||||
.Select((a, b) => new GetTrackTemplateListVO
|
||||
{
|
||||
Id = a.Id,
|
||||
@ -168,7 +153,8 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
|
||||
.ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
|
||||
public async Task<List<TrackTemplateContentEntity>> GetContentListAsync(Expression<Func<TrackTemplateContentEntity, bool>> whereExpression)
|
||||
public async Task<List<TrackTemplateContentEntity>> GetContentListAsync(
|
||||
Expression<Func<TrackTemplateContentEntity, bool>> whereExpression)
|
||||
{
|
||||
return await Context.Queryable<TrackTemplateContentEntity>().Where(whereExpression).ToListAsync();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user