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> /// </summary>
public string Code { get; set; } public string Code { get; set; }
/// <summary>
/// 显示原轨迹
/// </summary>
public bool ShowOrigin { get; set; }
} }
/// <summary> /// <summary>
@ -96,5 +101,10 @@
/// 模板代码 /// 模板代码
/// </summary> /// </summary>
public string? Code { set; get; } 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.Expand.ABP.Core.PublicMethords;
using SJZY.Track.Application.Contract.Dtos.TrackTemplates; using SJZY.Track.Application.Contract.Dtos.TrackTemplates;
using SJZY.Track.Application.Localization; 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.Aggregates.TrackTemplateAggregate;
using SJZY.Track.Domain.Dtos.TrackTemplate; using SJZY.Track.Domain.Dtos.TrackTemplate;
using Volo.Abp.DependencyInjection;
namespace SJZY.Track.Application.Services.TrackTemplates; namespace SJZY.Track.Application.Services.TrackTemplates;
@ -17,7 +14,7 @@ namespace SJZY.Track.Application.Services.TrackTemplates;
/// </summary> /// </summary>
[ApiExplorerSettings(GroupName = "轨迹模版")] [ApiExplorerSettings(GroupName = "轨迹模版")]
[Route("/Track/Template")] [Route("/Track/Template")]
public class TrackTemplateService : ApplicationService, ITransientDependency public class TrackTemplateService : ApplicationService
{ {
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer; private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
private readonly ITrackTemplateRepository _trackTemplateRepository; private readonly ITrackTemplateRepository _trackTemplateRepository;
@ -26,7 +23,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
public TrackTemplateService( public TrackTemplateService(
IStringLocalizer<TrackLocalizationResource> stringLocalizer, IStringLocalizer<TrackLocalizationResource> stringLocalizer,
ITrackTemplateRepository trackTemplateRepository ITrackTemplateRepository trackTemplateRepository
) )
{ {
_stringLocalizer = stringLocalizer; _stringLocalizer = stringLocalizer;
_trackTemplateRepository = trackTemplateRepository; _trackTemplateRepository = trackTemplateRepository;
@ -93,7 +90,8 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
//var templateEntity = //var templateEntity =
// await _trackTemplateRepository.GetFirstAsync( // await _trackTemplateRepository.GetFirstAsync(
// a => a.SubSystemId == input.SubSystemId && a.Code == input.Code); // 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()) if (templateEntitys.Any())
{ {
//throw new BusinessException(message: _stringLocalizer["TemplateExist"]); //throw new BusinessException(message: _stringLocalizer["TemplateExist"]);
@ -103,6 +101,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
{ {
throw new BusinessException(message: "该子系统下模板代码已存在"); throw new BusinessException(message: "该子系统下模板代码已存在");
} }
var trackTemplateName = templateEntitys.FirstOrDefault(t => t.Name == input.Name); var trackTemplateName = templateEntitys.FirstOrDefault(t => t.Name == input.Name);
if (trackTemplateName != null) if (trackTemplateName != null)
{ {
@ -132,6 +131,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
{ {
throw new BusinessException(message: "该子系统下模板代码已存在"); throw new BusinessException(message: "该子系统下模板代码已存在");
} }
var trackTemplateName = templateEntitys.FirstOrDefault(t => t.Name == input.Name); var trackTemplateName = templateEntitys.FirstOrDefault(t => t.Name == input.Name);
if (trackTemplateName != null) if (trackTemplateName != null)
{ {
@ -201,46 +201,48 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
switch (input.Options) switch (input.Options)
{ {
case OptionTypeNoNull.新增: 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); var entity = ObjectMapper.Map<EditTrackTemplateContentInput, TrackTemplateContentEntity>(input);
entity.Sort = maxSort + 1; entity.Sort = maxSort + 1;
await _trackTemplateRepository.InsertContentAsync(entity); await _trackTemplateRepository.InsertContentAsync(entity);
break; break;
} }
case OptionTypeNoNull.修改: case OptionTypeNoNull.修改:
{ {
var entity = await _trackTemplateRepository.GetContentByIdAsync(input.Id!.Value) ?? var entity = await _trackTemplateRepository.GetContentByIdAsync(input.Id!.Value) ??
throw new BusinessException(message: _stringLocalizer["NotFindData"]); 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.删除: 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) ?? await _trackTemplateRepository.SoftDeleteContentAsync(input.Id!.Value);
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
using (var ts = TransactionScopeHelper.Create()) await _trackTemplateRepository.UpdateContentAsync(x => x.Sort == x.Sort - 1,
{ x => x.TrackTemplateId == entity.TrackTemplateId && x.Sort > entity.Sort);
await _trackTemplateRepository.SoftDeleteContentAsync(input.Id!.Value);
await _trackTemplateRepository.UpdateContentAsync(x => x.Sort == x.Sort - 1, x => x.TrackTemplateId == entity.TrackTemplateId && x.Sort > entity.Sort); ts.Complete();
ts.Complete();
}
break;
} }
break;
}
default: default:
throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum, throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum,
nameof(EditTrackTemplateContentInput.Options)]); nameof(EditTrackTemplateContentInput.Options)]);

View File

@ -29,4 +29,10 @@ public class TrackTemplateEntity : IFullAuditedBasicEntitys, IAggregateRoot
/// </summary> /// </summary>
[SugarColumn(ColumnName = "SubSystemId")] [SugarColumn(ColumnName = "SubSystemId")]
public int SubSystemId { get; set; } 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> /// </summary>
public string Code { get; set; } public string Code { get; set; }
/// <summary>
/// 显示原轨迹
/// </summary>
public bool ShowOrigin { get; set; }
} }
/// <summary> /// <summary>
@ -59,7 +64,7 @@ public class GetTrackTemplateListVO
/// <summary> /// <summary>
/// 子系统id /// 子系统id
/// </summary> /// </summary>
public int SubSystemId { set; get; } public int SubSystemId { set; get; }
/// <summary> /// <summary>
/// 创建时间 /// 创建时间

View File

@ -24,13 +24,14 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
.Where((a, b) => a.Id == id) .Where((a, b) => a.Id == id)
.Select((a, b) => new .Select((a, b) => new
GetTrackTemplateDetailVO GetTrackTemplateDetailVO
{ {
Id = a.Id, Id = a.Id,
Code = a.Code, Code = a.Code,
Name = a.Name, Name = a.Name,
SubSystemId = a.SubSystemId, SubSystemId = a.SubSystemId,
SubSystem = b.CnName SubSystem = b.CnName,
}).FirstAsync(); ShowOrigin = a.ShowOrigin
}).FirstAsync();
return detail; return detail;
} }
@ -48,7 +49,9 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(), .WhereIF(!input.Keywords.IsNullOrWhiteSpace(),
(a, b) => a.Name.Contains(input.Keywords) || a.Code.Contains(input.Keywords)) (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) => 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 .Select((a, b) => new GetTrackTemplateListVO
{ {
Id = a.Id, Id = a.Id,
@ -69,7 +72,8 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
/// 获取轨迹内容属性值 /// 获取轨迹内容属性值
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<GetTemplateContentAttributeValueVO> GetTrackContentAttributeValue(GetTemplateContentAttributeValueInputVO input) public async Task<GetTemplateContentAttributeValueVO> GetTrackContentAttributeValue(
GetTemplateContentAttributeValueInputVO input)
{ {
return null; return null;
} }
@ -94,7 +98,8 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
(templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) => (templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) =>
templateContent.UpdateUserId == updateUser.Id && !updateUser.IsDeleted) templateContent.UpdateUserId == updateUser.Id && !updateUser.IsDeleted)
.Filter(null, true) .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) => .Select((templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) =>
new GetTrackTemplateContentPageOutputVO new GetTrackTemplateContentPageOutputVO
{ {
@ -174,13 +179,16 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
return await Context.Updateable(updateObjs).ExecuteCommandHasChangeAsync(); 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); 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();
} }
} }