From 65ac8b2a50d16d12539b19ae8007dbf168a1c46b 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, 2 Apr 2024 09:23:54 +0800 Subject: [PATCH] =?UTF-8?q?com=EF=BC=9A=E5=AF=B9=E6=8E=A5=E8=BD=A8?= =?UTF-8?q?=E8=BF=B9=E6=A8=A1=E6=9D=BF-=E6=96=B0=E5=A2=9E=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=EF=BC=9A=E5=AF=B9=E5=A4=96=E6=98=BE=E7=A4=BA=E5=8E=9F?= =?UTF-8?q?=E8=BD=A8=E8=BF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/TrackTemplates/GetTrackDetailDto.cs | 10 +++ .../TrackTemplates/TrackTemplateService.cs | 64 ++++++++++--------- .../TrackTemplateEntity.cs | 6 ++ .../TrackTemplate/GetTrackTemplateDetailVO.cs | 7 +- .../Repositories/TrackTemplateRepository.cs | 34 ++++++---- 5 files changed, 76 insertions(+), 45 deletions(-) diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackTemplates/GetTrackDetailDto.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackTemplates/GetTrackDetailDto.cs index 08f7824d..51fc9c20 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/TrackTemplates/GetTrackDetailDto.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackTemplates/GetTrackDetailDto.cs @@ -29,6 +29,11 @@ /// 模版代码 /// public string Code { get; set; } + + /// + /// 显示原轨迹 + /// + public bool ShowOrigin { get; set; } } /// @@ -96,5 +101,10 @@ /// 模板代码 /// public string? Code { set; get; } + + /// + /// 显示原轨迹 + /// + public bool ShowOrigin { get; set; } } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs index f78c1ed3..6f1ce384 100644 --- a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs +++ b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs @@ -4,11 +4,8 @@ using SJZY.Expand.ABP.Core.Localization; using SJZY.Expand.ABP.Core.PublicMethords; using SJZY.Track.Application.Contract.Dtos.TrackTemplates; using SJZY.Track.Application.Localization; -using SJZY.Track.Domain.Aggregates.TrackPullAggregate; -using SJZY.Track.Domain.Aggregates.TrackPushAggregate; using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; using SJZY.Track.Domain.Dtos.TrackTemplate; -using Volo.Abp.DependencyInjection; namespace SJZY.Track.Application.Services.TrackTemplates; @@ -17,7 +14,7 @@ namespace SJZY.Track.Application.Services.TrackTemplates; /// [ApiExplorerSettings(GroupName = "轨迹模版")] [Route("/Track/Template")] -public class TrackTemplateService : ApplicationService, ITransientDependency +public class TrackTemplateService : ApplicationService { private readonly IStringLocalizer _stringLocalizer; private readonly ITrackTemplateRepository _trackTemplateRepository; @@ -26,7 +23,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency public TrackTemplateService( IStringLocalizer stringLocalizer, ITrackTemplateRepository trackTemplateRepository - ) + ) { _stringLocalizer = stringLocalizer; _trackTemplateRepository = trackTemplateRepository; @@ -93,7 +90,8 @@ 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"]); @@ -103,6 +101,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency { throw new BusinessException(message: "该子系统下模板代码已存在"); } + var trackTemplateName = templateEntitys.FirstOrDefault(t => t.Name == input.Name); if (trackTemplateName != null) { @@ -132,6 +131,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency { throw new BusinessException(message: "该子系统下模板代码已存在"); } + var trackTemplateName = templateEntitys.FirstOrDefault(t => t.Name == input.Name); if (trackTemplateName != null) { @@ -201,46 +201,48 @@ public class TrackTemplateService : ApplicationService, ITransientDependency switch (input.Options) { case OptionTypeNoNull.新增: - { - int maxSort = await _trackTemplateRepository.ContentMaxAsync(x => x.Sort, x => x.TrackTemplateId == input.TrackTemplateId); + { + int maxSort = await _trackTemplateRepository.ContentMaxAsync(x => x.Sort, + x => x.TrackTemplateId == input.TrackTemplateId); - var entity = ObjectMapper.Map(input); - entity.Sort = maxSort + 1; + var entity = ObjectMapper.Map(input); + entity.Sort = maxSort + 1; - await _trackTemplateRepository.InsertContentAsync(entity); + await _trackTemplateRepository.InsertContentAsync(entity); - break; - } + break; + } case OptionTypeNoNull.修改: - { - var entity = await _trackTemplateRepository.GetContentByIdAsync(input.Id!.Value) ?? - throw new BusinessException(message: _stringLocalizer["NotFindData"]); + { + var entity = await _trackTemplateRepository.GetContentByIdAsync(input.Id!.Value) ?? + throw new BusinessException(message: _stringLocalizer["NotFindData"]); - ObjectMapper.Map(input, entity); + ObjectMapper.Map(input, entity); - await _trackTemplateRepository.UpdateContentAsync(entity); + await _trackTemplateRepository.UpdateContentAsync(entity); - break; - } + break; + } case OptionTypeNoNull.删除: + { + var entity = await _trackTemplateRepository.GetContentByIdAsync(input.Id!.Value) ?? + throw new BusinessException(message: _stringLocalizer["NotFindData"]); + + using (var ts = TransactionScopeHelper.Create()) { - var entity = await _trackTemplateRepository.GetContentByIdAsync(input.Id!.Value) ?? - throw new BusinessException(message: _stringLocalizer["NotFindData"]); + await _trackTemplateRepository.SoftDeleteContentAsync(input.Id!.Value); - using (var ts = TransactionScopeHelper.Create()) - { - await _trackTemplateRepository.SoftDeleteContentAsync(input.Id!.Value); + await _trackTemplateRepository.UpdateContentAsync(x => x.Sort == x.Sort - 1, + x => x.TrackTemplateId == entity.TrackTemplateId && x.Sort > entity.Sort); - await _trackTemplateRepository.UpdateContentAsync(x => x.Sort == x.Sort - 1, x => x.TrackTemplateId == entity.TrackTemplateId && x.Sort > entity.Sort); - - ts.Complete(); - } - - break; + ts.Complete(); } + break; + } + default: throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum, nameof(EditTrackTemplateContentInput.Options)]); diff --git a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/TrackTemplateEntity.cs b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/TrackTemplateEntity.cs index ce861050..f99eaec0 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/TrackTemplateEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/TrackTemplateEntity.cs @@ -29,4 +29,10 @@ public class TrackTemplateEntity : IFullAuditedBasicEntitys, IAggregateRoot /// [SugarColumn(ColumnName = "SubSystemId")] public int SubSystemId { get; set; } + + /// + /// 显示原轨迹 + /// + [SugarColumn(ColumnName = "ShowOrigin")] + public bool ShowOrigin { get; set; } } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateDetailVO.cs b/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateDetailVO.cs index 46677e0e..c5230b7e 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateDetailVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateDetailVO.cs @@ -29,6 +29,11 @@ public class GetTrackTemplateDetailVO /// 模版代码 /// public string Code { get; set; } + + /// + /// 显示原轨迹 + /// + public bool ShowOrigin { get; set; } } /// @@ -59,7 +64,7 @@ public class GetTrackTemplateListVO /// /// 子系统id /// - public int SubSystemId { set; get; } + public int SubSystemId { set; get; } /// /// 创建时间 diff --git a/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs index 88ebb3ba..e14bea79 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs @@ -24,13 +24,14 @@ public class TrackTemplateRepository : BasicRepository, ITr .Where((a, b) => a.Id == id) .Select((a, b) => new GetTrackTemplateDetailVO - { - Id = a.Id, - Code = a.Code, - Name = a.Name, - SubSystemId = a.SubSystemId, - SubSystem = b.CnName - }).FirstAsync(); + { + Id = a.Id, + Code = a.Code, + Name = a.Name, + SubSystemId = a.SubSystemId, + SubSystem = b.CnName, + ShowOrigin = a.ShowOrigin + }).FirstAsync(); return detail; } @@ -48,7 +49,9 @@ public class TrackTemplateRepository : BasicRepository, ITr .WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (a, b) => a.Name.Contains(input.Keywords) || a.Code.Contains(input.Keywords)) .OrderByIF(input.SelectIds.IsNullOrEmpty(), (a, b) => a.CreateTime, OrderByType.Desc) - .OrderByIF(!input.SelectIds.IsNullOrEmpty(), (a, b) => SqlFunc.IIF(input.SelectIds.Contains(a.Id), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), a.CreateTime), OrderByType.Desc) + .OrderByIF(!input.SelectIds.IsNullOrEmpty(), + (a, b) => SqlFunc.IIF(input.SelectIds.Contains(a.Id), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), + a.CreateTime), OrderByType.Desc) .Select((a, b) => new GetTrackTemplateListVO { Id = a.Id, @@ -69,7 +72,8 @@ public class TrackTemplateRepository : BasicRepository, ITr /// 获取轨迹内容属性值 /// /// - public async Task GetTrackContentAttributeValue(GetTemplateContentAttributeValueInputVO input) + public async Task GetTrackContentAttributeValue( + GetTemplateContentAttributeValueInputVO input) { return null; } @@ -94,7 +98,8 @@ public class TrackTemplateRepository : BasicRepository, ITr (templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) => templateContent.UpdateUserId == updateUser.Id && !updateUser.IsDeleted) .Filter(null, true) - .Where(templateContent => input.TrackTemplateIds.Contains(templateContent.TrackTemplateId) && !templateContent.IsDeleted) + .Where(templateContent => input.TrackTemplateIds.Contains(templateContent.TrackTemplateId) && + !templateContent.IsDeleted) .Select((templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) => new GetTrackTemplateContentPageOutputVO { @@ -174,13 +179,16 @@ public class TrackTemplateRepository : BasicRepository, ITr return await Context.Updateable(updateObjs).ExecuteCommandHasChangeAsync(); } - public async Task ContentMaxAsync(Expression> columns, Expression> whereExpression) + public async Task ContentMaxAsync(Expression> columns, + Expression> whereExpression) { return await Context.Queryable().Where(whereExpression).MaxAsync(columns); } - public async Task UpdateContentAsync(Expression> columns, Expression> whereExpression) + public async Task UpdateContentAsync(Expression> columns, + Expression> whereExpression) { - return await Context.Updateable().SetColumns(columns).Where(whereExpression).ExecuteCommandHasChangeAsync(); + return await Context.Updateable().SetColumns(columns).Where(whereExpression) + .ExecuteCommandHasChangeAsync(); } } \ No newline at end of file