Merge pull request 'S02-轨迹中台' (#62) from S02-轨迹中台 into uat
Reviewed-on: http://192.168.80.50:3000/Dotnet/SJZY.Track.Api/pulls/62
This commit is contained in:
commit
8056603a1d
@ -0,0 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
|
||||
public class BatchDeleteTrackInput : OrderNosInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹code,必填
|
||||
/// </summary>
|
||||
[Required]
|
||||
public List<string> TrackCodes { get; set; } = new();
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
|
||||
public class BatchUpsertTrackInput : OrderNosInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹内容代码
|
||||
/// </summary>
|
||||
[Required]
|
||||
[MaxLength(50)]
|
||||
public string TrackCode { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地
|
||||
/// </summary>
|
||||
[Required]
|
||||
[MaxLength(200)]
|
||||
public string TrackPlace { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时间
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime? TrackTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时区
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Range(-12, 12)]
|
||||
public float? TrackTimeZone { get; set; }
|
||||
}
|
||||
@ -1,4 +1,6 @@
|
||||
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
|
||||
public class DeleteOrderInput : OrderNoInfo
|
||||
{
|
||||
@ -9,5 +11,6 @@ public class DeleteTrackInput : OrderNoInfo
|
||||
/// <summary>
|
||||
/// 轨迹code
|
||||
/// </summary>
|
||||
[Required]
|
||||
public List<string> TrackCodes { get; set; } = new();
|
||||
}
|
||||
@ -32,6 +32,16 @@ namespace SJZY.Track.Application.Contract.Dtos.ProvideServices
|
||||
/// </summary>
|
||||
public int OrderId { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单类型(主数据枚举TrackOrderType)
|
||||
/// </summary>
|
||||
public int OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
public string OrderNo { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹代码
|
||||
/// </summary>
|
||||
|
||||
@ -17,6 +17,26 @@ public class GetPageTrackOrderInput : PageInfoInput
|
||||
/// </summary>
|
||||
public string? OrderNos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// tab标签类型 0 全部, 1 异常 2 预警
|
||||
/// </summary>
|
||||
public int TabType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
public int? TrackOrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户id
|
||||
/// </summary>
|
||||
public int? CustomerId { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 当tab选中 0 默认不传 1 直接写死传值 [1,4] 2 传 [2,4]
|
||||
///// </summary>
|
||||
//public List<int>? QuestionTypeIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间开始
|
||||
/// </summary>
|
||||
@ -73,6 +93,11 @@ public class TrackOrderDto
|
||||
/// </summary>
|
||||
public string? CustomerCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户id
|
||||
/// </summary>
|
||||
public int CustomerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单明细(json)
|
||||
/// </summary>
|
||||
@ -113,5 +138,28 @@ public class TrackOrderDto
|
||||
/// </summary>
|
||||
public string SubSystem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子系统id
|
||||
/// </summary>
|
||||
public int SubSystemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型(主数据枚举TrackQuestionType)
|
||||
/// </summary>
|
||||
public int QuestionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型名称
|
||||
/// </summary>
|
||||
public string? QuestionTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
||||
/// </summary>
|
||||
public int ProblemDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述名称
|
||||
/// </summary>
|
||||
public string? ProblemDescriptionName { get; set; }
|
||||
}
|
||||
@ -2,20 +2,8 @@ using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
|
||||
public class GetTrackInput
|
||||
public class GetTrackInput : OrderNosInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Range(1, int.MaxValue)]
|
||||
public int OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
public List<string> OrderNos { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 时区 +8 +8.25 -8.5 -9
|
||||
/// 不传默认+8
|
||||
|
||||
@ -22,7 +22,11 @@ public class LinkOrderInput
|
||||
[Required]
|
||||
public string OrderNo { get; set; }
|
||||
|
||||
[Required] public int LinkOrderType { get; set; }
|
||||
/// <summary>
|
||||
/// 关联单类型
|
||||
/// </summary>
|
||||
[Required]
|
||||
public int LinkOrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联的单号
|
||||
|
||||
@ -17,4 +17,20 @@ public class OrderNoInfo
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string OrderNo { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class OrderNosInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Range(1, int.MaxValue)]
|
||||
public int OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
[Required]
|
||||
public List<string> OrderNos { get; set; } = new();
|
||||
}
|
||||
@ -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,62 @@
|
||||
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>
|
||||
/// 服务商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; }
|
||||
}
|
||||
@ -45,10 +45,10 @@ public class UpdateOrderInput : OrderNoInfo
|
||||
/// <summary>
|
||||
/// 订单模板(传全量)
|
||||
/// </summary>
|
||||
public List<OrderTemplateInfo>? Templates { get; set; } = new();
|
||||
public List<OrderTemplateInfo> Templates { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 订单航班信息
|
||||
/// </summary>
|
||||
public List<OrderFlightInfo>? FlightInfos { get; set; } = new();
|
||||
public List<OrderFlightInfo> FlightInfos { get; set; } = new();
|
||||
}
|
||||
@ -17,6 +17,7 @@ public class OrderTemplateInfo
|
||||
/// 模板id
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Range(1, Int32.MaxValue)]
|
||||
public int TemplateId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -30,18 +30,4 @@ public class UpsertTrackInput : OrderNoInfo
|
||||
[Required]
|
||||
[Range(-12, 12)]
|
||||
public float? TrackTimeZone { get; set; }
|
||||
}
|
||||
|
||||
public class NotNullAttribute : ValidationAttribute
|
||||
{
|
||||
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return new ValidationResult(ErrorMessage ?? "The field is required.",
|
||||
new[] { validationContext.MemberName });
|
||||
}
|
||||
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
}
|
||||
@ -37,7 +37,7 @@ public class EditTrackPullConfigInput
|
||||
/// <summary>
|
||||
/// 拉取轨迹时区
|
||||
/// </summary>
|
||||
public string? TackTimeZoneName { get; set; }
|
||||
public string? TrackTimeZoneName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 拉取轨迹内容代码
|
||||
@ -59,13 +59,18 @@ public class EditTrackPullConfigInput
|
||||
/// </summary>
|
||||
public string? TrackStatusName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板id
|
||||
/// </summary>
|
||||
public int? TrackTemplateId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 拉取轨迹发生时间
|
||||
/// </summary>
|
||||
public string? TrackTimeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单路径
|
||||
/// </summary>
|
||||
public string? OrderPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹明细路径
|
||||
/// </summary>
|
||||
public string? TrackDetailsPath { get; set; }
|
||||
}
|
||||
@ -1,8 +1,13 @@
|
||||
namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
|
||||
public class UpdateTrackPullContentInput
|
||||
public class EditTrackPullContentInput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 操作类型
|
||||
/// </summary>
|
||||
public OptionTypeNoNull Options { get; set; }
|
||||
|
||||
public int? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商轨迹代码参数值
|
||||
@ -12,7 +17,7 @@ public class UpdateTrackPullContentInput
|
||||
/// <summary>
|
||||
/// 轨迹内容id
|
||||
/// </summary>
|
||||
public int TrackContentId { get; set; }
|
||||
public int? TrackContentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商轨迹内容参数值
|
||||
@ -37,7 +42,7 @@ public class UpdateTrackPullContentInput
|
||||
/// <summary>
|
||||
/// 轨迹拉取配置id
|
||||
/// </summary>
|
||||
public int TrackPullConfigId { get; set; }
|
||||
public int? TrackPullConfigId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商轨迹状态参数值
|
||||
@ -0,0 +1,19 @@
|
||||
namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
|
||||
public class TrackPullConfigDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务商拉取频率(分钟)
|
||||
/// </summary>
|
||||
public int PullInterval { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商id
|
||||
/// </summary>
|
||||
public int ServiceProviderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子系统id
|
||||
/// </summary>
|
||||
public int SubSystemId { get; set; }
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
|
||||
public class TrackPullContentConfigDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹内容代码
|
||||
/// </summary>
|
||||
public string TrackContentCode { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 服务商轨迹状态参数值
|
||||
/// </summary>
|
||||
public string? TrackStatusValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商轨迹代码参数值
|
||||
/// </summary>
|
||||
public string? TrackContentCodeValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商轨迹内容参数值
|
||||
/// </summary>
|
||||
public string? TrackContentValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹关键词(正向),多个逗分隔
|
||||
/// </summary>
|
||||
public string? TrackKeyword { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹关键词(反向),多个逗分隔
|
||||
/// </summary>
|
||||
public string? TrackKeywordReverse { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地参数值(主数据枚举)
|
||||
/// </summary>
|
||||
public int? TrackPlaceValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹时区GMT值
|
||||
/// </summary>
|
||||
public float? TrackTimeZoneValue { get; set; }
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
|
||||
public class TrackPullParamConfigDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 单号参数名
|
||||
/// </summary>
|
||||
public string OrderNoName { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹时区参数名
|
||||
/// </summary>
|
||||
public string? TrackTimeZoneName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹代码参数名
|
||||
/// </summary>
|
||||
public string? TrackContentCodeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容参数名
|
||||
/// </summary>
|
||||
public string? TrackContentName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地参数名
|
||||
/// </summary>
|
||||
public string? TrackPlaceName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态参数名
|
||||
/// </summary>
|
||||
public string? TrackStatusName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时间参数名
|
||||
/// </summary>
|
||||
public string? TrackTimeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单数组路径
|
||||
/// </summary>
|
||||
public string OrderPath { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹明细数组路径
|
||||
/// </summary>
|
||||
public string TrackDetailsPath { get; set; } = null!;
|
||||
}
|
||||
@ -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,16 @@
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
|
||||
namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
|
||||
public class TrackRefreshDto : OrderNoInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务商id
|
||||
/// </summary>
|
||||
public int ServiceProviderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子系统id
|
||||
/// </summary>
|
||||
public int SubSystemId { get; set; }
|
||||
}
|
||||
@ -5,7 +5,7 @@ public class EditTrackPushConfigInput
|
||||
/// <summary>
|
||||
/// 客户id
|
||||
/// </summary>
|
||||
public int CustomId { get; set; }
|
||||
public int? CustomId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 推送扩展字段
|
||||
@ -17,7 +17,7 @@ public class EditTrackPushConfigInput
|
||||
/// <summary>
|
||||
/// 是否自动推送
|
||||
/// </summary>
|
||||
public bool IsAutoPush { get; set; }
|
||||
public bool? IsAutoPush { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作类型
|
||||
@ -32,17 +32,17 @@ public class EditTrackPushConfigInput
|
||||
/// <summary>
|
||||
/// 服务商id
|
||||
/// </summary>
|
||||
public int ServiceProviderId { get; set; }
|
||||
public int? ServiceProviderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子系统id
|
||||
/// </summary>
|
||||
public int SubSystemId { get; set; }
|
||||
public int? SubSystemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 推送轨迹时区
|
||||
/// </summary>
|
||||
public string? TackTimeZoneName { get; set; }
|
||||
public string? TrackTimeZoneName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 推送轨迹内容代码
|
||||
@ -69,13 +69,18 @@ public class EditTrackPushConfigInput
|
||||
/// </summary>
|
||||
public string? TrackStatusName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板id
|
||||
/// </summary>
|
||||
public List<int>? TrackTemplateIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 推送轨迹发生时间
|
||||
/// </summary>
|
||||
public string? TrackTimeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否支持更新
|
||||
/// </summary>
|
||||
public bool? IsCanUpdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否支持删除
|
||||
/// </summary>
|
||||
public bool? IsCanDelete { get; set; }
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
namespace SJZY.Track.Application.Contract.Events;
|
||||
|
||||
public class OrderLinkAfterFillTrackEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 关联订单id
|
||||
/// </summary>
|
||||
public int OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子系统id
|
||||
/// </summary>
|
||||
public int SubSystemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联订单
|
||||
/// </summary>
|
||||
public List<int> LinkedOrderIds { get; set; } = null!;
|
||||
}
|
||||
@ -20,9 +20,9 @@ public class TrackUpsertEvent : UpsertTrackInput
|
||||
public int SubSystemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单是否推送完成(异步维护)
|
||||
/// 最新推送轨迹内容id(异步维护)
|
||||
/// </summary>
|
||||
public bool IsPushCompleted { get; set; }
|
||||
public int? LatestPushTrackContentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上游子系统id
|
||||
|
||||
@ -7,11 +7,16 @@ public class UpdateOrderTrackEvent
|
||||
/// </summary>
|
||||
public int OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否删除引起的更新
|
||||
/// </summary>
|
||||
public bool IsDelete { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 此次发生的轨迹是否意味完成
|
||||
/// </summary>
|
||||
public bool IsCompleted { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容
|
||||
/// </summary>
|
||||
@ -21,7 +26,7 @@ public class UpdateOrderTrackEvent
|
||||
/// 轨迹内容英文
|
||||
/// </summary>
|
||||
public string TrackEnContent { get; set; } = null!;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地
|
||||
/// </summary>
|
||||
@ -31,9 +36,14 @@ public class UpdateOrderTrackEvent
|
||||
/// 轨迹发生时间
|
||||
/// </summary>
|
||||
public DateTime TrackTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹时区
|
||||
/// </summary>
|
||||
public float TrackTimeZone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹代码
|
||||
/// </summary>
|
||||
public string TrackCode { get; set; } = null!;
|
||||
}
|
||||
@ -4,7 +4,9 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Version>0.0.2</Version>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<Version>1.0.0</Version>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SJZY.Expand.ABP.Common" Version="7.0.11" />
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using Volo.Abp;
|
||||
|
||||
namespace SJZY.Track.Application.Contract.Services;
|
||||
|
||||
public interface IOrderService : IRemoteService
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建订单,订单已存在则视为更新
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> UpsertAsync(UpsertOrderInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 删除订单
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleteOrderAsync(DeleteOrderInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 关联订单
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> LinkOrderAsync(LinkOrderInput input);
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
|
||||
namespace SJZY.Track.Application.Contract.Services;
|
||||
|
||||
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>
|
||||
/// <param name="subSystemId">子系统id</param>
|
||||
/// <param name="serviceProviderId">服务商id</param>
|
||||
/// <returns></returns>
|
||||
Task<TrackPullParamWithContentConfigDto> GetPullParamWithContentConfigAsync(int subSystemId, int serviceProviderId);
|
||||
|
||||
/// <summary>
|
||||
/// 设置拉取配置缓存
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="subSystemId">子系统id</param>
|
||||
/// <param name="serviceProviderId">服务商id</param>
|
||||
/// <returns></returns>
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// 判断客户是否需要推送
|
||||
/// 获取服务商拉取配置
|
||||
/// </summary>
|
||||
/// <param name="customId"></param>
|
||||
/// <param name="subSystemId">子系统id</param>
|
||||
/// <param name="customId">服务商id</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsPushAsync(int customId);
|
||||
Task<List<TrackPushContentConfigDto>> GetPushContentConfigsAsync(int subSystemId, int customId);
|
||||
|
||||
/// <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="isPush"></param>
|
||||
Task UpdateAsync(int customId, bool isPush);
|
||||
/// <param name="trackContentId"></param>
|
||||
/// <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);
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using Volo.Abp;
|
||||
|
||||
namespace SJZY.Track.Application.Contract.Services;
|
||||
|
||||
public interface ITrackService : IRemoteService
|
||||
{
|
||||
/// <summary>
|
||||
/// 新增/更新订单轨迹接口
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> UpsertTrackAsync(UpsertTrackInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 删除轨迹
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleteTrackAsync(DeleteTrackInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除轨迹
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> BatchDeleteTrackAsync(BatchDeleteTrackInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 根据订单号获取轨迹
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<GetTrackOutput>> QueryAsync(GetTrackInput input);
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
using AutoMapper;
|
||||
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||
using SJZY.Track.Domain.Dtos.TrackPull;
|
||||
using Volo.Abp.AutoMapper;
|
||||
|
||||
namespace SJZY.Track.Application.AutoMapper;
|
||||
@ -12,8 +13,10 @@ public class TrackPullAutoMapperProfile : Profile
|
||||
CreateMap<EditTrackPullConfigInput, TrackPullConfigEntity>(MemberList.None);
|
||||
CreateMap<EditTrackPullConfigInput, TrackPushPullParamsConfigEntity>(MemberList.None).Ignore(dest => dest.Id)
|
||||
.ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => false));
|
||||
CreateMap<UpdateTrackPullContentInput, TrackPullContentConfigEntity>(MemberList.None)
|
||||
CreateMap<EditTrackPullContentInput, TrackPullContentConfigEntity>(MemberList.None)
|
||||
.ForMember(dest => dest.TrackKeyword, opt => opt.MapFrom(src => string.Join(',', src.TrackKeywords)))
|
||||
.ForMember(dest => dest.TrackKeywordReverse, opt => opt.MapFrom(src => string.Join(',', src.TrackKeywordReverses)));
|
||||
CreateMap<GetTrackPullConfigDetailOutputVO, TrackPullParamConfigDto>(MemberList.None);
|
||||
CreateMap<GetTrackPullContentListCacheVO, TrackPullContentConfigDto>(MemberList.None);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using AutoMapper;
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Application.Contract.Dtos.TrackPush;
|
||||
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||
@ -10,10 +11,11 @@ public class TrackPushAutoMapperProfile : Profile
|
||||
{
|
||||
public TrackPushAutoMapperProfile()
|
||||
{
|
||||
CreateMap<EditTrackPushConfigInput, TrackPushConfigEntity>(MemberList.None)
|
||||
.ForMember(dest => dest.TrackTemplateId, opt => opt.MapFrom(source => string.Join(',', source.TrackTemplateIds)));
|
||||
CreateMap<EditTrackPushConfigInput, TrackPushConfigEntity>(MemberList.None);
|
||||
CreateMap<EditTrackPushConfigInput, TrackPushPullParamsConfigEntity>(MemberList.None).Ignore(dest => dest.Id)
|
||||
.ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => true));
|
||||
CreateMap<EditTrackPushContentInput, TrackPushContentConfigEntity>(MemberList.None);
|
||||
CreateMap<TrackPushContentConfigEntity, TrackPushContentConfigDto>(MemberList.None)
|
||||
.ForMember(dest => dest.OrderType, opt => opt.MapFrom(source => source.OrderNoType));
|
||||
}
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
using DotNetCore.CAP;
|
||||
using Newtonsoft.Json;
|
||||
using SJZY.InterfaceRelay.Application.Contracts;
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.EventHandlers;
|
||||
|
||||
public class InterfaceRelayTrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly IProvideQueries _provideQueries;
|
||||
|
||||
public InterfaceRelayTrackRefreshEventHandler(IOrderRepository orderRepository, IProvideQueries provideQueries)
|
||||
{
|
||||
_orderRepository = orderRepository;
|
||||
_provideQueries = provideQueries;
|
||||
}
|
||||
|
||||
[CapSubscribe(GlobalConst.InterfaceRelayTrackRefreshSubscribe)]
|
||||
public async Task ConsumerAsync(InterfaceRelayTrackRefreshEvent @event)
|
||||
{
|
||||
if (@event.RequestParams is List<OrderNoInfo> requestParams)
|
||||
{
|
||||
var orderNos = requestParams.Select(x => x.OrderNo).ToList();
|
||||
|
||||
// tips:attach返回的是服务商id,必有
|
||||
var pullContentConfigs = await _provideQueries.GetPullContentConfigsAsync(int.Parse(@event.Attach));
|
||||
|
||||
// 轨迹清洗入库
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
using DotNetCore.CAP;
|
||||
using SJZY.Track.Application.Contract.Events;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.EventHandlers;
|
||||
|
||||
public class OrderLinkAfterFillTrackHandler : ITransientDependency, ICapSubscribe
|
||||
{
|
||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||
private readonly ICapPublisher _capPublisher;
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
|
||||
public OrderLinkAfterFillTrackHandler(ITrackDetailsRepository trackDetailsRepository, ICapPublisher capPublisher,
|
||||
IOrderRepository orderRepository)
|
||||
{
|
||||
_trackDetailsRepository = trackDetailsRepository;
|
||||
_capPublisher = capPublisher;
|
||||
_orderRepository = orderRepository;
|
||||
}
|
||||
|
||||
[CapSubscribe(GlobalConst.OrderLinkAfterFillTrack)]
|
||||
public async Task ConsumerAsync(OrderLinkAfterFillTrackEvent @event)
|
||||
{
|
||||
var tracks = await _trackDetailsRepository.GetListAsync(@event.OrderId);
|
||||
|
||||
|
||||
foreach (var linkOrderId in @event.LinkedOrderIds)
|
||||
{
|
||||
var order = await _orderRepository.GetFirstAsync(x =>
|
||||
x.Id == linkOrderId, x => new
|
||||
{
|
||||
x.OrderType, x.OrderNo, x.CustomId, x.LatestPushTrackContentId, x.SubSystemId
|
||||
});
|
||||
|
||||
if (order == default) continue;
|
||||
|
||||
// 补轨迹
|
||||
foreach (var track in tracks)
|
||||
{
|
||||
var fillTrackEvent = new TrackUpsertEvent
|
||||
{
|
||||
OrderType = order.OrderType,
|
||||
OrderNo = order.OrderNo,
|
||||
TrackCode = track.TrackCode,
|
||||
TrackPlace = track.TrackPlace,
|
||||
TrackTime = track.TrackTime,
|
||||
TrackTimeZone = track.TrackTimeZone,
|
||||
OrderId = linkOrderId,
|
||||
CustomId = order.CustomId,
|
||||
SubSystemId = order.SubSystemId,
|
||||
LatestPushTrackContentId = order.LatestPushTrackContentId,
|
||||
UpSubSystemId = @event.SubSystemId,
|
||||
};
|
||||
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, fillTrackEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -29,7 +29,7 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
|
||||
{
|
||||
if (@event.Visited.Contains(@event.OrderId))
|
||||
{
|
||||
LogHelper.Error($"轨迹订单循环依赖预警:{@event.Visited.JoinAsString(",")}");
|
||||
LogHelper.Error($"删除轨迹订单时,发现循环依赖:{@event.Visited.JoinAsString(",")}");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -56,7 +56,31 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
|
||||
private async Task DeleteTrackAsync(TrackDeleteEvent @event)
|
||||
{
|
||||
// 删除轨迹
|
||||
await _trackDetailsRepository.DeleteTrackAsync(@event.OrderId, @event.TrackCodes);
|
||||
var isOk = await _trackDetailsRepository.DeleteTrackAsync(@event.OrderId, @event.TrackCodes);
|
||||
|
||||
// 触发订单主表更新事件
|
||||
if (isOk)
|
||||
{
|
||||
var track = await _trackDetailsRepository.GetLatestAsync(@event.OrderId);
|
||||
var updateOrderEvent = track == default
|
||||
? new UpdateOrderTrackEvent
|
||||
{
|
||||
OrderId = @event.OrderId,
|
||||
IsDelete = true
|
||||
}
|
||||
: new UpdateOrderTrackEvent
|
||||
{
|
||||
OrderId = @event.OrderId,
|
||||
IsCompleted = track.IsCompleted,
|
||||
TrackContent = track.TrackContent,
|
||||
TrackEnContent = track.TrackEnContent,
|
||||
TrackPlace = track.TrackPlace,
|
||||
TrackTime = track.TrackTime,
|
||||
TrackTimeZone = track.TrackTimeZone,
|
||||
IsDelete = true
|
||||
};
|
||||
await _capPublisher.PublishAsync(GlobalConst.UpdateOrderTrackSubscribe, updateOrderEvent);
|
||||
}
|
||||
|
||||
// 根据订单关联关系异步向下刷
|
||||
var linkedOrders = await _orderRepository.GetLinkedOrdersAsync(@event.OrderId);
|
||||
|
||||
@ -0,0 +1,199 @@
|
||||
using System.Diagnostics;
|
||||
using System.Linq.Expressions;
|
||||
using DotNetCore.CAP;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
using SJZY.InterfaceRelay.Application.Contracts;
|
||||
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
using SJZY.Track.Application.Contract.Events;
|
||||
using SJZY.Track.Application.Contract.Services;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Enums;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.EventHandlers;
|
||||
|
||||
public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly ICapPublisher _capPublisher;
|
||||
private readonly ITrackPullCacheService _trackPullCacheService;
|
||||
|
||||
public TrackRefreshEventHandler(IOrderRepository orderRepository,
|
||||
ICapPublisher capPublisher, ITrackPullCacheService trackPullCacheService)
|
||||
{
|
||||
_orderRepository = orderRepository;
|
||||
_capPublisher = capPublisher;
|
||||
_trackPullCacheService = trackPullCacheService;
|
||||
}
|
||||
|
||||
[CapSubscribe(GlobalConst.TrackRefreshSubscribe)]
|
||||
public async Task ConsumerAsync(InterfaceRelayForwardReplayEvent @event)
|
||||
{
|
||||
// tips:attach返回的是服务商id,必有
|
||||
var refreshDto = JsonConvert.DeserializeObject<List<TrackRefreshDto>>(@event.RequestParams)?.FirstOrDefault();
|
||||
if (refreshDto is null) return;
|
||||
var config =
|
||||
await _trackPullCacheService.GetPullParamWithContentConfigAsync(refreshDto.SubSystemId,
|
||||
refreshDto.ServiceProviderId);
|
||||
|
||||
var data = JObject.Parse(@event.Data.ToString()!);
|
||||
var orderToken = data[config.ParamConfig.OrderPath];
|
||||
if (orderToken is JArray orderTokens)
|
||||
{
|
||||
foreach (var token in orderTokens)
|
||||
{
|
||||
await HandleOrderAsync(token, config, refreshDto.OrderType);
|
||||
}
|
||||
}
|
||||
else if (orderToken is JObject)
|
||||
{
|
||||
await HandleOrderAsync(orderToken, config, refreshDto.OrderType);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleOrderAsync(JToken orderToken, TrackPullParamWithContentConfigDto paramWithContentConfig,
|
||||
int orderType)
|
||||
{
|
||||
var paramConfig = paramWithContentConfig.ParamConfig;
|
||||
var orderNo = orderToken[paramConfig.OrderNoName]?.Value<string>();
|
||||
if (orderNo.IsNullOrWhiteSpace()) return;
|
||||
|
||||
var order = await _orderRepository.GetFirstAsync(x =>
|
||||
x.OrderType == orderType && x.OrderNo == orderNo, x => new
|
||||
{
|
||||
x.Id, x.SubSystemId, x.LatestPushTrackContentId, x.CustomId
|
||||
});
|
||||
if (order == default) return;
|
||||
|
||||
var trackToken = orderToken[paramConfig.TrackDetailsPath];
|
||||
if (trackToken is null) return;
|
||||
var trackUpsertEvent = new TrackUpsertEvent
|
||||
{
|
||||
OrderId = order.Id,
|
||||
SubSystemId = order.SubSystemId,
|
||||
LatestPushTrackContentId = order.LatestPushTrackContentId,
|
||||
CustomId = order.CustomId,
|
||||
OrderType = orderType,
|
||||
OrderNo = orderNo!,
|
||||
};
|
||||
|
||||
if (trackToken is JArray trackTokens)
|
||||
{
|
||||
foreach (var item in trackTokens)
|
||||
{
|
||||
await HandleTrackAsync(item, paramWithContentConfig, trackUpsertEvent);
|
||||
}
|
||||
}
|
||||
else if (orderToken is JObject)
|
||||
{
|
||||
await HandleTrackAsync(orderToken, paramWithContentConfig, trackUpsertEvent);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleTrackAsync(JToken trackToken, TrackPullParamWithContentConfigDto paramWithContentConfig,
|
||||
TrackUpsertEvent @event)
|
||||
{
|
||||
var trackUpsertEvent = @event.DeepCopy();
|
||||
var paramConfig = paramWithContentConfig.ParamConfig;
|
||||
var contentConfigs = paramWithContentConfig.ContentConfigs;
|
||||
TrackPullContentConfigDto? matchedContentConfig = null;
|
||||
|
||||
// 1、匹配轨迹代码
|
||||
if (paramConfig.TrackContentCodeName != null)
|
||||
{
|
||||
var trackCode = trackToken[paramConfig.TrackContentCodeName]?.Value<string>();
|
||||
if (!trackCode.IsNullOrWhiteSpace())
|
||||
{
|
||||
matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackContentCodeValue == trackCode);
|
||||
}
|
||||
}
|
||||
// 2、匹配轨迹状态
|
||||
else if (paramConfig.TrackStatusName != null)
|
||||
{
|
||||
var trackStatus = trackToken[paramConfig.TrackStatusName]?.Value<string>();
|
||||
if (!trackStatus.IsNullOrWhiteSpace())
|
||||
{
|
||||
matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackStatusValue == trackStatus);
|
||||
}
|
||||
}
|
||||
// 3、匹配轨迹内容
|
||||
else if (paramConfig.TrackContentName != null)
|
||||
{
|
||||
var trackContent = trackToken[paramConfig.TrackContentName]?.Value<string>();
|
||||
if (!trackContent.IsNullOrWhiteSpace())
|
||||
{
|
||||
Debug.Assert(trackContent != null, nameof(trackContent) + " != null");
|
||||
matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackContentValue == trackContent);
|
||||
|
||||
// 按关键字分析轨迹内容
|
||||
if (matchedContentConfig is null)
|
||||
{
|
||||
foreach (var contentConfig in contentConfigs)
|
||||
{
|
||||
foreach (var keyword in contentConfig.TrackKeyword?.Split(',') ?? Enumerable.Empty<string>())
|
||||
{
|
||||
if (trackContent.Contains(keyword, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
matchedContentConfig = contentConfig;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedContentConfig is null) continue;
|
||||
|
||||
foreach (var keyword in contentConfig.TrackKeywordReverse?.Split(',') ??
|
||||
Enumerable.Empty<string>())
|
||||
{
|
||||
if (trackContent.Contains(keyword, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
matchedContentConfig = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedContentConfig is null) return;
|
||||
|
||||
// 轨迹发生地
|
||||
var trackPlace = paramConfig.TrackPlaceName == null
|
||||
? null
|
||||
: trackToken[paramConfig.TrackPlaceName]?.Value<string>();
|
||||
if (trackPlace.IsNullOrWhiteSpace())
|
||||
{
|
||||
Expression<Func<OrderEntity, string?>> resultExpression =
|
||||
(TrackLocationValue?)matchedContentConfig.TrackPlaceValue switch
|
||||
{
|
||||
TrackLocationValue.ArrivalPort => x => x.ArrivalPort,
|
||||
TrackLocationValue.ArriveCity => x => x.ArrivalCity,
|
||||
TrackLocationValue.ArrivalCountry => x => x.ArrivalCountry,
|
||||
TrackLocationValue.LeavePort => x => x.LeavePort,
|
||||
TrackLocationValue.LeaveCity => x => x.LeaveCity,
|
||||
TrackLocationValue.LeaveCountry => x => x.LeaveCountry,
|
||||
_ => x => x.LeaveCountry
|
||||
};
|
||||
trackPlace = await _orderRepository.GetFirstAsync(x =>
|
||||
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.TrackPlace = trackPlace ?? "CN";
|
||||
trackUpsertEvent.TrackTime = trackTime ?? DateTime.Now;
|
||||
trackUpsertEvent.TrackTimeZone = trackTimeZone ?? matchedContentConfig.TrackTimeZoneValue ?? 8;
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, trackUpsertEvent);
|
||||
}
|
||||
}
|
||||
@ -68,6 +68,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
var orderIsCompleted = false;
|
||||
if (track == default)
|
||||
{
|
||||
//todo:可以优化
|
||||
// 根据轨迹code在订单模板内容中寻找匹配的
|
||||
var trackContent = await _provideQueries.MatchTrackContentAsync(@event.OrderId, @event.TrackCode);
|
||||
if (trackContent == default)
|
||||
@ -87,6 +88,8 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
TrackStatus = trackContent.Status,
|
||||
TrackCode = @event.TrackCode,
|
||||
TrackContent = trackContent.Content,
|
||||
TrackContentId = trackContent.Id,
|
||||
IsCompleted = orderIsCompleted,
|
||||
TrackEnContent = trackContent.EnContent,
|
||||
TrackPlace = @event.TrackPlace,
|
||||
TrackTime = @event.TrackTime!.Value,
|
||||
@ -95,12 +98,6 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
CreateUser = CurrentUserRequest.CurrentUser.Name,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
|
||||
// todo:推送只做新增的,更新和删除的不做先
|
||||
if (!@event.IsPushCompleted && await _trackPushCacheService.IsPushAsync(@event.CustomId))
|
||||
{
|
||||
//await PushTrack();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -111,13 +108,24 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
track.UpdateTime = DateTime.Now;
|
||||
}
|
||||
|
||||
// upsert es轨迹
|
||||
await _trackDetailsRepository.UpsertAsync(track);
|
||||
|
||||
// 触发轨迹推送事件
|
||||
var content = await _trackPushCacheService.InferNextPushContentOrNullAsync(
|
||||
@event.SubSystemId, @event.CustomId, @event.LatestPushTrackContentId);
|
||||
if (content != default && content.TrackContentId == track.TrackContentId &&
|
||||
content.OrderType == @event.OrderType)
|
||||
{
|
||||
//await PushTrack(content);
|
||||
}
|
||||
|
||||
// 触发订单主表更新事件
|
||||
await _capPublisher.PublishAsync(GlobalConst.UpdateOrderTrackSubscribe, new UpdateOrderTrackEvent
|
||||
{
|
||||
OrderId = track.OrderId,
|
||||
IsCompleted = orderIsCompleted,
|
||||
TrackCode = track.TrackCode,
|
||||
TrackContent = track.TrackContent,
|
||||
TrackEnContent = track.TrackEnContent,
|
||||
TrackPlace = track.TrackPlace,
|
||||
@ -134,7 +142,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
nextEvent.OrderType = linkedOrder.OrderType;
|
||||
nextEvent.OrderNo = linkedOrder.OrderNo;
|
||||
nextEvent.SubSystemId = linkedOrder.SubSystemId;
|
||||
nextEvent.IsPushCompleted = linkedOrder.IsPushCompleted;
|
||||
nextEvent.LatestPushTrackContentId = linkedOrder.LatestPushTrackContentId;
|
||||
nextEvent.CustomId = linkedOrder.CustomId;
|
||||
nextEvent.UpSubSystemId = @event.SubSystemId;
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, nextEvent);
|
||||
|
||||
@ -20,16 +20,39 @@ public class UpdateOrderTrackEventHandler : ITransientDependency, ICapSubscribe
|
||||
var order = await _orderRepository.GetFirstAsync(x => x.Id == @event.OrderId);
|
||||
if (order == default) return;
|
||||
|
||||
if (order.IsCompleted) return;
|
||||
if (@event.IsDelete)
|
||||
{
|
||||
if (@event.TrackTime == default)
|
||||
{
|
||||
if (order.LatestTrackTime == null) return;
|
||||
|
||||
// 删除全部轨迹导致的重置行为
|
||||
// tips:订单是支持从已完成态到未完成态的
|
||||
order.ResetTrackInfo();
|
||||
|
||||
await _orderRepository.UpdateAsync(order);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 删除引发的回退更新
|
||||
if (order.LatestTrackTime != null &&
|
||||
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) ==
|
||||
@event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone))) return;
|
||||
}
|
||||
else // upsert引发的更新
|
||||
{
|
||||
if (order.LatestTrackTime != null &&
|
||||
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) >
|
||||
@event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone))) return;
|
||||
}
|
||||
|
||||
order.IsCompleted = @event.IsCompleted;
|
||||
order.LatestTrackContent = @event.TrackContent;
|
||||
order.LatestTrackEnContent = @event.TrackEnContent;
|
||||
order.LatestTrackPlace = @event.TrackPlace;
|
||||
order.LatestTrackTime = @event.TrackTime;
|
||||
order.LatestTrackTimeZone = @event.TrackTimeZone;
|
||||
if (@event.IsCompleted) order.IsCompleted = true;
|
||||
else if (order.LatestTrackTime != null &&
|
||||
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) >
|
||||
@event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone))) return;
|
||||
|
||||
await _orderRepository.UpdateColumnAsync(order, x => new
|
||||
{
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SJZY.InterfaceRelay.Application.Contracts" Version="7.1.2" />
|
||||
<PackageReference Include="SJZY.InterfaceRelay.Application.Contracts" Version="7.1.6"/>
|
||||
<PackageReference Include="Volo.Abp.Http.Client" Version="7.0.2" />
|
||||
<PackageReference Include="Volo.Abp.FluentValidation" Version="7.0.2" />
|
||||
<PackageReference Include="SJZY.UserCenter.HttpApi" Version="3.0.3-alpha8" />
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using DotNetCore.CAP;
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Application.Contract.Events;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
|
||||
@ -7,35 +9,31 @@ namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
/// <summary>
|
||||
/// 订单关联服务
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "提供接口")]
|
||||
[Route("/ProviderService")]
|
||||
public class OrderLinkService : ApplicationService
|
||||
public partial class OrderService
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly IBasicQuery<OrderLinkEntity> _orderLinkQuery;
|
||||
|
||||
public OrderLinkService(IBasicQuery<OrderLinkEntity> orderLinkQuery, IOrderRepository orderRepository)
|
||||
{
|
||||
_orderLinkQuery = orderLinkQuery;
|
||||
_orderRepository = orderRepository;
|
||||
}
|
||||
private readonly ICapPublisher _capPublisher;
|
||||
|
||||
/// <summary>
|
||||
/// 关联订单
|
||||
/// 关联、解除关联订单
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessException"></exception>
|
||||
[HttpPost("Order/Link")]
|
||||
public async Task<bool> LinkOrderAsync(LinkOrderInput input)
|
||||
{
|
||||
var orderId = await _orderRepository.GetFirstAsync(x =>
|
||||
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => x.Id);
|
||||
if (orderId == default)
|
||||
var order = await _orderRepository.GetFirstAsync(x =>
|
||||
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new
|
||||
{
|
||||
x.Id, x.SubSystemId
|
||||
});
|
||||
if (order == default)
|
||||
{
|
||||
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
|
||||
}
|
||||
|
||||
//todo:循环关联?
|
||||
//tips:循环关联问题再消费时解决
|
||||
if (input.OrderType == input.LinkOrderType)
|
||||
{
|
||||
throw new BusinessException(message: "不能同级关联");
|
||||
@ -52,10 +50,23 @@ public class OrderLinkService : ApplicationService
|
||||
if (!input.IsLink) return await UnLinkOrderAsync(input);
|
||||
|
||||
// 关联订单
|
||||
return await DoLinkOrderAsync(input, orderId);
|
||||
var linkedOrderIds = await DoLinkOrderAsync(input, order.Id);
|
||||
|
||||
// 补轨迹
|
||||
if (linkedOrderIds.Count > 0)
|
||||
{
|
||||
await _capPublisher.PublishAsync(GlobalConst.OrderLinkAfterFillTrack, new OrderLinkAfterFillTrackEvent
|
||||
{
|
||||
OrderId = order.Id,
|
||||
SubSystemId = order.SubSystemId,
|
||||
LinkedOrderIds = linkedOrderIds,
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task<bool> DoLinkOrderAsync(LinkOrderInput input, int orderId)
|
||||
private async Task<List<int>> DoLinkOrderAsync(LinkOrderInput input, int orderId)
|
||||
{
|
||||
// 获取已关联的订单
|
||||
var linkOrderNos = await _orderLinkQuery.GetListAsync(x =>
|
||||
@ -70,6 +81,8 @@ public class OrderLinkService : ApplicationService
|
||||
x.OrderType == input.LinkOrderType && noLinkOrderNos.Contains(x.OrderNo),
|
||||
x => new { x.Id, x.OrderNo });
|
||||
|
||||
if (canLinkOrders.Count == 0) return new List<int>();
|
||||
|
||||
await _orderRepository.LinkOrderAsync(canLinkOrders.Select(x => new OrderLinkEntity
|
||||
{
|
||||
OrderId = orderId,
|
||||
@ -80,9 +93,7 @@ public class OrderLinkService : ApplicationService
|
||||
LinkOrderType = input.LinkOrderType
|
||||
}).ToList());
|
||||
|
||||
// todo:补轨迹
|
||||
|
||||
return true;
|
||||
return canLinkOrders.Select(x => x.Id).ToList();
|
||||
}
|
||||
|
||||
private async Task<bool> UnLinkOrderAsync(LinkOrderInput input)
|
||||
@ -1,7 +1,8 @@
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using DotNetCore.CAP;
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Application.Contract.Services;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Order;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
using SJZY.UserCenter.HttpApi.Services;
|
||||
|
||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
@ -11,28 +12,27 @@ namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "提供接口")]
|
||||
[Route("/ProviderService")]
|
||||
public class OrderService : ApplicationService
|
||||
public partial class OrderService : ApplicationService, IOrderService
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||
|
||||
public OrderService(IOrderRepository orderRepository,
|
||||
ITrackDetailsRepository trackDetailsRepository
|
||||
)
|
||||
public OrderService(IOrderRepository orderRepository, IBasicQuery<OrderLinkEntity> orderLinkQuery,
|
||||
ICapPublisher capPublisher)
|
||||
{
|
||||
_orderRepository = orderRepository;
|
||||
_trackDetailsRepository = trackDetailsRepository;
|
||||
_capPublisher = capPublisher;
|
||||
_orderLinkQuery = orderLinkQuery;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建订单,订单已存在则视为更新
|
||||
/// 新增、更新订单(存在就更新)
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessException"></exception>
|
||||
[HttpPost("Order/Upsert")]
|
||||
public async Task<string> UpsertAsync(UpsertOrderInput input)
|
||||
{
|
||||
if (input.Templates.Count == 0) throw new BusinessException(message: "至少有一个模板");
|
||||
var order = await _orderRepository.GetFirstAsync(x =>
|
||||
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo);
|
||||
if (order != default)
|
||||
@ -44,8 +44,8 @@ public class OrderService : ApplicationService
|
||||
|
||||
order = ObjectMapper.Map<UpsertOrderInput, OrderEntity>(input);
|
||||
order.SubSystemId = CurrentUserRequest.SubSystemId;
|
||||
order.OrderTemplates = ObjectMapper.Map<List<OrderTemplateInfo>, List<OrderTemplateEntity>>(input.Templates!);
|
||||
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos!);
|
||||
order.OrderTemplates = ObjectMapper.Map<List<OrderTemplateInfo>, List<OrderTemplateEntity>>(input.Templates);
|
||||
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos);
|
||||
|
||||
await _orderRepository.CreateOrderAsync(order);
|
||||
return "创建成功";
|
||||
@ -75,8 +75,8 @@ public class OrderService : ApplicationService
|
||||
private async Task UpdateOrderAsync(UpdateOrderInput input, OrderEntity order)
|
||||
{
|
||||
order = ObjectMapper.Map(input, order);
|
||||
order.OrderTemplates = ObjectMapper.Map<List<OrderTemplateInfo>, List<OrderTemplateEntity>>(input.Templates!);
|
||||
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos!);
|
||||
order.OrderTemplates = ObjectMapper.Map<List<OrderTemplateInfo>, List<OrderTemplateEntity>>(input.Templates);
|
||||
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos);
|
||||
await _orderRepository.UpdateOrderAsync(order);
|
||||
}
|
||||
}
|
||||
@ -1,57 +1,109 @@
|
||||
using SJZY.InterfaceRelay.Application.Contracts;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using SJZY.Expand.ABP.Core;
|
||||
using SJZY.InterfaceRelay.Application.Contracts;
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
using SJZY.Track.Application.Contract.Services;
|
||||
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 IOrderRepository _orderRepository;
|
||||
private readonly IHttpClientProxy<IInterfaceForwardService> _httpClientProxy;
|
||||
private readonly IProvideQueries _provideQueries;
|
||||
private readonly IHttpClientProxy<IInterfaceForwardServiceV2> _httpClientProxy;
|
||||
private readonly ITrackPullCacheService _trackPullCacheService;
|
||||
|
||||
public TrackPullService(IOrderRepository orderRepository,
|
||||
IHttpClientProxy<IInterfaceForwardService> httpClientProxy)
|
||||
public TrackPullService(IProvideQueries provideQueries,
|
||||
IHttpClientProxy<IInterfaceForwardServiceV2> httpClientProxy,
|
||||
ITrackPullCacheService trackPullCacheService)
|
||||
{
|
||||
_orderRepository = orderRepository;
|
||||
_provideQueries = provideQueries;
|
||||
_httpClientProxy = httpClientProxy;
|
||||
_trackPullCacheService = trackPullCacheService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刷新轨迹
|
||||
/// 手动刷新轨迹
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Track/Refresh")]
|
||||
public async Task<bool> RefreshTrackAsync(RefreshTrackInput input)
|
||||
{
|
||||
if (input.OrderNos.Count == 0)
|
||||
// todo:罚时?
|
||||
input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空
|
||||
|
||||
// 这里没有区分订单类型,就算的不同类型的单一起刷新了也无所谓
|
||||
var orders = await _provideQueries.FindOrderWithServiceProviderAsync(input.OrderNos);
|
||||
|
||||
if (orders.Count == 0)
|
||||
{
|
||||
throw new BusinessException(message: "订单号数组不能为空");
|
||||
throw new BusinessException(message: "一个拉取配置都不存在");
|
||||
}
|
||||
|
||||
input.OrderNos = input.OrderNos.Distinct().ToList();
|
||||
|
||||
var orderTemplates = await _orderRepository.GetOrderTemplatesAsync(input.OrderNos);
|
||||
|
||||
foreach (var group in orderTemplates.GroupBy(x => x.ServiceProviderId))
|
||||
foreach (var group in orders.GroupBy(x => x.ServiceProviderCode))
|
||||
{
|
||||
var data = group.Select(x => new OrderNoInfo
|
||||
var data = group.Select(x => new TrackRefreshDto
|
||||
{
|
||||
OrderType = x.OrderType,
|
||||
OrderNo = x.OrderNo
|
||||
OrderNo = x.OrderNo,
|
||||
ServiceProviderId = x.ServiceProviderId,
|
||||
SubSystemId = x.SubSystemId
|
||||
}).ToList();
|
||||
|
||||
|
||||
// 批量获取轨迹
|
||||
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
|
||||
"A012", "yicang", 42, data, GlobalConst.InterfaceRelayTrackRefreshSubscribe
|
||||
, group.Key.ToString());
|
||||
"A012", group.Key, data, GlobalConst.TrackRefreshSubscribe);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 定时任务刷新轨迹
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpPost("Track/RefreshForTask")]
|
||||
public async Task<bool> RefreshTrackAsync()
|
||||
{
|
||||
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 => x.ServiceProviderCode))
|
||||
{
|
||||
var data = group.Select(x => new TrackRefreshDto
|
||||
{
|
||||
OrderType = x.OrderType,
|
||||
OrderNo = x.OrderNo,
|
||||
ServiceProviderId = x.ServiceProviderId,
|
||||
SubSystemId = x.SubSystemId
|
||||
}).ToList();
|
||||
|
||||
// 批量获取轨迹
|
||||
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
|
||||
"A012", group.Key, data, GlobalConst.TrackRefreshSubscribe);
|
||||
}
|
||||
|
||||
await RedisHelper.Client.SetExAsync(redisKey, config.PullInterval * 60, 1);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,93 @@
|
||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
using SJZY.InterfaceRelay.Application.Contracts;
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Application.Contract.Services;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using Volo.Abp.Http.Client.DynamicProxying;
|
||||
|
||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹推送服务
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "提供接口")]
|
||||
[Route("/ProviderService")]
|
||||
public class TrackPushService: ApplicationService
|
||||
public class TrackPushService : ApplicationService
|
||||
{
|
||||
|
||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly ITrackPushCacheService _pushCacheService;
|
||||
private readonly IHttpClientProxy<IInterfaceForwardServiceV2> _httpClientProxy;
|
||||
|
||||
public TrackPushService(
|
||||
IHttpClientProxy<IInterfaceForwardServiceV2> httpClientProxy, ITrackPushCacheService pushCacheService,
|
||||
ITrackDetailsRepository trackDetailsRepository, IOrderRepository orderRepository)
|
||||
{
|
||||
_httpClientProxy = httpClientProxy;
|
||||
_pushCacheService = pushCacheService;
|
||||
_trackDetailsRepository = trackDetailsRepository;
|
||||
_orderRepository = orderRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 手工推送轨迹
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Track/Push")]
|
||||
public async Task<bool> 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);
|
||||
|
||||
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 data = new
|
||||
{
|
||||
order.OrderNo,
|
||||
data = new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
// 推真实的发生地和发生时间
|
||||
location = track.TrackPlace,
|
||||
date = track.TrackTime.AddHours(config.TrackTimeZone ??
|
||||
track.TrackTimeZone - track.TrackTimeZone),
|
||||
timeZone = config.TrackTimeZone ?? track.TrackTimeZone,
|
||||
description = config.TrackEnContentValue,
|
||||
description_cn = config.TrackContentValue,
|
||||
code = config.TrackContentCodeValue,
|
||||
status = config.TrackStatusValue,
|
||||
extra = config.ExpandFieldsValue
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
await _httpClientProxy.Service.ForwardWithSubscribeAsync("A024", config.ServiceProviderCode, data);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1,32 +1,17 @@
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
|
||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹查询服务
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "提供接口")]
|
||||
[Route("/ProviderService")]
|
||||
public class TrackQueryService : ApplicationService
|
||||
public partial class TrackService
|
||||
{
|
||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly IProvideQueries _provideQueries;
|
||||
|
||||
public TrackQueryService(ITrackDetailsRepository trackDetailsRepository,
|
||||
IOrderRepository orderRepository,
|
||||
IProvideQueries provideQueries)
|
||||
{
|
||||
_trackDetailsRepository = trackDetailsRepository;
|
||||
_orderRepository = orderRepository;
|
||||
_provideQueries = provideQueries;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据订单号获取轨迹
|
||||
/// 查询轨迹
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
@ -1,7 +1,9 @@
|
||||
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.Queries;
|
||||
|
||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
@ -11,21 +13,24 @@ namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "提供接口")]
|
||||
[Route("/ProviderService")]
|
||||
public class TrackService : ApplicationService
|
||||
public partial class TrackService : ApplicationService, ITrackService
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly IProvideQueries _provideQueries;
|
||||
private readonly ICapPublisher _capPublisher;
|
||||
|
||||
public TrackService(IOrderRepository orderRepository, IProvideQueries provideQueries, ICapPublisher capPublisher)
|
||||
public TrackService(IOrderRepository orderRepository, IProvideQueries provideQueries, ICapPublisher capPublisher,
|
||||
ITrackDetailsRepository trackDetailsRepository)
|
||||
{
|
||||
_orderRepository = orderRepository;
|
||||
_provideQueries = provideQueries;
|
||||
_provideQueries = provideQueries;
|
||||
_capPublisher = capPublisher;
|
||||
_trackDetailsRepository = trackDetailsRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增/更新订单轨迹接口
|
||||
/// 新增、更新轨迹(存在就更新)
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
@ -36,7 +41,7 @@ public class TrackService : ApplicationService
|
||||
var order = await _orderRepository.GetFirstAsync(x =>
|
||||
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
|
||||
});
|
||||
if (order == default)
|
||||
{
|
||||
@ -47,12 +52,55 @@ public class TrackService : ApplicationService
|
||||
var @event = ObjectMapper.Map<UpsertTrackInput, TrackUpsertEvent>(input);
|
||||
@event.OrderId = order.Id;
|
||||
@event.SubSystemId = order.SubSystemId;
|
||||
@event.IsPushCompleted = order.IsPushCompleted;
|
||||
@event.LatestPushTrackContentId = order.LatestPushTrackContentId;
|
||||
@event.CustomId = order.CustomId;
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量新增、更新轨迹
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessException"></exception>
|
||||
[HttpPost("Track/BatchUpsert")]
|
||||
public async Task<bool> BatchUpsertTrackAsync(BatchUpsertTrackInput input)
|
||||
{
|
||||
input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空
|
||||
if (input.OrderNos.Count == 0)
|
||||
{
|
||||
throw new BusinessException(message: "订单一个都不存在");
|
||||
}
|
||||
|
||||
var orders = await _orderRepository.GetListAsync(x =>
|
||||
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo), x => new
|
||||
{
|
||||
x.Id, x.OrderNo, x.SubSystemId, x.LatestPushTrackContentId, x.CustomId
|
||||
});
|
||||
|
||||
foreach (var order in orders)
|
||||
{
|
||||
// 新增/更新轨迹
|
||||
var @event = new TrackUpsertEvent
|
||||
{
|
||||
TrackCode = input.TrackCode,
|
||||
TrackPlace = input.TrackPlace,
|
||||
TrackTime = input.TrackTime,
|
||||
TrackTimeZone = input.TrackTimeZone,
|
||||
OrderType = input.OrderType,
|
||||
OrderNo = order.OrderNo,
|
||||
OrderId = order.Id,
|
||||
SubSystemId = order.SubSystemId,
|
||||
LatestPushTrackContentId = order.LatestPushTrackContentId,
|
||||
CustomId = order.CustomId
|
||||
};
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除轨迹
|
||||
/// </summary>
|
||||
@ -65,14 +113,14 @@ public class TrackService : ApplicationService
|
||||
var order = await _orderRepository.GetFirstAsync(x =>
|
||||
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new
|
||||
{
|
||||
x.Id, x.SubSystemId, x.IsPushCompleted, x.CustomId
|
||||
x.Id, x.SubSystemId
|
||||
});
|
||||
if (order == default)
|
||||
{
|
||||
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
|
||||
}
|
||||
|
||||
var codes = await _provideQueries.GetCanDeleteTrackCodesAsync(order.Id, input.TrackCodes);
|
||||
var codes = await _provideQueries.GetCanDeleteTrackCodesAsync(new List<int> { order.Id }, input.TrackCodes);
|
||||
|
||||
if (codes.Count == 0)
|
||||
{
|
||||
@ -83,11 +131,51 @@ public class TrackService : ApplicationService
|
||||
var @event = new TrackDeleteEvent
|
||||
{
|
||||
OrderId = order.Id,
|
||||
TrackCodes = codes,
|
||||
TrackCodes = codes.Select(x => x.TrackCode).ToList(),
|
||||
SubSystemId = order.SubSystemId,
|
||||
};
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackDeleteSubscribe, @event);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除轨迹
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessException"></exception>
|
||||
[HttpPost("Track/BatchDelete")]
|
||||
public async Task<bool> BatchDeleteTrackAsync(BatchDeleteTrackInput input)
|
||||
{
|
||||
var orders = await _orderRepository.GetListAsync(x =>
|
||||
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo)
|
||||
, x => new
|
||||
{
|
||||
x.Id, x.SubSystemId
|
||||
});
|
||||
|
||||
var codes = await _provideQueries.GetCanDeleteTrackCodesAsync(
|
||||
orders.Select(x => x.Id).ToList(), input.TrackCodes
|
||||
);
|
||||
|
||||
if (codes.Count == 0)
|
||||
{
|
||||
throw new BusinessException(message: "没有一个轨迹代码是可删的");
|
||||
}
|
||||
|
||||
// 删除轨迹
|
||||
foreach (var group in codes.GroupBy(x => x.OrderId))
|
||||
{
|
||||
var @event = new TrackDeleteEvent
|
||||
{
|
||||
OrderId = group.Key,
|
||||
TrackCodes = codes.Select(x => x.TrackCode).ToList(),
|
||||
SubSystemId = orders.First(x => x.Id == group.Key).SubSystemId,
|
||||
};
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackDeleteSubscribe, @event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1,115 +1,118 @@
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Order;
|
||||
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
|
||||
namespace SJZY.Track.Application.Services.TrackOrders
|
||||
namespace SJZY.Track.Application.Services.TrackOrders;
|
||||
|
||||
[ApiExplorerSettings(GroupName = "轨迹订单")]
|
||||
[Route("/Track/Order")]
|
||||
public class TrackOrderService : ApplicationService
|
||||
{
|
||||
[ApiExplorerSettings(GroupName = "轨迹订单")]
|
||||
[Route("/Track/Order")]
|
||||
public class TrackOrderService : ApplicationService, ITransientDependency
|
||||
private readonly ITrackOrderQueries _trackOrderQueries;
|
||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||
private readonly ITrackContentRepository _trackContentRepository;
|
||||
|
||||
public TrackOrderService(
|
||||
ITrackOrderQueries trackOrderQueries,
|
||||
ITrackDetailsRepository trackDetailsRepository,
|
||||
ITrackContentRepository trackContentRepository
|
||||
)
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||
private readonly ITrackContentRepository _trackContentRepository;
|
||||
|
||||
public TrackOrderService(
|
||||
IOrderRepository orderRepository,
|
||||
ITrackDetailsRepository trackDetailsRepository,
|
||||
ITrackContentRepository trackContentRepository
|
||||
)
|
||||
{
|
||||
this._orderRepository=orderRepository;
|
||||
this._trackDetailsRepository=trackDetailsRepository;
|
||||
this._trackContentRepository=trackContentRepository;
|
||||
}
|
||||
|
||||
#region 轨迹订单明细
|
||||
/// <summary>
|
||||
/// 根据轨迹订单id获取轨迹订单明细列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("GetDetails")]
|
||||
public async Task<List<TrackOrderDetailDto>> GetOrderDetails(GetOrderDetailsInput input)
|
||||
{
|
||||
var trackDetails = await _trackDetailsRepository.GetListAsync(input.OrderId);
|
||||
if (!trackDetails.IsNullOrEmpty())
|
||||
{
|
||||
var list = ObjectMapper.Map<List<TrackDetailsIndex>, List<TrackOrderDetailDto>>(trackDetails);
|
||||
var trackCodes = list.Where(a => !a.Code.IsNullOrWhiteSpace()).Select(a => a.Code).Distinct().ToList();
|
||||
|
||||
var trackContents = await _trackContentRepository.GetTrackContentAttributeValue(new GetTemplateContentAttributeValueInputVO
|
||||
{
|
||||
SubSystemId =input.SubSystemId,
|
||||
TrackTemplateIds = input.TrackTemplateIds,
|
||||
TrackCodes=trackCodes
|
||||
});
|
||||
input.TrackTemplateIds =input.TrackTemplateIds.Where(a => a>0).ToList();
|
||||
int id = 1;
|
||||
list.ForEach(a =>
|
||||
{
|
||||
a.Id = id++;
|
||||
|
||||
var trackContentsOfTemplates = trackContents.Where(b => b.SubSystemId==input.SubSystemId && b.TrackCode==a.Code
|
||||
&& input.TrackTemplateIds.Contains(b.TrackTemplateId));
|
||||
GetTemplateContentAttributeValueVO trackContent = null;
|
||||
var insertData = input.TrackTemplateIds.Intersect(trackContentsOfTemplates.Select(aa => aa.TrackTemplateId)).ToList();
|
||||
if (!insertData.IsNullOrEmpty())
|
||||
{
|
||||
trackContent =trackContentsOfTemplates.FirstOrDefault(a => a.TrackTemplateId==insertData.FirstOrDefault());
|
||||
}
|
||||
|
||||
if (trackContent!=null)
|
||||
{
|
||||
a.IsCanDelete=trackContent.IsCanDelete;
|
||||
a.IsExternal = trackContent.IsExternal;
|
||||
}
|
||||
if (a.TrackTimeZoneValue==0f)
|
||||
{
|
||||
a.TrackTimeZone=$"GTM{" "}+00:00";
|
||||
}
|
||||
else
|
||||
{
|
||||
// 将小数形式的小时转换为时区偏移量
|
||||
int hours = (int)a.TrackTimeZoneValue; // 提取整数部分作为小时
|
||||
int minutes = (int)((a.TrackTimeZoneValue - hours) * 60); // 将小数部分乘以 60 转换为分钟
|
||||
TimeSpan offset = new TimeSpan(hours, minutes, 0);
|
||||
string timeZoneStr = offset.ToString();
|
||||
string flag = a.TrackTimeZoneValue>0f ? "+" : "";
|
||||
a.TrackTimeZone = $"GTM{" "}{flag}{timeZoneStr.RemovePostFix(":00")}";
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
return new List<TrackOrderDetailDto>();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 轨迹订单列表
|
||||
/// <summary>
|
||||
/// 获取分页的轨迹订单
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("GetTrackOrderList")]
|
||||
public async Task<UnifyPageResultDto<TrackOrderDto>> GetPageTrackOrder(GetPageTrackOrderInput input)
|
||||
{
|
||||
var vo = ObjectMapper.Map<GetPageTrackOrderInput, GetPageTrackOrderInputVO>(input);
|
||||
var pageList = await _orderRepository.GetPageTrackOrder(vo);
|
||||
var pageResultDto =
|
||||
ObjectMapper.Map<UnifyPageResultDto<TrackOrderVO>, UnifyPageResultDto<TrackOrderDto>>(pageList);
|
||||
return pageResultDto;
|
||||
}
|
||||
#endregion
|
||||
_trackOrderQueries = trackOrderQueries;
|
||||
_trackDetailsRepository = trackDetailsRepository;
|
||||
_trackContentRepository = trackContentRepository;
|
||||
}
|
||||
}
|
||||
|
||||
#region 轨迹订单明细
|
||||
|
||||
/// <summary>
|
||||
/// 根据轨迹订单id获取轨迹订单明细列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("GetDetails")]
|
||||
public async Task<List<TrackOrderDetailDto>> GetOrderDetails(GetOrderDetailsInput input)
|
||||
{
|
||||
var trackDetails = await _trackDetailsRepository.GetListAsync(input.OrderId);
|
||||
if (!trackDetails.IsNullOrEmpty())
|
||||
{
|
||||
var list = ObjectMapper.Map<List<TrackDetailsIndex>, List<TrackOrderDetailDto>>(trackDetails);
|
||||
var trackCodes = list.Where(a => !a.Code.IsNullOrWhiteSpace()).Select(a => a.Code).Distinct().ToList();
|
||||
|
||||
var trackContents = await _trackContentRepository.GetTrackContentAttributeValue(new GetTemplateContentAttributeValueInputVO
|
||||
{
|
||||
SubSystemId = input.SubSystemId,
|
||||
TrackTemplateIds = input.TrackTemplateIds,
|
||||
TrackCodes = trackCodes
|
||||
});
|
||||
input.TrackTemplateIds = input.TrackTemplateIds.Where(a => a > 0).ToList();
|
||||
int id = 1;
|
||||
list.ForEach(a =>
|
||||
{
|
||||
a.Id = id++;
|
||||
|
||||
var trackContentsOfTemplates = trackContents.Where(b => b.SubSystemId == input.SubSystemId && b.TrackCode == a.Code
|
||||
&& input.TrackTemplateIds.Contains(b.TrackTemplateId));
|
||||
GetTemplateContentAttributeValueVO trackContent = null;
|
||||
var insertData = input.TrackTemplateIds.Intersect(trackContentsOfTemplates.Select(aa => aa.TrackTemplateId)).ToList();
|
||||
if (!insertData.IsNullOrEmpty())
|
||||
{
|
||||
trackContent = trackContentsOfTemplates.FirstOrDefault(a => a.TrackTemplateId == insertData.FirstOrDefault());
|
||||
}
|
||||
|
||||
if (trackContent != null)
|
||||
{
|
||||
a.IsCanDelete = trackContent.IsCanDelete;
|
||||
a.IsExternal = trackContent.IsExternal;
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// a.IsCanDelete=false;
|
||||
// a.IsExternal=false;
|
||||
//}
|
||||
if (a.TrackTimeZoneValue == 0f)
|
||||
{
|
||||
a.TrackTimeZone = $"GTM{" "}+00:00";
|
||||
}
|
||||
else
|
||||
{
|
||||
// 将小数形式的小时转换为时区偏移量
|
||||
int hours = (int)a.TrackTimeZoneValue; // 提取整数部分作为小时
|
||||
int minutes = (int)((a.TrackTimeZoneValue - hours) * 60); // 将小数部分乘以 60 转换为分钟
|
||||
TimeSpan offset = new TimeSpan(hours, minutes, 0);
|
||||
string timeZoneStr = offset.ToString();
|
||||
string flag = a.TrackTimeZoneValue > 0f ? "+" : "";
|
||||
a.TrackTimeZone = $"GTM{" "}{flag}{timeZoneStr.RemovePostFix(":00")}";
|
||||
}
|
||||
});
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
return new List<TrackOrderDetailDto>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 轨迹订单列表
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页的轨迹订单
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("GetTrackOrderList")]
|
||||
public async Task<UnifyPageResultDto<TrackOrderDto>> GetPageTrackOrder(GetPageTrackOrderInput input)
|
||||
{
|
||||
var vo = ObjectMapper.Map<GetPageTrackOrderInput, GetPageTrackOrderInputVO>(input);
|
||||
var pageList = await _trackOrderQueries.GetPageTrackOrder(vo);
|
||||
var pageResultDto =
|
||||
ObjectMapper.Map<UnifyPageResultDto<TrackOrderVO>, UnifyPageResultDto<TrackOrderDto>>(pageList);
|
||||
return pageResultDto;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
using System.Linq.Expressions;
|
||||
using SJZY.Expand.ABP.Core;
|
||||
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
using SJZY.Track.Application.Contract.Services;
|
||||
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||
using SJZY.Track.Domain.Dtos.TrackPull;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.Services.TrackPull;
|
||||
|
||||
public class TrackPullCacheService : ApplicationService, ITrackPullCacheService, ITransientDependency
|
||||
{
|
||||
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
||||
|
||||
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)
|
||||
{
|
||||
_trackPullConfigRepository = trackPullConfigRepository;
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public async Task<List<TrackPullConfigDto>> GetAllPullConfigsAsync()
|
||||
{
|
||||
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);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public async Task<TrackPullParamWithContentConfigDto> SetPullConfigAsync(int? id = null, int? subSystemId = null,
|
||||
int? serviceProviderId = null)
|
||||
{
|
||||
var data = new TrackPullParamWithContentConfigDto();
|
||||
|
||||
Expression<Func<TrackPullConfigEntity, bool>> exp = x => true;
|
||||
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);
|
||||
if (trackPullConfigEntity == null) return data;
|
||||
|
||||
var trackPullConfigDetail = await _trackPullConfigRepository.GetDetailAsync(trackPullConfigEntity.Id);
|
||||
if (trackPullConfigDetail is null) return data;
|
||||
var trackPullContentList = await _trackPullConfigRepository.GetContentListCacheAsync(trackPullConfigEntity.Id);
|
||||
if (trackPullContentList.Count == 0) return data;
|
||||
|
||||
data.ParamConfig =
|
||||
ObjectMapper.Map<GetTrackPullConfigDetailOutputVO, TrackPullParamConfigDto>(trackPullConfigDetail);
|
||||
data.ContentConfigs =
|
||||
ObjectMapper.Map<List<GetTrackPullContentListCacheVO>, List<TrackPullContentConfigDto>>(
|
||||
trackPullContentList);
|
||||
|
||||
await RedisHelper.Client.SetAsync(
|
||||
TrackPullContentKey(trackPullConfigEntity.SubSystemId, trackPullConfigEntity.ServiceProviderId), data);
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Linq.Expressions;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SJZY.Expand.ABP.Core.Localization;
|
||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
using SJZY.Track.Application.Contract.Services;
|
||||
using SJZY.Track.Application.Localization;
|
||||
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Common;
|
||||
using SJZY.Track.Domain.Dtos.TrackPull;
|
||||
using SqlSugar;
|
||||
@ -23,16 +22,16 @@ public class TrackPullService : ApplicationService, ITransientDependency
|
||||
{
|
||||
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
|
||||
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
||||
private readonly ITrackTemplateRepository _trackTemplateRepository;
|
||||
private readonly ITrackPullCacheService _trackPullCacheService;
|
||||
|
||||
public TrackPullService(
|
||||
IStringLocalizer<TrackLocalizationResource> stringLocalizer,
|
||||
ITrackPullConfigRepository trackPullConfigRepository,
|
||||
ITrackTemplateRepository trackTemplateRepository)
|
||||
ITrackPullCacheService trackPullCacheService)
|
||||
{
|
||||
_stringLocalizer = stringLocalizer;
|
||||
_trackPullConfigRepository = trackPullConfigRepository;
|
||||
_trackTemplateRepository = trackTemplateRepository;
|
||||
_trackPullCacheService = trackPullCacheService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -91,8 +90,7 @@ public class TrackPullService : ApplicationService, ITransientDependency
|
||||
if (input.Options != OptionTypeNoNull.删除)
|
||||
{
|
||||
Expression<Func<TrackPullConfigEntity, bool>> isAnyExp = x =>
|
||||
x.SubSystemId == input.SubSystemId && x.TrackTemplateId == input.TrackTemplateId &&
|
||||
x.ServiceProviderId == input.ServiceProviderId;
|
||||
x.SubSystemId == input.SubSystemId && x.ServiceProviderId == input.ServiceProviderId;
|
||||
if (input.Options == OptionTypeNoNull.修改) isAnyExp = isAnyExp.And(x => x.Id != input.Id);
|
||||
|
||||
if (await _trackPullConfigRepository.IsAnyAsync(isAnyExp))
|
||||
@ -104,63 +102,29 @@ public class TrackPullService : ApplicationService, ITransientDependency
|
||||
case OptionTypeNoNull.新增:
|
||||
{
|
||||
var trackPullEntity = ObjectMapper.Map<EditTrackPullConfigInput, TrackPullConfigEntity>(input);
|
||||
var trackPullParamsEntity =
|
||||
ObjectMapper.Map<EditTrackPullConfigInput, TrackPushPullParamsConfigEntity>(input);
|
||||
var trackPullParamsEntity = ObjectMapper.Map<EditTrackPullConfigInput, TrackPushPullParamsConfigEntity>(input);
|
||||
|
||||
var trackTemplateContentEntities =
|
||||
await _trackTemplateRepository.GetContentListAsync(x => x.TrackTemplateId == input.TrackTemplateId);
|
||||
|
||||
var trackPullContentEntities = new List<TrackPullContentConfigEntity>();
|
||||
int id = 0;
|
||||
|
||||
using (var ts = TransactionScopeHelper.Create())
|
||||
{
|
||||
int id = await _trackPullConfigRepository.InsertReturnIdentityAsync(trackPullEntity);
|
||||
id = await _trackPullConfigRepository.InsertReturnIdentityAsync(trackPullEntity);
|
||||
|
||||
trackPullParamsEntity.PullOrPushConfigId = id;
|
||||
await _trackPullConfigRepository.InsertParamsAsync(trackPullParamsEntity);
|
||||
|
||||
foreach (var item in trackTemplateContentEntities)
|
||||
{
|
||||
trackPullContentEntities.Add(new()
|
||||
{
|
||||
TrackPullConfigId = id,
|
||||
TrackContentId = item.TrackContentId
|
||||
});
|
||||
}
|
||||
|
||||
await _trackPullConfigRepository.InsertContentRangeAsync(trackPullContentEntities);
|
||||
|
||||
ts.Complete();
|
||||
}
|
||||
|
||||
await _trackPullCacheService.SetPullConfigAsync(id);
|
||||
}
|
||||
break;
|
||||
|
||||
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 trackPullContentEntities = new List<TrackPullContentConfigEntity>();
|
||||
|
||||
if (oldTrackPullEntity.TrackTemplateId != input.TrackTemplateId)
|
||||
{
|
||||
var trackTemplateContentEntities =
|
||||
await _trackTemplateRepository.GetContentListAsync(x =>
|
||||
x.TrackTemplateId == input.TrackTemplateId);
|
||||
|
||||
foreach (var item in trackTemplateContentEntities)
|
||||
{
|
||||
trackPullContentEntities.Add(new()
|
||||
{
|
||||
TrackPullConfigId = oldTrackPullEntity.Id,
|
||||
TrackContentId = item.TrackContentId
|
||||
});
|
||||
}
|
||||
}
|
||||
var oldTrackPullParamsEntity = await _trackPullConfigRepository.GetParamsSingleAsync(x => x.PullOrPushConfigId == input.Id && !x.IsPush);
|
||||
|
||||
ObjectMapper.Map(input, oldTrackPullEntity);
|
||||
ObjectMapper.Map(input, oldTrackPullParamsEntity);
|
||||
@ -170,14 +134,10 @@ public class TrackPullService : ApplicationService, ITransientDependency
|
||||
await _trackPullConfigRepository.UpdateAsync(oldTrackPullEntity);
|
||||
await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPullParamsEntity);
|
||||
|
||||
if (trackPullContentEntities.Count > 0)
|
||||
{
|
||||
await _trackPullConfigRepository.SoftDeleteContentAsync(x => x.TrackPullConfigId == input.Id);
|
||||
await _trackPullConfigRepository.InsertContentRangeAsync(trackPullContentEntities);
|
||||
}
|
||||
|
||||
ts.Complete();
|
||||
}
|
||||
|
||||
await _trackPullCacheService.SetPullConfigAsync(input.Id);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -185,8 +145,7 @@ public class TrackPullService : ApplicationService, ITransientDependency
|
||||
using (var ts = TransactionScopeHelper.Create())
|
||||
{
|
||||
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);
|
||||
|
||||
ts.Complete();
|
||||
@ -203,38 +162,76 @@ public class TrackPullService : ApplicationService, ITransientDependency
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹拉取配置内容修改
|
||||
/// 轨迹拉取配置内容编辑
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("UpdateContent")]
|
||||
public async Task<bool> UpdateContentAsync([FromBody] UpdateTrackPullContentInput input)
|
||||
[HttpPost("EditContent")]
|
||||
public async Task<bool> EditContentAsync([FromBody] EditTrackPullContentInput input)
|
||||
{
|
||||
Expression<Func<TrackPullContentConfigEntity, bool>> isContentAnyExp = x => x.Id != input.Id && x.TrackPullConfigId == input.TrackPullConfigId;
|
||||
|
||||
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentId == input.TrackContentId)))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentAny"]);
|
||||
else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentCodeValue == input.TrackContentCodeValue)))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentCodeValueAny"]);
|
||||
else if (!input.TrackStatusValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackStatusValue == input.TrackStatusValue)))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentStatusValueAny"]);
|
||||
else if (!input.TrackContentValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentValue == input.TrackContentValue)))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentValueAny"]);
|
||||
else if (!input.TrackKeywords.IsNullOrEmpty())
|
||||
if (input.Options != OptionTypeNoNull.删除)
|
||||
{
|
||||
Expression<Func<TrackPullContentConfigEntity, bool>> trackKeywordExp = _ => false;
|
||||
input.TrackKeywords!.ForEach(item => { trackKeywordExp = trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item)); });
|
||||
Expression<Func<TrackPullContentConfigEntity, bool>> isContentAnyExp = x => x.TrackPullConfigId == input.TrackPullConfigId;
|
||||
if (input.Options == OptionTypeNoNull.修改) isContentAnyExp = isContentAnyExp.And(x => x.Id != input.Id);
|
||||
|
||||
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(trackKeywordExp)))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentKeywordsAny"]);
|
||||
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentId == input.TrackContentId)))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentAny"]);
|
||||
else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentCodeValue == input.TrackContentCodeValue)))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentCodeValueAny"]);
|
||||
else if (!input.TrackStatusValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackStatusValue == input.TrackStatusValue)))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentStatusValueAny"]);
|
||||
else if (!input.TrackContentValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentValue == input.TrackContentValue)))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentValueAny"]);
|
||||
else if (!input.TrackKeywords.IsNullOrEmpty())
|
||||
{
|
||||
Expression<Func<TrackPullContentConfigEntity, bool>> trackKeywordExp = _ => false;
|
||||
input.TrackKeywords!.ForEach(item => { trackKeywordExp = trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item)); });
|
||||
|
||||
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(trackKeywordExp)))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentKeywordsAny"]);
|
||||
}
|
||||
}
|
||||
|
||||
var oldTrackPullContentEntity = await _trackPullConfigRepository.GetContentByIdAsync(input.Id) ??
|
||||
switch (input.Options)
|
||||
{
|
||||
case OptionTypeNoNull.新增:
|
||||
{
|
||||
var entity = ObjectMapper.Map<EditTrackPullContentInput, TrackPullContentConfigEntity>(input);
|
||||
|
||||
await _trackPullConfigRepository.InsertContentAsync(entity);
|
||||
await _trackPullCacheService.SetPullConfigAsync(input.TrackPullConfigId);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case OptionTypeNoNull.修改:
|
||||
{
|
||||
var oldTrackPullContentEntity = await _trackPullConfigRepository.GetContentByIdAsync(input.Id!.Value) ??
|
||||
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||
|
||||
ObjectMapper.Map(input, oldTrackPullContentEntity);
|
||||
ObjectMapper.Map(input, oldTrackPullContentEntity);
|
||||
|
||||
await _trackPullConfigRepository.UpdateContentAsync(oldTrackPullContentEntity);
|
||||
await _trackPullConfigRepository.UpdateContentAsync(oldTrackPullContentEntity);
|
||||
await _trackPullCacheService.SetPullConfigAsync(oldTrackPullContentEntity.TrackPullConfigId);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
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 _trackPullCacheService.SetPullConfigAsync(oldTrackPullContentEntity.TrackPullConfigId);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum,
|
||||
nameof(EditTrackPullContentInput.Options)]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -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.Domain.Aggregates.TrackPushAggregate;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.Services.TrackPush;
|
||||
|
||||
public class TrackPushCacheService : ITrackPushCacheService, ITransientDependency
|
||||
public class TrackPushCacheService : ApplicationService, ITrackPushCacheService, ITransientDependency
|
||||
{
|
||||
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 =
|
||||
await RedisHelper.Client.GetAsync<bool?>(RedisKey(customId));
|
||||
var data = await GetPushConfigAsync(subSystemId, customId);
|
||||
|
||||
if (isPush == null)
|
||||
return data.ContentConfigs;
|
||||
}
|
||||
|
||||
[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);
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public async Task<TrackPushContentConfigDto?> InferNextPushContentOrNullAsync(int subSystemId, int customId,
|
||||
int? trackContentId)
|
||||
{
|
||||
var data = await GetPushConfigAsync(subSystemId, customId);
|
||||
if (!data.IsAutoPush) return null;
|
||||
|
||||
if (trackContentId.HasValue)
|
||||
{
|
||||
isPush = await _trackPushConfigQuery.GetFirstAsync(x => x.CustomId == customId,
|
||||
x => x.IsAutoPush);
|
||||
await RedisHelper.Client.SetAsync(RedisKey(customId), isPush);
|
||||
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 (bool)isPush;
|
||||
return data.ContentConfigs.FirstOrDefault();
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(int customId, bool isPush)
|
||||
[NonAction]
|
||||
public async Task<TrackPushConfigDto> SetPushContentConfigsAsync(int? id = null, int? subSystemId = null,
|
||||
int? customId = null)
|
||||
{
|
||||
await RedisHelper.Client.SetAsync(RedisKey(customId), isPush);
|
||||
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,5 +1,5 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SJZY.Expand.ABP.Core;
|
||||
using System.Linq.Expressions;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SJZY.Expand.ABP.Core.Localization;
|
||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
using SJZY.Track.Application.Contract.Dtos.TrackPush;
|
||||
@ -10,9 +10,6 @@ using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Common;
|
||||
using SJZY.Track.Domain.Dtos.TrackPush;
|
||||
using SqlSugar;
|
||||
using System.Linq.Expressions;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.Services.TrackPush;
|
||||
|
||||
@ -21,11 +18,10 @@ namespace SJZY.Track.Application.Services.TrackPush;
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "轨迹推送")]
|
||||
[Route("/Track/PushConfig")]
|
||||
public class TrackPushService : ApplicationService, ITransientDependency
|
||||
public class TrackPushService : ApplicationService
|
||||
{
|
||||
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
|
||||
private readonly ITrackPushConfigRepository _trackPushConfigRepository;
|
||||
private readonly ITrackTemplateRepository _trackTemplateRepository;
|
||||
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
||||
private readonly ITrackPushCacheService _trackPushCacheService;
|
||||
|
||||
@ -38,7 +34,6 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
||||
{
|
||||
_stringLocalizer = stringLocalizer;
|
||||
_trackPushConfigRepository = trackPushConfigRepository;
|
||||
_trackTemplateRepository = trackTemplateRepository;
|
||||
_trackPullConfigRepository = trackPullConfigRepository;
|
||||
_trackPushCacheService = trackPushCacheService;
|
||||
}
|
||||
@ -60,7 +55,8 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[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);
|
||||
}
|
||||
@ -73,16 +69,7 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
||||
[HttpGet("GetDetail")]
|
||||
public async Task<GetTrackPushConfigDetailOutputVO> GetDetailAsync(int id)
|
||||
{
|
||||
var res = await _trackPushConfigRepository.GetDetailAsync(id);
|
||||
if (res is null) return null;
|
||||
|
||||
List<int> trackTemplateIds = res.TrackTemplateId.Split(',').Select(int.Parse).ToList();
|
||||
|
||||
var trackTemplateEntities = await _trackTemplateRepository.GetListAsync(x => trackTemplateIds.Contains(x.Id));
|
||||
|
||||
trackTemplateEntities.ForEach(item => { (res.TrackTemplate ??= new()).Add(new() { Value = item.Id, Key = item.Name }); });
|
||||
|
||||
return res;
|
||||
return await _trackPushConfigRepository.GetDetailAsync(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -107,14 +94,9 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
||||
if (input.Options != OptionTypeNoNull.删除)
|
||||
{
|
||||
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);
|
||||
|
||||
var trackTemplateIdExp = Expressionable.Create<TrackPushConfigEntity>();
|
||||
input.TrackTemplateIds?.ForEach(item => { trackTemplateIdExp.Or(x => SqlFunc.SplitIn(x.TrackTemplateId, item.ToString())); });
|
||||
|
||||
isAnyExp = isAnyExp.And(trackTemplateIdExp.ToExpression());
|
||||
|
||||
if (await _trackPushConfigRepository.IsAnyAsync(isAnyExp))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackPushConfigAny"]);
|
||||
}
|
||||
@ -124,7 +106,8 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
||||
case OptionTypeNoNull.新增:
|
||||
{
|
||||
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())
|
||||
{
|
||||
@ -133,8 +116,6 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
||||
trackPushParamsEntity.PullOrPushConfigId = id;
|
||||
await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity);
|
||||
|
||||
if (input.IsAutoPush) await _trackPushCacheService.IsPushAsync(input.CustomId);
|
||||
|
||||
ts.Complete();
|
||||
}
|
||||
}
|
||||
@ -142,7 +123,8 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
||||
|
||||
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;
|
||||
|
||||
@ -158,17 +140,17 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
||||
await _trackPushConfigRepository.UpdateAsync(oldTrackPushEntity);
|
||||
await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity);
|
||||
|
||||
await _trackPushCacheService.UpdateAsync(oldCustomId, false);
|
||||
if (input.IsAutoPush) await _trackPushCacheService.IsPushAsync(input.CustomId);
|
||||
|
||||
ts.Complete();
|
||||
}
|
||||
|
||||
if (input.IsAutoPush!.Value) await _trackPushCacheService.SetPushContentConfigsAsync(input.Id);
|
||||
}
|
||||
break;
|
||||
|
||||
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())
|
||||
{
|
||||
@ -177,8 +159,6 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
||||
x.PullOrPushConfigId == input.Id && x.IsPush);
|
||||
await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id);
|
||||
|
||||
await _trackPushCacheService.UpdateAsync(oldTrackPushEntity.CustomId, false);
|
||||
|
||||
ts.Complete();
|
||||
}
|
||||
}
|
||||
@ -202,18 +182,28 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
||||
{
|
||||
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 (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"]);
|
||||
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"]);
|
||||
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"]);
|
||||
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"]);
|
||||
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"]);
|
||||
}
|
||||
|
||||
@ -221,40 +211,47 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
||||
{
|
||||
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);
|
||||
entity.Sort = maxSort + 1;
|
||||
|
||||
await _trackPushConfigRepository.InsertContentAsync(entity);
|
||||
await _trackPushCacheService.SetPushContentConfigsAsync(input.TrackPushConfigId);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
await _trackPushConfigRepository.UpdateContentAsync(entity);
|
||||
await _trackPushCacheService.SetPushContentConfigsAsync(entity.TrackPushConfigId);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
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())
|
||||
{
|
||||
await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id);
|
||||
|
||||
await _trackPushConfigRepository.UpdateContentAsync(x => x.Sort == x.Sort - 1, x => x.TrackPushConfigId == entity.TrackPushConfigId && x.Sort > entity.Sort);
|
||||
await _trackPushConfigRepository.UpdateContentAsync(x => x.Sort == x.Sort - 1,
|
||||
x => x.TrackPushConfigId == entity.TrackPushConfigId && x.Sort > entity.Sort);
|
||||
|
||||
ts.Complete();
|
||||
}
|
||||
|
||||
await _trackPushCacheService.SetPushContentConfigsAsync(entity.TrackPushConfigId);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -283,7 +280,11 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
||||
item.Sort = input.SortInfo.Single(x => x.Key == item.Id.ToString()).Value;
|
||||
});
|
||||
|
||||
await _trackPushConfigRepository.UpdateContentRangeAsync(trackPushContentEntities);
|
||||
if (trackPushContentEntities.Count > 0)
|
||||
{
|
||||
await _trackPushConfigRepository.UpdateContentRangeAsync(trackPushContentEntities);
|
||||
await _trackPushCacheService.SetPushContentConfigsAsync(trackPushContentEntities[0].TrackPushConfigId);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -21,21 +21,15 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
|
||||
{
|
||||
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
|
||||
private readonly ITrackTemplateRepository _trackTemplateRepository;
|
||||
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
|
||||
private readonly ITrackPushConfigRepository _trackPushConfigRepository;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public TrackTemplateService(
|
||||
IStringLocalizer<TrackLocalizationResource> stringLocalizer,
|
||||
ITrackTemplateRepository trackTemplateRepository,
|
||||
ITrackPullConfigRepository trackPullConfigRepository,
|
||||
ITrackPushConfigRepository trackPushConfigRepository
|
||||
ITrackTemplateRepository trackTemplateRepository
|
||||
)
|
||||
{
|
||||
_stringLocalizer = stringLocalizer;
|
||||
_trackTemplateRepository = trackTemplateRepository;
|
||||
_trackPullConfigRepository = trackPullConfigRepository;
|
||||
_trackPushConfigRepository = trackPushConfigRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -99,18 +93,18 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
|
||||
//var templateEntity =
|
||||
// await _trackTemplateRepository.GetFirstAsync(
|
||||
// a => a.SubSystemId == input.SubSystemId && a.Code == input.Code);
|
||||
var templateEntitys = await _trackTemplateRepository.GetListAsync(a => a.SubSystemId == input.SubSystemId && (a.Code == input.Code|| a.Name==input.Name));
|
||||
var templateEntitys = await _trackTemplateRepository.GetListAsync(a => a.SubSystemId == input.SubSystemId && (a.Code == input.Code || a.Name == input.Name));
|
||||
if (templateEntitys.Any())
|
||||
{
|
||||
//throw new BusinessException(message: _stringLocalizer["TemplateExist"]);
|
||||
//throw new BusinessException(message: "模板代码已存在于当前选择的子系统下");
|
||||
var trackTemplateCode = templateEntitys.FirstOrDefault(t => t.Code==input.Code);
|
||||
if (trackTemplateCode!=null)
|
||||
var trackTemplateCode = templateEntitys.FirstOrDefault(t => t.Code == input.Code);
|
||||
if (trackTemplateCode != null)
|
||||
{
|
||||
throw new BusinessException(message: "该子系统下模板代码已存在");
|
||||
}
|
||||
var trackTemplateName = templateEntitys.FirstOrDefault(t => t.Name==input.Name);
|
||||
if (trackTemplateName!=null)
|
||||
var trackTemplateName = templateEntitys.FirstOrDefault(t => t.Name == input.Name);
|
||||
if (trackTemplateName != null)
|
||||
{
|
||||
throw new BusinessException(message: "该子系统下模板名称已存在");
|
||||
}
|
||||
@ -129,17 +123,17 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
|
||||
#region 业务校验
|
||||
|
||||
var templateEntitys = await _trackTemplateRepository.GetListAsync(a =>
|
||||
a.Id != input.Id && a.SubSystemId == input.SubSystemId && (a.Code == input.Code || a.Name==input.Name));
|
||||
a.Id != input.Id && a.SubSystemId == input.SubSystemId && (a.Code == input.Code || a.Name == input.Name));
|
||||
if (templateEntitys.Any())
|
||||
{
|
||||
//throw new BusinessException(message: "模板代码已存在于当前选择的子系统下");
|
||||
var trackTemplateCode = templateEntitys.FirstOrDefault(t => t.Code==input.Code);
|
||||
if (trackTemplateCode!=null)
|
||||
var trackTemplateCode = templateEntitys.FirstOrDefault(t => t.Code == input.Code);
|
||||
if (trackTemplateCode != null)
|
||||
{
|
||||
throw new BusinessException(message: "该子系统下模板代码已存在");
|
||||
}
|
||||
var trackTemplateName = templateEntitys.FirstOrDefault(t => t.Name==input.Name);
|
||||
if (trackTemplateName!=null)
|
||||
var trackTemplateName = templateEntitys.FirstOrDefault(t => t.Name == input.Name);
|
||||
if (trackTemplateName != null)
|
||||
{
|
||||
throw new BusinessException(message: "该子系统下模板名称已存在");
|
||||
}
|
||||
@ -156,24 +150,6 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
|
||||
|
||||
private async Task<UnifyResultDto> DeleteAsync(EditTrackTemplateInput input)
|
||||
{
|
||||
#region 业务校验
|
||||
|
||||
//查询看看在轨迹拉取里面有没有被占用
|
||||
var isExisistTrackPullConfigs = await _trackPullConfigRepository.GetListAsync(a => a.TrackTemplateId == input.Id);
|
||||
if (isExisistTrackPullConfigs.Any())
|
||||
{
|
||||
//throw new BusinessException(message: _stringLocalizer["IsExistTrackPullConfig"]);
|
||||
throw new BusinessException(message: "该模板存在映射,禁止删除");
|
||||
}
|
||||
//轨迹推送里看看是否被占用
|
||||
var isExisistTrackPushConfigs = await _trackPushConfigRepository.GetListAsync(a => a.TrackTemplateId.Contains(input.Id.ToString()));
|
||||
if (isExisistTrackPushConfigs.Any())
|
||||
{
|
||||
throw new BusinessException(message: "该模板存在映射,禁止删除");
|
||||
}
|
||||
|
||||
#endregion 业务校验
|
||||
|
||||
var isTrue = await _trackTemplateRepository.SoftDeleteAsync(x => x.Id == input.Id);
|
||||
|
||||
return new UnifyResultDto("200", "删除成功", isTrue);
|
||||
@ -204,17 +180,6 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
|
||||
return await _trackTemplateRepository.GetContentDetailAsync(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板内容下拉框
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("GetContentDropDownList")]
|
||||
public async Task<UnifyPageResultDto<DropdownListDataDto>> GetContentDropDownListAsync([FromBody] GetTrackTemplateContentDropDownListVO input)
|
||||
{
|
||||
return await _trackTemplateRepository.GetContentDropDownListAsync(input);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板内容编辑
|
||||
/// </summary>
|
||||
|
||||
@ -68,9 +68,8 @@ namespace SJZY.Track.Application
|
||||
//用户中心
|
||||
context.Services.AddHttpClientProxies(typeof(SjzyUserCenterHttpApiModule).Assembly, "UserCenter", false);
|
||||
context.Services.AddHttpClient("InterfaceForward").AddHttpMessageHandler<InterfaceForwardHeaderHandler>();
|
||||
context.Services.AddHttpClientProxy<IInterfaceForwardService>(
|
||||
remoteServiceConfigurationName: "InterfaceForward",
|
||||
asDefaultService: false
|
||||
context.Services.AddHttpClientProxies(typeof(SJZYInterfaceRelayApplicationContractsModule).Assembly,
|
||||
"InterfaceForward", false
|
||||
);
|
||||
|
||||
//CAP
|
||||
|
||||
@ -25,8 +25,6 @@ public class EditTrackPullConfigInputValidation : AbstractValidator<EditTrackPul
|
||||
|
||||
RuleFor(x => x.SubSystemId).GreaterThan(0).WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_GreaterThan, nameof(EditTrackPullConfigInput.SubSystemId), 0]);
|
||||
|
||||
RuleFor(x => x.TrackTemplateId).GreaterThan(0).WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_GreaterThan, nameof(EditTrackPullConfigInput.TrackTemplateId), 0]);
|
||||
|
||||
When(x => x.Options != OptionTypeNoNull.新增, () =>
|
||||
{
|
||||
RuleFor(x => x.Id).NotNull().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotNull, nameof(EditTrackPullConfigInput.Id)]);
|
||||
@ -38,17 +36,19 @@ public class EditTrackPullConfigInputValidation : AbstractValidator<EditTrackPul
|
||||
|
||||
RuleFor(x => x.ServiceProviderId).NotNull().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotNull, nameof(EditTrackPullConfigInput.ServiceProviderId)]);
|
||||
|
||||
RuleFor(x => x.TrackTemplateId).NotNull().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotNull, nameof(EditTrackPullConfigInput.TrackTemplateId)]);
|
||||
|
||||
RuleFor(x => x.PullInterval).NotNull().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotNull, nameof(EditTrackPullConfigInput.PullInterval)]);
|
||||
|
||||
RuleFor(x => x.ParseMethod).NotNull().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotNull, nameof(EditTrackPullConfigInput.ParseMethod)]);
|
||||
|
||||
RuleFor(x => x.OrderNoName).NotEmpty().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotEmpty, nameof(EditTrackPullConfigInput.OrderNoName)]);
|
||||
|
||||
RuleFor(x => x.OrderPath).NotEmpty().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotEmpty, nameof(EditTrackPullConfigInput.OrderPath)]);
|
||||
|
||||
RuleFor(x => x.TrackDetailsPath).NotEmpty().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotEmpty, nameof(EditTrackPullConfigInput.TrackDetailsPath)]);
|
||||
|
||||
When(x => x.ParseMethod == 1, () =>
|
||||
{
|
||||
RuleFor(x => x.TackTimeZoneName).NotEmpty().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotEmpty, nameof(EditTrackPullConfigInput.TackTimeZoneName)]);
|
||||
RuleFor(x => x.TrackTimeZoneName).NotEmpty().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotEmpty, nameof(EditTrackPullConfigInput.TrackTimeZoneName)]);
|
||||
|
||||
RuleFor(x => x.TrackContentCodeName).NotEmpty().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotEmpty, nameof(EditTrackPullConfigInput.TrackContentCodeName)]);
|
||||
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
using FluentValidation;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SJZY.Expand.ABP.Core.Localization;
|
||||
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||
using SJZY.Track.Application.Localization;
|
||||
|
||||
namespace SJZY.Track.Application.Validations.TrackPull;
|
||||
|
||||
public class EditTrackPullContentInputValidation : AbstractValidator<EditTrackPullContentInput>, IValidationEnabled
|
||||
{
|
||||
public EditTrackPullContentInputValidation(IStringLocalizer<TrackLocalizationResource> stringLocalizer)
|
||||
{
|
||||
RuleFor(x => x.Options).IsInEnum().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum, nameof(EditTrackPullContentInput.Options)]);
|
||||
|
||||
RuleFor(x => x.Id).GreaterThan(0).WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_GreaterThan, nameof(EditTrackPullContentInput.Id), 0]);
|
||||
|
||||
RuleFor(x => x.TrackContentId).GreaterThan(0).WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_GreaterThan, nameof(EditTrackPullContentInput.TrackContentId), 0]);
|
||||
|
||||
RuleFor(x => x.TrackPullConfigId).GreaterThan(0).WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_GreaterThan, nameof(EditTrackPullContentInput.TrackPullConfigId), 0]);
|
||||
|
||||
When(x => x.Options != OptionTypeNoNull.新增, () =>
|
||||
{
|
||||
RuleFor(x => x.Id).NotNull().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotNull, nameof(EditTrackPullContentInput.Id)]);
|
||||
});
|
||||
|
||||
When(x => x.Options != OptionTypeNoNull.删除, () =>
|
||||
{
|
||||
RuleFor(x => x.TrackContentId).NotNull().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotNull, nameof(EditTrackPullContentInput.TrackContentId)]);
|
||||
|
||||
RuleFor(x => x.TrackPullConfigId).NotNull().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotNull, nameof(EditTrackPullContentInput.TrackPullConfigId)]);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -11,13 +11,6 @@ public interface IOrderRepository : IBasicRepository<OrderEntity>
|
||||
/// <returns></returns>
|
||||
Task CreateOrderAsync(OrderEntity order);
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页的轨迹订单
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<UnifyPageResultDto<TrackOrderVO>> GetPageTrackOrder(GetPageTrackOrderInputVO input);
|
||||
|
||||
/// <summary>
|
||||
/// 更新订单
|
||||
/// </summary>
|
||||
@ -57,12 +50,4 @@ public interface IOrderRepository : IBasicRepository<OrderEntity>
|
||||
Task UnLinkByIdsAsync(List<int> linkIds);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取订单模板列表
|
||||
/// </summary>
|
||||
/// <param name="orderNos"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<OrderTemplateVO>> GetOrderTemplatesAsync(List<string> orderNos);
|
||||
}
|
||||
@ -41,12 +41,12 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "IsCompleted")]
|
||||
public bool IsCompleted { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 订单是否推送完成(异步维护)
|
||||
/// 最新推送轨迹内容id(异步维护)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "IsPushCompleted")]
|
||||
public bool IsPushCompleted { get; set; }
|
||||
[SugarColumn(ColumnName = "LatestPushTrackContentId")]
|
||||
public int? LatestPushTrackContentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最新轨迹内容(异步维护)
|
||||
@ -65,7 +65,7 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LatestTrackTime")]
|
||||
public DateTime? LatestTrackTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 最新轨迹时区(异步维护)
|
||||
/// </summary>
|
||||
@ -108,14 +108,34 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
[SugarColumn(ColumnName = "LeaveCountry")]
|
||||
public string LeaveCountry { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型(主数据枚举TrackQuestionType)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "QuestionType")]
|
||||
public int QuestionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "ProblemDescription")]
|
||||
public int ProblemDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 起运港口
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LeavePort")]
|
||||
public string? LeavePort { get; set; }
|
||||
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<OrderFlightEntity> OrderFlights { get; set; }
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<OrderTemplateEntity> OrderTemplates { get; set; }
|
||||
[SugarColumn(IsIgnore = true)] public List<OrderFlightEntity> OrderFlights { get; set; }
|
||||
[SugarColumn(IsIgnore = true)] public List<OrderTemplateEntity> OrderTemplates { get; set; }
|
||||
|
||||
public void ResetTrackInfo()
|
||||
{
|
||||
IsCompleted = false;
|
||||
LatestTrackContent = null;
|
||||
LatestTrackEnContent = null;
|
||||
LatestTrackTime = null;
|
||||
LatestTrackPlace = null;
|
||||
LatestTrackTimeZone = null;
|
||||
}
|
||||
}
|
||||
@ -10,15 +10,25 @@ public interface ITrackDetailsRepository
|
||||
|
||||
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>?> GetListAsync(int orderId);
|
||||
|
||||
Task<List<TrackDetailsIndex>> GetListAsync(int orderId);
|
||||
|
||||
/// <summary>
|
||||
/// 删除轨迹
|
||||
/// </summary>
|
||||
/// <param name="orderId"></param>
|
||||
/// <param name="trackCodes"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteTrackAsync(int orderId, List<string> trackCodes);
|
||||
Task<bool> DeleteTrackAsync(int orderId, List<string> trackCodes);
|
||||
|
||||
Task<List<TrackDetailsIndex>?> GetListAsync(List<int> orderIds);
|
||||
|
||||
/// <summary>
|
||||
/// 获取最近一条发生的轨迹
|
||||
/// </summary>
|
||||
/// <param name="orderId"></param>
|
||||
/// <returns></returns>
|
||||
Task<TrackDetailsIndex?> GetLatestAsync(int orderId);
|
||||
}
|
||||
@ -11,6 +11,11 @@ public class TrackDetailsIndex : IdBaseIndex
|
||||
/// </summary>
|
||||
public int OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商code
|
||||
/// </summary>
|
||||
public string? ServiceProviderCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
@ -46,6 +51,16 @@ public class TrackDetailsIndex : IdBaseIndex
|
||||
/// </summary>
|
||||
public string TrackContent { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容Id
|
||||
/// </summary>
|
||||
public int TrackContentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否意味着完成
|
||||
/// </summary>
|
||||
public bool IsCompleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 原轨迹内容
|
||||
/// </summary>
|
||||
|
||||
@ -19,6 +19,13 @@ public interface ITrackPullConfigRepository : IBasicRepository<TrackPullConfigEn
|
||||
/// <returns></returns>
|
||||
Task<UnifyPageResultDto<GetTrackPullContentPageOutputVO>> GetContentPageAsync(GetTrackPullContentPageInputVO input);
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹拉取配置内容集合(缓存使用)
|
||||
/// </summary>
|
||||
/// <param name="trackPullConfigId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<GetTrackPullContentListCacheVO>> GetContentListCacheAsync(int trackPullConfigId);
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹拉取配置详情
|
||||
/// </summary>
|
||||
@ -35,7 +42,7 @@ public interface ITrackPullConfigRepository : IBasicRepository<TrackPullConfigEn
|
||||
|
||||
Task<bool> InsertParamsAsync(TrackPushPullParamsConfigEntity insertObj);
|
||||
|
||||
Task<bool> InsertContentRangeAsync(List<TrackPullContentConfigEntity> insertObjs);
|
||||
Task<bool> InsertContentAsync(TrackPullContentConfigEntity insertObj);
|
||||
|
||||
Task<TrackPushPullParamsConfigEntity> GetParamsSingleAsync(Expression<Func<TrackPushPullParamsConfigEntity, bool>> whereExpression);
|
||||
|
||||
|
||||
@ -35,10 +35,4 @@ public class TrackPullConfigEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "SubSystemId")]
|
||||
public int SubSystemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模板id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "TrackTemplateId")]
|
||||
public int TrackTemplateId { get; set; }
|
||||
}
|
||||
@ -39,8 +39,8 @@ public class TrackPushPullParamsConfigEntity : IFullAuditedBasicEntitys, IEntity
|
||||
/// <summary>
|
||||
/// 轨迹时区参数名
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "TackTimeZoneName")]
|
||||
public string TackTimeZoneName { get; set; }
|
||||
[SugarColumn(ColumnName = "TrackTimeZoneName")]
|
||||
public string TrackTimeZoneName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹代码参数名
|
||||
@ -77,4 +77,16 @@ public class TrackPushPullParamsConfigEntity : IFullAuditedBasicEntitys, IEntity
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "TrackTimeName")]
|
||||
public string TrackTimeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单路径
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "OrderPath")]
|
||||
public string OrderPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹明细路径
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "TrackDetailsPath")]
|
||||
public string TrackDetailsPath { get; set; }
|
||||
}
|
||||
@ -37,8 +37,14 @@ public class TrackPushConfigEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
public int SubSystemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模板id(多个之间英文逗号分隔)
|
||||
/// 是否支持更新
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "TrackTemplateId")]
|
||||
public string TrackTemplateId { get; set; }
|
||||
[SugarColumn(ColumnName = "IsCanUpdate")]
|
||||
public bool IsCanUpdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否支持删除
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "IsCanDelete")]
|
||||
public bool IsCanDelete { get; set; }
|
||||
}
|
||||
@ -39,8 +39,6 @@ public interface ITrackTemplateRepository : IBasicRepository<TrackTemplateEntity
|
||||
|
||||
Task<bool> UpdateContentRangeAsync(List<TrackTemplateContentEntity> updateObjs);
|
||||
|
||||
Task<UnifyPageResultDto<DropdownListDataDto>> GetContentDropDownListAsync(GetTrackTemplateContentDropDownListVO input);
|
||||
|
||||
Task<T> ContentMaxAsync<T>(Expression<Func<TrackTemplateContentEntity, T>> columns, Expression<Func<TrackTemplateContentEntity, bool>> whereExpression);
|
||||
|
||||
Task<bool> UpdateContentAsync(Expression<Func<TrackTemplateContentEntity, bool>> columns, Expression<Func<TrackTemplateContentEntity, bool>> whereExpression);
|
||||
|
||||
@ -18,6 +18,25 @@ namespace SJZY.Track.Domain.Dtos.Order
|
||||
///// </summary>
|
||||
//public List<string>? OrderNos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当tab选中 0 默认不传 1 直接写死传值 [1,4] 2 传 [2,4]
|
||||
/// </summary>
|
||||
public int TabType { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 当tab选中 1 直接写死传值 [1,4] 2 传 [2,4]
|
||||
///// </summary>
|
||||
//public List<int>? QuestionTypeIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
public int? TrackOrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户id
|
||||
/// </summary>
|
||||
public int? CustomerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单号
|
||||
@ -51,9 +70,9 @@ namespace SJZY.Track.Domain.Dtos.Order
|
||||
public int OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单名称
|
||||
/// 订单类型名称
|
||||
/// </summary>
|
||||
public string OrderTypeName { get; set; }
|
||||
public string? OrderTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
@ -75,6 +94,11 @@ namespace SJZY.Track.Domain.Dtos.Order
|
||||
/// </summary>
|
||||
public string? CustomerCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户id
|
||||
/// </summary>
|
||||
public int CustomerId { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 订单明细(json)
|
||||
///// </summary>
|
||||
@ -124,5 +148,25 @@ namespace SJZY.Track.Domain.Dtos.Order
|
||||
/// 轨迹模板Id数组
|
||||
/// </summary>
|
||||
public List<int>? TrackTemplateIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型(主数据枚举TrackQuestionType)
|
||||
/// </summary>
|
||||
public int QuestionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型名称
|
||||
/// </summary>
|
||||
public string? QuestionTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述(主数据枚举TrackProblemDescription)
|
||||
/// </summary>
|
||||
public int ProblemDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题描述名称
|
||||
/// </summary>
|
||||
public string? ProblemDescriptionName { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ public class LinkedOrderVO
|
||||
/// 关联订单id
|
||||
/// </summary>
|
||||
public int OrderId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
@ -21,12 +21,12 @@ public class LinkedOrderVO
|
||||
/// 子系统id
|
||||
/// </summary>
|
||||
public int SubSystemId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 订单是否推送完成(异步维护)
|
||||
/// 最新推送轨迹内容id(异步维护)
|
||||
/// </summary>
|
||||
public bool IsPushCompleted { get; set; }
|
||||
|
||||
public int? LatestPushTrackContentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户id
|
||||
/// </summary>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
namespace SJZY.Track.Domain.Dtos.Order;
|
||||
|
||||
public class OrderTemplateVO
|
||||
public class OrderWithServiceProviderVO
|
||||
{
|
||||
public string OrderNo { get; set; } = null!;
|
||||
|
||||
@ -8,8 +8,16 @@ public class OrderTemplateVO
|
||||
/// 订单类型(主数据枚举TrackOrderType)
|
||||
/// </summary>
|
||||
public int OrderType { get; set; }
|
||||
|
||||
public int TemplateId { get; set; }
|
||||
|
||||
|
||||
public int ServiceProviderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商code
|
||||
/// </summary>
|
||||
public string ServiceProviderCode { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 子系统id
|
||||
/// </summary>
|
||||
public int SubSystemId { get; set; }
|
||||
}
|
||||
@ -2,6 +2,11 @@
|
||||
|
||||
public class MatchTrackContentDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹内容id
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容
|
||||
/// </summary>
|
||||
|
||||
@ -42,7 +42,7 @@ public class GetTrackPullConfigDetailOutputVO
|
||||
/// <summary>
|
||||
/// 拉取轨迹时区
|
||||
/// </summary>
|
||||
public string TackTimeZoneName { get; set; }
|
||||
public string TrackTimeZoneName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 拉取轨迹内容代码
|
||||
@ -64,18 +64,18 @@ public class GetTrackPullConfigDetailOutputVO
|
||||
/// </summary>
|
||||
public string TrackStatusName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板
|
||||
/// </summary>
|
||||
public string TrackTemplate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板id
|
||||
/// </summary>
|
||||
public int TrackTemplateId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 拉取轨迹发生时间
|
||||
/// </summary>
|
||||
public string TrackTimeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单路径
|
||||
/// </summary>
|
||||
public string OrderPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹明细路径
|
||||
/// </summary>
|
||||
public string TrackDetailsPath { get; set; }
|
||||
}
|
||||
@ -20,7 +20,7 @@ public class GetTrackPullConfigPageOutputVO
|
||||
public string SubSystem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模板名称
|
||||
/// 子系统id
|
||||
/// </summary>
|
||||
public string TrackTemplate { get; set; }
|
||||
public int SubSystemId { get; set; }
|
||||
}
|
||||
@ -1,12 +1,17 @@
|
||||
namespace SJZY.Track.Domain.Dtos.Order;
|
||||
namespace SJZY.Track.Domain.Dtos.TrackPull;
|
||||
|
||||
public class TrackPullContentConfigVO
|
||||
public class GetTrackPullContentListCacheVO
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹内容id
|
||||
/// 轨迹内容代码
|
||||
/// </summary>
|
||||
public int TrackContentId { get; set; }
|
||||
|
||||
public string TrackContentCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商轨迹状态参数值
|
||||
/// </summary>
|
||||
public string? TrackStatusValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商轨迹代码参数值
|
||||
/// </summary>
|
||||
@ -32,13 +37,8 @@ public class TrackPullContentConfigVO
|
||||
/// </summary>
|
||||
public int? TrackPlaceValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商轨迹状态参数值
|
||||
/// </summary>
|
||||
public string? TrackStatusValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹时区GMT
|
||||
/// </summary>
|
||||
public double? TrackTimeZone { get; set; }
|
||||
public float? TrackTimeZone { get; set; }
|
||||
}
|
||||
@ -54,7 +54,7 @@ public class GetTrackPushConfigDetailOutputVO
|
||||
/// <summary>
|
||||
/// 推送轨迹时区
|
||||
/// </summary>
|
||||
public string TackTimeZoneName { get; set; }
|
||||
public string TrackTimeZoneName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 推送轨迹内容代码
|
||||
@ -81,23 +81,18 @@ public class GetTrackPushConfigDetailOutputVO
|
||||
/// </summary>
|
||||
public string TrackStatusName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板
|
||||
/// </summary>
|
||||
public List<DropdownListDataDto> TrackTemplate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板id
|
||||
/// </summary>
|
||||
public string TrackTemplateId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板ids
|
||||
/// </summary>
|
||||
public List<int> TrackTemplateIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 推送轨迹发生时间
|
||||
/// </summary>
|
||||
public string TrackTimeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否支持更新
|
||||
/// </summary>
|
||||
public bool IsCanUpdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否支持删除
|
||||
/// </summary>
|
||||
public bool IsCanDelete { get; set; }
|
||||
}
|
||||
@ -20,17 +20,7 @@ public class GetTrackPushConfigPageOutputVO
|
||||
public string SubSystem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模板名称
|
||||
/// 子系统id
|
||||
/// </summary>
|
||||
public string TrackTemplate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板id
|
||||
/// </summary>
|
||||
public string TrackTemplateId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板ids
|
||||
/// </summary>
|
||||
public List<int> TrackTemplateIds { get; set; }
|
||||
public int SubSystemId { get; set; }
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
namespace SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
|
||||
public class CanDeleteTrackCodeVO
|
||||
{
|
||||
public int OrderId { get; set; }
|
||||
public string TrackCode { get; set; }
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
namespace SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
|
||||
public class GetTrackTemplateContentDropDownListVO : PageInfoInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹模板id
|
||||
/// </summary>
|
||||
public List<int> TrackTemplateIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 选中项
|
||||
/// </summary>
|
||||
public List<int>? SelectedIds { get; set; }
|
||||
}
|
||||
@ -15,5 +15,10 @@ public enum EnumPropertyEnums
|
||||
/// <summary>
|
||||
/// 单号类型
|
||||
/// </summary>
|
||||
[Description("TrackOrderType")] 单号类型
|
||||
[Description("TrackOrderType")] 单号类型,
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地
|
||||
/// </summary>
|
||||
[Description("TrackLocationValue")] 轨迹发生地
|
||||
}
|
||||
11
src/SJZY.Track.Domain/Enums/TrackLocationValue.cs
Normal file
11
src/SJZY.Track.Domain/Enums/TrackLocationValue.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace SJZY.Track.Domain.Enums;
|
||||
|
||||
public enum TrackLocationValue
|
||||
{
|
||||
ArrivalPort = 2,
|
||||
LeavePort = 3,
|
||||
ArrivalCountry = 4,
|
||||
LeaveCountry = 5,
|
||||
ArriveCity = 6,
|
||||
LeaveCity = 7
|
||||
}
|
||||
15
src/SJZY.Track.Domain/Enums/TrackProblemType.cs
Normal file
15
src/SJZY.Track.Domain/Enums/TrackProblemType.cs
Normal file
@ -0,0 +1,15 @@
|
||||
namespace SJZY.Track.Domain.Enums;
|
||||
|
||||
[Flags]
|
||||
public enum TrackProblemType
|
||||
{
|
||||
/// <summary>
|
||||
/// 异常
|
||||
/// </summary>
|
||||
Error = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 预警
|
||||
/// </summary>
|
||||
Warn = 2,
|
||||
}
|
||||
@ -11,24 +11,44 @@ public class GlobalConst
|
||||
/// 轨迹新增/更新 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 InterfaceRelayTrackRefreshSubscribe = "SJZY.Track.TrackRefresh";
|
||||
public const string TrackRefreshSubscribe = "SJZY.Track.TrackRefresh";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹新增/更新后触发更新订单轨迹 mq订阅名称
|
||||
/// </summary>
|
||||
public const string UpdateOrderTrackSubscribe = "SJZY.Track.UpdateOrderTrack";
|
||||
|
||||
/// <summary>
|
||||
/// 关联订单后补轨迹 mq订阅名称
|
||||
/// </summary>
|
||||
public const string OrderLinkAfterFillTrack = "SJZY.Track.OrderLinkAfterFillTrack";
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹要推送的客户redis key前缀
|
||||
/// </summary>
|
||||
public const string TrackPushKeyPrefix = "TrackPush:";
|
||||
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";
|
||||
}
|
||||
@ -9,7 +9,7 @@ public interface IBasicQuery<T> where T : IEntity
|
||||
/// <returns></returns>
|
||||
Task<T?> GetFirstAsync(Expression<Func<T, bool>> whereExpression);
|
||||
|
||||
Task<TResult> GetFirstAsync<TResult>(Expression<Func<T, bool>> whereExpression,
|
||||
Task<TResult?> GetFirstAsync<TResult>(Expression<Func<T, bool>> whereExpression,
|
||||
Expression<Func<T, TResult>> resultExpression);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Order;
|
||||
using SJZY.Track.Domain.Dtos.TrackDetails;
|
||||
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
@ -32,14 +31,14 @@ public interface IProvideQueries
|
||||
/// <param name="code">轨迹代码</param>
|
||||
/// <returns></returns>
|
||||
Task<MatchTrackContentDto?> MatchTrackContentAsync(int orderId, string code);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取可删除的订单轨迹代码
|
||||
/// </summary>
|
||||
/// <param name="orderId"></param>
|
||||
/// <param name="orderIds"></param>
|
||||
/// <param name="trackCodes"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<string>> GetCanDeleteTrackCodesAsync(int orderId, List<string> trackCodes);
|
||||
Task<List<CanDeleteTrackCodeVO>> GetCanDeleteTrackCodesAsync(List<int> orderIds, List<string> trackCodes);
|
||||
|
||||
/// <summary>
|
||||
/// 根据子系统内容映射,得到映射后的轨迹code
|
||||
@ -51,9 +50,16 @@ public interface IProvideQueries
|
||||
Task<List<string>> MapTrackCodesAsync(int upSubSystemId, int subSystemId, params string[] trackCodes);
|
||||
|
||||
/// <summary>
|
||||
/// 获取服务商模板配置
|
||||
/// 根据订单模板找对应服务商
|
||||
/// </summary>
|
||||
/// <param name="serviceProviderId"></param>
|
||||
/// <param name="orderNos"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<TrackPullContentConfigVO>> GetPullContentConfigsAsync(int serviceProviderId);
|
||||
Task<List<OrderWithServiceProviderVO>> FindOrderWithServiceProviderAsync(List<string> orderNos);
|
||||
|
||||
/// <summary>
|
||||
/// 获取服务商下所有单(未完成的)
|
||||
/// </summary>
|
||||
/// <param name="serviceProvider"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<OrderWithServiceProviderVO>> FindOrderWithServiceProviderAsync(int serviceProvider);
|
||||
}
|
||||
13
src/SJZY.Track.Domain/Queries/ITrackOrderQueries.cs
Normal file
13
src/SJZY.Track.Domain/Queries/ITrackOrderQueries.cs
Normal file
@ -0,0 +1,13 @@
|
||||
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);
|
||||
}
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -13,7 +13,7 @@ public class BasicQuery<T> : SimpleClient<T>, IBasicQuery<T> where T : class, IE
|
||||
Context = SqlsugarScopeBasic.GetContextSafely("default");
|
||||
}
|
||||
|
||||
public async Task<TResult> GetFirstAsync<TResult>(Expression<Func<T, bool>> whereExpression,
|
||||
public async Task<TResult?> GetFirstAsync<TResult>(Expression<Func<T, bool>> whereExpression,
|
||||
Expression<Func<T, TResult>> resultExpression)
|
||||
{
|
||||
return await Context.Queryable<T>().Where(whereExpression).Select(resultExpression).FirstAsync();
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Order;
|
||||
using SJZY.Track.Domain.Dtos.TrackDetails;
|
||||
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
using SJZY.Track.Domain.VEntities;
|
||||
|
||||
namespace SJZY.Track.Repository.Queries;
|
||||
|
||||
@ -71,6 +71,7 @@ public class ProvideQueries : ISugarRepository, IProvideQueries,
|
||||
.Where((x, a, b) => x.OrderId == orderId && b.Code == code)
|
||||
.Select((x, a, b, c) => new MatchTrackContentDto
|
||||
{
|
||||
Id = b.Id,
|
||||
Content = b.Content,
|
||||
EnContent = b.EnContent,
|
||||
Status = c.Status,
|
||||
@ -80,14 +81,19 @@ public class ProvideQueries : ISugarRepository, IProvideQueries,
|
||||
.FirstAsync();
|
||||
}
|
||||
|
||||
public async Task<List<string>> GetCanDeleteTrackCodesAsync(int orderId, List<string> trackCodes)
|
||||
public async Task<List<CanDeleteTrackCodeVO>> GetCanDeleteTrackCodesAsync(List<int> orderIds,
|
||||
List<string> trackCodes)
|
||||
{
|
||||
return await Context.Queryable<OrderTemplateEntity>()
|
||||
.LeftJoin<TrackTemplateContentEntity>((x, a) => x.TrackTemplateId == a.TrackTemplateId && a.IsCanDelete)
|
||||
.LeftJoin<TrackContentEntity>((x, a, b) => a.TrackContentId == b.Id)
|
||||
.Where((x, a, b) => x.OrderId == orderId
|
||||
.Where((x, a, b) => orderIds.Contains(x.OrderId)
|
||||
&& trackCodes.Contains(b.Code) && a.IsCanDelete)
|
||||
.Select((x, a, b) => b.Code)
|
||||
.Select((x, a, b) => new CanDeleteTrackCodeVO
|
||||
{
|
||||
OrderId = x.OrderId,
|
||||
TrackCode = b.Code
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
@ -101,21 +107,38 @@ public class ProvideQueries : ISugarRepository, IProvideQueries,
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<TrackPullContentConfigVO>> GetPullContentConfigsAsync(int serviceProviderId)
|
||||
|
||||
public async Task<List<OrderWithServiceProviderVO>> FindOrderWithServiceProviderAsync(List<string> orderNos)
|
||||
{
|
||||
return await Context.Queryable<TrackPullConfigEntity>()
|
||||
.LeftJoin<TrackPullContentConfigEntity>((a, b) => a.Id == b.TrackPullConfigId)
|
||||
.Where(a => a.ServiceProviderId == serviceProviderId)
|
||||
.Select(x => new TrackPullContentConfigVO
|
||||
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 OrderWithServiceProviderVO
|
||||
{
|
||||
TrackContentId = 0,
|
||||
TrackContentCodeValue = null,
|
||||
TrackContentValue = null,
|
||||
TrackKeyword = null,
|
||||
TrackKeywordReverse = null,
|
||||
TrackPlaceValue = null,
|
||||
TrackStatusValue = null,
|
||||
TrackTimeZone = null
|
||||
}).ToListAsync();
|
||||
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();
|
||||
}
|
||||
}
|
||||
117
src/SJZY.Track.Repository/Queries/TrackOrderQueries.cs
Normal file
117
src/SJZY.Track.Repository/Queries/TrackOrderQueries.cs
Normal file
@ -0,0 +1,117 @@
|
||||
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)
|
||||
{
|
||||
List<string> orderNoList = new List<string>();
|
||||
List<int> questionTypeIds = new List<int>();
|
||||
int ques = 0;
|
||||
if (!input.OrderNos.IsNullOrWhiteSpace())
|
||||
{
|
||||
orderNoList = input.OrderNos!.Split(new[] { ',', ',', ':', ':' }).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 { 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;
|
||||
}
|
||||
}
|
||||
@ -1,24 +1,11 @@
|
||||
using SJZY.Track.Domain;
|
||||
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.VEntities;
|
||||
using SJZY.Track.Repository.VData.Entitys;
|
||||
|
||||
namespace SJZY.Track.Repository.Repositories;
|
||||
|
||||
public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, ITransientDependency
|
||||
{
|
||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||
|
||||
public OrderRepository(
|
||||
ITrackDetailsRepository trackDetailsRepository
|
||||
)
|
||||
{
|
||||
this._trackDetailsRepository=trackDetailsRepository;
|
||||
}
|
||||
|
||||
public async Task CreateOrderAsync(OrderEntity order)
|
||||
{
|
||||
using var tran = TransactionHelper.GetReadCommitted();
|
||||
@ -79,7 +66,7 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
OrderType = b.OrderType,
|
||||
OrderNo = b.OrderNo,
|
||||
SubSystemId = b.SubSystemId,
|
||||
IsPushCompleted = b.IsPushCompleted,
|
||||
LatestPushTrackContentId = b.LatestPushTrackContentId,
|
||||
CustomId = b.CustomId
|
||||
})
|
||||
.ToListAsync();
|
||||
@ -96,161 +83,4 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
}
|
||||
|
||||
#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>();
|
||||
if (!input.OrderNos.IsNullOrWhiteSpace())
|
||||
{
|
||||
orderNoList = input.OrderNos.Split(new char[] { ',', ',', ':', ':' }).ToList();
|
||||
}
|
||||
|
||||
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)
|
||||
.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,
|
||||
//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).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)
|
||||
.Where(a => orderNos.Contains(a.OrderNo))
|
||||
.Select((a, b) => new OrderTemplateVO
|
||||
{
|
||||
OrderNo = a.OrderNo,
|
||||
OrderType = a.OrderType,
|
||||
TemplateId = b.TrackTemplateId,
|
||||
ServiceProviderId = b.ServiceProviderId
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
@ -38,7 +38,8 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
{
|
||||
// 按天写入es
|
||||
var r = await Context.IndexAsync(index, request => request
|
||||
.Index(index.IndexName)
|
||||
.Index(index.IndexName)
|
||||
//.Refresh(Refresh.True) // 可选:立即刷新索引使更改立即可见
|
||||
);
|
||||
|
||||
if (!r.IsValid)
|
||||
@ -86,7 +87,12 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
return data.Documents.ToList();
|
||||
}
|
||||
|
||||
public async Task<List<TrackDetailsIndex>?> GetListAsync(int orderId)
|
||||
public Task<List<TrackDetailsIndex>> GetListAsync(int orderType, List<string> orderNos, string trackCode)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<List<TrackDetailsIndex>> GetListAsync(int orderId)
|
||||
{
|
||||
var data = await Context.SearchAsync<TrackDetailsIndex>(x => x
|
||||
.Query(q =>
|
||||
@ -95,7 +101,7 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
.Size(1000)
|
||||
.Sort(s => s.Field(f => f.TrackTime, SortOrder.Descending)));
|
||||
|
||||
return data?.Documents?.ToList();
|
||||
return data.Documents.ToList();
|
||||
}
|
||||
|
||||
public async Task<List<TrackDetailsIndex>?> GetListAsync(List<int> orderIds)
|
||||
@ -109,18 +115,42 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
return data?.Documents?.ToList();
|
||||
}
|
||||
|
||||
public async Task DeleteTrackAsync(int orderId, List<string> trackCodes)
|
||||
public async Task<TrackDetailsIndex?> GetLatestAsync(int orderId)
|
||||
{
|
||||
var data = await Context.SearchAsync<TrackDetailsIndex>(x => x
|
||||
.Source(s => s.Includes(fd => fd
|
||||
.Field(f => f.IsCompleted)
|
||||
.Field(f => f.TrackEnContent)
|
||||
.Field(f => f.TrackContent)
|
||||
.Field(f => f.TrackPlace)
|
||||
.Field(f => f.TrackTime)
|
||||
.Field(f => f.TrackTimeZone)
|
||||
))
|
||||
.Query(q =>
|
||||
q.Term(f => f.OrderId, orderId)
|
||||
)
|
||||
.Sort(s => s.Field(f => f.TrackTime, SortOrder.Descending))
|
||||
.Size(1)
|
||||
);
|
||||
|
||||
return data.Documents.FirstOrDefault();
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteTrackAsync(int orderId, List<string> trackCodes)
|
||||
{
|
||||
var r = await Context.DeleteByQueryAsync<TrackDetailsIndex>(x => x
|
||||
.Query(
|
||||
q =>
|
||||
q.Term(t => t.OrderId, orderId)
|
||||
&& q.Term(t => t.IsCanDelete, true)
|
||||
&& q.Terms(t => t.Field(f => f.TrackCode.Suffix("keyword")).Terms(trackCodes)))
|
||||
.Query(
|
||||
q =>
|
||||
q.Term(t => t.OrderId, orderId)
|
||||
&& q.Term(t => t.IsCanDelete, true)
|
||||
&& q.Terms(t => t.Field(f => f.TrackCode.Suffix("keyword")).Terms(trackCodes)))
|
||||
.Refresh() // 可选:立即刷新索引使更改立即可见
|
||||
);
|
||||
|
||||
if (!r.IsValid)
|
||||
throw new Exception($"轨迹数据删除失败,原因:{r.DebugInformation}");
|
||||
|
||||
return r.Deleted > 0;
|
||||
}
|
||||
|
||||
public async Task<(List<TrackDetailsIndex> list, long total)> GetListAsync(TrackDetailsQueryInput input)
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
using System.Linq.Expressions;
|
||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Common;
|
||||
using SJZY.Track.Domain.Dtos.TrackPull;
|
||||
using SJZY.Track.Domain.Enums;
|
||||
using SJZY.Track.Domain.VEntities;
|
||||
|
||||
namespace SJZY.Track.Repository.Repositories;
|
||||
@ -16,18 +17,17 @@ public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>,
|
||||
return await AsQueryable()
|
||||
.LeftJoin<VSystemEntity>((trackPull, system) => trackPull.SubSystemId == system.Id && !system.IsDeleted)
|
||||
.LeftJoin<VServiceProviderEntity>((trackPull, system, service) => trackPull.ServiceProviderId == service.Id && !service.IsDeleted)
|
||||
.LeftJoin<TrackTemplateEntity>((trackPull, system, service, template) => trackPull.TrackTemplateId == template.Id && !template.IsDeleted)
|
||||
.Filter(null, true)
|
||||
.Where(trackPull => !trackPull.IsDeleted)
|
||||
.WhereIF(input.SubSystemId.HasValue, trackPull => trackPull.SubSystemId == input.SubSystemId)
|
||||
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (trackPull, system, service, template) => service.Name.Contains(input.Keywords) || template.Name.Contains(input.Keywords))
|
||||
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (trackPull, system, service) => service.Name.Contains(input.Keywords!))
|
||||
.OrderByDescending(trackPull => trackPull.CreateTime)
|
||||
.Select((trackPull, system, service, template) => new GetTrackPullConfigPageOutputVO
|
||||
.Select((trackPull, system, service) => new GetTrackPullConfigPageOutputVO
|
||||
{
|
||||
Id = trackPull.Id,
|
||||
SubSystemId = system.Id,
|
||||
SubSystem = system.CnName,
|
||||
ServiceProvider = service.Name,
|
||||
TrackTemplate = template.Name,
|
||||
CreateTime = trackPull.CreateTime
|
||||
})
|
||||
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||
@ -37,32 +37,42 @@ public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>,
|
||||
{
|
||||
return await Context.Queryable<TrackPullContentConfigEntity>()
|
||||
.InnerJoin<TrackContentEntity>((pullContent, trackContent) => pullContent.TrackContentId == trackContent.Id)
|
||||
.InnerJoin<TrackPullConfigEntity>((pullContent, trackContent, trackPull) => pullContent.TrackPullConfigId == trackPull.Id)
|
||||
.InnerJoin<TrackTemplateContentEntity>((pullContent, trackContent, trackPull, templateContent) => trackPull.TrackTemplateId == templateContent.TrackTemplateId && pullContent.TrackContentId == templateContent.TrackContentId)
|
||||
.LeftJoin<VEnumValueInfoEntity>((pullContent, trackContent, enumValue) => enumValue.Property == EnumPropertyEnums.轨迹发生地.GetDescription() && pullContent.TrackPlaceValue == enumValue.Enumkey)
|
||||
.Where(pullContent => pullContent.TrackPullConfigId == input.TrackPullConfigId)
|
||||
.OrderBy((pullContent, trackContent, trackPull, templateContent) => templateContent.Sort)
|
||||
.Select((pullContent, trackContent, trackPull, templateContent) => new GetTrackPullContentPageOutputVO
|
||||
.OrderBy(pullContent => pullContent.CreateTime)
|
||||
.Select((pullContent, trackContent, enumValue) => new GetTrackPullContentPageOutputVO
|
||||
{
|
||||
Id = pullContent.Id
|
||||
Id = pullContent.Id,
|
||||
TrackPlaceValue = enumValue.Disp
|
||||
}, true)
|
||||
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||
}
|
||||
|
||||
public async Task<List<GetTrackPullContentListCacheVO>> GetContentListCacheAsync(int trackPullConfigId)
|
||||
{
|
||||
return await Context.Queryable<TrackPullContentConfigEntity>()
|
||||
.InnerJoin<TrackContentEntity>((pullContent, trackContent) => pullContent.TrackContentId == trackContent.Id)
|
||||
.Where(pullContent => pullContent.TrackPullConfigId == trackPullConfigId)
|
||||
.Select((pullContent, trackContent) => new GetTrackPullContentListCacheVO
|
||||
{
|
||||
TrackContentCode = trackContent.Code
|
||||
}, true)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<GetTrackPullConfigDetailOutputVO> GetDetailAsync(int id)
|
||||
{
|
||||
return await AsQueryable()
|
||||
.LeftJoin<VSystemEntity>((trackPull, system) => trackPull.SubSystemId == system.Id && !system.IsDeleted)
|
||||
.LeftJoin<VServiceProviderEntity>((trackPull, system, service) => trackPull.ServiceProviderId == service.Id && !service.IsDeleted)
|
||||
.LeftJoin<TrackTemplateEntity>((trackPull, system, service, template) => trackPull.TrackTemplateId == template.Id && !template.IsDeleted)
|
||||
.InnerJoin<TrackPushPullParamsConfigEntity>((trackPull, system, service, template, paramsConfig) => trackPull.Id == paramsConfig.PullOrPushConfigId && !paramsConfig.IsPush && !paramsConfig.IsDeleted)
|
||||
.InnerJoin<TrackPushPullParamsConfigEntity>((trackPull, system, service, paramsConfig) => trackPull.Id == paramsConfig.PullOrPushConfigId && !paramsConfig.IsPush && !paramsConfig.IsDeleted)
|
||||
.Filter(null, true)
|
||||
.Where(trackPull => trackPull.Id == id && !trackPull.IsDeleted)
|
||||
.Select((trackPull, system, service, template, paramsConfig) => new GetTrackPullConfigDetailOutputVO
|
||||
.Select((trackPull, system, service, paramsConfig) => new GetTrackPullConfigDetailOutputVO
|
||||
{
|
||||
Id = trackPull.Id,
|
||||
SubSystem = system.CnName,
|
||||
ServiceProvider = service.Name,
|
||||
TrackTemplate = template.Name
|
||||
ServiceProvider = service.Name
|
||||
}, true)
|
||||
.SingleAsync();
|
||||
}
|
||||
@ -90,9 +100,9 @@ public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>,
|
||||
return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
|
||||
public async Task<bool> InsertContentRangeAsync(List<TrackPullContentConfigEntity> insertObjs)
|
||||
public async Task<bool> InsertContentAsync(TrackPullContentConfigEntity insertObj)
|
||||
{
|
||||
return await Context.Insertable(insertObjs).ExecuteCommandAsync() > 0;
|
||||
return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
|
||||
public async Task<TrackPushPullParamsConfigEntity> GetParamsSingleAsync(Expression<Func<TrackPushPullParamsConfigEntity, bool>> whereExpression)
|
||||
|
||||
@ -20,25 +20,19 @@ public class TrackPushConfigRepository : BasicRepository<TrackPushConfigEntity>,
|
||||
return await AsQueryable()
|
||||
.LeftJoin<VSystemEntity>((trackPush, system) => trackPush.SubSystemId == system.Id && !system.IsDeleted)
|
||||
.LeftJoin<VExternalSubjectEntity>((trackPush, system, externalSubject) => trackPush.CustomId == externalSubject.Id && !externalSubject.IsDeleted)
|
||||
.LeftJoin<TrackTemplateEntity>((trackPush, system, externalSubject, template) => SqlFunc.SplitIn(trackPush.TrackTemplateId, template.Id.ToString()) && !template.IsDeleted)
|
||||
.Filter(null, true)
|
||||
.Where(trackPush => !trackPush.IsDeleted)
|
||||
.WhereIF(input.SubSystemId.HasValue, trackPush => trackPush.SubSystemId == input.SubSystemId)
|
||||
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (trackPush, system, externalSubject, template) => externalSubject.Abbreviation.Contains(input.Keywords) || externalSubject.Name.Contains(input.Keywords) || template.Name.Contains(input.Keywords))
|
||||
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (trackPush, system, externalSubject) => externalSubject.Abbreviation.Contains(input.Keywords!) || externalSubject.Name.Contains(input.Keywords!))
|
||||
.OrderByDescending(trackPush => trackPush.CreateTime)
|
||||
.Select((trackPush, system, externalSubject, template) => new GetTrackPushConfigPageOutputVO
|
||||
.Select((trackPush, system, externalSubject) => new GetTrackPushConfigPageOutputVO
|
||||
{
|
||||
Id = trackPush.Id,
|
||||
SubSystemId = system.Id,
|
||||
SubSystem = system.CnName,
|
||||
CustomName = externalSubject.Abbreviation,
|
||||
TrackTemplate = SqlFunc.Subqueryable<TrackTemplateEntity>()
|
||||
.Where(template => SqlFunc.SplitIn(trackPush.TrackTemplateId, template.Id.ToString()) && !template.IsDeleted)
|
||||
.SelectStringJoin(template => template.Name, ","),
|
||||
TrackTemplateId = trackPush.TrackTemplateId,
|
||||
CreateTime = trackPush.CreateTime
|
||||
})
|
||||
.Distinct()
|
||||
.Mapper(x => { x.TrackTemplateIds = x.TrackTemplateId.Split(',').Select(int.Parse).ToList(); })
|
||||
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||
}
|
||||
|
||||
@ -74,7 +68,6 @@ public class TrackPushConfigRepository : BasicRepository<TrackPushConfigEntity>,
|
||||
CustomName = externalSubject.Abbreviation,
|
||||
ServiceProvider = service.Name,
|
||||
}, true)
|
||||
.Mapper(x => { x.TrackTemplateIds = x.TrackTemplateId.Split(',').Select(int.Parse).ToList(); })
|
||||
.SingleAsync();
|
||||
}
|
||||
|
||||
|
||||
@ -71,8 +71,6 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
|
||||
/// <returns></returns>
|
||||
public async Task<GetTemplateContentAttributeValueVO> GetTrackContentAttributeValue(GetTemplateContentAttributeValueInputVO input)
|
||||
{
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -176,22 +174,6 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
|
||||
return await Context.Updateable(updateObjs).ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
|
||||
public async Task<UnifyPageResultDto<DropdownListDataDto>> GetContentDropDownListAsync(GetTrackTemplateContentDropDownListVO input)
|
||||
{
|
||||
return await Context.Queryable<TrackTemplateContentEntity>()
|
||||
.InnerJoin<TrackContentEntity>((templateContent, trackContent) => templateContent.TrackContentId == trackContent.Id)
|
||||
.Where(templateContent => input.TrackTemplateIds.Contains(templateContent.TrackTemplateId))
|
||||
.OrderByIF(input.SelectedIds.IsNullOrEmpty(), templateContent => templateContent.CreateTime, OrderByType.Desc)
|
||||
.OrderByIF(!input.SelectedIds.IsNullOrEmpty(), templateContent => SqlFunc.IIF(input.SelectedIds.Contains(templateContent.TrackContentId), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), templateContent.CreateTime), OrderByType.Desc)
|
||||
.Select((templateContent, trackContent) => new DropdownListDataDto
|
||||
{
|
||||
Value = templateContent.TrackContentId,
|
||||
Key = trackContent.Code + "-" + trackContent.Content
|
||||
})
|
||||
.Distinct()
|
||||
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||
}
|
||||
|
||||
public async Task<T> ContentMaxAsync<T>(Expression<Func<TrackTemplateContentEntity, T>> columns, Expression<Func<TrackTemplateContentEntity, bool>> whereExpression)
|
||||
{
|
||||
return await Context.Queryable<TrackTemplateContentEntity>().Where(whereExpression).MaxAsync(columns);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user