Merge branch 'S01-轨迹中台' of http://192.168.80.50:3000/Dotnet/SJZY.Track.Api into S01-轨迹中台

This commit is contained in:
moyongzhen 2024-03-02 14:20:31 +08:00
commit b8357b33d7
10 changed files with 57 additions and 25 deletions

View File

@ -7,7 +7,7 @@ public class UpdateTrackPullContentInput
/// <summary> /// <summary>
/// 服务商轨迹代码参数值 /// 服务商轨迹代码参数值
/// </summary> /// </summary>
public string TrackContentCodeValue { get; set; } public string? TrackContentCodeValue { get; set; }
/// <summary> /// <summary>
/// 轨迹内容id /// 轨迹内容id
@ -17,17 +17,17 @@ public class UpdateTrackPullContentInput
/// <summary> /// <summary>
/// 服务商轨迹内容参数值 /// 服务商轨迹内容参数值
/// </summary> /// </summary>
public string TrackContentValue { get; set; } public string? TrackContentValue { get; set; }
/// <summary> /// <summary>
/// 轨迹关键词(正向) /// 拉取轨迹关键字(正向)
/// </summary> /// </summary>
public string TrackKeyword { get; set; } public List<string>? TrackKeywords { get; set; }
/// <summary> /// <summary>
/// 轨迹关键词(反向) /// 拉取轨迹关键字(反向)
/// </summary> /// </summary>
public string TrackKeywordReverse { get; set; } public List<string>? TrackKeywordReverses { get; set; }
/// <summary> /// <summary>
/// 轨迹发生地参数值 /// 轨迹发生地参数值
@ -42,7 +42,7 @@ public class UpdateTrackPullContentInput
/// <summary> /// <summary>
/// 服务商轨迹状态参数值 /// 服务商轨迹状态参数值
/// </summary> /// </summary>
public string TrackStatusValue { get; set; } public string? TrackStatusValue { get; set; }
/// <summary> /// <summary>
/// 轨迹时区GMT /// 轨迹时区GMT

View File

@ -72,7 +72,7 @@ public class EditTrackPushConfigInput
/// <summary> /// <summary>
/// 轨迹模板id /// 轨迹模板id
/// </summary> /// </summary>
public List<int> TrackTemplateIds { get; set; } public List<int>? TrackTemplateIds { get; set; }
/// <summary> /// <summary>
/// 推送轨迹发生时间 /// 推送轨迹发生时间

View File

@ -12,6 +12,16 @@ public class TrackPullAutoMapperProfile : Profile
CreateMap<EditTrackPullConfigInput, TrackPullConfigEntity>(MemberList.None); CreateMap<EditTrackPullConfigInput, TrackPullConfigEntity>(MemberList.None);
CreateMap<EditTrackPullConfigInput, TrackPushPullParamsConfigEntity>(MemberList.None).Ignore(dest => dest.Id) CreateMap<EditTrackPullConfigInput, TrackPushPullParamsConfigEntity>(MemberList.None).Ignore(dest => dest.Id)
.ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => false)); .ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => false));
CreateMap<UpdateTrackPullContentInput, TrackPullContentConfigEntity>(MemberList.None); CreateMap<UpdateTrackPullContentInput, TrackPullContentConfigEntity>(MemberList.None)
.ForMember(dest => dest.TrackKeyword, opt =>
{
opt.Condition(src => !src.TrackKeywords.IsNullOrEmpty());
opt.MapFrom(src => string.Join(',', src.TrackKeywords));
})
.ForMember(dest => dest.TrackKeywordReverse, opt =>
{
opt.Condition(src => !src.TrackKeywordReverses.IsNullOrEmpty());
opt.MapFrom(src => string.Join(',', src.TrackKeywordReverses));
});
} }
} }

View File

@ -5,9 +5,11 @@ using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.Track.Application.Contract.Dtos.TrackPull; using SJZY.Track.Application.Contract.Dtos.TrackPull;
using SJZY.Track.Application.Localization; using SJZY.Track.Application.Localization;
using SJZY.Track.Domain.Aggregates.TrackPullAggregate; using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
using SJZY.Track.Domain.Dtos.Common; using SJZY.Track.Domain.Dtos.Common;
using SJZY.Track.Domain.Dtos.TrackPull; using SJZY.Track.Domain.Dtos.TrackPull;
using SqlSugar;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace SJZY.Track.Application.Services.TrackPull; namespace SJZY.Track.Application.Services.TrackPull;
@ -208,6 +210,18 @@ public class TrackPullService : ApplicationService, ITransientDependency
[HttpPost("UpdateContent")] [HttpPost("UpdateContent")]
public async Task<bool> UpdateContentAsync([FromBody] UpdateTrackPullContentInput input) public async Task<bool> UpdateContentAsync([FromBody] UpdateTrackPullContentInput input)
{ {
Expression<Func<TrackPullContentConfigEntity, bool>> isContentAnyExp = x => x.Id != input.Id && x.TrackPullConfigId == input.TrackPullConfigId;
var trackKeywordExp = Expressionable.Create<TrackPullContentConfigEntity>()
.And(x => x.TrackContentId == input.TrackContentId || x.TrackContentCodeValue == input.TrackContentCodeValue || x.TrackStatusValue == input.TrackStatusValue || x.TrackContentValue == input.TrackContentValue);
input.TrackKeywords?.ForEach(item => { trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item)); });
isContentAnyExp = isContentAnyExp.And(trackKeywordExp.ToExpression());
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp))
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentAny"]);
var oldTrackPullContentEntity = await _trackPullConfigRepository.GetContentByIdAsync(input.Id) ?? var oldTrackPullContentEntity = await _trackPullConfigRepository.GetContentByIdAsync(input.Id) ??
throw new BusinessException(message: _stringLocalizer["NotFindData"]); throw new BusinessException(message: _stringLocalizer["NotFindData"]);

View File

@ -199,7 +199,7 @@ public class TrackPushService : ApplicationService, ITransientDependency
if (input.Options != OptionTypeNoNull.删除) if (input.Options != OptionTypeNoNull.删除)
{ {
Expression<Func<TrackPushContentConfigEntity, bool>> isContentAnyExp = x => Expression<Func<TrackPushContentConfigEntity, bool>> isContentAnyExp = x =>
x.TrackPushConfigId == input.TrackPushConfigId && x.TrackContentId == input.TrackContentId; x.TrackPushConfigId == input.TrackPushConfigId && (x.TrackContentId == input.TrackContentId || x.TrackContentCodeValue == input.TrackContentCodeValue || x.TrackStatusValue == x.TrackStatusValue || x.TrackContentValue == input.TrackContentValue || x.TrackEnContentValue == input.TrackEnContentValue);
if (input.Options == OptionTypeNoNull.修改) isContentAnyExp = isContentAnyExp.And(x => x.Id != input.Id); if (input.Options == OptionTypeNoNull.修改) isContentAnyExp = isContentAnyExp.And(x => x.Id != input.Id);
if (await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp)) if (await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp))

View File

@ -48,4 +48,6 @@ public interface ITrackPullConfigRepository : IBasicRepository<TrackPullConfigEn
Task<TrackPullContentConfigEntity> GetContentByIdAsync(int id); Task<TrackPullContentConfigEntity> GetContentByIdAsync(int id);
Task<bool> UpdateContentAsync(TrackPullContentConfigEntity updateObj); Task<bool> UpdateContentAsync(TrackPullContentConfigEntity updateObj);
Task<bool> IsContentAnyAsync(Expression<Func<TrackPullContentConfigEntity, bool>> whereExpression);
} }

View File

@ -29,11 +29,21 @@ public class GetTrackPullContentDetailOutputVO
/// </summary> /// </summary>
public string TrackKeyword { get; set; } public string TrackKeyword { get; set; }
/// <summary>
/// 拉取轨迹关键字(正向)
/// </summary>
public List<string>? TrackKeywords { get; set; }
/// <summary> /// <summary>
/// 拉取轨迹关键字(反向) /// 拉取轨迹关键字(反向)
/// </summary> /// </summary>
public string TrackKeywordReverse { get; set; } public string TrackKeywordReverse { get; set; }
/// <summary>
/// 拉取轨迹关键字(反向)
/// </summary>
public List<string>? TrackKeywordReverses { get; set; }
/// <summary> /// <summary>
/// 拉取轨迹发生地 /// 拉取轨迹发生地
/// </summary> /// </summary>

View File

@ -34,21 +34,11 @@ public class GetTrackPullContentPageOutputVO
/// </summary> /// </summary>
public string? TrackKeyword { get; set; } public string? TrackKeyword { get; set; }
/// <summary>
/// 拉取轨迹关键字(正向)
/// </summary>
public List<string>? TrackKeywords { get; set; }
/// <summary> /// <summary>
/// 拉取轨迹关键字(反向) /// 拉取轨迹关键字(反向)
/// </summary> /// </summary>
public string? TrackKeywordReverse { get; set; } public string? TrackKeywordReverse { get; set; }
/// <summary>
/// 拉取轨迹关键字(反向)
/// </summary>
public List<string>? TrackKeywordsReverse { get; set; }
/// <summary> /// <summary>
/// 轨迹发生地 /// 轨迹发生地
/// </summary> /// </summary>

View File

@ -45,11 +45,6 @@ public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>,
{ {
Id = pullContent.Id Id = pullContent.Id
}, true) }, true)
.Mapper(x =>
{
x.TrackKeywords = x.TrackKeyword?.Split(',').ToList();
x.TrackKeywordsReverse = x.TrackKeywordReverse?.Split(',').ToList();
})
.ToPagedListAsync(input.PageIndex, input.PageSize); .ToPagedListAsync(input.PageIndex, input.PageSize);
} }
@ -82,6 +77,11 @@ public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>,
Id = pullContent.Id, Id = pullContent.Id,
Code = trackContent.Code + "-" + trackContent.Content, Code = trackContent.Code + "-" + trackContent.Content,
}, true) }, true)
.Mapper(x =>
{
x.TrackKeywords = x.TrackKeyword?.Split(',').ToList();
x.TrackKeywordReverses = x.TrackKeywordReverse?.Split(',').ToList();
})
.SingleAsync(); .SingleAsync();
} }
@ -130,4 +130,9 @@ public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>,
{ {
return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync(); return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync();
} }
public async Task<bool> IsContentAnyAsync(Expression<Func<TrackPullContentConfigEntity, bool>> whereExpression)
{
return await Context.Queryable<TrackPullContentConfigEntity>().Where(whereExpression).AnyAsync();
}
} }

View File

@ -99,6 +99,7 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
UpdateTime = templateContent.UpdateTime, UpdateTime = templateContent.UpdateTime,
UpdateUser = updateUser.Name UpdateUser = updateUser.Name
}, true) }, true)
.Distinct()
.ToPagedListAsync(input.PageIndex, input.PageSize); .ToPagedListAsync(input.PageIndex, input.PageSize);
} }