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() .LeftJoin((a, b) => a.SubSystemId == b.Id) .Where((a, b) => a.Id == id) .Select((a, b) => new GetTrackStatusDetailVO { Id = a.Id, SubSystemId = a.SubSystemId, SubSystem = b.CnName, Code = a.Code, EntrackStatus = a.EnStatus, NodeId = a.Node, TrackStatus = a.Status }) .FirstAsync(); return detail; } /// /// 分页获取轨迹状态 /// /// /// public async Task> GetPageTrackStatus(GetPageTrackStatusVO input) { UnifyPageResultDto pagedList = await Context.Queryable() .LeftJoin((a, b) => a.SubSystemId == b.Id) .LeftJoin((a, b, c) => a.CreateUserId == c.Id) .LeftJoin((a, b, c, d) => a.UpdateUserId == d.Id) .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) => SqlFunc.IIF(input.SelectIds.Contains(a.Id), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), a.CreateTime), OrderByType.Desc) .Select((a, b, c, d) => new GetTrackStatusListVO { Id = a.Id, Code = a.Code, EntrackStatus = a.EnStatus, TrackStatus = a.Status, NodeId = a.Node, Node = SqlFunc.IF(a.Node == 1).Return("揽收").ElseIF(a.Node == 2).Return("干线").ElseIF(a.Node == 3) .Return("清关") .ElseIF(a.Node == 4).Return("中转").ElseIF(a.Node == 5).Return("派送") .End(""), CreateTime = a.CreateTime, CreateUser = c.Name, UpdateTime = a.UpdateTime, UpdateUser = d.Name, SubSystem = b.CnName }) .ToPagedListAsync(input.PageIndex, input.PageSize); return pagedList; } }