fix:拉取-轨迹状态多选,逗号分隔

fix:修复空字符串的spilt问题
This commit is contained in:
xiaolipro 2024-09-26 17:17:14 +08:00
parent 651ec3131e
commit 7d583b6734
6 changed files with 46 additions and 18 deletions

View File

@ -10,17 +10,17 @@ public class TrackPullContentConfigDto
/// <summary>
/// 服务商轨迹状态参数值
/// </summary>
public string? TrackStatusValue { get; set; }
public List<string> TrackStatusValues { get; set; } = new();
/// <summary>
/// 轨迹关键词(正向),多个逗分隔
/// 轨迹关键词(正向)
/// </summary>
public string? TrackKeyword { get; set; }
public List<string> TrackKeywords { get; set; } = new();
/// <summary>
/// 轨迹关键词(反向),多个逗分隔
/// 轨迹关键词(反向)
/// </summary>
public string? TrackKeywordReverse { get; set; }
public List<string> TrackKeywordReverses { get; set; } = new();
/// <summary>
/// 轨迹发生地参数值(主数据枚举)

View File

@ -21,6 +21,7 @@ public class TrackPullAutoMapperProfile : Profile
opt => opt.MapFrom(src => string.Join(',', src.TrackKeywordReverses ?? Enumerable.Empty<string>())))
.ForMember(dest => dest.TrackZonePlaceValue, opt => opt.MapFrom(src => src.TrackTimePlaceValue));
CreateMap<GetTrackPullConfigDetailOutputVO, TrackPullParamConfigDto>(MemberList.None);
CreateMap<GetTrackPullContentListCacheVO, TrackPullContentConfigDto>(MemberList.None);
CreateMap<PullConfigInfo, UpdateOrderPullConfigsInputVo>(MemberList.None);

View File

@ -168,7 +168,7 @@ public class TrackRefreshEventHandler : ITransientDependency, IRabbitHandler
var trackStatus = trackToken[paramConfig.TrackStatusName!]?.Value<string>();
if (!trackStatus.IsNullOrWhiteSpace())
{
matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackStatusValue == trackStatus);
matchedContentConfig = contentConfigs.FirstOrDefault(x => x.TrackStatusValues.Contains(trackStatus!));
}
}
@ -183,7 +183,7 @@ public class TrackRefreshEventHandler : ITransientDependency, IRabbitHandler
// 3.2 按关键字分析轨迹内容
foreach (var contentConfig in contentConfigs)
{
foreach (var keyword in contentConfig.TrackKeyword?.Split(',') ?? Enumerable.Empty<string>())
foreach (var keyword in contentConfig.TrackKeywords)
{
if (trackContent.Contains(keyword, StringComparison.OrdinalIgnoreCase))
{
@ -194,8 +194,7 @@ public class TrackRefreshEventHandler : ITransientDependency, IRabbitHandler
if (matchedContentConfig is null) continue;
foreach (var keyword in contentConfig.TrackKeywordReverse?.Split(',') ??
Enumerable.Empty<string>())
foreach (var keyword in contentConfig.TrackKeywordReverses)
{
if (trackContent.Contains(keyword, StringComparison.OrdinalIgnoreCase))
{

View File

@ -25,7 +25,7 @@ public class TrackPullContentConfigEntity : IFullAuditedBasicEntitys, IEntity
public int TrackContentId { get; set; }
/// <summary>
/// 服务商轨迹状态参数值
/// 服务商轨迹状态参数值,多个逗分隔
/// </summary>
[SugarColumn(ColumnName = "TrackStatusValue")]
public string? TrackStatusValue { get; set; }

View File

@ -7,11 +7,6 @@ public class GetTrackPullContentListCacheVO
/// </summary>
public string TrackContentCode { get; set; }
/// <summary>
/// 是否完成
/// </summary>
public bool IsCompleted { get; set; }
/// <summary>
/// 服务商轨迹状态参数值
/// </summary>
@ -27,6 +22,21 @@ public class GetTrackPullContentListCacheVO
/// </summary>
public string? TrackKeywordReverse { get; set; }
/// <summary>
/// 服务商轨迹状态参数值
/// </summary>
public List<string> TrackStatusValues { get; set; } = new();
/// <summary>
/// 轨迹关键词(正向)
/// </summary>
public List<string> TrackKeywords { get; set; } = new();
/// <summary>
/// 轨迹关键词(反向)
/// </summary>
public List<string> TrackKeywordReverses { get; set; } = new();
/// <summary>
/// 兜底轨迹发生地参数值
/// </summary>

View File

@ -65,8 +65,19 @@ public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>,
new GetTrackPullContentListCacheVO
{
TrackContentCode = trackContent.Code,
IsCompleted = trackStutas.IsCompleted
}, true)
.Mapper(x =>
{
x.TrackKeywords = x.TrackKeyword.IsNullOrWhiteSpace()
? new List<string>()
: x.TrackKeyword!.Split(',').ToList();
x.TrackKeywordReverses = x.TrackKeywordReverse.IsNullOrWhiteSpace()
? new List<string>()
: x.TrackKeywordReverse!.Split(',').ToList();
x.TrackStatusValues = x.TrackStatusValue.IsNullOrWhiteSpace()
? new List<string>()
: x.TrackStatusValue!.Split(',').ToList();
})
.ToListAsync();
}
@ -102,8 +113,15 @@ public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>,
}, true)
.Mapper(x =>
{
x.TrackKeywords = x.TrackKeyword?.Split(',').ToList();
x.TrackKeywordReverses = x.TrackKeywordReverse?.Split(',').ToList();
x.TrackKeywords = x.TrackKeyword.IsNullOrWhiteSpace()
? new List<string>()
: x.TrackKeyword!.Split(',').ToList();
x.TrackKeywordReverses = x.TrackKeywordReverse.IsNullOrWhiteSpace()
? new List<string>()
: x.TrackKeywordReverse!.Split(',').ToList();
x.TrackStatusValues = x.TrackStatusValue.IsNullOrWhiteSpace()
? new List<string>()
: x.TrackStatusValue!.Split(',').ToList();
})
.SingleAsync();
}