轨迹映射修改

This commit is contained in:
柳文翔 2024-03-08 09:50:02 +08:00
parent 8ab49cd4ff
commit 2e0a1f3e4d
22 changed files with 141 additions and 286 deletions

View File

@ -59,11 +59,6 @@ public class EditTrackPullConfigInput
/// </summary>
public string? TrackStatusName { get; set; }
/// <summary>
/// 轨迹模板id
/// </summary>
public int? TrackTemplateId { get; set; }
/// <summary>
/// 拉取轨迹发生时间
/// </summary>

View File

@ -1,8 +1,13 @@
namespace SJZY.Track.Application.Contract.Dtos.TrackPull;
public class UpdateTrackPullContentInput
public class EditTrackPullContentInput
{
public int Id { get; set; }
/// <summary>
/// 操作类型
/// </summary>
public OptionTypeNoNull Options { get; set; }
public int? Id { get; set; }
/// <summary>
/// 服务商轨迹代码参数值
@ -12,7 +17,7 @@ public class UpdateTrackPullContentInput
/// <summary>
/// 轨迹内容id
/// </summary>
public int TrackContentId { get; set; }
public int? TrackContentId { get; set; }
/// <summary>
/// 服务商轨迹内容参数值
@ -37,7 +42,7 @@ public class UpdateTrackPullContentInput
/// <summary>
/// 轨迹拉取配置id
/// </summary>
public int TrackPullConfigId { get; set; }
public int? TrackPullConfigId { get; set; }
/// <summary>
/// 服务商轨迹状态参数值

View File

@ -5,7 +5,7 @@ public class EditTrackPushConfigInput
/// <summary>
/// 客户id
/// </summary>
public int CustomId { get; set; }
public int? CustomId { get; set; }
/// <summary>
/// 推送扩展字段
@ -17,7 +17,7 @@ public class EditTrackPushConfigInput
/// <summary>
/// 是否自动推送
/// </summary>
public bool IsAutoPush { get; set; }
public bool? IsAutoPush { get; set; }
/// <summary>
/// 操作类型
@ -32,12 +32,12 @@ public class EditTrackPushConfigInput
/// <summary>
/// 服务商id
/// </summary>
public int ServiceProviderId { get; set; }
public int? ServiceProviderId { get; set; }
/// <summary>
/// 子系统id
/// </summary>
public int SubSystemId { get; set; }
public int? SubSystemId { get; set; }
/// <summary>
/// 推送轨迹时区
@ -69,13 +69,18 @@ public class EditTrackPushConfigInput
/// </summary>
public string? TrackStatusName { get; set; }
/// <summary>
/// 轨迹模板id
/// </summary>
public List<int>? TrackTemplateIds { get; set; }
/// <summary>
/// 推送轨迹发生时间
/// </summary>
public string? TrackTimeName { get; set; }
/// <summary>
/// 是否支持更新
/// </summary>
public bool? IsCanUpdate { get; set; }
/// <summary>
/// 是否支持删除
/// </summary>
public bool? IsCanDelete { get; set; }
}

View File

@ -12,7 +12,7 @@ public class TrackPullAutoMapperProfile : Profile
CreateMap<EditTrackPullConfigInput, TrackPullConfigEntity>(MemberList.None);
CreateMap<EditTrackPullConfigInput, TrackPushPullParamsConfigEntity>(MemberList.None).Ignore(dest => dest.Id)
.ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => false));
CreateMap<UpdateTrackPullContentInput, TrackPullContentConfigEntity>(MemberList.None)
CreateMap<EditTrackPullContentInput, TrackPullContentConfigEntity>(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)));
}

View File

@ -10,8 +10,7 @@ public class TrackPushAutoMapperProfile : Profile
{
public TrackPushAutoMapperProfile()
{
CreateMap<EditTrackPushConfigInput, TrackPushConfigEntity>(MemberList.None)
.ForMember(dest => dest.TrackTemplateId, opt => opt.MapFrom(source => string.Join(',', source.TrackTemplateIds)));
CreateMap<EditTrackPushConfigInput, TrackPushConfigEntity>(MemberList.None);
CreateMap<EditTrackPushConfigInput, TrackPushPullParamsConfigEntity>(MemberList.None).Ignore(dest => dest.Id)
.ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => true));
CreateMap<EditTrackPushContentInput, TrackPushContentConfigEntity>(MemberList.None);

View File

@ -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<Func<TrackPullConfigEntity, bool>> 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<EditTrackPullConfigInput, TrackPullConfigEntity>(input);
var trackPullParamsEntity =
ObjectMapper.Map<EditTrackPullConfigInput, TrackPushPullParamsConfigEntity>(input);
var trackTemplateContentEntities =
await _trackTemplateRepository.GetContentListAsync(x => x.TrackTemplateId == input.TrackTemplateId);
var trackPullContentEntities = new List<TrackPullContentConfigEntity>();
var trackPullParamsEntity = ObjectMapper.Map<EditTrackPullConfigInput, TrackPushPullParamsConfigEntity>(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<TrackPullContentConfigEntity>();
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
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("UpdateContent")]
public async Task<bool> UpdateContentAsync([FromBody] UpdateTrackPullContentInput input)
[HttpPost("EditContent")]
public async Task<bool> UpdateContentAsync([FromBody] EditTrackPullContentInput input)
{
Expression<Func<TrackPullContentConfigEntity, bool>> 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<Func<TrackPullContentConfigEntity, bool>> trackKeywordExp = _ => false;
input.TrackKeywords!.ForEach(item => { trackKeywordExp = trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item)); });
Expression<Func<TrackPullContentConfigEntity, bool>> 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<Func<TrackPullContentConfigEntity, bool>> 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<EditTrackPullContentInput, TrackPullContentConfigEntity>(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;
}

View File

@ -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<GetTrackPushConfigDetailOutputVO> GetDetailAsync(int id)
{
var res = await _trackPushConfigRepository.GetDetailAsync(id);
if (res is null) return null;
List<int> 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);
}
/// <summary>
@ -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<TrackPushConfigEntity>();
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();

View File

@ -21,21 +21,15 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
{
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
private readonly ITrackTemplateRepository _trackTemplateRepository;
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
private readonly ITrackPushConfigRepository _trackPushConfigRepository;
/// <inheritdoc/>
public TrackTemplateService(
IStringLocalizer<TrackLocalizationResource> stringLocalizer,
ITrackTemplateRepository trackTemplateRepository,
ITrackPullConfigRepository trackPullConfigRepository,
ITrackPushConfigRepository trackPushConfigRepository
ITrackTemplateRepository trackTemplateRepository
)
{
_stringLocalizer = stringLocalizer;
_trackTemplateRepository = trackTemplateRepository;
_trackPullConfigRepository = trackPullConfigRepository;
_trackPushConfigRepository = trackPushConfigRepository;
}
/// <summary>
@ -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<UnifyResultDto> 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);
}
/// <summary>
/// 轨迹模板内容下拉框
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("GetContentDropDownList")]
public async Task<UnifyPageResultDto<DropdownListDataDto>> GetContentDropDownListAsync([FromBody] GetTrackTemplateContentDropDownListVO input)
{
return await _trackTemplateRepository.GetContentDropDownListAsync(input);
}
/// <summary>
/// 轨迹模板内容编辑
/// </summary>

View File

@ -25,8 +25,6 @@ public class EditTrackPullConfigInputValidation : AbstractValidator<EditTrackPul
RuleFor(x => 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<EditTrackPul
RuleFor(x => 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)]);

View File

@ -35,7 +35,7 @@ public interface ITrackPullConfigRepository : IBasicRepository<TrackPullConfigEn
Task<bool> InsertParamsAsync(TrackPushPullParamsConfigEntity insertObj);
Task<bool> InsertContentRangeAsync(List<TrackPullContentConfigEntity> insertObjs);
Task<bool> InsertContentAsync(TrackPullContentConfigEntity insertObj);
Task<TrackPushPullParamsConfigEntity> GetParamsSingleAsync(Expression<Func<TrackPushPullParamsConfigEntity, bool>> whereExpression);

View File

@ -35,10 +35,4 @@ public class TrackPullConfigEntity : IFullAuditedBasicEntitys, IAggregateRoot
/// </summary>
[SugarColumn(ColumnName = "SubSystemId")]
public int SubSystemId { get; set; }
/// <summary>
/// 模板id
/// </summary>
[SugarColumn(ColumnName = "TrackTemplateId")]
public int TrackTemplateId { get; set; }
}

View File

@ -37,8 +37,14 @@ public class TrackPushConfigEntity : IFullAuditedBasicEntitys, IAggregateRoot
public int SubSystemId { get; set; }
/// <summary>
/// 模板id(多个之间英文逗号分隔)
/// 是否支持更新
/// </summary>
[SugarColumn(ColumnName = "TrackTemplateId")]
public string TrackTemplateId { get; set; }
[SugarColumn(ColumnName = "IsCanUpdate")]
public bool IsCanUpdate { get; set; }
/// <summary>
/// 是否支持删除
/// </summary>
[SugarColumn(ColumnName = "IsCanDelete")]
public bool IsCanDelete { get; set; }
}

View File

@ -39,8 +39,6 @@ public interface ITrackTemplateRepository : IBasicRepository<TrackTemplateEntity
Task<bool> UpdateContentRangeAsync(List<TrackTemplateContentEntity> updateObjs);
Task<UnifyPageResultDto<DropdownListDataDto>> GetContentDropDownListAsync(GetTrackTemplateContentDropDownListVO input);
Task<T> ContentMaxAsync<T>(Expression<Func<TrackTemplateContentEntity, T>> columns, Expression<Func<TrackTemplateContentEntity, bool>> whereExpression);
Task<bool> UpdateContentAsync(Expression<Func<TrackTemplateContentEntity, bool>> columns, Expression<Func<TrackTemplateContentEntity, bool>> whereExpression);

View File

@ -64,16 +64,6 @@ public class GetTrackPullConfigDetailOutputVO
/// </summary>
public string TrackStatusName { get; set; }
/// <summary>
/// 轨迹模板
/// </summary>
public string TrackTemplate { get; set; }
/// <summary>
/// 轨迹模板id
/// </summary>
public int TrackTemplateId { get; set; }
/// <summary>
/// 拉取轨迹发生时间
/// </summary>

View File

@ -18,9 +18,4 @@ public class GetTrackPullConfigPageOutputVO
/// 子系统名称
/// </summary>
public string SubSystem { get; set; }
/// <summary>
/// 模板名称
/// </summary>
public string TrackTemplate { get; set; }
}

View File

@ -81,23 +81,18 @@ public class GetTrackPushConfigDetailOutputVO
/// </summary>
public string TrackStatusName { get; set; }
/// <summary>
/// 轨迹模板
/// </summary>
public List<DropdownListDataDto> TrackTemplate { get; set; }
/// <summary>
/// 轨迹模板id
/// </summary>
public string TrackTemplateId { get; set; }
/// <summary>
/// 轨迹模板ids
/// </summary>
public List<int> TrackTemplateIds { get; set; }
/// <summary>
/// 推送轨迹发生时间
/// </summary>
public string TrackTimeName { get; set; }
/// <summary>
/// 是否支持更新
/// </summary>
public bool IsCanUpdate { get; set; }
/// <summary>
/// 是否支持删除
/// </summary>
public bool IsCanDelete { get; set; }
}

View File

@ -18,19 +18,4 @@ public class GetTrackPushConfigPageOutputVO
/// 子系统名称
/// </summary>
public string SubSystem { get; set; }
/// <summary>
/// 模板名称
/// </summary>
public string TrackTemplate { get; set; }
/// <summary>
/// 轨迹模板id
/// </summary>
public string TrackTemplateId { get; set; }
/// <summary>
/// 轨迹模板ids
/// </summary>
public List<int> TrackTemplateIds { get; set; }
}

View File

@ -1,14 +0,0 @@
namespace SJZY.Track.Domain.Dtos.TrackTemplate;
public class GetTrackTemplateContentDropDownListVO : PageInfoInput
{
/// <summary>
/// 轨迹模板id
/// </summary>
public List<int> TrackTemplateIds { get; set; }
/// <summary>
/// 选中项
/// </summary>
public List<int>? SelectedIds { get; set; }
}

View File

@ -15,5 +15,10 @@ public enum EnumPropertyEnums
/// <summary>
/// 单号类型
/// </summary>
[Description("TrackOrderType")] 单号类型
[Description("TrackOrderType")] 单号类型,
/// <summary>
/// 轨迹发生地
/// </summary>
[Description("TrackLocationValue")] 轨迹发生地
}

View File

@ -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<TrackPullConfigEntity>,
return await AsQueryable()
.LeftJoin<VSystemEntity>((trackPull, system) => trackPull.SubSystemId == system.Id && !system.IsDeleted)
.LeftJoin<VServiceProviderEntity>((trackPull, system, service) => trackPull.ServiceProviderId == service.Id && !service.IsDeleted)
.LeftJoin<TrackTemplateEntity>((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<TrackPullConfigEntity>,
return await Context.Queryable<TrackPullContentConfigEntity>()
.InnerJoin<TrackContentEntity>((pullContent, trackContent) => pullContent.TrackContentId == trackContent.Id)
.InnerJoin<TrackPullConfigEntity>((pullContent, trackContent, trackPull) => pullContent.TrackPullConfigId == trackPull.Id)
.InnerJoin<TrackTemplateContentEntity>((pullContent, trackContent, trackPull, templateContent) => trackPull.TrackTemplateId == templateContent.TrackTemplateId && pullContent.TrackContentId == templateContent.TrackContentId)
.LeftJoin<VEnumValueInfoEntity>((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<TrackPullConfigEntity>,
return await AsQueryable()
.LeftJoin<VSystemEntity>((trackPull, system) => trackPull.SubSystemId == system.Id && !system.IsDeleted)
.LeftJoin<VServiceProviderEntity>((trackPull, system, service) => trackPull.ServiceProviderId == service.Id && !service.IsDeleted)
.LeftJoin<TrackTemplateEntity>((trackPull, system, service, template) => trackPull.TrackTemplateId == template.Id && !template.IsDeleted)
.InnerJoin<TrackPushPullParamsConfigEntity>((trackPull, system, service, template, paramsConfig) => trackPull.Id == paramsConfig.PullOrPushConfigId && !paramsConfig.IsPush && !paramsConfig.IsDeleted)
.InnerJoin<TrackPushPullParamsConfigEntity>((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<TrackPullConfigEntity>,
return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0;
}
public async Task<bool> InsertContentRangeAsync(List<TrackPullContentConfigEntity> insertObjs)
public async Task<bool> InsertContentAsync(TrackPullContentConfigEntity insertObj)
{
return await Context.Insertable(insertObjs).ExecuteCommandAsync() > 0;
return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0;
}
public async Task<TrackPushPullParamsConfigEntity> GetParamsSingleAsync(Expression<Func<TrackPushPullParamsConfigEntity, bool>> whereExpression)

View File

@ -20,25 +20,18 @@ public class TrackPushConfigRepository : BasicRepository<TrackPushConfigEntity>,
return await AsQueryable()
.LeftJoin<VSystemEntity>((trackPush, system) => trackPush.SubSystemId == system.Id && !system.IsDeleted)
.LeftJoin<VExternalSubjectEntity>((trackPush, system, externalSubject) => trackPush.CustomId == externalSubject.Id && !externalSubject.IsDeleted)
.LeftJoin<TrackTemplateEntity>((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<TrackTemplateEntity>()
.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<TrackPushConfigEntity>,
CustomName = externalSubject.Abbreviation,
ServiceProvider = service.Name,
}, true)
.Mapper(x => { x.TrackTemplateIds = x.TrackTemplateId.Split(',').Select(int.Parse).ToList(); })
.SingleAsync();
}

View File

@ -71,8 +71,6 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
/// <returns></returns>
public async Task<GetTemplateContentAttributeValueVO> GetTrackContentAttributeValue(GetTemplateContentAttributeValueInputVO input)
{
return null;
}
@ -176,22 +174,6 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
return await Context.Updateable(updateObjs).ExecuteCommandHasChangeAsync();
}
public async Task<UnifyPageResultDto<DropdownListDataDto>> GetContentDropDownListAsync(GetTrackTemplateContentDropDownListVO input)
{
return await Context.Queryable<TrackTemplateContentEntity>()
.InnerJoin<TrackContentEntity>((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<T> ContentMaxAsync<T>(Expression<Func<TrackTemplateContentEntity, T>> columns, Expression<Func<TrackTemplateContentEntity, bool>> whereExpression)
{
return await Context.Queryable<TrackTemplateContentEntity>().Where(whereExpression).MaxAsync(columns);