Merge branch 'S01-轨迹中台' of http://192.168.80.50:3000/Dotnet/SJZY.Track.Api into S01-轨迹中台

This commit is contained in:
柳文翔 2024-02-27 20:52:44 +08:00
commit 57c888a448
8 changed files with 85 additions and 13 deletions

View File

@ -14,5 +14,10 @@
/// 关键字
/// </summary>
public string Keywords { get; set; }
/// <summary>
/// 轨迹模版id,轨迹映射的查询使用
/// </summary>
public int TrackTemplateId { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SJZY.Track.Application.Services.TrackStatus
{
public class TrackStatusService
{
}
}

View File

@ -14,7 +14,7 @@ namespace SJZY.Track.Application.Services.TrackTemplates;
/// </summary>
[ApiExplorerSettings(GroupName = "轨迹模版")]
[Route("/Track/Template")]
public class TrackTemplateService : ApplicationService, ITrackTemplateService, IScopedDependency
public class TrackTemplateService : ApplicationService, ITransientDependency
{
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
private readonly ITrackTemplateRepository _trackTemplateRepository;

View File

@ -17,6 +17,7 @@
<Folder Include="TrackPullAggregate\Dtos\" />
<Folder Include="TrackPushAggregate\Dtos\" />
<Folder Include="TrackStatusAggregate\Dtos\" />
<Folder Include="TrackStatusAggregate\Dtos\" />
</ItemGroup>
</Project>

View File

@ -2,4 +2,5 @@
public interface ITrackStatusRepository : IBasicRepository<TrackStatusEntity>
{
}

View File

@ -11,4 +11,14 @@ public class GetPageTrackTemplateVO : PageInfoInput
/// 关键字
/// </summary>
public string Keywords { get; set; }
///// <summary>
///// 是否置顶
///// </summary>
//public bool IsTop { get; set; }=false;
/// <summary>
/// 轨迹模版id
/// </summary>
public int TrackTemplateId { get; set; }
}

View File

@ -4,4 +4,9 @@ namespace SJZY.Track.Repository;
public class TrackStatusRepository : BasicRepository<TrackStatusEntity>, ITrackStatusRepository, IScopedDependency
{
public TrackStatusRepository()
{
}
}

View File

@ -1,4 +1,5 @@
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.Expand.ABP.Core.Common.Dto;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.Track.Domain.TrackContentAggregate;
using SJZY.Track.Domain.TrackFlagAggregate;
using SJZY.Track.Domain.TrackStatusAggregate;
@ -47,18 +48,54 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
/// <returns></returns>
public async Task<UnifyPageResultDto<GetTrackTemplateListVO>> GetPageTrackTemplate(GetPageTrackTemplateVO input)
{
var pagedList = await Context.Queryable<TrackTemplateEntity>().LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
.WhereIF(input.SubSystemId > 0, (a, b) => a.SubSystemId == input.SubSystemId)
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (a, b) => a.Name.Contains(input.Keywords) || a.Code.Contains(input.Keywords))
.Select((a, b) => new GetTrackTemplateListVO
UnifyPageResultDto<GetTrackTemplateListVO> pagedList = new UnifyPageResultDto<GetTrackTemplateListVO>();
pagedList = await Context.Queryable<TrackTemplateEntity>().LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
.WhereIF(input.SubSystemId > 0, (a, b) => a.SubSystemId == input.SubSystemId)
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (a, b) => a.Name.Contains(input.Keywords) || a.Code.Contains(input.Keywords))
.Select((a, b) => new GetTrackTemplateListVO
{
Id = a.Id,
Code = a.Code,
CreateTime = a.CreateTime,
Name = a.Name,
SubSystem = b.CnName
})
.ToPagedListAsync(input.PageIndex, input.PageSize);
//如果轨迹模版id传值了,就置顶在第一条
if (input.TrackTemplateId>0&& (!pagedList.List.IsNullOrEmpty()))
{
if (input.PageIndex==1)
{
Id = a.Id,
Code = a.Code,
CreateTime = a.CreateTime,
Name = a.Name,
SubSystem = b.CnName
})
.ToPagedListAsync(input.PageIndex, input.PageSize);
bool existCurrent = pagedList.List.Any(x => x.Id==input.TrackTemplateId);
if (existCurrent)
{
var item = pagedList.List.FirstOrDefault(x => x.Id==input.TrackTemplateId);
pagedList.List.Remove(item);
pagedList.List.Insert(0, item);
}
else
{
var item = await Context.Queryable<TrackTemplateEntity>().LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
.Where((a, b) => a.Id==input.TrackTemplateId)
.Select((a, b) => new GetTrackTemplateListVO
{
Id = a.Id,
Code = a.Code,
CreateTime = a.CreateTime,
Name = a.Name,
SubSystem = b.CnName
})
.FirstAsync();
if (item!=null)
{
var removeItem = pagedList.List.LastOrDefault();
pagedList.List.Remove(removeItem);
pagedList.List.Insert(0, item);
}
}
}
}
return pagedList;
}