com:对接轨迹模板-新增字段:对外显示原轨迹

This commit is contained in:
李鹏军 2024-04-02 09:23:54 +08:00
parent 4db7cdbdf8
commit 65ac8b2a50
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;
@ -26,7 +23,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
public TrackTemplateService(
IStringLocalizer<TrackLocalizationResource> 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<EditTrackTemplateContentInput, TrackTemplateContentEntity>(input);
entity.Sort = maxSort + 1;
var entity = ObjectMapper.Map<EditTrackTemplateContentInput, TrackTemplateContentEntity>(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)]);

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>
@ -59,7 +64,7 @@ public class GetTrackTemplateListVO
/// <summary>
/// 子系统id
/// </summary>
public int SubSystemId { set; get; }
public int SubSystemId { set; get; }
/// <summary>
/// 创建时间

View File

@ -24,13 +24,14 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, 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<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();
}
}