feat:完成2025-12-1晚上讨论的
This commit is contained in:
parent
f26a27d9dd
commit
27fcd4192a
@ -136,14 +136,14 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
|
||||
serviceProviderCode,
|
||||
items.Cast<object>().ToList(),
|
||||
GlobalConst.TrackPushCompletedSubscribe,
|
||||
attach: asciiString);
|
||||
other: asciiString);
|
||||
|
||||
if (r.Code != GlobalConst.SuccessCode)
|
||||
{
|
||||
TrackPushFailedPublicTopic($"轨迹中台调用接口通失败,RequestId: {r.RequestId}; Msg: {r.Msg}", @event, r.RequestId,
|
||||
TrackPushFailedPublicTopic($"轨迹中台调用接口通失败,RequestId: {r.LogId}; Msg: {r.Msg}", @event, r.LogId,
|
||||
items.Cast<dynamic>().ToList());
|
||||
throw new BusinessException(
|
||||
message: $"requestId: {r.RequestId}; serviceProviderCode:{serviceProviderCode} Msg: {r.Msg}");
|
||||
message: $"requestId: {r.LogId}; serviceProviderCode:{serviceProviderCode} Msg: {r.Msg}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -364,14 +364,14 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
|
||||
serviceProviderCode,
|
||||
items.Cast<object>().ToList(),
|
||||
GlobalConst.TrackPushCompletedSubscribe,
|
||||
attach: asciiString);
|
||||
other: asciiString);
|
||||
|
||||
if (r.Code != GlobalConst.SuccessCode)
|
||||
{
|
||||
TrackPushFailedPublicTopic($"轨迹中台调用接口通失败,RequestId: {r.RequestId}; Msg: {r.Msg}", @event, r.RequestId,
|
||||
TrackPushFailedPublicTopic($"轨迹中台调用接口通失败,RequestId: {r.LogId}; Msg: {r.Msg}", @event, r.LogId,
|
||||
items.Cast<dynamic>().ToList());
|
||||
throw new BusinessException(
|
||||
message: $"requestId: {r.RequestId}; serviceProviderCode:{serviceProviderCode} Msg: {r.Msg}");
|
||||
message: $"requestId: {r.LogId}; serviceProviderCode:{serviceProviderCode} Msg: {r.Msg}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,11 @@ public class EditTrackPullPriorityInput
|
||||
/// </summary>
|
||||
public TrackOrderType OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号类型
|
||||
/// </summary>
|
||||
public TrackOrderNoType OrderNoType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 优先级
|
||||
/// </summary>
|
||||
|
||||
@ -86,13 +86,13 @@ public class WarningTaskService(
|
||||
upStreamCode: upStreamCode,
|
||||
serviceProviderCode: task.ServiceProviderCode,
|
||||
data: items,
|
||||
resSubscribeName: GlobalConst.TrackPushCompletedSubscribe,
|
||||
attach: Base64Helper.SerializeObject(task.OptionType));
|
||||
followName: GlobalConst.TrackPushCompletedSubscribe,
|
||||
other: Base64Helper.SerializeObject(task.OptionType));
|
||||
|
||||
if (r.Code != GlobalConst.SuccessCode)
|
||||
{
|
||||
var msg = $"接口通调用失败:BatchForwardThenPushToQueueAsync" +
|
||||
$"RequestId: {r.RequestId};AppCode:{task.AppCode};" +
|
||||
$"RequestId: {r.LogId};AppCode:{task.AppCode};" +
|
||||
$" serviceProviderCode:{task.ServiceProviderCode} Msg: {r.Msg}";
|
||||
|
||||
// 处理调用接口通失败,直接处于完结状态
|
||||
|
||||
@ -36,6 +36,11 @@ public class TrackPullTask : ApplicationServiceBase, ISingletonDependency
|
||||
using var serviceScope = _serviceScopeFactory.CreateScope();
|
||||
|
||||
var trackPullConfigRepository = serviceScope.ServiceProvider.GetRequiredService<ITrackPullConfigRepository>();
|
||||
// var configs = await trackPullConfigRepository.AsQueryable()
|
||||
// .LeftJoin<TrackPullPriorityEntity>((a, b) => a.Id == b.TrackPullConfigId)
|
||||
// .Where()
|
||||
|
||||
|
||||
var configs = await trackPullConfigRepository.GetListAsync(x => true, x => new TrackPullConfigVo
|
||||
{
|
||||
// todo:去读priority表,按照客户、订单类型、优先级拉
|
||||
|
||||
@ -121,9 +121,24 @@ public class TrackPullService(
|
||||
trackPullEntity.TrackTimeZoneName = paramsConfig.TrackTimeZoneName;
|
||||
}
|
||||
|
||||
var id = await trackPullConfigRepository.InsertReturnIdentityAsync(trackPullEntity);
|
||||
using (var ts = TransacationHelper.GetReadCommitted())
|
||||
{
|
||||
var id = await trackPullConfigRepository.InsertReturnIdentityAsync(trackPullEntity);
|
||||
|
||||
await trackPullCacheService.SetPullConfigAsync(id);
|
||||
// 新增拉取配置的时候默认加一条所有客户的拉取优先级,兜底,该记录无法被删除
|
||||
await trackPullConfigRepository.InsertPriorityAsync(new TrackPullPriorityEntity
|
||||
{
|
||||
TrackPullConfigId = id,
|
||||
Customer = GlobalConst.All,
|
||||
OrderType = TrackOrderType.小包,
|
||||
OrderNoType = TrackOrderNoType.跟踪单号,
|
||||
Priority = 999,
|
||||
PullInterval = 12 * 60 // 12小时
|
||||
});
|
||||
await trackPullCacheService.SetPullConfigAsync(id);
|
||||
|
||||
ts.Complete();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -166,6 +181,8 @@ public class TrackPullService(
|
||||
|
||||
await trackPullConfigRepository.SoftDeleteContentAsync(x => x.TrackPullConfigId == input.Id);
|
||||
|
||||
await trackPullConfigRepository.SoftDeletePriorityAsync(x => x.TrackPullConfigId == input.Id);
|
||||
|
||||
await trackPullCacheService.SetPullConfigAsync(input.Id!.Value);
|
||||
ts.Complete();
|
||||
}
|
||||
@ -307,7 +324,8 @@ public class TrackPullService(
|
||||
Expression<Func<TrackPullPriorityEntity, bool>> isPriorityAnyExp = x =>
|
||||
x.TrackPullConfigId == input.TrackPullConfigId &&
|
||||
x.Customer == input.Customer &&
|
||||
x.OrderType == input.OrderType;
|
||||
x.OrderType == input.OrderType &&
|
||||
x.OrderNoType == input.OrderNoType;
|
||||
|
||||
if (input.Options == OptionTypeNoNull.修改)
|
||||
{
|
||||
@ -346,9 +364,11 @@ public class TrackPullService(
|
||||
|
||||
case OptionTypeNoNull.删除:
|
||||
{
|
||||
_ = await trackPullConfigRepository.GetPriorityByIdAsync(input.Id!.Value) ??
|
||||
var priority = await trackPullConfigRepository.GetPriorityByIdAsync(input.Id!.Value) ??
|
||||
throw new BusinessException(message: "找不到数据");
|
||||
|
||||
if (priority.Customer == GlobalConst.All) throw new BusinessException(message: "兜底配置禁止被删除");
|
||||
|
||||
await trackPullConfigRepository.SoftDeletePriorityAsync(x => x.Id == input.Id);
|
||||
|
||||
break;
|
||||
|
||||
@ -20,9 +20,9 @@ public class InterfaceForwardService : ITransientDependency
|
||||
string upStreamCode,
|
||||
string serviceProviderCode,
|
||||
List<object> data,
|
||||
string resSubscribeName,
|
||||
string? attach = null,
|
||||
bool isReturnMessage = false)
|
||||
string followName,
|
||||
string? other = null,
|
||||
bool sourceData = false)
|
||||
{
|
||||
var client = _httpClientFactory.CreateClient("itfx");
|
||||
|
||||
@ -46,11 +46,11 @@ public class InterfaceForwardService : ITransientDependency
|
||||
|
||||
content.Headers.Add(nameof(InterfaceForwardOptions.AppKey), key);
|
||||
content.Headers.Add(nameof(InterfaceForwardOptions.AppSecret), secret);
|
||||
content.Headers.Add(nameof(resSubscribeName), resSubscribeName);
|
||||
content.Headers.Add(nameof(attach), attach);
|
||||
content.Headers.Add(nameof(isReturnMessage), isReturnMessage.ToString());
|
||||
content.Headers.Add(nameof(followName), followName);
|
||||
content.Headers.Add(nameof(other), other);
|
||||
content.Headers.Add(nameof(sourceData), sourceData.ToString());
|
||||
|
||||
using var response = await client.PostAsync($"InterfaceForward/BatchForwardThenPushToQueue?upStreamCode={upStreamCode}&serviceProvidercode={serviceProviderCode}", content);
|
||||
using var response = await client.PostAsync($"Itfx/ForwardWithSubscribe?standardCode={upStreamCode}&supplierCode={serviceProviderCode}", content);
|
||||
|
||||
var res = await response.Content.ReadAsStringAsync();
|
||||
if (!response.IsSuccessStatusCode)
|
||||
|
||||
@ -22,15 +22,15 @@ public class InterfaceRelayUnifyResultDto
|
||||
/// <summary>
|
||||
/// 请求Id
|
||||
/// </summary>
|
||||
public Guid RequestId { get; set; }
|
||||
public Guid LogId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 原报文
|
||||
/// </summary>
|
||||
public string? OriginalMessage { get; set; }
|
||||
public string? SourceData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 附加数据
|
||||
/// </summary>
|
||||
public string? Attach { get; set; }
|
||||
public string? Other { get; set; }
|
||||
}
|
||||
|
||||
@ -26,6 +26,12 @@ public class TrackPullPriorityEntity: FullAuditedEntity<int, int>
|
||||
[SugarColumn(ColumnName = "OrderType")]
|
||||
public TrackOrderType OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "OrderNoType")]
|
||||
public TrackOrderNoType OrderNoType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 优先级
|
||||
/// </summary>
|
||||
|
||||
@ -19,4 +19,6 @@ public partial class GlobalConst
|
||||
public static readonly DateTime MinDateTime = new DateTime(1900, 1, 1, 0, 0, 0);
|
||||
|
||||
public static readonly DateTime MaxDateTime = new DateTime(2999, 1, 1, 0, 0, 0);
|
||||
|
||||
public const string All = "*";
|
||||
}
|
||||
|
||||
@ -21,6 +21,21 @@ public class GetTrackPullPriorityDetailOutputVO
|
||||
/// </summary>
|
||||
public TrackOrderType OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
public string OrderTypeName => OrderType.ToString();
|
||||
|
||||
/// <summary>
|
||||
/// 订单号类型
|
||||
/// </summary>
|
||||
public TrackOrderNoType OrderNoType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号类型
|
||||
/// </summary>
|
||||
public string OrderNoTypeName => OrderNoType.ToString();
|
||||
|
||||
/// <summary>
|
||||
/// 优先级
|
||||
/// </summary>
|
||||
|
||||
@ -16,6 +16,21 @@ public class GetTrackPullPriorityPageOutputVO
|
||||
/// </summary>
|
||||
public TrackOrderType OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
public string OrderTypeName => OrderType.ToString();
|
||||
|
||||
/// <summary>
|
||||
/// 订单号类型
|
||||
/// </summary>
|
||||
public TrackOrderNoType OrderNoType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号类型
|
||||
/// </summary>
|
||||
public string OrderNoTypeName => OrderNoType.ToString();
|
||||
|
||||
/// <summary>
|
||||
/// 优先级
|
||||
/// </summary>
|
||||
|
||||
@ -16,4 +16,9 @@ public class TrackPullConfigVo
|
||||
/// 应用
|
||||
/// </summary>
|
||||
public string AppKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户
|
||||
/// </summary>
|
||||
public string Customer { get; set; }
|
||||
}
|
||||
|
||||
8
src/TrackCenter.Domain/Enums/TrackOrderNoType.cs
Normal file
8
src/TrackCenter.Domain/Enums/TrackOrderNoType.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace TrackCenter.Domain.Enums;
|
||||
|
||||
public enum TrackOrderNoType
|
||||
{
|
||||
客户单号 = 1,
|
||||
跟踪单号 = 2,
|
||||
其他单号 = 4
|
||||
}
|
||||
@ -149,6 +149,7 @@ public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>,
|
||||
Id = x.Id,
|
||||
Customer = x.Customer,
|
||||
OrderType = x.OrderType,
|
||||
OrderNoType = x.OrderNoType,
|
||||
Priority = x.Priority,
|
||||
PullInterval = x.PullInterval,
|
||||
CreateTime = x.CreateTime,
|
||||
@ -169,6 +170,7 @@ public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>,
|
||||
TrackPullConfigId = x.TrackPullConfigId,
|
||||
Customer = x.Customer,
|
||||
OrderType = x.OrderType,
|
||||
OrderNoType = x.OrderNoType,
|
||||
Priority = x.Priority,
|
||||
PullInterval = x.PullInterval
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user