From 2e0a1f3e4db20b67d0d4248f6651527d27ce4d13 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Fri, 8 Mar 2024 09:50:02 +0800
Subject: [PATCH 01/49] =?UTF-8?q?=E8=BD=A8=E8=BF=B9=E6=98=A0=E5=B0=84?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../TrackPull/EditTrackPullConfigInput.cs | 5 -
...tInput.cs => EditTrackPullContentInput.cs} | 13 +-
.../TrackPush/EditTrackPushConfigInput.cs | 23 ++--
.../AutoMapper/TrackPullAutoMapperProfile.cs | 2 +-
.../AutoMapper/TrackPushAutoMapperProfile.cs | 3 +-
.../Services/TrackPull/TrackPullService.cs | 130 ++++++++----------
.../Services/TrackPush/TrackPushService.cs | 32 +----
.../TrackTemplates/TrackTemplateService.cs | 57 ++------
.../EditTrackPullConfigInputValidation.cs | 4 -
.../ITrackPullConfigRepository.cs | 2 +-
.../TrackPullConfigEntity.cs | 6 -
.../TrackPushConfigEntity.cs | 12 +-
.../ITrackTemplateRepository.cs | 2 -
.../GetTrackPullConfigDetailOutputVO.cs | 10 --
.../GetTrackPullConfigPageOutputVO.cs | 5 -
.../GetTrackPushConfigDetailOutputVO.cs | 25 ++--
.../GetTrackPushConfigPageOutputVO.cs | 15 --
.../GetTrackTemplateContentDropDownListVO.cs | 14 --
.../Enums/EnumPropertyEnums.cs | 7 +-
.../Repositories/TrackPullConfigRepository.cs | 30 ++--
.../Repositories/TrackPushConfigRepository.cs | 12 +-
.../Repositories/TrackTemplateRepository.cs | 18 ---
22 files changed, 141 insertions(+), 286 deletions(-)
rename src/SJZY.Track.Application.Contract/Dtos/TrackPull/{UpdateTrackPullContentInput.cs => EditTrackPullContentInput.cs} (79%)
delete mode 100644 src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentDropDownListVO.cs
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs
index 2803a4b3..a53c49b3 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs
@@ -59,11 +59,6 @@ public class EditTrackPullConfigInput
///
public string? TrackStatusName { get; set; }
- ///
- /// 轨迹模板id
- ///
- public int? TrackTemplateId { get; set; }
-
///
/// 拉取轨迹发生时间
///
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/TrackPush/EditTrackPushConfigInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs
index b462f6a4..ebd8e0be 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,12 +32,12 @@ 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; }
///
/// 推送轨迹时区
@@ -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/AutoMapper/TrackPullAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackPullAutoMapperProfile.cs
index d8dad310..02553894 100644
--- a/src/SJZY.Track.Application/AutoMapper/TrackPullAutoMapperProfile.cs
+++ b/src/SJZY.Track.Application/AutoMapper/TrackPullAutoMapperProfile.cs
@@ -12,7 +12,7 @@ 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)));
}
diff --git a/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs
index 3a42d0e4..eed8b90b 100644
--- a/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs
+++ b/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs
@@ -10,8 +10,7 @@ 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);
diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs
index 34998b29..7161b54c 100644
--- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs
@@ -1,5 +1,4 @@
-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;
@@ -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,13 +102,7 @@ public class TrackPullService : ApplicationService, ITransientDependency
case OptionTypeNoNull.新增:
{
var trackPullEntity = ObjectMapper.Map(input);
- var trackPullParamsEntity =
- ObjectMapper.Map(input);
-
- var trackTemplateContentEntities =
- await _trackTemplateRepository.GetContentListAsync(x => x.TrackTemplateId == input.TrackTemplateId);
-
- var trackPullContentEntities = new List();
+ var trackPullParamsEntity = ObjectMapper.Map(input);
using (var ts = TransactionScopeHelper.Create())
{
@@ -119,17 +111,6 @@ public class TrackPullService : ApplicationService, ITransientDependency
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();
}
}
@@ -137,30 +118,9 @@ public class TrackPullService : ApplicationService, ITransientDependency
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,12 +130,6 @@ 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();
}
}
@@ -185,8 +139,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();
@@ -207,34 +160,65 @@ public class TrackPullService : ApplicationService, ITransientDependency
///
///
///
- [HttpPost("UpdateContent")]
- public async Task UpdateContentAsync([FromBody] UpdateTrackPullContentInput input)
+ [HttpPost("EditContent")]
+ public async Task UpdateContentAsync([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);
+
+ 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);
+
+ break;
+ }
+
+ case OptionTypeNoNull.删除:
+
+ await _trackPullConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id);
+
+ break;
+
+ default:
+ throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum,
+ nameof(EditTrackPullContentInput.Options)]);
+ }
return true;
}
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
index 1b009a95..1ecb8f41 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
@@ -1,5 +1,4 @@
using Microsoft.Extensions.Localization;
-using SJZY.Expand.ABP.Core;
using SJZY.Expand.ABP.Core.Localization;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.Track.Application.Contract.Dtos.TrackPush;
@@ -73,16 +72,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);
}
///
@@ -110,13 +100,7 @@ public class TrackPushService : ApplicationService, ITransientDependency
x.SubSystemId == input.SubSystemId && x.CustomId == input.CustomId && x.ServiceProviderId == input.ServiceProviderId;
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"]);
+ if (await _trackPushConfigRepository.IsAnyAsync(isAnyExp)) throw new BusinessException(message: _stringLocalizer["IsTrackPushConfigAny"]);
}
switch (input.Options)
@@ -133,7 +117,7 @@ public class TrackPushService : ApplicationService, ITransientDependency
trackPushParamsEntity.PullOrPushConfigId = id;
await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity);
- if (input.IsAutoPush) await _trackPushCacheService.IsPushAsync(input.CustomId);
+ if (input.IsAutoPush!.Value) await _trackPushCacheService.IsPushAsync(input.CustomId!.Value);
ts.Complete();
}
@@ -146,9 +130,7 @@ public class TrackPushService : ApplicationService, ITransientDependency
int oldCustomId = oldTrackPushEntity.CustomId;
- var oldTrackPushParamsEntity =
- await _trackPullConfigRepository.GetParamsSingleAsync(x =>
- x.PullOrPushConfigId == input.Id && x.IsPush);
+ var oldTrackPushParamsEntity = await _trackPullConfigRepository.GetParamsSingleAsync(x => x.PullOrPushConfigId == input.Id && x.IsPush);
ObjectMapper.Map(input, oldTrackPushEntity);
ObjectMapper.Map(input, oldTrackPushParamsEntity);
@@ -159,7 +141,7 @@ public class TrackPushService : ApplicationService, ITransientDependency
await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity);
await _trackPushCacheService.UpdateAsync(oldCustomId, false);
- if (input.IsAutoPush) await _trackPushCacheService.IsPushAsync(input.CustomId);
+ if (input.IsAutoPush!.Value) await _trackPushCacheService.IsPushAsync(input.CustomId!.Value);
ts.Complete();
}
@@ -173,10 +155,8 @@ public class TrackPushService : ApplicationService, ITransientDependency
using (var ts = TransactionScopeHelper.Create())
{
await _trackPushConfigRepository.SoftDeleteAsync(x => x.Id == input.Id);
- await _trackPullConfigRepository.SoftDeleteParamsAsync(x =>
- x.PullOrPushConfigId == input.Id && x.IsPush);
+ await _trackPullConfigRepository.SoftDeleteParamsAsync(x => x.PullOrPushConfigId == input.Id && x.IsPush);
await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id);
-
await _trackPushCacheService.UpdateAsync(oldTrackPushEntity.CustomId, false);
ts.Complete();
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/Validations/TrackPull/EditTrackPullConfigInputValidation.cs b/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs
index 9b0a4503..e54d9279 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,8 +36,6 @@ 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)]);
diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs
index 7b7dec1f..606f813f 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs
@@ -35,7 +35,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/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/TrackPull/GetTrackPullConfigDetailOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs
index c424e5a6..2d917ce0 100644
--- a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs
@@ -64,16 +64,6 @@ public class GetTrackPullConfigDetailOutputVO
///
public string TrackStatusName { get; set; }
- ///
- /// 轨迹模板
- ///
- public string TrackTemplate { get; set; }
-
- ///
- /// 轨迹模板id
- ///
- public int TrackTemplateId { get; set; }
-
///
/// 拉取轨迹发生时间
///
diff --git a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs
index 15d25401..4fd13bbd 100644
--- a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs
@@ -18,9 +18,4 @@ public class GetTrackPullConfigPageOutputVO
/// 子系统名称
///
public string SubSystem { get; set; }
-
- ///
- /// 模板名称
- ///
- public string TrackTemplate { 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..46bf32f8 100644
--- a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs
@@ -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..ba01bf5e 100644
--- a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs
@@ -18,19 +18,4 @@ public class GetTrackPushConfigPageOutputVO
/// 子系统名称
///
public string SubSystem { get; set; }
-
- ///
- /// 模板名称
- ///
- public string TrackTemplate { get; set; }
-
- ///
- /// 轨迹模板id
- ///
- public string TrackTemplateId { get; set; }
-
- ///
- /// 轨迹模板ids
- ///
- public List TrackTemplateIds { 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.Repository/Repositories/TrackPullConfigRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs
index 3a381a0f..23061501 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,16 @@ 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,
SubSystem = system.CnName,
ServiceProvider = service.Name,
- TrackTemplate = template.Name,
CreateTime = trackPull.CreateTime
})
.ToPagedListAsync(input.PageIndex, input.PageSize);
@@ -38,12 +37,13 @@ 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, trackPull, 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, trackPull, enumValue) => new GetTrackPullContentPageOutputVO
{
- Id = pullContent.Id
+ Id = pullContent.Id,
+ TrackPlaceValue = enumValue.Disp
}, true)
.ToPagedListAsync(input.PageIndex, input.PageSize);
}
@@ -53,16 +53,14 @@ 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)
- .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 +88,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..a04a0ac2 100644
--- a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs
@@ -20,25 +20,18 @@ 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,
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 +67,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);
From 76fcd29ca71191e3e30cfa4180ecbd4d187bb19b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Fri, 8 Mar 2024 18:45:34 +0800
Subject: [PATCH 02/49] =?UTF-8?q?add=20=E5=85=B3=E8=81=94=E8=A1=A5?=
=?UTF-8?q?=E8=BD=A8=E8=BF=B9=EF=BC=8Cadd=20=E6=89=B9=E9=87=8F=E5=88=A0?=
=?UTF-8?q?=E9=99=A4=E8=BD=A8=E8=BF=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ProvideServices/BatchDeleteTrackInput.cs | 25 ++++++++
.../Dtos/ProvideServices/DeleteOrderInput.cs | 5 +-
.../Dtos/ProvideServices/LinkOrderInput.cs | 6 +-
.../Events/OrderLinkAfterFillTrackEvent.cs | 19 ++++++
.../OrderLinkAfterFillTrackHandler.cs | 61 +++++++++++++++++++
.../EventHandlers/TrackUpsertEventHandler.cs | 1 +
.../ProvideServices/OrderLinkService.cs | 43 +++++++++----
.../Services/ProvideServices/TrackService.cs | 45 +++++++++++++-
.../ITrackDetailsRepository.cs | 5 +-
.../TrackTemplate/CanDeleteTrackCodeVO.cs | 7 +++
src/SJZY.Track.Domain/GlobalConst.cs | 9 ++-
src/SJZY.Track.Domain/Queries/IBasicQuery.cs | 2 +-
.../Queries/IProvideQueries.cs | 7 +--
.../Queries/BasicQuery.cs | 2 +-
.../Queries/ProvideQueries.cs | 11 +++-
.../Repositories/TrackDetailsRepository.cs | 4 +-
16 files changed, 221 insertions(+), 31 deletions(-)
create mode 100644 src/SJZY.Track.Application.Contract/Dtos/ProvideServices/BatchDeleteTrackInput.cs
create mode 100644 src/SJZY.Track.Application.Contract/Events/OrderLinkAfterFillTrackEvent.cs
create mode 100644 src/SJZY.Track.Application/EventHandlers/OrderLinkAfterFillTrackHandler.cs
create mode 100644 src/SJZY.Track.Domain/Dtos/TrackTemplate/CanDeleteTrackCodeVO.cs
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..5616f912
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/BatchDeleteTrackInput.cs
@@ -0,0 +1,25 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
+
+public class BatchDeleteTrackInput
+{
+ ///
+ /// 订单类型,必填
+ ///
+ [Required]
+ [Range(1, int.MaxValue)]
+ public int OrderType { get; set; }
+
+ ///
+ /// 订单号,必填
+ ///
+ [Required]
+ public List OrderNos { get; set; } = new();
+
+ ///
+ /// 轨迹code,必填
+ ///
+ [Required]
+ public List TrackCodes { get; set; } = new();
+}
\ 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/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/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/EventHandlers/OrderLinkAfterFillTrackHandler.cs b/src/SJZY.Track.Application/EventHandlers/OrderLinkAfterFillTrackHandler.cs
new file mode 100644
index 00000000..4a014b49
--- /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.IsPushCompleted, 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,
+ IsPushCompleted = order.IsPushCompleted,
+ UpSubSystemId = @event.SubSystemId,
+ };
+
+ await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, fillTrackEvent);
+ }
+ }
+ }
+}
\ 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..db60129a 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)
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderLinkService.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderLinkService.cs
index c4a6d1db..56741efe 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/OrderLinkService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderLinkService.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;
@@ -13,11 +15,14 @@ public class OrderLinkService : ApplicationService
{
private readonly IOrderRepository _orderRepository;
private readonly IBasicQuery _orderLinkQuery;
+ private readonly ICapPublisher _capPublisher;
- public OrderLinkService(IBasicQuery orderLinkQuery, IOrderRepository orderRepository)
+ public OrderLinkService(IBasicQuery orderLinkQuery, IOrderRepository orderRepository,
+ ICapPublisher capPublisher)
{
_orderLinkQuery = orderLinkQuery;
_orderRepository = orderRepository;
+ _capPublisher = capPublisher;
}
///
@@ -28,14 +33,17 @@ public class OrderLinkService : ApplicationService
[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 +60,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 +91,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 +103,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/TrackService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
index 18adf7fa..298cc2a4 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
@@ -65,14 +65,19 @@ 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.IsCompleted
});
if (order == default)
{
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
}
- var codes = await _provideQueries.GetCanDeleteTrackCodesAsync(order.Id, input.TrackCodes);
+ if (order.IsCompleted)
+ {
+ throw new BusinessException(message: $"订单:{input.OrderNo}已完成无法删除轨迹");
+ }
+
+ var codes = await _provideQueries.GetCanDeleteTrackCodesAsync(new List(order.Id), input.TrackCodes);
if (codes.Count == 0)
{
@@ -83,11 +88,45 @@ 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 BatchTrackAsync(BatchDeleteTrackInput input)
+ {
+ var orders = await _orderRepository.GetListAsync(x =>
+ x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo) && !x.IsPushCompleted
+ , 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.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs
index f6578023..4025579e 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs
@@ -11,8 +11,8 @@ public interface ITrackDetailsRepository
Task> GetListAsync(int orderType, List orderNos);
Task<(List list, long total)> GetListAsync(TrackDetailsQueryInput input);
- Task?> GetListAsync(int orderId);
-
+ Task> GetListAsync(int orderId);
+
///
/// 删除轨迹
///
@@ -20,5 +20,6 @@ public interface ITrackDetailsRepository
///
///
Task DeleteTrackAsync(int orderId, List trackCodes);
+
Task?> GetListAsync(List orderIds);
}
\ 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/GlobalConst.cs b/src/SJZY.Track.Domain/GlobalConst.cs
index 92545ea9..78fdd6a8 100644
--- a/src/SJZY.Track.Domain/GlobalConst.cs
+++ b/src/SJZY.Track.Domain/GlobalConst.cs
@@ -11,14 +11,14 @@ 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";
@@ -27,6 +27,11 @@ public class GlobalConst
///
public const string UpdateOrderTrackSubscribe = "SJZY.Track.UpdateOrderTrack";
+ ///
+ /// 关联订单后补轨迹 mq订阅名称
+ ///
+ public const string OrderLinkAfterFillTrack = "SJZY.Track.OrderLinkAfterFillTrack";
+
///
/// 轨迹要推送的客户redis key前缀
///
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..710cb3f4 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
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..78639986 100644
--- a/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
+++ b/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
@@ -80,14 +80,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();
}
diff --git a/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
index 70f62f7e..da6f784a 100644
--- a/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
@@ -86,7 +86,7 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract?> GetListAsync(int orderId)
+ public async Task> GetListAsync(int orderId)
{
var data = await Context.SearchAsync(x => x
.Query(q =>
@@ -95,7 +95,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)
From dd1a653d267e59141367782a7023084e6570ea3b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Sat, 9 Mar 2024 10:20:49 +0800
Subject: [PATCH 03/49] =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=A1=A8=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=E5=AD=97=E6=AE=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../TrackPushPullParamsConfigEntity.cs | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPushPullParamsConfigEntity.cs b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPushPullParamsConfigEntity.cs
index 8187c651..85495ade 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPushPullParamsConfigEntity.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPushPullParamsConfigEntity.cs
@@ -77,4 +77,16 @@ public class TrackPushPullParamsConfigEntity : IFullAuditedBasicEntitys, IEntity
///
[SugarColumn(ColumnName = "TrackTimeName")]
public string TrackTimeName { get; set; }
+
+ ///
+ /// 订单数组路径
+ ///
+ [SugarColumn(ColumnName = "OrderArrayPath")]
+ public string OrderArrayPath { get; set; }
+
+ ///
+ /// 轨迹明细数组路径
+ ///
+ [SugarColumn(ColumnName = "TrackDetailsArrayPath")]
+ public string TrackDetailsArrayPath { get; set; }
}
\ No newline at end of file
From 4d2850077b3538834bd0cff3d7c01dd1b0aa8174 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Sat, 9 Mar 2024 10:28:27 +0800
Subject: [PATCH 04/49] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BD=A8=E8=BF=B9?=
=?UTF-8?q?=E6=8B=89=E5=8F=96=E9=85=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dtos/TrackPull/EditTrackPullConfigInput.cs | 10 ++++++++++
.../TrackPull/EditTrackPullConfigInputValidation.cs | 4 ++++
.../Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs | 10 ++++++++++
3 files changed, 24 insertions(+)
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs
index a53c49b3..022a6183 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs
@@ -63,4 +63,14 @@ public class EditTrackPullConfigInput
/// 拉取轨迹发生时间
///
public string? TrackTimeName { get; set; }
+
+ ///
+ /// 订单数组路径
+ ///
+ public string? OrderArrayPath { get; set; }
+
+ ///
+ /// 轨迹明细数组路径
+ ///
+ public string? TrackDetailsArrayPath { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs b/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs
index e54d9279..0a4a881c 100644
--- a/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs
+++ b/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs
@@ -42,6 +42,10 @@ public class EditTrackPullConfigInputValidation : AbstractValidator x.OrderNoName).NotEmpty().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotEmpty, nameof(EditTrackPullConfigInput.OrderNoName)]);
+ RuleFor(x => x.OrderArrayPath).NotEmpty().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotEmpty, nameof(EditTrackPullConfigInput.OrderArrayPath)]);
+
+ RuleFor(x => x.TrackDetailsArrayPath).NotEmpty().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotEmpty, nameof(EditTrackPullConfigInput.TrackDetailsArrayPath)]);
+
When(x => x.ParseMethod == 1, () =>
{
RuleFor(x => x.TackTimeZoneName).NotEmpty().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotEmpty, nameof(EditTrackPullConfigInput.TackTimeZoneName)]);
diff --git a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs
index 2d917ce0..ba98d780 100644
--- a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs
@@ -68,4 +68,14 @@ public class GetTrackPullConfigDetailOutputVO
/// 拉取轨迹发生时间
///
public string TrackTimeName { get; set; }
+
+ ///
+ /// 订单数组路径
+ ///
+ public string OrderArrayPath { get; set; }
+
+ ///
+ /// 轨迹明细数组路径
+ ///
+ public string TrackDetailsArrayPath { get; set; }
}
\ No newline at end of file
From 0e8af9275673a3a59c2ae6009676ba2ca2410bbf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Sat, 9 Mar 2024 15:16:32 +0800
Subject: [PATCH 05/49] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=97=E6=AE=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dtos/TrackPull/EditTrackPullConfigInput.cs | 8 ++++----
.../TrackPull/EditTrackPullConfigInputValidation.cs | 4 ++--
.../TrackPushPullParamsConfigEntity.cs | 12 ++++++------
.../TrackPull/GetTrackPullConfigDetailOutputVO.cs | 8 ++++----
4 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs
index 022a6183..10f5c720 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs
@@ -65,12 +65,12 @@ public class EditTrackPullConfigInput
public string? TrackTimeName { get; set; }
///
- /// 订单数组路径
+ /// 订单路径
///
- public string? OrderArrayPath { get; set; }
+ public string? OrderPath { get; set; }
///
- /// 轨迹明细数组路径
+ /// 轨迹明细路径
///
- public string? TrackDetailsArrayPath { get; set; }
+ public string? TrackDetailsPath { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs b/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs
index 0a4a881c..988f801b 100644
--- a/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs
+++ b/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs
@@ -42,9 +42,9 @@ public class EditTrackPullConfigInputValidation : AbstractValidator x.OrderNoName).NotEmpty().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotEmpty, nameof(EditTrackPullConfigInput.OrderNoName)]);
- RuleFor(x => x.OrderArrayPath).NotEmpty().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotEmpty, nameof(EditTrackPullConfigInput.OrderArrayPath)]);
+ RuleFor(x => x.OrderPath).NotEmpty().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotEmpty, nameof(EditTrackPullConfigInput.OrderPath)]);
- RuleFor(x => x.TrackDetailsArrayPath).NotEmpty().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotEmpty, nameof(EditTrackPullConfigInput.TrackDetailsArrayPath)]);
+ RuleFor(x => x.TrackDetailsPath).NotEmpty().WithMessage(stringLocalizer[SjzyBasicLocalization.Validation_NotEmpty, nameof(EditTrackPullConfigInput.TrackDetailsPath)]);
When(x => x.ParseMethod == 1, () =>
{
diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPushPullParamsConfigEntity.cs b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPushPullParamsConfigEntity.cs
index 85495ade..785f9979 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPushPullParamsConfigEntity.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPushPullParamsConfigEntity.cs
@@ -79,14 +79,14 @@ public class TrackPushPullParamsConfigEntity : IFullAuditedBasicEntitys, IEntity
public string TrackTimeName { get; set; }
///
- /// 订单数组路径
+ /// 订单路径
///
- [SugarColumn(ColumnName = "OrderArrayPath")]
- public string OrderArrayPath { get; set; }
+ [SugarColumn(ColumnName = "OrderPath")]
+ public string OrderPath { get; set; }
///
- /// 轨迹明细数组路径
+ /// 轨迹明细路径
///
- [SugarColumn(ColumnName = "TrackDetailsArrayPath")]
- public string TrackDetailsArrayPath { get; set; }
+ [SugarColumn(ColumnName = "TrackDetailsPath")]
+ public string TrackDetailsPath { get; set; }
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs
index ba98d780..c8b3934d 100644
--- a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs
@@ -70,12 +70,12 @@ public class GetTrackPullConfigDetailOutputVO
public string TrackTimeName { get; set; }
///
- /// 订单数组路径
+ /// 订单路径
///
- public string OrderArrayPath { get; set; }
+ public string OrderPath { get; set; }
///
- /// 轨迹明细数组路径
+ /// 轨迹明细路径
///
- public string TrackDetailsArrayPath { get; set; }
+ public string TrackDetailsPath { get; set; }
}
\ No newline at end of file
From e17eb425a4570c9064840fe63cedc2fa9d474083 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Sat, 9 Mar 2024 16:15:04 +0800
Subject: [PATCH 06/49] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dtos/TrackPull/TrackPullConfigDto.cs | 8 ++
.../TrackPull/TrackPullContentConfigDto.cs} | 22 ++---
.../Dtos/TrackPull/TrackPullParamConfigDto.cs | 49 ++++++++++
.../Services/ITrackPullCacheService.cs | 13 +++
.../InterfaceRelayTrackRefreshEventHandler.cs | 35 -------
.../EventHandlers/TrackRefreshEventHandler.cs | 95 +++++++++++++++++++
.../EventHandlers/TrackUpsertEventHandler.cs | 1 +
.../Services/ProvideServices/OrderService.cs | 8 +-
.../ProvideServices/TrackPullService.cs | 21 ++--
.../Dtos/Order/OrderTemplateVO.cs | 9 +-
src/SJZY.Track.Domain/GlobalConst.cs | 2 +-
.../Queries/IProvideQueries.cs | 7 --
.../Queries/ProvideQueries.cs | 19 ----
.../Repositories/OrderRepository.cs | 49 +++++-----
14 files changed, 224 insertions(+), 114 deletions(-)
create mode 100644 src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullConfigDto.cs
rename src/{SJZY.Track.Domain/Dtos/Order/TrackPullContentConfigVO.cs => SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullContentConfigDto.cs} (79%)
create mode 100644 src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs
create mode 100644 src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs
delete mode 100644 src/SJZY.Track.Application/EventHandlers/InterfaceRelayTrackRefreshEventHandler.cs
create mode 100644 src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
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..f6020d9f
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullConfigDto.cs
@@ -0,0 +1,8 @@
+namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
+
+public class TrackPullConfigDto
+{
+ public TrackPullParamConfigDto ParamConfig { get; set; }
+
+ public List ContentConfigs { get; set; }
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Dtos/Order/TrackPullContentConfigVO.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullContentConfigDto.cs
similarity index 79%
rename from src/SJZY.Track.Domain/Dtos/Order/TrackPullContentConfigVO.cs
rename to src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullContentConfigDto.cs
index 1f82cbe6..fd0fae59 100644
--- a/src/SJZY.Track.Domain/Dtos/Order/TrackPullContentConfigVO.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullContentConfigDto.cs
@@ -1,12 +1,17 @@
-namespace SJZY.Track.Domain.Dtos.Order;
+namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
-public class TrackPullContentConfigVO
+public class TrackPullContentConfigDto
{
///
- /// 轨迹内容id
+ /// 轨迹内容代码
///
- public int TrackContentId { get; set; }
-
+ public string TrackContentCode { get; set; } = null!;
+
+ ///
+ /// 服务商轨迹状态参数值
+ ///
+ 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.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs
new file mode 100644
index 00000000..37c18332
--- /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 TackTimeZoneName { get; set; } = null!;
+
+ ///
+ /// 轨迹代码参数名
+ ///
+ public string TrackContentCodeName { get; set; } = null!;
+
+ ///
+ /// 轨迹内容参数名
+ ///
+ public string TrackContentName { get; set; } = null!;
+
+ ///
+ /// 轨迹发生地参数名
+ ///
+ public string TrackPlaceName { get; set; } = null!;
+
+ ///
+ /// 轨迹状态参数名
+ ///
+ public string TrackStatusName { get; set; } = null!;
+
+ ///
+ /// 轨迹发生时间参数名
+ ///
+ public string TrackTimeName { get; set; } = null!;
+
+ ///
+ /// 订单数组路径
+ ///
+ 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/Services/ITrackPullCacheService.cs b/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs
new file mode 100644
index 00000000..3ff68a49
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs
@@ -0,0 +1,13 @@
+using SJZY.Track.Application.Contract.Dtos.TrackPull;
+
+namespace SJZY.Track.Application.Contract.Services;
+
+public interface ITrackPullCacheService
+{
+ ///
+ /// 获取服务商拉取配置
+ ///
+ ///
+ ///
+ Task GetPullConfigAsync(int serviceProviderId);
+}
\ 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/TrackRefreshEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
new file mode 100644
index 00000000..5d2187cb
--- /dev/null
+++ b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
@@ -0,0 +1,95 @@
+using DotNetCore.CAP;
+using Newtonsoft.Json.Linq;
+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 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(InterfaceRelayTrackRefreshEvent @event)
+ {
+ // tips:attach返回的是服务商id,必有
+ var attach = JObject.Parse(@event.Attach);
+ var serviceProviderId = attach["ServiceProviderId"]!.Value();
+ var orderType = attach["OrderType"]!.Value();
+ var config = await _trackPullCacheService.GetPullConfigAsync(serviceProviderId);
+
+ var data = JObject.FromObject(@event.Data)["Data"]!;
+ var orderToken = data[config.ParamConfig.OrderPath];
+ if (orderToken is JArray orderTokens)
+ {
+ foreach (var token in orderTokens)
+ {
+ await HandleOrderAsync(token, config, orderType);
+ }
+ }
+ else if (orderToken is JObject)
+ {
+ await HandleOrderAsync(orderToken, config, orderType);
+ }
+ }
+
+ private async Task HandleOrderAsync(JToken token, TrackPullConfigDto config, int orderType)
+ {
+ var paramConfig = config.ParamConfig;
+ var orderNo = token[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.IsPushCompleted, x.CustomId
+ });
+ if (order == default) return;
+
+ var trackToken = token[paramConfig.TrackDetailsPath];
+ if (trackToken is null) return;
+ var trackUpsertEvent = new TrackUpsertEvent
+ {
+ OrderId = order.Id,
+ SubSystemId = order.SubSystemId,
+ IsPushCompleted = order.IsPushCompleted,
+ CustomId = order.CustomId,
+ OrderType = orderType,
+ OrderNo = orderNo!,
+ };
+
+ if (trackToken is JArray trackTokens)
+ {
+ foreach (var item in trackTokens)
+ {
+ await HandleTrackAsync(item, config, trackUpsertEvent);
+ }
+ }
+ }
+
+ private async Task HandleTrackAsync(JToken token, TrackPullConfigDto config,
+ TrackUpsertEvent trackUpsertEvent)
+ {
+ // 新增/更新轨迹
+ trackUpsertEvent.TrackCode = null;
+ trackUpsertEvent.TrackPlace = null;
+ trackUpsertEvent.TrackTime = null;
+ trackUpsertEvent.TrackTimeZone = null;
+ trackUpsertEvent.UpSubSystemId = 0;
+ 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 db60129a..5784d125 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs
@@ -88,6 +88,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
TrackStatus = trackContent.Status,
TrackCode = @event.TrackCode,
TrackContent = trackContent.Content,
+
TrackEnContent = trackContent.EnContent,
TrackPlace = @event.TrackPlace,
TrackTime = @event.TrackTime!.Value,
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
index a021cd41..1de07174 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
@@ -1,7 +1,5 @@
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
using SJZY.Track.Domain.Aggregates.OrderAggregate;
-using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
-using SJZY.Track.Domain.Dtos.Order;
using SJZY.UserCenter.HttpApi.Services;
namespace SJZY.Track.Application.Services.ProvideServices;
@@ -14,14 +12,10 @@ namespace SJZY.Track.Application.Services.ProvideServices;
public class OrderService : ApplicationService
{
private readonly IOrderRepository _orderRepository;
- private readonly ITrackDetailsRepository _trackDetailsRepository;
- public OrderService(IOrderRepository orderRepository,
- ITrackDetailsRepository trackDetailsRepository
- )
+ public OrderService(IOrderRepository orderRepository)
{
_orderRepository = orderRepository;
- _trackDetailsRepository = trackDetailsRepository;
}
///
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
index 53cdfd57..840ccba7 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
@@ -1,4 +1,5 @@
-using SJZY.InterfaceRelay.Application.Contracts;
+using Newtonsoft.Json;
+using SJZY.InterfaceRelay.Application.Contracts;
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
using SJZY.Track.Domain.Aggregates.OrderAggregate;
using Volo.Abp.Http.Client.DynamicProxying;
@@ -39,19 +40,21 @@ public class TrackPullService : ApplicationService
var orderTemplates = await _orderRepository.GetOrderTemplatesAsync(input.OrderNos);
- foreach (var group in orderTemplates.GroupBy(x => x.ServiceProviderId))
+ foreach (var group in orderTemplates.GroupBy(x => new
+ {
+ x.ServiceProviderId, x.OrderType, x.ServiceProviderCode
+ }))
{
- var data = group.Select(x => new OrderNoInfo
+ var data = group.Select(x => new
{
- OrderType = x.OrderType,
- OrderNo = x.OrderNo
+ x.OrderNo
}).ToList();
-
+
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
- "A012", "yicang", 42, data, GlobalConst.InterfaceRelayTrackRefreshSubscribe
- , group.Key.ToString());
+ "A012", group.Key.ServiceProviderCode, 42, data,
+ GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
}
-
+
return true;
}
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs b/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs
index 9360db40..723ed89e 100644
--- a/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs
@@ -8,8 +8,13 @@ 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!;
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/GlobalConst.cs b/src/SJZY.Track.Domain/GlobalConst.cs
index 78fdd6a8..2768048e 100644
--- a/src/SJZY.Track.Domain/GlobalConst.cs
+++ b/src/SJZY.Track.Domain/GlobalConst.cs
@@ -20,7 +20,7 @@ public class GlobalConst
///
/// 接口通批量轨迹刷新 mq订阅名称
///
- public const string InterfaceRelayTrackRefreshSubscribe = "SJZY.Track.TrackRefresh";
+ public const string TrackRefreshSubscribe = "SJZY.Track.TrackRefresh";
///
/// 轨迹新增/更新后触发更新订单轨迹 mq订阅名称
diff --git a/src/SJZY.Track.Domain/Queries/IProvideQueries.cs b/src/SJZY.Track.Domain/Queries/IProvideQueries.cs
index 710cb3f4..a3f8450c 100644
--- a/src/SJZY.Track.Domain/Queries/IProvideQueries.cs
+++ b/src/SJZY.Track.Domain/Queries/IProvideQueries.cs
@@ -48,11 +48,4 @@ public interface IProvideQueries
///
///
Task> MapTrackCodesAsync(int upSubSystemId, int subSystemId, params string[] trackCodes);
-
- ///
- /// 获取服务商模板配置
- ///
- ///
- ///
- Task> GetPullContentConfigsAsync(int serviceProviderId);
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Repository/Queries/ProvideQueries.cs b/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
index 78639986..a84a28f5 100644
--- a/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
+++ b/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
@@ -1,6 +1,5 @@
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;
@@ -105,22 +104,4 @@ public class ProvideQueries : ISugarRepository, IProvideQueries,
.Select(x => x.TrackContentCode)
.ToListAsync();
}
-
- public async Task> GetPullContentConfigsAsync(int serviceProviderId)
- {
- return await Context.Queryable()
- .LeftJoin((a, b) => a.Id == b.TrackPullConfigId)
- .Where(a => a.ServiceProviderId == serviceProviderId)
- .Select(x => new TrackPullContentConfigVO
- {
- TrackContentId = 0,
- TrackContentCodeValue = null,
- TrackContentValue = null,
- TrackKeyword = null,
- TrackKeywordReverse = null,
- TrackPlaceValue = null,
- TrackStatusValue = null,
- TrackTimeZone = null
- }).ToListAsync();
- }
}
\ 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..1a7383f1 100644
--- a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
@@ -14,9 +14,9 @@ public class OrderRepository : BasicRepository, IOrderRepository, I
public OrderRepository(
ITrackDetailsRepository trackDetailsRepository
- )
+ )
{
- this._trackDetailsRepository=trackDetailsRepository;
+ this._trackDetailsRepository = trackDetailsRepository;
}
public async Task CreateOrderAsync(OrderEntity order)
@@ -172,44 +172,45 @@ public class OrderRepository : BasicRepository, IOrderRepository, I
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();
+ .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 esDetails = esTrackDetails?.Where(b => b.OrderId == a.Id).OrderByDescending(b => b.TrackTime);
var trackDetail = esDetails?.FirstOrDefault();
- if (trackDetail!=null)
+ if (trackDetail != null)
{
- if (trackDetail.TrackContent!=a.NewestTrackContent)
+ if (trackDetail.TrackContent != a.NewestTrackContent)
{
- a.NewestTrackContent=trackDetail.TrackContent;
+ a.NewestTrackContent = trackDetail.TrackContent;
}
- if (trackDetail.TrackEnContent!=a.NewestTrackEnContent)
+
+ if (trackDetail.TrackEnContent != a.NewestTrackEnContent)
{
- a.NewestTrackEnContent=trackDetail.TrackEnContent;
+ a.NewestTrackEnContent = trackDetail.TrackEnContent;
}
- if (trackDetail.TrackPlace!=a.NewestTrackPlace)
+
+ if (trackDetail.TrackPlace != a.NewestTrackPlace)
{
- a.NewestTrackPlace=trackDetail.TrackPlace;
+ a.NewestTrackPlace = trackDetail.TrackPlace;
}
- if (trackDetail.TrackTime!= a.NewestTrackTime)
+
+ if (trackDetail.TrackTime != a.NewestTrackTime)
{
- a.NewestTrackTime=trackDetail.TrackTime;
+ 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();
+ 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())
@@ -243,13 +244,15 @@ public class OrderRepository : BasicRepository, IOrderRepository, I
{
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) => new OrderTemplateVO
+ .Select((a, b, c) => new OrderTemplateVO
{
OrderNo = a.OrderNo,
OrderType = a.OrderType,
TemplateId = b.TrackTemplateId,
- ServiceProviderId = b.ServiceProviderId
+ ServiceProviderId = b.ServiceProviderId,
+ ServiceProviderCode = c.Code
})
.ToListAsync();
}
From 3baf9aea8b42b5c13a2927f09e9b62b72535cdd6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Sat, 9 Mar 2024 17:31:21 +0800
Subject: [PATCH 07/49] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=9C=8D=E5=8A=A1?=
=?UTF-8?q?=E5=95=86=E6=8B=89=E5=8F=96=E9=85=8D=E7=BD=AE=E6=B7=BB=E5=8A=A0?=
=?UTF-8?q?=E5=AD=90=E7=B3=BB=E7=BB=9F=E5=85=A5=E5=8F=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/ITrackPullCacheService.cs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs b/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs
index 3ff68a49..24a9ecb5 100644
--- a/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs
+++ b/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs
@@ -7,7 +7,8 @@ public interface ITrackPullCacheService
///
/// 获取服务商拉取配置
///
- ///
+ /// 子系统id
+ /// 服务商id
///
- Task GetPullConfigAsync(int serviceProviderId);
+ Task GetPullConfigAsync(int subSystemId, int serviceProviderId);
}
\ No newline at end of file
From 9ae2a8335a6b5a5e47a88c2fd9ee898820161c5d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Sat, 9 Mar 2024 18:08:42 +0800
Subject: [PATCH 08/49] =?UTF-8?q?=E8=BD=A8=E8=BF=B9=E5=88=B7=E6=96=B0?=
=?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=AE=8C=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../TrackPull/TrackPullContentConfigDto.cs | 4 +-
.../Dtos/TrackPull/TrackPullParamConfigDto.cs | 5 +
.../Dtos/TrackPull/TrackRefreshAttach.cs | 32 ++++++
.../EventHandlers/TrackRefreshEventHandler.cs | 100 ++++++++++++++----
.../ProvideServices/TrackPullService.cs | 7 +-
.../Dtos/Order/OrderTemplateVO.cs | 5 +
.../Enums/TrackLocationValue.cs | 11 ++
.../Repositories/OrderRepository.cs | 3 +-
.../Repositories/TrackDetailsRepository.cs | 4 +-
9 files changed, 145 insertions(+), 26 deletions(-)
create mode 100644 src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackRefreshAttach.cs
create mode 100644 src/SJZY.Track.Domain/Enums/TrackLocationValue.cs
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullContentConfigDto.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullContentConfigDto.cs
index fd0fae59..cab541f3 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullContentConfigDto.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullContentConfigDto.cs
@@ -38,7 +38,7 @@ public class TrackPullContentConfigDto
public int? TrackPlaceValue { get; set; }
///
- /// 轨迹时区GMT
+ /// 轨迹时区GMT值
///
- public float? TrackTimeZone { get; set; }
+ 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
index 37c18332..39de6d21 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs
@@ -37,6 +37,11 @@ public class TrackPullParamConfigDto
///
public string TrackTimeName { get; set; } = null!;
+ ///
+ /// 轨迹发生时间参数名
+ ///
+ public string TrackTimeZoneName { get; set; } = null!;
+
///
/// 订单数组路径
///
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackRefreshAttach.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackRefreshAttach.cs
new file mode 100644
index 00000000..ae47f35a
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackRefreshAttach.cs
@@ -0,0 +1,32 @@
+namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
+
+public class TrackRefreshAttach
+{
+ public TrackRefreshAttach(int serviceProviderId, string serviceProviderCode, int subSystemId, int orderType)
+ {
+ ServiceProviderId = serviceProviderId;
+ ServiceProviderCode = serviceProviderCode;
+ SubSystemId = subSystemId;
+ OrderType = orderType;
+ }
+
+ ///
+ /// 服务商id
+ ///
+ public int ServiceProviderId { get; set; }
+
+ ///
+ /// 服务商code
+ ///
+ public string ServiceProviderCode { get; set; }
+
+ ///
+ /// 订单类型(主数据枚举TrackOrderType)
+ ///
+ public int OrderType { get; set; }
+
+ ///
+ /// 子系统id
+ ///
+ public int SubSystemId { get; set; }
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
index 5d2187cb..50cabb23 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
@@ -1,10 +1,14 @@
-using DotNetCore.CAP;
+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;
@@ -27,30 +31,29 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
public async Task ConsumerAsync(InterfaceRelayTrackRefreshEvent @event)
{
// tips:attach返回的是服务商id,必有
- var attach = JObject.Parse(@event.Attach);
- var serviceProviderId = attach["ServiceProviderId"]!.Value();
- var orderType = attach["OrderType"]!.Value();
- var config = await _trackPullCacheService.GetPullConfigAsync(serviceProviderId);
+ var attach = JsonConvert.DeserializeObject(@event.Attach);
+ if (attach is null) return;
+ var config = await _trackPullCacheService.GetPullConfigAsync(attach.ServiceProviderId, attach.SubSystemId);
- var data = JObject.FromObject(@event.Data)["Data"]!;
+ var data = JObject.FromObject(@event.Data);
var orderToken = data[config.ParamConfig.OrderPath];
if (orderToken is JArray orderTokens)
{
foreach (var token in orderTokens)
{
- await HandleOrderAsync(token, config, orderType);
+ await HandleOrderAsync(token, config, attach.OrderType);
}
}
else if (orderToken is JObject)
{
- await HandleOrderAsync(orderToken, config, orderType);
+ await HandleOrderAsync(orderToken, config, attach.OrderType);
}
}
- private async Task HandleOrderAsync(JToken token, TrackPullConfigDto config, int orderType)
+ private async Task HandleOrderAsync(JToken orderToken, TrackPullConfigDto config, int orderType)
{
var paramConfig = config.ParamConfig;
- var orderNo = token[paramConfig.OrderNoName]?.Value();
+ var orderNo = orderToken[paramConfig.OrderNoName]?.Value();
if (orderNo.IsNullOrWhiteSpace()) return;
var order = await _orderRepository.GetFirstAsync(x =>
@@ -60,7 +63,7 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
});
if (order == default) return;
- var trackToken = token[paramConfig.TrackDetailsPath];
+ var trackToken = orderToken[paramConfig.TrackDetailsPath];
if (trackToken is null) return;
var trackUpsertEvent = new TrackUpsertEvent
{
@@ -79,17 +82,78 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
await HandleTrackAsync(item, config, trackUpsertEvent);
}
}
+ else if (orderToken is JObject)
+ {
+ await HandleTrackAsync(orderToken, config, trackUpsertEvent);
+ }
}
- private async Task HandleTrackAsync(JToken token, TrackPullConfigDto config,
- TrackUpsertEvent trackUpsertEvent)
+ private async Task HandleTrackAsync(JToken trackToken, TrackPullConfigDto config,
+ TrackUpsertEvent @event)
{
+ var trackUpsertEvent = @event.DeepCopy();
+ var paramConfig = config.ParamConfig;
+ var contentConfigs = config.ContentConfigs;
+ TrackPullContentConfigDto? trackContent = null;
+
+ // 1、匹配轨迹代码
+ var serviceProviderTrackCode = trackToken[paramConfig.TrackContentCodeName]?.Value();
+ if (!serviceProviderTrackCode.IsNullOrWhiteSpace())
+ {
+ trackContent = contentConfigs.FirstOrDefault(x => x.TrackContentCodeValue == serviceProviderTrackCode);
+ }
+
+ // 2、匹配轨迹状态
+ if (trackContent is null)
+ {
+ var serviceProviderTrackStatus = trackToken[paramConfig.TrackStatusName]?.Value();
+ if (!serviceProviderTrackStatus.IsNullOrWhiteSpace())
+ {
+ trackContent = contentConfigs.FirstOrDefault(x => x.TrackStatusValue == serviceProviderTrackCode);
+ }
+ }
+
+ // 3、匹配轨迹内容
+ if (trackContent is null)
+ {
+ var serviceProviderTrackContent = trackToken[paramConfig.TrackContentName]?.Value();
+ if (!serviceProviderTrackContent.IsNullOrWhiteSpace())
+ {
+ trackContent = contentConfigs.FirstOrDefault(x => x.TrackContentValue == serviceProviderTrackCode);
+
+ // 3.1、按关键字匹配
+ if (trackContent is null)
+ {
+ }
+ }
+ }
+
+ if (trackContent is null) return;
+
+ var trackPlace = trackToken[paramConfig.TrackPlaceName]?.Value();
+ if (trackPlace.IsNullOrWhiteSpace())
+ {
+ Expression> resultExpression =
+ (TrackLocationValue?)trackContent.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);
+ }
+
// 新增/更新轨迹
- trackUpsertEvent.TrackCode = null;
- trackUpsertEvent.TrackPlace = null;
- trackUpsertEvent.TrackTime = null;
- trackUpsertEvent.TrackTimeZone = null;
- trackUpsertEvent.UpSubSystemId = 0;
+ trackUpsertEvent.TrackCode = trackContent.TrackContentCode;
+ trackUpsertEvent.TrackPlace = trackPlace ?? "CN";
+ trackUpsertEvent.TrackTime = trackToken[paramConfig.TrackTimeName]?.Value() ?? DateTime.Now;
+ trackUpsertEvent.TrackTimeZone = trackToken[paramConfig.TrackTimeZoneName]?.Value() ??
+ trackContent.TrackTimeZoneValue ?? 8;
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, trackUpsertEvent);
}
}
\ 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 840ccba7..95a2d573 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
@@ -1,6 +1,7 @@
using Newtonsoft.Json;
using SJZY.InterfaceRelay.Application.Contracts;
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
+using SJZY.Track.Application.Contract.Dtos.TrackPull;
using SJZY.Track.Domain.Aggregates.OrderAggregate;
using Volo.Abp.Http.Client.DynamicProxying;
@@ -40,10 +41,8 @@ public class TrackPullService : ApplicationService
var orderTemplates = await _orderRepository.GetOrderTemplatesAsync(input.OrderNos);
- foreach (var group in orderTemplates.GroupBy(x => new
- {
- x.ServiceProviderId, x.OrderType, x.ServiceProviderCode
- }))
+ foreach (var group in orderTemplates.GroupBy(x =>
+ new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId, x.OrderType)))
{
var data = group.Select(x => new
{
diff --git a/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs b/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs
index 723ed89e..6fe7d2b5 100644
--- a/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs
@@ -17,4 +17,9 @@ public class OrderTemplateVO
/// 服务商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/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.Repository/Repositories/OrderRepository.cs b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
index 1a7383f1..be9cc648 100644
--- a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
@@ -252,7 +252,8 @@ public class OrderRepository : BasicRepository, IOrderRepository, I
OrderType = a.OrderType,
TemplateId = b.TrackTemplateId,
ServiceProviderId = b.ServiceProviderId,
- ServiceProviderCode = c.Code
+ ServiceProviderCode = c.Code,
+ SubSystemId = a.SubSystemId
})
.ToListAsync();
}
diff --git a/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
index da6f784a..e6aae4f0 100644
--- a/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
@@ -1,3 +1,4 @@
+using Elasticsearch.Net;
using Nest;
using SJZY.Expand.ABP.Core.Logger;
using SJZY.Expand.ElasticSearch.Services;
@@ -38,7 +39,8 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract request
- .Index(index.IndexName)
+ .Index(index.IndexName)
+ .Refresh(Refresh.True) // 可选:立即刷新索引使更改立即可见
);
if (!r.IsValid)
From 88aba1edb874176a2ad01be06003c9ad1bd402ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Mon, 11 Mar 2024 09:10:03 +0800
Subject: [PATCH 09/49] =?UTF-8?q?add=E3=80=90=E8=BD=A8=E8=BF=B9=E4=B8=AD?=
=?UTF-8?q?=E5=BF=83=E5=AF=B9=E5=A4=96=E6=8E=A5=E5=8F=A3=E6=8F=90=E4=BE=9B?=
=?UTF-8?q?--=E6=96=B0=E5=A2=9E=E8=BD=A8=E8=BF=B9/=E6=9B=B4=E6=96=B0?=
=?UTF-8?q?=E8=BD=A8=E8=BF=B9=E8=AE=A2=E5=8D=95=E3=80=91https://www.tapd.c?=
=?UTF-8?q?n/60863849/prong/tasks/view/1160863849001016386?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../SJZY.Track.Application.Contract.csproj | 2 +-
.../Services/IOrderService.cs | 14 ++++++++++++++
.../Services/ProvideServices/OrderService.cs | 3 ++-
3 files changed, 17 insertions(+), 2 deletions(-)
create mode 100644 src/SJZY.Track.Application.Contract/Services/IOrderService.cs
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..0a863be2 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,7 @@
net7.0
- 0.0.2
+ 1.0.0
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..eb14b092
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Services/IOrderService.cs
@@ -0,0 +1,14 @@
+using SJZY.Track.Application.Contract.Dtos.ProvideServices;
+using Volo.Abp;
+
+namespace SJZY.Track.Application.Contract.Services;
+
+public interface IOrderService : IRemoteService
+{
+ ///
+ /// 创建订单,订单已存在则视为更新
+ ///
+ ///
+ ///
+ Task UpsertAsync(UpsertOrderInput input);
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
index 1de07174..3d639bb0 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
@@ -1,4 +1,5 @@
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
+using SJZY.Track.Application.Contract.Services;
using SJZY.Track.Domain.Aggregates.OrderAggregate;
using SJZY.UserCenter.HttpApi.Services;
@@ -9,7 +10,7 @@ namespace SJZY.Track.Application.Services.ProvideServices;
///
[ApiExplorerSettings(GroupName = "提供接口")]
[Route("/ProviderService")]
-public class OrderService : ApplicationService
+public class OrderService : ApplicationService, IOrderService
{
private readonly IOrderRepository _orderRepository;
From edf9704ffe1c6a138a083a8e6a32801e80c91437 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Mon, 11 Mar 2024 09:46:17 +0800
Subject: [PATCH 10/49] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=82=E6=95=B0?=
=?UTF-8?q?=E8=A1=A8=E5=AD=97=E6=AE=B5=EF=BC=9B=E6=B7=BB=E5=8A=A0=E6=8B=89?=
=?UTF-8?q?=E5=8E=BB=E9=85=8D=E7=BD=AE=E7=BC=93=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../TrackPull/EditTrackPullConfigInput.cs | 2 +-
.../Dtos/TrackPull/TrackPullParamConfigDto.cs | 7 +--
.../TrackPush/EditTrackPushConfigInput.cs | 2 +-
.../Services/ITrackPullCacheService.cs | 9 ++++
.../AutoMapper/TrackPullAutoMapperProfile.cs | 3 ++
.../TrackPull/TrackPullCacheService.cs | 53 +++++++++++++++++++
.../Services/TrackPull/TrackPullService.cs | 20 ++++---
.../EditTrackPullConfigInputValidation.cs | 2 +-
.../ITrackPullConfigRepository.cs | 7 +++
.../TrackPushPullParamsConfigEntity.cs | 4 +-
.../GetTrackPullConfigDetailOutputVO.cs | 2 +-
.../GetTrackPullContentListCacheVO.cs | 44 +++++++++++++++
.../GetTrackPushConfigDetailOutputVO.cs | 2 +-
src/SJZY.Track.Domain/GlobalConst.cs | 5 ++
.../Repositories/TrackPullConfigRepository.cs | 17 ++++--
15 files changed, 157 insertions(+), 22 deletions(-)
create mode 100644 src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
create mode 100644 src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentListCacheVO.cs
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs
index 10f5c720..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; }
///
/// 拉取轨迹内容代码
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs
index 39de6d21..b8f22ac1 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs
@@ -10,7 +10,7 @@ public class TrackPullParamConfigDto
///
/// 轨迹时区参数名
///
- public string TackTimeZoneName { get; set; } = null!;
+ public string TrackTimeZoneName { get; set; } = null!;
///
/// 轨迹代码参数名
@@ -37,11 +37,6 @@ public class TrackPullParamConfigDto
///
public string TrackTimeName { get; set; } = null!;
- ///
- /// 轨迹发生时间参数名
- ///
- public string TrackTimeZoneName { get; set; } = null!;
-
///
/// 订单数组路径
///
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs
index ebd8e0be..20473d85 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs
@@ -42,7 +42,7 @@ public class EditTrackPushConfigInput
///
/// 推送轨迹时区
///
- public string? TackTimeZoneName { get; set; }
+ public string? TrackTimeZoneName { get; set; }
///
/// 推送轨迹内容代码
diff --git a/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs b/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs
index 24a9ecb5..7eb93992 100644
--- a/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs
+++ b/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs
@@ -11,4 +11,13 @@ public interface ITrackPullCacheService
/// 服务商id
///
Task GetPullConfigAsync(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/AutoMapper/TrackPullAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackPullAutoMapperProfile.cs
index 02553894..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;
@@ -15,5 +16,7 @@ public class TrackPullAutoMapperProfile : Profile
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/Services/TrackPull/TrackPullCacheService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
new file mode 100644
index 00000000..0367196b
--- /dev/null
+++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
@@ -0,0 +1,53 @@
+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 System.Linq.Expressions;
+using Volo.Abp.DependencyInjection;
+
+namespace SJZY.Track.Application.Services.TrackPull;
+
+public class TrackPullCacheService : ApplicationService, ITrackPullCacheService, ITransientDependency
+{
+ private readonly ITrackPullConfigRepository _trackPullConfigRepository;
+
+ private string RedisKey(int subSystemId, int serviceProviderId) => GlobalConst.TrackPushKeyPrefix + subSystemId + ":" + serviceProviderId;
+
+ public TrackPullCacheService(ITrackPullConfigRepository trackPullConfigRepository)
+ {
+ _trackPullConfigRepository = trackPullConfigRepository;
+ }
+
+ [NonAction]
+ public async Task GetPullConfigAsync(int subSystemId, int serviceProviderId)
+ {
+ var data = await RedisHelper.Client.GetAsync(RedisKey(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 TrackPullConfigDto();
+
+ Expression> exp = x => id.HasValue ? x.Id == id : 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(RedisKey(trackPullConfigEntity.SubSystemId, trackPullConfigEntity.ServiceProviderId), data, 86400);
+
+ 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 7161b54c..90f6bbcb 100644
--- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs
@@ -3,9 +3,9 @@ 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;
@@ -22,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;
}
///
@@ -104,15 +104,19 @@ public class TrackPullService : ApplicationService, ITransientDependency
var trackPullEntity = ObjectMapper.Map(input);
var trackPullParamsEntity = ObjectMapper.Map(input);
+ 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);
ts.Complete();
}
+
+ await _trackPullCacheService.SetPullConfigAsync(id);
}
break;
@@ -132,6 +136,8 @@ public class TrackPullService : ApplicationService, ITransientDependency
ts.Complete();
}
+
+ await _trackPullCacheService.SetPullConfigAsync(input.Id);
}
break;
@@ -156,7 +162,7 @@ public class TrackPullService : ApplicationService, ITransientDependency
}
///
- /// 轨迹拉取配置内容修改
+ /// 轨迹拉取配置内容编辑
///
///
///
@@ -193,6 +199,7 @@ public class TrackPullService : ApplicationService, ITransientDependency
var entity = ObjectMapper.Map(input);
await _trackPullConfigRepository.InsertContentAsync(entity);
+ await _trackPullCacheService.SetPullConfigAsync(input.TrackPullConfigId);
break;
}
@@ -205,6 +212,7 @@ public class TrackPullService : ApplicationService, ITransientDependency
ObjectMapper.Map(input, oldTrackPullContentEntity);
await _trackPullConfigRepository.UpdateContentAsync(oldTrackPullContentEntity);
+ await _trackPullCacheService.SetPullConfigAsync(input.TrackPullConfigId);
break;
}
diff --git a/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs b/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs
index 988f801b..50beea14 100644
--- a/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs
+++ b/src/SJZY.Track.Application/Validations/TrackPull/EditTrackPullConfigInputValidation.cs
@@ -48,7 +48,7 @@ public class EditTrackPullConfigInputValidation : AbstractValidator 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.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs
index 606f813f..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);
+
///
/// 轨迹拉取配置详情
///
diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPushPullParamsConfigEntity.cs b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/TrackPushPullParamsConfigEntity.cs
index 785f9979..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; }
///
/// 轨迹代码参数名
diff --git a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs
index c8b3934d..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; }
///
/// 拉取轨迹内容代码
diff --git a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentListCacheVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentListCacheVO.cs
new file mode 100644
index 00000000..1551647d
--- /dev/null
+++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentListCacheVO.cs
@@ -0,0 +1,44 @@
+namespace SJZY.Track.Domain.Dtos.TrackPull;
+
+public class GetTrackPullContentListCacheVO
+{
+ ///
+ /// 轨迹内容代码
+ ///
+ public string TrackContentCode { get; set; }
+
+ ///
+ /// 服务商轨迹状态参数值
+ ///
+ 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? 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 46bf32f8..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; }
///
/// 推送轨迹内容代码
diff --git a/src/SJZY.Track.Domain/GlobalConst.cs b/src/SJZY.Track.Domain/GlobalConst.cs
index 2768048e..27a07bb1 100644
--- a/src/SJZY.Track.Domain/GlobalConst.cs
+++ b/src/SJZY.Track.Domain/GlobalConst.cs
@@ -36,4 +36,9 @@ public class GlobalConst
/// 轨迹要推送的客户redis key前缀
///
public const string TrackPushKeyPrefix = "TrackPush:";
+
+ ///
+ /// 轨迹拉取配置信息redis key前缀
+ ///
+ public const string TrackPullConfigInfoKeyPrefix = "TrackPullConfigInfo:";
}
\ 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 23061501..5f71c4c2 100644
--- a/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs
@@ -36,11 +36,10 @@ public class TrackPullConfigRepository : BasicRepository,
{
return await Context.Queryable()
.InnerJoin((pullContent, trackContent) => pullContent.TrackContentId == trackContent.Id)
- .InnerJoin((pullContent, trackContent, trackPull) => pullContent.TrackPullConfigId == trackPull.Id)
- .LeftJoin((pullContent, trackContent, trackPull, enumValue) => enumValue.Property == EnumPropertyEnums.轨迹发生地.GetDescription() && pullContent.TrackPlaceValue == enumValue.Enumkey)
+ .LeftJoin((pullContent, trackContent, enumValue) => enumValue.Property == EnumPropertyEnums.轨迹发生地.GetDescription() && pullContent.TrackPlaceValue == enumValue.Enumkey)
.Where(pullContent => pullContent.TrackPullConfigId == input.TrackPullConfigId)
.OrderBy(pullContent => pullContent.CreateTime)
- .Select((pullContent, trackContent, trackPull, enumValue) => new GetTrackPullContentPageOutputVO
+ .Select((pullContent, trackContent, enumValue) => new GetTrackPullContentPageOutputVO
{
Id = pullContent.Id,
TrackPlaceValue = enumValue.Disp
@@ -48,6 +47,18 @@ public class TrackPullConfigRepository : BasicRepository,
.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()
From ba78ba46ae8e921b64e1d9e44177ae9ed3ac0bac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Mon, 11 Mar 2024 10:19:06 +0800
Subject: [PATCH 11/49] =?UTF-8?q?change=20=E6=95=B4=E5=90=88=E8=BD=A8?=
=?UTF-8?q?=E8=BF=B9=E6=9C=8D=E5=8A=A1=E3=80=81=E8=AE=A2=E5=8D=95=E6=9C=8D?=
=?UTF-8?q?=E5=8A=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/IOrderService.cs | 14 ++++++++
.../Services/ITrackService.cs | 35 +++++++++++++++++++
...derLinkService.cs => OrderService.Link.cs} | 18 +---------
.../Services/ProvideServices/OrderService.cs | 23 +++++-------
...PullService.cs => TrackPushPullService.cs} | 7 ++--
.../ProvideServices/TrackPushService.cs | 11 ------
...kQueryService.cs => TrackService.Query.cs} | 23 +-----------
.../Services/ProvideServices/TrackService.cs | 23 +++++-------
8 files changed, 71 insertions(+), 83 deletions(-)
create mode 100644 src/SJZY.Track.Application.Contract/Services/ITrackService.cs
rename src/SJZY.Track.Application/Services/ProvideServices/{OrderLinkService.cs => OrderService.Link.cs} (85%)
rename src/SJZY.Track.Application/Services/ProvideServices/{TrackPullService.cs => TrackPushPullService.cs} (90%)
delete mode 100644 src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
rename src/SJZY.Track.Application/Services/ProvideServices/{TrackQueryService.cs => TrackService.Query.cs} (80%)
diff --git a/src/SJZY.Track.Application.Contract/Services/IOrderService.cs b/src/SJZY.Track.Application.Contract/Services/IOrderService.cs
index eb14b092..0dd34413 100644
--- a/src/SJZY.Track.Application.Contract/Services/IOrderService.cs
+++ b/src/SJZY.Track.Application.Contract/Services/IOrderService.cs
@@ -11,4 +11,18 @@ 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/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/Services/ProvideServices/OrderLinkService.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs
similarity index 85%
rename from src/SJZY.Track.Application/Services/ProvideServices/OrderLinkService.cs
rename to src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs
index 56741efe..5c35b728 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/OrderLinkService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs
@@ -9,27 +9,11 @@ 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;
private readonly ICapPublisher _capPublisher;
- public OrderLinkService(IBasicQuery orderLinkQuery, IOrderRepository orderRepository,
- ICapPublisher capPublisher)
- {
- _orderLinkQuery = orderLinkQuery;
- _orderRepository = orderRepository;
- _capPublisher = 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 3d639bb0..5c56337d 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
@@ -1,6 +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.Queries;
using SJZY.UserCenter.HttpApi.Services;
namespace SJZY.Track.Application.Services.ProvideServices;
@@ -10,21 +12,18 @@ namespace SJZY.Track.Application.Services.ProvideServices;
///
[ApiExplorerSettings(GroupName = "提供接口")]
[Route("/ProviderService")]
-public class OrderService : ApplicationService, IOrderService
+public partial class OrderService : ApplicationService, IOrderService
{
private readonly IOrderRepository _orderRepository;
- public OrderService(IOrderRepository orderRepository)
+ public OrderService(IOrderRepository orderRepository, IBasicQuery orderLinkQuery,
+ ICapPublisher capPublisher)
{
_orderRepository = orderRepository;
+ _capPublisher = capPublisher;
+ _orderLinkQuery = orderLinkQuery;
}
- ///
- /// 创建订单,订单已存在则视为更新
- ///
- ///
- ///
- ///
[HttpPost("Order/Upsert")]
public async Task UpsertAsync(UpsertOrderInput input)
{
@@ -46,12 +45,6 @@ public class OrderService : ApplicationService, IOrderService
return "创建成功";
}
- ///
- /// 删除订单
- ///
- ///
- ///
- ///
[HttpPost("Order/Delete")]
public async Task DeleteOrderAsync(DeleteOrderInput input)
{
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
similarity index 90%
rename from src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
rename to src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
index 95a2d573..66625f36 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
@@ -8,16 +8,16 @@ using Volo.Abp.Http.Client.DynamicProxying;
namespace SJZY.Track.Application.Services.ProvideServices;
///
-/// 轨迹拉取服务
+/// 轨迹推送、拉取服务
///
[ApiExplorerSettings(GroupName = "提供接口")]
[Route("/ProviderService")]
-public class TrackPullService : ApplicationService
+public class TrackPushPullService : ApplicationService
{
private readonly IOrderRepository _orderRepository;
private readonly IHttpClientProxy _httpClientProxy;
- public TrackPullService(IOrderRepository orderRepository,
+ public TrackPushPullService(IOrderRepository orderRepository,
IHttpClientProxy httpClientProxy)
{
_orderRepository = orderRepository;
@@ -49,6 +49,7 @@ public class TrackPullService : ApplicationService
x.OrderNo
}).ToList();
+ // 批量获取轨迹
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
"A012", group.Key.ServiceProviderCode, 42, data,
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
deleted file mode 100644
index f2b5320f..00000000
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace SJZY.Track.Application.Services.ProvideServices;
-
-///
-/// 轨迹推送服务
-///
-[ApiExplorerSettings(GroupName = "提供接口")]
-[Route("/ProviderService")]
-public class TrackPushService: ApplicationService
-{
-
-}
\ 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 80%
rename from src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs
rename to src/SJZY.Track.Application/Services/ProvideServices/TrackService.Query.cs
index 241d9030..372d3f01 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.Query.cs
@@ -1,36 +1,15 @@
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;
- }
-
- ///
- /// 根据订单号获取轨迹
- ///
- ///
- ///
- ///
[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 298cc2a4..7c84dbc3 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,25 +13,22 @@ 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;
}
- ///
- /// 新增/更新订单轨迹接口
- ///
- ///
- ///
- ///
[HttpPost("Track/Upsert")]
public async Task UpsertTrackAsync(UpsertTrackInput input)
{
@@ -53,12 +52,6 @@ public class TrackService : ApplicationService
return true;
}
- ///
- /// 删除轨迹
- ///
- ///
- ///
- ///
[HttpPost("Track/Delete")]
public async Task DeleteTrackAsync(DeleteTrackInput input)
{
@@ -97,7 +90,7 @@ public class TrackService : ApplicationService
}
[HttpPost("Track/BatchDelete")]
- public async Task BatchTrackAsync(BatchDeleteTrackInput input)
+ public async Task BatchDeleteTrackAsync(BatchDeleteTrackInput input)
{
var orders = await _orderRepository.GetListAsync(x =>
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo) && !x.IsPushCompleted
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 12/49] =?UTF-8?q?=E8=A7=A3=E5=86=B3swagger=E5=AD=97?=
=?UTF-8?q?=E6=AE=B5=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 13/49] =?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 14/49] =?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 15/49] =?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 16/49] =?UTF-8?q?=E6=8B=89=E5=8F=96=20=E6=8E=A8=E9=80=81?=
=?UTF-8?q?=20=E5=88=97=E8=A1=A8=E8=BF=94=E5=9B=9E=E5=AD=90=E7=B3=BB?=
=?UTF-8?q?=E7=BB=9Fid?=
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 17/49] =?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)
From 2e86b7f7ba6aa1b2e227e4a6a9fce3d0921a7f4e 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 17:28:15 +0800
Subject: [PATCH 18/49] =?UTF-8?q?change=E3=80=90=E6=9B=B4=E6=96=B0?=
=?UTF-8?q?=E8=BD=A8=E8=BF=B9=E9=9C=80=E8=A6=81=E6=9B=B4=E6=96=B0=E8=AE=A2?=
=?UTF-8?q?=E5=8D=95=E7=9A=84=E6=9C=80=E6=96=B0=E8=BD=A8=E8=BF=B9=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF=E3=80=91https://www.tapd.cn/60863849/prong/tasks/view?=
=?UTF-8?q?/1160863849001016391?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Events/UpdateOrderTrackEvent.cs | 11 +++++---
.../EventHandlers/TrackDeleteEventHandler.cs | 25 ++++++++++++++++++-
.../EventHandlers/TrackUpsertEventHandler.cs | 2 +-
.../UpdateOrderTrackEventHandler.cs | 22 ++++++++++++----
.../Aggregates/OrderAggregate/OrderEntity.cs | 20 ++++++++++-----
.../ITrackDetailsRepository.cs | 9 ++++++-
.../TrackDetailsIndex.cs | 5 ++++
src/SJZY.Track.Domain/GlobalConst.cs | 5 ++++
.../Repositories/TrackDetailsRepository.cs | 25 ++++++++++++++++++-
9 files changed, 106 insertions(+), 18 deletions(-)
diff --git a/src/SJZY.Track.Application.Contract/Events/UpdateOrderTrackEvent.cs b/src/SJZY.Track.Application.Contract/Events/UpdateOrderTrackEvent.cs
index f04cd86c..779415e2 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,7 +36,7 @@ public class UpdateOrderTrackEvent
/// 轨迹发生时间
///
public DateTime TrackTime { get; set; }
-
+
///
/// 轨迹时区
///
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackDeleteEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackDeleteEventHandler.cs
index 5fa44212..1994118d 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackDeleteEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackDeleteEventHandler.cs
@@ -56,7 +56,30 @@ 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
+ };
+ await _capPublisher.PublishAsync(GlobalConst.UpdateOrderTrackSubscribe, updateOrderEvent);
+ }
// 根据订单关联关系异步向下刷
var linkedOrders = await _orderRepository.GetLinkedOrdersAsync(@event.OrderId);
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs
index 5784d125..21ddffc0 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs
@@ -88,7 +88,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
TrackStatus = trackContent.Status,
TrackCode = @event.TrackCode,
TrackContent = trackContent.Content,
-
+ IsCompleted = orderIsCompleted,
TrackEnContent = trackContent.EnContent,
TrackPlace = @event.TrackPlace,
TrackTime = @event.TrackTime!.Value,
diff --git a/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs
index 0901b2a0..f2fca16a 100644
--- a/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs
@@ -20,16 +20,28 @@ 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)
+ {
+ // 删除全部轨迹导致的重置行为
+ order.ResetTrackInfo();
+ }
+ else if (@event.TrackTime == order.LatestTrackTime) 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.Domain/Aggregates/OrderAggregate/OrderEntity.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs
index 04432d30..69d5f706 100644
--- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs
+++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs
@@ -41,7 +41,7 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
///
[SugarColumn(ColumnName = "IsCompleted")]
public bool IsCompleted { get; set; }
-
+
///
/// 订单是否推送完成(异步维护)
///
@@ -65,7 +65,7 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
///
[SugarColumn(ColumnName = "LatestTrackTime")]
public DateTime? LatestTrackTime { get; set; }
-
+
///
/// 最新轨迹时区(异步维护)
///
@@ -114,8 +114,16 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
[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 4025579e..34cdac01 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs
@@ -19,7 +19,14 @@ public interface ITrackDetailsRepository
///
///
///
- 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..d5909320 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs
@@ -46,6 +46,11 @@ public class TrackDetailsIndex : IdBaseIndex
///
public string TrackContent { get; set; } = null!;
+ ///
+ /// 是否意味着完成
+ ///
+ public bool IsCompleted { get; set; }
+
///
/// 原轨迹内容
///
diff --git a/src/SJZY.Track.Domain/GlobalConst.cs b/src/SJZY.Track.Domain/GlobalConst.cs
index 27a07bb1..629149a8 100644
--- a/src/SJZY.Track.Domain/GlobalConst.cs
+++ b/src/SJZY.Track.Domain/GlobalConst.cs
@@ -27,6 +27,11 @@ public class GlobalConst
///
public const string UpdateOrderTrackSubscribe = "SJZY.Track.UpdateOrderTrack";
+ ///
+ /// 轨迹删除后触发更新订单轨迹 mq订阅名称
+ ///
+ public const string DeleteTrackAfterUpdateOrderSubscribe = "SJZY.Track.DeleteTrackAfterUpdateOrder";
+
///
/// 关联订单后补轨迹 mq订阅名称
///
diff --git a/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
index 99290105..8bc2739d 100644
--- a/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
@@ -110,7 +110,28 @@ 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(
@@ -122,6 +143,8 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract 0;
}
public async Task<(List list, long total)> GetListAsync(TrackDetailsQueryInput input)
From d23edffffc77a2c12b7f32c6d098de61d552c869 Mon Sep 17 00:00:00 2001
From: moyongzhen <2534173414@qq.com>
Date: Tue, 12 Mar 2024 21:13:20 +0800
Subject: [PATCH 19/49] =?UTF-8?q?=E8=BD=A8=E8=BF=B9=E8=AE=A2=E5=8D=95?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=97=AE=E9=A2=98=E7=B1=BB=E5=9E=8B=E5=AD=97?=
=?UTF-8?q?=E6=AE=B5=E5=92=8C=E9=97=AE=E9=A2=98=E6=8F=8F=E8=BF=B0=E8=BF=94?=
=?UTF-8?q?=E5=8F=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ProvideServices/GetPageTrackOrderInput.cs | 33 +++++++++++++++++++
.../ProvideServices/TrackPushPullService.cs | 4 +--
.../Aggregates/OrderAggregate/OrderEntity.cs | 12 +++++++
.../Dtos/Order/GetPageTrackOrderInputVO.cs | 29 ++++++++++++++++
.../Repositories/OrderRepository.cs | 7 +++-
5 files changed, 82 insertions(+), 3 deletions(-)
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs
index 81aa553e..64191392 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs
@@ -17,6 +17,16 @@ public class GetPageTrackOrderInput : PageInfoInput
///
public string? OrderNos { get; set; }
+ ///
+ /// tab标签类型 0 全部, 1 异常 2 预警
+ ///
+ public int TabType { get; set; }
+
+ ///
+ /// 当tab选中 0 默认不传 1 直接写死传值 [1,4] 2 传 [2,4]
+ ///
+ public List? QuestionTypeIds { get; set; }
+
///
/// 创建时间开始
///
@@ -113,5 +123,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/Services/ProvideServices/TrackPushPullService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
index 2e1dd08b..53b71e31 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
@@ -49,9 +49,9 @@ public class TrackPushPullService : ApplicationService
x.OrderNo
}).ToList();
- // 批量获取轨迹
+ // 批量获取轨迹 这里报错了,我先随便给个 写死的主体值
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
- "A012", group.Key.ServiceProviderCode, data,
+ "A012", group.Key.ServiceProviderCode, 42, data,
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
}
diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs
index 69d5f706..66f704a3 100644
--- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs
+++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs
@@ -108,6 +108,18 @@ 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; }
+
///
/// 起运港口
///
diff --git a/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs b/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
index c1b97cc5..99a8d068 100644
--- a/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
@@ -18,6 +18,15 @@ 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; }
///
/// 单号
@@ -124,5 +133,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.Repository/Repositories/OrderRepository.cs b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
index be9cc648..eeeeeb14 100644
--- a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
@@ -137,6 +137,7 @@ public class OrderRepository : BasicRepository, IOrderRepository, I
(a, b, c) => a.CreateTime >= input.CreateTimeStart)
.WhereIF((!input.CreateTimeStart.HasValue) && input.CreateTimeEnd.HasValue,
(a, b, c) => a.CreateTime <= input.CreateTimeEnd)
+ .WhereIF(input.TabType>0 && (!input.QuestionTypeIds.IsNullOrEmpty()), (a, b, c) => input.QuestionTypeIds.Contains(a.QuestionType))
.OrderByDescending((a, b, c) => a.CreateTime)
.Select((a, b, c) => new TrackOrderVO
{
@@ -148,6 +149,10 @@ public class OrderRepository : BasicRepository, IOrderRepository, I
.Return("箱/袋单").ElseIF(a.OrderType == 4).Return("FBA订单").End(""),
CustomerShortName = b.Abbreviation,
CustomerCode = b.Code,
+ 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, ","),
@@ -206,7 +211,7 @@ public class OrderRepository : BasicRepository, IOrderRepository, I
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();
+ a.TrackTemplateIds = trackTemplateList.Where(b => b.OrderId == a.Id).Where(b => b.TemplateId>0).Select(a => a.TemplateId).ToList();
});
}
From 10a68b817af4deac4a2a5bddbcdba2c227ca5303 Mon Sep 17 00:00:00 2001
From: moyongzhen <2534173414@qq.com>
Date: Tue, 12 Mar 2024 21:23:47 +0800
Subject: [PATCH 20/49] =?UTF-8?q?=E9=87=8D=E6=96=B0=E8=A7=A3=E5=86=B3?=
=?UTF-8?q?=E6=8A=A5=E9=94=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/ProvideServices/TrackPushPullService.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
index 53b71e31..8e32d1c1 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
@@ -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));
}
From 6bea8224f09417457199af70b09f2e5ced7eb63e Mon Sep 17 00:00:00 2001
From: moyongzhen <2534173414@qq.com>
Date: Wed, 13 Mar 2024 09:34:42 +0800
Subject: [PATCH 21/49] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=8F=82=E6=95=B0?=
=?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ProvideServices/GetPageTrackOrderInput.cs | 19 +++++++++++++++++--
.../Dtos/Order/GetPageTrackOrderInputVO.cs | 13 +++++++++----
.../Repositories/OrderRepository.cs | 13 ++++++++++++-
3 files changed, 38 insertions(+), 7 deletions(-)
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs
index 64191392..9bd8fcc9 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs
@@ -22,10 +22,20 @@ public class GetPageTrackOrderInput : PageInfoInput
///
public int TabType { get; set; }
+ /////
+ ///// 当tab选中 0 默认不传 1 直接写死传值 [1,4] 2 传 [2,4]
+ /////
+ //public List? QuestionTypeIds { get; set; }
+
///
- /// 当tab选中 0 默认不传 1 直接写死传值 [1,4] 2 传 [2,4]
+ /// 订单类型
///
- public List? QuestionTypeIds { get; set; }
+ public int? TrackOrderType { get; set; }
+
+ ///
+ /// 客户id
+ ///
+ public int? CustomerId { get; set; }
///
/// 创建时间开始
@@ -83,6 +93,11 @@ public class TrackOrderDto
///
public string? CustomerCode { get; set; }
+ ///
+ /// 客户id
+ ///
+ public int CustomerId { get; set; }
+
///
/// 订单明细(json)
///
diff --git a/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs b/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
index 99a8d068..b0abd5b0 100644
--- a/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
@@ -23,10 +23,10 @@ namespace SJZY.Track.Domain.Dtos.Order
///
public int TabType { get; set; }
- ///
- /// 当tab选中 1 直接写死传值 [1,4] 2 传 [2,4]
- ///
- public List? QuestionTypeIds { get; set; }
+ /////
+ ///// 当tab选中 1 直接写死传值 [1,4] 2 传 [2,4]
+ /////
+ //public List? QuestionTypeIds { get; set; }
///
/// 单号
@@ -84,6 +84,11 @@ namespace SJZY.Track.Domain.Dtos.Order
///
public string? CustomerCode { get; set; }
+ ///
+ /// 客户id
+ ///
+ public int CustomerId { get; set; }
+
/////
///// 订单明细(json)
/////
diff --git a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
index eeeeeb14..43de6ccb 100644
--- a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
@@ -5,6 +5,7 @@ using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
using SJZY.Track.Domain.Dtos.Order;
using SJZY.Track.Domain.VEntities;
using SJZY.Track.Repository.VData.Entitys;
+using SqlSugar;
namespace SJZY.Track.Repository.Repositories;
@@ -121,10 +122,19 @@ public class OrderRepository : BasicRepository, IOrderRepository, I
public async Task> GetPageTrackOrder(GetPageTrackOrderInputVO input)
{
List orderNoList = new List();
+ List questionTypeIds = new List();
if (!input.OrderNos.IsNullOrWhiteSpace())
{
orderNoList = input.OrderNos.Split(new char[] { ',', ',', ':', ':' }).ToList();
}
+ if (input.TabType==1)
+ {
+ questionTypeIds= new List { 1, 4 };
+ }
+ else if (input.TabType==2)
+ {
+ questionTypeIds= new List { 2, 4 };
+ }
var pageList = await Context.Queryable()
.LeftJoin((a, b) => a.CustomId == b.Id && b.IsDeleted == false)
@@ -137,7 +147,7 @@ public class OrderRepository : BasicRepository, IOrderRepository, I
(a, b, c) => a.CreateTime >= input.CreateTimeStart)
.WhereIF((!input.CreateTimeStart.HasValue) && input.CreateTimeEnd.HasValue,
(a, b, c) => a.CreateTime <= input.CreateTimeEnd)
- .WhereIF(input.TabType>0 && (!input.QuestionTypeIds.IsNullOrEmpty()), (a, b, c) => input.QuestionTypeIds.Contains(a.QuestionType))
+ .WhereIF(input.TabType>0 && (!questionTypeIds.IsNullOrEmpty()), (a, b, c) => questionTypeIds.Contains(a.QuestionType))
.OrderByDescending((a, b, c) => a.CreateTime)
.Select((a, b, c) => new TrackOrderVO
{
@@ -149,6 +159,7 @@ public class OrderRepository : BasicRepository, IOrderRepository, I
.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,
From f19ba6c01a3a760fefc74773f448759d5ad2a1d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Wed, 13 Mar 2024 10:08:41 +0800
Subject: [PATCH 22/49] =?UTF-8?q?add=20=E5=88=A0=E9=99=A4=E5=BC=95?=
=?UTF-8?q?=E5=8F=91=E8=BD=A8=E8=BF=B9=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../EventHandlers/UpdateOrderTrackEventHandler.cs | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs
index f2fca16a..72316cef 100644
--- a/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs
@@ -24,12 +24,15 @@ public class UpdateOrderTrackEventHandler : ITransientDependency, ICapSubscribe
{
if (@event.TrackTime == default)
{
+ if (order.LatestTrackTime == null) return;
// 删除全部轨迹导致的重置行为
order.ResetTrackInfo();
}
- else if (@event.TrackTime == order.LatestTrackTime) return;
+ else if (order.LatestTrackTime != null &&
+ order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) ==
+ @event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone))) return;
}
- else // upsert引发的更新,需要校验发生时间是否大于最新时间
+ else // upsert引发的更新
{
if (order.LatestTrackTime != null &&
order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) >
From 953bca93f54b51dcf3768ba14bfa2e37f23df645 Mon Sep 17 00:00:00 2001
From: moyongzhen <2534173414@qq.com>
Date: Wed, 13 Mar 2024 10:16:27 +0800
Subject: [PATCH 23/49] =?UTF-8?q?=E8=BD=A8=E8=BF=B9=E8=AE=A2=E5=8D=95?=
=?UTF-8?q?=E5=8F=82=E6=95=B0=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dtos/ProvideServices/GetPageTrackOrderInput.cs | 10 +++++-----
.../Dtos/Order/GetPageTrackOrderInputVO.cs | 10 ++++++++++
.../Repositories/OrderRepository.cs | 7 ++++++-
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs
index 9bd8fcc9..c6a143df 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetPageTrackOrderInput.cs
@@ -22,11 +22,6 @@ public class GetPageTrackOrderInput : PageInfoInput
///
public int TabType { get; set; }
- /////
- ///// 当tab选中 0 默认不传 1 直接写死传值 [1,4] 2 传 [2,4]
- /////
- //public List? QuestionTypeIds { get; set; }
-
///
/// 订单类型
///
@@ -37,6 +32,11 @@ public class GetPageTrackOrderInput : PageInfoInput
///
public int? CustomerId { get; set; }
+ /////
+ ///// 当tab选中 0 默认不传 1 直接写死传值 [1,4] 2 传 [2,4]
+ /////
+ //public List? QuestionTypeIds { get; set; }
+
///
/// 创建时间开始
///
diff --git a/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs b/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
index b0abd5b0..788c9fb8 100644
--- a/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
@@ -28,6 +28,16 @@ namespace SJZY.Track.Domain.Dtos.Order
/////
//public List? QuestionTypeIds { get; set; }
+ ///
+ /// 订单类型
+ ///
+ public int? TrackOrderType { get; set; }
+
+ ///
+ /// 客户id
+ ///
+ public int? CustomerId { get; set; }
+
///
/// 单号
///
diff --git a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
index 43de6ccb..e160ec0b 100644
--- a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
@@ -123,6 +123,7 @@ public class OrderRepository : BasicRepository, IOrderRepository, I
{
List orderNoList = new List();
List questionTypeIds = new List();
+ int ques = 0;
if (!input.OrderNos.IsNullOrWhiteSpace())
{
orderNoList = input.OrderNos.Split(new char[] { ',', ',', ':', ':' }).ToList();
@@ -130,10 +131,12 @@ public class OrderRepository : BasicRepository, IOrderRepository, I
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()
@@ -147,7 +150,9 @@ public class OrderRepository : BasicRepository, IOrderRepository, I
(a, b, c) => a.CreateTime >= input.CreateTimeStart)
.WhereIF((!input.CreateTimeStart.HasValue) && input.CreateTimeEnd.HasValue,
(a, b, c) => a.CreateTime <= input.CreateTimeEnd)
- .WhereIF(input.TabType>0 && (!questionTypeIds.IsNullOrEmpty()), (a, b, c) => questionTypeIds.Contains(a.QuestionType))
+ .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
{
From 6a911177f7485729146368a4711d5403b808ee70 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Wed, 13 Mar 2024 15:41:59 +0800
Subject: [PATCH 24/49] =?UTF-8?q?add=20=E6=A0=A1=E9=AA=8C=E8=AE=A2?=
=?UTF-8?q?=E5=8D=95=E8=87=B3=E5=B0=91=E6=9C=89=E4=B8=80=E4=B8=AA=E6=A8=A1?=
=?UTF-8?q?=E6=9D=BF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dtos/ProvideServices/UpdateOrderInput.cs | 4 ++--
.../Dtos/ProvideServices/UpsertOrderInput.cs | 1 +
src/SJZY.Track.Application/SJZY.Track.Application.csproj | 2 +-
.../Services/ProvideServices/OrderService.cs | 9 +++++----
.../Services/ProvideServices/TrackPushPullService.cs | 2 +-
src/SJZY.Track.Application/SjzyTrackApplicationModule.cs | 5 ++---
6 files changed, 12 insertions(+), 11 deletions(-)
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/SJZY.Track.Application.csproj b/src/SJZY.Track.Application/SJZY.Track.Application.csproj
index da60d1a4..160ca752 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.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
index 765ff6ad..712b775c 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
@@ -32,6 +32,7 @@ public partial class OrderService : ApplicationService, IOrderService
[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)
@@ -43,8 +44,8 @@ public partial class OrderService : ApplicationService, IOrderService
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 "创建成功";
@@ -74,8 +75,8 @@ public partial class OrderService : ApplicationService, IOrderService
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/TrackPushPullService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
index 8e32d1c1..2e1dd08b 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
@@ -49,7 +49,7 @@ public class TrackPushPullService : ApplicationService
x.OrderNo
}).ToList();
- // 批量获取轨迹 这里报错了,我先随便给个 写死的主体值
+ // 批量获取轨迹
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
"A012", group.Key.ServiceProviderCode, data,
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
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
From c0b5db3ab54890f65fa09163444715aa12481ea9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Wed, 13 Mar 2024 17:16:15 +0800
Subject: [PATCH 25/49] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?=
=?UTF-8?q?=E8=AF=AD=E5=8F=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/TrackPull/TrackPullCacheService.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
index 168dae3a..420c44e6 100644
--- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
@@ -35,7 +35,7 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService,
var data = new TrackPullConfigDto();
Expression> exp = x =>
- (!id.HasValue || x.Id == id) && (id.HasValue || (x.SubSystemId == subSystemId && x.ServiceProviderId == serviceProviderId));
+ (id == null || x.Id == id) && (id != null || (x.SubSystemId == subSystemId && x.ServiceProviderId == serviceProviderId));
var trackPullConfigEntity = await _trackPullConfigRepository.GetFirstAsync(exp);
if (trackPullConfigEntity == null) return data;
From 9bd030465b129a46c8967ae01c892f5f15323765 Mon Sep 17 00:00:00 2001
From: moyongzhen <2534173414@qq.com>
Date: Wed, 13 Mar 2024 17:41:57 +0800
Subject: [PATCH 26/49] =?UTF-8?q?=E8=BD=A8=E8=BF=B9=E6=98=8E=E7=BB=86?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A2=E5=8D=95=E7=B1=BB=E5=9E=8Bid?=
=?UTF-8?q?=E5=92=8C=E8=AE=A2=E5=8D=95=E5=8F=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dtos/ProvideServices/GetOrderDetailsInput.cs | 10 ++++++++++
.../Dtos/Order/GetPageTrackOrderInputVO.cs | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
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.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs b/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
index 788c9fb8..91c30797 100644
--- a/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
@@ -70,7 +70,7 @@ namespace SJZY.Track.Domain.Dtos.Order
public int OrderType { get; set; }
///
- /// 订单名称
+ /// 订单类型名称
///
public string OrderTypeName { get; set; }
From c74b33151106f05359a424df8d9eec1871eec8ad Mon Sep 17 00:00:00 2001
From: moyongzhen <2534173414@qq.com>
Date: Wed, 13 Mar 2024 17:44:54 +0800
Subject: [PATCH 27/49] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs b/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
index 91c30797..c6b966e6 100644
--- a/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs
@@ -72,7 +72,7 @@ namespace SJZY.Track.Domain.Dtos.Order
///
/// 订单类型名称
///
- public string OrderTypeName { get; set; }
+ public string? OrderTypeName { get; set; }
///
/// 订单号
From 1718ede2eeefa0d051567ad982d5be13d939bfe9 Mon Sep 17 00:00:00 2001
From: dingenwen <543338760@qq.com>
Date: Wed, 13 Mar 2024 19:33:04 +0800
Subject: [PATCH 28/49] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=82=E5=B8=B8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/ProvideServices/TrackService.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
index fbd0fd99..cef3c88c 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
@@ -120,7 +120,7 @@ public partial class TrackService : ApplicationService, ITrackService
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
}
- var codes = await _provideQueries.GetCanDeleteTrackCodesAsync(new List(order.Id), input.TrackCodes);
+ var codes = await _provideQueries.GetCanDeleteTrackCodesAsync(new List { order.Id }, input.TrackCodes);
if (codes.Count == 0)
{
From 6a6e46482a74e319b3e73ab7e6299fb0020c9bab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Thu, 14 Mar 2024 09:21:22 +0800
Subject: [PATCH 29/49] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8B=89=E5=8F=96?=
=?UTF-8?q?=E7=BC=93=E5=AD=98=E8=AE=BE=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/TrackPull/TrackPullCacheService.cs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
index 420c44e6..f54f366a 100644
--- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
@@ -34,8 +34,10 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService,
{
var data = new TrackPullConfigDto();
- Expression> exp = x =>
- (id == null || x.Id == id) && (id != null || (x.SubSystemId == subSystemId && x.ServiceProviderId == serviceProviderId));
+ 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;
From 92bf6f549fd464fbdf6872696c4a6dd1decebcb4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Thu, 14 Mar 2024 10:10:04 +0800
Subject: [PATCH 30/49] =?UTF-8?q?=E8=B0=83=E8=AF=95=E8=BD=A8=E8=BF=B9?=
=?UTF-8?q?=E5=88=B7=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dtos/TrackPull/TrackPullParamConfigDto.cs | 12 ++---
.../EventHandlers/TrackRefreshEventHandler.cs | 44 ++++++++++++-------
.../SJZY.Track.Application.csproj | 2 +-
.../ProvideServices/TrackPushPullService.cs | 2 +-
.../Services/ProvideServices/TrackService.cs | 2 +-
5 files changed, 37 insertions(+), 25 deletions(-)
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs
index b8f22ac1..79af5185 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamConfigDto.cs
@@ -10,32 +10,32 @@ public class TrackPullParamConfigDto
///
/// 轨迹时区参数名
///
- public string TrackTimeZoneName { get; set; } = null!;
+ public string? TrackTimeZoneName { get; set; }
///
/// 轨迹代码参数名
///
- public string TrackContentCodeName { get; set; } = null!;
+ public string? TrackContentCodeName { get; set; }
///
/// 轨迹内容参数名
///
- public string TrackContentName { get; set; } = null!;
+ public string? TrackContentName { get; set; }
///
/// 轨迹发生地参数名
///
- public string TrackPlaceName { get; set; } = null!;
+ public string? TrackPlaceName { get; set; }
///
/// 轨迹状态参数名
///
- public string TrackStatusName { get; set; } = null!;
+ public string? TrackStatusName { get; set; }
///
/// 轨迹发生时间参数名
///
- public string TrackTimeName { get; set; } = null!;
+ public string? TrackTimeName { get; set; }
///
/// 订单数组路径
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
index e898fcf7..f708877e 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
@@ -29,14 +29,14 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
}
[CapSubscribe(GlobalConst.TrackRefreshSubscribe)]
- public async Task ConsumerAsync(InterfaceRelayTrackRefreshEvent @event)
+ public async Task ConsumerAsync(InterfaceRelayForwardReplayEvent @event)
{
// tips:attach返回的是服务商id,必有
var attach = JsonConvert.DeserializeObject(@event.Attach);
if (attach is null) return;
- var config = await _trackPullCacheService.GetPullConfigAsync(attach.ServiceProviderId, attach.SubSystemId);
+ var config = await _trackPullCacheService.GetPullConfigAsync(attach.SubSystemId, attach.ServiceProviderId);
- var data = JObject.FromObject(@event.Data);
+ var data = JObject.Parse(@event.Data.ToString()!);
var orderToken = data[config.ParamConfig.OrderPath];
if (orderToken is JArray orderTokens)
{
@@ -98,30 +98,31 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
TrackPullContentConfigDto? matchedContentConfig = null;
// 1、匹配轨迹代码
- var trackCode = trackToken[paramConfig.TrackContentCodeName]?.Value();
- if (!trackCode.IsNullOrWhiteSpace())
+ if (paramConfig.TrackContentCodeName != null)
{
- matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackContentCodeValue == trackCode);
+ var trackCode = trackToken[paramConfig.TrackContentCodeName]?.Value();
+ if (!trackCode.IsNullOrWhiteSpace())
+ {
+ matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackContentCodeValue == trackCode);
+ }
}
-
// 2、匹配轨迹状态
- if (matchedContentConfig is null)
+ else if (paramConfig.TrackStatusName != null)
{
var trackStatus = trackToken[paramConfig.TrackStatusName]?.Value();
if (!trackStatus.IsNullOrWhiteSpace())
{
- matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackStatusValue == trackCode);
+ matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackStatusValue == trackStatus);
}
}
-
// 3、匹配轨迹内容
- if (matchedContentConfig is null)
+ 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 == trackCode);
+ matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackContentValue == trackContent);
// 按关键字分析轨迹内容
if (matchedContentConfig is null)
@@ -155,7 +156,10 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
if (matchedContentConfig is null) return;
- var trackPlace = trackToken[paramConfig.TrackPlaceName]?.Value();
+ // 轨迹发生地
+ var trackPlace = paramConfig.TrackPlaceName == null
+ ? null
+ : trackToken[paramConfig.TrackPlaceName]?.Value();
if (trackPlace.IsNullOrWhiteSpace())
{
Expression> resultExpression =
@@ -173,12 +177,20 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
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 = trackToken[paramConfig.TrackTimeName]?.Value() ?? DateTime.Now;
- trackUpsertEvent.TrackTimeZone = trackToken[paramConfig.TrackTimeZoneName]?.Value() ??
- matchedContentConfig.TrackTimeZoneValue ?? 8;
+ 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/SJZY.Track.Application.csproj b/src/SJZY.Track.Application/SJZY.Track.Application.csproj
index 160ca752..fc1c5423 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/TrackPushPullService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
index 2e1dd08b..1401b5b8 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
@@ -50,7 +50,7 @@ public class TrackPushPullService : ApplicationService
}).ToList();
// 批量获取轨迹
- await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
+ var requestId = await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
"A012", group.Key.ServiceProviderCode, data,
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
}
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
index cef3c88c..4c3d1a45 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
@@ -149,7 +149,7 @@ public partial class TrackService : ApplicationService, ITrackService
public async Task BatchDeleteTrackAsync(BatchDeleteTrackInput input)
{
var orders = await _orderRepository.GetListAsync(x =>
- x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo) && !x.IsPushCompleted
+ x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo)
, x => new
{
x.Id, x.SubSystemId
From 8f0f40cc56130280f35b778719aaedcae40a47a8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Thu, 14 Mar 2024 11:49:24 +0800
Subject: [PATCH 31/49] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dtos/TrackPull/TrackPullConfigDto.cs | 17 +-
.../TrackPullParamWithContentConfigDto.cs | 8 +
.../Services/ITrackPullCacheService.cs | 14 +-
.../EventHandlers/TrackRefreshEventHandler.cs | 19 +-
.../UpdateOrderTrackEventHandler.cs | 2 +
.../ProvideServices/TrackPushPullService.cs | 55 ++++-
.../Services/TrackOrders/TrackOrderService.cs | 215 +++++++++---------
.../TrackPull/TrackPullCacheService.cs | 43 ++--
.../TrackPush/TrackPushCacheService.cs | 2 +-
.../OrderAggregate/IOrderRepository.cs | 18 +-
...emplateVO.cs => OrderServiceProviderVO.cs} | 4 +-
src/SJZY.Track.Domain/GlobalConst.cs | 14 +-
.../Queries/ITrackOrderQueries.cs | 13 ++
.../Queries/TrackOrderQueries.cs | 117 ++++++++++
.../Repositories/OrderRepository.cs | 198 ++--------------
15 files changed, 404 insertions(+), 335 deletions(-)
create mode 100644 src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullParamWithContentConfigDto.cs
rename src/SJZY.Track.Domain/Dtos/Order/{OrderTemplateVO.cs => OrderServiceProviderVO.cs} (87%)
create mode 100644 src/SJZY.Track.Domain/Queries/ITrackOrderQueries.cs
create mode 100644 src/SJZY.Track.Repository/Queries/TrackOrderQueries.cs
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullConfigDto.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullConfigDto.cs
index f6020d9f..10f78964 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullConfigDto.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackPullConfigDto.cs
@@ -1,8 +1,19 @@
-namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
+namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
public class TrackPullConfigDto
{
- public TrackPullParamConfigDto ParamConfig { get; set; }
+ ///
+ /// 服务商拉取频率(分钟)
+ ///
+ public int PullInterval { get; set; }
- public List ContentConfigs { 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/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/Services/ITrackPullCacheService.cs b/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs
index 7eb93992..486d4157 100644
--- a/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs
+++ b/src/SJZY.Track.Application.Contract/Services/ITrackPullCacheService.cs
@@ -4,13 +4,22 @@ 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 GetPullConfigAsync(int subSystemId, int serviceProviderId);
+ Task GetPullParamWithContentConfigAsync(int subSystemId, int serviceProviderId);
///
/// 设置拉取配置缓存
@@ -19,5 +28,6 @@ public interface ITrackPullCacheService
/// 子系统id
/// 服务商id
///
- Task SetPullConfigAsync(int? id = null, int? subSystemId = null, int? serviceProviderId = null);
+ Task SetPullConfigAsync(int? id = null, int? subSystemId = null,
+ int? serviceProviderId = null);
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
index f708877e..b3864e55 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
@@ -34,7 +34,9 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
// tips:attach返回的是服务商id,必有
var attach = JsonConvert.DeserializeObject(@event.Attach);
if (attach is null) return;
- var config = await _trackPullCacheService.GetPullConfigAsync(attach.SubSystemId, attach.ServiceProviderId);
+ var config =
+ await _trackPullCacheService.GetPullParamWithContentConfigAsync(attach.SubSystemId,
+ attach.ServiceProviderId);
var data = JObject.Parse(@event.Data.ToString()!);
var orderToken = data[config.ParamConfig.OrderPath];
@@ -51,9 +53,10 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
}
}
- private async Task HandleOrderAsync(JToken orderToken, TrackPullConfigDto config, int orderType)
+ private async Task HandleOrderAsync(JToken orderToken, TrackPullParamWithContentConfigDto paramWithContentConfig,
+ int orderType)
{
- var paramConfig = config.ParamConfig;
+ var paramConfig = paramWithContentConfig.ParamConfig;
var orderNo = orderToken[paramConfig.OrderNoName]?.Value();
if (orderNo.IsNullOrWhiteSpace()) return;
@@ -80,21 +83,21 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
{
foreach (var item in trackTokens)
{
- await HandleTrackAsync(item, config, trackUpsertEvent);
+ await HandleTrackAsync(item, paramWithContentConfig, trackUpsertEvent);
}
}
else if (orderToken is JObject)
{
- await HandleTrackAsync(orderToken, config, trackUpsertEvent);
+ await HandleTrackAsync(orderToken, paramWithContentConfig, trackUpsertEvent);
}
}
- private async Task HandleTrackAsync(JToken trackToken, TrackPullConfigDto config,
+ private async Task HandleTrackAsync(JToken trackToken, TrackPullParamWithContentConfigDto paramWithContentConfig,
TrackUpsertEvent @event)
{
var trackUpsertEvent = @event.DeepCopy();
- var paramConfig = config.ParamConfig;
- var contentConfigs = config.ContentConfigs;
+ var paramConfig = paramWithContentConfig.ParamConfig;
+ var contentConfigs = paramWithContentConfig.ContentConfigs;
TrackPullContentConfigDto? matchedContentConfig = null;
// 1、匹配轨迹代码
diff --git a/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs
index 72316cef..414a4afd 100644
--- a/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs
@@ -25,7 +25,9 @@ public class UpdateOrderTrackEventHandler : ITransientDependency, ICapSubscribe
if (@event.TrackTime == default)
{
if (order.LatestTrackTime == null) return;
+
// 删除全部轨迹导致的重置行为
+ // tips:订单是支持从已完成态到未完成态的
order.ResetTrackInfo();
}
else if (order.LatestTrackTime != null &&
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
index 1401b5b8..faa64a0f 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
@@ -1,7 +1,9 @@
using Newtonsoft.Json;
+using SJZY.Expand.ABP.Core;
using SJZY.InterfaceRelay.Application.Contracts;
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
using SJZY.Track.Application.Contract.Dtos.TrackPull;
+using SJZY.Track.Application.Contract.Services;
using SJZY.Track.Domain.Aggregates.OrderAggregate;
using Volo.Abp.Http.Client.DynamicProxying;
@@ -16,22 +18,26 @@ public class TrackPushPullService : ApplicationService
{
private readonly IOrderRepository _orderRepository;
private readonly IHttpClientProxy _httpClientProxy;
+ private readonly ITrackPullCacheService _trackPullCacheService;
public TrackPushPullService(IOrderRepository orderRepository,
- IHttpClientProxy httpClientProxy)
+ IHttpClientProxy httpClientProxy,
+ ITrackPullCacheService trackPullCacheService)
{
_orderRepository = orderRepository;
_httpClientProxy = httpClientProxy;
+ _trackPullCacheService = trackPullCacheService;
}
///
- /// 刷新轨迹
+ /// 手动刷新轨迹
///
///
///
[HttpPost("Track/Refresh")]
public async Task RefreshTrackAsync(RefreshTrackInput input)
{
+ // todo:罚时?
if (input.OrderNos.Count == 0)
{
throw new BusinessException(message: "订单号数组不能为空");
@@ -39,7 +45,8 @@ public class TrackPushPullService : ApplicationService
input.OrderNos = input.OrderNos.Distinct().ToList();
- var orderTemplates = await _orderRepository.GetOrderTemplatesAsync(input.OrderNos);
+ // 这里没有区分订单类型,就算的不同类型的单一起刷新了也无所谓
+ var orderTemplates = await _orderRepository.FindServiceProviderByOrderAsync(input.OrderNos);
foreach (var group in orderTemplates.GroupBy(x =>
new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId, x.OrderType)))
@@ -50,11 +57,51 @@ public class TrackPushPullService : ApplicationService
}).ToList();
// 批量获取轨迹
- var requestId = await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
+ await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
"A012", group.Key.ServiceProviderCode, data,
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
}
+ return true;
+ }
+
+ ///
+ /// 定时任务刷新轨迹
+ ///
+ ///
+ [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 _orderRepository.FindOrderByServiceProviderAsync(config.ServiceProviderId);
+
+ foreach (var group in orders.GroupBy(x =>
+ new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId,
+ x.OrderType)))
+ {
+ var data = group.Select(x => new
+ {
+ x.OrderNo
+ }).ToList();
+
+ // 批量获取轨迹
+ await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
+ "A012", group.Key.ServiceProviderCode, data,
+ GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
+ }
+
+ 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/TrackOrders/TrackOrderService.cs b/src/SJZY.Track.Application/Services/TrackOrders/TrackOrderService.cs
index 908d7227..06800fc0 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;
+ }
+
+ 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
index f54f366a..55351d80 100644
--- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
@@ -1,28 +1,39 @@
-using SJZY.Expand.ABP.Core;
+using System.Linq.Expressions;
+using SJZY.Expand.ABP.Core;
using SJZY.Track.Application.Contract.Dtos.TrackPull;
using SJZY.Track.Application.Contract.Services;
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
using SJZY.Track.Domain.Dtos.TrackPull;
-using System.Linq.Expressions;
-using Volo.Abp.DependencyInjection;
namespace SJZY.Track.Application.Services.TrackPull;
-public class TrackPullCacheService : ApplicationService, ITrackPullCacheService, ITransientDependency
+public class TrackPullCacheService : ApplicationService, ITrackPullCacheService
{
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
- private string RedisKey(int subSystemId, int serviceProviderId) => GlobalConst.TrackPushKeyPrefix + subSystemId + ":" + serviceProviderId;
+ public string TrackPullKey(int subSystemId, int serviceProviderId) =>
+ $"{GlobalConst.TrackPullKeyPrefix}:{subSystemId}:{serviceProviderId}";
+
+ public string TrackPullContentKey(int subSystemId, int serviceProviderId) =>
+ $"{GlobalConst.TrackPullContentKeyPrefix}:{subSystemId}:{serviceProviderId}";
public TrackPullCacheService(ITrackPullConfigRepository trackPullConfigRepository)
{
_trackPullConfigRepository = trackPullConfigRepository;
}
- [NonAction]
- public async Task GetPullConfigAsync(int subSystemId, int serviceProviderId)
+ public Task> GetAllPullConfigsAsync()
{
- var data = await RedisHelper.Client.GetAsync(RedisKey(subSystemId, serviceProviderId));
+ throw new NotImplementedException();
+ }
+
+ [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);
@@ -30,9 +41,10 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService,
}
[NonAction]
- public async Task SetPullConfigAsync(int? id = null, int? subSystemId = null, int? serviceProviderId = null)
+ public async Task SetPullConfigAsync(int? id = null, int? subSystemId = null,
+ int? serviceProviderId = null)
{
- var data = new TrackPullConfigDto();
+ var data = new TrackPullParamWithContentConfigDto();
Expression> exp = x => true;
if (id.HasValue) exp = x => x.Id == id;
@@ -47,10 +59,15 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService,
var trackPullContentList = await _trackPullConfigRepository.GetContentListCacheAsync(trackPullConfigEntity.Id);
if (trackPullContentList.Count == 0) return data;
- data.ParamConfig = ObjectMapper.Map(trackPullConfigDetail);
- data.ContentConfigs = ObjectMapper.Map, List>(trackPullContentList);
+ data.ParamConfig =
+ ObjectMapper.Map(trackPullConfigDetail);
+ data.ContentConfigs =
+ ObjectMapper.Map, List>(
+ trackPullContentList);
- await RedisHelper.Client.SetAsync(RedisKey(trackPullConfigEntity.SubSystemId, trackPullConfigEntity.ServiceProviderId), data, 86400);
+ await RedisHelper.Client.SetAsync(
+ TrackPullContentKey(trackPullConfigEntity.SubSystemId, trackPullConfigEntity.ServiceProviderId), data,
+ 86400);
return data;
}
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
index 62df4046..046ea943 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
@@ -10,7 +10,7 @@ public class TrackPushCacheService : ITrackPushCacheService, ITransientDependenc
{
private readonly IBasicQuery _trackPushConfigQuery;
- private string RedisKey(int customId) => GlobalConst.TrackPushKeyPrefix + customId;
+ private string RedisKey(int customId) => $"{GlobalConst.TrackPushKeyPrefix}:{customId}";
public TrackPushCacheService(IBasicQuery trackPushConfigQuery)
{
diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs
index 9e8d59eb..2f99ba3f 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);
-
///
/// 更新订单
///
@@ -60,9 +53,16 @@ public interface IOrderRepository : IBasicRepository
///
- /// 获取订单模板列表
+ /// 根据订单模板找对应服务商
///
///
///
- Task> GetOrderTemplatesAsync(List orderNos);
+ Task> FindServiceProviderByOrderAsync(List orderNos);
+
+ ///
+ /// 获取服务商下所有单(未完成的)
+ ///
+ ///
+ ///
+ Task> FindOrderByServiceProviderAsync(int serviceProvider);
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs b/src/SJZY.Track.Domain/Dtos/Order/OrderServiceProviderVO.cs
similarity index 87%
rename from src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs
rename to src/SJZY.Track.Domain/Dtos/Order/OrderServiceProviderVO.cs
index 6fe7d2b5..36a46aa8 100644
--- a/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/Order/OrderServiceProviderVO.cs
@@ -1,6 +1,6 @@
namespace SJZY.Track.Domain.Dtos.Order;
-public class OrderTemplateVO
+public class OrderServiceProviderVO
{
public string OrderNo { get; set; } = null!;
@@ -9,8 +9,6 @@ public class OrderTemplateVO
///
public int OrderType { get; set; }
- public int TemplateId { get; set; }
-
public int ServiceProviderId { get; set; }
///
diff --git a/src/SJZY.Track.Domain/GlobalConst.cs b/src/SJZY.Track.Domain/GlobalConst.cs
index 629149a8..981ce249 100644
--- a/src/SJZY.Track.Domain/GlobalConst.cs
+++ b/src/SJZY.Track.Domain/GlobalConst.cs
@@ -27,11 +27,6 @@ public class GlobalConst
///
public const string UpdateOrderTrackSubscribe = "SJZY.Track.UpdateOrderTrack";
- ///
- /// 轨迹删除后触发更新订单轨迹 mq订阅名称
- ///
- public const string DeleteTrackAfterUpdateOrderSubscribe = "SJZY.Track.DeleteTrackAfterUpdateOrder";
-
///
/// 关联订单后补轨迹 mq订阅名称
///
@@ -40,10 +35,15 @@ public class GlobalConst
///
/// 轨迹要推送的客户redis key前缀
///
- public const string TrackPushKeyPrefix = "TrackPush:";
+ public const string TrackPushKeyPrefix = "TrackPush";
///
/// 轨迹拉取配置信息redis key前缀
///
- public const string TrackPullConfigInfoKeyPrefix = "TrackPullConfigInfo:";
+ 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/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.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 e160ec0b..aac0ef93 100644
--- a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
@@ -1,25 +1,12 @@
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;
-using SqlSugar;
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();
@@ -98,180 +85,33 @@ 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();
- List questionTypeIds = new List();
- int ques = 0;
- if (!input.OrderNos.IsNullOrWhiteSpace())
- {
- orderNoList = input.OrderNos.Split(new char[] { ',', ',', ':', ':' }).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 { OrderId = a.OrderId, Name = b.Name, TemplateId = b.Id })
- .ToListAsync();
- var esTrackDetails = await _trackDetailsRepository.GetListAsync(orderIds);
- pageList.List.ForEach(a =>
- {
- var esDetails = esTrackDetails?.Where(b => b.OrderId == a.Id).OrderByDescending(b => b.TrackTime);
- var trackDetail = esDetails?.FirstOrDefault();
- if (trackDetail != null)
- {
- if (trackDetail.TrackContent != a.NewestTrackContent)
- {
- a.NewestTrackContent = trackDetail.TrackContent;
- }
-
- if (trackDetail.TrackEnContent != a.NewestTrackEnContent)
- {
- a.NewestTrackEnContent = trackDetail.TrackEnContent;
- }
-
- if (trackDetail.TrackPlace != a.NewestTrackPlace)
- {
- a.NewestTrackPlace = trackDetail.TrackPlace;
- }
-
- if (trackDetail.TrackTime != a.NewestTrackTime)
- {
- a.NewestTrackTime = trackDetail.TrackTime;
- }
- }
-
- a.TrackTemplateNames = trackTemplateList.Where(b => b.OrderId == a.Id).Select(a => a.Name)
- .JoinAsString(",");
- a.TrackTemplateIds = trackTemplateList.Where(b => b.OrderId == a.Id).Where(b => b.TemplateId>0).Select(a => a.TemplateId).ToList();
- });
- }
-
-
- #region 暂时注释
-
- //if (pageList.List.Any())
- //{
- // var orderIds = pageList.List.Select(a => a.Id);
- // //查询轨迹模版
-
-
- // var trackTemplateList = await Context.Queryable()
- // .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)
+ public async Task> FindServiceProviderByOrderAsync(List orderNos)
{
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 OrderTemplateVO
+ .Select((a, b, c) => new OrderServiceProviderVO
+ {
+ OrderNo = a.OrderNo,
+ OrderType = a.OrderType,
+ ServiceProviderId = b.ServiceProviderId,
+ ServiceProviderCode = c.Code,
+ SubSystemId = a.SubSystemId
+ })
+ .ToListAsync();
+ }
+
+ public async Task> FindOrderByServiceProviderAsync(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 OrderServiceProviderVO
{
OrderNo = a.OrderNo,
OrderType = a.OrderType,
- TemplateId = b.TrackTemplateId,
ServiceProviderId = b.ServiceProviderId,
ServiceProviderCode = c.Code,
SubSystemId = a.SubSystemId
From 786f1f0d2537a88caa5ce5c29e25f0d4adbd7128 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Thu, 14 Mar 2024 14:07:09 +0800
Subject: [PATCH 32/49] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8B=89=E5=8F=96?=
=?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=BC=93=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/TrackPull/TrackPullCacheService.cs | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
index 55351d80..26541474 100644
--- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
@@ -22,9 +22,15 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService
_trackPullConfigRepository = trackPullConfigRepository;
}
- public Task> GetAllPullConfigsAsync()
+ [NonAction]
+ public async Task> GetAllPullConfigsAsync()
{
- throw new NotImplementedException();
+ return await _trackPullConfigRepository.GetListAsync(x => true, x => new TrackPullConfigDto
+ {
+ SubSystemId = x.SubSystemId,
+ ServiceProviderId = x.ServiceProviderId,
+ PullInterval = x.PullInterval
+ });
}
[NonAction]
@@ -53,7 +59,6 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService
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);
From f50dccebe836be233f23308c528a615eb993dc26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Fri, 15 Mar 2024 09:53:24 +0800
Subject: [PATCH 33/49] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/ITrackPushCacheService.cs | 8 ++++++++
.../EventHandlers/TrackUpsertEventHandler.cs | 3 ++-
.../Services/TrackPush/TrackPushCacheService.cs | 15 +++++++++++++++
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
index 04369975..378d2d02 100644
--- a/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
+++ b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
@@ -9,6 +9,14 @@ public interface ITrackPushCacheService
///
Task IsPushAsync(int customId);
+ ///
+ /// 判断客户是否需要推送
+ ///
+ ///
+ ///
+ ///
+ Task IsPushAsync(int subSystemId, int customId);
+
///
/// 更新缓存
///
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs
index 21ddffc0..fd33d3e1 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs
@@ -99,7 +99,8 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
};
// todo:推送只做新增的,更新和删除的不做先
- if (!@event.IsPushCompleted && await _trackPushCacheService.IsPushAsync(@event.CustomId))
+ if (!@event.IsPushCompleted &&
+ await _trackPushCacheService.IsPushAsync(@event.SubSystemId, @event.CustomId))
{
//await PushTrack();
}
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
index 046ea943..ba084f93 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
@@ -32,6 +32,21 @@ public class TrackPushCacheService : ITrackPushCacheService, ITransientDependenc
return (bool)isPush;
}
+ public async Task IsPushAsync(int subSystemId, int customId)
+ {
+ var isPush =
+ await RedisHelper.Client.GetAsync(RedisKey(customId));
+
+ if (isPush == null)
+ {
+ isPush = await _trackPushConfigQuery.GetFirstAsync(x => x.CustomId == customId,
+ x => x.IsAutoPush);
+ await RedisHelper.Client.SetAsync(RedisKey(customId), isPush);
+ }
+
+ return (bool)isPush;
+ }
+
public async Task UpdateAsync(int customId, bool isPush)
{
await RedisHelper.Client.SetAsync(RedisKey(customId), isPush);
From 91ad7eebb8fb022a0598b7e70222198351d5bf02 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Fri, 15 Mar 2024 14:49:09 +0800
Subject: [PATCH 34/49] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../TrackPushContentConfigDto.cs | 44 +++++
.../Events/TrackUpsertEvent.cs | 4 +-
.../Events/UpdateOrderTrackEvent.cs | 5 +
.../Services/ITrackPushCacheService.cs | 18 +-
.../OrderLinkAfterFillTrackHandler.cs | 4 +-
.../EventHandlers/TrackRefreshEventHandler.cs | 4 +-
.../EventHandlers/TrackUpsertEventHandler.cs | 21 ++-
.../Services/ProvideServices/TrackService.cs | 8 +-
.../TrackPush/TrackPushCacheService.cs | 33 +---
.../Services/TrackPush/TrackPushService.cs | 173 ++++++++++--------
.../Aggregates/OrderAggregate/OrderEntity.cs | 8 +-
.../TrackDetailsIndex.cs | 5 +
.../Dtos/Order/LinkedOrderVO.cs | 10 +-
.../Dtos/TrackDetails/MatchTrackContentDto.cs | 5 +
.../Enums/TrackProblemType.cs | 15 ++
src/SJZY.Track.Domain/GlobalConst.cs | 5 +
.../Queries/ProvideQueries.cs | 1 +
.../Repositories/OrderRepository.cs | 2 +-
18 files changed, 234 insertions(+), 131 deletions(-)
create mode 100644 src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackPushContentConfigDto.cs
create mode 100644 src/SJZY.Track.Domain/Enums/TrackProblemType.cs
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..ed2e02d0
--- /dev/null
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackPushContentConfigDto.cs
@@ -0,0 +1,44 @@
+namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
+
+public class TrackPushContentConfigDto
+{
+ ///
+ /// 扩展字段参数值
+ ///
+ 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/Events/TrackUpsertEvent.cs b/src/SJZY.Track.Application.Contract/Events/TrackUpsertEvent.cs
index 04f91415..56032acb 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; }
///
- /// 订单是否推送完成(异步维护)
+ /// 最新推送代码(异步维护)
///
- 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 779415e2..7daa9a7d 100644
--- a/src/SJZY.Track.Application.Contract/Events/UpdateOrderTrackEvent.cs
+++ b/src/SJZY.Track.Application.Contract/Events/UpdateOrderTrackEvent.cs
@@ -41,4 +41,9 @@ public class UpdateOrderTrackEvent
/// 轨迹时区
///
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/Services/ITrackPushCacheService.cs b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
index 378d2d02..acc00b72 100644
--- a/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
+++ b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
@@ -1,4 +1,6 @@
-namespace SJZY.Track.Application.Contract.Services;
+using SJZY.Track.Application.Contract.Dtos.ProvideServices;
+
+namespace SJZY.Track.Application.Contract.Services;
public interface ITrackPushCacheService
{
@@ -10,12 +12,22 @@ public interface ITrackPushCacheService
Task IsPushAsync(int customId);
///
- /// 判断客户是否需要推送
+ /// 获取服务商拉取配置
+ ///
+ /// 子系统id
+ /// 服务商id
+ ///
+ Task> GetPushContentConfigsAsync(int subSystemId, int customId);
+
+ ///
+ /// 根据轨迹代码推断下一个(升序)要推送的内容,如果找不到或者已经是最后一个了,返回null
///
///
///
+ ///
///
- Task IsPushAsync(int subSystemId, int customId);
+ Task InferNextPushContentOrNullAsync(int subSystemId, int customId,
+ int? trackContentId);
///
/// 更新缓存
diff --git a/src/SJZY.Track.Application/EventHandlers/OrderLinkAfterFillTrackHandler.cs b/src/SJZY.Track.Application/EventHandlers/OrderLinkAfterFillTrackHandler.cs
index 4a014b49..80c5dda8 100644
--- a/src/SJZY.Track.Application/EventHandlers/OrderLinkAfterFillTrackHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/OrderLinkAfterFillTrackHandler.cs
@@ -31,7 +31,7 @@ public class OrderLinkAfterFillTrackHandler : ITransientDependency, ICapSubscrib
var order = await _orderRepository.GetFirstAsync(x =>
x.Id == linkOrderId, x => new
{
- x.OrderType, x.OrderNo, x.CustomId, x.IsPushCompleted, x.SubSystemId
+ x.OrderType, x.OrderNo, x.CustomId, LatestPushCode = x.LatestPushTrackContentId, x.SubSystemId
});
if (order == default) continue;
@@ -50,7 +50,7 @@ public class OrderLinkAfterFillTrackHandler : ITransientDependency, ICapSubscrib
OrderId = linkOrderId,
CustomId = order.CustomId,
SubSystemId = order.SubSystemId,
- IsPushCompleted = order.IsPushCompleted,
+ LatestPushTrackContentId = order.LatestPushCode,
UpSubSystemId = @event.SubSystemId,
};
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
index b3864e55..5d74b758 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
@@ -63,7 +63,7 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
var order = await _orderRepository.GetFirstAsync(x =>
x.OrderType == orderType && x.OrderNo == orderNo, x => new
{
- x.Id, x.SubSystemId, x.IsPushCompleted, x.CustomId
+ x.Id, x.SubSystemId, LatestPushCode = x.LatestPushTrackContentId, x.CustomId
});
if (order == default) return;
@@ -73,7 +73,7 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
{
OrderId = order.Id,
SubSystemId = order.SubSystemId,
- IsPushCompleted = order.IsPushCompleted,
+ LatestPushTrackContentId = order.LatestPushCode,
CustomId = order.CustomId,
OrderType = orderType,
OrderNo = orderNo!,
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs
index fd33d3e1..7c6f3159 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs
@@ -88,6 +88,7 @@ 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,
@@ -97,13 +98,6 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
CreateUser = CurrentUserRequest.CurrentUser.Name,
CreateTime = DateTime.Now
};
-
- // todo:推送只做新增的,更新和删除的不做先
- if (!@event.IsPushCompleted &&
- await _trackPushCacheService.IsPushAsync(@event.SubSystemId, @event.CustomId))
- {
- //await PushTrack();
- }
}
else
{
@@ -114,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,
@@ -137,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/Services/ProvideServices/TrackService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
index 4c3d1a45..b1c809d3 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
@@ -41,7 +41,7 @@ public partial class TrackService : ApplicationService, ITrackService
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, LatestPushCode = x.LatestPushTrackContentId, x.CustomId
});
if (order == default)
{
@@ -52,7 +52,7 @@ public partial class TrackService : ApplicationService, ITrackService
var @event = ObjectMapper.Map(input);
@event.OrderId = order.Id;
@event.SubSystemId = order.SubSystemId;
- @event.IsPushCompleted = order.IsPushCompleted;
+ @event.LatestPushTrackContentId = order.LatestPushCode;
@event.CustomId = order.CustomId;
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
return true;
@@ -76,7 +76,7 @@ public partial class TrackService : ApplicationService, ITrackService
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
+ x.Id, x.OrderNo, x.SubSystemId, LatestPushCode = x.LatestPushTrackContentId, x.CustomId
});
foreach (var order in orders)
@@ -92,7 +92,7 @@ public partial class TrackService : ApplicationService, ITrackService
OrderNo = order.OrderNo,
OrderId = order.Id,
SubSystemId = order.SubSystemId,
- IsPushCompleted = order.IsPushCompleted,
+ LatestPushTrackContentId = order.LatestPushCode,
CustomId = order.CustomId
};
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
index ba084f93..eb11ae2c 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
@@ -1,4 +1,5 @@
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;
@@ -17,34 +18,20 @@ public class TrackPushCacheService : ITrackPushCacheService, ITransientDependenc
_trackPushConfigQuery = trackPushConfigQuery;
}
- public async Task IsPushAsync(int customId)
+ public Task IsPushAsync(int customId)
{
- var isPush =
- await RedisHelper.Client.GetAsync(RedisKey(customId));
-
- if (isPush == null)
- {
- isPush = await _trackPushConfigQuery.GetFirstAsync(x => x.CustomId == customId,
- x => x.IsAutoPush);
- await RedisHelper.Client.SetAsync(RedisKey(customId), isPush);
- }
-
- return (bool)isPush;
+ throw new NotImplementedException();
}
- public async Task IsPushAsync(int subSystemId, int customId)
+ public Task> GetPushContentConfigsAsync(int subSystemId, int customId)
{
- var isPush =
- await RedisHelper.Client.GetAsync(RedisKey(customId));
+ throw new NotImplementedException();
+ }
- if (isPush == null)
- {
- isPush = await _trackPushConfigQuery.GetFirstAsync(x => x.CustomId == customId,
- x => x.IsAutoPush);
- await RedisHelper.Client.SetAsync(RedisKey(customId), isPush);
- }
-
- return (bool)isPush;
+ public Task InferNextPushContentOrNullAsync(int subSystemId, int customId,
+ int? trackContentId)
+ {
+ throw new NotImplementedException();
}
public async Task UpdateAsync(int customId, bool isPush)
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
index 1ecb8f41..34903f75 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
@@ -1,4 +1,5 @@
-using Microsoft.Extensions.Localization;
+using System.Linq.Expressions;
+using Microsoft.Extensions.Localization;
using SJZY.Expand.ABP.Core.Localization;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.Track.Application.Contract.Dtos.TrackPush;
@@ -9,9 +10,6 @@ using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
using SJZY.Track.Domain.Dtos.Common;
using SJZY.Track.Domain.Dtos.TrackPush;
-using SqlSugar;
-using System.Linq.Expressions;
-using Volo.Abp.DependencyInjection;
namespace SJZY.Track.Application.Services.TrackPush;
@@ -20,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;
@@ -37,7 +34,6 @@ public class TrackPushService : ApplicationService, ITransientDependency
{
_stringLocalizer = stringLocalizer;
_trackPushConfigRepository = trackPushConfigRepository;
- _trackTemplateRepository = trackTemplateRepository;
_trackPullConfigRepository = trackPullConfigRepository;
_trackPushCacheService = trackPushCacheService;
}
@@ -59,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);
}
@@ -97,71 +94,79 @@ 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 &&
+ x.ServiceProviderId == input.ServiceProviderId;
if (input.Options == OptionTypeNoNull.修改) isAnyExp = isAnyExp.And(x => x.Id != input.Id);
- if (await _trackPushConfigRepository.IsAnyAsync(isAnyExp)) throw new BusinessException(message: _stringLocalizer["IsTrackPushConfigAny"]);
+ if (await _trackPushConfigRepository.IsAnyAsync(isAnyExp))
+ throw new BusinessException(message: _stringLocalizer["IsTrackPushConfigAny"]);
}
switch (input.Options)
{
case OptionTypeNoNull.新增:
+ {
+ var trackPushEntity = ObjectMapper.Map(input);
+ var trackPushParamsEntity =
+ ObjectMapper.Map(input);
+
+ using (var ts = TransactionScopeHelper.Create())
{
- var trackPushEntity = ObjectMapper.Map(input);
- var trackPushParamsEntity = ObjectMapper.Map(input);
+ int id = await _trackPushConfigRepository.InsertReturnIdentityAsync(trackPushEntity);
- using (var ts = TransactionScopeHelper.Create())
- {
- int id = await _trackPushConfigRepository.InsertReturnIdentityAsync(trackPushEntity);
+ trackPushParamsEntity.PullOrPushConfigId = id;
+ await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity);
- trackPushParamsEntity.PullOrPushConfigId = id;
- await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity);
+ if (input.IsAutoPush!.Value) await _trackPushCacheService.IsPushAsync(input.CustomId!.Value);
- if (input.IsAutoPush!.Value) await _trackPushCacheService.IsPushAsync(input.CustomId!.Value);
-
- ts.Complete();
- }
+ ts.Complete();
}
+ }
break;
case OptionTypeNoNull.修改:
+ {
+ var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ??
+ throw new BusinessException(message: _stringLocalizer["NotFindData"]);
+
+ int oldCustomId = oldTrackPushEntity.CustomId;
+
+ var oldTrackPushParamsEntity =
+ await _trackPullConfigRepository.GetParamsSingleAsync(x =>
+ x.PullOrPushConfigId == input.Id && x.IsPush);
+
+ ObjectMapper.Map(input, oldTrackPushEntity);
+ ObjectMapper.Map(input, oldTrackPushParamsEntity);
+
+ using (var ts = TransactionScopeHelper.Create())
{
- var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
+ await _trackPushConfigRepository.UpdateAsync(oldTrackPushEntity);
+ await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity);
- int oldCustomId = oldTrackPushEntity.CustomId;
+ await _trackPushCacheService.UpdateAsync(oldCustomId, false);
+ if (input.IsAutoPush!.Value) await _trackPushCacheService.IsPushAsync(input.CustomId!.Value);
- var oldTrackPushParamsEntity = await _trackPullConfigRepository.GetParamsSingleAsync(x => x.PullOrPushConfigId == input.Id && x.IsPush);
-
- ObjectMapper.Map(input, oldTrackPushEntity);
- ObjectMapper.Map(input, oldTrackPushParamsEntity);
-
- using (var ts = TransactionScopeHelper.Create())
- {
- await _trackPushConfigRepository.UpdateAsync(oldTrackPushEntity);
- await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity);
-
- await _trackPushCacheService.UpdateAsync(oldCustomId, false);
- if (input.IsAutoPush!.Value) await _trackPushCacheService.IsPushAsync(input.CustomId!.Value);
-
- ts.Complete();
- }
+ ts.Complete();
}
+ }
break;
case OptionTypeNoNull.删除:
+ {
+ var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ??
+ throw new BusinessException(message: _stringLocalizer["NotFindData"]);
+
+ using (var ts = TransactionScopeHelper.Create())
{
- var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
+ await _trackPushConfigRepository.SoftDeleteAsync(x => x.Id == input.Id);
+ await _trackPullConfigRepository.SoftDeleteParamsAsync(x =>
+ x.PullOrPushConfigId == input.Id && x.IsPush);
+ await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id);
+ await _trackPushCacheService.UpdateAsync(oldTrackPushEntity.CustomId, false);
- using (var ts = TransactionScopeHelper.Create())
- {
- await _trackPushConfigRepository.SoftDeleteAsync(x => x.Id == input.Id);
- await _trackPullConfigRepository.SoftDeleteParamsAsync(x => x.PullOrPushConfigId == input.Id && x.IsPush);
- await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id);
- await _trackPushCacheService.UpdateAsync(oldTrackPushEntity.CustomId, false);
-
- ts.Complete();
- }
+ ts.Complete();
}
+ }
break;
default:
@@ -182,62 +187,76 @@ 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"]);
}
switch (input.Options)
{
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;
+ var entity = ObjectMapper.Map(input);
+ entity.Sort = maxSort + 1;
- await _trackPushConfigRepository.InsertContentAsync(entity);
+ await _trackPushConfigRepository.InsertContentAsync(entity);
- break;
- }
+ 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);
+ ObjectMapper.Map(input, entity);
- await _trackPushConfigRepository.UpdateContentAsync(entity);
+ await _trackPushConfigRepository.UpdateContentAsync(entity);
- break;
- }
+ break;
+ }
case OptionTypeNoNull.删除:
+ {
+ var entity = await _trackPushConfigRepository.GetContentByIdAsync(input.Id!.Value) ??
+ throw new BusinessException(message: _stringLocalizer["NotFindData"]);
+
+ using (var ts = TransactionScopeHelper.Create())
{
- var entity = await _trackPushConfigRepository.GetContentByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
+ await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id);
- 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();
- }
-
- break;
+ ts.Complete();
}
+ break;
+ }
+
default:
throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum,
nameof(EditTrackPushContentInput.Options)]);
diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs
index 66f704a3..3defe94f 100644
--- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs
+++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderEntity.cs
@@ -43,10 +43,10 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
public bool IsCompleted { get; set; }
///
- /// 订单是否推送完成(异步维护)
+ /// 最新推送轨迹内容id(异步维护)
///
- [SugarColumn(ColumnName = "IsPushCompleted")]
- public bool IsPushCompleted { get; set; }
+ [SugarColumn(ColumnName = "LatestPushTrackContentId")]
+ public int? LatestPushTrackContentId { get; set; }
///
/// 最新轨迹内容(异步维护)
@@ -112,7 +112,7 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
/// 问题类型(主数据枚举TrackQuestionType)
///
[SugarColumn(ColumnName = "QuestionType")]
- public int QuestionType { get; set; }
+ public int QuestionType { get; set; }
///
/// 问题描述(主数据枚举TrackProblemDescription)
diff --git a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs
index d5909320..812b2377 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs
@@ -46,6 +46,11 @@ public class TrackDetailsIndex : IdBaseIndex
///
public string TrackContent { get; set; } = null!;
+ ///
+ /// 轨迹内容Id
+ ///
+ public int TrackContentId { 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/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/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 981ce249..528115ea 100644
--- a/src/SJZY.Track.Domain/GlobalConst.cs
+++ b/src/SJZY.Track.Domain/GlobalConst.cs
@@ -37,6 +37,11 @@ public class GlobalConst
///
public const string TrackPushKeyPrefix = "TrackPush";
+ ///
+ /// 轨迹推送内容配置redis key前缀
+ ///
+ public const string TrackPushContentKeyPrefix = "TrackPushContent";
+
///
/// 轨迹拉取配置信息redis key前缀
///
diff --git a/src/SJZY.Track.Repository/Queries/ProvideQueries.cs b/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
index a84a28f5..04301286 100644
--- a/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
+++ b/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
@@ -70,6 +70,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,
diff --git a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
index aac0ef93..47c0bb60 100644
--- a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
@@ -67,7 +67,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();
From 35bb8e13e0fa16dffe04839b0c63c1cd3770f348 Mon Sep 17 00:00:00 2001
From: moyongzhen <2534173414@qq.com>
Date: Fri, 15 Mar 2024 15:33:27 +0800
Subject: [PATCH 35/49] =?UTF-8?q?=E8=BD=A8=E8=BF=B9=E8=AE=A2=E5=8D=95?=
=?UTF-8?q?=E6=98=8E=E7=BB=86=E8=A1=A5=E5=85=85s01=E9=81=97=E6=BC=8F?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/TrackOrders/TrackOrderService.cs | 32 +++++++++----------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/SJZY.Track.Application/Services/TrackOrders/TrackOrderService.cs b/src/SJZY.Track.Application/Services/TrackOrders/TrackOrderService.cs
index 06800fc0..e799aeea 100644
--- a/src/SJZY.Track.Application/Services/TrackOrders/TrackOrderService.cs
+++ b/src/SJZY.Track.Application/Services/TrackOrders/TrackOrderService.cs
@@ -42,30 +42,25 @@ public class TrackOrderService : ApplicationService
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
- });
+ 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));
+ 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();
+ var insertData = input.TrackTemplateIds.Intersect(trackContentsOfTemplates.Select(aa => aa.TrackTemplateId)).ToList();
if (!insertData.IsNullOrEmpty())
{
- trackContent =
- trackContentsOfTemplates.FirstOrDefault(a => a.TrackTemplateId == insertData.FirstOrDefault());
+ trackContent = trackContentsOfTemplates.FirstOrDefault(a => a.TrackTemplateId == insertData.FirstOrDefault());
}
if (trackContent != null)
@@ -73,7 +68,11 @@ public class TrackOrderService : ApplicationService
a.IsCanDelete = trackContent.IsCanDelete;
a.IsExternal = trackContent.IsExternal;
}
-
+ //else
+ //{
+ // a.IsCanDelete=false;
+ // a.IsExternal=false;
+ //}
if (a.TrackTimeZoneValue == 0f)
{
a.TrackTimeZone = $"GTM{" "}+00:00";
@@ -90,6 +89,7 @@ public class TrackOrderService : ApplicationService
}
});
return list;
+
}
return new List();
From 1d80a8de4eb58ed77808373a2110ae13412cc600 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Fri, 15 Mar 2024 16:09:27 +0800
Subject: [PATCH 36/49] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=A8=E9=80=81?=
=?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=BC=93=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/ITrackPushCacheService.cs | 17 +-
.../AutoMapper/TrackPushAutoMapperProfile.cs | 3 +
.../TrackPull/TrackPullCacheService.cs | 6 +-
.../Services/TrackPull/TrackPullService.cs | 11 +-
.../TrackPush/TrackPushCacheService.cs | 71 ++++++--
.../Services/TrackPush/TrackPushService.cs | 160 +++++++++---------
6 files changed, 153 insertions(+), 115 deletions(-)
diff --git a/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
index acc00b72..cc7fec74 100644
--- a/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
+++ b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
@@ -4,13 +4,6 @@ namespace SJZY.Track.Application.Contract.Services;
public interface ITrackPushCacheService
{
- ///
- /// 判断客户是否需要推送
- ///
- ///
- ///
- Task IsPushAsync(int customId);
-
///
/// 获取服务商拉取配置
///
@@ -30,9 +23,11 @@ public interface ITrackPushCacheService
int? trackContentId);
///
- /// 更新缓存
+ /// 设置推送配置缓存
///
- ///
- ///
- Task UpdateAsync(int customId, bool isPush);
+ ///
+ /// 子系统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/AutoMapper/TrackPushAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs
index eed8b90b..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;
@@ -14,5 +15,7 @@ public class TrackPushAutoMapperProfile : Profile
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/Services/TrackPull/TrackPullCacheService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
index 26541474..1a57ea08 100644
--- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
@@ -4,10 +4,11 @@ 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
+public class TrackPullCacheService : ApplicationService, ITrackPullCacheService, ITransientDependency
{
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
@@ -59,6 +60,7 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService
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);
@@ -72,7 +74,7 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService
await RedisHelper.Client.SetAsync(
TrackPullContentKey(trackPullConfigEntity.SubSystemId, trackPullConfigEntity.ServiceProviderId), data,
- 86400);
+ (int)TimeSpan.FromDays(1).TotalSeconds);
return data;
}
diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs
index 61f2cb2d..daba134c 100644
--- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs
@@ -212,16 +212,21 @@ public class TrackPullService : ApplicationService, ITransientDependency
ObjectMapper.Map(input, oldTrackPullContentEntity);
await _trackPullConfigRepository.UpdateContentAsync(oldTrackPullContentEntity);
- await _trackPullCacheService.SetPullConfigAsync(input.TrackPullConfigId);
+ 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 _trackPullConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id);
+ await _trackPullCacheService.SetPullConfigAsync(oldTrackPullContentEntity.TrackPullConfigId);
- break;
+ break;
+ }
default:
throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum,
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
index eb11ae2c..c8581b7c 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
@@ -1,41 +1,78 @@
-using SJZY.Expand.ABP.Core;
+using Microsoft.Extensions.DependencyInjection;
+using Nest;
+using SJZY.Expand.ABP.Core;
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
using SJZY.Track.Application.Contract.Services;
+using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
using SJZY.Track.Domain.Queries;
+using SJZY.UserCenter.SharedModel.Dtos.PHP.User;
+using System.Linq.Expressions;
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 Task IsPushAsync(int customId)
+ [NonAction]
+ public async Task> GetPushContentConfigsAsync(int subSystemId, int customId)
{
- throw new NotImplementedException();
+ var data = await RedisHelper.Client.GetAsync>(TrackPushContentKey(subSystemId, customId));
+
+ data ??= await SetPushContentConfigsAsync(subSystemId: subSystemId, customId: customId);
+
+ return data;
}
- public Task> GetPushContentConfigsAsync(int subSystemId, int customId)
+ [NonAction]
+ public async Task InferNextPushContentOrNullAsync(int subSystemId, int customId, int? trackContentId)
{
- throw new NotImplementedException();
+ var data = await GetPushContentConfigsAsync(subSystemId, customId);
+
+ if (trackContentId.HasValue)
+ {
+ if (data.Count > 1 && data.Any(x => x.TrackContentId == trackContentId))
+ {
+ int index = data.FindIndex(x => x.TrackContentId == trackContentId);
+ int nextIndex = (index + 1) % data.Count; // 计算下一个索引,处理最后一个元素的情况
+
+ return data[nextIndex];
+ }
+ else return null;
+ }
+ else return data.FirstOrDefault();
}
- public Task InferNextPushContentOrNullAsync(int subSystemId, int customId,
- int? trackContentId)
+ [NonAction]
+ public async Task> SetPushContentConfigsAsync(int? id = null, int? subSystemId = null, int? customId = null)
{
- throw new NotImplementedException();
- }
+ var data = new List();
+ 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;
- public async Task UpdateAsync(int customId, bool isPush)
- {
- await RedisHelper.Client.SetAsync(RedisKey(customId), isPush);
+ 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 = ObjectMapper.Map, List>(trackPushContentList);
+
+ await RedisHelper.Client.SetAsync(TrackPushContentKey(trackPushConfigEntity.SubSystemId, trackPushConfigEntity.CustomId), data, (int)TimeSpan.FromDays(1).TotalSeconds);
+
+ 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 34903f75..e2771645 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
@@ -94,8 +94,7 @@ public class TrackPushService : ApplicationService
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);
if (await _trackPushConfigRepository.IsAnyAsync(isAnyExp))
@@ -105,68 +104,62 @@ public class TrackPushService : ApplicationService
switch (input.Options)
{
case OptionTypeNoNull.新增:
- {
- var trackPushEntity = ObjectMapper.Map(input);
- var trackPushParamsEntity =
- ObjectMapper.Map(input);
-
- using (var ts = TransactionScopeHelper.Create())
{
- int id = await _trackPushConfigRepository.InsertReturnIdentityAsync(trackPushEntity);
+ var trackPushEntity = ObjectMapper.Map(input);
+ var trackPushParamsEntity =
+ ObjectMapper.Map(input);
- trackPushParamsEntity.PullOrPushConfigId = id;
- await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity);
+ using (var ts = TransactionScopeHelper.Create())
+ {
+ int id = await _trackPushConfigRepository.InsertReturnIdentityAsync(trackPushEntity);
- if (input.IsAutoPush!.Value) await _trackPushCacheService.IsPushAsync(input.CustomId!.Value);
+ trackPushParamsEntity.PullOrPushConfigId = id;
+ await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity);
- ts.Complete();
+ ts.Complete();
+ }
}
- }
break;
case OptionTypeNoNull.修改:
- {
- var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ??
- throw new BusinessException(message: _stringLocalizer["NotFindData"]);
-
- int oldCustomId = oldTrackPushEntity.CustomId;
-
- var oldTrackPushParamsEntity =
- await _trackPullConfigRepository.GetParamsSingleAsync(x =>
- x.PullOrPushConfigId == input.Id && x.IsPush);
-
- ObjectMapper.Map(input, oldTrackPushEntity);
- ObjectMapper.Map(input, oldTrackPushParamsEntity);
-
- using (var ts = TransactionScopeHelper.Create())
{
- await _trackPushConfigRepository.UpdateAsync(oldTrackPushEntity);
- await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity);
+ var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ??
+ throw new BusinessException(message: _stringLocalizer["NotFindData"]);
- await _trackPushCacheService.UpdateAsync(oldCustomId, false);
- if (input.IsAutoPush!.Value) await _trackPushCacheService.IsPushAsync(input.CustomId!.Value);
+ int oldCustomId = oldTrackPushEntity.CustomId;
- ts.Complete();
+ var oldTrackPushParamsEntity =
+ await _trackPullConfigRepository.GetParamsSingleAsync(x =>
+ x.PullOrPushConfigId == input.Id && x.IsPush);
+
+ ObjectMapper.Map(input, oldTrackPushEntity);
+ ObjectMapper.Map(input, oldTrackPushParamsEntity);
+
+ using (var ts = TransactionScopeHelper.Create())
+ {
+ await _trackPushConfigRepository.UpdateAsync(oldTrackPushEntity);
+ await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity);
+
+ ts.Complete();
+ }
}
- }
break;
case OptionTypeNoNull.删除:
- {
- var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ??
- throw new BusinessException(message: _stringLocalizer["NotFindData"]);
-
- using (var ts = TransactionScopeHelper.Create())
{
- await _trackPushConfigRepository.SoftDeleteAsync(x => x.Id == input.Id);
- await _trackPullConfigRepository.SoftDeleteParamsAsync(x =>
- x.PullOrPushConfigId == input.Id && x.IsPush);
- await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id);
- await _trackPushCacheService.UpdateAsync(oldTrackPushEntity.CustomId, false);
+ var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ??
+ throw new BusinessException(message: _stringLocalizer["NotFindData"]);
- ts.Complete();
+ using (var ts = TransactionScopeHelper.Create())
+ {
+ await _trackPushConfigRepository.SoftDeleteAsync(x => x.Id == input.Id);
+ await _trackPullConfigRepository.SoftDeleteParamsAsync(x =>
+ x.PullOrPushConfigId == input.Id && x.IsPush);
+ await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id);
+
+ ts.Complete();
+ }
}
- }
break;
default:
@@ -215,47 +208,50 @@ public class TrackPushService : ApplicationService
switch (input.Options)
{
case OptionTypeNoNull.新增:
- {
- 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);
-
- break;
- }
-
- case OptionTypeNoNull.修改:
- {
- var entity = await _trackPushConfigRepository.GetContentByIdAsync(input.Id!.Value) ??
- throw new BusinessException(message: _stringLocalizer["NotFindData"]);
-
- ObjectMapper.Map(input, entity);
-
- await _trackPushConfigRepository.UpdateContentAsync(entity);
-
- break;
- }
-
- case OptionTypeNoNull.删除:
- {
- 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);
+ int maxSort = await _trackPushConfigRepository.ContentMaxAsync(x => x.Sort,
+ x => x.TrackPushConfigId == input.TrackPushConfigId);
- await _trackPushConfigRepository.UpdateContentAsync(x => x.Sort == x.Sort - 1,
- x => x.TrackPushConfigId == entity.TrackPushConfigId && x.Sort > entity.Sort);
+ var entity = ObjectMapper.Map(input);
+ entity.Sort = maxSort + 1;
- ts.Complete();
+ await _trackPushConfigRepository.InsertContentAsync(entity);
+ await _trackPushCacheService.SetPushContentConfigsAsync(input.TrackPushConfigId);
+
+ break;
}
- break;
- }
+ case OptionTypeNoNull.修改:
+ {
+ 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"]);
+
+ 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);
+
+ ts.Complete();
+ }
+
+ await _trackPushCacheService.SetPushContentConfigsAsync(entity.TrackPushConfigId);
+
+ break;
+ }
default:
throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum,
From 06e43db12c11e743ca0877602605081664a7c0a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Fri, 15 Mar 2024 16:12:55 +0800
Subject: [PATCH 37/49] =?UTF-8?q?=E8=A1=A5=E5=85=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/TrackPush/TrackPushService.cs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
index e2771645..e7498c2c 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
@@ -278,7 +278,11 @@ public class TrackPushService : ApplicationService
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;
}
From 3871b31af0c6eb66470ef4892c382e189839dd73 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Fri, 15 Mar 2024 16:13:47 +0800
Subject: [PATCH 38/49] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?=
=?UTF-8?q?=E5=BC=95=E7=94=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/TrackPush/TrackPushCacheService.cs | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
index c8581b7c..b5988ab3 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
@@ -1,12 +1,7 @@
-using Microsoft.Extensions.DependencyInjection;
-using Nest;
-using SJZY.Expand.ABP.Core;
+using SJZY.Expand.ABP.Core;
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
using SJZY.Track.Application.Contract.Services;
-using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
-using SJZY.Track.Domain.Queries;
-using SJZY.UserCenter.SharedModel.Dtos.PHP.User;
using System.Linq.Expressions;
using Volo.Abp.DependencyInjection;
From f8d5705551068934d8f76b121034168775db8a07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Fri, 15 Mar 2024 16:52:36 +0800
Subject: [PATCH 39/49] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dtos/ProvideServices/PushTrackInput.cs | 12 +++
.../Services/ITrackPushCacheService.cs | 9 +++
.../OrderLinkAfterFillTrackHandler.cs | 4 +-
.../EventHandlers/TrackRefreshEventHandler.cs | 4 +-
...PushPullService.cs => TrackPullService.cs} | 27 +++----
.../ProvideServices/TrackPushService.cs | 77 +++++++++++++++++++
.../Services/ProvideServices/TrackService.cs | 8 +-
.../TrackPush/TrackPushCacheService.cs | 5 ++
.../OrderAggregate/IOrderRepository.cs | 15 ----
...derVO.cs => OrderWithServiceProviderVO.cs} | 2 +-
.../Queries/IProvideQueries.cs | 14 ++++
.../Queries/ProvideQueries.cs | 36 +++++++++
.../Repositories/OrderRepository.cs | 35 ---------
13 files changed, 176 insertions(+), 72 deletions(-)
create mode 100644 src/SJZY.Track.Application.Contract/Dtos/ProvideServices/PushTrackInput.cs
rename src/SJZY.Track.Application/Services/ProvideServices/{TrackPushPullService.cs => TrackPullService.cs} (79%)
create mode 100644 src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
rename src/SJZY.Track.Domain/Dtos/Order/{OrderServiceProviderVO.cs => OrderWithServiceProviderVO.cs} (92%)
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/Services/ITrackPushCacheService.cs b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
index acc00b72..12db0f65 100644
--- a/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
+++ b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
@@ -19,6 +19,15 @@ public interface ITrackPushCacheService
///
Task> GetPushContentConfigsAsync(int subSystemId, int customId);
+ ///
+ /// 获取服务商拉取配置
+ ///
+ /// 子系统id
+ /// 服务商id
+ ///
+ ///
+ Task GetPushContentConfigAsync(int subSystemId, int customId, int trackContentId);
+
///
/// 根据轨迹代码推断下一个(升序)要推送的内容,如果找不到或者已经是最后一个了,返回null
///
diff --git a/src/SJZY.Track.Application/EventHandlers/OrderLinkAfterFillTrackHandler.cs b/src/SJZY.Track.Application/EventHandlers/OrderLinkAfterFillTrackHandler.cs
index 80c5dda8..9335175a 100644
--- a/src/SJZY.Track.Application/EventHandlers/OrderLinkAfterFillTrackHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/OrderLinkAfterFillTrackHandler.cs
@@ -31,7 +31,7 @@ public class OrderLinkAfterFillTrackHandler : ITransientDependency, ICapSubscrib
var order = await _orderRepository.GetFirstAsync(x =>
x.Id == linkOrderId, x => new
{
- x.OrderType, x.OrderNo, x.CustomId, LatestPushCode = x.LatestPushTrackContentId, x.SubSystemId
+ x.OrderType, x.OrderNo, x.CustomId, x.LatestPushTrackContentId, x.SubSystemId
});
if (order == default) continue;
@@ -50,7 +50,7 @@ public class OrderLinkAfterFillTrackHandler : ITransientDependency, ICapSubscrib
OrderId = linkOrderId,
CustomId = order.CustomId,
SubSystemId = order.SubSystemId,
- LatestPushTrackContentId = order.LatestPushCode,
+ LatestPushTrackContentId = order.LatestPushTrackContentId,
UpSubSystemId = @event.SubSystemId,
};
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
index 5d74b758..e5207ee2 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
@@ -63,7 +63,7 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
var order = await _orderRepository.GetFirstAsync(x =>
x.OrderType == orderType && x.OrderNo == orderNo, x => new
{
- x.Id, x.SubSystemId, LatestPushCode = x.LatestPushTrackContentId, x.CustomId
+ x.Id, x.SubSystemId, x.LatestPushTrackContentId, x.CustomId
});
if (order == default) return;
@@ -73,7 +73,7 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
{
OrderId = order.Id,
SubSystemId = order.SubSystemId,
- LatestPushTrackContentId = order.LatestPushCode,
+ LatestPushTrackContentId = order.LatestPushTrackContentId,
CustomId = order.CustomId,
OrderType = orderType,
OrderNo = orderNo!,
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
similarity index 79%
rename from src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
rename to src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
index faa64a0f..e74ca894 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushPullService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
@@ -1,30 +1,31 @@
-using Newtonsoft.Json;
+using Microsoft.AspNetCore.Authorization;
+using Newtonsoft.Json;
using SJZY.Expand.ABP.Core;
using SJZY.InterfaceRelay.Application.Contracts;
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
using SJZY.Track.Application.Contract.Dtos.TrackPull;
using SJZY.Track.Application.Contract.Services;
-using SJZY.Track.Domain.Aggregates.OrderAggregate;
+using SJZY.Track.Domain.Queries;
using Volo.Abp.Http.Client.DynamicProxying;
namespace SJZY.Track.Application.Services.ProvideServices;
///
-/// 轨迹推送、拉取服务
+/// 轨迹刷新服务
///
[ApiExplorerSettings(GroupName = "提供接口")]
[Route("/ProviderService")]
-public class TrackPushPullService : ApplicationService
+public class TrackPullService : ApplicationService
{
- private readonly IOrderRepository _orderRepository;
+ private readonly IProvideQueries _provideQueries;
private readonly IHttpClientProxy _httpClientProxy;
private readonly ITrackPullCacheService _trackPullCacheService;
- public TrackPushPullService(IOrderRepository orderRepository,
+ public TrackPullService(IProvideQueries provideQueries,
IHttpClientProxy httpClientProxy,
ITrackPullCacheService trackPullCacheService)
{
- _orderRepository = orderRepository;
+ _provideQueries = provideQueries;
_httpClientProxy = httpClientProxy;
_trackPullCacheService = trackPullCacheService;
}
@@ -38,17 +39,16 @@ public class TrackPushPullService : ApplicationService
public async Task RefreshTrackAsync(RefreshTrackInput input)
{
// todo:罚时?
+ input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空
if (input.OrderNos.Count == 0)
{
- throw new BusinessException(message: "订单号数组不能为空");
+ throw new BusinessException(message: "订单一个都不存在");
}
- input.OrderNos = input.OrderNos.Distinct().ToList();
-
// 这里没有区分订单类型,就算的不同类型的单一起刷新了也无所谓
- var orderTemplates = await _orderRepository.FindServiceProviderByOrderAsync(input.OrderNos);
+ var orders = await _provideQueries.FindOrderWithServiceProviderAsync(input.OrderNos);
- foreach (var group in orderTemplates.GroupBy(x =>
+ foreach (var group in orders.GroupBy(x =>
new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId, x.OrderType)))
{
var data = group.Select(x => new
@@ -69,6 +69,7 @@ public class TrackPushPullService : ApplicationService
/// 定时任务刷新轨迹
///
///
+ [AllowAnonymous]
[HttpPost("Track/RefreshForTask")]
public async Task RefreshTrackAsync()
{
@@ -81,7 +82,7 @@ public class TrackPushPullService : ApplicationService
continue;
}
- var orders = await _orderRepository.FindOrderByServiceProviderAsync(config.ServiceProviderId);
+ var orders = await _provideQueries.FindOrderWithServiceProviderAsync(config.ServiceProviderId);
foreach (var group in orders.GroupBy(x =>
new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId,
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
new file mode 100644
index 00000000..10b28796
--- /dev/null
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
@@ -0,0 +1,77 @@
+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.TrackContentAggregate;
+using Volo.Abp.Http.Client.DynamicProxying;
+
+namespace SJZY.Track.Application.Services.ProvideServices;
+
+///
+/// 轨迹推送服务
+///
+[ApiExplorerSettings(GroupName = "提供接口")]
+[Route("/ProviderService")]
+public class TrackPushService : ApplicationService
+{
+ private readonly IOrderRepository _orderRepository;
+ private readonly ITrackContentRepository _trackContentRepository;
+ private readonly ITrackPushCacheService _pushCacheService;
+ private readonly IHttpClientProxy _httpClientProxy;
+
+ public TrackPushService(IOrderRepository orderRepository,
+ IHttpClientProxy httpClientProxy, ITrackPushCacheService pushCacheService,
+ ITrackContentRepository trackContentRepository)
+ {
+ _orderRepository = orderRepository;
+ _httpClientProxy = httpClientProxy;
+ _pushCacheService = pushCacheService;
+ _trackContentRepository = trackContentRepository;
+ }
+
+ ///
+ /// 推送轨迹
+ ///
+ ///
+ ///
+ [HttpPost("Track/Push")]
+ public async Task PushTrackAsync(PushTrackInput 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.CustomId
+ });
+
+ var trackContents = await _trackContentRepository.GetListAsync(x => x.Code == input.TrackCode, x => new
+ {
+ x.SubSystemId, x.Id
+ });
+
+ foreach (var group in orders.GroupBy(x =>
+ new { x.SubSystemId, x.CustomId }))
+ {
+ var trackContent = trackContents.FirstOrDefault(x => x.SubSystemId == group.Key.SubSystemId);
+ if (trackContent == null) continue;
+ await _pushCacheService.GetPushContentConfigAsync(group.Key.SubSystemId, group.Key.CustomId,
+ trackContent.Id);
+ var data = group.Select(x => new
+ {
+ x.OrderNo
+ }).ToList();
+
+ // 批量获取轨迹
+ // await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
+ // "A024", group.Key.ServiceProviderCode, data,
+ // GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
index b1c809d3..b9af7e6e 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
@@ -41,7 +41,7 @@ public partial class TrackService : ApplicationService, ITrackService
var order = await _orderRepository.GetFirstAsync(x =>
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new
{
- x.Id, x.SubSystemId, LatestPushCode = x.LatestPushTrackContentId, x.CustomId
+ x.Id, x.SubSystemId, x.LatestPushTrackContentId, x.CustomId
});
if (order == default)
{
@@ -52,7 +52,7 @@ public partial class TrackService : ApplicationService, ITrackService
var @event = ObjectMapper.Map(input);
@event.OrderId = order.Id;
@event.SubSystemId = order.SubSystemId;
- @event.LatestPushTrackContentId = order.LatestPushCode;
+ @event.LatestPushTrackContentId = order.LatestPushTrackContentId;
@event.CustomId = order.CustomId;
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
return true;
@@ -76,7 +76,7 @@ public partial class TrackService : ApplicationService, ITrackService
var orders = await _orderRepository.GetListAsync(x =>
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo), x => new
{
- x.Id, x.OrderNo, x.SubSystemId, LatestPushCode = x.LatestPushTrackContentId, x.CustomId
+ x.Id, x.OrderNo, x.SubSystemId, x.LatestPushTrackContentId, x.CustomId
});
foreach (var order in orders)
@@ -92,7 +92,7 @@ public partial class TrackService : ApplicationService, ITrackService
OrderNo = order.OrderNo,
OrderId = order.Id,
SubSystemId = order.SubSystemId,
- LatestPushTrackContentId = order.LatestPushCode,
+ LatestPushTrackContentId = order.LatestPushTrackContentId,
CustomId = order.CustomId
};
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
index eb11ae2c..d2bb3e2d 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
@@ -28,6 +28,11 @@ public class TrackPushCacheService : ITrackPushCacheService, ITransientDependenc
throw new NotImplementedException();
}
+ public Task GetPushContentConfigAsync(int subSystemId, int customId, int trackContentId)
+ {
+ throw new NotImplementedException();
+ }
+
public Task InferNextPushContentOrNullAsync(int subSystemId, int customId,
int? trackContentId)
{
diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs
index 2f99ba3f..acc0d4de 100644
--- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs
+++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs
@@ -50,19 +50,4 @@ public interface IOrderRepository : IBasicRepository
Task UnLinkByIdsAsync(List linkIds);
#endregion
-
-
- ///
- /// 根据订单模板找对应服务商
- ///
- ///
- ///
- Task> FindServiceProviderByOrderAsync(List orderNos);
-
- ///
- /// 获取服务商下所有单(未完成的)
- ///
- ///
- ///
- Task> FindOrderByServiceProviderAsync(int serviceProvider);
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Domain/Dtos/Order/OrderServiceProviderVO.cs b/src/SJZY.Track.Domain/Dtos/Order/OrderWithServiceProviderVO.cs
similarity index 92%
rename from src/SJZY.Track.Domain/Dtos/Order/OrderServiceProviderVO.cs
rename to src/SJZY.Track.Domain/Dtos/Order/OrderWithServiceProviderVO.cs
index 36a46aa8..df193e03 100644
--- a/src/SJZY.Track.Domain/Dtos/Order/OrderServiceProviderVO.cs
+++ b/src/SJZY.Track.Domain/Dtos/Order/OrderWithServiceProviderVO.cs
@@ -1,6 +1,6 @@
namespace SJZY.Track.Domain.Dtos.Order;
-public class OrderServiceProviderVO
+public class OrderWithServiceProviderVO
{
public string OrderNo { get; set; } = null!;
diff --git a/src/SJZY.Track.Domain/Queries/IProvideQueries.cs b/src/SJZY.Track.Domain/Queries/IProvideQueries.cs
index a3f8450c..2795df48 100644
--- a/src/SJZY.Track.Domain/Queries/IProvideQueries.cs
+++ b/src/SJZY.Track.Domain/Queries/IProvideQueries.cs
@@ -48,4 +48,18 @@ public interface IProvideQueries
///
///
Task> MapTrackCodesAsync(int upSubSystemId, int subSystemId, params string[] trackCodes);
+
+ ///
+ /// 根据订单模板找对应服务商
+ ///
+ ///
+ ///
+ Task> FindOrderWithServiceProviderAsync(List orderNos);
+
+ ///
+ /// 获取服务商下所有单(未完成的)
+ ///
+ ///
+ ///
+ Task> FindOrderWithServiceProviderAsync(int serviceProvider);
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Repository/Queries/ProvideQueries.cs b/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
index 04301286..8058689e 100644
--- a/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
+++ b/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
@@ -6,6 +6,7 @@ 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;
@@ -105,4 +106,39 @@ public class ProvideQueries : ISugarRepository, IProvideQueries,
.Select(x => x.TrackContentCode)
.ToListAsync();
}
+
+
+ public async Task> FindOrderWithServiceProviderAsync(List orderNos)
+ {
+ 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
+ {
+ 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/Repositories/OrderRepository.cs b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
index 47c0bb60..633db8c2 100644
--- a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
@@ -1,7 +1,6 @@
using SJZY.Track.Domain;
using SJZY.Track.Domain.Aggregates.OrderAggregate;
using SJZY.Track.Domain.Dtos.Order;
-using SJZY.Track.Domain.VEntities;
namespace SJZY.Track.Repository.Repositories;
@@ -84,38 +83,4 @@ public class OrderRepository : BasicRepository, IOrderRepository, I
}
#endregion
-
- public async Task> FindServiceProviderByOrderAsync(List orderNos)
- {
- 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 OrderServiceProviderVO
- {
- OrderNo = a.OrderNo,
- OrderType = a.OrderType,
- ServiceProviderId = b.ServiceProviderId,
- ServiceProviderCode = c.Code,
- SubSystemId = a.SubSystemId
- })
- .ToListAsync();
- }
-
- public async Task> FindOrderByServiceProviderAsync(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 OrderServiceProviderVO
- {
- OrderNo = a.OrderNo,
- OrderType = a.OrderType,
- ServiceProviderId = b.ServiceProviderId,
- ServiceProviderCode = c.Code,
- SubSystemId = a.SubSystemId
- })
- .ToListAsync();
- }
}
\ No newline at end of file
From b10f1cedfdf0ea5dc619dd44a0cba8a621fa041e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Fri, 15 Mar 2024 17:06:46 +0800
Subject: [PATCH 40/49] =?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../TrackPushContentConfigDto.cs | 13 +++++++
.../Services/ITrackPushCacheService.cs | 2 +-
.../TrackPush/TrackPushCacheService.cs | 39 ++++++++++++-------
.../Services/TrackPush/TrackPushService.cs | 2 +
4 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackPushContentConfigDto.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackPushContentConfigDto.cs
index ed2e02d0..578c298d 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackPushContentConfigDto.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackPushContentConfigDto.cs
@@ -1,5 +1,18 @@
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
+public class TrackPushConfigDto
+{
+ ///
+ /// 是否自动推送
+ ///
+ public bool IsAutoPush { get; set; }
+
+ ///
+ /// 轨迹推送内容配置
+ ///
+ public List ContentConfigs { get; set; }
+}
+
public class TrackPushContentConfigDto
{
///
diff --git a/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
index cc7fec74..77c35661 100644
--- a/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
+++ b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs
@@ -29,5 +29,5 @@ public interface ITrackPushCacheService
/// 子系统id
/// 客户id
///
- Task> SetPushContentConfigsAsync(int? id = null, int? subSystemId = null, int? customId = null);
+ Task SetPushContentConfigsAsync(int? id = null, int? subSystemId = null, int? customId = null);
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
index b5988ab3..c0eca26e 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
@@ -21,40 +21,39 @@ public class TrackPushCacheService : ApplicationService, ITrackPushCacheService,
[NonAction]
public async Task> GetPushContentConfigsAsync(int subSystemId, int customId)
{
- var data = await RedisHelper.Client.GetAsync>(TrackPushContentKey(subSystemId, customId));
+ var data = await GetPushConfigAsync(subSystemId, customId);
- data ??= await SetPushContentConfigsAsync(subSystemId: subSystemId, customId: customId);
-
- return data;
+ return data.ContentConfigs;
}
[NonAction]
public async Task InferNextPushContentOrNullAsync(int subSystemId, int customId, int? trackContentId)
{
- var data = await GetPushContentConfigsAsync(subSystemId, customId);
+ var data = await GetPushConfigAsync(subSystemId, customId);
+ if (!data.IsAutoPush) return null;
if (trackContentId.HasValue)
{
- if (data.Count > 1 && data.Any(x => x.TrackContentId == trackContentId))
+ if (data.ContentConfigs.Count > 1 && data.ContentConfigs.Any(x => x.TrackContentId == trackContentId))
{
- int index = data.FindIndex(x => x.TrackContentId == trackContentId);
- int nextIndex = (index + 1) % data.Count; // 计算下一个索引,处理最后一个元素的情况
+ int index = data.ContentConfigs.FindIndex(x => x.TrackContentId == trackContentId);
+ int nextIndex = (index + 1) % data.ContentConfigs.Count; // 计算下一个索引,处理最后一个元素的情况
- return data[nextIndex];
+ return data.ContentConfigs[nextIndex];
}
else return null;
}
- else return data.FirstOrDefault();
+ else return data.ContentConfigs.FirstOrDefault();
}
[NonAction]
- public async Task> SetPushContentConfigsAsync(int? id = null, int? subSystemId = null, int? customId = null)
+ public async Task SetPushContentConfigsAsync(int? id = null, int? subSystemId = null, int? customId = null)
{
- var data = new List();
+ var data = new TrackPushConfigDto { ContentConfigs = [] };
+
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;
+ 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;
@@ -64,10 +63,20 @@ public class TrackPushCacheService : ApplicationService, ITrackPushCacheService,
trackPushContentList = trackPushContentList.OrderBy(x => x.Sort).ToList();
- data = ObjectMapper.Map, List>(trackPushContentList);
+ data.IsAutoPush = trackPushConfigEntity.IsAutoPush;
+ data.ContentConfigs = ObjectMapper.Map, List>(trackPushContentList);
await RedisHelper.Client.SetAsync(TrackPushContentKey(trackPushConfigEntity.SubSystemId, trackPushConfigEntity.CustomId), data, (int)TimeSpan.FromDays(1).TotalSeconds);
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 e7498c2c..712bbc3c 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs
@@ -142,6 +142,8 @@ public class TrackPushService : ApplicationService
ts.Complete();
}
+
+ if (input.IsAutoPush!.Value) await _trackPushCacheService.SetPushContentConfigsAsync(input.Id);
}
break;
From 2845acce761db12249e993c9964e4dd001c2844f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Fri, 15 Mar 2024 17:10:11 +0800
Subject: [PATCH 41/49] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=9E=E7=8E=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/TrackPush/TrackPushCacheService.cs | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
index eb0f3910..0b8f4378 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
@@ -25,10 +25,13 @@ public class TrackPushCacheService : ApplicationService, ITrackPushCacheService,
return data.ContentConfigs;
}
-
- public Task GetPushContentConfigAsync(int subSystemId, int customId, int trackContentId)
+
+ [NonAction]
+ public async Task GetPushContentConfigAsync(int subSystemId, int customId, int trackContentId)
{
- throw new NotImplementedException();
+ var data = await GetPushContentConfigsAsync(subSystemId, customId);
+
+ return data.Single(x => x.TrackContentId == trackContentId);
}
[NonAction]
From b484a53711c37fd2d3920fc1d9ddc294af50141a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Fri, 15 Mar 2024 17:12:24 +0800
Subject: [PATCH 42/49] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=BC=93=E5=AD=98?=
=?UTF-8?q?=E6=97=B6=E9=97=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/TrackPull/TrackPullCacheService.cs | 3 +--
.../Services/TrackPush/TrackPushCacheService.cs | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
index 1a57ea08..b5418f24 100644
--- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullCacheService.cs
@@ -73,8 +73,7 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService,
trackPullContentList);
await RedisHelper.Client.SetAsync(
- TrackPullContentKey(trackPullConfigEntity.SubSystemId, trackPullConfigEntity.ServiceProviderId), data,
- (int)TimeSpan.FromDays(1).TotalSeconds);
+ TrackPullContentKey(trackPullConfigEntity.SubSystemId, trackPullConfigEntity.ServiceProviderId), data);
return data;
}
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
index 0b8f4378..30766856 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
@@ -74,7 +74,7 @@ public class TrackPushCacheService : ApplicationService, ITrackPushCacheService,
data.IsAutoPush = trackPushConfigEntity.IsAutoPush;
data.ContentConfigs = ObjectMapper.Map, List>(trackPushContentList);
- await RedisHelper.Client.SetAsync(TrackPushContentKey(trackPushConfigEntity.SubSystemId, trackPushConfigEntity.CustomId), data, (int)TimeSpan.FromDays(1).TotalSeconds);
+ await RedisHelper.Client.SetAsync(TrackPushContentKey(trackPushConfigEntity.SubSystemId, trackPushConfigEntity.CustomId), data);
return data;
}
From 25b7fc724ad359d09de2e26589806d14f11ad5f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Fri, 15 Mar 2024 17:47:10 +0800
Subject: [PATCH 43/49] =?UTF-8?q?=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../EventHandlers/TrackDeleteEventHandler.cs | 3 ++-
.../Services/ProvideServices/TrackPushService.cs | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackDeleteEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackDeleteEventHandler.cs
index 1994118d..1bbf3aac 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackDeleteEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackDeleteEventHandler.cs
@@ -76,7 +76,8 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
TrackEnContent = track.TrackEnContent,
TrackPlace = track.TrackPlace,
TrackTime = track.TrackTime,
- TrackTimeZone = track.TrackTimeZone
+ TrackTimeZone = track.TrackTimeZone,
+ IsDelete = true
};
await _capPublisher.PublishAsync(GlobalConst.UpdateOrderTrackSubscribe, updateOrderEvent);
}
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
index 10b28796..03e18f69 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
@@ -59,8 +59,8 @@ public class TrackPushService : ApplicationService
{
var trackContent = trackContents.FirstOrDefault(x => x.SubSystemId == group.Key.SubSystemId);
if (trackContent == null) continue;
- await _pushCacheService.GetPushContentConfigAsync(group.Key.SubSystemId, group.Key.CustomId,
- trackContent.Id);
+ var config = await _pushCacheService.GetPushContentConfigAsync(group.Key.SubSystemId,
+ group.Key.CustomId, trackContent.Id);
var data = group.Select(x => new
{
x.OrderNo
From 18f065fbf1f878e37dfe885a66f8b2b90690cdd2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com>
Date: Fri, 15 Mar 2024 17:50:29 +0800
Subject: [PATCH 44/49] =?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/TrackPush/TrackPushCacheService.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
index 30766856..61ddbcb5 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
@@ -57,7 +57,7 @@ public class TrackPushCacheService : ApplicationService, ITrackPushCacheService,
[NonAction]
public async Task SetPushContentConfigsAsync(int? id = null, int? subSystemId = null, int? customId = null)
{
- var data = new TrackPushConfigDto { ContentConfigs = [] };
+ var data = new TrackPushConfigDto { ContentConfigs = new() };
Expression> exp = x => true;
if (id.HasValue) exp = x => x.Id == id;
From d819dfe6d8f57831e1f1450f67332669a81b0390 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Sat, 16 Mar 2024 10:29:04 +0800
Subject: [PATCH 45/49] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../TrackPushContentConfigDto.cs | 7 +-
.../Events/TrackUpsertEvent.cs | 2 +-
.../ProvideServices/TrackPushService.cs | 70 ++++++++++++-------
.../TrackPush/TrackPushCacheService.cs | 35 ++++++----
.../ITrackDetailsRepository.cs | 2 +
.../TrackDetailsIndex.cs | 5 ++
.../Repositories/TrackDetailsRepository.cs | 16 +++--
7 files changed, 91 insertions(+), 46 deletions(-)
diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackPushContentConfigDto.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackPushContentConfigDto.cs
index 578c298d..64ae2569 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackPushContentConfigDto.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/TrackPushContentConfigDto.cs
@@ -10,11 +10,16 @@ public class TrackPushConfigDto
///
/// 轨迹推送内容配置
///
- public List ContentConfigs { get; set; }
+ public List ContentConfigs { get; set; } = new();
}
public class TrackPushContentConfigDto
{
+ ///
+ /// 服务商code
+ ///
+ public string ServiceProviderCode { get; set; } = null!;
+
///
/// 扩展字段参数值
///
diff --git a/src/SJZY.Track.Application.Contract/Events/TrackUpsertEvent.cs b/src/SJZY.Track.Application.Contract/Events/TrackUpsertEvent.cs
index 56032acb..5bbcbea6 100644
--- a/src/SJZY.Track.Application.Contract/Events/TrackUpsertEvent.cs
+++ b/src/SJZY.Track.Application.Contract/Events/TrackUpsertEvent.cs
@@ -20,7 +20,7 @@ public class TrackUpsertEvent : UpsertTrackInput
public int SubSystemId { get; set; }
///
- /// 最新推送代码(异步维护)
+ /// 最新推送轨迹内容id(异步维护)
///
public int? LatestPushTrackContentId { get; set; }
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
index 03e18f69..9febcaf7 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
@@ -2,7 +2,7 @@
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
using SJZY.Track.Application.Contract.Services;
using SJZY.Track.Domain.Aggregates.OrderAggregate;
-using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
+using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
using Volo.Abp.Http.Client.DynamicProxying;
namespace SJZY.Track.Application.Services.ProvideServices;
@@ -14,23 +14,23 @@ namespace SJZY.Track.Application.Services.ProvideServices;
[Route("/ProviderService")]
public class TrackPushService : ApplicationService
{
+ private readonly ITrackDetailsRepository _trackDetailsRepository;
private readonly IOrderRepository _orderRepository;
- private readonly ITrackContentRepository _trackContentRepository;
private readonly ITrackPushCacheService _pushCacheService;
private readonly IHttpClientProxy _httpClientProxy;
- public TrackPushService(IOrderRepository orderRepository,
+ public TrackPushService(
IHttpClientProxy httpClientProxy, ITrackPushCacheService pushCacheService,
- ITrackContentRepository trackContentRepository)
+ ITrackDetailsRepository trackDetailsRepository, IOrderRepository orderRepository)
{
- _orderRepository = orderRepository;
_httpClientProxy = httpClientProxy;
_pushCacheService = pushCacheService;
- _trackContentRepository = trackContentRepository;
+ _trackDetailsRepository = trackDetailsRepository;
+ _orderRepository = orderRepository;
}
///
- /// 推送轨迹
+ /// 手工推送轨迹
///
///
///
@@ -38,10 +38,7 @@ public class TrackPushService : ApplicationService
public async Task PushTrackAsync(PushTrackInput 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
@@ -49,27 +46,46 @@ public class TrackPushService : ApplicationService
x.Id, x.OrderNo, x.SubSystemId, x.CustomId
});
- var trackContents = await _trackContentRepository.GetListAsync(x => x.Code == input.TrackCode, x => new
+ if (input.OrderNos.Count == 0)
{
- x.SubSystemId, x.Id
- });
+ throw new BusinessException(message: "一个推送配置都不存在");
+ }
- foreach (var group in orders.GroupBy(x =>
- new { x.SubSystemId, x.CustomId }))
+ var tracks = await _trackDetailsRepository.GetListAsync(input.OrderType, input.OrderNos, input.TrackCode);
+
+ foreach (var order in orders)
{
- var trackContent = trackContents.FirstOrDefault(x => x.SubSystemId == group.Key.SubSystemId);
- if (trackContent == null) continue;
- var config = await _pushCacheService.GetPushContentConfigAsync(group.Key.SubSystemId,
- group.Key.CustomId, trackContent.Id);
- var data = group.Select(x => new
+ // 如果没有轨迹,就不需要推
+ 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
{
- x.OrderNo
- }).ToList();
+ 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.BatchForwardThenPushToQueueAsync(
- // "A024", group.Key.ServiceProviderCode, data,
- // GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
+ await _httpClientProxy.Service.ForwardWithSubscribeAsync("A024", config.ServiceProviderCode, data);
}
return true;
diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
index 61ddbcb5..36e386b8 100644
--- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
+++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs
@@ -1,8 +1,8 @@
-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 System.Linq.Expressions;
using Volo.Abp.DependencyInjection;
namespace SJZY.Track.Application.Services.TrackPush;
@@ -11,7 +11,8 @@ public class TrackPushCacheService : ApplicationService, ITrackPushCacheService,
{
private readonly ITrackPushConfigRepository _trackPushConfigRepository;
- private string TrackPushContentKey(int subSystemId, int customId) => $"{GlobalConst.TrackPushKeyPrefix}:{subSystemId}:{customId}";
+ private string TrackPushContentKey(int subSystemId, int customId) =>
+ $"{GlobalConst.TrackPushKeyPrefix}:{subSystemId}:{customId}";
public TrackPushCacheService(ITrackPushConfigRepository trackPushConfigRepository)
{
@@ -27,7 +28,8 @@ public class TrackPushCacheService : ApplicationService, ITrackPushCacheService,
}
[NonAction]
- public async Task GetPushContentConfigAsync(int subSystemId, int customId, int trackContentId)
+ public async Task GetPushContentConfigAsync(int subSystemId, int customId,
+ int trackContentId)
{
var data = await GetPushContentConfigsAsync(subSystemId, customId);
@@ -35,7 +37,8 @@ public class TrackPushCacheService : ApplicationService, ITrackPushCacheService,
}
[NonAction]
- public async Task InferNextPushContentOrNullAsync(int subSystemId, int customId, int? trackContentId)
+ public async Task InferNextPushContentOrNullAsync(int subSystemId, int customId,
+ int? trackContentId)
{
var data = await GetPushConfigAsync(subSystemId, customId);
if (!data.IsAutoPush) return null;
@@ -45,36 +48,44 @@ public class TrackPushCacheService : ApplicationService, ITrackPushCacheService,
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];
}
- else return null;
+
+ return null;
}
- else return data.ContentConfigs.FirstOrDefault();
+
+ return data.ContentConfigs.FirstOrDefault();
}
[NonAction]
- public async Task SetPushContentConfigsAsync(int? id = null, int? subSystemId = null, int? customId = null)
+ public async Task SetPushContentConfigsAsync(int? id = null, int? subSystemId = null,
+ int? customId = null)
{
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;
+ 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);
+ 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);
+ data.ContentConfigs =
+ ObjectMapper.Map, List>(trackPushContentList);
- await RedisHelper.Client.SetAsync(TrackPushContentKey(trackPushConfigEntity.SubSystemId, trackPushConfigEntity.CustomId), data);
+ await RedisHelper.Client.SetAsync(
+ TrackPushContentKey(trackPushConfigEntity.SubSystemId, trackPushConfigEntity.CustomId), data);
return data;
}
diff --git a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs
index 34cdac01..b0a1cf21 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs
@@ -10,6 +10,8 @@ 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);
diff --git a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs
index 812b2377..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; }
+
///
/// 订单号
///
diff --git a/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
index 8bc2739d..132341a1 100644
--- a/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
@@ -87,6 +87,11 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract> GetListAsync(int orderType, List orderNos, string trackCode)
+ {
+ throw new NotImplementedException();
+ }
+
public async Task> GetListAsync(int orderId)
{
var data = await Context.SearchAsync(x => x
@@ -134,11 +139,12 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract 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)
From 7e0911fd51e0629efd365168f19d62f38992059b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Sat, 16 Mar 2024 10:40:22 +0800
Subject: [PATCH 46/49] =?UTF-8?q?fix=E3=80=90=E3=80=90=E8=BD=A8=E8=BF=B9?=
=?UTF-8?q?=E8=AE=A2=E5=8D=95=E3=80=91=E8=BD=A8=E8=BF=B9=E6=98=8E=E7=BB=86?=
=?UTF-8?q?=E5=88=A0=E9=99=A4=E5=90=8E=EF=BC=8C=E5=88=97=E8=A1=A8=E4=B8=8B?=
=?UTF-8?q?=E5=8F=91=E7=9A=84=E6=95=B0=E6=8D=AE=E4=BB=8D=E6=98=BE=E7=A4=BA?=
=?UTF-8?q?=E8=BD=A8=E8=BF=B9=E6=98=8E=E7=BB=86=E4=BF=A1=E6=81=AF=E3=80=91?=
=?UTF-8?q?https://www.tapd.cn/60863849/bugtrace/bugs/view=3Fbug=5Fid=3D11?=
=?UTF-8?q?60863849001030812?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../EventHandlers/UpdateOrderTrackEventHandler.cs | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs
index 414a4afd..7eb5811a 100644
--- a/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/UpdateOrderTrackEventHandler.cs
@@ -29,10 +29,16 @@ public class UpdateOrderTrackEventHandler : ITransientDependency, ICapSubscribe
// 删除全部轨迹导致的重置行为
// tips:订单是支持从已完成态到未完成态的
order.ResetTrackInfo();
+
+ await _orderRepository.UpdateAsync(order);
+
+ return;
}
- else if (order.LatestTrackTime != null &&
- order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) ==
- @event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone))) return;
+
+ // 删除引发的回退更新
+ if (order.LatestTrackTime != null &&
+ order.LatestTrackTime.Value.Subtract(TimeSpan.FromHours(order.LatestTrackTimeZone ?? 0)) ==
+ @event.TrackTime.Subtract(TimeSpan.FromHours(@event.TrackTimeZone))) return;
}
else // upsert引发的更新
{
From 8d186fa985b97aab9de4f6c502851b3ce8729b77 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Sat, 16 Mar 2024 11:32:02 +0800
Subject: [PATCH 47/49] =?UTF-8?q?opt=E6=8F=90=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/ProvideServices/TrackPullService.cs | 10 ++++++----
.../Services/ProvideServices/TrackPushService.cs | 2 +-
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
index e74ca894..b9113abe 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
@@ -40,14 +40,16 @@ public class TrackPullService : ApplicationService
{
// todo:罚时?
input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空
- if (input.OrderNos.Count == 0)
- {
- throw new BusinessException(message: "订单一个都不存在");
- }
+
// 这里没有区分订单类型,就算的不同类型的单一起刷新了也无所谓
var orders = await _provideQueries.FindOrderWithServiceProviderAsync(input.OrderNos);
+ if (orders.Count == 0)
+ {
+ throw new BusinessException(message: "一个拉取配置都不存在");
+ }
+
foreach (var group in orders.GroupBy(x =>
new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId, x.OrderType)))
{
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
index 9febcaf7..443bceb3 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
@@ -46,7 +46,7 @@ public class TrackPushService : ApplicationService
x.Id, x.OrderNo, x.SubSystemId, x.CustomId
});
- if (input.OrderNos.Count == 0)
+ if (orders.Count == 0)
{
throw new BusinessException(message: "一个推送配置都不存在");
}
From 51b529ae9085db53a3554f04f52e370f22d6c5b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Sat, 16 Mar 2024 14:23:01 +0800
Subject: [PATCH 48/49] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3?=
=?UTF-8?q?=E9=80=9A7.1.6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dtos/TrackPull/TrackRefreshAttach.cs | 32 -------------------
.../Dtos/TrackPull/TrackRefreshDto.cs | 16 ++++++++++
.../EventHandlers/TrackRefreshEventHandler.cs | 2 +-
.../SJZY.Track.Application.csproj | 2 +-
.../ProvideServices/TrackPullService.cs | 29 ++++++++---------
5 files changed, 32 insertions(+), 49 deletions(-)
delete mode 100644 src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackRefreshAttach.cs
create mode 100644 src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackRefreshDto.cs
diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackRefreshAttach.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackRefreshAttach.cs
deleted file mode 100644
index ae47f35a..00000000
--- a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/TrackRefreshAttach.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
-
-public class TrackRefreshAttach
-{
- public TrackRefreshAttach(int serviceProviderId, string serviceProviderCode, int subSystemId, int orderType)
- {
- ServiceProviderId = serviceProviderId;
- ServiceProviderCode = serviceProviderCode;
- SubSystemId = subSystemId;
- OrderType = orderType;
- }
-
- ///
- /// 服务商id
- ///
- public int ServiceProviderId { get; set; }
-
- ///
- /// 服务商code
- ///
- public string ServiceProviderCode { get; set; }
-
- ///
- /// 订单类型(主数据枚举TrackOrderType)
- ///
- public int OrderType { get; set; }
-
- ///
- /// 子系统id
- ///
- public int SubSystemId { 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/EventHandlers/TrackRefreshEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
index e5207ee2..2ce214c6 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
@@ -32,7 +32,7 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
public async Task ConsumerAsync(InterfaceRelayForwardReplayEvent @event)
{
// tips:attach返回的是服务商id,必有
- var attach = JsonConvert.DeserializeObject(@event.Attach);
+ var attach = JsonConvert.DeserializeObject(@event.Attach);
if (attach is null) return;
var config =
await _trackPullCacheService.GetPullParamWithContentConfigAsync(attach.SubSystemId,
diff --git a/src/SJZY.Track.Application/SJZY.Track.Application.csproj b/src/SJZY.Track.Application/SJZY.Track.Application.csproj
index fc1c5423..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/TrackPullService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
index b9113abe..10f1d52a 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPullService.cs
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Authorization;
-using Newtonsoft.Json;
using SJZY.Expand.ABP.Core;
using SJZY.InterfaceRelay.Application.Contracts;
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
@@ -41,7 +40,6 @@ public class TrackPullService : ApplicationService
// todo:罚时?
input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空
-
// 这里没有区分订单类型,就算的不同类型的单一起刷新了也无所谓
var orders = await _provideQueries.FindOrderWithServiceProviderAsync(input.OrderNos);
@@ -50,18 +48,19 @@ public class TrackPullService : ApplicationService
throw new BusinessException(message: "一个拉取配置都不存在");
}
- foreach (var group in orders.GroupBy(x =>
- new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId, x.OrderType)))
+ foreach (var group in orders.GroupBy(x => x.ServiceProviderCode))
{
- var data = group.Select(x => new
+ var data = group.Select(x => new TrackRefreshDto
{
- x.OrderNo
+ OrderType = x.OrderType,
+ OrderNo = x.OrderNo,
+ ServiceProviderId = x.ServiceProviderId,
+ SubSystemId = x.SubSystemId
}).ToList();
// 批量获取轨迹
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
- "A012", group.Key.ServiceProviderCode, data,
- GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
+ "A012", group.Key, data, GlobalConst.TrackRefreshSubscribe);
}
return true;
@@ -86,19 +85,19 @@ public class TrackPullService : ApplicationService
var orders = await _provideQueries.FindOrderWithServiceProviderAsync(config.ServiceProviderId);
- foreach (var group in orders.GroupBy(x =>
- new TrackRefreshAttach(x.ServiceProviderId, x.ServiceProviderCode, x.SubSystemId,
- x.OrderType)))
+ foreach (var group in orders.GroupBy(x => x.ServiceProviderCode))
{
- var data = group.Select(x => new
+ var data = group.Select(x => new TrackRefreshDto
{
- x.OrderNo
+ OrderType = x.OrderType,
+ OrderNo = x.OrderNo,
+ ServiceProviderId = x.ServiceProviderId,
+ SubSystemId = x.SubSystemId
}).ToList();
// 批量获取轨迹
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
- "A012", group.Key.ServiceProviderCode, data,
- GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));
+ "A012", group.Key, data, GlobalConst.TrackRefreshSubscribe);
}
await RedisHelper.Client.SetExAsync(redisKey, config.PullInterval * 60, 1);
From df509216b356e6a5c42fe4b06065cf38d07ca67c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Sat, 16 Mar 2024 14:27:43 +0800
Subject: [PATCH 49/49] attach
---
.../EventHandlers/TrackRefreshEventHandler.cs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
index 2ce214c6..52c005f2 100644
--- a/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
+++ b/src/SJZY.Track.Application/EventHandlers/TrackRefreshEventHandler.cs
@@ -32,11 +32,11 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
public async Task ConsumerAsync(InterfaceRelayForwardReplayEvent @event)
{
// tips:attach返回的是服务商id,必有
- var attach = JsonConvert.DeserializeObject(@event.Attach);
- if (attach is null) return;
+ var refreshDto = JsonConvert.DeserializeObject>(@event.RequestParams)?.FirstOrDefault();
+ if (refreshDto is null) return;
var config =
- await _trackPullCacheService.GetPullParamWithContentConfigAsync(attach.SubSystemId,
- attach.ServiceProviderId);
+ await _trackPullCacheService.GetPullParamWithContentConfigAsync(refreshDto.SubSystemId,
+ refreshDto.ServiceProviderId);
var data = JObject.Parse(@event.Data.ToString()!);
var orderToken = data[config.ParamConfig.OrderPath];
@@ -44,12 +44,12 @@ public class TrackRefreshEventHandler : ITransientDependency, ICapSubscribe
{
foreach (var token in orderTokens)
{
- await HandleOrderAsync(token, config, attach.OrderType);
+ await HandleOrderAsync(token, config, refreshDto.OrderType);
}
}
else if (orderToken is JObject)
{
- await HandleOrderAsync(orderToken, config, attach.OrderType);
+ await HandleOrderAsync(orderToken, config, refreshDto.OrderType);
}
}