diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/BatchDeleteTrackInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/BatchDeleteTrackInput.cs
new file mode 100644
index 00000000..0a79e008
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/BatchDeleteTrackInput.cs
@@ -0,0 +1,12 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
+
+public class BatchDeleteTrackInput : OrderNosInfo
+{
+ ///
+ /// 轨迹code,必填
+ ///
+ [Required]
+ public List TrackCodes { get; set; } = new();
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/BatchUpsertTrackInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/BatchUpsertTrackInput.cs
new file mode 100644
index 00000000..fa5d3880
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/BatchUpsertTrackInput.cs
@@ -0,0 +1,33 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
+
+public class BatchUpsertTrackInput : OrderNosInfo
+{
+ ///
+ /// 轨迹内容代码
+ ///
+ [Required]
+ [MaxLength(50)]
+ public string TrackCode { get; set; } = null!;
+
+ ///
+ /// 轨迹发生地
+ ///
+ [Required]
+ [MaxLength(200)]
+ public string TrackPlace { get; set; } = null!;
+
+ ///
+ /// 轨迹发生时间
+ ///
+ [Required]
+ public DateTime? TrackTime { get; set; }
+
+ ///
+ /// 轨迹发生时区
+ ///
+ [Required]
+ [Range(-12, 12)]
+ public float? TrackTimeZone { get; set; }
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/DeleteOrderInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/DeleteOrderInput.cs
index 0e318811..bff3df6e 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/DeleteOrderInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/DeleteOrderInput.cs
@@ -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
///
/// 轨迹code
///
+ [Required]
public List TrackCodes { get; set; } = new();
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetOrderDetailsInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetOrderDetailsInput.cs
index 3920f5c1..9ec96ba5 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetOrderDetailsInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetOrderDetailsInput.cs
@@ -32,6 +32,16 @@ namespace SJZY.Track.Application.Contract.Dtos.ProvideServices
///
public int OrderId { set; get; }
+ ///
+ /// 订单类型(主数据枚举TrackOrderType)
+ ///
+ public int OrderType { get; set; }
+
+ ///
+ /// 订单号
+ ///
+ public string OrderNo { get; set; } = null!;
+
///
/// 轨迹代码
///
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs
index 81aa553e..c6a143df 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs
@@ -17,6 +17,26 @@ public class GetPageTrackOrderInput : PageInfoInput
///
public string? OrderNos { get; set; }
+ ///
+ /// tab标签类型 0 全部, 1 异常 2 预警
+ ///
+ public int TabType { get; set; }
+
+ ///
+ /// 订单类型
+ ///
+ public int? TrackOrderType { get; set; }
+
+ ///
+ /// 客户id
+ ///
+ public int? CustomerId { get; set; }
+
+ /////
+ ///// 当tab选中 0 默认不传 1 直接写死传值 [1,4] 2 传 [2,4]
+ /////
+ //public List? QuestionTypeIds { get; set; }
+
///
/// 创建时间开始
///
@@ -73,6 +93,11 @@ public class TrackOrderDto
///
public string? CustomerCode { get; set; }
+ ///
+ /// 客户id
+ ///
+ public int CustomerId { get; set; }
+
///
/// 订单明细(json)
///
@@ -113,5 +138,28 @@ public class TrackOrderDto
///
public string SubSystem { get; set; }
+ ///
+ /// 子系统id
+ ///
public int SubSystemId { get; set; }
+
+ ///
+ /// 问题类型(主数据枚举TrackQuestionType)
+ ///
+ public int QuestionType { get; set; }
+
+ ///
+ /// 问题类型名称
+ ///
+ public string? QuestionTypeName { get; set; }
+
+ ///
+ /// 问题描述(主数据枚举TrackProblemDescription)
+ ///
+ public int ProblemDescription { get; set; }
+
+ ///
+ /// 问题描述名称
+ ///
+ public string? ProblemDescriptionName { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetTrackInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetTrackInput.cs
index 598ee759..8fa3dec0 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetTrackInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetTrackInput.cs
@@ -2,20 +2,8 @@ using System.ComponentModel.DataAnnotations;
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
-public class GetTrackInput
+public class GetTrackInput : OrderNosInfo
{
- ///
- /// 订单类型
- ///
- [Required]
- [Range(1, int.MaxValue)]
- public int OrderType { get; set; }
-
- ///
- /// 订单号
- ///
- public List OrderNos { get; set; } = new();
-
///
/// 时区 +8 +8.25 -8.5 -9
/// 不传默认+8
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/LinkOrderInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/LinkOrderInput.cs
index cf3e5b79..7d30b3c5 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/LinkOrderInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/LinkOrderInput.cs
@@ -22,7 +22,11 @@ public class LinkOrderInput
[Required]
public string OrderNo { get; set; }
- [Required] public int LinkOrderType { get; set; }
+ ///
+ /// 关联单类型
+ ///
+ [Required]
+ public int LinkOrderType { get; set; }
///
/// 关联的单号
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/OrderNoInfo.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/OrderNoInfo.cs
index eda65e4a..3ec49a17 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/OrderNoInfo.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/OrderNoInfo.cs
@@ -17,4 +17,20 @@ public class OrderNoInfo
[Required]
[MaxLength(100)]
public string OrderNo { get; set; } = null!;
+}
+
+public class OrderNosInfo
+{
+ ///
+ /// 订单类型
+ ///
+ [Required]
+ [Range(1, int.MaxValue)]
+ public int OrderType { get; set; }
+
+ ///
+ /// 订单号
+ ///
+ [Required]
+ public List OrderNos { get; set; } = new();
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/PushTrackInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/PushTrackInput.cs
new file mode 100644
index 00000000..5eaff31e
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/PushTrackInput.cs
@@ -0,0 +1,12 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
+
+public class PushTrackInput : OrderNosInfo
+{
+ ///
+ /// 轨迹code,必填
+ ///
+ [Required]
+ public string TrackCode { get; set; } = null!;
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackPushContentConfigDto.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackPushContentConfigDto.cs
new file mode 100644
index 00000000..64ae2569
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackPushContentConfigDto.cs
@@ -0,0 +1,62 @@
+namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
+
+public class TrackPushConfigDto
+{
+ ///
+ /// 是否自动推送
+ ///
+ public bool IsAutoPush { get; set; }
+
+ ///
+ /// 轨迹推送内容配置
+ ///
+ public List ContentConfigs { get; set; } = new();
+}
+
+public class TrackPushContentConfigDto
+{
+ ///
+ /// 服务商code
+ ///
+ public string ServiceProviderCode { get; set; } = null!;
+
+ ///
+ /// 扩展字段参数值
+ ///
+ public string? ExpandFieldsValue { get; set; }
+
+ ///
+ /// 推送单号类型(主数据枚举TrackOrderType)
+ ///
+ public int OrderType { get; set; }
+
+ ///
+ /// 轨迹代码参数值
+ ///
+ public string? TrackContentCodeValue { get; set; }
+
+ ///
+ /// 轨迹内容id
+ ///
+ public int TrackContentId { get; set; }
+
+ ///
+ /// 轨迹内容参数值
+ ///
+ public string? TrackContentValue { get; set; }
+
+ ///
+ /// 轨迹内容英文参数值
+ ///
+ public string? TrackEnContentValue { get; set; }
+
+ ///
+ /// 轨迹状态参数值
+ ///
+ public string? TrackStatusValue { get; set; }
+
+ ///
+ /// 轨迹时区GMT
+ ///
+ public double? TrackTimeZone { get; set; }
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpdateOrderInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpdateOrderInput.cs
index 69ad9a0b..ebb47f17 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpdateOrderInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpdateOrderInput.cs
@@ -45,10 +45,10 @@ public class UpdateOrderInput : OrderNoInfo
///
/// 订单模板(传全量)
///
- public List? Templates { get; set; } = new();
+ public List Templates { get; set; } = new();
///
/// 订单航班信息
///
- public List? FlightInfos { get; set; } = new();
+ public List FlightInfos { get; set; } = new();
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertOrderInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertOrderInput.cs
index 91ae6d11..4293ccc0 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertOrderInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertOrderInput.cs
@@ -17,6 +17,7 @@ public class OrderTemplateInfo
/// 模板id
///
[Required]
+ [Range(1, Int32.MaxValue)]
public int TemplateId { get; set; }
///
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertTrackInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertTrackInput.cs
index b62cf77b..8248c8e0 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertTrackInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/UpsertTrackInput.cs
@@ -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;
- }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs
index 2803a4b3..f60beeb4 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs
@@ -37,7 +37,7 @@ public class EditTrackPullConfigInput
///
/// 拉取轨迹时区
///
- public string? TackTimeZoneName { get; set; }
+ public string? TrackTimeZoneName { get; set; }
///
/// 拉取轨迹内容代码
@@ -59,13 +59,18 @@ public class EditTrackPullConfigInput
///
public string? TrackStatusName { get; set; }
- ///
- /// 轨迹模板id
- ///
- public int? TrackTemplateId { get; set; }
-
///
/// 拉取轨迹发生时间
///
public string? TrackTimeName { get; set; }
+
+ ///
+ /// 订单路径
+ ///
+ public string? OrderPath { get; set; }
+
+ ///
+ /// 轨迹明细路径
+ ///
+ public string? TrackDetailsPath { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/UpdateTrackPullContentInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullContentInput.cs
similarity index 79%
rename from src/SJZY.Track.Application.Contract/Dtos/TrackPull/UpdateTrackPullContentInput.cs
rename to src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullContentInput.cs
index 6f3c76dd..b409c9e6 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/UpdateTrackPullContentInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullContentInput.cs
@@ -1,8 +1,13 @@
namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
-public class UpdateTrackPullContentInput
+public class EditTrackPullContentInput
{
- public int Id { get; set; }
+ ///
+ /// 操作类型
+ ///
+ public OptionTypeNoNull Options { get; set; }
+
+ public int? Id { get; set; }
///
/// 服务商轨迹代码参数值
@@ -12,7 +17,7 @@ public class UpdateTrackPullContentInput
///
/// 轨迹内容id
///
- public int TrackContentId { get; set; }
+ public int? TrackContentId { get; set; }
///
/// 服务商轨迹内容参数值
@@ -37,7 +42,7 @@ public class UpdateTrackPullContentInput
///
/// 轨迹拉取配置id
///
- public int TrackPullConfigId { get; set; }
+ public int? TrackPullConfigId { get; set; }
///
/// 服务商轨迹状态参数值
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullConfigDto.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullConfigDto.cs
new file mode 100644
index 00000000..10f78964
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullConfigDto.cs
@@ -0,0 +1,19 @@
+namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
+
+public class TrackPullConfigDto
+{
+ ///
+ /// 服务商拉取频率(分钟)
+ ///
+ public int PullInterval { get; set; }
+
+ ///
+ /// 服务商id
+ ///
+ public int ServiceProviderId { get; set; }
+
+ ///
+ /// 子系统id
+ ///
+ public int SubSystemId { get; set; }
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullContentConfigDto.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullContentConfigDto.cs
new file mode 100644
index 00000000..cab541f3
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullContentConfigDto.cs
@@ -0,0 +1,44 @@
+namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
+
+public class TrackPullContentConfigDto
+{
+ ///
+ /// 轨迹内容代码
+ ///
+ public string TrackContentCode { get; set; } = null!;
+
+ ///
+ /// 服务商轨迹状态参数值
+ ///
+ public string? TrackStatusValue { get; set; }
+
+ ///
+ /// 服务商轨迹代码参数值
+ ///
+ public string? TrackContentCodeValue { get; set; }
+
+ ///
+ /// 服务商轨迹内容参数值
+ ///
+ public string? TrackContentValue { get; set; }
+
+ ///
+ /// 轨迹关键词(正向),多个逗分隔
+ ///
+ public string? TrackKeyword { get; set; }
+
+ ///
+ /// 轨迹关键词(反向),多个逗分隔
+ ///
+ public string? TrackKeywordReverse { get; set; }
+
+ ///
+ /// 轨迹发生地参数值(主数据枚举)
+ ///
+ public int? TrackPlaceValue { get; set; }
+
+ ///
+ /// 轨迹时区GMT值
+ ///
+ public float? TrackTimeZoneValue { get; set; }
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs
new file mode 100644
index 00000000..79af5185
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs
@@ -0,0 +1,49 @@
+namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
+
+public class TrackPullParamConfigDto
+{
+ ///
+ /// 单号参数名
+ ///
+ public string OrderNoName { get; set; } = null!;
+
+ ///
+ /// 轨迹时区参数名
+ ///
+ public string? TrackTimeZoneName { get; set; }
+
+ ///
+ /// 轨迹代码参数名
+ ///
+ public string? TrackContentCodeName { get; set; }
+
+ ///
+ /// 轨迹内容参数名
+ ///
+ public string? TrackContentName { get; set; }
+
+ ///
+ /// 轨迹发生地参数名
+ ///
+ public string? TrackPlaceName { get; set; }
+
+ ///
+ /// 轨迹状态参数名
+ ///
+ public string? TrackStatusName { get; set; }
+
+ ///
+ /// 轨迹发生时间参数名
+ ///
+ public string? TrackTimeName { get; set; }
+
+ ///
+ /// 订单数组路径
+ ///
+ public string OrderPath { get; set; } = null!;
+
+ ///
+ /// 轨迹明细数组路径
+ ///
+ public string TrackDetailsPath { get; set; } = null!;
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamWithContentConfigDto.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamWithContentConfigDto.cs
new file mode 100644
index 00000000..ba38457f
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamWithContentConfigDto.cs
@@ -0,0 +1,8 @@
+namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
+
+public class TrackPullParamWithContentConfigDto
+{
+ public TrackPullParamConfigDto ParamConfig { get; set; }
+
+ public List ContentConfigs { get; set; }
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackRefreshDto.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackRefreshDto.cs
new file mode 100644
index 00000000..d8d476d2
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackRefreshDto.cs
@@ -0,0 +1,16 @@
+using SJZY.Track.Application.Contract.Dtos.ProvideServices;
+
+namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
+
+public class TrackRefreshDto : OrderNoInfo
+{
+ ///
+ /// 服务商id
+ ///
+ public int ServiceProviderId { get; set; }
+
+ ///
+ /// 子系统id
+ ///
+ public int SubSystemId { get; set; }
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs
index b462f6a4..20473d85 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs
@@ -5,7 +5,7 @@ public class EditTrackPushConfigInput
///
/// 客户id
///
- public int CustomId { get; set; }
+ public int? CustomId { get; set; }
///
/// 推送扩展字段
@@ -17,7 +17,7 @@ public class EditTrackPushConfigInput
///
/// 是否自动推送
///
- public bool IsAutoPush { get; set; }
+ public bool? IsAutoPush { get; set; }
///
/// 操作类型
@@ -32,17 +32,17 @@ public class EditTrackPushConfigInput
///
/// 服务商id
///
- public int ServiceProviderId { get; set; }
+ public int? ServiceProviderId { get; set; }
///
/// 子系统id
///
- public int SubSystemId { get; set; }
+ public int? SubSystemId { get; set; }
///
/// 推送轨迹时区
///
- public string? TackTimeZoneName { get; set; }
+ public string? TrackTimeZoneName { get; set; }
///
/// 推送轨迹内容代码
@@ -69,13 +69,18 @@ public class EditTrackPushConfigInput
///
public string? TrackStatusName { get; set; }
- ///
- /// 轨迹模板id
- ///
- public List? TrackTemplateIds { get; set; }
-
///
/// 推送轨迹发生时间
///
public string? TrackTimeName { get; set; }
+
+ ///
+ /// 是否支持更新
+ ///
+ public bool? IsCanUpdate { get; set; }
+
+ ///
+ /// 是否支持删除
+ ///
+ public bool? IsCanDelete { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Events/OrderLinkAfterFillTrackEvent.cs b/src/SJZY.Track.Application.Contract/Events/OrderLinkAfterFillTrackEvent.cs
new file mode 100644
index 00000000..5caa784e
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Events/OrderLinkAfterFillTrackEvent.cs
@@ -0,0 +1,19 @@
+namespace SJZY.Track.Application.Contract.Events;
+
+public class OrderLinkAfterFillTrackEvent
+{
+ ///
+ /// 关联订单id
+ ///
+ public int OrderId { get; set; }
+
+ ///
+ /// 子系统id
+ ///
+ public int SubSystemId { get; set; }
+
+ ///
+ /// 关联订单
+ ///
+ public List LinkedOrderIds { get; set; } = null!;
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Events/TrackUpsertEvent.cs b/src/SJZY.Track.Application.Contract/Events/TrackUpsertEvent.cs
index 04f91415..5bbcbea6 100644
--- a/src/SJZY.Track.Application.Contract/Events/TrackUpsertEvent.cs
+++ b/src/SJZY.Track.Application.Contract/Events/TrackUpsertEvent.cs
@@ -20,9 +20,9 @@ public class TrackUpsertEvent : UpsertTrackInput
public int SubSystemId { get; set; }
///
- /// 订单是否推送完成(异步维护)
+ /// 最新推送轨迹内容id(异步维护)
///
- public bool IsPushCompleted { get; set; }
+ public int? LatestPushTrackContentId { get; set; }
///
/// 上游子系统id
diff --git a/src/SJZY.Track.Application.Contract/Events/UpdateOrderTrackEvent.cs b/src/SJZY.Track.Application.Contract/Events/UpdateOrderTrackEvent.cs
index f04cd86c..7daa9a7d 100644
--- a/src/SJZY.Track.Application.Contract/Events/UpdateOrderTrackEvent.cs
+++ b/src/SJZY.Track.Application.Contract/Events/UpdateOrderTrackEvent.cs
@@ -7,11 +7,16 @@ public class UpdateOrderTrackEvent
///
public int OrderId { get; set; }
+ ///
+ /// 是否删除引起的更新
+ ///
+ public bool IsDelete { get; set; }
+
///
/// 此次发生的轨迹是否意味完成
///
public bool IsCompleted { get; set; }
-
+
///
/// 轨迹内容
///
@@ -21,7 +26,7 @@ public class UpdateOrderTrackEvent
/// 轨迹内容英文
///
public string TrackEnContent { get; set; } = null!;
-
+
///
/// 轨迹发生地
///
@@ -31,9 +36,14 @@ public class UpdateOrderTrackEvent
/// 轨迹发生时间
///
public DateTime TrackTime { get; set; }
-
+
///
/// 轨迹时区
///
public float TrackTimeZone { get; set; }
+
+ ///
+ /// 轨迹代码
+ ///
+ public string TrackCode { get; set; } = null!;
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj b/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj
index de5d1421..f13ee0b2 100644
--- a/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj
+++ b/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj
@@ -4,7 +4,9 @@
net7.0
- 0.0.2
+ True
+ 1.0.0
+ True
diff --git a/src/SJZY.Track.Application.Contract/Services/IOrderService.cs b/src/SJZY.Track.Application.Contract/Services/IOrderService.cs
new file mode 100644
index 00000000..0dd34413
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Services/IOrderService.cs
@@ -0,0 +1,28 @@
+using SJZY.Track.Application.Contract.Dtos.ProvideServices;
+using Volo.Abp;
+
+namespace SJZY.Track.Application.Contract.Services;
+
+public interface IOrderService : IRemoteService
+{
+ ///
+ /// 创建订单,订单已存在则视为更新
+ ///
+ ///
+ ///
+ Task UpsertAsync(UpsertOrderInput input);
+
+ ///
+ /// 删除订单
+ ///
+ ///
+ ///
+ Task DeleteOrderAsync(DeleteOrderInput input);
+
+ ///
+ /// 关联订单
+ ///
+ ///
+ ///
+ Task LinkOrderAsync(LinkOrderInput input);
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs b/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs
new file mode 100644
index 00000000..486d4157
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs
@@ -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);
+
+ ///
+ /// 获取所有拉取配置
+ ///
+ ///
+ Task> GetAllPullConfigsAsync();
+
+ ///
+ /// 获取服务商拉取配置
+ ///
+ /// 子系统id
+ /// 服务商id
+ ///
+ Task GetPullParamWithContentConfigAsync(int subSystemId, int serviceProviderId);
+
+ ///
+ /// 设置拉取配置缓存
+ ///
+ ///
+ /// 子系统id
+ /// 服务商id
+ ///
+ Task SetPullConfigAsync(int? id = null, int? subSystemId = null,
+ int? serviceProviderId = null);
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
index 04369975..a4a57bc0 100644
--- a/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
+++ b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
@@ -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
{
///
- /// 判断客户是否需要推送
+ /// 获取服务商拉取配置
///
- ///
+ /// 子系统id
+ /// 服务商id
///
- Task IsPushAsync(int customId);
+ Task> GetPushContentConfigsAsync(int subSystemId, int customId);
///
- /// 更新缓存
+ /// 获取服务商拉取配置
///
+ /// 子系统id
+ /// 服务商id
+ ///
+ ///
+ Task GetPushContentConfigAsync(int subSystemId, int customId, int trackContentId);
+
+ ///
+ /// 根据轨迹代码推断下一个(升序)要推送的内容,如果找不到或者已经是最后一个了,返回null
+ ///
+ ///
///
- ///
- Task UpdateAsync(int customId, bool isPush);
+ ///
+ ///
+ Task InferNextPushContentOrNullAsync(int subSystemId, int customId,
+ int? trackContentId);
+
+ ///
+ /// 设置推送配置缓存
+ ///
+ ///
+ /// 子系统id
+ /// 客户id
+ ///
+ Task SetPushContentConfigsAsync(int? id = null, int? subSystemId = null, int? customId = null);
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application.Contract/Services/ITrackService.cs b/src/SJZY.Track.Application.Contract/Services/ITrackService.cs
new file mode 100644
index 00000000..1b0ec5b5
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Services/ITrackService.cs
@@ -0,0 +1,35 @@
+using SJZY.Track.Application.Contract.Dtos.ProvideServices;
+using Volo.Abp;
+
+namespace SJZY.Track.Application.Contract.Services;
+
+public interface ITrackService : IRemoteService
+{
+ ///
+ /// 新增/更新订单轨迹接口
+ ///
+ ///
+ ///
+ Task UpsertTrackAsync(UpsertTrackInput input);
+
+ ///
+ /// 删除轨迹
+ ///
+ ///
+ ///
+ Task DeleteTrackAsync(DeleteTrackInput input);
+
+ ///
+ /// 批量删除轨迹
+ ///
+ ///
+ ///
+ Task BatchDeleteTrackAsync(BatchDeleteTrackInput input);
+
+ ///
+ /// 根据订单号获取轨迹
+ ///
+ ///
+ ///
+ Task> QueryAsync(GetTrackInput input);
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/AutoMapper/TrackPullAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackPullAutoMapperProfile.cs
index d8dad310..c2409eea 100644
--- a/src/SJZY.Track.Application/AutoMapper/TrackPullAutoMapperProfile.cs
+++ b/src/SJZY.Track.Application/AutoMapper/TrackPullAutoMapperProfile.cs
@@ -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(MemberList.None);
CreateMap(MemberList.None).Ignore(dest => dest.Id)
.ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => false));
- CreateMap(MemberList.None)
+ CreateMap(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(MemberList.None);
+ CreateMap(MemberList.None);
}
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs
index 3a42d0e4..6be69d46 100644
--- a/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs
+++ b/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs
@@ -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(MemberList.None)
- .ForMember(dest => dest.TrackTemplateId, opt => opt.MapFrom(source => string.Join(',', source.TrackTemplateIds)));
+ CreateMap(MemberList.None);
CreateMap(MemberList.None).Ignore(dest => dest.Id)
.ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => true));
CreateMap(MemberList.None);
+ CreateMap(MemberList.None)
+ .ForMember(dest => dest.OrderType, opt => opt.MapFrom(source => source.OrderNoType));
}
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/EventHandlers/InterfaceRelayTrackRefreshEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/InterfaceRelayTrackRefreshEventHandler.cs
deleted file mode 100644
index 099b1b99..00000000
--- a/src/SJZY.Track.Application/EventHandlers/InterfaceRelayTrackRefreshEventHandler.cs
+++ /dev/null
@@ -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 requestParams)
- {
- var orderNos = requestParams.Select(x => x.OrderNo).ToList();
-
- // tips:attach返回的是服务商id,必有
- var pullContentConfigs = await _provideQueries.GetPullContentConfigsAsync(int.Parse(@event.Attach));
-
- // 轨迹清洗入库
- }
- }
-}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/EventHandlers/OrderLinkAfterFillTrackHandler.cs b/src/SJZY.Track.Application/EventHandlers/OrderLinkAfterFillTrackHandler.cs
new file mode 100644
index 00000000..9335175a
--- /dev/null
+++ b/src/SJZY.Track.Application/EventHandlers/OrderLinkAfterFillTrackHandler.cs
@@ -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);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackDeleteEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackDeleteEventHandler.cs
index 55bb5b1d..1bbf3aac 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackDeleteEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackDeleteEventHandler.cs
@@ -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);
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
new file mode 100644
index 00000000..52c005f2
--- /dev/null
+++ b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
@@ -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>(@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();
+ 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();
+ if (!trackCode.IsNullOrWhiteSpace())
+ {
+ matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackContentCodeValue == trackCode);
+ }
+ }
+ // 2、匹配轨迹状态
+ else if (paramConfig.TrackStatusName != null)
+ {
+ var trackStatus = trackToken[paramConfig.TrackStatusName]?.Value();
+ if (!trackStatus.IsNullOrWhiteSpace())
+ {
+ matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackStatusValue == trackStatus);
+ }
+ }
+ // 3、匹配轨迹内容
+ else if (paramConfig.TrackContentName != null)
+ {
+ var trackContent = trackToken[paramConfig.TrackContentName]?.Value();
+ 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())
+ {
+ if (trackContent.Contains(keyword, StringComparison.OrdinalIgnoreCase))
+ {
+ matchedContentConfig = contentConfig;
+ break;
+ }
+ }
+
+ if (matchedContentConfig is null) continue;
+
+ foreach (var keyword in contentConfig.TrackKeywordReverse?.Split(',') ??
+ Enumerable.Empty())
+ {
+ if (trackContent.Contains(keyword, StringComparison.OrdinalIgnoreCase))
+ {
+ matchedContentConfig = null;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (matchedContentConfig is null) return;
+
+ // 轨迹发生地
+ var trackPlace = paramConfig.TrackPlaceName == null
+ ? null
+ : trackToken[paramConfig.TrackPlaceName]?.Value();
+ if (trackPlace.IsNullOrWhiteSpace())
+ {
+ Expression> 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();
+ // 轨迹发生时区
+ var trackTimeZone = paramConfig.TrackTimeZoneName == null
+ ? null
+ : trackToken[paramConfig.TrackTimeZoneName]?.Value();
+
+ // 新增/更新轨迹
+ 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);
+ }
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs
index 29e14bc2..7c6f3159 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs
@@ -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);
diff --git a/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs
index 0901b2a0..7eb5811a 100644
--- a/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs
@@ -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
{
diff --git a/src/SJZY.Track.Application/SJZY.Track.Application.csproj b/src/SJZY.Track.Application/SJZY.Track.Application.csproj
index d2b2eafd..62282f44 100644
--- a/src/SJZY.Track.Application/SJZY.Track.Application.csproj
+++ b/src/SJZY.Track.Application/SJZY.Track.Application.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderLinkService.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs
similarity index 69%
rename from src/SJZY.Track.Application/Services/ProvideServices/OrderLinkService.cs
rename to src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs
index c4a6d1db..51f50f3b 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/OrderLinkService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs
@@ -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;
///
/// 订单关联服务
///
-[ApiExplorerSettings(GroupName = "提供接口")]
-[Route("/ProviderService")]
-public class OrderLinkService : ApplicationService
+public partial class OrderService
{
- private readonly IOrderRepository _orderRepository;
private readonly IBasicQuery _orderLinkQuery;
-
- public OrderLinkService(IBasicQuery orderLinkQuery, IOrderRepository orderRepository)
- {
- _orderLinkQuery = orderLinkQuery;
- _orderRepository = orderRepository;
- }
+ private readonly ICapPublisher _capPublisher;
///
- /// 关联订单
+ /// 关联、解除关联订单
///
///
///
+ ///
[HttpPost("Order/Link")]
public async Task 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 DoLinkOrderAsync(LinkOrderInput input, int orderId)
+ private async Task> 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();
+
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 UnLinkOrderAsync(LinkOrderInput input)
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
index a021cd41..712b775c 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
@@ -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;
///
[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 orderLinkQuery,
+ ICapPublisher capPublisher)
{
_orderRepository = orderRepository;
- _trackDetailsRepository = trackDetailsRepository;
+ _capPublisher = capPublisher;
+ _orderLinkQuery = orderLinkQuery;
}
///
- /// 创建订单,订单已存在则视为更新
+ /// 新增、更新订单(存在就更新)
///
///
///
- ///
[HttpPost("Order/Upsert")]
public async Task 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(input);
order.SubSystemId = CurrentUserRequest.SubSystemId;
- order.OrderTemplates = ObjectMapper.Map, List>(input.Templates!);
- order.OrderFlights = ObjectMapper.Map, List>(input.FlightInfos!);
+ order.OrderTemplates = ObjectMapper.Map, List>(input.Templates);
+ order.OrderFlights = ObjectMapper.Map, List>(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>(input.Templates!);
- order.OrderFlights = ObjectMapper.Map, List>(input.FlightInfos!);
+ order.OrderTemplates = ObjectMapper.Map, List>(input.Templates);
+ order.OrderFlights = ObjectMapper.Map, List>(input.FlightInfos);
await _orderRepository.UpdateOrderAsync(order);
}
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
index 53cdfd57..10f1d52a 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
@@ -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;
///
-/// 轨迹拉取服务
+/// 轨迹刷新服务
///
[ApiExplorerSettings(GroupName = "提供接口")]
[Route("/ProviderService")]
public class TrackPullService : ApplicationService
{
- private readonly IOrderRepository _orderRepository;
- private readonly IHttpClientProxy _httpClientProxy;
+ private readonly IProvideQueries _provideQueries;
+ private readonly IHttpClientProxy _httpClientProxy;
+ private readonly ITrackPullCacheService _trackPullCacheService;
- public TrackPullService(IOrderRepository orderRepository,
- IHttpClientProxy httpClientProxy)
+ public TrackPullService(IProvideQueries provideQueries,
+ IHttpClientProxy httpClientProxy,
+ ITrackPullCacheService trackPullCacheService)
{
- _orderRepository = orderRepository;
+ _provideQueries = provideQueries;
_httpClientProxy = httpClientProxy;
+ _trackPullCacheService = trackPullCacheService;
}
///
- /// 刷新轨迹
+ /// 手动刷新轨迹
///
///
///
[HttpPost("Track/Refresh")]
public async Task 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;
+ }
+
+ ///
+ /// 定时任务刷新轨迹
+ ///
+ ///
+ [AllowAnonymous]
+ [HttpPost("Track/RefreshForTask")]
+ public async Task 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;
}
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
index f2b5320f..443bceb3 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
@@ -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;
///
/// 轨迹推送服务
///
[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 _httpClientProxy;
+
+ public TrackPushService(
+ IHttpClientProxy httpClientProxy, ITrackPushCacheService pushCacheService,
+ ITrackDetailsRepository trackDetailsRepository, IOrderRepository orderRepository)
+ {
+ _httpClientProxy = httpClientProxy;
+ _pushCacheService = pushCacheService;
+ _trackDetailsRepository = trackDetailsRepository;
+ _orderRepository = orderRepository;
+ }
+
+ ///
+ /// 手工推送轨迹
+ ///
+ ///
+ ///
+ [HttpPost("Track/Push")]
+ public async Task 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;
+ }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.Query.cs
similarity index 84%
rename from src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs
rename to src/SJZY.Track.Application/Services/ProvideServices/TrackService.Query.cs
index 241d9030..35237196 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.Query.cs
@@ -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;
///
/// 轨迹查询服务
///
-[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;
- }
///
- /// 根据订单号获取轨迹
+ /// 查询轨迹
///
///
///
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
index 18adf7fa..b9af7e6e 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
@@ -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;
///
[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;
}
///
- /// 新增/更新订单轨迹接口
+ /// 新增、更新轨迹(存在就更新)
///
///
///
@@ -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(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;
}
+ ///
+ /// 批量新增、更新轨迹
+ ///
+ ///
+ ///
+ ///
+ [HttpPost("Track/BatchUpsert")]
+ public async Task 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;
+ }
+
///
/// 删除轨迹
///
@@ -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 { 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;
}
+
+ ///
+ /// 批量删除轨迹
+ ///
+ ///
+ ///
+ ///
+ [HttpPost("Track/BatchDelete")]
+ public async Task 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;
+ }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Services/TrackOrders/TrackOrderService.cs b/src/SJZY.Track.Application/Services/TrackOrders/TrackOrderService.cs
index 908d7227..e799aeea 100644
--- a/src/SJZY.Track.Application/Services/TrackOrders/TrackOrderService.cs
+++ b/src/SJZY.Track.Application/Services/TrackOrders/TrackOrderService.cs
@@ -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 轨迹订单明细
- ///
- /// 根据轨迹订单id获取轨迹订单明细列表
- ///
- ///
- ///
- [HttpPost("GetDetails")]
- public async Task> GetOrderDetails(GetOrderDetailsInput input)
- {
- var trackDetails = await _trackDetailsRepository.GetListAsync(input.OrderId);
- if (!trackDetails.IsNullOrEmpty())
- {
- var list = ObjectMapper.Map, List>(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();
- }
- #endregion
-
- #region 轨迹订单列表
- ///
- /// 获取分页的轨迹订单
- ///
- ///
- ///
- [HttpPost("GetTrackOrderList")]
- public async Task> GetPageTrackOrder(GetPageTrackOrderInput input)
- {
- var vo = ObjectMapper.Map(input);
- var pageList = await _orderRepository.GetPageTrackOrder(vo);
- var pageResultDto =
- ObjectMapper.Map, UnifyPageResultDto>(pageList);
- return pageResultDto;
- }
- #endregion
+ _trackOrderQueries = trackOrderQueries;
+ _trackDetailsRepository = trackDetailsRepository;
+ _trackContentRepository = trackContentRepository;
}
-}
+
+ #region 轨迹订单明细
+
+ ///
+ /// 根据轨迹订单id获取轨迹订单明细列表
+ ///
+ ///
+ ///
+ [HttpPost("GetDetails")]
+ public async Task> GetOrderDetails(GetOrderDetailsInput input)
+ {
+ var trackDetails = await _trackDetailsRepository.GetListAsync(input.OrderId);
+ if (!trackDetails.IsNullOrEmpty())
+ {
+ var list = ObjectMapper.Map, List>(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();
+ }
+
+ #endregion
+
+ #region 轨迹订单列表
+
+ ///
+ /// 获取分页的轨迹订单
+ ///
+ ///
+ ///
+ [HttpPost("GetTrackOrderList")]
+ public async Task> GetPageTrackOrder(GetPageTrackOrderInput input)
+ {
+ var vo = ObjectMapper.Map(input);
+ var pageList = await _trackOrderQueries.GetPageTrackOrder(vo);
+ var pageResultDto =
+ ObjectMapper.Map, UnifyPageResultDto>(pageList);
+ return pageResultDto;
+ }
+
+ #endregion
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
new file mode 100644
index 00000000..b5418f24
--- /dev/null
+++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
@@ -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> GetAllPullConfigsAsync()
+ {
+ return await _trackPullConfigRepository.GetListAsync(x => true, x => new TrackPullConfigDto
+ {
+ SubSystemId = x.SubSystemId,
+ ServiceProviderId = x.ServiceProviderId,
+ PullInterval = x.PullInterval
+ });
+ }
+
+ [NonAction]
+ public async Task GetPullParamWithContentConfigAsync(int subSystemId,
+ int serviceProviderId)
+ {
+ var data = await RedisHelper.Client.GetAsync(TrackPullContentKey(
+ subSystemId,
+ serviceProviderId));
+
+ data ??= await SetPullConfigAsync(subSystemId: subSystemId, serviceProviderId: serviceProviderId);
+
+ return data;
+ }
+
+ [NonAction]
+ public async Task SetPullConfigAsync(int? id = null, int? subSystemId = null,
+ int? serviceProviderId = null)
+ {
+ var data = new TrackPullParamWithContentConfigDto();
+
+ Expression> 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(trackPullConfigDetail);
+ data.ContentConfigs =
+ ObjectMapper.Map, List>(
+ trackPullContentList);
+
+ await RedisHelper.Client.SetAsync(
+ TrackPullContentKey(trackPullConfigEntity.SubSystemId, trackPullConfigEntity.ServiceProviderId), data);
+
+ return data;
+ }
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs
index 34998b29..daba134c 100644
--- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs
@@ -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 _stringLocalizer;
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
- private readonly ITrackTemplateRepository _trackTemplateRepository;
+ private readonly ITrackPullCacheService _trackPullCacheService;
public TrackPullService(
IStringLocalizer stringLocalizer,
ITrackPullConfigRepository trackPullConfigRepository,
- ITrackTemplateRepository trackTemplateRepository)
+ ITrackPullCacheService trackPullCacheService)
{
_stringLocalizer = stringLocalizer;
_trackPullConfigRepository = trackPullConfigRepository;
- _trackTemplateRepository = trackTemplateRepository;
+ _trackPullCacheService = trackPullCacheService;
}
///
@@ -91,8 +90,7 @@ public class TrackPullService : ApplicationService, ITransientDependency
if (input.Options != OptionTypeNoNull.删除)
{
Expression> 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(input);
- var trackPullParamsEntity =
- ObjectMapper.Map(input);
+ var trackPullParamsEntity = ObjectMapper.Map(input);
- var trackTemplateContentEntities =
- await _trackTemplateRepository.GetContentListAsync(x => x.TrackTemplateId == input.TrackTemplateId);
-
- var trackPullContentEntities = new List();
+ 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();
-
- 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
}
///
- /// 轨迹拉取配置内容修改
+ /// 轨迹拉取配置内容编辑
///
///
///
- [HttpPost("UpdateContent")]
- public async Task UpdateContentAsync([FromBody] UpdateTrackPullContentInput input)
+ [HttpPost("EditContent")]
+ public async Task EditContentAsync([FromBody] EditTrackPullContentInput input)
{
- Expression> 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> trackKeywordExp = _ => false;
- input.TrackKeywords!.ForEach(item => { trackKeywordExp = trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item)); });
+ Expression> 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> 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(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;
}
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
index 62df4046..36e386b8 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
@@ -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 _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 trackPushConfigQuery)
+ public TrackPushCacheService(ITrackPushConfigRepository trackPushConfigRepository)
{
- _trackPushConfigQuery = trackPushConfigQuery;
+ _trackPushConfigRepository = trackPushConfigRepository;
}
- public async Task IsPushAsync(int customId)
+ [NonAction]
+ public async Task> GetPushContentConfigsAsync(int subSystemId, int customId)
{
- var isPush =
- await RedisHelper.Client.GetAsync(RedisKey(customId));
+ var data = await GetPushConfigAsync(subSystemId, customId);
- if (isPush == null)
+ return data.ContentConfigs;
+ }
+
+ [NonAction]
+ public async Task GetPushContentConfigAsync(int subSystemId, int customId,
+ int trackContentId)
+ {
+ var data = await GetPushContentConfigsAsync(subSystemId, customId);
+
+ return data.Single(x => x.TrackContentId == trackContentId);
+ }
+
+ [NonAction]
+ public async Task 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 SetPushContentConfigsAsync(int? id = null, int? subSystemId = null,
+ int? customId = null)
{
- await RedisHelper.Client.SetAsync(RedisKey(customId), isPush);
+ var data = new TrackPushConfigDto { ContentConfigs = new() };
+
+ Expression> 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>(trackPushContentList);
+
+ await RedisHelper.Client.SetAsync(
+ TrackPushContentKey(trackPushConfigEntity.SubSystemId, trackPushConfigEntity.CustomId), data);
+
+ return data;
+ }
+
+ private async Task GetPushConfigAsync(int subSystemId, int customId)
+ {
+ var data = await RedisHelper.Client.GetAsync(TrackPushContentKey(subSystemId, customId));
+
+ data ??= await SetPushContentConfigsAsync(subSystemId: subSystemId, customId: customId);
+
+ return data;
}
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
index 1b009a95..712bbc3c 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
@@ -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;
///
[ApiExplorerSettings(GroupName = "轨迹推送")]
[Route("/Track/PushConfig")]
-public class TrackPushService : ApplicationService, ITransientDependency
+public class TrackPushService : ApplicationService
{
private readonly IStringLocalizer _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
///
///
[HttpPost("GetContentPage")]
- public async Task> GetContentPageAsync([FromBody] GetTrackPushContentPageInputVO input)
+ public async Task> GetContentPageAsync(
+ [FromBody] GetTrackPushContentPageInputVO input)
{
return await _trackPushConfigRepository.GetContentPageAsync(input);
}
@@ -73,16 +69,7 @@ public class TrackPushService : ApplicationService, ITransientDependency
[HttpGet("GetDetail")]
public async Task GetDetailAsync(int id)
{
- var res = await _trackPushConfigRepository.GetDetailAsync(id);
- if (res is null) return null;
-
- List 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);
}
///
@@ -107,14 +94,9 @@ public class TrackPushService : ApplicationService, ITransientDependency
if (input.Options != OptionTypeNoNull.删除)
{
Expression> 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();
- 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(input);
- var trackPushParamsEntity = ObjectMapper.Map(input);
+ var trackPushParamsEntity =
+ ObjectMapper.Map(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> isContentAnyExp = x => x.TrackPushConfigId == input.TrackPushConfigId;
+ Expression> 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(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;
}
diff --git a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs
index 525add23..f78c1ed3 100644
--- a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs
+++ b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs
@@ -21,21 +21,15 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
{
private readonly IStringLocalizer _stringLocalizer;
private readonly ITrackTemplateRepository _trackTemplateRepository;
- private readonly ITrackPullConfigRepository _trackPullConfigRepository;
- private readonly ITrackPushConfigRepository _trackPushConfigRepository;
///
public TrackTemplateService(
IStringLocalizer stringLocalizer,
- ITrackTemplateRepository trackTemplateRepository,
- ITrackPullConfigRepository trackPullConfigRepository,
- ITrackPushConfigRepository trackPushConfigRepository
+ ITrackTemplateRepository trackTemplateRepository
)
{
_stringLocalizer = stringLocalizer;
_trackTemplateRepository = trackTemplateRepository;
- _trackPullConfigRepository = trackPullConfigRepository;
- _trackPushConfigRepository = trackPushConfigRepository;
}
///
@@ -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 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);
}
- ///
- /// 轨迹模板内容下拉框
- ///
- ///
- ///
- [HttpPost("GetContentDropDownList")]
- public async Task> GetContentDropDownListAsync([FromBody] GetTrackTemplateContentDropDownListVO input)
- {
- return await _trackTemplateRepository.GetContentDropDownListAsync(input);
- }
-
///
/// 轨迹模板内容编辑
///
diff --git a/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs b/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs
index ba706085..b2b2cd06 100644
--- a/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs
+++ b/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs
@@ -68,9 +68,8 @@ namespace SJZY.Track.Application
//用户中心
context.Services.AddHttpClientProxies(typeof(SjzyUserCenterHttpApiModule).Assembly, "UserCenter", false);
context.Services.AddHttpClient("InterfaceForward").AddHttpMessageHandler();
- context.Services.AddHttpClientProxy(
- remoteServiceConfigurationName: "InterfaceForward",
- asDefaultService: false
+ context.Services.AddHttpClientProxies(typeof(SJZYInterfaceRelayApplicationContractsModule).Assembly,
+ "InterfaceForward", false
);
//CAP
diff --git a/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs b/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs
index 9b0a4503..50beea14 100644
--- a/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs
+++ b/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs
@@ -25,8 +25,6 @@ public class EditTrackPullConfigInputValidation : AbstractValidator 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 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)]);
diff --git a/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullContentInputValidation.cs b/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullContentInputValidation.cs
new file mode 100644
index 00000000..dcf6ff1c
--- /dev/null
+++ b/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullContentInputValidation.cs
@@ -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, IValidationEnabled
+{
+ public EditTrackPullContentInputValidation(IStringLocalizer 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)]);
+ });
+ }
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs
index 9e8d59eb..acc0d4de 100644
--- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs
+++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs
@@ -11,13 +11,6 @@ public interface IOrderRepository : IBasicRepository
///
Task CreateOrderAsync(OrderEntity order);
- ///
- /// 获取分页的轨迹订单
- ///
- ///
- ///
- Task> GetPageTrackOrder(GetPageTrackOrderInputVO input);
-
///
/// 更新订单
///
@@ -57,12 +50,4 @@ public interface IOrderRepository : IBasicRepository
Task UnLinkByIdsAsync(List linkIds);
#endregion
-
-
- ///
- /// 获取订单模板列表
- ///
- ///
- ///
- Task> GetOrderTemplatesAsync(List orderNos);
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs
index 04432d30..3defe94f 100644
--- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs
+++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs
@@ -41,12 +41,12 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
///
[SugarColumn(ColumnName = "IsCompleted")]
public bool IsCompleted { get; set; }
-
+
///
- /// 订单是否推送完成(异步维护)
+ /// 最新推送轨迹内容id(异步维护)
///
- [SugarColumn(ColumnName = "IsPushCompleted")]
- public bool IsPushCompleted { get; set; }
+ [SugarColumn(ColumnName = "LatestPushTrackContentId")]
+ public int? LatestPushTrackContentId { get; set; }
///
/// 最新轨迹内容(异步维护)
@@ -65,7 +65,7 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
///
[SugarColumn(ColumnName = "LatestTrackTime")]
public DateTime? LatestTrackTime { get; set; }
-
+
///
/// 最新轨迹时区(异步维护)
///
@@ -108,14 +108,34 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
[SugarColumn(ColumnName = "LeaveCountry")]
public string LeaveCountry { get; set; } = null!;
+ ///
+ /// 问题类型(主数据枚举TrackQuestionType)
+ ///
+ [SugarColumn(ColumnName = "QuestionType")]
+ public int QuestionType { get; set; }
+
+ ///
+ /// 问题描述(主数据枚举TrackProblemDescription)
+ ///
+ [SugarColumn(ColumnName = "ProblemDescription")]
+ public int ProblemDescription { get; set; }
+
///
/// 起运港口
///
[SugarColumn(ColumnName = "LeavePort")]
public string? LeavePort { get; set; }
- [SugarColumn(IsIgnore = true)]
- public List OrderFlights { get; set; }
- [SugarColumn(IsIgnore = true)]
- public List OrderTemplates { get; set; }
+ [SugarColumn(IsIgnore = true)] public List OrderFlights { get; set; }
+ [SugarColumn(IsIgnore = true)] public List OrderTemplates { get; set; }
+
+ public void ResetTrackInfo()
+ {
+ IsCompleted = false;
+ LatestTrackContent = null;
+ LatestTrackEnContent = null;
+ LatestTrackTime = null;
+ LatestTrackPlace = null;
+ LatestTrackTimeZone = null;
+ }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs
index f6578023..b0a1cf21 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs
@@ -10,15 +10,25 @@ public interface ITrackDetailsRepository
Task> GetListAsync(int orderType, List orderNos);
+ Task> GetListAsync(int orderType, List orderNos, string trackCode);
+
Task<(List list, long total)> GetListAsync(TrackDetailsQueryInput input);
- Task?> GetListAsync(int orderId);
-
+ Task> GetListAsync(int orderId);
+
///
/// 删除轨迹
///
///
///
///
- Task DeleteTrackAsync(int orderId, List trackCodes);
+ Task DeleteTrackAsync(int orderId, List trackCodes);
+
Task?> GetListAsync(List orderIds);
+
+ ///
+ /// 获取最近一条发生的轨迹
+ ///
+ ///
+ ///
+ Task GetLatestAsync(int orderId);
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs
index d4f5c9e1..964b4ee4 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs
@@ -11,6 +11,11 @@ public class TrackDetailsIndex : IdBaseIndex
///
public int OrderId { get; set; }
+ ///
+ /// 服务商code
+ ///
+ public string? ServiceProviderCode { get; set; }
+
///
/// 订单号
///
@@ -46,6 +51,16 @@ public class TrackDetailsIndex : IdBaseIndex
///
public string TrackContent { get; set; } = null!;
+ ///
+ /// 轨迹内容Id
+ ///
+ public int TrackContentId { get; set; }
+
+ ///
+ /// 是否意味着完成
+ ///
+ public bool IsCompleted { get; set; }
+
///
/// 原轨迹内容
///
diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs
index 7b7dec1f..c21eef77 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs
@@ -19,6 +19,13 @@ public interface ITrackPullConfigRepository : IBasicRepository
Task> GetContentPageAsync(GetTrackPullContentPageInputVO input);
+ ///
+ /// 轨迹拉取配置内容集合(缓存使用)
+ ///
+ ///
+ ///
+ Task> GetContentListCacheAsync(int trackPullConfigId);
+
///
/// 轨迹拉取配置详情
///
@@ -35,7 +42,7 @@ public interface ITrackPullConfigRepository : IBasicRepository InsertParamsAsync(TrackPushPullParamsConfigEntity insertObj);
- Task InsertContentRangeAsync(List insertObjs);
+ Task InsertContentAsync(TrackPullContentConfigEntity insertObj);
Task GetParamsSingleAsync(Expression> whereExpression);
diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPullConfigEntity.cs b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPullConfigEntity.cs
index 1a672799..4c6d7ed7 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPullConfigEntity.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPullConfigEntity.cs
@@ -35,10 +35,4 @@ public class TrackPullConfigEntity : IFullAuditedBasicEntitys, IAggregateRoot
///
[SugarColumn(ColumnName = "SubSystemId")]
public int SubSystemId { get; set; }
-
- ///
- /// 模板id
- ///
- [SugarColumn(ColumnName = "TrackTemplateId")]
- public int TrackTemplateId { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPushPullParamsConfigEntity.cs b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPushPullParamsConfigEntity.cs
index 8187c651..a603ad65 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPushPullParamsConfigEntity.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPushPullParamsConfigEntity.cs
@@ -39,8 +39,8 @@ public class TrackPushPullParamsConfigEntity : IFullAuditedBasicEntitys, IEntity
///
/// 轨迹时区参数名
///
- [SugarColumn(ColumnName = "TackTimeZoneName")]
- public string TackTimeZoneName { get; set; }
+ [SugarColumn(ColumnName = "TrackTimeZoneName")]
+ public string TrackTimeZoneName { get; set; }
///
/// 轨迹代码参数名
@@ -77,4 +77,16 @@ public class TrackPushPullParamsConfigEntity : IFullAuditedBasicEntitys, IEntity
///
[SugarColumn(ColumnName = "TrackTimeName")]
public string TrackTimeName { get; set; }
+
+ ///
+ /// 订单路径
+ ///
+ [SugarColumn(ColumnName = "OrderPath")]
+ public string OrderPath { get; set; }
+
+ ///
+ /// 轨迹明细路径
+ ///
+ [SugarColumn(ColumnName = "TrackDetailsPath")]
+ public string TrackDetailsPath { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/TrackPushConfigEntity.cs b/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/TrackPushConfigEntity.cs
index 00088ccd..0c417253 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/TrackPushConfigEntity.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/TrackPushConfigEntity.cs
@@ -37,8 +37,14 @@ public class TrackPushConfigEntity : IFullAuditedBasicEntitys, IAggregateRoot
public int SubSystemId { get; set; }
///
- /// 模板id(多个之间英文逗号分隔)
+ /// 是否支持更新
///
- [SugarColumn(ColumnName = "TrackTemplateId")]
- public string TrackTemplateId { get; set; }
+ [SugarColumn(ColumnName = "IsCanUpdate")]
+ public bool IsCanUpdate { get; set; }
+
+ ///
+ /// 是否支持删除
+ ///
+ [SugarColumn(ColumnName = "IsCanDelete")]
+ public bool IsCanDelete { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs
index e6ab4b0b..1f36d840 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs
@@ -39,8 +39,6 @@ public interface ITrackTemplateRepository : IBasicRepository UpdateContentRangeAsync(List updateObjs);
- Task> GetContentDropDownListAsync(GetTrackTemplateContentDropDownListVO input);
-
Task ContentMaxAsync(Expression> columns, Expression> whereExpression);
Task UpdateContentAsync(Expression> columns, Expression> whereExpression);
diff --git a/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs b/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
index c1b97cc5..c6b966e6 100644
--- a/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
@@ -18,6 +18,25 @@ namespace SJZY.Track.Domain.Dtos.Order
/////
//public List? OrderNos { get; set; }
+ ///
+ /// 当tab选中 0 默认不传 1 直接写死传值 [1,4] 2 传 [2,4]
+ ///
+ public int TabType { get; set; }
+
+ /////
+ ///// 当tab选中 1 直接写死传值 [1,4] 2 传 [2,4]
+ /////
+ //public List? QuestionTypeIds { get; set; }
+
+ ///
+ /// 订单类型
+ ///
+ public int? TrackOrderType { get; set; }
+
+ ///
+ /// 客户id
+ ///
+ public int? CustomerId { get; set; }
///
/// 单号
@@ -51,9 +70,9 @@ namespace SJZY.Track.Domain.Dtos.Order
public int OrderType { get; set; }
///
- /// 订单名称
+ /// 订单类型名称
///
- public string OrderTypeName { get; set; }
+ public string? OrderTypeName { get; set; }
///
/// 订单号
@@ -75,6 +94,11 @@ namespace SJZY.Track.Domain.Dtos.Order
///
public string? CustomerCode { get; set; }
+ ///
+ /// 客户id
+ ///
+ public int CustomerId { get; set; }
+
/////
///// 订单明细(json)
/////
@@ -124,5 +148,25 @@ namespace SJZY.Track.Domain.Dtos.Order
/// 轨迹模板Id数组
///
public List? TrackTemplateIds { get; set; }
+
+ ///
+ /// 问题类型(主数据枚举TrackQuestionType)
+ ///
+ public int QuestionType { get; set; }
+
+ ///
+ /// 问题类型名称
+ ///
+ public string? QuestionTypeName { get; set; }
+
+ ///
+ /// 问题描述(主数据枚举TrackProblemDescription)
+ ///
+ public int ProblemDescription { get; set; }
+
+ ///
+ /// 问题描述名称
+ ///
+ public string? ProblemDescriptionName { get; set; }
}
}
diff --git a/src/SJZY.Track.Domain/Dtos/Order/LinkedOrderVO.cs b/src/SJZY.Track.Domain/Dtos/Order/LinkedOrderVO.cs
index c0344880..8cc9fbb2 100644
--- a/src/SJZY.Track.Domain/Dtos/Order/LinkedOrderVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/Order/LinkedOrderVO.cs
@@ -6,7 +6,7 @@ public class LinkedOrderVO
/// 关联订单id
///
public int OrderId { get; set; }
-
+
///
/// 订单号
///
@@ -21,12 +21,12 @@ public class LinkedOrderVO
/// 子系统id
///
public int SubSystemId { get; set; }
-
+
///
- /// 订单是否推送完成(异步维护)
+ /// 最新推送轨迹内容id(异步维护)
///
- public bool IsPushCompleted { get; set; }
-
+ public int? LatestPushTrackContentId { get; set; }
+
///
/// 客户id
///
diff --git a/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs b/src/SJZY.Track.Domain/Dtos/Order/OrderWithServiceProviderVO.cs
similarity index 51%
rename from src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs
rename to src/SJZY.Track.Domain/Dtos/Order/OrderWithServiceProviderVO.cs
index 9360db40..df193e03 100644
--- a/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/Order/OrderWithServiceProviderVO.cs
@@ -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)
///
public int OrderType { get; set; }
-
- public int TemplateId { get; set; }
-
+
public int ServiceProviderId { get; set; }
+
+ ///
+ /// 服务商code
+ ///
+ public string ServiceProviderCode { get; set; } = null!;
+
+ ///
+ /// 子系统id
+ ///
+ public int SubSystemId { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Dtos/TrackDetails/MatchTrackContentDto.cs b/src/SJZY.Track.Domain/Dtos/TrackDetails/MatchTrackContentDto.cs
index adb51944..e0213b5e 100644
--- a/src/SJZY.Track.Domain/Dtos/TrackDetails/MatchTrackContentDto.cs
+++ b/src/SJZY.Track.Domain/Dtos/TrackDetails/MatchTrackContentDto.cs
@@ -2,6 +2,11 @@
public class MatchTrackContentDto
{
+ ///
+ /// 轨迹内容id
+ ///
+ public int Id { get; set; }
+
///
/// 轨迹内容
///
diff --git a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs
index c424e5a6..c52c081b 100644
--- a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs
@@ -42,7 +42,7 @@ public class GetTrackPullConfigDetailOutputVO
///
/// 拉取轨迹时区
///
- public string TackTimeZoneName { get; set; }
+ public string TrackTimeZoneName { get; set; }
///
/// 拉取轨迹内容代码
@@ -64,18 +64,18 @@ public class GetTrackPullConfigDetailOutputVO
///
public string TrackStatusName { get; set; }
- ///
- /// 轨迹模板
- ///
- public string TrackTemplate { get; set; }
-
- ///
- /// 轨迹模板id
- ///
- public int TrackTemplateId { get; set; }
-
///
/// 拉取轨迹发生时间
///
public string TrackTimeName { get; set; }
+
+ ///
+ /// 订单路径
+ ///
+ public string OrderPath { get; set; }
+
+ ///
+ /// 轨迹明细路径
+ ///
+ public string TrackDetailsPath { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs
index 15d25401..bd73f920 100644
--- a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs
@@ -20,7 +20,7 @@ public class GetTrackPullConfigPageOutputVO
public string SubSystem { get; set; }
///
- /// 模板名称
+ /// 子系统id
///
- public string TrackTemplate { get; set; }
+ public int SubSystemId { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Dtos/Order/TrackPullContentConfigVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentListCacheVO.cs
similarity index 80%
rename from src/SJZY.Track.Domain/Dtos/Order/TrackPullContentConfigVO.cs
rename to src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentListCacheVO.cs
index 1f82cbe6..1551647d 100644
--- a/src/SJZY.Track.Domain/Dtos/Order/TrackPullContentConfigVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentListCacheVO.cs
@@ -1,12 +1,17 @@
-namespace SJZY.Track.Domain.Dtos.Order;
+namespace SJZY.Track.Domain.Dtos.TrackPull;
-public class TrackPullContentConfigVO
+public class GetTrackPullContentListCacheVO
{
///
- /// 轨迹内容id
+ /// 轨迹内容代码
///
- public int TrackContentId { get; set; }
-
+ public string TrackContentCode { get; set; }
+
+ ///
+ /// 服务商轨迹状态参数值
+ ///
+ public string? TrackStatusValue { get; set; }
+
///
/// 服务商轨迹代码参数值
///
@@ -32,13 +37,8 @@ public class TrackPullContentConfigVO
///
public int? TrackPlaceValue { get; set; }
- ///
- /// 服务商轨迹状态参数值
- ///
- public string? TrackStatusValue { get; set; }
-
///
/// 轨迹时区GMT
///
- public double? TrackTimeZone { get; set; }
+ public float? TrackTimeZone { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs
index ced23f75..9b3255ab 100644
--- a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs
@@ -54,7 +54,7 @@ public class GetTrackPushConfigDetailOutputVO
///
/// 推送轨迹时区
///
- public string TackTimeZoneName { get; set; }
+ public string TrackTimeZoneName { get; set; }
///
/// 推送轨迹内容代码
@@ -81,23 +81,18 @@ public class GetTrackPushConfigDetailOutputVO
///
public string TrackStatusName { get; set; }
- ///
- /// 轨迹模板
- ///
- public List TrackTemplate { get; set; }
-
- ///
- /// 轨迹模板id
- ///
- public string TrackTemplateId { get; set; }
-
- ///
- /// 轨迹模板ids
- ///
- public List TrackTemplateIds { get; set; }
-
///
/// 推送轨迹发生时间
///
public string TrackTimeName { get; set; }
+
+ ///
+ /// 是否支持更新
+ ///
+ public bool IsCanUpdate { get; set; }
+
+ ///
+ /// 是否支持删除
+ ///
+ public bool IsCanDelete { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs
index e0095b23..01550b7f 100644
--- a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs
@@ -20,17 +20,7 @@ public class GetTrackPushConfigPageOutputVO
public string SubSystem { get; set; }
///
- /// 模板名称
+ /// 子系统id
///
- public string TrackTemplate { get; set; }
-
- ///
- /// 轨迹模板id
- ///
- public string TrackTemplateId { get; set; }
-
- ///
- /// 轨迹模板ids
- ///
- public List TrackTemplateIds { get; set; }
+ public int SubSystemId { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Dtos/TrackTemplate/CanDeleteTrackCodeVO.cs b/src/SJZY.Track.Domain/Dtos/TrackTemplate/CanDeleteTrackCodeVO.cs
new file mode 100644
index 00000000..b4376fe5
--- /dev/null
+++ b/src/SJZY.Track.Domain/Dtos/TrackTemplate/CanDeleteTrackCodeVO.cs
@@ -0,0 +1,7 @@
+namespace SJZY.Track.Domain.Dtos.TrackTemplate;
+
+public class CanDeleteTrackCodeVO
+{
+ public int OrderId { get; set; }
+ public string TrackCode { get; set; }
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentDropDownListVO.cs b/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentDropDownListVO.cs
deleted file mode 100644
index ab4a6f8c..00000000
--- a/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentDropDownListVO.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace SJZY.Track.Domain.Dtos.TrackTemplate;
-
-public class GetTrackTemplateContentDropDownListVO : PageInfoInput
-{
- ///
- /// 轨迹模板id
- ///
- public List TrackTemplateIds { get; set; }
-
- ///
- /// 选中项
- ///
- public List? SelectedIds { get; set; }
-}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Enums/EnumPropertyEnums.cs b/src/SJZY.Track.Domain/Enums/EnumPropertyEnums.cs
index a0b74b22..b26a4303 100644
--- a/src/SJZY.Track.Domain/Enums/EnumPropertyEnums.cs
+++ b/src/SJZY.Track.Domain/Enums/EnumPropertyEnums.cs
@@ -15,5 +15,10 @@ public enum EnumPropertyEnums
///
/// 单号类型
///
- [Description("TrackOrderType")] 单号类型
+ [Description("TrackOrderType")] 单号类型,
+
+ ///
+ /// 轨迹发生地
+ ///
+ [Description("TrackLocationValue")] 轨迹发生地
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Enums/TrackLocationValue.cs b/src/SJZY.Track.Domain/Enums/TrackLocationValue.cs
new file mode 100644
index 00000000..2aae150e
--- /dev/null
+++ b/src/SJZY.Track.Domain/Enums/TrackLocationValue.cs
@@ -0,0 +1,11 @@
+namespace SJZY.Track.Domain.Enums;
+
+public enum TrackLocationValue
+{
+ ArrivalPort = 2,
+ LeavePort = 3,
+ ArrivalCountry = 4,
+ LeaveCountry = 5,
+ ArriveCity = 6,
+ LeaveCity = 7
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Enums/TrackProblemType.cs b/src/SJZY.Track.Domain/Enums/TrackProblemType.cs
new file mode 100644
index 00000000..4abcc47e
--- /dev/null
+++ b/src/SJZY.Track.Domain/Enums/TrackProblemType.cs
@@ -0,0 +1,15 @@
+namespace SJZY.Track.Domain.Enums;
+
+[Flags]
+public enum TrackProblemType
+{
+ ///
+ /// 异常
+ ///
+ Error = 1,
+
+ ///
+ /// 预警
+ ///
+ Warn = 2,
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/GlobalConst.cs b/src/SJZY.Track.Domain/GlobalConst.cs
index 92545ea9..528115ea 100644
--- a/src/SJZY.Track.Domain/GlobalConst.cs
+++ b/src/SJZY.Track.Domain/GlobalConst.cs
@@ -11,24 +11,44 @@ public class GlobalConst
/// 轨迹新增/更新 mq订阅名称
///
public const string TrackUpsertSubscribe = "SJZY.Track.TrackUpsert";
-
+
///
/// 轨迹删除 mq订阅名称
///
public const string TrackDeleteSubscribe = "SJZY.Track.TrackDelete";
///
- /// 接口通批量轨迹刷新订阅
+ /// 接口通批量轨迹刷新 mq订阅名称
///
- public const string InterfaceRelayTrackRefreshSubscribe = "SJZY.Track.TrackRefresh";
+ public const string TrackRefreshSubscribe = "SJZY.Track.TrackRefresh";
///
/// 轨迹新增/更新后触发更新订单轨迹 mq订阅名称
///
public const string UpdateOrderTrackSubscribe = "SJZY.Track.UpdateOrderTrack";
+ ///
+ /// 关联订单后补轨迹 mq订阅名称
+ ///
+ public const string OrderLinkAfterFillTrack = "SJZY.Track.OrderLinkAfterFillTrack";
+
///
/// 轨迹要推送的客户redis key前缀
///
- public const string TrackPushKeyPrefix = "TrackPush:";
+ public const string TrackPushKeyPrefix = "TrackPush";
+
+ ///
+ /// 轨迹推送内容配置redis key前缀
+ ///
+ public const string TrackPushContentKeyPrefix = "TrackPushContent";
+
+ ///
+ /// 轨迹拉取配置信息redis key前缀
+ ///
+ public const string TrackPullKeyPrefix = "TrackPull";
+
+ ///
+ /// 轨迹拉取配置信息redis key前缀
+ ///
+ public const string TrackPullContentKeyPrefix = "TrackPullContent";
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Queries/IBasicQuery.cs b/src/SJZY.Track.Domain/Queries/IBasicQuery.cs
index 894e72a9..460e58be 100644
--- a/src/SJZY.Track.Domain/Queries/IBasicQuery.cs
+++ b/src/SJZY.Track.Domain/Queries/IBasicQuery.cs
@@ -9,7 +9,7 @@ public interface IBasicQuery where T : IEntity
///
Task GetFirstAsync(Expression> whereExpression);
- Task GetFirstAsync(Expression> whereExpression,
+ Task GetFirstAsync(Expression> whereExpression,
Expression> resultExpression);
///
diff --git a/src/SJZY.Track.Domain/Queries/IProvideQueries.cs b/src/SJZY.Track.Domain/Queries/IProvideQueries.cs
index 9c17d1d4..2795df48 100644
--- a/src/SJZY.Track.Domain/Queries/IProvideQueries.cs
+++ b/src/SJZY.Track.Domain/Queries/IProvideQueries.cs
@@ -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
/// 轨迹代码
///
Task MatchTrackContentAsync(int orderId, string code);
-
+
///
/// 获取可删除的订单轨迹代码
///
- ///
+ ///
///
///
- Task> GetCanDeleteTrackCodesAsync(int orderId, List trackCodes);
+ Task> GetCanDeleteTrackCodesAsync(List orderIds, List trackCodes);
///
/// 根据子系统内容映射,得到映射后的轨迹code
@@ -51,9 +50,16 @@ public interface IProvideQueries
Task> MapTrackCodesAsync(int upSubSystemId, int subSystemId, params string[] trackCodes);
///
- /// 获取服务商模板配置
+ /// 根据订单模板找对应服务商
///
- ///
+ ///
///
- Task> GetPullContentConfigsAsync(int serviceProviderId);
+ Task> FindOrderWithServiceProviderAsync(List orderNos);
+
+ ///
+ /// 获取服务商下所有单(未完成的)
+ ///
+ ///
+ ///
+ Task> FindOrderWithServiceProviderAsync(int serviceProvider);
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Queries/ITrackOrderQueries.cs b/src/SJZY.Track.Domain/Queries/ITrackOrderQueries.cs
new file mode 100644
index 00000000..45309ad5
--- /dev/null
+++ b/src/SJZY.Track.Domain/Queries/ITrackOrderQueries.cs
@@ -0,0 +1,13 @@
+using SJZY.Track.Domain.Dtos.Order;
+
+namespace SJZY.Track.Domain.Queries;
+
+public interface ITrackOrderQueries
+{
+ ///
+ /// 获取分页的轨迹订单
+ ///
+ ///
+ ///
+ Task> GetPageTrackOrder(GetPageTrackOrderInputVO input);
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/SJZY.Track.Domain.csproj b/src/SJZY.Track.Domain/SJZY.Track.Domain.csproj
index b1f4dc63..cb0a715f 100644
--- a/src/SJZY.Track.Domain/SJZY.Track.Domain.csproj
+++ b/src/SJZY.Track.Domain/SJZY.Track.Domain.csproj
@@ -4,6 +4,7 @@
net7.0
+ True
diff --git a/src/SJZY.Track.Repository/Queries/BasicQuery.cs b/src/SJZY.Track.Repository/Queries/BasicQuery.cs
index 60a234ef..d8003be8 100644
--- a/src/SJZY.Track.Repository/Queries/BasicQuery.cs
+++ b/src/SJZY.Track.Repository/Queries/BasicQuery.cs
@@ -13,7 +13,7 @@ public class BasicQuery : SimpleClient, IBasicQuery where T : class, IE
Context = SqlsugarScopeBasic.GetContextSafely("default");
}
- public async Task GetFirstAsync(Expression> whereExpression,
+ public async Task GetFirstAsync(Expression> whereExpression,
Expression> resultExpression)
{
return await Context.Queryable().Where(whereExpression).Select(resultExpression).FirstAsync();
diff --git a/src/SJZY.Track.Repository/Queries/ProvideQueries.cs b/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
index 526d5e3d..8058689e 100644
--- a/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
+++ b/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
@@ -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> GetCanDeleteTrackCodesAsync(int orderId, List trackCodes)
+ public async Task> GetCanDeleteTrackCodesAsync(List orderIds,
+ List trackCodes)
{
return await Context.Queryable()
.LeftJoin((x, a) => x.TrackTemplateId == a.TrackTemplateId && a.IsCanDelete)
.LeftJoin((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> GetPullContentConfigsAsync(int serviceProviderId)
+
+ public async Task> FindOrderWithServiceProviderAsync(List orderNos)
{
- return await Context.Queryable()
- .LeftJoin((a, b) => a.Id == b.TrackPullConfigId)
- .Where(a => a.ServiceProviderId == serviceProviderId)
- .Select(x => new TrackPullContentConfigVO
+ return await Context.Queryable()
+ .LeftJoin((a, b) => a.Id == b.OrderId)
+ .LeftJoin((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> FindOrderWithServiceProviderAsync(int serviceProvider)
+ {
+ return await Context.Queryable()
+ .RightJoin((a, b) => a.Id == b.OrderId)
+ .LeftJoin((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();
}
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Repository/Queries/TrackOrderQueries.cs b/src/SJZY.Track.Repository/Queries/TrackOrderQueries.cs
new file mode 100644
index 00000000..73a566d0
--- /dev/null
+++ b/src/SJZY.Track.Repository/Queries/TrackOrderQueries.cs
@@ -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");
+ }
+
+ ///
+ /// 获取分页的轨迹订单
+ ///
+ ///
+ ///
+ public async Task> GetPageTrackOrder(GetPageTrackOrderInputVO input)
+ {
+ List orderNoList = new List();
+ List questionTypeIds = new List();
+ int ques = 0;
+ if (!input.OrderNos.IsNullOrWhiteSpace())
+ {
+ orderNoList = input.OrderNos!.Split(new[] { ',', ',', ':', ':' }).ToList();
+ }
+
+ if (input.TabType == 1)
+ {
+ questionTypeIds = new List { 1, 4 };
+ ques = questionTypeIds.Sum();
+ }
+ else if (input.TabType == 2)
+ {
+ questionTypeIds = new List { 2, 4 };
+ ques = questionTypeIds.Sum();
+ }
+
+ var pageList = await Context.Queryable()
+ .LeftJoin((a, b) => a.CustomId == b.Id && b.IsDeleted == false)
+ .LeftJoin((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()
+ // .LeftJoin((aa, bb) => aa.TrackTemplateId == bb.Id)
+ // .Where((aa, bb) => a.Id == aa.OrderId).SelectStringJoin((aa, bb) => bb.Name, ","),
+
+ //TrackTemplateIds = SqlFunc.Subqueryable()
+ // .LeftJoin((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()
+ .LeftJoin((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;
+ }
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
index 481a5c87..633db8c2 100644
--- a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
@@ -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, 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, 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, IOrderRepository, I
}
#endregion
-
- #region 轨迹订单明细
-
- /////
- ///// 根据轨迹订单id获取轨迹明细列表
- /////
- /////
- /////
- //public async Task> GetOrderDetails(GetOrderDetailsInputVO input)
- //{
- // return null;
- //}
-
- #endregion
-
- #region 轨迹订单分页
-
- ///
- /// 获取分页的轨迹订单
- ///
- ///
- ///
- public async Task> GetPageTrackOrder(GetPageTrackOrderInputVO input)
- {
- List orderNoList = new List();
- if (!input.OrderNos.IsNullOrWhiteSpace())
- {
- orderNoList = input.OrderNos.Split(new char[] { ',', ',', ':', ':' }).ToList();
- }
-
- var pageList = await Context.Queryable()
- .LeftJoin((a, b) => a.CustomId == b.Id && b.IsDeleted == false)
- .LeftJoin((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()
- // .LeftJoin((aa, bb) => aa.TrackTemplateId == bb.Id)
- // .Where((aa, bb) => a.Id == aa.OrderId).SelectStringJoin((aa, bb) => bb.Name, ","),
-
- //TrackTemplateIds = SqlFunc.Subqueryable()
- // .LeftJoin((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()
- .LeftJoin((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()
- // .LeftJoin((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> GetOrderTemplatesAsync(List orderNos)
- {
- return await Context.Queryable()
- .LeftJoin((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();
- }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
index 70f62f7e..132341a1 100644
--- a/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
@@ -38,7 +38,8 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract request
- .Index(index.IndexName)
+ .Index(index.IndexName)
+ //.Refresh(Refresh.True) // 可选:立即刷新索引使更改立即可见
);
if (!r.IsValid)
@@ -86,7 +87,12 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract?> GetListAsync(int orderId)
+ public Task> GetListAsync(int orderType, List orderNos, string trackCode)
+ {
+ throw new NotImplementedException();
+ }
+
+ public async Task> GetListAsync(int orderId)
{
var data = await Context.SearchAsync(x => x
.Query(q =>
@@ -95,7 +101,7 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract s.Field(f => f.TrackTime, SortOrder.Descending)));
- return data?.Documents?.ToList();
+ return data.Documents.ToList();
}
public async Task?> GetListAsync(List orderIds)
@@ -109,18 +115,42 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract trackCodes)
+ public async Task GetLatestAsync(int orderId)
+ {
+ var data = await Context.SearchAsync(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 DeleteTrackAsync(int orderId, List trackCodes)
{
var r = await Context.DeleteByQueryAsync(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 list, long total)> GetListAsync(TrackDetailsQueryInput input)
diff --git a/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs
index 3a381a0f..b3267e8a 100644
--- a/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs
@@ -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,
return await AsQueryable()
.LeftJoin((trackPull, system) => trackPull.SubSystemId == system.Id && !system.IsDeleted)
.LeftJoin((trackPull, system, service) => trackPull.ServiceProviderId == service.Id && !service.IsDeleted)
- .LeftJoin((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,
{
return await Context.Queryable()
.InnerJoin((pullContent, trackContent) => pullContent.TrackContentId == trackContent.Id)
- .InnerJoin((pullContent, trackContent, trackPull) => pullContent.TrackPullConfigId == trackPull.Id)
- .InnerJoin((pullContent, trackContent, trackPull, templateContent) => trackPull.TrackTemplateId == templateContent.TrackTemplateId && pullContent.TrackContentId == templateContent.TrackContentId)
+ .LeftJoin((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> GetContentListCacheAsync(int trackPullConfigId)
+ {
+ return await Context.Queryable()
+ .InnerJoin((pullContent, trackContent) => pullContent.TrackContentId == trackContent.Id)
+ .Where(pullContent => pullContent.TrackPullConfigId == trackPullConfigId)
+ .Select((pullContent, trackContent) => new GetTrackPullContentListCacheVO
+ {
+ TrackContentCode = trackContent.Code
+ }, true)
+ .ToListAsync();
+ }
+
public async Task GetDetailAsync(int id)
{
return await AsQueryable()
.LeftJoin((trackPull, system) => trackPull.SubSystemId == system.Id && !system.IsDeleted)
.LeftJoin((trackPull, system, service) => trackPull.ServiceProviderId == service.Id && !service.IsDeleted)
- .LeftJoin((trackPull, system, service, template) => trackPull.TrackTemplateId == template.Id && !template.IsDeleted)
- .InnerJoin((trackPull, system, service, template, paramsConfig) => trackPull.Id == paramsConfig.PullOrPushConfigId && !paramsConfig.IsPush && !paramsConfig.IsDeleted)
+ .InnerJoin((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,
return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0;
}
- public async Task InsertContentRangeAsync(List insertObjs)
+ public async Task InsertContentAsync(TrackPullContentConfigEntity insertObj)
{
- return await Context.Insertable(insertObjs).ExecuteCommandAsync() > 0;
+ return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0;
}
public async Task GetParamsSingleAsync(Expression> whereExpression)
diff --git a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs
index f6a325fd..e58b1020 100644
--- a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs
@@ -20,25 +20,19 @@ public class TrackPushConfigRepository : BasicRepository,
return await AsQueryable()
.LeftJoin((trackPush, system) => trackPush.SubSystemId == system.Id && !system.IsDeleted)
.LeftJoin((trackPush, system, externalSubject) => trackPush.CustomId == externalSubject.Id && !externalSubject.IsDeleted)
- .LeftJoin((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()
- .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,
CustomName = externalSubject.Abbreviation,
ServiceProvider = service.Name,
}, true)
- .Mapper(x => { x.TrackTemplateIds = x.TrackTemplateId.Split(',').Select(int.Parse).ToList(); })
.SingleAsync();
}
diff --git a/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs
index 21b72d53..88ebb3ba 100644
--- a/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs
@@ -71,8 +71,6 @@ public class TrackTemplateRepository : BasicRepository, ITr
///
public async Task GetTrackContentAttributeValue(GetTemplateContentAttributeValueInputVO input)
{
-
-
return null;
}
@@ -176,22 +174,6 @@ public class TrackTemplateRepository : BasicRepository, ITr
return await Context.Updateable(updateObjs).ExecuteCommandHasChangeAsync();
}
- public async Task> GetContentDropDownListAsync(GetTrackTemplateContentDropDownListVO input)
- {
- return await Context.Queryable()
- .InnerJoin((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 ContentMaxAsync(Expression> columns, Expression> whereExpression)
{
return await Context.Queryable().Where(whereExpression).MaxAsync(columns);