解决冲突
This commit is contained in:
commit
d336c90e62
@ -7,15 +7,15 @@ public class GetPageTrackOrderInput : PageInfoInput
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int SubSystemId { get; set; }
|
public int SubSystemId { get; set; }
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 单号
|
|
||||||
///// </summary>
|
|
||||||
//public List<string>? OrderNos { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 单号
|
/// 单号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? OrderNos { get; set; }
|
public List<string>? OrderNos { get; set; }
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 单号
|
||||||
|
///// </summary>
|
||||||
|
//public string? OrderNos { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// tab标签类型 0 全部, 1 异常 2 预警
|
/// tab标签类型 0 全部, 1 异常 2 预警
|
||||||
@ -136,7 +136,7 @@ public class TrackOrderDto
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 子系统
|
/// 子系统
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string SubSystem { get; set; }
|
public string? SubSystem { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 子系统id
|
/// 子系统id
|
||||||
@ -153,13 +153,13 @@ public class TrackOrderDto
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? QuestionTypeName { get; set; }
|
public string? QuestionTypeName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
///// 问题描述(主数据枚举TrackProblemDescription)
|
||||||
/// </summary>
|
///// </summary>
|
||||||
public int ProblemDescription { get; set; }
|
//public int ProblemDescription { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 问题描述名称
|
///// 问题描述名称
|
||||||
/// </summary>
|
///// </summary>
|
||||||
public string? ProblemDescriptionName { get; set; }
|
//public string? ProblemDescriptionName { get; set; }
|
||||||
}
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
|
|
||||||
|
public class PushTrackInput : OrderNosInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹code,必填
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public string TrackCode { get; set; } = null!;
|
||||||
|
}
|
||||||
@ -0,0 +1,72 @@
|
|||||||
|
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
|
|
||||||
|
public class TrackPushConfigDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 是否自动推送
|
||||||
|
/// </summary>
|
||||||
|
public bool IsAutoPush { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹推送内容配置
|
||||||
|
/// </summary>
|
||||||
|
public List<TrackPushContentConfigDto> ContentConfigs { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TrackPushContentConfigDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 是否自动推送
|
||||||
|
/// </summary>
|
||||||
|
public bool IsAutoPush { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否支持更新
|
||||||
|
/// </summary>
|
||||||
|
public bool IsCanUpdate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 服务商code
|
||||||
|
/// </summary>
|
||||||
|
public string ServiceProviderCode { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 扩展字段参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? ExpandFieldsValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推送单号类型(主数据枚举TrackOrderType)
|
||||||
|
/// </summary>
|
||||||
|
public int OrderType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹代码参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackContentCodeValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容id
|
||||||
|
/// </summary>
|
||||||
|
public int TrackContentId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackContentValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容英文参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackEnContentValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹状态参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackStatusValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹时区GMT
|
||||||
|
/// </summary>
|
||||||
|
public double? TrackTimeZone { get; set; }
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
namespace SJZY.Track.Application.Contract.Dtos.TrackOrder;
|
||||||
|
|
||||||
|
public class GetTrackCounterOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 总条数
|
||||||
|
/// </summary>
|
||||||
|
public int TotalCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异常数
|
||||||
|
/// </summary>
|
||||||
|
public int ErrorCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 预警数
|
||||||
|
/// </summary>
|
||||||
|
public int WarnCount { get; set; }
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
namespace SJZY.Track.Application.Contract.Dtos.TrackOrder;
|
||||||
|
|
||||||
|
public class TrackPushRecordItem
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -1,8 +1,19 @@
|
|||||||
namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
|
namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||||
|
|
||||||
public class TrackPullConfigDto
|
public class TrackPullConfigDto
|
||||||
{
|
{
|
||||||
public TrackPullParamConfigDto ParamConfig { get; set; }
|
/// <summary>
|
||||||
|
/// 服务商拉取频率(分钟)
|
||||||
|
/// </summary>
|
||||||
|
public int PullInterval { get; set; }
|
||||||
|
|
||||||
public List<TrackPullContentConfigDto> ContentConfigs { get; set; }
|
/// <summary>
|
||||||
|
/// 服务商id
|
||||||
|
/// </summary>
|
||||||
|
public int ServiceProviderId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 子系统id
|
||||||
|
/// </summary>
|
||||||
|
public int SubSystemId { get; set; }
|
||||||
}
|
}
|
||||||
@ -10,32 +10,32 @@ public class TrackPullParamConfigDto
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 轨迹时区参数名
|
/// 轨迹时区参数名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string TrackTimeZoneName { get; set; } = null!;
|
public string? TrackTimeZoneName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 轨迹代码参数名
|
/// 轨迹代码参数名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string TrackContentCodeName { get; set; } = null!;
|
public string? TrackContentCodeName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 轨迹内容参数名
|
/// 轨迹内容参数名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string TrackContentName { get; set; } = null!;
|
public string? TrackContentName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 轨迹发生地参数名
|
/// 轨迹发生地参数名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string TrackPlaceName { get; set; } = null!;
|
public string? TrackPlaceName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 轨迹状态参数名
|
/// 轨迹状态参数名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string TrackStatusName { get; set; } = null!;
|
public string? TrackStatusName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 轨迹发生时间参数名
|
/// 轨迹发生时间参数名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string TrackTimeName { get; set; } = null!;
|
public string? TrackTimeName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 订单数组路径
|
/// 订单数组路径
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||||
|
|
||||||
|
public class TrackPullParamWithContentConfigDto
|
||||||
|
{
|
||||||
|
public TrackPullParamConfigDto ParamConfig { get; set; }
|
||||||
|
|
||||||
|
public List<TrackPullContentConfigDto> ContentConfigs { get; set; }
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
namespace SJZY.Track.Application.Contract.Events;
|
||||||
|
|
||||||
|
public class TrackPushAfterUpdateOrderEvent
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 操作类型
|
||||||
|
/// </summary>
|
||||||
|
public OptionType OptionType { get; set; } = OptionType.新增;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单Id
|
||||||
|
/// </summary>
|
||||||
|
public int OrderId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容id
|
||||||
|
/// </summary>
|
||||||
|
public int TrackContentId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 问题类型
|
||||||
|
/// </summary>
|
||||||
|
public bool IsSuccess { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 问题描述
|
||||||
|
/// </summary>
|
||||||
|
public string? Message { get; set; }
|
||||||
|
}
|
||||||
89
src/SJZY.Track.Application.Contract/Events/TrackPushEvent.cs
Normal file
89
src/SJZY.Track.Application.Contract/Events/TrackPushEvent.cs
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
namespace SJZY.Track.Application.Contract.Events;
|
||||||
|
|
||||||
|
public class TrackPushEvent
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 操作类型
|
||||||
|
/// </summary>
|
||||||
|
public OptionType OptionType { get; set; } = OptionType.新增;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 服务商code
|
||||||
|
/// </summary>
|
||||||
|
public string ServiceProviderCode { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单id
|
||||||
|
/// </summary>
|
||||||
|
public int OrderId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单号
|
||||||
|
/// </summary>
|
||||||
|
public string OrderNo { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容id
|
||||||
|
/// </summary>
|
||||||
|
public int TrackContentId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹状态
|
||||||
|
/// </summary>
|
||||||
|
public string TrackStatus { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容代码
|
||||||
|
/// </summary>
|
||||||
|
public string TrackCode { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容
|
||||||
|
/// </summary>
|
||||||
|
public string TrackContent { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹发生地
|
||||||
|
/// </summary>
|
||||||
|
public string TrackPlace { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹发生时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime TrackTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹发生时区
|
||||||
|
/// </summary>
|
||||||
|
public float TrackTimeZone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹代码参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackContentCodeValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackContentValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容英文参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackEnContentValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹状态参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackStatusValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 扩展字段参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? ExpandFieldsValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 操作人
|
||||||
|
/// </summary>
|
||||||
|
public string? OperationMan { get; set; }
|
||||||
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
namespace SJZY.Track.Application.Contract.Events;
|
namespace SJZY.Track.Application.Contract.Events;
|
||||||
|
|
||||||
public class UpdateOrderTrackEvent
|
public class TrackUpsertAfterUpdateOrderEvent
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 订单Id
|
/// 订单Id
|
||||||
@ -41,4 +41,9 @@ public class UpdateOrderTrackEvent
|
|||||||
/// 轨迹时区
|
/// 轨迹时区
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float TrackTimeZone { get; set; }
|
public float TrackTimeZone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹代码
|
||||||
|
/// </summary>
|
||||||
|
public string TrackCode { get; set; } = null!;
|
||||||
}
|
}
|
||||||
@ -9,6 +9,11 @@ public class TrackUpsertEvent : UpsertTrackInput
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int OrderId { get; set; }
|
public int OrderId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单是否完成
|
||||||
|
/// </summary>
|
||||||
|
public bool IsCompleted { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 客户id
|
/// 客户id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -20,9 +25,9 @@ public class TrackUpsertEvent : UpsertTrackInput
|
|||||||
public int SubSystemId { get; set; }
|
public int SubSystemId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 订单是否推送完成(异步维护)
|
/// 最新推送轨迹内容id(异步维护)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsPushCompleted { get; set; }
|
public int? LatestPushTrackContentId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上游子系统id
|
/// 上游子系统id
|
||||||
|
|||||||
@ -4,13 +4,22 @@ namespace SJZY.Track.Application.Contract.Services;
|
|||||||
|
|
||||||
public interface ITrackPullCacheService
|
public interface ITrackPullCacheService
|
||||||
{
|
{
|
||||||
|
string TrackPullKey(int subSystemId, int serviceProviderId);
|
||||||
|
string TrackPullContentKey(int subSystemId, int serviceProviderId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有拉取配置
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<TrackPullConfigDto>> GetAllPullConfigsAsync();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取服务商拉取配置
|
/// 获取服务商拉取配置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="subSystemId">子系统id</param>
|
/// <param name="subSystemId">子系统id</param>
|
||||||
/// <param name="serviceProviderId">服务商id</param>
|
/// <param name="serviceProviderId">服务商id</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<TrackPullConfigDto> GetPullConfigAsync(int subSystemId, int serviceProviderId);
|
Task<TrackPullParamWithContentConfigDto> GetPullParamWithContentConfigAsync(int subSystemId, int serviceProviderId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置拉取配置缓存
|
/// 设置拉取配置缓存
|
||||||
@ -19,5 +28,6 @@ public interface ITrackPullCacheService
|
|||||||
/// <param name="subSystemId">子系统id</param>
|
/// <param name="subSystemId">子系统id</param>
|
||||||
/// <param name="serviceProviderId">服务商id</param>
|
/// <param name="serviceProviderId">服务商id</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<TrackPullConfigDto> SetPullConfigAsync(int? id = null, int? subSystemId = null, int? serviceProviderId = null);
|
Task<TrackPullParamWithContentConfigDto> SetPullConfigAsync(int? id = null, int? subSystemId = null,
|
||||||
|
int? serviceProviderId = null);
|
||||||
}
|
}
|
||||||
@ -1,18 +1,42 @@
|
|||||||
namespace SJZY.Track.Application.Contract.Services;
|
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Application.Contract.Services;
|
||||||
|
|
||||||
public interface ITrackPushCacheService
|
public interface ITrackPushCacheService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 判断客户是否需要推送
|
/// 获取服务商拉取配置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="customId"></param>
|
/// <param name="subSystemId">子系统id</param>
|
||||||
|
/// <param name="customId">服务商id</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> IsPushAsync(int customId);
|
Task<List<TrackPushContentConfigDto>> GetPushContentConfigsAsync(int subSystemId, int customId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新缓存
|
/// 获取服务商拉取配置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="subSystemId">子系统id</param>
|
||||||
|
/// <param name="customId">服务商id</param>
|
||||||
|
/// <param name="trackContentId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<TrackPushContentConfigDto> GetPushContentConfigAsync(int subSystemId, int customId, int trackContentId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据轨迹代码推断下一个(升序)要推送的内容,如果找不到或者已经是最后一个了,返回null
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="subSystemId"></param>
|
||||||
/// <param name="customId"></param>
|
/// <param name="customId"></param>
|
||||||
/// <param name="isPush"></param>
|
/// <param name="trackContentId"></param>
|
||||||
Task UpdateAsync(int customId, bool isPush);
|
/// <returns></returns>
|
||||||
|
Task<TrackPushContentConfigDto?> InferNextPushContentOrNullAsync(int subSystemId, int customId,
|
||||||
|
int? trackContentId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置推送配置缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="subSystemId">子系统id</param>
|
||||||
|
/// <param name="customId">客户id</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<TrackPushConfigDto> SetPushContentConfigsAsync(int? id = null, int? subSystemId = null, int? customId = null);
|
||||||
}
|
}
|
||||||
@ -1,8 +1,13 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
using Google.Protobuf.WellKnownTypes;
|
||||||
|
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||||
using SJZY.Track.Domain.Dtos.Order;
|
using SJZY.Track.Domain.Dtos.Order;
|
||||||
|
using SJZY.Track.Domain.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Reflection;
|
||||||
using Volo.Abp.AutoMapper;
|
using Volo.Abp.AutoMapper;
|
||||||
|
|
||||||
namespace SJZY.Track.Application.AutoMapper;
|
namespace SJZY.Track.Application.AutoMapper;
|
||||||
@ -20,7 +25,10 @@ public class OrderAutoMapperProfile : Profile
|
|||||||
CreateMap<OrderFlightInfo, OrderFlightEntity>(MemberList.None);
|
CreateMap<OrderFlightInfo, OrderFlightEntity>(MemberList.None);
|
||||||
|
|
||||||
CreateMap<GetPageTrackOrderInput, GetPageTrackOrderInputVO>(MemberList.None);
|
CreateMap<GetPageTrackOrderInput, GetPageTrackOrderInputVO>(MemberList.None);
|
||||||
CreateMap<TrackOrderVO, TrackOrderDto>(MemberList.None);
|
CreateMap<TrackOrderVO, TrackOrderDto>(MemberList.None)
|
||||||
|
.ForMember(dest => dest.OrderTypeName, opt => opt.MapFrom(source => GetEnumDescription(2, source.OrderType)))
|
||||||
|
.ForMember(dest => dest.QuestionTypeName, opt => opt.MapFrom(source => GetEnumDescription(1, source.QuestionType)));
|
||||||
|
|
||||||
CreateMap<UnifyPageResultDto<TrackOrderVO>, UnifyPageResultDto<TrackOrderDto>>(MemberList.None);
|
CreateMap<UnifyPageResultDto<TrackOrderVO>, UnifyPageResultDto<TrackOrderDto>>(MemberList.None);
|
||||||
CreateMap<TrackDetailsIndex, TrackOrderDetailDto>(MemberList.None).Ignore(dest => dest.TrackTimeZone)
|
CreateMap<TrackDetailsIndex, TrackOrderDetailDto>(MemberList.None).Ignore(dest => dest.TrackTimeZone)
|
||||||
.ForMember(dest => dest.Id, opt => opt.Ignore())
|
.ForMember(dest => dest.Id, opt => opt.Ignore())
|
||||||
@ -29,4 +37,34 @@ public class OrderAutoMapperProfile : Profile
|
|||||||
.ForMember(dest => dest.EnContent, opt => opt.MapFrom(m => m.TrackEnContent))
|
.ForMember(dest => dest.EnContent, opt => opt.MapFrom(m => m.TrackEnContent))
|
||||||
.ForMember(dest => dest.TrackTimeZoneValue, opt => opt.MapFrom(m => m.TrackTimeZone));
|
.ForMember(dest => dest.TrackTimeZoneValue, opt => opt.MapFrom(m => m.TrackTimeZone));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通过类型int获取枚举描述
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="type">1 问题类型枚举 2 订单枚举</param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetEnumDescription(int type, int value)
|
||||||
|
{
|
||||||
|
string enumDescription = string.Empty;
|
||||||
|
if (type == 1)
|
||||||
|
{
|
||||||
|
TrackProblemType trackProblem = (TrackProblemType)value; // 将int值转换为枚举
|
||||||
|
if (trackProblem.GetDescription().IsNullOrWhiteSpace())
|
||||||
|
enumDescription = "";
|
||||||
|
else
|
||||||
|
enumDescription = trackProblem.GetDescription(); // 获取描述标记
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OrderType orderType = (OrderType)value; // 将int值转换为枚举
|
||||||
|
if (orderType.GetDescription().IsNullOrWhiteSpace())
|
||||||
|
enumDescription = "";
|
||||||
|
else
|
||||||
|
enumDescription = orderType.GetDescription(); // 获取描述标记
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return enumDescription;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
using SJZY.Track.Application.Contract.Dtos.TrackPush;
|
using SJZY.Track.Application.Contract.Dtos.TrackPush;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||||
@ -14,5 +15,7 @@ public class TrackPushAutoMapperProfile : Profile
|
|||||||
CreateMap<EditTrackPushConfigInput, TrackPushPullParamsConfigEntity>(MemberList.None).Ignore(dest => dest.Id)
|
CreateMap<EditTrackPushConfigInput, TrackPushPullParamsConfigEntity>(MemberList.None).Ignore(dest => dest.Id)
|
||||||
.ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => true));
|
.ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => true));
|
||||||
CreateMap<EditTrackPushContentInput, TrackPushContentConfigEntity>(MemberList.None);
|
CreateMap<EditTrackPushContentInput, TrackPushContentConfigEntity>(MemberList.None);
|
||||||
|
CreateMap<TrackPushContentConfigEntity, TrackPushContentConfigDto>(MemberList.None)
|
||||||
|
.ForMember(dest => dest.OrderType, opt => opt.MapFrom(source => source.OrderNoType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,6 +2,7 @@
|
|||||||
using SJZY.Track.Application.Contract.Events;
|
using SJZY.Track.Application.Contract.Events;
|
||||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||||
|
using SJZY.Track.Domain.Consts;
|
||||||
using Volo.Abp.DependencyInjection;
|
using Volo.Abp.DependencyInjection;
|
||||||
|
|
||||||
namespace SJZY.Track.Application.EventHandlers;
|
namespace SJZY.Track.Application.EventHandlers;
|
||||||
@ -31,7 +32,7 @@ public class OrderLinkAfterFillTrackHandler : ITransientDependency, ICapSubscrib
|
|||||||
var order = await _orderRepository.GetFirstAsync(x =>
|
var order = await _orderRepository.GetFirstAsync(x =>
|
||||||
x.Id == linkOrderId, x => new
|
x.Id == linkOrderId, x => new
|
||||||
{
|
{
|
||||||
x.OrderType, x.OrderNo, x.CustomId, x.IsPushCompleted, x.SubSystemId
|
x.OrderType, x.OrderNo, x.CustomId, x.LatestPushTrackContentId, x.SubSystemId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (order == default) continue;
|
if (order == default) continue;
|
||||||
@ -50,7 +51,7 @@ public class OrderLinkAfterFillTrackHandler : ITransientDependency, ICapSubscrib
|
|||||||
OrderId = linkOrderId,
|
OrderId = linkOrderId,
|
||||||
CustomId = order.CustomId,
|
CustomId = order.CustomId,
|
||||||
SubSystemId = order.SubSystemId,
|
SubSystemId = order.SubSystemId,
|
||||||
IsPushCompleted = order.IsPushCompleted,
|
LatestPushTrackContentId = order.LatestPushTrackContentId,
|
||||||
UpSubSystemId = @event.SubSystemId,
|
UpSubSystemId = @event.SubSystemId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using SJZY.Expand.ABP.Core.Logger;
|
|||||||
using SJZY.Track.Application.Contract.Events;
|
using SJZY.Track.Application.Contract.Events;
|
||||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||||
|
using SJZY.Track.Domain.Consts;
|
||||||
using SJZY.Track.Domain.Queries;
|
using SJZY.Track.Domain.Queries;
|
||||||
using Volo.Abp.DependencyInjection;
|
using Volo.Abp.DependencyInjection;
|
||||||
|
|
||||||
@ -63,12 +64,12 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
{
|
{
|
||||||
var track = await _trackDetailsRepository.GetLatestAsync(@event.OrderId);
|
var track = await _trackDetailsRepository.GetLatestAsync(@event.OrderId);
|
||||||
var updateOrderEvent = track == default
|
var updateOrderEvent = track == default
|
||||||
? new UpdateOrderTrackEvent
|
? new TrackUpsertAfterUpdateOrderEvent
|
||||||
{
|
{
|
||||||
OrderId = @event.OrderId,
|
OrderId = @event.OrderId,
|
||||||
IsDelete = true
|
IsDelete = true
|
||||||
}
|
}
|
||||||
: new UpdateOrderTrackEvent
|
: new TrackUpsertAfterUpdateOrderEvent
|
||||||
{
|
{
|
||||||
OrderId = @event.OrderId,
|
OrderId = @event.OrderId,
|
||||||
IsCompleted = track.IsCompleted,
|
IsCompleted = track.IsCompleted,
|
||||||
@ -76,9 +77,10 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
TrackEnContent = track.TrackEnContent,
|
TrackEnContent = track.TrackEnContent,
|
||||||
TrackPlace = track.TrackPlace,
|
TrackPlace = track.TrackPlace,
|
||||||
TrackTime = track.TrackTime,
|
TrackTime = track.TrackTime,
|
||||||
TrackTimeZone = track.TrackTimeZone
|
TrackTimeZone = track.TrackTimeZone,
|
||||||
|
IsDelete = true
|
||||||
};
|
};
|
||||||
await _capPublisher.PublishAsync(GlobalConst.UpdateOrderTrackSubscribe, updateOrderEvent);
|
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertAfterUpdateOrderSubscribe, updateOrderEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据订单关联关系异步向下刷
|
// 根据订单关联关系异步向下刷
|
||||||
|
|||||||
@ -0,0 +1,50 @@
|
|||||||
|
using DotNetCore.CAP;
|
||||||
|
using SJZY.Track.Application.Contract.Events;
|
||||||
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||||
|
using SJZY.Track.Domain.Consts;
|
||||||
|
using SJZY.Track.Domain.Enums;
|
||||||
|
using Volo.Abp.DependencyInjection;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Application.EventHandlers;
|
||||||
|
|
||||||
|
public class TrackPushAfterUpdateOrderEventHandler : ITransientDependency, ICapSubscribe
|
||||||
|
{
|
||||||
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
|
||||||
|
public TrackPushAfterUpdateOrderEventHandler(IOrderRepository orderRepository)
|
||||||
|
{
|
||||||
|
_orderRepository = orderRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CapSubscribe(GlobalConst.TrackPushAfterUpdateOrderSubscribe)]
|
||||||
|
public async Task ConsumerAsync(TrackPushAfterUpdateOrderEvent @event)
|
||||||
|
{
|
||||||
|
var order = await _orderRepository.GetFirstAsync(x => x.Id == @event.OrderId);
|
||||||
|
if (order == default) return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 异常:最近一条推送是失败
|
||||||
|
*/
|
||||||
|
if (!@event.IsSuccess)
|
||||||
|
{
|
||||||
|
order.QuestionType = (int)TrackProblemType.Error;
|
||||||
|
order.ProblemDescription = @event.Message;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
order.QuestionType = (int)TrackProblemType.None;
|
||||||
|
if (@event.OptionType == OptionType.新增)
|
||||||
|
{
|
||||||
|
// tips:只有新增会影响推送进度?
|
||||||
|
order.LatestPushTrackContentId = @event.TrackContentId;
|
||||||
|
order.LatestPushTime = DateTime.Now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
await _orderRepository.UpdateColumnAsync(order, x => new
|
||||||
|
{
|
||||||
|
x.LatestPushTrackContentId, x.QuestionType, x.ProblemDescription, x.LatestPushTime
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,139 @@
|
|||||||
|
using DotNetCore.CAP;
|
||||||
|
using SJZY.InterfaceRelay.Application.Contracts;
|
||||||
|
using SJZY.Track.Application.Contract.Events;
|
||||||
|
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||||
|
using SJZY.Track.Domain.Consts;
|
||||||
|
using Volo.Abp.DependencyInjection;
|
||||||
|
using Volo.Abp.Http.Client.DynamicProxying;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Application.EventHandlers;
|
||||||
|
|
||||||
|
public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
|
||||||
|
{
|
||||||
|
private readonly IHttpClientProxy<IInterfaceForwardServiceV2> _httpClientProxy;
|
||||||
|
private readonly ITrackPushRecordsRepository _trackPushRecordsRepository;
|
||||||
|
private readonly ICapPublisher _capPublisher;
|
||||||
|
|
||||||
|
public TrackPushEventHandler(IHttpClientProxy<IInterfaceForwardServiceV2> httpClientProxy,
|
||||||
|
ITrackPushRecordsRepository trackPushRecordsRepository, ICapPublisher capPublisher)
|
||||||
|
{
|
||||||
|
_httpClientProxy = httpClientProxy;
|
||||||
|
_trackPushRecordsRepository = trackPushRecordsRepository;
|
||||||
|
_capPublisher = capPublisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CapSubscribe(GlobalConst.TrackPushSubscribe)]
|
||||||
|
public async Task ConsumerAsync(TrackPushEvent @event)
|
||||||
|
{
|
||||||
|
InterfaceRelayUnifyResultDto res = null!;
|
||||||
|
switch (@event.OptionType)
|
||||||
|
{
|
||||||
|
case OptionType.无:
|
||||||
|
return;
|
||||||
|
case OptionType.新增:
|
||||||
|
res = await PushAddAsync(@event);
|
||||||
|
break;
|
||||||
|
case OptionType.删除:
|
||||||
|
break;
|
||||||
|
case OptionType.修改:
|
||||||
|
res = await PushUpdateAsync(@event);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
|
|
||||||
|
var isSuccess = res.Code == InterfaceRelayConst.SuccessCode;
|
||||||
|
|
||||||
|
// 写推送日志
|
||||||
|
await _trackPushRecordsRepository.AddAsync(new TrackPushRecordIndex
|
||||||
|
{
|
||||||
|
IndexName = $"{GlobalConst.TrackPushRecordsIndex}-{DateTime.Now:yyyy.MM.dd}",
|
||||||
|
RequestId = res.RequestId,
|
||||||
|
Message = res.Msg,
|
||||||
|
OptionType = @event.OptionType.ToString(),
|
||||||
|
TrackStatus = @event.TrackStatus,
|
||||||
|
TrackCode = @event.TrackCode,
|
||||||
|
TrackContent = @event.TrackContent,
|
||||||
|
TrackPlace = @event.TrackPlace,
|
||||||
|
TrackTime = @event.TrackTime,
|
||||||
|
TrackTimeZone = @event.TrackTimeZone,
|
||||||
|
TrackContentCodeValue = @event.TrackContentCodeValue,
|
||||||
|
TrackContentValue = @event.TrackContentValue,
|
||||||
|
TrackEnContentValue = @event.TrackEnContentValue,
|
||||||
|
TrackStatusValue = @event.TrackStatusValue,
|
||||||
|
ExpandFieldsValue = @event.ExpandFieldsValue,
|
||||||
|
IsSuccess = isSuccess,
|
||||||
|
CreateUser = @event.OperationMan ?? "系统",
|
||||||
|
CreateTime = DateTime.Now
|
||||||
|
});
|
||||||
|
|
||||||
|
// 更新订单主表(异步)
|
||||||
|
await _capPublisher.PublishAsync(GlobalConst.TrackPushAfterUpdateOrderSubscribe,
|
||||||
|
new TrackPushAfterUpdateOrderEvent
|
||||||
|
{
|
||||||
|
OptionType = @event.OptionType,
|
||||||
|
OrderId = @event.OrderId,
|
||||||
|
TrackContentId = @event.TrackContentId,
|
||||||
|
IsSuccess = isSuccess,
|
||||||
|
Message = res.Msg
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<InterfaceRelayUnifyResultDto> PushAddAsync(TrackPushEvent @event)
|
||||||
|
{
|
||||||
|
var data = new
|
||||||
|
{
|
||||||
|
orderNo = @event.OrderNo,
|
||||||
|
data = new[]
|
||||||
|
{
|
||||||
|
new
|
||||||
|
{
|
||||||
|
// 推真实的发生地和发生时间(时间是计算后的)
|
||||||
|
location = @event.TrackPlace,
|
||||||
|
date = @event.TrackTime,
|
||||||
|
timeZone = @event.TrackTimeZone,
|
||||||
|
description = @event.TrackEnContentValue,
|
||||||
|
description_cn = @event.TrackContentValue,
|
||||||
|
code = @event.TrackContentCodeValue,
|
||||||
|
status = @event.TrackStatusValue,
|
||||||
|
extra = @event.ExpandFieldsValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var res = await _httpClientProxy.Service.ForwardWithSubscribeAsync(InterfaceRelayConst.PushTrackInterfaceCode,
|
||||||
|
@event.ServiceProviderCode, data);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<InterfaceRelayUnifyResultDto> PushUpdateAsync(TrackPushEvent @event)
|
||||||
|
{
|
||||||
|
var data = new
|
||||||
|
{
|
||||||
|
orderNo = @event.OrderNo,
|
||||||
|
data = new[]
|
||||||
|
{
|
||||||
|
new
|
||||||
|
{
|
||||||
|
// 推真实的发生地和发生时间
|
||||||
|
location = @event.TrackPlace,
|
||||||
|
date = @event.TrackTime,
|
||||||
|
timeZone = @event.TrackTimeZone,
|
||||||
|
description = @event.TrackEnContentValue,
|
||||||
|
description_cn = @event.TrackContentValue,
|
||||||
|
code = @event.TrackContentCodeValue,
|
||||||
|
status = @event.TrackStatusValue,
|
||||||
|
extra = @event.ExpandFieldsValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var res = await _httpClientProxy.Service.ForwardWithSubscribeAsync(InterfaceRelayConst.TrackUpdateInterfaceCode,
|
||||||
|
@event.ServiceProviderCode, data);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,6 +9,7 @@ using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
|||||||
using SJZY.Track.Application.Contract.Events;
|
using SJZY.Track.Application.Contract.Events;
|
||||||
using SJZY.Track.Application.Contract.Services;
|
using SJZY.Track.Application.Contract.Services;
|
||||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||||
|
using SJZY.Track.Domain.Consts;
|
||||||
using SJZY.Track.Domain.Enums;
|
using SJZY.Track.Domain.Enums;
|
||||||
using Volo.Abp.DependencyInjection;
|
using Volo.Abp.DependencyInjection;
|
||||||
|
|
||||||
@ -28,15 +29,15 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
_trackPullCacheService = trackPullCacheService;
|
_trackPullCacheService = trackPullCacheService;
|
||||||
}
|
}
|
||||||
|
|
||||||
[CapSubscribe(GlobalConst.TrackRefreshSubscribe)]
|
[CapSubscribe(GlobalConst.TrackRefreshSubscribe, Group = GlobalConst.TrackRefreshSubscribe)]
|
||||||
public async Task ConsumerAsync(InterfaceRelayTrackRefreshEvent @event)
|
public async Task ConsumerAsync(InterfaceRelayForwardReplayEvent @event)
|
||||||
{
|
{
|
||||||
// tips:attach返回的是服务商id,必有
|
|
||||||
var attach = JsonConvert.DeserializeObject<TrackRefreshAttach>(@event.Attach);
|
var attach = JsonConvert.DeserializeObject<TrackRefreshAttach>(@event.Attach);
|
||||||
if (attach is null) return;
|
if (attach is null) return;
|
||||||
var config = await _trackPullCacheService.GetPullConfigAsync(attach.ServiceProviderId, attach.SubSystemId);
|
var config = await _trackPullCacheService.GetPullParamWithContentConfigAsync(attach.SubSystemId,
|
||||||
|
attach.ServiceProviderId);
|
||||||
|
|
||||||
var data = JObject.FromObject(@event.Data);
|
var data = JObject.Parse(@event.Data.ToString()!);
|
||||||
var orderToken = data[config.ParamConfig.OrderPath];
|
var orderToken = data[config.ParamConfig.OrderPath];
|
||||||
if (orderToken is JArray orderTokens)
|
if (orderToken is JArray orderTokens)
|
||||||
{
|
{
|
||||||
@ -51,16 +52,17 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task HandleOrderAsync(JToken orderToken, TrackPullConfigDto config, int orderType)
|
private async Task HandleOrderAsync(JToken orderToken, TrackPullParamWithContentConfigDto paramWithContentConfig,
|
||||||
|
int orderType)
|
||||||
{
|
{
|
||||||
var paramConfig = config.ParamConfig;
|
var paramConfig = paramWithContentConfig.ParamConfig;
|
||||||
var orderNo = orderToken[paramConfig.OrderNoName]?.Value<string>();
|
var orderNo = orderToken[paramConfig.OrderNoName]?.Value<string>();
|
||||||
if (orderNo.IsNullOrWhiteSpace()) return;
|
if (orderNo.IsNullOrWhiteSpace()) return;
|
||||||
|
|
||||||
var order = await _orderRepository.GetFirstAsync(x =>
|
var order = await _orderRepository.GetFirstAsync(x =>
|
||||||
x.OrderType == orderType && x.OrderNo == orderNo, x => new
|
x.OrderType == orderType && x.OrderNo == orderNo, x => new
|
||||||
{
|
{
|
||||||
x.Id, x.SubSystemId, x.IsPushCompleted, x.CustomId
|
x.Id, x.SubSystemId, x.LatestPushTrackContentId, x.CustomId
|
||||||
});
|
});
|
||||||
if (order == default) return;
|
if (order == default) return;
|
||||||
|
|
||||||
@ -70,7 +72,7 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
{
|
{
|
||||||
OrderId = order.Id,
|
OrderId = order.Id,
|
||||||
SubSystemId = order.SubSystemId,
|
SubSystemId = order.SubSystemId,
|
||||||
IsPushCompleted = order.IsPushCompleted,
|
LatestPushTrackContentId = order.LatestPushTrackContentId,
|
||||||
CustomId = order.CustomId,
|
CustomId = order.CustomId,
|
||||||
OrderType = orderType,
|
OrderType = orderType,
|
||||||
OrderNo = orderNo!,
|
OrderNo = orderNo!,
|
||||||
@ -80,48 +82,49 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
{
|
{
|
||||||
foreach (var item in trackTokens)
|
foreach (var item in trackTokens)
|
||||||
{
|
{
|
||||||
await HandleTrackAsync(item, config, trackUpsertEvent);
|
await HandleTrackAsync(item, paramWithContentConfig, trackUpsertEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (orderToken is JObject)
|
else if (orderToken is JObject)
|
||||||
{
|
{
|
||||||
await HandleTrackAsync(orderToken, config, trackUpsertEvent);
|
await HandleTrackAsync(orderToken, paramWithContentConfig, trackUpsertEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task HandleTrackAsync(JToken trackToken, TrackPullConfigDto config,
|
private async Task HandleTrackAsync(JToken trackToken, TrackPullParamWithContentConfigDto paramWithContentConfig,
|
||||||
TrackUpsertEvent @event)
|
TrackUpsertEvent @event)
|
||||||
{
|
{
|
||||||
var trackUpsertEvent = @event.DeepCopy();
|
var trackUpsertEvent = @event.DeepCopy();
|
||||||
var paramConfig = config.ParamConfig;
|
var paramConfig = paramWithContentConfig.ParamConfig;
|
||||||
var contentConfigs = config.ContentConfigs;
|
var contentConfigs = paramWithContentConfig.ContentConfigs;
|
||||||
TrackPullContentConfigDto? matchedContentConfig = null;
|
TrackPullContentConfigDto? matchedContentConfig = null;
|
||||||
|
|
||||||
// 1、匹配轨迹代码
|
// 1、匹配轨迹代码
|
||||||
|
if (paramConfig.TrackContentCodeName != null)
|
||||||
|
{
|
||||||
var trackCode = trackToken[paramConfig.TrackContentCodeName]?.Value<string>();
|
var trackCode = trackToken[paramConfig.TrackContentCodeName]?.Value<string>();
|
||||||
if (!trackCode.IsNullOrWhiteSpace())
|
if (!trackCode.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackContentCodeValue == trackCode);
|
matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackContentCodeValue == trackCode);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// 2、匹配轨迹状态
|
// 2、匹配轨迹状态
|
||||||
if (matchedContentConfig is null)
|
else if (paramConfig.TrackStatusName != null)
|
||||||
{
|
{
|
||||||
var trackStatus = trackToken[paramConfig.TrackStatusName]?.Value<string>();
|
var trackStatus = trackToken[paramConfig.TrackStatusName]?.Value<string>();
|
||||||
if (!trackStatus.IsNullOrWhiteSpace())
|
if (!trackStatus.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackStatusValue == trackCode);
|
matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackStatusValue == trackStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3、匹配轨迹内容
|
// 3、匹配轨迹内容
|
||||||
if (matchedContentConfig is null)
|
else if (paramConfig.TrackContentName != null)
|
||||||
{
|
{
|
||||||
var trackContent = trackToken[paramConfig.TrackContentName]?.Value<string>();
|
var trackContent = trackToken[paramConfig.TrackContentName]?.Value<string>();
|
||||||
if (!trackContent.IsNullOrWhiteSpace())
|
if (!trackContent.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
Debug.Assert(trackContent != null, nameof(trackContent) + " != null");
|
Debug.Assert(trackContent != null, nameof(trackContent) + " != null");
|
||||||
matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackContentValue == trackCode);
|
matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackContentValue == trackContent);
|
||||||
|
|
||||||
// 按关键字分析轨迹内容
|
// 按关键字分析轨迹内容
|
||||||
if (matchedContentConfig is null)
|
if (matchedContentConfig is null)
|
||||||
@ -155,7 +158,10 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
|
|
||||||
if (matchedContentConfig is null) return;
|
if (matchedContentConfig is null) return;
|
||||||
|
|
||||||
var trackPlace = trackToken[paramConfig.TrackPlaceName]?.Value<string>();
|
// 轨迹发生地
|
||||||
|
var trackPlace = paramConfig.TrackPlaceName == null
|
||||||
|
? null
|
||||||
|
: trackToken[paramConfig.TrackPlaceName]?.Value<string>();
|
||||||
if (trackPlace.IsNullOrWhiteSpace())
|
if (trackPlace.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
Expression<Func<OrderEntity, string?>> resultExpression =
|
Expression<Func<OrderEntity, string?>> resultExpression =
|
||||||
@ -173,12 +179,20 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
x.Id == trackUpsertEvent.OrderId, resultExpression);
|
x.Id == trackUpsertEvent.OrderId, resultExpression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 轨迹发生时间
|
||||||
|
var trackTime = paramConfig.TrackTimeName == null
|
||||||
|
? null
|
||||||
|
: trackToken[paramConfig.TrackTimeName]?.Value<DateTime>();
|
||||||
|
// 轨迹发生时区
|
||||||
|
var trackTimeZone = paramConfig.TrackTimeZoneName == null
|
||||||
|
? null
|
||||||
|
: trackToken[paramConfig.TrackTimeZoneName]?.Value<float>();
|
||||||
|
|
||||||
// 新增/更新轨迹
|
// 新增/更新轨迹
|
||||||
trackUpsertEvent.TrackCode = matchedContentConfig.TrackContentCode;
|
trackUpsertEvent.TrackCode = matchedContentConfig.TrackContentCode;
|
||||||
trackUpsertEvent.TrackPlace = trackPlace ?? "CN";
|
trackUpsertEvent.TrackPlace = trackPlace ?? "CN";
|
||||||
trackUpsertEvent.TrackTime = trackToken[paramConfig.TrackTimeName]?.Value<DateTime>() ?? DateTime.Now;
|
trackUpsertEvent.TrackTime = trackTime ?? DateTime.Now;
|
||||||
trackUpsertEvent.TrackTimeZone = trackToken[paramConfig.TrackTimeZoneName]?.Value<float>() ??
|
trackUpsertEvent.TrackTimeZone = trackTimeZone ?? matchedContentConfig.TrackTimeZoneValue ?? 8;
|
||||||
matchedContentConfig.TrackTimeZoneValue ?? 8;
|
|
||||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, trackUpsertEvent);
|
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, trackUpsertEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,21 +1,22 @@
|
|||||||
using DotNetCore.CAP;
|
using DotNetCore.CAP;
|
||||||
using SJZY.Track.Application.Contract.Events;
|
using SJZY.Track.Application.Contract.Events;
|
||||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||||
|
using SJZY.Track.Domain.Consts;
|
||||||
using Volo.Abp.DependencyInjection;
|
using Volo.Abp.DependencyInjection;
|
||||||
|
|
||||||
namespace SJZY.Track.Application.EventHandlers;
|
namespace SJZY.Track.Application.EventHandlers;
|
||||||
|
|
||||||
public class UpdateOrderTrackEventHandler : ITransientDependency, ICapSubscribe
|
public class TrackUpsertAfterUpdateOrderEventHandler : ITransientDependency, ICapSubscribe
|
||||||
{
|
{
|
||||||
private readonly IOrderRepository _orderRepository;
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
|
||||||
public UpdateOrderTrackEventHandler(IOrderRepository orderRepository)
|
public TrackUpsertAfterUpdateOrderEventHandler(IOrderRepository orderRepository)
|
||||||
{
|
{
|
||||||
_orderRepository = orderRepository;
|
_orderRepository = orderRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
[CapSubscribe(GlobalConst.UpdateOrderTrackSubscribe)]
|
[CapSubscribe(GlobalConst.TrackUpsertAfterUpdateOrderSubscribe)]
|
||||||
public async Task ConsumerAsync(UpdateOrderTrackEvent @event)
|
public async Task ConsumerAsync(TrackUpsertAfterUpdateOrderEvent @event)
|
||||||
{
|
{
|
||||||
var order = await _orderRepository.GetFirstAsync(x => x.Id == @event.OrderId);
|
var order = await _orderRepository.GetFirstAsync(x => x.Id == @event.OrderId);
|
||||||
if (order == default) return;
|
if (order == default) return;
|
||||||
@ -25,18 +26,32 @@ public class UpdateOrderTrackEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
if (@event.TrackTime == default)
|
if (@event.TrackTime == default)
|
||||||
{
|
{
|
||||||
if (order.LatestTrackTime == null) return;
|
if (order.LatestTrackTime == null) return;
|
||||||
|
|
||||||
// 删除全部轨迹导致的重置行为
|
// 删除全部轨迹导致的重置行为
|
||||||
|
// tips:订单是支持从已完成态到未完成态的
|
||||||
order.ResetTrackInfo();
|
order.ResetTrackInfo();
|
||||||
|
|
||||||
|
await _orderRepository.UpdateAsync(order);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除引发的回退更新
|
||||||
|
if (order.LatestTrackTime != null &&
|
||||||
|
@event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone)) ==
|
||||||
|
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)))
|
||||||
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (order.LatestTrackTime != null &&
|
|
||||||
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) ==
|
|
||||||
@event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone))) return;
|
|
||||||
}
|
}
|
||||||
else // upsert引发的更新
|
else // upsert引发的更新
|
||||||
{
|
{
|
||||||
if (order.LatestTrackTime != null &&
|
if (order.LatestTrackTime != null &&
|
||||||
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) >
|
@event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone)) <
|
||||||
@event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone))) return;
|
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
order.IsCompleted = @event.IsCompleted;
|
order.IsCompleted = @event.IsCompleted;
|
||||||
@ -1,10 +1,13 @@
|
|||||||
using DotNetCore.CAP;
|
using System.Diagnostics;
|
||||||
|
using DotNetCore.CAP;
|
||||||
using SJZY.Expand.ABP.Core.Logger;
|
using SJZY.Expand.ABP.Core.Logger;
|
||||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||||
|
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
using SJZY.Track.Application.Contract.Events;
|
using SJZY.Track.Application.Contract.Events;
|
||||||
using SJZY.Track.Application.Contract.Services;
|
using SJZY.Track.Application.Contract.Services;
|
||||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||||
|
using SJZY.Track.Domain.Consts;
|
||||||
using SJZY.Track.Domain.Queries;
|
using SJZY.Track.Domain.Queries;
|
||||||
using SJZY.UserCenter.HttpApi.Services;
|
using SJZY.UserCenter.HttpApi.Services;
|
||||||
using Volo.Abp.DependencyInjection;
|
using Volo.Abp.DependencyInjection;
|
||||||
@ -57,15 +60,52 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
@event.TrackCode = mapCode;
|
@event.TrackCode = mapCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
await UpsertTrackAsync(@event);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task UpsertTrackAsync(TrackUpsertEvent @event)
|
|
||||||
{
|
|
||||||
// 不存在则新增轨迹,存在则更新
|
|
||||||
var track = await _trackDetailsRepository.GetFirstOrDefaultAsync(@event.OrderId, @event.TrackCode);
|
var track = await _trackDetailsRepository.GetFirstOrDefaultAsync(@event.OrderId, @event.TrackCode);
|
||||||
|
|
||||||
var orderIsCompleted = false;
|
// step1、upsert es轨迹
|
||||||
|
await UpsertTrackAsync(track, @event);
|
||||||
|
Debug.Assert(track != null, nameof(track) + " != null");
|
||||||
|
|
||||||
|
// step2、触发轨迹推送事件(异步)
|
||||||
|
await HandleTrackPushAsync(@event, track);
|
||||||
|
|
||||||
|
// step3、触发订单主表更新事件(异步)
|
||||||
|
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertAfterUpdateOrderSubscribe,
|
||||||
|
new TrackUpsertAfterUpdateOrderEvent
|
||||||
|
{
|
||||||
|
OrderId = track.OrderId,
|
||||||
|
IsCompleted = track.IsCompleted,
|
||||||
|
TrackCode = track.TrackCode,
|
||||||
|
TrackContent = track.TrackContent,
|
||||||
|
TrackEnContent = track.TrackEnContent,
|
||||||
|
TrackPlace = track.TrackPlace,
|
||||||
|
TrackTime = track.TrackTime,
|
||||||
|
TrackTimeZone = track.TrackTimeZone
|
||||||
|
});
|
||||||
|
|
||||||
|
// step4、根据订单关联关系异步向下刷(异步)
|
||||||
|
var linkedOrders = await _orderRepository.GetLinkedOrdersAsync(@event.OrderId);
|
||||||
|
foreach (var linkedOrder in linkedOrders)
|
||||||
|
{
|
||||||
|
var nextEvent = @event.DeepCopy();
|
||||||
|
nextEvent.OrderId = linkedOrder.OrderId;
|
||||||
|
nextEvent.OrderType = linkedOrder.OrderType;
|
||||||
|
nextEvent.OrderNo = linkedOrder.OrderNo;
|
||||||
|
nextEvent.SubSystemId = linkedOrder.SubSystemId;
|
||||||
|
nextEvent.LatestPushTrackContentId = linkedOrder.LatestPushTrackContentId;
|
||||||
|
nextEvent.CustomId = linkedOrder.CustomId;
|
||||||
|
nextEvent.UpSubSystemId = @event.SubSystemId;
|
||||||
|
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, nextEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 不存在则新增轨迹,存在则更新
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="track"></param>
|
||||||
|
/// <param name="event"></param>
|
||||||
|
private async Task UpsertTrackAsync(TrackDetailsIndex? track, TrackUpsertEvent @event)
|
||||||
|
{
|
||||||
if (track == default)
|
if (track == default)
|
||||||
{
|
{
|
||||||
//todo:可以优化
|
//todo:可以优化
|
||||||
@ -73,12 +113,10 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
var trackContent = await _provideQueries.MatchTrackContentAsync(@event.OrderId, @event.TrackCode);
|
var trackContent = await _provideQueries.MatchTrackContentAsync(@event.OrderId, @event.TrackCode);
|
||||||
if (trackContent == default)
|
if (trackContent == default)
|
||||||
{
|
{
|
||||||
//throw new BusinessException(message: $"订单:{@event.OrderNo} 所绑定的模板,没有一条内容可以匹配轨迹代码:{@event.TrackCode}");
|
// 订单所绑定的模板,没有一条内容可以匹配发生的轨迹
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
orderIsCompleted = trackContent.IsCompleted;
|
|
||||||
|
|
||||||
track = new TrackDetailsIndex
|
track = new TrackDetailsIndex
|
||||||
{
|
{
|
||||||
IndexName = $"{GlobalConst.TrackIndex}-{DateTime.Now:yyyy.MM.dd}",
|
IndexName = $"{GlobalConst.TrackIndex}-{DateTime.Now:yyyy.MM.dd}",
|
||||||
@ -88,7 +126,8 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
TrackStatus = trackContent.Status,
|
TrackStatus = trackContent.Status,
|
||||||
TrackCode = @event.TrackCode,
|
TrackCode = @event.TrackCode,
|
||||||
TrackContent = trackContent.Content,
|
TrackContent = trackContent.Content,
|
||||||
IsCompleted = orderIsCompleted,
|
TrackContentId = trackContent.Id,
|
||||||
|
IsCompleted = trackContent.IsCompleted,
|
||||||
TrackEnContent = trackContent.EnContent,
|
TrackEnContent = trackContent.EnContent,
|
||||||
TrackPlace = @event.TrackPlace,
|
TrackPlace = @event.TrackPlace,
|
||||||
TrackTime = @event.TrackTime!.Value,
|
TrackTime = @event.TrackTime!.Value,
|
||||||
@ -97,12 +136,6 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
CreateUser = CurrentUserRequest.CurrentUser.Name,
|
CreateUser = CurrentUserRequest.CurrentUser.Name,
|
||||||
CreateTime = DateTime.Now
|
CreateTime = DateTime.Now
|
||||||
};
|
};
|
||||||
|
|
||||||
// todo:推送只做新增的,更新和删除的不做先
|
|
||||||
if (!@event.IsPushCompleted && await _trackPushCacheService.IsPushAsync(@event.CustomId))
|
|
||||||
{
|
|
||||||
//await PushTrack();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -114,32 +147,59 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
}
|
}
|
||||||
|
|
||||||
await _trackDetailsRepository.UpsertAsync(track);
|
await _trackDetailsRepository.UpsertAsync(track);
|
||||||
|
|
||||||
// 触发订单主表更新事件
|
|
||||||
await _capPublisher.PublishAsync(GlobalConst.UpdateOrderTrackSubscribe, new UpdateOrderTrackEvent
|
|
||||||
{
|
|
||||||
OrderId = track.OrderId,
|
|
||||||
IsCompleted = orderIsCompleted,
|
|
||||||
TrackContent = track.TrackContent,
|
|
||||||
TrackEnContent = track.TrackEnContent,
|
|
||||||
TrackPlace = track.TrackPlace,
|
|
||||||
TrackTime = track.TrackTime,
|
|
||||||
TrackTimeZone = track.TrackTimeZone
|
|
||||||
});
|
|
||||||
|
|
||||||
// 根据订单关联关系异步向下刷
|
|
||||||
var linkedOrders = await _orderRepository.GetLinkedOrdersAsync(@event.OrderId);
|
|
||||||
foreach (var linkedOrder in linkedOrders)
|
|
||||||
{
|
|
||||||
var nextEvent = @event.DeepCopy();
|
|
||||||
nextEvent.OrderId = linkedOrder.OrderId;
|
|
||||||
nextEvent.OrderType = linkedOrder.OrderType;
|
|
||||||
nextEvent.OrderNo = linkedOrder.OrderNo;
|
|
||||||
nextEvent.SubSystemId = linkedOrder.SubSystemId;
|
|
||||||
nextEvent.IsPushCompleted = linkedOrder.IsPushCompleted;
|
|
||||||
nextEvent.CustomId = linkedOrder.CustomId;
|
|
||||||
nextEvent.UpSubSystemId = @event.SubSystemId;
|
|
||||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, nextEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理轨迹自动推送
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="event"></param>
|
||||||
|
/// <param name="track"></param>
|
||||||
|
private async Task HandleTrackPushAsync(TrackUpsertEvent @event, TrackDetailsIndex track)
|
||||||
|
{
|
||||||
|
TrackPushContentConfigDto? config;
|
||||||
|
OptionType optionType = OptionType.修改;
|
||||||
|
// 推送更新
|
||||||
|
if (!track.Id.IsNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
config = await _trackPushCacheService.GetPushContentConfigAsync(
|
||||||
|
@event.SubSystemId, @event.CustomId, track.TrackContentId);
|
||||||
|
if (!config.IsCanUpdate) return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 推送新增,需要根据上一次的推送 推断 本次推送 是否可行
|
||||||
|
config = await _trackPushCacheService.InferNextPushContentOrNullAsync(
|
||||||
|
@event.SubSystemId, @event.CustomId, @event.LatestPushTrackContentId);
|
||||||
|
|
||||||
|
if (config == null || !config.IsAutoPush) return;
|
||||||
|
|
||||||
|
// 当前发生的轨迹就是要推送的
|
||||||
|
if (config.TrackContentId != track.TrackContentId) return;
|
||||||
|
|
||||||
|
optionType = OptionType.新增;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.OrderType != @event.OrderType) return;
|
||||||
|
|
||||||
|
var trackPushEvent = new TrackPushEvent
|
||||||
|
{
|
||||||
|
OptionType = optionType,
|
||||||
|
ServiceProviderCode = config.ServiceProviderCode,
|
||||||
|
OrderNo = track.OrderNo,
|
||||||
|
TrackContentId = config.TrackContentId,
|
||||||
|
TrackStatus = track.TrackStatus,
|
||||||
|
TrackCode = track.TrackCode,
|
||||||
|
TrackContent = track.TrackContent,
|
||||||
|
TrackPlace = track.TrackPlace,
|
||||||
|
TrackTime = track.TrackTime.AddHours(config.TrackTimeZone ?? track.TrackTimeZone - track.TrackTimeZone),
|
||||||
|
TrackTimeZone = (float)(config.TrackTimeZone ?? track.TrackTimeZone),
|
||||||
|
TrackContentCodeValue = config.TrackContentCodeValue,
|
||||||
|
TrackContentValue = config.TrackContentValue,
|
||||||
|
TrackEnContentValue = config.TrackEnContentValue,
|
||||||
|
TrackStatusValue = config.TrackStatusValue,
|
||||||
|
ExpandFieldsValue = config.ExpandFieldsValue
|
||||||
|
};
|
||||||
|
|
||||||
|
await _capPublisher.PublishAsync(GlobalConst.TrackPushSubscribe, trackPushEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8,7 +8,11 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="SJZY.InterfaceRelay.Application.Contracts" Version="7.1.4"/>
|
<None Include="..\..\.editorconfig" Link=".editorconfig" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="SJZY.InterfaceRelay.Application.Contracts" Version="7.1.6" />
|
||||||
<PackageReference Include="Volo.Abp.Http.Client" Version="7.0.2" />
|
<PackageReference Include="Volo.Abp.Http.Client" Version="7.0.2" />
|
||||||
<PackageReference Include="Volo.Abp.FluentValidation" Version="7.0.2" />
|
<PackageReference Include="Volo.Abp.FluentValidation" Version="7.0.2" />
|
||||||
<PackageReference Include="SJZY.UserCenter.HttpApi" Version="3.0.3-alpha8" />
|
<PackageReference Include="SJZY.UserCenter.HttpApi" Version="3.0.3-alpha8" />
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
using SJZY.Track.Application.Contract.Events;
|
using SJZY.Track.Application.Contract.Events;
|
||||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||||
|
using SJZY.Track.Domain.Consts;
|
||||||
using SJZY.Track.Domain.Queries;
|
using SJZY.Track.Domain.Queries;
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||||
|
|||||||
@ -0,0 +1,111 @@
|
|||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using SJZY.Expand.ABP.Core;
|
||||||
|
using SJZY.InterfaceRelay.Application.Contracts;
|
||||||
|
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
|
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||||
|
using SJZY.Track.Application.Contract.Services;
|
||||||
|
using SJZY.Track.Domain.Consts;
|
||||||
|
using SJZY.Track.Domain.Queries;
|
||||||
|
using Volo.Abp.Http.Client.DynamicProxying;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹刷新服务
|
||||||
|
/// </summary>
|
||||||
|
[ApiExplorerSettings(GroupName = "提供接口")]
|
||||||
|
[Route("/ProviderService")]
|
||||||
|
public class TrackPullService : ApplicationService
|
||||||
|
{
|
||||||
|
private readonly IProvideQueries _provideQueries;
|
||||||
|
private readonly IHttpClientProxy<IInterfaceForwardServiceV2> _httpClientProxy;
|
||||||
|
private readonly ITrackPullCacheService _trackPullCacheService;
|
||||||
|
|
||||||
|
public TrackPullService(IProvideQueries provideQueries,
|
||||||
|
IHttpClientProxy<IInterfaceForwardServiceV2> httpClientProxy,
|
||||||
|
ITrackPullCacheService trackPullCacheService)
|
||||||
|
{
|
||||||
|
_provideQueries = provideQueries;
|
||||||
|
_httpClientProxy = httpClientProxy;
|
||||||
|
_trackPullCacheService = trackPullCacheService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 手动刷新轨迹
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("Track/Refresh")]
|
||||||
|
public async Task<bool> RefreshTrackAsync(RefreshTrackInput input)
|
||||||
|
{
|
||||||
|
// todo:罚时?
|
||||||
|
input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空
|
||||||
|
|
||||||
|
// tips:这里没有区分订单类型,就算的不同类型的单一起刷新了也无所谓
|
||||||
|
var orders = await _provideQueries.FindOrderWithServiceProviderAsync(input.OrderNos);
|
||||||
|
|
||||||
|
if (orders.Count == 0)
|
||||||
|
{
|
||||||
|
// tips:可能是没有配置、或者所有单都刷完了、或者单不存在
|
||||||
|
throw new BusinessException(message: "一个能更新的都没有");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var group in orders.GroupBy(x =>
|
||||||
|
new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId, x.OrderType)))
|
||||||
|
{
|
||||||
|
var data = group.Select(x => new
|
||||||
|
{
|
||||||
|
x.OrderNo
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
// 批量获取轨迹
|
||||||
|
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
|
||||||
|
"A012", group.Key.ServiceProviderCode, data,
|
||||||
|
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 定时任务刷新轨迹
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[AllowAnonymous]
|
||||||
|
[HttpPost("Track/RefreshForTask")]
|
||||||
|
public async Task<bool> RefreshForTaskAsync()
|
||||||
|
{
|
||||||
|
var configs = await _trackPullCacheService.GetAllPullConfigsAsync();
|
||||||
|
foreach (var config in configs)
|
||||||
|
{
|
||||||
|
var redisKey = _trackPullCacheService.TrackPullKey(config.SubSystemId, config.ServiceProviderId);
|
||||||
|
if (await RedisHelper.Client.ExistsAsync(redisKey))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var orders = await _provideQueries.FindOrderWithServiceProviderAsync(config.ServiceProviderId);
|
||||||
|
|
||||||
|
foreach (var group in orders.GroupBy(x =>
|
||||||
|
new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId,
|
||||||
|
x.OrderType)))
|
||||||
|
{
|
||||||
|
var data = group.Select(x => new
|
||||||
|
{
|
||||||
|
x.OrderNo
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
// 批量获取轨迹
|
||||||
|
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
|
||||||
|
InterfaceRelayConst.GetTrackInterfaceCode, group.Key.ServiceProviderCode, data,
|
||||||
|
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
|
||||||
|
}
|
||||||
|
|
||||||
|
await RedisHelper.Client.SetExAsync(redisKey, config.PullInterval * 60, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,60 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using SJZY.InterfaceRelay.Application.Contracts;
|
|
||||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
|
||||||
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
|
||||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
|
||||||
using Volo.Abp.Http.Client.DynamicProxying;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 轨迹推送、拉取服务
|
|
||||||
/// </summary>
|
|
||||||
[ApiExplorerSettings(GroupName = "提供接口")]
|
|
||||||
[Route("/ProviderService")]
|
|
||||||
public class TrackPushPullService : ApplicationService
|
|
||||||
{
|
|
||||||
private readonly IOrderRepository _orderRepository;
|
|
||||||
private readonly IHttpClientProxy<IInterfaceForwardServiceV2> _httpClientProxy;
|
|
||||||
|
|
||||||
public TrackPushPullService(IOrderRepository orderRepository,
|
|
||||||
IHttpClientProxy<IInterfaceForwardServiceV2> httpClientProxy)
|
|
||||||
{
|
|
||||||
_orderRepository = orderRepository;
|
|
||||||
_httpClientProxy = httpClientProxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 刷新轨迹
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("Track/Refresh")]
|
|
||||||
public async Task<bool> RefreshTrackAsync(RefreshTrackInput input)
|
|
||||||
{
|
|
||||||
if (input.OrderNos.Count == 0)
|
|
||||||
{
|
|
||||||
throw new BusinessException(message: "订单号数组不能为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
input.OrderNos = input.OrderNos.Distinct().ToList();
|
|
||||||
|
|
||||||
var orderTemplates = await _orderRepository.GetOrderTemplatesAsync(input.OrderNos);
|
|
||||||
|
|
||||||
foreach (var group in orderTemplates.GroupBy(x =>
|
|
||||||
new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId, x.OrderType)))
|
|
||||||
{
|
|
||||||
var data = group.Select(x => new
|
|
||||||
{
|
|
||||||
x.OrderNo
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
// 批量获取轨迹
|
|
||||||
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
|
|
||||||
"A012", group.Key.ServiceProviderCode, data,
|
|
||||||
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,123 @@
|
|||||||
|
using DotNetCore.CAP;
|
||||||
|
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
|
using SJZY.Track.Application.Contract.Events;
|
||||||
|
using SJZY.Track.Application.Contract.Services;
|
||||||
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||||
|
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||||
|
using SJZY.Track.Domain.Consts;
|
||||||
|
using SJZY.Track.Domain.Enums;
|
||||||
|
using SJZY.UserCenter.HttpApi.Services;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹推送服务
|
||||||
|
/// </summary>
|
||||||
|
[ApiExplorerSettings(GroupName = "提供接口")]
|
||||||
|
[Route("/ProviderService")]
|
||||||
|
public class TrackPushService : ApplicationService
|
||||||
|
{
|
||||||
|
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||||
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
private readonly ITrackPushCacheService _pushCacheService;
|
||||||
|
private readonly ICapPublisher _capPublisher;
|
||||||
|
|
||||||
|
public TrackPushService(ITrackPushCacheService pushCacheService,
|
||||||
|
ITrackDetailsRepository trackDetailsRepository
|
||||||
|
, IOrderRepository orderRepository
|
||||||
|
, ICapPublisher capPublisher)
|
||||||
|
{
|
||||||
|
_pushCacheService = pushCacheService;
|
||||||
|
_trackDetailsRepository = trackDetailsRepository;
|
||||||
|
_orderRepository = orderRepository;
|
||||||
|
_capPublisher = capPublisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 手工推送轨迹
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("Track/Push")]
|
||||||
|
public async Task<string> PushTrackAsync(PushTrackInput input)
|
||||||
|
{
|
||||||
|
input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空
|
||||||
|
|
||||||
|
var orders = await _orderRepository.GetListAsync(x =>
|
||||||
|
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo), x => new
|
||||||
|
{
|
||||||
|
x.Id, x.OrderNo, x.SubSystemId, x.CustomId
|
||||||
|
});
|
||||||
|
|
||||||
|
if (orders.Count == 0)
|
||||||
|
{
|
||||||
|
throw new BusinessException(message: "一个推送配置都不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
var tracks = await _trackDetailsRepository.GetListAsync(input.OrderType, input.OrderNos, input.TrackCode);
|
||||||
|
|
||||||
|
if (tracks.Count == 0)
|
||||||
|
{
|
||||||
|
throw new BusinessException(message: "一个能推的轨迹都不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
var res = 0;
|
||||||
|
|
||||||
|
foreach (var order in orders)
|
||||||
|
{
|
||||||
|
// 如果没有轨迹,就不需要推
|
||||||
|
var track = tracks.FirstOrDefault(x => x.OrderId == order.Id);
|
||||||
|
if (track == null) continue;
|
||||||
|
|
||||||
|
// 手工推送不推断,直接无脑推
|
||||||
|
var config =
|
||||||
|
await _pushCacheService.GetPushContentConfigAsync(order.SubSystemId, order.CustomId,
|
||||||
|
track.TrackContentId);
|
||||||
|
|
||||||
|
var trackPushEvent = new TrackPushEvent
|
||||||
|
{
|
||||||
|
ServiceProviderCode = config.ServiceProviderCode,
|
||||||
|
OrderNo = order.OrderNo,
|
||||||
|
TrackContentId = config.TrackContentId,
|
||||||
|
TrackStatus = track.TrackStatus,
|
||||||
|
TrackCode = track.TrackCode,
|
||||||
|
TrackContent = track.TrackContent,
|
||||||
|
TrackPlace = track.TrackPlace,
|
||||||
|
TrackTime = track.TrackTime.AddHours(config.TrackTimeZone ??
|
||||||
|
track.TrackTimeZone - track.TrackTimeZone),
|
||||||
|
TrackTimeZone = (float)(config.TrackTimeZone ?? track.TrackTimeZone),
|
||||||
|
TrackContentCodeValue = config.TrackContentCodeValue,
|
||||||
|
TrackContentValue = config.TrackContentValue,
|
||||||
|
TrackEnContentValue = config.TrackEnContentValue,
|
||||||
|
TrackStatusValue = config.TrackStatusValue,
|
||||||
|
ExpandFieldsValue = config.ExpandFieldsValue,
|
||||||
|
OperationMan = CurrentUserRequest.CurrentUser.Name,
|
||||||
|
};
|
||||||
|
|
||||||
|
await _capPublisher.PublishAsync(GlobalConst.TrackPushSubscribe, trackPushEvent);
|
||||||
|
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $"即将推送轨迹代码{input.TrackCode}给{res}个订单";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 定时任务推送预警(》12小时没有推送的)
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("Track/PushWarnForTask")]
|
||||||
|
public async Task<string> PushWarnForTaskAsync()
|
||||||
|
{
|
||||||
|
var time = DateTime.Now.Subtract(TimeSpan.FromHours(12));
|
||||||
|
var orders = await _orderRepository.GetListAsync(x =>
|
||||||
|
!x.IsCompleted && x.QuestionType == 0 && x.LatestPushTime < time);
|
||||||
|
|
||||||
|
orders.ForEach(x => { x.QuestionType = (int)TrackProblemType.Warn; });
|
||||||
|
|
||||||
|
await _orderRepository.UpdateRangeAsync(orders, x => new { x.QuestionType });
|
||||||
|
|
||||||
|
return $"成功将{orders.Select(x => x.OrderNo).JoinAsString(",")}置为预警单";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,6 +4,7 @@ using SJZY.Track.Application.Contract.Events;
|
|||||||
using SJZY.Track.Application.Contract.Services;
|
using SJZY.Track.Application.Contract.Services;
|
||||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||||
|
using SJZY.Track.Domain.Consts;
|
||||||
using SJZY.Track.Domain.Queries;
|
using SJZY.Track.Domain.Queries;
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||||
@ -41,7 +42,7 @@ public partial class TrackService : ApplicationService, ITrackService
|
|||||||
var order = await _orderRepository.GetFirstAsync(x =>
|
var order = await _orderRepository.GetFirstAsync(x =>
|
||||||
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new
|
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new
|
||||||
{
|
{
|
||||||
x.Id, x.SubSystemId, x.IsPushCompleted, x.CustomId
|
x.Id, x.SubSystemId, x.LatestPushTrackContentId, x.CustomId, x.IsCompleted
|
||||||
});
|
});
|
||||||
if (order == default)
|
if (order == default)
|
||||||
{
|
{
|
||||||
@ -52,8 +53,9 @@ public partial class TrackService : ApplicationService, ITrackService
|
|||||||
var @event = ObjectMapper.Map<UpsertTrackInput, TrackUpsertEvent>(input);
|
var @event = ObjectMapper.Map<UpsertTrackInput, TrackUpsertEvent>(input);
|
||||||
@event.OrderId = order.Id;
|
@event.OrderId = order.Id;
|
||||||
@event.SubSystemId = order.SubSystemId;
|
@event.SubSystemId = order.SubSystemId;
|
||||||
@event.IsPushCompleted = order.IsPushCompleted;
|
@event.LatestPushTrackContentId = order.LatestPushTrackContentId;
|
||||||
@event.CustomId = order.CustomId;
|
@event.CustomId = order.CustomId;
|
||||||
|
@event.IsCompleted = order.IsCompleted;
|
||||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
|
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -76,7 +78,7 @@ public partial class TrackService : ApplicationService, ITrackService
|
|||||||
var orders = await _orderRepository.GetListAsync(x =>
|
var orders = await _orderRepository.GetListAsync(x =>
|
||||||
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo), x => new
|
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo), x => new
|
||||||
{
|
{
|
||||||
x.Id, x.OrderNo, x.SubSystemId, x.IsPushCompleted, x.CustomId
|
x.Id, x.OrderNo, x.SubSystemId, x.LatestPushTrackContentId, x.CustomId
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var order in orders)
|
foreach (var order in orders)
|
||||||
@ -92,7 +94,7 @@ public partial class TrackService : ApplicationService, ITrackService
|
|||||||
OrderNo = order.OrderNo,
|
OrderNo = order.OrderNo,
|
||||||
OrderId = order.Id,
|
OrderId = order.Id,
|
||||||
SubSystemId = order.SubSystemId,
|
SubSystemId = order.SubSystemId,
|
||||||
IsPushCompleted = order.IsPushCompleted,
|
LatestPushTrackContentId = order.LatestPushTrackContentId,
|
||||||
CustomId = order.CustomId
|
CustomId = order.CustomId
|
||||||
};
|
};
|
||||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
|
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
|
||||||
@ -120,7 +122,7 @@ public partial class TrackService : ApplicationService, ITrackService
|
|||||||
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
|
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
var codes = await _provideQueries.GetCanDeleteTrackCodesAsync(new List<int>(order.Id), input.TrackCodes);
|
var codes = await _provideQueries.GetCanDeleteTrackCodesAsync(new List<int> { order.Id }, input.TrackCodes);
|
||||||
|
|
||||||
if (codes.Count == 0)
|
if (codes.Count == 0)
|
||||||
{
|
{
|
||||||
@ -149,7 +151,7 @@ public partial class TrackService : ApplicationService, ITrackService
|
|||||||
public async Task<bool> BatchDeleteTrackAsync(BatchDeleteTrackInput input)
|
public async Task<bool> BatchDeleteTrackAsync(BatchDeleteTrackInput input)
|
||||||
{
|
{
|
||||||
var orders = await _orderRepository.GetListAsync(x =>
|
var orders = await _orderRepository.GetListAsync(x =>
|
||||||
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo) && !x.IsPushCompleted
|
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo)
|
||||||
, x => new
|
, x => new
|
||||||
{
|
{
|
||||||
x.Id, x.SubSystemId
|
x.Id, x.SubSystemId
|
||||||
|
|||||||
@ -1,38 +1,40 @@
|
|||||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
using System.Diagnostics;
|
||||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
|
using SJZY.Track.Application.Contract.Dtos.TrackOrder;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||||
|
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||||
using SJZY.Track.Domain.Dtos.Order;
|
using SJZY.Track.Domain.Dtos.Order;
|
||||||
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||||
using System;
|
using SJZY.Track.Domain.Enums;
|
||||||
using System.Collections.Generic;
|
using SJZY.Track.Domain.Queries;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Volo.Abp.DependencyInjection;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Services.TrackOrders
|
namespace SJZY.Track.Application.Services.TrackOrders;
|
||||||
|
|
||||||
|
[ApiExplorerSettings(GroupName = "轨迹订单")]
|
||||||
|
[Route("/Track/Order")]
|
||||||
|
public class TrackOrderService : ApplicationService
|
||||||
{
|
{
|
||||||
[ApiExplorerSettings(GroupName = "轨迹订单")]
|
private readonly ITrackOrderQueries _trackOrderQueries;
|
||||||
[Route("/Track/Order")]
|
|
||||||
public class TrackOrderService : ApplicationService, ITransientDependency
|
|
||||||
{
|
|
||||||
private readonly IOrderRepository _orderRepository;
|
|
||||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||||
private readonly ITrackContentRepository _trackContentRepository;
|
private readonly ITrackContentRepository _trackContentRepository;
|
||||||
|
private readonly ITrackPushRecordsRepository _trackPushRecordsRepository;
|
||||||
|
|
||||||
public TrackOrderService(
|
public TrackOrderService(
|
||||||
IOrderRepository orderRepository,
|
ITrackOrderQueries trackOrderQueries,
|
||||||
ITrackDetailsRepository trackDetailsRepository,
|
ITrackDetailsRepository trackDetailsRepository,
|
||||||
ITrackContentRepository trackContentRepository
|
ITrackContentRepository trackContentRepository,
|
||||||
|
ITrackPushRecordsRepository trackPushRecordsRepository
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this._orderRepository=orderRepository;
|
_trackOrderQueries = trackOrderQueries;
|
||||||
this._trackDetailsRepository=trackDetailsRepository;
|
_trackDetailsRepository = trackDetailsRepository;
|
||||||
this._trackContentRepository=trackContentRepository;
|
_trackContentRepository = trackContentRepository;
|
||||||
|
_trackPushRecordsRepository = trackPushRecordsRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 轨迹订单明细
|
#region 轨迹订单明细
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据轨迹订单id获取轨迹订单明细列表
|
/// 根据轨迹订单id获取轨迹订单明细列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -47,40 +49,42 @@ namespace SJZY.Track.Application.Services.TrackOrders
|
|||||||
var list = ObjectMapper.Map<List<TrackDetailsIndex>, List<TrackOrderDetailDto>>(trackDetails);
|
var list = ObjectMapper.Map<List<TrackDetailsIndex>, List<TrackOrderDetailDto>>(trackDetails);
|
||||||
var trackCodes = list.Where(a => !a.Code.IsNullOrWhiteSpace()).Select(a => a.Code).Distinct().ToList();
|
var trackCodes = list.Where(a => !a.Code.IsNullOrWhiteSpace()).Select(a => a.Code).Distinct().ToList();
|
||||||
|
|
||||||
var trackContents = await _trackContentRepository.GetTrackContentAttributeValue(new GetTemplateContentAttributeValueInputVO
|
var trackContents = await _trackContentRepository.GetTrackContentAttributeValue(
|
||||||
|
new GetTemplateContentAttributeValueInputVO
|
||||||
{
|
{
|
||||||
SubSystemId =input.SubSystemId,
|
SubSystemId = input.SubSystemId,
|
||||||
TrackTemplateIds = input.TrackTemplateIds,
|
TrackTemplateIds = input.TrackTemplateIds,
|
||||||
TrackCodes=trackCodes
|
TrackCodes = trackCodes
|
||||||
});
|
});
|
||||||
input.TrackTemplateIds =input.TrackTemplateIds.Where(a => a>0).ToList();
|
Debug.Assert(input.TrackTemplateIds != null, "input.TrackTemplateIds != null");
|
||||||
|
input.TrackTemplateIds = input.TrackTemplateIds.Where(a => a > 0).ToList();
|
||||||
int id = 1;
|
int id = 1;
|
||||||
list.ForEach(a =>
|
list.ForEach(a =>
|
||||||
{
|
{
|
||||||
a.Id = id++;
|
a.Id = id++;
|
||||||
|
var trackContentsOfTemplates = trackContents.Where(b => b.SubSystemId == input.SubSystemId &&
|
||||||
var trackContentsOfTemplates = trackContents.Where(b => b.SubSystemId==input.SubSystemId && b.TrackCode==a.Code
|
b.TrackCode == a.Code
|
||||||
&& input.TrackTemplateIds.Contains(b.TrackTemplateId));
|
&& input.TrackTemplateIds.Contains(
|
||||||
GetTemplateContentAttributeValueVO trackContent = null;
|
b.TrackTemplateId)).ToList();
|
||||||
var insertData = input.TrackTemplateIds.Intersect(trackContentsOfTemplates.Select(aa => aa.TrackTemplateId)).ToList();
|
GetTemplateContentAttributeValueVO? trackContent = null;
|
||||||
|
var insertData = input.TrackTemplateIds
|
||||||
|
.Intersect(trackContentsOfTemplates.Select(aa => aa.TrackTemplateId)).ToList();
|
||||||
if (!insertData.IsNullOrEmpty())
|
if (!insertData.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
trackContent =trackContentsOfTemplates.FirstOrDefault(a => a.TrackTemplateId==insertData.FirstOrDefault());
|
trackContent =
|
||||||
|
trackContentsOfTemplates.FirstOrDefault(it =>
|
||||||
|
it.TrackTemplateId == insertData.FirstOrDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trackContent!=null)
|
if (trackContent != null)
|
||||||
{
|
{
|
||||||
a.IsCanDelete=trackContent.IsCanDelete;
|
a.IsCanDelete = trackContent.IsCanDelete;
|
||||||
a.IsExternal = trackContent.IsExternal;
|
a.IsExternal = trackContent.IsExternal;
|
||||||
}
|
}
|
||||||
//else
|
|
||||||
//{
|
if (a.TrackTimeZoneValue == 0f)
|
||||||
// a.IsCanDelete=false;
|
|
||||||
// a.IsExternal=false;
|
|
||||||
//}
|
|
||||||
if (a.TrackTimeZoneValue==0f)
|
|
||||||
{
|
{
|
||||||
a.TrackTimeZone=$"GTM{" "}+00:00";
|
a.TrackTimeZone = "GTM +00:00";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -89,8 +93,8 @@ namespace SJZY.Track.Application.Services.TrackOrders
|
|||||||
int minutes = (int)((a.TrackTimeZoneValue - hours) * 60); // 将小数部分乘以 60 转换为分钟
|
int minutes = (int)((a.TrackTimeZoneValue - hours) * 60); // 将小数部分乘以 60 转换为分钟
|
||||||
TimeSpan offset = new TimeSpan(hours, minutes, 0);
|
TimeSpan offset = new TimeSpan(hours, minutes, 0);
|
||||||
string timeZoneStr = offset.ToString();
|
string timeZoneStr = offset.ToString();
|
||||||
string flag = a.TrackTimeZoneValue>0f ? "+" : "";
|
string flag = a.TrackTimeZoneValue > 0f ? "+" : "";
|
||||||
a.TrackTimeZone = $"GTM{" "}{flag}{timeZoneStr.RemovePostFix(":00")}";
|
a.TrackTimeZone = $"GTM {flag}{timeZoneStr.RemovePostFix(":00")}";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return list;
|
return list;
|
||||||
@ -98,9 +102,11 @@ namespace SJZY.Track.Application.Services.TrackOrders
|
|||||||
|
|
||||||
return new List<TrackOrderDetailDto>();
|
return new List<TrackOrderDetailDto>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 轨迹订单列表
|
#region 轨迹订单列表
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取分页的轨迹订单
|
/// 获取分页的轨迹订单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -110,11 +116,39 @@ namespace SJZY.Track.Application.Services.TrackOrders
|
|||||||
public async Task<UnifyPageResultDto<TrackOrderDto>> GetPageTrackOrder(GetPageTrackOrderInput input)
|
public async Task<UnifyPageResultDto<TrackOrderDto>> GetPageTrackOrder(GetPageTrackOrderInput input)
|
||||||
{
|
{
|
||||||
var vo = ObjectMapper.Map<GetPageTrackOrderInput, GetPageTrackOrderInputVO>(input);
|
var vo = ObjectMapper.Map<GetPageTrackOrderInput, GetPageTrackOrderInputVO>(input);
|
||||||
var pageList = await _orderRepository.GetPageTrackOrder(vo);
|
var pageList = await _trackOrderQueries.GetPageTrackOrder(vo);
|
||||||
var pageResultDto =
|
var pageResultDto =
|
||||||
ObjectMapper.Map<UnifyPageResultDto<TrackOrderVO>, UnifyPageResultDto<TrackOrderDto>>(pageList);
|
ObjectMapper.Map<UnifyPageResultDto<TrackOrderVO>, UnifyPageResultDto<TrackOrderDto>>(pageList);
|
||||||
return pageResultDto;
|
return pageResultDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取轨迹计数器
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<GetTrackCounterOutput> GetTrackCounterAsync()
|
||||||
|
{
|
||||||
|
var counts = await _trackOrderQueries.GetTrackProblemCountsAsync();
|
||||||
|
|
||||||
|
return new GetTrackCounterOutput
|
||||||
|
{
|
||||||
|
TotalCount = counts.Sum(x => x.Count),
|
||||||
|
ErrorCount = counts.FirstOrDefault(x => x.ProblemType == (int)TrackProblemType.Error)?.Count ?? 0,
|
||||||
|
WarnCount = counts.FirstOrDefault(x => x.ProblemType == (int)TrackProblemType.Warn)?.Count ?? 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取轨迹推送记录
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <param name="orderId">订单id</param>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<List<TrackPushRecordIndex>> GetTrackPushRecordsAsync(int orderId)
|
||||||
|
{
|
||||||
|
return await _trackPushRecordsRepository.GetTrackPushRecordsAsync(orderId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,18 +1,22 @@
|
|||||||
using SJZY.Expand.ABP.Core;
|
using System.Linq.Expressions;
|
||||||
|
using SJZY.Expand.ABP.Core;
|
||||||
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||||
using SJZY.Track.Application.Contract.Services;
|
using SJZY.Track.Application.Contract.Services;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||||
|
using SJZY.Track.Domain.Consts;
|
||||||
using SJZY.Track.Domain.Dtos.TrackPull;
|
using SJZY.Track.Domain.Dtos.TrackPull;
|
||||||
using System.Linq.Expressions;
|
|
||||||
using Volo.Abp.DependencyInjection;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Services.TrackPull;
|
namespace SJZY.Track.Application.Services.TrackPull;
|
||||||
|
|
||||||
public class TrackPullCacheService : ApplicationService, ITrackPullCacheService, ITransientDependency
|
public class TrackPullCacheService : ApplicationService, ITrackPullCacheService
|
||||||
{
|
{
|
||||||
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
||||||
|
|
||||||
private string RedisKey(int subSystemId, int serviceProviderId) => GlobalConst.TrackPushKeyPrefix + subSystemId + ":" + serviceProviderId;
|
public string TrackPullKey(int subSystemId, int serviceProviderId) =>
|
||||||
|
$"{GlobalConst.TrackPullKeyPrefix}:{subSystemId}:{serviceProviderId}";
|
||||||
|
|
||||||
|
public string TrackPullContentKey(int subSystemId, int serviceProviderId) =>
|
||||||
|
$"{GlobalConst.TrackPullContentKeyPrefix}:{subSystemId}:{serviceProviderId}";
|
||||||
|
|
||||||
public TrackPullCacheService(ITrackPullConfigRepository trackPullConfigRepository)
|
public TrackPullCacheService(ITrackPullConfigRepository trackPullConfigRepository)
|
||||||
{
|
{
|
||||||
@ -20,9 +24,23 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService,
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public async Task<TrackPullConfigDto> GetPullConfigAsync(int subSystemId, int serviceProviderId)
|
public async Task<List<TrackPullConfigDto>> GetAllPullConfigsAsync()
|
||||||
{
|
{
|
||||||
var data = await RedisHelper.Client.GetAsync<TrackPullConfigDto>(RedisKey(subSystemId, serviceProviderId));
|
return await _trackPullConfigRepository.GetListAsync(x => true, x => new TrackPullConfigDto
|
||||||
|
{
|
||||||
|
SubSystemId = x.SubSystemId,
|
||||||
|
ServiceProviderId = x.ServiceProviderId,
|
||||||
|
PullInterval = x.PullInterval
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
public async Task<TrackPullParamWithContentConfigDto> GetPullParamWithContentConfigAsync(int subSystemId,
|
||||||
|
int serviceProviderId)
|
||||||
|
{
|
||||||
|
var data = await RedisHelper.Client.GetAsync<TrackPullParamWithContentConfigDto>(TrackPullContentKey(
|
||||||
|
subSystemId,
|
||||||
|
serviceProviderId));
|
||||||
|
|
||||||
data ??= await SetPullConfigAsync(subSystemId: subSystemId, serviceProviderId: serviceProviderId);
|
data ??= await SetPullConfigAsync(subSystemId: subSystemId, serviceProviderId: serviceProviderId);
|
||||||
|
|
||||||
@ -30,12 +48,15 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService,
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public async Task<TrackPullConfigDto> SetPullConfigAsync(int? id = null, int? subSystemId = null, int? serviceProviderId = null)
|
public async Task<TrackPullParamWithContentConfigDto> SetPullConfigAsync(int? id = null, int? subSystemId = null,
|
||||||
|
int? serviceProviderId = null)
|
||||||
{
|
{
|
||||||
var data = new TrackPullConfigDto();
|
var data = new TrackPullParamWithContentConfigDto();
|
||||||
|
|
||||||
Expression<Func<TrackPullConfigEntity, bool>> exp = x =>
|
Expression<Func<TrackPullConfigEntity, bool>> exp = x => true;
|
||||||
(id == null || x.Id == id) && (id != null || (x.SubSystemId == subSystemId && x.ServiceProviderId == serviceProviderId));
|
if (id.HasValue) exp = x => x.Id == id;
|
||||||
|
else if (subSystemId.HasValue && serviceProviderId.HasValue)
|
||||||
|
exp = x => x.SubSystemId == subSystemId && x.ServiceProviderId == serviceProviderId;
|
||||||
|
|
||||||
var trackPullConfigEntity = await _trackPullConfigRepository.GetFirstAsync(exp);
|
var trackPullConfigEntity = await _trackPullConfigRepository.GetFirstAsync(exp);
|
||||||
if (trackPullConfigEntity == null) return data;
|
if (trackPullConfigEntity == null) return data;
|
||||||
@ -45,10 +66,14 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService,
|
|||||||
var trackPullContentList = await _trackPullConfigRepository.GetContentListCacheAsync(trackPullConfigEntity.Id);
|
var trackPullContentList = await _trackPullConfigRepository.GetContentListCacheAsync(trackPullConfigEntity.Id);
|
||||||
if (trackPullContentList.Count == 0) return data;
|
if (trackPullContentList.Count == 0) return data;
|
||||||
|
|
||||||
data.ParamConfig = ObjectMapper.Map<GetTrackPullConfigDetailOutputVO, TrackPullParamConfigDto>(trackPullConfigDetail);
|
data.ParamConfig =
|
||||||
data.ContentConfigs = ObjectMapper.Map<List<GetTrackPullContentListCacheVO>, List<TrackPullContentConfigDto>>(trackPullContentList);
|
ObjectMapper.Map<GetTrackPullConfigDetailOutputVO, TrackPullParamConfigDto>(trackPullConfigDetail);
|
||||||
|
data.ContentConfigs =
|
||||||
|
ObjectMapper.Map<List<GetTrackPullContentListCacheVO>, List<TrackPullContentConfigDto>>(
|
||||||
|
trackPullContentList);
|
||||||
|
|
||||||
await RedisHelper.Client.SetAsync(RedisKey(trackPullConfigEntity.SubSystemId, trackPullConfigEntity.ServiceProviderId), data, 86400);
|
await RedisHelper.Client.SetAsync(
|
||||||
|
TrackPullContentKey(trackPullConfigEntity.SubSystemId, trackPullConfigEntity.ServiceProviderId), data);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,6 @@ using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
|||||||
using SJZY.Track.Domain.Dtos.Common;
|
using SJZY.Track.Domain.Dtos.Common;
|
||||||
using SJZY.Track.Domain.Dtos.TrackPull;
|
using SJZY.Track.Domain.Dtos.TrackPull;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Volo.Abp.DependencyInjection;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Services.TrackPull;
|
namespace SJZY.Track.Application.Services.TrackPull;
|
||||||
|
|
||||||
@ -18,7 +17,7 @@ namespace SJZY.Track.Application.Services.TrackPull;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[ApiExplorerSettings(GroupName = "轨迹拉取")]
|
[ApiExplorerSettings(GroupName = "轨迹拉取")]
|
||||||
[Route("/Track/PullConfig")]
|
[Route("/Track/PullConfig")]
|
||||||
public class TrackPullService : ApplicationService, ITransientDependency
|
public class TrackPullService : ApplicationService
|
||||||
{
|
{
|
||||||
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
|
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
|
||||||
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
||||||
@ -102,9 +101,10 @@ public class TrackPullService : ApplicationService, ITransientDependency
|
|||||||
case OptionTypeNoNull.新增:
|
case OptionTypeNoNull.新增:
|
||||||
{
|
{
|
||||||
var trackPullEntity = ObjectMapper.Map<EditTrackPullConfigInput, TrackPullConfigEntity>(input);
|
var trackPullEntity = ObjectMapper.Map<EditTrackPullConfigInput, TrackPullConfigEntity>(input);
|
||||||
var trackPullParamsEntity = ObjectMapper.Map<EditTrackPullConfigInput, TrackPushPullParamsConfigEntity>(input);
|
var trackPullParamsEntity =
|
||||||
|
ObjectMapper.Map<EditTrackPullConfigInput, TrackPushPullParamsConfigEntity>(input);
|
||||||
|
|
||||||
int id = 0;
|
int id;
|
||||||
|
|
||||||
using (var ts = TransactionScopeHelper.Create())
|
using (var ts = TransactionScopeHelper.Create())
|
||||||
{
|
{
|
||||||
@ -122,9 +122,12 @@ public class TrackPullService : ApplicationService, ITransientDependency
|
|||||||
|
|
||||||
case OptionTypeNoNull.修改:
|
case OptionTypeNoNull.修改:
|
||||||
{
|
{
|
||||||
var oldTrackPullEntity = await _trackPullConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
var oldTrackPullEntity = await _trackPullConfigRepository.GetFirstAsync(x => x.Id == input.Id) ??
|
||||||
|
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||||
|
|
||||||
var oldTrackPullParamsEntity = await _trackPullConfigRepository.GetParamsSingleAsync(x => x.PullOrPushConfigId == input.Id && !x.IsPush);
|
var oldTrackPullParamsEntity =
|
||||||
|
await _trackPullConfigRepository.GetParamsSingleAsync(x =>
|
||||||
|
x.PullOrPushConfigId == input.Id && !x.IsPush);
|
||||||
|
|
||||||
ObjectMapper.Map(input, oldTrackPullEntity);
|
ObjectMapper.Map(input, oldTrackPullEntity);
|
||||||
ObjectMapper.Map(input, oldTrackPullParamsEntity);
|
ObjectMapper.Map(input, oldTrackPullParamsEntity);
|
||||||
@ -145,7 +148,8 @@ public class TrackPullService : ApplicationService, ITransientDependency
|
|||||||
using (var ts = TransactionScopeHelper.Create())
|
using (var ts = TransactionScopeHelper.Create())
|
||||||
{
|
{
|
||||||
await _trackPullConfigRepository.SoftDeleteAsync(x => x.Id == input.Id);
|
await _trackPullConfigRepository.SoftDeleteAsync(x => x.Id == input.Id);
|
||||||
await _trackPullConfigRepository.SoftDeleteParamsAsync(x => x.PullOrPushConfigId == input.Id && !x.IsPush);
|
await _trackPullConfigRepository.SoftDeleteParamsAsync(x =>
|
||||||
|
x.PullOrPushConfigId == input.Id && !x.IsPush);
|
||||||
await _trackPullConfigRepository.SoftDeleteContentAsync(x => x.TrackPullConfigId == input.Id);
|
await _trackPullConfigRepository.SoftDeleteContentAsync(x => x.TrackPullConfigId == input.Id);
|
||||||
|
|
||||||
ts.Complete();
|
ts.Complete();
|
||||||
@ -171,21 +175,32 @@ public class TrackPullService : ApplicationService, ITransientDependency
|
|||||||
{
|
{
|
||||||
if (input.Options != OptionTypeNoNull.删除)
|
if (input.Options != OptionTypeNoNull.删除)
|
||||||
{
|
{
|
||||||
Expression<Func<TrackPullContentConfigEntity, bool>> isContentAnyExp = x => x.TrackPullConfigId == input.TrackPullConfigId;
|
Expression<Func<TrackPullContentConfigEntity, bool>> isContentAnyExp = x =>
|
||||||
|
x.TrackPullConfigId == input.TrackPullConfigId;
|
||||||
if (input.Options == OptionTypeNoNull.修改) isContentAnyExp = isContentAnyExp.And(x => x.Id != input.Id);
|
if (input.Options == OptionTypeNoNull.修改) isContentAnyExp = isContentAnyExp.And(x => x.Id != input.Id);
|
||||||
|
|
||||||
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentId == input.TrackContentId)))
|
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||||
|
x.TrackContentId == input.TrackContentId)))
|
||||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentAny"]);
|
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentAny"]);
|
||||||
else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentCodeValue == input.TrackContentCodeValue)))
|
else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() &&
|
||||||
|
await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||||
|
x.TrackContentCodeValue == input.TrackContentCodeValue)))
|
||||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentCodeValueAny"]);
|
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentCodeValueAny"]);
|
||||||
else if (!input.TrackStatusValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackStatusValue == input.TrackStatusValue)))
|
else if (!input.TrackStatusValue.IsNullOrWhiteSpace() &&
|
||||||
|
await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||||
|
x.TrackStatusValue == input.TrackStatusValue)))
|
||||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentStatusValueAny"]);
|
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentStatusValueAny"]);
|
||||||
else if (!input.TrackContentValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentValue == input.TrackContentValue)))
|
else if (!input.TrackContentValue.IsNullOrWhiteSpace() &&
|
||||||
|
await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||||
|
x.TrackContentValue == input.TrackContentValue)))
|
||||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentValueAny"]);
|
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentValueAny"]);
|
||||||
else if (!input.TrackKeywords.IsNullOrEmpty())
|
else if (!input.TrackKeywords.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
Expression<Func<TrackPullContentConfigEntity, bool>> trackKeywordExp = _ => false;
|
Expression<Func<TrackPullContentConfigEntity, bool>> trackKeywordExp = _ => false;
|
||||||
input.TrackKeywords!.ForEach(item => { trackKeywordExp = trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item)); });
|
input.TrackKeywords!.ForEach(item =>
|
||||||
|
{
|
||||||
|
trackKeywordExp = trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item));
|
||||||
|
});
|
||||||
|
|
||||||
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(trackKeywordExp)))
|
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(trackKeywordExp)))
|
||||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentKeywordsAny"]);
|
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentKeywordsAny"]);
|
||||||
@ -212,16 +227,21 @@ public class TrackPullService : ApplicationService, ITransientDependency
|
|||||||
ObjectMapper.Map(input, oldTrackPullContentEntity);
|
ObjectMapper.Map(input, oldTrackPullContentEntity);
|
||||||
|
|
||||||
await _trackPullConfigRepository.UpdateContentAsync(oldTrackPullContentEntity);
|
await _trackPullConfigRepository.UpdateContentAsync(oldTrackPullContentEntity);
|
||||||
await _trackPullCacheService.SetPullConfigAsync(input.TrackPullConfigId);
|
await _trackPullCacheService.SetPullConfigAsync(oldTrackPullContentEntity.TrackPullConfigId);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case OptionTypeNoNull.删除:
|
case OptionTypeNoNull.删除:
|
||||||
|
{
|
||||||
|
var oldTrackPullContentEntity = await _trackPullConfigRepository.GetContentByIdAsync(input.Id!.Value) ??
|
||||||
|
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||||
|
|
||||||
await _trackPullConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id);
|
await _trackPullConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id);
|
||||||
|
await _trackPullCacheService.SetPullConfigAsync(oldTrackPullContentEntity.TrackPullConfigId);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum,
|
throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum,
|
||||||
|
|||||||
@ -1,39 +1,101 @@
|
|||||||
using SJZY.Expand.ABP.Core;
|
using System.Linq.Expressions;
|
||||||
|
using SJZY.Expand.ABP.Core;
|
||||||
|
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||||
using SJZY.Track.Application.Contract.Services;
|
using SJZY.Track.Application.Contract.Services;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||||
using SJZY.Track.Domain.Queries;
|
using SJZY.Track.Domain.Consts;
|
||||||
using Volo.Abp.DependencyInjection;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Services.TrackPush;
|
namespace SJZY.Track.Application.Services.TrackPush;
|
||||||
|
|
||||||
public class TrackPushCacheService : ITrackPushCacheService, ITransientDependency
|
public class TrackPushCacheService : ApplicationService, ITrackPushCacheService
|
||||||
{
|
{
|
||||||
private readonly IBasicQuery<TrackPushConfigEntity> _trackPushConfigQuery;
|
private readonly ITrackPushConfigRepository _trackPushConfigRepository;
|
||||||
|
|
||||||
private string RedisKey(int customId) => GlobalConst.TrackPushKeyPrefix + customId;
|
private string TrackPushContentKey(int subSystemId, int customId) =>
|
||||||
|
$"{GlobalConst.TrackPushKeyPrefix}:{subSystemId}:{customId}";
|
||||||
|
|
||||||
public TrackPushCacheService(IBasicQuery<TrackPushConfigEntity> trackPushConfigQuery)
|
public TrackPushCacheService(ITrackPushConfigRepository trackPushConfigRepository)
|
||||||
{
|
{
|
||||||
_trackPushConfigQuery = trackPushConfigQuery;
|
_trackPushConfigRepository = trackPushConfigRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> IsPushAsync(int customId)
|
[NonAction]
|
||||||
|
public async Task<List<TrackPushContentConfigDto>> GetPushContentConfigsAsync(int subSystemId, int customId)
|
||||||
{
|
{
|
||||||
var isPush =
|
var data = await GetPushConfigAsync(subSystemId, customId);
|
||||||
await RedisHelper.Client.GetAsync<bool?>(RedisKey(customId));
|
|
||||||
|
|
||||||
if (isPush == null)
|
return data.ContentConfigs;
|
||||||
{
|
|
||||||
isPush = await _trackPushConfigQuery.GetFirstAsync(x => x.CustomId == customId,
|
|
||||||
x => x.IsAutoPush);
|
|
||||||
await RedisHelper.Client.SetAsync(RedisKey(customId), isPush);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (bool)isPush;
|
[NonAction]
|
||||||
|
public async Task<TrackPushContentConfigDto> GetPushContentConfigAsync(int subSystemId, int customId,
|
||||||
|
int trackContentId)
|
||||||
|
{
|
||||||
|
var data = await GetPushContentConfigsAsync(subSystemId, customId);
|
||||||
|
|
||||||
|
return data.Single(x => x.TrackContentId == trackContentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateAsync(int customId, bool isPush)
|
[NonAction]
|
||||||
|
public async Task<TrackPushContentConfigDto?> InferNextPushContentOrNullAsync(int subSystemId, int customId,
|
||||||
|
int? trackContentId)
|
||||||
{
|
{
|
||||||
await RedisHelper.Client.SetAsync(RedisKey(customId), isPush);
|
var data = await GetPushConfigAsync(subSystemId, customId);
|
||||||
|
if (!data.IsAutoPush) return null;
|
||||||
|
|
||||||
|
if (trackContentId.HasValue)
|
||||||
|
{
|
||||||
|
if (data.ContentConfigs.Count > 1 && data.ContentConfigs.Any(x => x.TrackContentId == trackContentId))
|
||||||
|
{
|
||||||
|
int index = data.ContentConfigs.FindIndex(x => x.TrackContentId == trackContentId);
|
||||||
|
if (index == data.ContentConfigs.Count - 1) return null;
|
||||||
|
int nextIndex = (index + 1) % data.ContentConfigs.Count; // 计算下一个索引,处理最后一个元素的情况
|
||||||
|
|
||||||
|
return data.ContentConfigs[nextIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.ContentConfigs.FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
public async Task<TrackPushConfigDto> SetPushContentConfigsAsync(int? id = null, int? subSystemId = null,
|
||||||
|
int? customId = null)
|
||||||
|
{
|
||||||
|
var data = new TrackPushConfigDto { ContentConfigs = new() };
|
||||||
|
|
||||||
|
Expression<Func<TrackPushConfigEntity, bool>> exp = x => true;
|
||||||
|
if (id.HasValue) exp = x => x.Id == id;
|
||||||
|
else if (subSystemId.HasValue && customId.HasValue)
|
||||||
|
exp = x => x.SubSystemId == subSystemId && x.CustomId == customId;
|
||||||
|
|
||||||
|
var trackPushConfigEntity = await _trackPushConfigRepository.GetFirstAsync(exp);
|
||||||
|
if (trackPushConfigEntity == null) return data;
|
||||||
|
|
||||||
|
var trackPushContentList =
|
||||||
|
await _trackPushConfigRepository.GetContentListAsync(x => x.TrackPushConfigId == trackPushConfigEntity.Id);
|
||||||
|
if (trackPushContentList.Count == 0) return data;
|
||||||
|
|
||||||
|
trackPushContentList = trackPushContentList.OrderBy(x => x.Sort).ToList();
|
||||||
|
|
||||||
|
data.IsAutoPush = trackPushConfigEntity.IsAutoPush;
|
||||||
|
data.ContentConfigs =
|
||||||
|
ObjectMapper.Map<List<TrackPushContentConfigEntity>, List<TrackPushContentConfigDto>>(trackPushContentList);
|
||||||
|
|
||||||
|
await RedisHelper.Client.SetAsync(
|
||||||
|
TrackPushContentKey(trackPushConfigEntity.SubSystemId, trackPushConfigEntity.CustomId), data);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<TrackPushConfigDto> GetPushConfigAsync(int subSystemId, int customId)
|
||||||
|
{
|
||||||
|
var data = await RedisHelper.Client.GetAsync<TrackPushConfigDto>(TrackPushContentKey(subSystemId, customId));
|
||||||
|
|
||||||
|
data ??= await SetPushContentConfigsAsync(subSystemId: subSystemId, customId: customId);
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Extensions.Localization;
|
using System.Linq.Expressions;
|
||||||
|
using Microsoft.Extensions.Localization;
|
||||||
using SJZY.Expand.ABP.Core.Localization;
|
using SJZY.Expand.ABP.Core.Localization;
|
||||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||||
using SJZY.Track.Application.Contract.Dtos.TrackPush;
|
using SJZY.Track.Application.Contract.Dtos.TrackPush;
|
||||||
@ -9,9 +10,6 @@ using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
|||||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||||
using SJZY.Track.Domain.Dtos.Common;
|
using SJZY.Track.Domain.Dtos.Common;
|
||||||
using SJZY.Track.Domain.Dtos.TrackPush;
|
using SJZY.Track.Domain.Dtos.TrackPush;
|
||||||
using SqlSugar;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using Volo.Abp.DependencyInjection;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Services.TrackPush;
|
namespace SJZY.Track.Application.Services.TrackPush;
|
||||||
|
|
||||||
@ -20,11 +18,10 @@ namespace SJZY.Track.Application.Services.TrackPush;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[ApiExplorerSettings(GroupName = "轨迹推送")]
|
[ApiExplorerSettings(GroupName = "轨迹推送")]
|
||||||
[Route("/Track/PushConfig")]
|
[Route("/Track/PushConfig")]
|
||||||
public class TrackPushService : ApplicationService, ITransientDependency
|
public class TrackPushService : ApplicationService
|
||||||
{
|
{
|
||||||
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
|
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
|
||||||
private readonly ITrackPushConfigRepository _trackPushConfigRepository;
|
private readonly ITrackPushConfigRepository _trackPushConfigRepository;
|
||||||
private readonly ITrackTemplateRepository _trackTemplateRepository;
|
|
||||||
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
||||||
private readonly ITrackPushCacheService _trackPushCacheService;
|
private readonly ITrackPushCacheService _trackPushCacheService;
|
||||||
|
|
||||||
@ -37,7 +34,6 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
{
|
{
|
||||||
_stringLocalizer = stringLocalizer;
|
_stringLocalizer = stringLocalizer;
|
||||||
_trackPushConfigRepository = trackPushConfigRepository;
|
_trackPushConfigRepository = trackPushConfigRepository;
|
||||||
_trackTemplateRepository = trackTemplateRepository;
|
|
||||||
_trackPullConfigRepository = trackPullConfigRepository;
|
_trackPullConfigRepository = trackPullConfigRepository;
|
||||||
_trackPushCacheService = trackPushCacheService;
|
_trackPushCacheService = trackPushCacheService;
|
||||||
}
|
}
|
||||||
@ -59,7 +55,8 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("GetContentPage")]
|
[HttpPost("GetContentPage")]
|
||||||
public async Task<UnifyPageResultDto<GetTrackPushContentPageOutputVO>> GetContentPageAsync([FromBody] GetTrackPushContentPageInputVO input)
|
public async Task<UnifyPageResultDto<GetTrackPushContentPageOutputVO>> GetContentPageAsync(
|
||||||
|
[FromBody] GetTrackPushContentPageInputVO input)
|
||||||
{
|
{
|
||||||
return await _trackPushConfigRepository.GetContentPageAsync(input);
|
return await _trackPushConfigRepository.GetContentPageAsync(input);
|
||||||
}
|
}
|
||||||
@ -97,10 +94,11 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
if (input.Options != OptionTypeNoNull.删除)
|
if (input.Options != OptionTypeNoNull.删除)
|
||||||
{
|
{
|
||||||
Expression<Func<TrackPushConfigEntity, bool>> isAnyExp = x =>
|
Expression<Func<TrackPushConfigEntity, bool>> isAnyExp = x =>
|
||||||
x.SubSystemId == input.SubSystemId && x.CustomId == input.CustomId && x.ServiceProviderId == input.ServiceProviderId;
|
x.SubSystemId == input.SubSystemId && x.CustomId == input.CustomId;
|
||||||
if (input.Options == OptionTypeNoNull.修改) isAnyExp = isAnyExp.And(x => x.Id != input.Id);
|
if (input.Options == OptionTypeNoNull.修改) isAnyExp = isAnyExp.And(x => x.Id != input.Id);
|
||||||
|
|
||||||
if (await _trackPushConfigRepository.IsAnyAsync(isAnyExp)) throw new BusinessException(message: _stringLocalizer["IsTrackPushConfigAny"]);
|
if (await _trackPushConfigRepository.IsAnyAsync(isAnyExp))
|
||||||
|
throw new BusinessException(message: _stringLocalizer["IsTrackPushConfigAny"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (input.Options)
|
switch (input.Options)
|
||||||
@ -108,7 +106,8 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
case OptionTypeNoNull.新增:
|
case OptionTypeNoNull.新增:
|
||||||
{
|
{
|
||||||
var trackPushEntity = ObjectMapper.Map<EditTrackPushConfigInput, TrackPushConfigEntity>(input);
|
var trackPushEntity = ObjectMapper.Map<EditTrackPushConfigInput, TrackPushConfigEntity>(input);
|
||||||
var trackPushParamsEntity = ObjectMapper.Map<EditTrackPushConfigInput, TrackPushPullParamsConfigEntity>(input);
|
var trackPushParamsEntity =
|
||||||
|
ObjectMapper.Map<EditTrackPushConfigInput, TrackPushPullParamsConfigEntity>(input);
|
||||||
|
|
||||||
using (var ts = TransactionScopeHelper.Create())
|
using (var ts = TransactionScopeHelper.Create())
|
||||||
{
|
{
|
||||||
@ -117,8 +116,6 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
trackPushParamsEntity.PullOrPushConfigId = id;
|
trackPushParamsEntity.PullOrPushConfigId = id;
|
||||||
await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity);
|
await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity);
|
||||||
|
|
||||||
if (input.IsAutoPush!.Value) await _trackPushCacheService.IsPushAsync(input.CustomId!.Value);
|
|
||||||
|
|
||||||
ts.Complete();
|
ts.Complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,11 +123,14 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
|
|
||||||
case OptionTypeNoNull.修改:
|
case OptionTypeNoNull.修改:
|
||||||
{
|
{
|
||||||
var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ??
|
||||||
|
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||||
|
|
||||||
int oldCustomId = oldTrackPushEntity.CustomId;
|
int oldCustomId = oldTrackPushEntity.CustomId;
|
||||||
|
|
||||||
var oldTrackPushParamsEntity = await _trackPullConfigRepository.GetParamsSingleAsync(x => x.PullOrPushConfigId == input.Id && x.IsPush);
|
var oldTrackPushParamsEntity =
|
||||||
|
await _trackPullConfigRepository.GetParamsSingleAsync(x =>
|
||||||
|
x.PullOrPushConfigId == input.Id && x.IsPush);
|
||||||
|
|
||||||
ObjectMapper.Map(input, oldTrackPushEntity);
|
ObjectMapper.Map(input, oldTrackPushEntity);
|
||||||
ObjectMapper.Map(input, oldTrackPushParamsEntity);
|
ObjectMapper.Map(input, oldTrackPushParamsEntity);
|
||||||
@ -140,24 +140,24 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
await _trackPushConfigRepository.UpdateAsync(oldTrackPushEntity);
|
await _trackPushConfigRepository.UpdateAsync(oldTrackPushEntity);
|
||||||
await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity);
|
await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity);
|
||||||
|
|
||||||
await _trackPushCacheService.UpdateAsync(oldCustomId, false);
|
|
||||||
if (input.IsAutoPush!.Value) await _trackPushCacheService.IsPushAsync(input.CustomId!.Value);
|
|
||||||
|
|
||||||
ts.Complete();
|
ts.Complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (input.IsAutoPush!.Value) await _trackPushCacheService.SetPushContentConfigsAsync(input.Id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionTypeNoNull.删除:
|
case OptionTypeNoNull.删除:
|
||||||
{
|
{
|
||||||
var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ??
|
||||||
|
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||||
|
|
||||||
using (var ts = TransactionScopeHelper.Create())
|
using (var ts = TransactionScopeHelper.Create())
|
||||||
{
|
{
|
||||||
await _trackPushConfigRepository.SoftDeleteAsync(x => x.Id == input.Id);
|
await _trackPushConfigRepository.SoftDeleteAsync(x => x.Id == input.Id);
|
||||||
await _trackPullConfigRepository.SoftDeleteParamsAsync(x => x.PullOrPushConfigId == input.Id && x.IsPush);
|
await _trackPullConfigRepository.SoftDeleteParamsAsync(x =>
|
||||||
|
x.PullOrPushConfigId == input.Id && x.IsPush);
|
||||||
await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id);
|
await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id);
|
||||||
await _trackPushCacheService.UpdateAsync(oldTrackPushEntity.CustomId, false);
|
|
||||||
|
|
||||||
ts.Complete();
|
ts.Complete();
|
||||||
}
|
}
|
||||||
@ -182,18 +182,28 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
{
|
{
|
||||||
if (input.Options != OptionTypeNoNull.删除)
|
if (input.Options != OptionTypeNoNull.删除)
|
||||||
{
|
{
|
||||||
Expression<Func<TrackPushContentConfigEntity, bool>> isContentAnyExp = x => x.TrackPushConfigId == input.TrackPushConfigId;
|
Expression<Func<TrackPushContentConfigEntity, bool>> isContentAnyExp = x =>
|
||||||
|
x.TrackPushConfigId == input.TrackPushConfigId;
|
||||||
if (input.Options == OptionTypeNoNull.修改) isContentAnyExp = isContentAnyExp.And(x => x.Id != input.Id);
|
if (input.Options == OptionTypeNoNull.修改) isContentAnyExp = isContentAnyExp.And(x => x.Id != input.Id);
|
||||||
|
|
||||||
if (await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentId == input.TrackContentId)))
|
if (await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||||
|
x.TrackContentId == input.TrackContentId)))
|
||||||
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentAny"]);
|
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentAny"]);
|
||||||
else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentCodeValue == input.TrackContentCodeValue)))
|
else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() &&
|
||||||
|
await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||||
|
x.TrackContentCodeValue == input.TrackContentCodeValue)))
|
||||||
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentCodeValueAny"]);
|
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentCodeValueAny"]);
|
||||||
else if (!input.TrackStatusValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackStatusValue == input.TrackStatusValue)))
|
else if (!input.TrackStatusValue.IsNullOrWhiteSpace() &&
|
||||||
|
await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||||
|
x.TrackStatusValue == input.TrackStatusValue)))
|
||||||
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentStatusValueAny"]);
|
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentStatusValueAny"]);
|
||||||
else if (!input.TrackContentValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentValue == input.TrackContentValue)))
|
else if (!input.TrackContentValue.IsNullOrWhiteSpace() &&
|
||||||
|
await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||||
|
x.TrackContentValue == input.TrackContentValue)))
|
||||||
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentValueAny"]);
|
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentValueAny"]);
|
||||||
else if (!input.TrackEnContentValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackEnContentValue == input.TrackEnContentValue)))
|
else if (!input.TrackEnContentValue.IsNullOrWhiteSpace() &&
|
||||||
|
await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x =>
|
||||||
|
x.TrackEnContentValue == input.TrackEnContentValue)))
|
||||||
throw new BusinessException(message: _stringLocalizer["IsTrackPushEnContentValueAny"]);
|
throw new BusinessException(message: _stringLocalizer["IsTrackPushEnContentValueAny"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,40 +211,47 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
{
|
{
|
||||||
case OptionTypeNoNull.新增:
|
case OptionTypeNoNull.新增:
|
||||||
{
|
{
|
||||||
int maxSort = await _trackPushConfigRepository.ContentMaxAsync(x => x.Sort, x => x.TrackPushConfigId == input.TrackPushConfigId);
|
int maxSort = await _trackPushConfigRepository.ContentMaxAsync(x => x.Sort,
|
||||||
|
x => x.TrackPushConfigId == input.TrackPushConfigId);
|
||||||
|
|
||||||
var entity = ObjectMapper.Map<EditTrackPushContentInput, TrackPushContentConfigEntity>(input);
|
var entity = ObjectMapper.Map<EditTrackPushContentInput, TrackPushContentConfigEntity>(input);
|
||||||
entity.Sort = maxSort + 1;
|
entity.Sort = maxSort + 1;
|
||||||
|
|
||||||
await _trackPushConfigRepository.InsertContentAsync(entity);
|
await _trackPushConfigRepository.InsertContentAsync(entity);
|
||||||
|
await _trackPushCacheService.SetPushContentConfigsAsync(input.TrackPushConfigId);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case OptionTypeNoNull.修改:
|
case OptionTypeNoNull.修改:
|
||||||
{
|
{
|
||||||
var entity = await _trackPushConfigRepository.GetContentByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
var entity = await _trackPushConfigRepository.GetContentByIdAsync(input.Id!.Value) ??
|
||||||
|
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||||
|
|
||||||
ObjectMapper.Map(input, entity);
|
ObjectMapper.Map(input, entity);
|
||||||
|
|
||||||
await _trackPushConfigRepository.UpdateContentAsync(entity);
|
await _trackPushConfigRepository.UpdateContentAsync(entity);
|
||||||
|
await _trackPushCacheService.SetPushContentConfigsAsync(entity.TrackPushConfigId);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case OptionTypeNoNull.删除:
|
case OptionTypeNoNull.删除:
|
||||||
{
|
{
|
||||||
var entity = await _trackPushConfigRepository.GetContentByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
var entity = await _trackPushConfigRepository.GetContentByIdAsync(input.Id!.Value) ??
|
||||||
|
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||||
|
|
||||||
using (var ts = TransactionScopeHelper.Create())
|
using (var ts = TransactionScopeHelper.Create())
|
||||||
{
|
{
|
||||||
await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id);
|
await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id);
|
||||||
|
await _trackPushConfigRepository.UpdateContentAsync(x => x.Sort == x.Sort - 1,
|
||||||
await _trackPushConfigRepository.UpdateContentAsync(x => x.Sort == x.Sort - 1, x => x.TrackPushConfigId == entity.TrackPushConfigId && x.Sort > entity.Sort);
|
x => x.TrackPushConfigId == entity.TrackPushConfigId && x.Sort > entity.Sort);
|
||||||
|
|
||||||
ts.Complete();
|
ts.Complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await _trackPushCacheService.SetPushContentConfigsAsync(entity.TrackPushConfigId);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +280,11 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
item.Sort = input.SortInfo.Single(x => x.Key == item.Id.ToString()).Value;
|
item.Sort = input.SortInfo.Single(x => x.Key == item.Id.ToString()).Value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (trackPushContentEntities.Count > 0)
|
||||||
|
{
|
||||||
await _trackPushConfigRepository.UpdateContentRangeAsync(trackPushContentEntities);
|
await _trackPushConfigRepository.UpdateContentRangeAsync(trackPushContentEntities);
|
||||||
|
await _trackPushCacheService.SetPushContentConfigsAsync(trackPushContentEntities[0].TrackPushConfigId);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,13 +11,6 @@ public interface IOrderRepository : IBasicRepository<OrderEntity>
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task CreateOrderAsync(OrderEntity order);
|
Task CreateOrderAsync(OrderEntity order);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取分页的轨迹订单
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<UnifyPageResultDto<TrackOrderVO>> GetPageTrackOrder(GetPageTrackOrderInputVO input);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新订单
|
/// 更新订单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -57,12 +50,4 @@ public interface IOrderRepository : IBasicRepository<OrderEntity>
|
|||||||
Task UnLinkByIdsAsync(List<int> linkIds);
|
Task UnLinkByIdsAsync(List<int> linkIds);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取订单模板列表
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="orderNos"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<List<OrderTemplateVO>> GetOrderTemplatesAsync(List<string> orderNos);
|
|
||||||
}
|
}
|
||||||
@ -43,10 +43,16 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
|||||||
public bool IsCompleted { get; set; }
|
public bool IsCompleted { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 订单是否推送完成(异步维护)
|
/// 最新推送轨迹内容id(异步维护)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnName = "IsPushCompleted")]
|
[SugarColumn(ColumnName = "LatestPushTrackContentId")]
|
||||||
public bool IsPushCompleted { get; set; }
|
public int? LatestPushTrackContentId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最新推送时间(异步维护)
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "LatestPushTime")]
|
||||||
|
public DateTime? LatestPushTime { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 最新轨迹内容(异步维护)
|
/// 最新轨迹内容(异步维护)
|
||||||
@ -115,10 +121,10 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
|||||||
public int QuestionType { get; set; }
|
public int QuestionType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
/// 问题描述
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnName = "ProblemDescription")]
|
[SugarColumn(ColumnName = "ProblemDescription")]
|
||||||
public int ProblemDescription { get; set; }
|
public string? ProblemDescription { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 起运港口
|
/// 起运港口
|
||||||
|
|||||||
@ -10,6 +10,8 @@ public interface ITrackDetailsRepository
|
|||||||
|
|
||||||
Task<List<TrackDetailsIndex>> GetListAsync(int orderType, List<string> orderNos);
|
Task<List<TrackDetailsIndex>> GetListAsync(int orderType, List<string> orderNos);
|
||||||
|
|
||||||
|
Task<List<TrackDetailsIndex>> GetListAsync(int orderType, List<string> orderNos, string trackCode);
|
||||||
|
|
||||||
Task<(List<TrackDetailsIndex> list, long total)> GetListAsync(TrackDetailsQueryInput input);
|
Task<(List<TrackDetailsIndex> list, long total)> GetListAsync(TrackDetailsQueryInput input);
|
||||||
Task<List<TrackDetailsIndex>> GetListAsync(int orderId);
|
Task<List<TrackDetailsIndex>> GetListAsync(int orderId);
|
||||||
|
|
||||||
@ -21,8 +23,6 @@ public interface ITrackDetailsRepository
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> DeleteTrackAsync(int orderId, List<string> trackCodes);
|
Task<bool> DeleteTrackAsync(int orderId, List<string> trackCodes);
|
||||||
|
|
||||||
Task<List<TrackDetailsIndex>?> GetListAsync(List<int> orderIds);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取最近一条发生的轨迹
|
/// 获取最近一条发生的轨迹
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using Nest;
|
using Nest;
|
||||||
using SJZY.Expand.ElasticSearch;
|
using SJZY.Expand.ElasticSearch;
|
||||||
|
using SJZY.Track.Domain.Consts;
|
||||||
|
|
||||||
namespace SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
namespace SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||||
|
|
||||||
@ -31,11 +32,6 @@ public class TrackDetailsIndex : IdBaseIndex
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string TrackStatus { get; set; } = null!;
|
public string TrackStatus { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 原轨迹状态
|
|
||||||
/// </summary>
|
|
||||||
public string? OriginTrackStatus { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 轨迹内容代码
|
/// 轨迹内容代码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -47,10 +43,20 @@ public class TrackDetailsIndex : IdBaseIndex
|
|||||||
public string TrackContent { get; set; } = null!;
|
public string TrackContent { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否意味着完成
|
/// 轨迹内容Id
|
||||||
|
/// </summary>
|
||||||
|
public int TrackContentId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 这条轨迹是否意味着完成(删除回退需要用到)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsCompleted { get; set; }
|
public bool IsCompleted { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 原轨迹状态
|
||||||
|
/// </summary>
|
||||||
|
public string? OriginTrackStatus { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 原轨迹内容
|
/// 原轨迹内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -0,0 +1,18 @@
|
|||||||
|
namespace SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||||
|
|
||||||
|
public interface ITrackPushRecordsRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 添加推送记录
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task AddAsync(TrackPushRecordIndex index);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取轨迹推送记录
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orderId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<TrackPushRecordIndex>> GetTrackPushRecordsAsync(int orderId);
|
||||||
|
}
|
||||||
@ -0,0 +1,100 @@
|
|||||||
|
using Nest;
|
||||||
|
using SJZY.Expand.ElasticSearch;
|
||||||
|
using SJZY.Track.Domain.Consts;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||||
|
|
||||||
|
[ElasticsearchType(RelationName = GlobalConst.TrackPushRecordsIndex)]
|
||||||
|
public class TrackPushRecordIndex : IdBaseIndex
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 索引名称
|
||||||
|
/// </summary>
|
||||||
|
public string IndexName { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单Id
|
||||||
|
/// </summary>
|
||||||
|
public int OrderId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 接口通请求Id
|
||||||
|
/// </summary>
|
||||||
|
public Guid RequestId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 信息
|
||||||
|
/// </summary>
|
||||||
|
public string Message { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 操作类型
|
||||||
|
/// </summary>
|
||||||
|
public string OptionType { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹状态
|
||||||
|
/// </summary>
|
||||||
|
public string TrackStatus { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容代码
|
||||||
|
/// </summary>
|
||||||
|
public string TrackCode { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容
|
||||||
|
/// </summary>
|
||||||
|
public string TrackContent { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹发生地
|
||||||
|
/// </summary>
|
||||||
|
public string TrackPlace { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹发生时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime TrackTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹发生时区
|
||||||
|
/// </summary>
|
||||||
|
public float TrackTimeZone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否成功
|
||||||
|
/// </summary>
|
||||||
|
public bool IsSuccess { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹代码参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackContentCodeValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackContentValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容英文参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackEnContentValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹状态参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? TrackStatusValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 扩展字段参数值
|
||||||
|
/// </summary>
|
||||||
|
public string? ExpandFieldsValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>创建人</summary>
|
||||||
|
public string? CreateUser { get; set; }
|
||||||
|
|
||||||
|
/// <summary>创建时间</summary>
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
14
src/SJZY.Track.Domain/Consts/GlobalConst.ES.cs
Normal file
14
src/SJZY.Track.Domain/Consts/GlobalConst.ES.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
namespace SJZY.Track.Domain.Consts;
|
||||||
|
|
||||||
|
public partial class GlobalConst
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹明细 es索引名称(模板)
|
||||||
|
/// </summary>
|
||||||
|
public const string TrackIndex = "sjzy_track_details";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹推送记录 es索引名称(模板)
|
||||||
|
/// </summary>
|
||||||
|
public const string TrackPushRecordsIndex = "sjzy_track_push_records";
|
||||||
|
}
|
||||||
39
src/SJZY.Track.Domain/Consts/GlobalConst.MQ.cs
Normal file
39
src/SJZY.Track.Domain/Consts/GlobalConst.MQ.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace SJZY.Track.Domain.Consts;
|
||||||
|
|
||||||
|
public partial class GlobalConst
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹新增/更新
|
||||||
|
/// </summary>
|
||||||
|
public const string TrackUpsertSubscribe = "SJZY.Track.TrackUpsert";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹删除
|
||||||
|
/// </summary>
|
||||||
|
public const string TrackDeleteSubscribe = "SJZY.Track.TrackDelete";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 接口通批量轨迹刷新
|
||||||
|
/// </summary>
|
||||||
|
public const string TrackRefreshSubscribe = "SJZY.Track.TrackRefresh";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹推送
|
||||||
|
/// </summary>
|
||||||
|
public const string TrackPushSubscribe = "SJZY.Track.TrackPush";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹新增/更新后触发更新订单主表
|
||||||
|
/// </summary>
|
||||||
|
public const string TrackUpsertAfterUpdateOrderSubscribe = "SJZY.Track.TrackUpsertAfterUpdateOrder";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹推送后触发更新订单主表
|
||||||
|
/// </summary>
|
||||||
|
public const string TrackPushAfterUpdateOrderSubscribe = "SJZY.Traack.TrackPushAfterUpdateOrder";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关联订单后补轨迹
|
||||||
|
/// </summary>
|
||||||
|
public const string OrderLinkAfterFillTrack = "SJZY.Track.OrderLinkAfterFillTrack";
|
||||||
|
}
|
||||||
24
src/SJZY.Track.Domain/Consts/GlobalConst.Redis.cs
Normal file
24
src/SJZY.Track.Domain/Consts/GlobalConst.Redis.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
namespace SJZY.Track.Domain.Consts;
|
||||||
|
|
||||||
|
public partial class GlobalConst
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹要推送的客户redis key前缀
|
||||||
|
/// </summary>
|
||||||
|
public const string TrackPushKeyPrefix = "TrackPush";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹推送内容配置redis key前缀
|
||||||
|
/// </summary>
|
||||||
|
public const string TrackPushContentKeyPrefix = "TrackPushContent";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹拉取配置信息redis key前缀
|
||||||
|
/// </summary>
|
||||||
|
public const string TrackPullKeyPrefix = "TrackPull";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹拉取配置信息redis key前缀
|
||||||
|
/// </summary>
|
||||||
|
public const string TrackPullContentKeyPrefix = "TrackPullContent";
|
||||||
|
}
|
||||||
27
src/SJZY.Track.Domain/Consts/InterfaceRelayConst.cs
Normal file
27
src/SJZY.Track.Domain/Consts/InterfaceRelayConst.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
namespace SJZY.Track.Domain.Consts;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 接口通常量
|
||||||
|
/// </summary>
|
||||||
|
public class InterfaceRelayConst
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 接口通成功代码
|
||||||
|
/// </summary>
|
||||||
|
public const string SuccessCode = "200";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取轨迹接口代码
|
||||||
|
/// </summary>
|
||||||
|
public const string GetTrackInterfaceCode = "A012";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推送轨迹接口代码
|
||||||
|
/// </summary>
|
||||||
|
public const string PushTrackInterfaceCode = "A024";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新轨迹接口代码
|
||||||
|
/// </summary>
|
||||||
|
public const string TrackUpdateInterfaceCode = "A040";
|
||||||
|
}
|
||||||
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace SJZY.Track.Domain.Dtos.Order
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Domain.Dtos.Order
|
|
||||||
{
|
{
|
||||||
public class GetPageTrackOrderInputVO : PageInfoInput
|
public class GetPageTrackOrderInputVO : PageInfoInput
|
||||||
{
|
{
|
||||||
@ -13,17 +7,11 @@ namespace SJZY.Track.Domain.Dtos.Order
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int SubSystemId { get; set; }
|
public int SubSystemId { get; set; }
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 单号
|
|
||||||
///// </summary>
|
|
||||||
//public List<string>? OrderNos { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当tab选中 0 默认不传 1 直接写死传值 [1,4] 2 传 [2,4]
|
/// 当tab选中 0 全部 1 异常 2 警告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int TabType { get; set; }
|
public int TabType { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 订单类型
|
/// 订单类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -34,10 +22,15 @@ namespace SJZY.Track.Domain.Dtos.Order
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int? CustomerId { get; set; }
|
public int? CustomerId { get; set; }
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 单号
|
||||||
|
///// </summary>
|
||||||
|
//public string? OrderNos { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 单号
|
/// 单号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? OrderNos { get; set; }
|
public List<string>? OrderNos { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建时间开始
|
/// 创建时间开始
|
||||||
@ -133,7 +126,7 @@ namespace SJZY.Track.Domain.Dtos.Order
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 子系统
|
/// 子系统
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string SubSystem { get; set; }
|
public string? SubSystem { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 子系统id
|
/// 子系统id
|
||||||
@ -154,15 +147,5 @@ namespace SJZY.Track.Domain.Dtos.Order
|
|||||||
/// 问题类型名称
|
/// 问题类型名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? QuestionTypeName { get; set; }
|
public string? QuestionTypeName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
|
||||||
/// </summary>
|
|
||||||
public int ProblemDescription { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 问题描述名称
|
|
||||||
/// </summary>
|
|
||||||
public string? ProblemDescriptionName { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
14
src/SJZY.Track.Domain/Dtos/Order/GetTrackCounterVO.cs
Normal file
14
src/SJZY.Track.Domain/Dtos/Order/GetTrackCounterVO.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
namespace SJZY.Track.Domain.Dtos.Order;
|
||||||
|
|
||||||
|
public class GetTrackCounterVO
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 问题类型
|
||||||
|
/// </summary>
|
||||||
|
public int ProblemType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 总条数
|
||||||
|
/// </summary>
|
||||||
|
public int Count { get; set; }
|
||||||
|
}
|
||||||
@ -23,12 +23,17 @@ public class LinkedOrderVO
|
|||||||
public int SubSystemId { get; set; }
|
public int SubSystemId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 订单是否推送完成(异步维护)
|
/// 最新推送轨迹内容id(异步维护)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsPushCompleted { get; set; }
|
public int? LatestPushTrackContentId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 客户id
|
/// 客户id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int CustomId { get; set; }
|
public int CustomId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单是否完成
|
||||||
|
/// </summary>
|
||||||
|
public bool IsCompleted { get; set; }
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
namespace SJZY.Track.Domain.Dtos.Order;
|
namespace SJZY.Track.Domain.Dtos.Order;
|
||||||
|
|
||||||
public class OrderTemplateVO
|
public class OrderWithServiceProviderVO
|
||||||
{
|
{
|
||||||
public string OrderNo { get; set; } = null!;
|
public string OrderNo { get; set; } = null!;
|
||||||
|
|
||||||
@ -9,8 +9,6 @@ public class OrderTemplateVO
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int OrderType { get; set; }
|
public int OrderType { get; set; }
|
||||||
|
|
||||||
public int TemplateId { get; set; }
|
|
||||||
|
|
||||||
public int ServiceProviderId { get; set; }
|
public int ServiceProviderId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
public class MatchTrackContentDto
|
public class MatchTrackContentDto
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容id
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 轨迹内容
|
/// 轨迹内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
18
src/SJZY.Track.Domain/Enums/OrderType.cs
Normal file
18
src/SJZY.Track.Domain/Enums/OrderType.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Domain.Enums;
|
||||||
|
|
||||||
|
public enum OrderType
|
||||||
|
{
|
||||||
|
[Description("干线提单")]
|
||||||
|
干线提单 = 1,
|
||||||
|
|
||||||
|
[Description("小包运单")]
|
||||||
|
小包运单 = 2,
|
||||||
|
|
||||||
|
[Description("箱/袋单")]
|
||||||
|
箱袋单 = 3,
|
||||||
|
|
||||||
|
[Description("FBA订单")]
|
||||||
|
FBA订单 = 4,
|
||||||
|
}
|
||||||
25
src/SJZY.Track.Domain/Enums/TrackProblemType.cs
Normal file
25
src/SJZY.Track.Domain/Enums/TrackProblemType.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Domain.Enums;
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum TrackProblemType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 没问题
|
||||||
|
/// </summary>
|
||||||
|
[Description("无")]
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异常
|
||||||
|
/// </summary>
|
||||||
|
[Description("异常")]
|
||||||
|
Error = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 预警
|
||||||
|
/// </summary>
|
||||||
|
[Description("预警")]
|
||||||
|
Warn = 2,
|
||||||
|
}
|
||||||
@ -1,49 +0,0 @@
|
|||||||
namespace SJZY.Track.Domain;
|
|
||||||
|
|
||||||
public class GlobalConst
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 轨迹明细 es索引名称
|
|
||||||
/// </summary>
|
|
||||||
public const string TrackIndex = "sjzy_track_details";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 轨迹新增/更新 mq订阅名称
|
|
||||||
/// </summary>
|
|
||||||
public const string TrackUpsertSubscribe = "SJZY.Track.TrackUpsert";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 轨迹删除 mq订阅名称
|
|
||||||
/// </summary>
|
|
||||||
public const string TrackDeleteSubscribe = "SJZY.Track.TrackDelete";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 接口通批量轨迹刷新 mq订阅名称
|
|
||||||
/// </summary>
|
|
||||||
public const string TrackRefreshSubscribe = "SJZY.Track.TrackRefresh";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 轨迹新增/更新后触发更新订单轨迹 mq订阅名称
|
|
||||||
/// </summary>
|
|
||||||
public const string UpdateOrderTrackSubscribe = "SJZY.Track.UpdateOrderTrack";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 轨迹删除后触发更新订单轨迹 mq订阅名称
|
|
||||||
/// </summary>
|
|
||||||
public const string DeleteTrackAfterUpdateOrderSubscribe = "SJZY.Track.DeleteTrackAfterUpdateOrder";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 关联订单后补轨迹 mq订阅名称
|
|
||||||
/// </summary>
|
|
||||||
public const string OrderLinkAfterFillTrack = "SJZY.Track.OrderLinkAfterFillTrack";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 轨迹要推送的客户redis key前缀
|
|
||||||
/// </summary>
|
|
||||||
public const string TrackPushKeyPrefix = "TrackPush:";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 轨迹拉取配置信息redis key前缀
|
|
||||||
/// </summary>
|
|
||||||
public const string TrackPullConfigInfoKeyPrefix = "TrackPullConfigInfo:";
|
|
||||||
}
|
|
||||||
@ -48,4 +48,18 @@ public interface IProvideQueries
|
|||||||
/// <param name="trackCodes"></param>
|
/// <param name="trackCodes"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<string>> MapTrackCodesAsync(int upSubSystemId, int subSystemId, params string[] trackCodes);
|
Task<List<string>> MapTrackCodesAsync(int upSubSystemId, int subSystemId, params string[] trackCodes);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据订单模板找对应服务商
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orderNos"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<OrderWithServiceProviderVO>> FindOrderWithServiceProviderAsync(List<string> orderNos);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取服务商下所有单(未完成的)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serviceProvider"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<OrderWithServiceProviderVO>> FindOrderWithServiceProviderAsync(int serviceProvider);
|
||||||
}
|
}
|
||||||
19
src/SJZY.Track.Domain/Queries/ITrackOrderQueries.cs
Normal file
19
src/SJZY.Track.Domain/Queries/ITrackOrderQueries.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using SJZY.Track.Domain.Dtos.Order;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Domain.Queries;
|
||||||
|
|
||||||
|
public interface ITrackOrderQueries
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取分页的轨迹订单
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<UnifyPageResultDto<TrackOrderVO>> GetPageTrackOrder(GetPageTrackOrderInputVO input);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取轨迹各个问题数
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<GetTrackCounterVO>> GetTrackProblemCountsAsync();
|
||||||
|
}
|
||||||
@ -6,6 +6,7 @@ using SJZY.Track.Domain.Dtos.Order;
|
|||||||
using SJZY.Track.Domain.Dtos.TrackDetails;
|
using SJZY.Track.Domain.Dtos.TrackDetails;
|
||||||
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||||
using SJZY.Track.Domain.Queries;
|
using SJZY.Track.Domain.Queries;
|
||||||
|
using SJZY.Track.Domain.VEntities;
|
||||||
|
|
||||||
namespace SJZY.Track.Repository.Queries;
|
namespace SJZY.Track.Repository.Queries;
|
||||||
|
|
||||||
@ -70,6 +71,7 @@ public class ProvideQueries : ISugarRepository, IProvideQueries,
|
|||||||
.Where((x, a, b) => x.OrderId == orderId && b.Code == code)
|
.Where((x, a, b) => x.OrderId == orderId && b.Code == code)
|
||||||
.Select((x, a, b, c) => new MatchTrackContentDto
|
.Select((x, a, b, c) => new MatchTrackContentDto
|
||||||
{
|
{
|
||||||
|
Id = b.Id,
|
||||||
Content = b.Content,
|
Content = b.Content,
|
||||||
EnContent = b.EnContent,
|
EnContent = b.EnContent,
|
||||||
Status = c.Status,
|
Status = c.Status,
|
||||||
@ -104,4 +106,39 @@ public class ProvideQueries : ISugarRepository, IProvideQueries,
|
|||||||
.Select(x => x.TrackContentCode)
|
.Select(x => x.TrackContentCode)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<List<OrderWithServiceProviderVO>> FindOrderWithServiceProviderAsync(List<string> orderNos)
|
||||||
|
{
|
||||||
|
return await Context.Queryable<OrderEntity>()
|
||||||
|
.LeftJoin<OrderTemplateEntity>((a, b) => a.Id == b.OrderId)
|
||||||
|
.LeftJoin<VServiceProviderEntity>((a, b, c) => b.ServiceProviderId == c.Id)
|
||||||
|
.Where(a => !a.IsCompleted && orderNos.Contains(a.OrderNo))
|
||||||
|
.Select((a, b, c) => new OrderWithServiceProviderVO
|
||||||
|
{
|
||||||
|
OrderNo = a.OrderNo,
|
||||||
|
OrderType = a.OrderType,
|
||||||
|
ServiceProviderId = b.ServiceProviderId,
|
||||||
|
ServiceProviderCode = c.Code,
|
||||||
|
SubSystemId = a.SubSystemId
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<OrderWithServiceProviderVO>> FindOrderWithServiceProviderAsync(int serviceProvider)
|
||||||
|
{
|
||||||
|
return await Context.Queryable<OrderEntity>()
|
||||||
|
.RightJoin<OrderTemplateEntity>((a, b) => a.Id == b.OrderId)
|
||||||
|
.LeftJoin<VServiceProviderEntity>((a, b, c) => b.ServiceProviderId == c.Id)
|
||||||
|
.Where((a, b) => b.ServiceProviderId == serviceProvider && !a.IsCompleted)
|
||||||
|
.Select((a, b, c) => new OrderWithServiceProviderVO
|
||||||
|
{
|
||||||
|
OrderNo = a.OrderNo,
|
||||||
|
OrderType = a.OrderType,
|
||||||
|
ServiceProviderId = b.ServiceProviderId,
|
||||||
|
ServiceProviderCode = c.Code,
|
||||||
|
SubSystemId = a.SubSystemId
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
95
src/SJZY.Track.Repository/Queries/TrackOrderQueries.cs
Normal file
95
src/SJZY.Track.Repository/Queries/TrackOrderQueries.cs
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||||
|
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||||
|
using SJZY.Track.Domain.Dtos.Order;
|
||||||
|
using SJZY.Track.Domain.Queries;
|
||||||
|
using SJZY.Track.Domain.VEntities;
|
||||||
|
using SJZY.Track.Repository.VData.Entitys;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Repository.Queries;
|
||||||
|
|
||||||
|
public class TrackOrderQueries : ISugarRepository, ITrackOrderQueries,
|
||||||
|
ITransientDependency
|
||||||
|
{
|
||||||
|
public ISqlSugarClient Context { get; set; }
|
||||||
|
|
||||||
|
public TrackOrderQueries()
|
||||||
|
{
|
||||||
|
Context = SqlsugarScopeBasic.GetContextSafely("default");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取分页的轨迹订单
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<UnifyPageResultDto<TrackOrderVO>> GetPageTrackOrder(GetPageTrackOrderInputVO input)
|
||||||
|
{
|
||||||
|
var pageList = await Context.Queryable<OrderEntity>()
|
||||||
|
.LeftJoin<VExternalSubjectEntity>((a, b) => a.CustomId == b.Id && b.IsDeleted == false)
|
||||||
|
.LeftJoin<VSystemEntity>((a, b, c) => a.SubSystemId == c.Id && c.IsDeleted == false)
|
||||||
|
.WhereIF(input.SubSystemId > 0, (a, b, c) => a.SubSystemId == input.SubSystemId)
|
||||||
|
.WhereIF(!input.OrderNos.IsNullOrEmpty(), (a, b, c) => input.OrderNos!.Contains(a.OrderNo))
|
||||||
|
.WhereIF(input.CreateTimeStart.HasValue && input.CreateTimeEnd.HasValue,
|
||||||
|
(a, b, c) => a.CreateTime >= input.CreateTimeStart && a.CreateTime <= input.CreateTimeEnd)
|
||||||
|
.WhereIF(input.CreateTimeStart.HasValue && (!input.CreateTimeEnd.HasValue),
|
||||||
|
(a, b, c) => a.CreateTime >= input.CreateTimeStart)
|
||||||
|
.WhereIF((!input.CreateTimeStart.HasValue) && input.CreateTimeEnd.HasValue,
|
||||||
|
(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, (a, b, c) => a.QuestionType == input.TabType)
|
||||||
|
.OrderByDescending((a, b, c) => a.CreateTime)
|
||||||
|
.Select((a, b, c) => new TrackOrderVO
|
||||||
|
{
|
||||||
|
Id = a.Id,
|
||||||
|
OrderNumber = a.OrderNo,
|
||||||
|
OrderType = a.OrderType,
|
||||||
|
QuestionType = a.QuestionType,
|
||||||
|
CustomerShortName = b.Abbreviation,
|
||||||
|
CustomerCode = b.Code,
|
||||||
|
CustomerId = a.CustomId,
|
||||||
|
NewestTrackContent = a.LatestTrackContent,
|
||||||
|
NewestTrackEnContent = a.LatestTrackEnContent,
|
||||||
|
NewestTrackPlace = a.LatestTrackPlace,
|
||||||
|
NewestTrackTime = a.LatestTrackTime,
|
||||||
|
IsFinish = a.IsCompleted,
|
||||||
|
CreateTime = a.CreateTime,
|
||||||
|
SubSystem = c.CnName,
|
||||||
|
SubSystemId = c.Id
|
||||||
|
})
|
||||||
|
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||||
|
|
||||||
|
if (pageList.List.Any())
|
||||||
|
{
|
||||||
|
//查询也需要最新的轨迹
|
||||||
|
var orderIds = pageList.List.Select(a => a.Id).ToList();
|
||||||
|
//查询轨迹模版
|
||||||
|
var trackTemplateList = await Context.Queryable<OrderTemplateEntity>()
|
||||||
|
.LeftJoin<TrackTemplateEntity>((a, b) => a.TrackTemplateId == b.Id)
|
||||||
|
.Where((a, b) => orderIds.Contains(a.OrderId))
|
||||||
|
.Select((a, b) => new { a.OrderId, b.Name, TemplateId = b.Id })
|
||||||
|
.ToListAsync();
|
||||||
|
pageList.List.ForEach(a =>
|
||||||
|
{
|
||||||
|
a.TrackTemplateNames = trackTemplateList.Where(b => b.OrderId == a.Id).Select(x => x.Name)
|
||||||
|
.JoinAsString(",");
|
||||||
|
a.TrackTemplateIds = trackTemplateList.Where(b => b.OrderId == a.Id).Where(b => b.TemplateId > 0)
|
||||||
|
.Select(x => x.TemplateId).ToList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return pageList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<GetTrackCounterVO>> GetTrackProblemCountsAsync()
|
||||||
|
{
|
||||||
|
return await Context.Queryable<OrderEntity>()
|
||||||
|
.GroupBy(x => x.QuestionType)
|
||||||
|
.Select(x => new GetTrackCounterVO
|
||||||
|
{
|
||||||
|
ProblemType = x.QuestionType,
|
||||||
|
Count = SqlFunc.AggregateCount(1)
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,25 +1,11 @@
|
|||||||
using SJZY.Track.Domain;
|
using SJZY.Track.Domain;
|
||||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
|
||||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
|
||||||
using SJZY.Track.Domain.Dtos.Order;
|
using SJZY.Track.Domain.Dtos.Order;
|
||||||
using SJZY.Track.Domain.VEntities;
|
|
||||||
using SJZY.Track.Repository.VData.Entitys;
|
|
||||||
using SqlSugar;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Repository.Repositories;
|
namespace SJZY.Track.Repository.Repositories;
|
||||||
|
|
||||||
public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, ITransientDependency
|
public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, ITransientDependency
|
||||||
{
|
{
|
||||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
|
||||||
|
|
||||||
public OrderRepository(
|
|
||||||
ITrackDetailsRepository trackDetailsRepository
|
|
||||||
)
|
|
||||||
{
|
|
||||||
this._trackDetailsRepository = trackDetailsRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task CreateOrderAsync(OrderEntity order)
|
public async Task CreateOrderAsync(OrderEntity order)
|
||||||
{
|
{
|
||||||
using var tran = TransactionHelper.GetReadCommitted();
|
using var tran = TransactionHelper.GetReadCommitted();
|
||||||
@ -80,8 +66,9 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
|||||||
OrderType = b.OrderType,
|
OrderType = b.OrderType,
|
||||||
OrderNo = b.OrderNo,
|
OrderNo = b.OrderNo,
|
||||||
SubSystemId = b.SubSystemId,
|
SubSystemId = b.SubSystemId,
|
||||||
IsPushCompleted = b.IsPushCompleted,
|
LatestPushTrackContentId = b.LatestPushTrackContentId,
|
||||||
CustomId = b.CustomId
|
CustomId = b.CustomId,
|
||||||
|
IsCompleted = b.IsCompleted
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
@ -97,185 +84,4 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 轨迹订单明细
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 根据轨迹订单id获取轨迹明细列表
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="input"></param>
|
|
||||||
///// <returns></returns>
|
|
||||||
//public async Task<List<TrackOrderDetailVO>> GetOrderDetails(GetOrderDetailsInputVO input)
|
|
||||||
//{
|
|
||||||
// return null;
|
|
||||||
//}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 轨迹订单分页
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取分页的轨迹订单
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
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)
|
|
||||||
.LeftJoin<VSystemEntity>((a, b, c) => a.SubSystemId == c.Id && c.IsDeleted == false)
|
|
||||||
.WhereIF(input.SubSystemId > 0, (a, b, c) => a.SubSystemId == input.SubSystemId)
|
|
||||||
.WhereIF(!orderNoList.IsNullOrEmpty(), (a, b, c) => orderNoList.Contains(a.OrderNo))
|
|
||||||
.WhereIF(input.CreateTimeStart.HasValue && input.CreateTimeEnd.HasValue,
|
|
||||||
(a, b, c) => a.CreateTime >= input.CreateTimeStart && a.CreateTime <= input.CreateTimeEnd)
|
|
||||||
.WhereIF(input.CreateTimeStart.HasValue && (!input.CreateTimeEnd.HasValue),
|
|
||||||
(a, b, c) => a.CreateTime >= input.CreateTimeStart)
|
|
||||||
.WhereIF((!input.CreateTimeStart.HasValue) && input.CreateTimeEnd.HasValue,
|
|
||||||
(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
|
|
||||||
{
|
|
||||||
Id = a.Id,
|
|
||||||
OrderNumber = a.OrderNo,
|
|
||||||
OrderType = a.OrderType,
|
|
||||||
OrderTypeName = SqlFunc.IF(a.OrderType == 1).Return("干线提单").ElseIF(a.OrderType == 2).Return("小包运单")
|
|
||||||
.ElseIF(a.OrderType == 3)
|
|
||||||
.Return("箱/袋单").ElseIF(a.OrderType == 4).Return("FBA订单").End(""),
|
|
||||||
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, ","),
|
|
||||||
|
|
||||||
//TrackTemplateIds = SqlFunc.Subqueryable<OrderTemplateEntity>()
|
|
||||||
// .LeftJoin<TrackTemplateEntity>((aa, bb) => aa.TrackTemplateId == bb.Id)
|
|
||||||
// .Where((aa, bb) => a.Id == aa.OrderId).SelectStringJoin((aa, bb) => bb.Id, ","),
|
|
||||||
NewestTrackContent = a.LatestTrackContent,
|
|
||||||
NewestTrackEnContent = a.LatestTrackEnContent,
|
|
||||||
NewestTrackPlace = a.LatestTrackPlace,
|
|
||||||
NewestTrackTime = a.LatestTrackTime,
|
|
||||||
IsFinish = a.IsCompleted,
|
|
||||||
CreateTime = a.CreateTime,
|
|
||||||
SubSystem = c.CnName,
|
|
||||||
SubSystemId = c.Id
|
|
||||||
})
|
|
||||||
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
|
||||||
|
|
||||||
if (pageList.List.Any())
|
|
||||||
{
|
|
||||||
//查询也需要最新的轨迹
|
|
||||||
var orderIds = pageList.List.Select(a => a.Id).ToList();
|
|
||||||
//查询轨迹模版
|
|
||||||
var trackTemplateList = await Context.Queryable<OrderTemplateEntity>()
|
|
||||||
.LeftJoin<TrackTemplateEntity>((a, b) => a.TrackTemplateId == b.Id)
|
|
||||||
.Where((a, b) => orderIds.Contains(a.OrderId))
|
|
||||||
.Select((a, b) => new { OrderId = a.OrderId, Name = b.Name, TemplateId = b.Id })
|
|
||||||
.ToListAsync();
|
|
||||||
var esTrackDetails = await _trackDetailsRepository.GetListAsync(orderIds);
|
|
||||||
pageList.List.ForEach(a =>
|
|
||||||
{
|
|
||||||
var esDetails = esTrackDetails?.Where(b => b.OrderId == a.Id).OrderByDescending(b => b.TrackTime);
|
|
||||||
var trackDetail = esDetails?.FirstOrDefault();
|
|
||||||
if (trackDetail != null)
|
|
||||||
{
|
|
||||||
if (trackDetail.TrackContent != a.NewestTrackContent)
|
|
||||||
{
|
|
||||||
a.NewestTrackContent = trackDetail.TrackContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trackDetail.TrackEnContent != a.NewestTrackEnContent)
|
|
||||||
{
|
|
||||||
a.NewestTrackEnContent = trackDetail.TrackEnContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trackDetail.TrackPlace != a.NewestTrackPlace)
|
|
||||||
{
|
|
||||||
a.NewestTrackPlace = trackDetail.TrackPlace;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trackDetail.TrackTime != a.NewestTrackTime)
|
|
||||||
{
|
|
||||||
a.NewestTrackTime = trackDetail.TrackTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
a.TrackTemplateNames = trackTemplateList.Where(b => b.OrderId == a.Id).Select(a => a.Name)
|
|
||||||
.JoinAsString(",");
|
|
||||||
a.TrackTemplateIds = trackTemplateList.Where(b => b.OrderId == a.Id).Where(b => b.TemplateId>0).Select(a => a.TemplateId).ToList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#region 暂时注释
|
|
||||||
|
|
||||||
//if (pageList.List.Any())
|
|
||||||
//{
|
|
||||||
// var orderIds = pageList.List.Select(a => a.Id);
|
|
||||||
// //查询轨迹模版
|
|
||||||
|
|
||||||
|
|
||||||
// var trackTemplateList = await Context.Queryable<OrderTemplateEntity>()
|
|
||||||
// .LeftJoin<TrackTemplateEntity>((a, b) => a.TrackTemplateId==b.Id)
|
|
||||||
// .Where((a, b) => orderIds.Contains(a.OrderId))
|
|
||||||
// .Select((a, b) => new { OrderId = a.OrderId, Name = b.Name })
|
|
||||||
// .ToListAsync();
|
|
||||||
|
|
||||||
// pageList.List.ForEach(a =>
|
|
||||||
// {
|
|
||||||
// var templateListOfOrderId = trackTemplateList.Where(b => b.OrderId== a.Id);
|
|
||||||
// a.TrackTemplateNames = templateListOfOrderId.Select(c => c.Name).JoinAsString(",");
|
|
||||||
// });
|
|
||||||
//}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
return pageList;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
public async Task<List<OrderTemplateVO>> GetOrderTemplatesAsync(List<string> orderNos)
|
|
||||||
{
|
|
||||||
return await Context.Queryable<OrderEntity>()
|
|
||||||
.LeftJoin<OrderTemplateEntity>((a, b) => a.Id == b.OrderId)
|
|
||||||
.LeftJoin<VServiceProviderEntity>((a, b, c) => b.ServiceProviderId == c.Id)
|
|
||||||
.Where(a => orderNos.Contains(a.OrderNo))
|
|
||||||
.Select((a, b, c) => new OrderTemplateVO
|
|
||||||
{
|
|
||||||
OrderNo = a.OrderNo,
|
|
||||||
OrderType = a.OrderType,
|
|
||||||
TemplateId = b.TrackTemplateId,
|
|
||||||
ServiceProviderId = b.ServiceProviderId,
|
|
||||||
ServiceProviderCode = c.Code,
|
|
||||||
SubSystemId = a.SubSystemId
|
|
||||||
})
|
|
||||||
.ToListAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
|
|||||||
CreateUser = e.Name,
|
CreateUser = e.Name,
|
||||||
UpdateTime = a.UpdateTime,
|
UpdateTime = a.UpdateTime,
|
||||||
UpdateUser = f.Name,
|
UpdateUser = f.Name,
|
||||||
IsFinish= a.IsCompleted
|
IsFinish = a.IsCompleted
|
||||||
})
|
})
|
||||||
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||||
|
|
||||||
@ -97,21 +97,21 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
|
|||||||
public async Task<List<GetTemplateContentAttributeValueVO>> GetTrackContentAttributeValue(GetTemplateContentAttributeValueInputVO input)
|
public async Task<List<GetTemplateContentAttributeValueVO>> GetTrackContentAttributeValue(GetTemplateContentAttributeValueInputVO input)
|
||||||
{
|
{
|
||||||
var list = await Context.Queryable<TrackContentEntity>()
|
var list = await Context.Queryable<TrackContentEntity>()
|
||||||
.LeftJoin<TrackTemplateContentEntity>((a, b) => a.Id==b.TrackContentId&& b.TrackTemplateId>0 && b.IsDeleted==false)
|
.LeftJoin<TrackTemplateContentEntity>((a, b) => a.Id == b.TrackContentId && b.TrackTemplateId > 0 && b.IsDeleted == false)
|
||||||
.LeftJoin<TrackTemplateEntity>((a, b, c) => b.TrackTemplateId==c.Id&& c.IsDeleted==false)
|
.LeftJoin<TrackTemplateEntity>((a, b, c) => b.TrackTemplateId == c.Id && c.IsDeleted == false)
|
||||||
.WhereIF(!input.TrackCodes.IsNullOrEmpty(), (a, b, c) => input.TrackCodes.Contains(a.Code))
|
.WhereIF(!input.TrackCodes.IsNullOrEmpty(), (a, b, c) => input.TrackCodes!.Contains(a.Code))
|
||||||
.WhereIF(input.SubSystemId>0, (a, b, c) => a.SubSystemId==input.SubSystemId)
|
.WhereIF(input.SubSystemId > 0, (a, b, c) => a.SubSystemId == input.SubSystemId)
|
||||||
.WhereIF(!input.TrackTemplateIds.IsNullOrEmpty(), (a, b, c) => input.TrackTemplateIds.Contains(c.Id))
|
.WhereIF(!input.TrackTemplateIds.IsNullOrEmpty(), (a, b, c) => input.TrackTemplateIds!.Contains(c.Id))
|
||||||
.Where((a, b, c) => c.Id>0)
|
.Where((a, b, c) => c.Id > 0)
|
||||||
//.OrderByIF(!input.TrackTemplateIds.IsNullOrEmpty(), (a, b, c) => SqlFunc.IIF(input.TrackTemplateIds.Contains(a.Id), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), c.CreateTime), OrderByType.Desc)
|
//.OrderByIF(!input.TrackTemplateIds.IsNullOrEmpty(), (a, b, c) => SqlFunc.IIF(input.TrackTemplateIds.Contains(a.Id), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), c.CreateTime), OrderByType.Desc)
|
||||||
.Select((a, b, c) => new GetTemplateContentAttributeValueVO
|
.Select((a, b, c) => new GetTemplateContentAttributeValueVO
|
||||||
{
|
{
|
||||||
IsCanDelete=b.IsCanDelete,
|
IsCanDelete = b.IsCanDelete,
|
||||||
IsExternal=b.IsExternal,
|
IsExternal = b.IsExternal,
|
||||||
SubSystemId= a.SubSystemId,
|
SubSystemId = a.SubSystemId,
|
||||||
TrackCode= a.Code,
|
TrackCode = a.Code,
|
||||||
TrackContenId= a.Id,
|
TrackContenId = a.Id,
|
||||||
TrackTemplateId=c.Id
|
TrackTemplateId = c.Id
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@ -125,9 +125,9 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
|
|||||||
public async Task<bool> GetTemplateIsExist(int trackContentId)
|
public async Task<bool> GetTemplateIsExist(int trackContentId)
|
||||||
{
|
{
|
||||||
//var trackTemplateContents = await _trackTemplateContentBasicQuery.GetListAsync(a => a.TrackContentId == input.Id);
|
//var trackTemplateContents = await _trackTemplateContentBasicQuery.GetListAsync(a => a.TrackContentId == input.Id);
|
||||||
var trackContentEntities = await Context.Queryable<TrackContentEntity>().LeftJoin<TrackTemplateContentEntity>((a, b) => a.Id==b.TrackContentId && b.IsDeleted==false)
|
var trackContentEntities = await Context.Queryable<TrackContentEntity>().LeftJoin<TrackTemplateContentEntity>((a, b) => a.Id == b.TrackContentId && b.IsDeleted == false)
|
||||||
.LeftJoin<TrackTemplateEntity>((a, b, c) => b.TrackTemplateId==c.Id&& c.IsDeleted==false)
|
.LeftJoin<TrackTemplateEntity>((a, b, c) => b.TrackTemplateId == c.Id && c.IsDeleted == false)
|
||||||
.Where((a, b, c) => a.Id==trackContentId)
|
.Where((a, b, c) => a.Id == trackContentId)
|
||||||
.Select((a, b, c) => new
|
.Select((a, b, c) => new
|
||||||
{
|
{
|
||||||
TrackContentId = a.Id,
|
TrackContentId = a.Id,
|
||||||
@ -135,7 +135,7 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
|
|||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
if (trackContentEntities.Any(a => a.TemplateId>0))
|
if (trackContentEntities.Any(a => a.TemplateId > 0))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,6 +87,32 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
|||||||
return data.Documents.ToList();
|
return data.Documents.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<TrackDetailsIndex>> GetListAsync(int orderType, List<string> orderNos, string trackCode)
|
||||||
|
{
|
||||||
|
if (orderNos.Count < 1) return new List<TrackDetailsIndex>();
|
||||||
|
|
||||||
|
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)
|
||||||
|
.Field(f => f.TrackPlace)
|
||||||
|
.Field(f => f.TrackTime)
|
||||||
|
.Field(f => f.TrackTimeZone)
|
||||||
|
))
|
||||||
|
.Query(q =>
|
||||||
|
q.Terms(t => t
|
||||||
|
.Field(f => f.OrderNo.Suffix("keyword"))
|
||||||
|
.Terms(orderNos))
|
||||||
|
&& q.Term(f => f.OrderType, orderType)
|
||||||
|
&& q.Term(f => f.TrackCode.Suffix("keyword"), trackCode)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return data.Documents.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<List<TrackDetailsIndex>> GetListAsync(int orderId)
|
public async Task<List<TrackDetailsIndex>> GetListAsync(int orderId)
|
||||||
{
|
{
|
||||||
var data = await Context.SearchAsync<TrackDetailsIndex>(x => x
|
var data = await Context.SearchAsync<TrackDetailsIndex>(x => x
|
||||||
@ -139,6 +165,7 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
|||||||
q.Term(t => t.OrderId, orderId)
|
q.Term(t => t.OrderId, orderId)
|
||||||
&& q.Term(t => t.IsCanDelete, true)
|
&& q.Term(t => t.IsCanDelete, true)
|
||||||
&& q.Terms(t => t.Field(f => f.TrackCode.Suffix("keyword")).Terms(trackCodes)))
|
&& q.Terms(t => t.Field(f => f.TrackCode.Suffix("keyword")).Terms(trackCodes)))
|
||||||
|
.Refresh() // 可选:立即刷新索引使更改立即可见
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!r.IsValid)
|
if (!r.IsValid)
|
||||||
|
|||||||
@ -0,0 +1,41 @@
|
|||||||
|
using Nest;
|
||||||
|
using SJZY.Expand.ABP.Core.Logger;
|
||||||
|
using SJZY.Expand.ElasticSearch.Services;
|
||||||
|
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||||
|
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Repository.Repositories;
|
||||||
|
|
||||||
|
public class TrackPushRecordsRepository : ElasticSearchContextAbstract<TrackDetailsIndex>, ITrackPushRecordsRepository,
|
||||||
|
ITransientDependency
|
||||||
|
{
|
||||||
|
public TrackPushRecordsRepository(ConnectionFactory connectionFactory) : base(connectionFactory)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AddAsync(TrackPushRecordIndex index)
|
||||||
|
{
|
||||||
|
// 按天写入es
|
||||||
|
var r = await Context.IndexAsync(index, request => request
|
||||||
|
.Index(index.IndexName)
|
||||||
|
//.Refresh(Refresh.True) // 可选:立即刷新索引使更改立即可见
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!r.IsValid)
|
||||||
|
{
|
||||||
|
LogHelper.Error($"轨迹推送记录写入es失败,原因:{r.DebugInformation}。");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<TrackPushRecordIndex>> GetTrackPushRecordsAsync(int orderId)
|
||||||
|
{
|
||||||
|
var data = await Context.SearchAsync<TrackPushRecordIndex>(x => x
|
||||||
|
.Query(q =>
|
||||||
|
q.Term(t => t.OrderId, orderId)
|
||||||
|
)
|
||||||
|
.Size(1000)
|
||||||
|
.Sort(s => s.Field(f => f.CreateTime, SortOrder.Descending)));
|
||||||
|
|
||||||
|
return data.Documents.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user