using AngleSharp.Dom; using Mapster; using SqlSugar; using System.Threading.Tasks; using WIDESEA_Common; using WIDESEA_Core; using WIDESEA_DTO; using WIDESEA_Model.Models; namespace WIDESEA_StorageBasicService; public class LocationErrorService : ServiceBase, ILocationErrorService { private readonly IMapper _mapper; public LocationErrorService(ILocationErrorRepository BaseDal,IMapper mapper,IDt_TaskService taskService) : base(BaseDal) { _mapper = mapper; } public override PageGridData GetPageData(PageDataOptions options) { string wheres = ValidatePageOptions(options); //获取排序字段 Dictionary orderbyDic = GetPageDataSort(options, TProperties); List orderByModels = new List(); foreach (var item in orderbyDic) { OrderByModel orderByModel = new() { FieldName = item.Key, OrderByType = item.Value }; orderByModels.Add(orderByModel); } int totalCount = 0; List searchParametersList = new List(); if (!string.IsNullOrEmpty(options.Wheres)) { try { searchParametersList = options.Wheres.DeserializeObject>(); options.Filter = searchParametersList; } catch { } } var now = DateTime.Now; // 使用Subtract方法 var threeHoursAgo = now.Subtract(TimeSpan.FromHours(3)); var data = BaseDal.Db.Queryable() .Where(x => x.LocationStatus != 2 && x.LocationStatus != 0) .Where(x => x.EnalbeStatus != 1) .WhereIF(!wheres.IsNullOrEmpty(), wheres) .OrderBy(orderByModels) .ToPageList(options.Page, options.Rows, ref totalCount); return new PageGridData(totalCount, data); } }