From dd92ea9102203235b99d108dd3279480313825b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Tue, 12 Mar 2024 09:51:22 +0800
Subject: [PATCH 1/6] =?UTF-8?q?=E8=A7=A3=E5=86=B3swagger=E5=AD=97=E6=AE=B5?=
=?UTF-8?q?=E6=B3=A8=E9=87=8A=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../SJZY.Track.Application.Contract.csproj | 1 +
1 file changed, 1 insertion(+)
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 0a863be2..041d97e2 100644
--- a/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj
+++ b/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj
@@ -5,6 +5,7 @@
net7.0
1.0.0
+ True
From 2d7e1fb60928b10b459c83aa0c51ee51f1aafa5b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Tue, 12 Mar 2024 09:54:06 +0800
Subject: [PATCH 2/6] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/SJZY.Track.Domain/SJZY.Track.Domain.csproj | 1 +
1 file changed, 1 insertion(+)
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
From 2ce73fd57b5720a98f266e8ce38bac3de04c7593 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Tue, 12 Mar 2024 10:11:17 +0800
Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/TrackPull/TrackPullCacheService.cs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
index 0367196b..168dae3a 100644
--- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
@@ -34,7 +34,9 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService,
{
var data = new TrackPullConfigDto();
- Expression> exp = x => id.HasValue ? x.Id == id : x.SubSystemId == subSystemId && x.ServiceProviderId == serviceProviderId;
+ Expression> exp = x =>
+ (!id.HasValue || x.Id == id) && (id.HasValue || (x.SubSystemId == subSystemId && x.ServiceProviderId == serviceProviderId));
+
var trackPullConfigEntity = await _trackPullConfigRepository.GetFirstAsync(exp);
if (trackPullConfigEntity == null) return data;
From b1441abf26c9c83756b2f5fed9f20b70b57f092c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Tue, 12 Mar 2024 10:19:02 +0800
Subject: [PATCH 4/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BD=A8=E8=BF=B9?=
=?UTF-8?q?=E6=8B=89=E5=8F=96=E5=86=85=E5=AE=B9=E5=85=A5=E5=8F=82=E6=A0=A1?=
=?UTF-8?q?=E9=AA=8C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/TrackPull/TrackPullService.cs | 2 +-
.../EditTrackPullContentInputValidation.cs | 33 +++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
create mode 100644 src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullContentInputValidation.cs
diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs
index 90f6bbcb..61f2cb2d 100644
--- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs
@@ -167,7 +167,7 @@ public class TrackPullService : ApplicationService, ITransientDependency
///
///
[HttpPost("EditContent")]
- public async Task UpdateContentAsync([FromBody] EditTrackPullContentInput input)
+ public async Task EditContentAsync([FromBody] EditTrackPullContentInput input)
{
if (input.Options != OptionTypeNoNull.删除)
{
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
From ff32e003f4987a81fc93d4545f96ca6090abfe48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Tue, 12 Mar 2024 10:49:04 +0800
Subject: [PATCH 5/6] =?UTF-8?q?=E6=8B=89=E5=8F=96=20=E6=8E=A8=E9=80=81=20?=
=?UTF-8?q?=E5=88=97=E8=A1=A8=E8=BF=94=E5=9B=9E=E5=AD=90=E7=B3=BB=E7=BB=9F?=
=?UTF-8?q?id?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs | 5 +++++
.../Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs | 5 +++++
.../Repositories/TrackPullConfigRepository.cs | 1 +
.../Repositories/TrackPushConfigRepository.cs | 1 +
4 files changed, 12 insertions(+)
diff --git a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs
index 4fd13bbd..bd73f920 100644
--- a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs
@@ -18,4 +18,9 @@ public class GetTrackPullConfigPageOutputVO
/// 子系统名称
///
public string SubSystem { get; set; }
+
+ ///
+ /// 子系统id
+ ///
+ public int SubSystemId { 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 ba01bf5e..01550b7f 100644
--- a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs
@@ -18,4 +18,9 @@ public class GetTrackPushConfigPageOutputVO
/// 子系统名称
///
public string SubSystem { get; set; }
+
+ ///
+ /// 子系统id
+ ///
+ public int SubSystemId { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs
index 5f71c4c2..b3267e8a 100644
--- a/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs
@@ -25,6 +25,7 @@ public class TrackPullConfigRepository : BasicRepository,
.Select((trackPull, system, service) => new GetTrackPullConfigPageOutputVO
{
Id = trackPull.Id,
+ SubSystemId = system.Id,
SubSystem = system.CnName,
ServiceProvider = service.Name,
CreateTime = trackPull.CreateTime
diff --git a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs
index a04a0ac2..e58b1020 100644
--- a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs
@@ -28,6 +28,7 @@ public class TrackPushConfigRepository : BasicRepository,
.Select((trackPush, system, externalSubject) => new GetTrackPushConfigPageOutputVO
{
Id = trackPush.Id,
+ SubSystemId = system.Id,
SubSystem = system.CnName,
CustomName = externalSubject.Abbreviation,
CreateTime = trackPush.CreateTime
From f4b7645ddfe5534a6a5857ce3b5e1e749612f9bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Tue, 12 Mar 2024 15:59:34 +0800
Subject: [PATCH 6/6] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=89=B9=E9=87=8F?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E=E3=80=81=E6=9B=B4=E6=96=B0=E8=BD=A8=E8=BF=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ProvideServices/BatchDeleteTrackInput.cs | 15 +---
.../ProvideServices/BatchUpsertTrackInput.cs | 33 +++++++++
.../Dtos/ProvideServices/GetTrackInput.cs | 14 +---
.../Dtos/ProvideServices/OrderNoInfo.cs | 16 +++++
.../Dtos/ProvideServices/UpsertTrackInput.cs | 14 ----
.../SJZY.Track.Application.Contract.csproj | 1 +
.../EventHandlers/TrackDeleteEventHandler.cs | 2 +-
.../EventHandlers/TrackRefreshEventHandler.cs | 63 +++++++++++------
.../SJZY.Track.Application.csproj | 2 +-
.../ProvideServices/OrderService.Link.cs | 6 ++
.../Services/ProvideServices/OrderService.cs | 11 +++
.../ProvideServices/TrackPushPullService.cs | 6 +-
.../ProvideServices/TrackService.Query.cs | 6 ++
.../Services/ProvideServices/TrackService.cs | 68 +++++++++++++++++--
.../Repositories/TrackDetailsRepository.cs | 3 +-
15 files changed, 187 insertions(+), 73 deletions(-)
create mode 100644 src/SJZY.Track.Application.Contract/Dtos/ProvideServices/BatchUpsertTrackInput.cs
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/BatchDeleteTrackInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/BatchDeleteTrackInput.cs
index 5616f912..0a79e008 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/BatchDeleteTrackInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/BatchDeleteTrackInput.cs
@@ -2,21 +2,8 @@
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
-public class BatchDeleteTrackInput
+public class BatchDeleteTrackInput : OrderNosInfo
{
- ///
- /// 订单类型,必填
- ///
- [Required]
- [Range(1, int.MaxValue)]
- public int OrderType { get; set; }
-
- ///
- /// 订单号,必填
- ///
- [Required]
- public List OrderNos { get; set; } = new();
-
///
/// 轨迹code,必填
///
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/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/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/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/SJZY.Track.Application.Contract.csproj b/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj
index 0a863be2..68b939c0 100644
--- a/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj
+++ b/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj
@@ -4,6 +4,7 @@
net7.0
+ True
1.0.0
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackDeleteEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackDeleteEventHandler.cs
index 55bb5b1d..5fa44212 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;
}
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
index 50cabb23..e898fcf7 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
@@ -1,4 +1,5 @@
-using System.Linq.Expressions;
+using System.Diagnostics;
+using System.Linq.Expressions;
using DotNetCore.CAP;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -94,47 +95,71 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
var trackUpsertEvent = @event.DeepCopy();
var paramConfig = config.ParamConfig;
var contentConfigs = config.ContentConfigs;
- TrackPullContentConfigDto? trackContent = null;
+ TrackPullContentConfigDto? matchedContentConfig = null;
// 1、匹配轨迹代码
- var serviceProviderTrackCode = trackToken[paramConfig.TrackContentCodeName]?.Value();
- if (!serviceProviderTrackCode.IsNullOrWhiteSpace())
+ var trackCode = trackToken[paramConfig.TrackContentCodeName]?.Value();
+ if (!trackCode.IsNullOrWhiteSpace())
{
- trackContent = contentConfigs.FirstOrDefault(x => x.TrackContentCodeValue == serviceProviderTrackCode);
+ matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackContentCodeValue == trackCode);
}
// 2、匹配轨迹状态
- if (trackContent is null)
+ if (matchedContentConfig is null)
{
- var serviceProviderTrackStatus = trackToken[paramConfig.TrackStatusName]?.Value();
- if (!serviceProviderTrackStatus.IsNullOrWhiteSpace())
+ var trackStatus = trackToken[paramConfig.TrackStatusName]?.Value();
+ if (!trackStatus.IsNullOrWhiteSpace())
{
- trackContent = contentConfigs.FirstOrDefault(x => x.TrackStatusValue == serviceProviderTrackCode);
+ matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackStatusValue == trackCode);
}
}
// 3、匹配轨迹内容
- if (trackContent is null)
+ if (matchedContentConfig is null)
{
- var serviceProviderTrackContent = trackToken[paramConfig.TrackContentName]?.Value();
- if (!serviceProviderTrackContent.IsNullOrWhiteSpace())
+ var trackContent = trackToken[paramConfig.TrackContentName]?.Value();
+ if (!trackContent.IsNullOrWhiteSpace())
{
- trackContent = contentConfigs.FirstOrDefault(x => x.TrackContentValue == serviceProviderTrackCode);
+ Debug.Assert(trackContent != null, nameof(trackContent) + " != null");
+ matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackContentValue == trackCode);
- // 3.1、按关键字匹配
- if (trackContent is null)
+ // 按关键字分析轨迹内容
+ if (matchedContentConfig is null)
{
+ foreach (var contentConfig in contentConfigs)
+ {
+ foreach (var keyword in contentConfig.TrackKeyword?.Split(',') ?? Enumerable.Empty())
+ {
+ 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 (trackContent is null) return;
+ if (matchedContentConfig is null) return;
var trackPlace = trackToken[paramConfig.TrackPlaceName]?.Value();
if (trackPlace.IsNullOrWhiteSpace())
{
Expression> resultExpression =
- (TrackLocationValue?)trackContent.TrackPlaceValue switch
+ (TrackLocationValue?)matchedContentConfig.TrackPlaceValue switch
{
TrackLocationValue.ArrivalPort => x => x.ArrivalPort,
TrackLocationValue.ArriveCity => x => x.ArrivalCity,
@@ -149,11 +174,11 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
}
// 新增/更新轨迹
- trackUpsertEvent.TrackCode = trackContent.TrackContentCode;
+ trackUpsertEvent.TrackCode = matchedContentConfig.TrackContentCode;
trackUpsertEvent.TrackPlace = trackPlace ?? "CN";
trackUpsertEvent.TrackTime = trackToken[paramConfig.TrackTimeName]?.Value() ?? DateTime.Now;
trackUpsertEvent.TrackTimeZone = trackToken[paramConfig.TrackTimeZoneName]?.Value() ??
- trackContent.TrackTimeZoneValue ?? 8;
+ matchedContentConfig.TrackTimeZoneValue ?? 8;
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, trackUpsertEvent);
}
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/SJZY.Track.Application.csproj b/src/SJZY.Track.Application/SJZY.Track.Application.csproj
index d2b2eafd..da60d1a4 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/OrderService.Link.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs
index 5c35b728..51f50f3b 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs
@@ -14,6 +14,12 @@ public partial class OrderService
private readonly IBasicQuery _orderLinkQuery;
private readonly ICapPublisher _capPublisher;
+ ///
+ /// 关联、解除关联订单
+ ///
+ ///
+ ///
+ ///
[HttpPost("Order/Link")]
public async Task LinkOrderAsync(LinkOrderInput input)
{
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
index 5c56337d..765ff6ad 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
@@ -24,6 +24,11 @@ public partial class OrderService : ApplicationService, IOrderService
_orderLinkQuery = orderLinkQuery;
}
+ ///
+ /// 新增、更新订单(存在就更新)
+ ///
+ ///
+ ///
[HttpPost("Order/Upsert")]
public async Task UpsertAsync(UpsertOrderInput input)
{
@@ -45,6 +50,12 @@ public partial class OrderService : ApplicationService, IOrderService
return "创建成功";
}
+ ///
+ /// 删除订单
+ ///
+ ///
+ ///
+ ///
[HttpPost("Order/Delete")]
public async Task DeleteOrderAsync(DeleteOrderInput input)
{
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
index 66625f36..2e1dd08b 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
@@ -15,10 +15,10 @@ namespace SJZY.Track.Application.Services.ProvideServices;
public class TrackPushPullService : ApplicationService
{
private readonly IOrderRepository _orderRepository;
- private readonly IHttpClientProxy _httpClientProxy;
+ private readonly IHttpClientProxy _httpClientProxy;
public TrackPushPullService(IOrderRepository orderRepository,
- IHttpClientProxy httpClientProxy)
+ IHttpClientProxy httpClientProxy)
{
_orderRepository = orderRepository;
_httpClientProxy = httpClientProxy;
@@ -51,7 +51,7 @@ public class TrackPushPullService : ApplicationService
// 批量获取轨迹
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
- "A012", group.Key.ServiceProviderCode, 42, data,
+ "A012", group.Key.ServiceProviderCode, data,
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
}
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.Query.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.Query.cs
index 372d3f01..35237196 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.Query.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.Query.cs
@@ -10,6 +10,12 @@ public partial class TrackService
{
private readonly ITrackDetailsRepository _trackDetailsRepository;
+ ///
+ /// 查询轨迹
+ ///
+ ///
+ ///
+ ///
[HttpPost("Track/Query")]
public async Task> QueryAsync(GetTrackInput input)
{
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
index 7c84dbc3..fbd0fd99 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
@@ -29,6 +29,12 @@ public partial class TrackService : ApplicationService, ITrackService
_trackDetailsRepository = trackDetailsRepository;
}
+ ///
+ /// 新增、更新轨迹(存在就更新)
+ ///
+ ///
+ ///
+ ///
[HttpPost("Track/Upsert")]
public async Task UpsertTrackAsync(UpsertTrackInput input)
{
@@ -52,24 +58,68 @@ public partial class TrackService : ApplicationService, ITrackService
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.IsPushCompleted, x.CustomId
+ });
+
+ foreach (var order in orders)
+ {
+ // 新增/更新轨迹
+ var @event = new TrackUpsertEvent
+ {
+ TrackCode = input.TrackCode,
+ TrackPlace = input.TrackPlace,
+ TrackTime = input.TrackTime,
+ TrackTimeZone = input.TrackTimeZone,
+ OrderType = input.OrderType,
+ OrderNo = order.OrderNo,
+ OrderId = order.Id,
+ SubSystemId = order.SubSystemId,
+ IsPushCompleted = order.IsPushCompleted,
+ CustomId = order.CustomId
+ };
+ await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
+ }
+
+ return true;
+ }
+
+ ///
+ /// 删除轨迹
+ ///
+ ///
+ ///
+ ///
[HttpPost("Track/Delete")]
public async Task DeleteTrackAsync(DeleteTrackInput input)
{
var order = await _orderRepository.GetFirstAsync(x =>
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new
{
- x.Id, x.SubSystemId, x.IsCompleted
+ x.Id, x.SubSystemId
});
if (order == default)
{
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
}
- if (order.IsCompleted)
- {
- throw new BusinessException(message: $"订单:{input.OrderNo}已完成无法删除轨迹");
- }
-
var codes = await _provideQueries.GetCanDeleteTrackCodesAsync(new List(order.Id), input.TrackCodes);
if (codes.Count == 0)
@@ -89,6 +139,12 @@ public partial class TrackService : ApplicationService, ITrackService
return true;
}
+ ///
+ /// 批量删除轨迹
+ ///
+ ///
+ ///
+ ///
[HttpPost("Track/BatchDelete")]
public async Task BatchDeleteTrackAsync(BatchDeleteTrackInput input)
{
diff --git a/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
index e6aae4f0..99290105 100644
--- a/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
@@ -1,4 +1,3 @@
-using Elasticsearch.Net;
using Nest;
using SJZY.Expand.ABP.Core.Logger;
using SJZY.Expand.ElasticSearch.Services;
@@ -40,7 +39,7 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract request
.Index(index.IndexName)
- .Refresh(Refresh.True) // 可选:立即刷新索引使更改立即可见
+ //.Refresh(Refresh.True) // 可选:立即刷新索引使更改立即可见
);
if (!r.IsValid)