using SJZY.Track.Domain.Aggregates.TrackNodeAggregate; using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; using SJZY.Track.Domain.Dtos.TrackStatus; using SJZY.Track.Domain.VEntities; namespace SJZY.Track.Repository.Repositories; public class TrackStatusRepository : BasicRepository, ITrackStatusRepository, IScopedDependency { /// /// 获取轨迹状态明细 /// /// /// public async Task GetDetailAsync(int id) { var detail = await Context.Queryable() .InnerJoin((a,t)=>a.Node==t.Id) .LeftJoin((a, t,b) => a.SubSystemId == b.Id&&b.IsDeleted==false) .Where((a,t, b) => a.Id == id) .Select((a, t,b) => new GetTrackStatusDetailVO { Id = a.Id, SubSystemId = a.SubSystemId, SubSystem = b.CnName, Code = a.Code, EntrackStatus = a.EnStatus, NodeId = a.Node, TrackStatus = a.Status, NodeName = t.NodeName }) .FirstAsync(); return detail; } /// /// 分页获取轨迹状态 /// /// /// public async Task> GetPageTrackStatus(GetPageTrackStatusVO input) { UnifyPageResultDto pagedList = await Context.Queryable() .LeftJoin((a, b) => a.SubSystemId == b.Id && b.IsDeleted == false) .LeftJoin((a, b, c) => a.CreateUserId == c.Id && c.IsDeleted == false) .LeftJoin((a, b, c, d) => a.UpdateUserId == d.Id && d.IsDeleted == false) .InnerJoin((a, b, c, d,e) => a.Node==e.Id&&a.SubSystemId==e.SubSystemId) .WhereIF(input.SubSystemId > 0, (a, b, c, d) => a.SubSystemId == input.SubSystemId) .WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (a, b, c, d) => a.Status.Contains(input.Keywords) || a.EnStatus.Contains(input.Keywords) || a.Code.Contains(input.Keywords)) .OrderByIF(input.SelectIds.IsNullOrEmpty(), (a, b, c, d) => a.CreateTime, OrderByType.Desc) .OrderByIF(!input.SelectIds.IsNullOrEmpty(), (a, b, c, d) => SqlFunc.IIF(input.SelectIds.Contains(a.Id), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), a.CreateTime), OrderByType.Desc) .Select((a, b, c, d,e) => new GetTrackStatusListVO { Id = a.Id, Code = a.Code, EntrackStatus = a.EnStatus, TrackStatus = a.Status, NodeId = a.Node, Node = e.NodeName!, CreateTime = a.CreateTime, CreateUser = c.Name, UpdateTime = a.UpdateTime, UpdateUser = d.Name, SubSystem = b.CnName }) .ToPagedListAsync(input.PageIndex, input.PageSize); return pagedList; } }