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);