解决冲突
This commit is contained in:
commit
5ebe58d8b3
@ -2,21 +2,8 @@
|
||||
|
||||
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
|
||||
public class BatchDeleteTrackInput
|
||||
public class BatchDeleteTrackInput : OrderNosInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单类型,必填
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Range(1, int.MaxValue)]
|
||||
public int OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号,必填
|
||||
/// </summary>
|
||||
[Required]
|
||||
public List<string> OrderNos { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹code,必填
|
||||
/// </summary>
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
|
||||
public class BatchUpsertTrackInput : OrderNosInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹内容代码
|
||||
/// </summary>
|
||||
[Required]
|
||||
[MaxLength(50)]
|
||||
public string TrackCode { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地
|
||||
/// </summary>
|
||||
[Required]
|
||||
[MaxLength(200)]
|
||||
public string TrackPlace { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时间
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime? TrackTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时区
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Range(-12, 12)]
|
||||
public float? TrackTimeZone { get; set; }
|
||||
}
|
||||
@ -17,6 +17,11 @@ public class GetPageTrackOrderInput : PageInfoInput
|
||||
/// </summary>
|
||||
public string? OrderNos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// tab标签类型 0 全部, 1 异常 2 预警
|
||||
/// </summary>
|
||||
public int TabType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
@ -27,6 +32,11 @@ public class GetPageTrackOrderInput : PageInfoInput
|
||||
/// </summary>
|
||||
public int? CustomerId { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 当tab选中 0 默认不传 1 直接写死传值 [1,4] 2 传 [2,4]
|
||||
///// </summary>
|
||||
//public List<int>? QuestionTypeIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间开始
|
||||
/// </summary>
|
||||
@ -128,5 +138,28 @@ public class TrackOrderDto
|
||||
/// </summary>
|
||||
public string SubSystem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子系统id
|
||||
/// </summary>
|
||||
public int SubSystemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型(主数据枚举TrackQuestionType)
|
||||
/// </summary>
|
||||
public int QuestionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型名称
|
||||
/// </summary>
|
||||
public string? QuestionTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
||||
/// </summary>
|
||||
public int ProblemDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述名称
|
||||
/// </summary>
|
||||
public string? ProblemDescriptionName { get; set; }
|
||||
}
|
||||
@ -2,20 +2,8 @@ using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
|
||||
public class GetTrackInput
|
||||
public class GetTrackInput : OrderNosInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Range(1, int.MaxValue)]
|
||||
public int OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
public List<string> OrderNos { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 时区 +8 +8.25 -8.5 -9
|
||||
/// 不传默认+8
|
||||
|
||||
@ -18,3 +18,19 @@ public class OrderNoInfo
|
||||
[MaxLength(100)]
|
||||
public string OrderNo { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class OrderNosInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Range(1, int.MaxValue)]
|
||||
public int OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
[Required]
|
||||
public List<string> OrderNos { get; set; } = new();
|
||||
}
|
||||
@ -31,17 +31,3 @@ public class UpsertTrackInput : OrderNoInfo
|
||||
[Range(-12, 12)]
|
||||
public float? TrackTimeZone { get; set; }
|
||||
}
|
||||
|
||||
public class NotNullAttribute : ValidationAttribute
|
||||
{
|
||||
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return new ValidationResult(ErrorMessage ?? "The field is required.",
|
||||
new[] { validationContext.MemberName });
|
||||
}
|
||||
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,11 @@ public class UpdateOrderTrackEvent
|
||||
/// </summary>
|
||||
public int OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否删除引起的更新
|
||||
/// </summary>
|
||||
public bool IsDelete { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 此次发生的轨迹是否意味完成
|
||||
/// </summary>
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<Version>1.0.0</Version>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
@ -29,7 +29,7 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
|
||||
{
|
||||
if (@event.Visited.Contains(@event.OrderId))
|
||||
{
|
||||
LogHelper.Error($"轨迹订单循环依赖预警:{@event.Visited.JoinAsString(",")}");
|
||||
LogHelper.Error($"删除轨迹订单时,发现循环依赖:{@event.Visited.JoinAsString(",")}");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -56,7 +56,30 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
|
||||
private async Task DeleteTrackAsync(TrackDeleteEvent @event)
|
||||
{
|
||||
// 删除轨迹
|
||||
await _trackDetailsRepository.DeleteTrackAsync(@event.OrderId, @event.TrackCodes);
|
||||
var isOk = await _trackDetailsRepository.DeleteTrackAsync(@event.OrderId, @event.TrackCodes);
|
||||
|
||||
// 触发订单主表更新事件
|
||||
if (isOk)
|
||||
{
|
||||
var track = await _trackDetailsRepository.GetLatestAsync(@event.OrderId);
|
||||
var updateOrderEvent = track == default
|
||||
? new UpdateOrderTrackEvent
|
||||
{
|
||||
OrderId = @event.OrderId,
|
||||
IsDelete = true
|
||||
}
|
||||
: new UpdateOrderTrackEvent
|
||||
{
|
||||
OrderId = @event.OrderId,
|
||||
IsCompleted = track.IsCompleted,
|
||||
TrackContent = track.TrackContent,
|
||||
TrackEnContent = track.TrackEnContent,
|
||||
TrackPlace = track.TrackPlace,
|
||||
TrackTime = track.TrackTime,
|
||||
TrackTimeZone = track.TrackTimeZone
|
||||
};
|
||||
await _capPublisher.PublishAsync(GlobalConst.UpdateOrderTrackSubscribe, updateOrderEvent);
|
||||
}
|
||||
|
||||
// 根据订单关联关系异步向下刷
|
||||
var linkedOrders = await _orderRepository.GetLinkedOrdersAsync(@event.OrderId);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Linq.Expressions;
|
||||
using System.Diagnostics;
|
||||
using System.Linq.Expressions;
|
||||
using DotNetCore.CAP;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@ -94,47 +95,71 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
||||
var trackUpsertEvent = @event.DeepCopy();
|
||||
var paramConfig = config.ParamConfig;
|
||||
var contentConfigs = config.ContentConfigs;
|
||||
TrackPullContentConfigDto? trackContent = null;
|
||||
TrackPullContentConfigDto? matchedContentConfig = null;
|
||||
|
||||
// 1、匹配轨迹代码
|
||||
var serviceProviderTrackCode = trackToken[paramConfig.TrackContentCodeName]?.Value<string>();
|
||||
if (!serviceProviderTrackCode.IsNullOrWhiteSpace())
|
||||
var trackCode = trackToken[paramConfig.TrackContentCodeName]?.Value<string>();
|
||||
if (!trackCode.IsNullOrWhiteSpace())
|
||||
{
|
||||
trackContent = contentConfigs.FirstOrDefault(x => x.TrackContentCodeValue == serviceProviderTrackCode);
|
||||
matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackContentCodeValue == trackCode);
|
||||
}
|
||||
|
||||
// 2、匹配轨迹状态
|
||||
if (trackContent is null)
|
||||
if (matchedContentConfig is null)
|
||||
{
|
||||
var serviceProviderTrackStatus = trackToken[paramConfig.TrackStatusName]?.Value<string>();
|
||||
if (!serviceProviderTrackStatus.IsNullOrWhiteSpace())
|
||||
var trackStatus = trackToken[paramConfig.TrackStatusName]?.Value<string>();
|
||||
if (!trackStatus.IsNullOrWhiteSpace())
|
||||
{
|
||||
trackContent = contentConfigs.FirstOrDefault(x => x.TrackStatusValue == serviceProviderTrackCode);
|
||||
matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackStatusValue == trackCode);
|
||||
}
|
||||
}
|
||||
|
||||
// 3、匹配轨迹内容
|
||||
if (trackContent is null)
|
||||
if (matchedContentConfig is null)
|
||||
{
|
||||
var serviceProviderTrackContent = trackToken[paramConfig.TrackContentName]?.Value<string>();
|
||||
if (!serviceProviderTrackContent.IsNullOrWhiteSpace())
|
||||
var trackContent = trackToken[paramConfig.TrackContentName]?.Value<string>();
|
||||
if (!trackContent.IsNullOrWhiteSpace())
|
||||
{
|
||||
trackContent = contentConfigs.FirstOrDefault(x => x.TrackContentValue == serviceProviderTrackCode);
|
||||
Debug.Assert(trackContent != null, nameof(trackContent) + " != null");
|
||||
matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackContentValue == trackCode);
|
||||
|
||||
// 3.1、按关键字匹配
|
||||
if (trackContent is null)
|
||||
// 按关键字分析轨迹内容
|
||||
if (matchedContentConfig is null)
|
||||
{
|
||||
foreach (var contentConfig in contentConfigs)
|
||||
{
|
||||
foreach (var keyword in contentConfig.TrackKeyword?.Split(',') ?? Enumerable.Empty<string>())
|
||||
{
|
||||
if (trackContent.Contains(keyword, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
matchedContentConfig = contentConfig;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedContentConfig is null) continue;
|
||||
|
||||
foreach (var keyword in contentConfig.TrackKeywordReverse?.Split(',') ??
|
||||
Enumerable.Empty<string>())
|
||||
{
|
||||
if (trackContent.Contains(keyword, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
matchedContentConfig = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (trackContent is null) return;
|
||||
if (matchedContentConfig is null) return;
|
||||
|
||||
var trackPlace = trackToken[paramConfig.TrackPlaceName]?.Value<string>();
|
||||
if (trackPlace.IsNullOrWhiteSpace())
|
||||
{
|
||||
Expression<Func<OrderEntity, string?>> resultExpression =
|
||||
(TrackLocationValue?)trackContent.TrackPlaceValue switch
|
||||
(TrackLocationValue?)matchedContentConfig.TrackPlaceValue switch
|
||||
{
|
||||
TrackLocationValue.ArrivalPort => x => x.ArrivalPort,
|
||||
TrackLocationValue.ArriveCity => x => x.ArrivalCity,
|
||||
@ -149,11 +174,11 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
||||
}
|
||||
|
||||
// 新增/更新轨迹
|
||||
trackUpsertEvent.TrackCode = trackContent.TrackContentCode;
|
||||
trackUpsertEvent.TrackCode = matchedContentConfig.TrackContentCode;
|
||||
trackUpsertEvent.TrackPlace = trackPlace ?? "CN";
|
||||
trackUpsertEvent.TrackTime = trackToken[paramConfig.TrackTimeName]?.Value<DateTime>() ?? DateTime.Now;
|
||||
trackUpsertEvent.TrackTimeZone = trackToken[paramConfig.TrackTimeZoneName]?.Value<float>() ??
|
||||
trackContent.TrackTimeZoneValue ?? 8;
|
||||
matchedContentConfig.TrackTimeZoneValue ?? 8;
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, trackUpsertEvent);
|
||||
}
|
||||
}
|
||||
@ -88,7 +88,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
TrackStatus = trackContent.Status,
|
||||
TrackCode = @event.TrackCode,
|
||||
TrackContent = trackContent.Content,
|
||||
|
||||
IsCompleted = orderIsCompleted,
|
||||
TrackEnContent = trackContent.EnContent,
|
||||
TrackPlace = @event.TrackPlace,
|
||||
TrackTime = @event.TrackTime!.Value,
|
||||
|
||||
@ -20,16 +20,31 @@ public class UpdateOrderTrackEventHandler : ITransientDependency, ICapSubscribe
|
||||
var order = await _orderRepository.GetFirstAsync(x => x.Id == @event.OrderId);
|
||||
if (order == default) return;
|
||||
|
||||
if (order.IsCompleted) return;
|
||||
if (@event.IsDelete)
|
||||
{
|
||||
if (@event.TrackTime == default)
|
||||
{
|
||||
if (order.LatestTrackTime == null) return;
|
||||
// 删除全部轨迹导致的重置行为
|
||||
order.ResetTrackInfo();
|
||||
}
|
||||
else if (order.LatestTrackTime != null &&
|
||||
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) ==
|
||||
@event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone))) return;
|
||||
}
|
||||
else // upsert引发的更新
|
||||
{
|
||||
if (order.LatestTrackTime != null &&
|
||||
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) >
|
||||
@event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone))) return;
|
||||
}
|
||||
|
||||
order.IsCompleted = @event.IsCompleted;
|
||||
order.LatestTrackContent = @event.TrackContent;
|
||||
order.LatestTrackEnContent = @event.TrackEnContent;
|
||||
order.LatestTrackPlace = @event.TrackPlace;
|
||||
order.LatestTrackTime = @event.TrackTime;
|
||||
order.LatestTrackTimeZone = @event.TrackTimeZone;
|
||||
if (@event.IsCompleted) order.IsCompleted = true;
|
||||
else if (order.LatestTrackTime != null &&
|
||||
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) >
|
||||
@event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone))) return;
|
||||
|
||||
await _orderRepository.UpdateColumnAsync(order, x => new
|
||||
{
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SJZY.InterfaceRelay.Application.Contracts" Version="7.1.2" />
|
||||
<PackageReference Include="SJZY.InterfaceRelay.Application.Contracts" Version="7.1.3"/>
|
||||
<PackageReference Include="Volo.Abp.Http.Client" Version="7.0.2" />
|
||||
<PackageReference Include="Volo.Abp.FluentValidation" Version="7.0.2" />
|
||||
<PackageReference Include="SJZY.UserCenter.HttpApi" Version="3.0.3-alpha8" />
|
||||
|
||||
@ -14,6 +14,12 @@ public partial class OrderService
|
||||
private readonly IBasicQuery<OrderLinkEntity> _orderLinkQuery;
|
||||
private readonly ICapPublisher _capPublisher;
|
||||
|
||||
/// <summary>
|
||||
/// 关联、解除关联订单
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessException"></exception>
|
||||
[HttpPost("Order/Link")]
|
||||
public async Task<bool> LinkOrderAsync(LinkOrderInput input)
|
||||
{
|
||||
|
||||
@ -24,6 +24,11 @@ public partial class OrderService : ApplicationService, IOrderService
|
||||
_orderLinkQuery = orderLinkQuery;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增、更新订单(存在就更新)
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Order/Upsert")]
|
||||
public async Task<string> UpsertAsync(UpsertOrderInput input)
|
||||
{
|
||||
@ -45,6 +50,12 @@ public partial class OrderService : ApplicationService, IOrderService
|
||||
return "创建成功";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除订单
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessException"></exception>
|
||||
[HttpPost("Order/Delete")]
|
||||
public async Task<bool> DeleteOrderAsync(DeleteOrderInput input)
|
||||
{
|
||||
|
||||
@ -15,10 +15,10 @@ namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
public class TrackPushPullService : ApplicationService
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly IHttpClientProxy<IInterfaceForwardService> _httpClientProxy;
|
||||
private readonly IHttpClientProxy<IInterfaceForwardServiceV2> _httpClientProxy;
|
||||
|
||||
public TrackPushPullService(IOrderRepository orderRepository,
|
||||
IHttpClientProxy<IInterfaceForwardService> httpClientProxy)
|
||||
IHttpClientProxy<IInterfaceForwardServiceV2> httpClientProxy)
|
||||
{
|
||||
_orderRepository = orderRepository;
|
||||
_httpClientProxy = httpClientProxy;
|
||||
@ -49,9 +49,9 @@ public class TrackPushPullService : ApplicationService
|
||||
x.OrderNo
|
||||
}).ToList();
|
||||
|
||||
// 批量获取轨迹
|
||||
// 批量获取轨迹 这里报错了,我先随便给个 写死的主体值
|
||||
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
|
||||
"A012", group.Key.ServiceProviderCode, 42, data,
|
||||
"A012", group.Key.ServiceProviderCode, data,
|
||||
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,12 @@ public partial class TrackService
|
||||
{
|
||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||
|
||||
/// <summary>
|
||||
/// 查询轨迹
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessException"></exception>
|
||||
[HttpPost("Track/Query")]
|
||||
public async Task<List<GetTrackOutput>> QueryAsync(GetTrackInput input)
|
||||
{
|
||||
|
||||
@ -29,6 +29,12 @@ public partial class TrackService : ApplicationService, ITrackService
|
||||
_trackDetailsRepository = trackDetailsRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增、更新轨迹(存在就更新)
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessException"></exception>
|
||||
[HttpPost("Track/Upsert")]
|
||||
public async Task<bool> UpsertTrackAsync(UpsertTrackInput input)
|
||||
{
|
||||
@ -52,24 +58,68 @@ public partial class TrackService : ApplicationService, ITrackService
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量新增、更新轨迹
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessException"></exception>
|
||||
[HttpPost("Track/BatchUpsert")]
|
||||
public async Task<bool> BatchUpsertTrackAsync(BatchUpsertTrackInput input)
|
||||
{
|
||||
input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空
|
||||
if (input.OrderNos.Count == 0)
|
||||
{
|
||||
throw new BusinessException(message: "订单一个都不存在");
|
||||
}
|
||||
|
||||
var orders = await _orderRepository.GetListAsync(x =>
|
||||
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo), x => new
|
||||
{
|
||||
x.Id, x.OrderNo, x.SubSystemId, x.IsPushCompleted, x.CustomId
|
||||
});
|
||||
|
||||
foreach (var order in orders)
|
||||
{
|
||||
// 新增/更新轨迹
|
||||
var @event = new TrackUpsertEvent
|
||||
{
|
||||
TrackCode = input.TrackCode,
|
||||
TrackPlace = input.TrackPlace,
|
||||
TrackTime = input.TrackTime,
|
||||
TrackTimeZone = input.TrackTimeZone,
|
||||
OrderType = input.OrderType,
|
||||
OrderNo = order.OrderNo,
|
||||
OrderId = order.Id,
|
||||
SubSystemId = order.SubSystemId,
|
||||
IsPushCompleted = order.IsPushCompleted,
|
||||
CustomId = order.CustomId
|
||||
};
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除轨迹
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessException"></exception>
|
||||
[HttpPost("Track/Delete")]
|
||||
public async Task<bool> DeleteTrackAsync(DeleteTrackInput input)
|
||||
{
|
||||
var order = await _orderRepository.GetFirstAsync(x =>
|
||||
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new
|
||||
{
|
||||
x.Id, x.SubSystemId, x.IsCompleted
|
||||
x.Id, x.SubSystemId
|
||||
});
|
||||
if (order == default)
|
||||
{
|
||||
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
|
||||
}
|
||||
|
||||
if (order.IsCompleted)
|
||||
{
|
||||
throw new BusinessException(message: $"订单:{input.OrderNo}已完成无法删除轨迹");
|
||||
}
|
||||
|
||||
var codes = await _provideQueries.GetCanDeleteTrackCodesAsync(new List<int>(order.Id), input.TrackCodes);
|
||||
|
||||
if (codes.Count == 0)
|
||||
@ -89,6 +139,12 @@ public partial class TrackService : ApplicationService, ITrackService
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除轨迹
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessException"></exception>
|
||||
[HttpPost("Track/BatchDelete")]
|
||||
public async Task<bool> BatchDeleteTrackAsync(BatchDeleteTrackInput input)
|
||||
{
|
||||
|
||||
@ -108,14 +108,34 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
[SugarColumn(ColumnName = "LeaveCountry")]
|
||||
public string LeaveCountry { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型(主数据枚举TrackQuestionType)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "QuestionType")]
|
||||
public int QuestionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "ProblemDescription")]
|
||||
public int ProblemDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 起运港口
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LeavePort")]
|
||||
public string? LeavePort { get; set; }
|
||||
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<OrderFlightEntity> OrderFlights { get; set; }
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<OrderTemplateEntity> OrderTemplates { get; set; }
|
||||
[SugarColumn(IsIgnore = true)] public List<OrderFlightEntity> OrderFlights { get; set; }
|
||||
[SugarColumn(IsIgnore = true)] public List<OrderTemplateEntity> OrderTemplates { get; set; }
|
||||
|
||||
public void ResetTrackInfo()
|
||||
{
|
||||
IsCompleted = false;
|
||||
LatestTrackContent = null;
|
||||
LatestTrackEnContent = null;
|
||||
LatestTrackTime = null;
|
||||
LatestTrackPlace = null;
|
||||
LatestTrackTimeZone = null;
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,14 @@ public interface ITrackDetailsRepository
|
||||
/// <param name="orderId"></param>
|
||||
/// <param name="trackCodes"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteTrackAsync(int orderId, List<string> trackCodes);
|
||||
Task<bool> DeleteTrackAsync(int orderId, List<string> trackCodes);
|
||||
|
||||
Task<List<TrackDetailsIndex>?> GetListAsync(List<int> orderIds);
|
||||
|
||||
/// <summary>
|
||||
/// 获取最近一条发生的轨迹
|
||||
/// </summary>
|
||||
/// <param name="orderId"></param>
|
||||
/// <returns></returns>
|
||||
Task<TrackDetailsIndex?> GetLatestAsync(int orderId);
|
||||
}
|
||||
@ -46,6 +46,11 @@ public class TrackDetailsIndex : IdBaseIndex
|
||||
/// </summary>
|
||||
public string TrackContent { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 是否意味着完成
|
||||
/// </summary>
|
||||
public bool IsCompleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 原轨迹内容
|
||||
/// </summary>
|
||||
|
||||
@ -18,6 +18,25 @@ namespace SJZY.Track.Domain.Dtos.Order
|
||||
///// </summary>
|
||||
//public List<string>? OrderNos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当tab选中 0 默认不传 1 直接写死传值 [1,4] 2 传 [2,4]
|
||||
/// </summary>
|
||||
public int TabType { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 当tab选中 1 直接写死传值 [1,4] 2 传 [2,4]
|
||||
///// </summary>
|
||||
//public List<int>? QuestionTypeIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
public int? TrackOrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户id
|
||||
/// </summary>
|
||||
public int? CustomerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单号
|
||||
@ -139,5 +158,25 @@ namespace SJZY.Track.Domain.Dtos.Order
|
||||
/// 轨迹模板Id数组
|
||||
/// </summary>
|
||||
public List<int>? TrackTemplateIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型(主数据枚举TrackQuestionType)
|
||||
/// </summary>
|
||||
public int QuestionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型名称
|
||||
/// </summary>
|
||||
public string? QuestionTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
||||
/// </summary>
|
||||
public int ProblemDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述名称
|
||||
/// </summary>
|
||||
public string? ProblemDescriptionName { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +27,11 @@ public class GlobalConst
|
||||
/// </summary>
|
||||
public const string UpdateOrderTrackSubscribe = "SJZY.Track.UpdateOrderTrack";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹删除后触发更新订单轨迹 mq订阅名称
|
||||
/// </summary>
|
||||
public const string DeleteTrackAfterUpdateOrderSubscribe = "SJZY.Track.DeleteTrackAfterUpdateOrder";
|
||||
|
||||
/// <summary>
|
||||
/// 关联订单后补轨迹 mq订阅名称
|
||||
/// </summary>
|
||||
|
||||
@ -5,6 +5,7 @@ using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Order;
|
||||
using SJZY.Track.Domain.VEntities;
|
||||
using SJZY.Track.Repository.VData.Entitys;
|
||||
using SqlSugar;
|
||||
|
||||
namespace SJZY.Track.Repository.Repositories;
|
||||
|
||||
@ -121,10 +122,22 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
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)
|
||||
@ -139,6 +152,7 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
(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
|
||||
{
|
||||
@ -151,6 +165,10 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
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, ","),
|
||||
@ -209,7 +227,7 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
|
||||
a.TrackTemplateNames = trackTemplateList.Where(b => b.OrderId == a.Id).Select(a => a.Name)
|
||||
.JoinAsString(",");
|
||||
a.TrackTemplateIds = trackTemplateList.Where(b => b.OrderId == a.Id).Select(a => a.TemplateId).ToList();
|
||||
a.TrackTemplateIds = trackTemplateList.Where(b => b.OrderId == a.Id).Where(b => b.TemplateId>0).Select(a => a.TemplateId).ToList();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
using Elasticsearch.Net;
|
||||
using Nest;
|
||||
using SJZY.Expand.ABP.Core.Logger;
|
||||
using SJZY.Expand.ElasticSearch.Services;
|
||||
@ -40,7 +39,7 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
// 按天写入es
|
||||
var r = await Context.IndexAsync(index, request => request
|
||||
.Index(index.IndexName)
|
||||
.Refresh(Refresh.True) // 可选:立即刷新索引使更改立即可见
|
||||
//.Refresh(Refresh.True) // 可选:立即刷新索引使更改立即可见
|
||||
);
|
||||
|
||||
if (!r.IsValid)
|
||||
@ -111,7 +110,28 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
return data?.Documents?.ToList();
|
||||
}
|
||||
|
||||
public async Task DeleteTrackAsync(int orderId, List<string> trackCodes)
|
||||
public async Task<TrackDetailsIndex?> GetLatestAsync(int orderId)
|
||||
{
|
||||
var data = await Context.SearchAsync<TrackDetailsIndex>(x => x
|
||||
.Source(s => s.Includes(fd => fd
|
||||
.Field(f => f.IsCompleted)
|
||||
.Field(f => f.TrackEnContent)
|
||||
.Field(f => f.TrackContent)
|
||||
.Field(f => f.TrackPlace)
|
||||
.Field(f => f.TrackTime)
|
||||
.Field(f => f.TrackTimeZone)
|
||||
))
|
||||
.Query(q =>
|
||||
q.Term(f => f.OrderId, orderId)
|
||||
)
|
||||
.Sort(s => s.Field(f => f.TrackTime, SortOrder.Descending))
|
||||
.Size(1)
|
||||
);
|
||||
|
||||
return data.Documents.FirstOrDefault();
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteTrackAsync(int orderId, List<string> trackCodes)
|
||||
{
|
||||
var r = await Context.DeleteByQueryAsync<TrackDetailsIndex>(x => x
|
||||
.Query(
|
||||
@ -123,6 +143,8 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
|
||||
if (!r.IsValid)
|
||||
throw new Exception($"轨迹数据删除失败,原因:{r.DebugInformation}");
|
||||
|
||||
return r.Deleted > 0;
|
||||
}
|
||||
|
||||
public async Task<(List<TrackDetailsIndex> list, long total)> GetListAsync(TrackDetailsQueryInput input)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user