Merge branch 'S03-轨迹中台' into dev

This commit is contained in:
李鹏军 2024-04-02 09:24:12 +08:00
commit 29bf3ae1b7
5 changed files with 76 additions and 45 deletions

View File

@ -29,6 +29,11 @@
/// 模版代码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 显示原轨迹
/// </summary>
public bool ShowOrigin { get; set; }
}
/// <summary>
@ -96,5 +101,10 @@
/// 模板代码
/// </summary>
public string? Code { set; get; }
/// <summary>
/// 显示原轨迹
/// </summary>
public bool ShowOrigin { get; set; }
}
}

View File

@ -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;
/// </summary>
[ApiExplorerSettings(GroupName = "轨迹模版")]
[Route("/Track/Template")]
public class TrackTemplateService : ApplicationService, ITransientDependency
public class TrackTemplateService : ApplicationService
{
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
private readonly ITrackTemplateRepository _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)
{
@ -202,7 +202,8 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
{
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<EditTrackTemplateContentInput, TrackTemplateContentEntity>(input);
entity.Sort = maxSort + 1;
@ -233,7 +234,8 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
{
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();
}

View File

@ -29,4 +29,10 @@ public class TrackTemplateEntity : IFullAuditedBasicEntitys, IAggregateRoot
/// </summary>
[SugarColumn(ColumnName = "SubSystemId")]
public int SubSystemId { get; set; }
/// <summary>
/// 显示原轨迹
/// </summary>
[SugarColumn(ColumnName = "ShowOrigin")]
public bool ShowOrigin { get; set; }
}

View File

@ -29,6 +29,11 @@ public class GetTrackTemplateDetailVO
/// 模版代码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 显示原轨迹
/// </summary>
public bool ShowOrigin { get; set; }
}
/// <summary>

View File

@ -29,7 +29,8 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
Code = a.Code,
Name = a.Name,
SubSystemId = a.SubSystemId,
SubSystem = b.CnName
SubSystem = b.CnName,
ShowOrigin = a.ShowOrigin
}).FirstAsync();
return detail;
@ -48,7 +49,9 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, 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<TrackTemplateEntity>, ITr
/// 获取轨迹内容属性值
/// </summary>
/// <returns></returns>
public async Task<GetTemplateContentAttributeValueVO> GetTrackContentAttributeValue(GetTemplateContentAttributeValueInputVO input)
public async Task<GetTemplateContentAttributeValueVO> GetTrackContentAttributeValue(
GetTemplateContentAttributeValueInputVO input)
{
return null;
}
@ -94,7 +98,8 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, 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<TrackTemplateEntity>, ITr
return await Context.Updateable(updateObjs).ExecuteCommandHasChangeAsync();
}
public async Task<T> ContentMaxAsync<T>(Expression<Func<TrackTemplateContentEntity, T>> columns, Expression<Func<TrackTemplateContentEntity, bool>> whereExpression)
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);
}
public async Task<bool> UpdateContentAsync(Expression<Func<TrackTemplateContentEntity, bool>> columns, Expression<Func<TrackTemplateContentEntity, bool>> whereExpression)
public async Task<bool> UpdateContentAsync(Expression<Func<TrackTemplateContentEntity, bool>> columns,
Expression<Func<TrackTemplateContentEntity, bool>> whereExpression)
{
return await Context.Updateable<TrackTemplateContentEntity>().SetColumns(columns).Where(whereExpression).ExecuteCommandHasChangeAsync();
return await Context.Updateable<TrackTemplateContentEntity>().SetColumns(columns).Where(whereExpression)
.ExecuteCommandHasChangeAsync();
}
}