using AngleSharp.Dom; using Mapster; using Masuit.Tools; using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; using SqlSugar; using System.Collections; using System.Collections.Generic; using System.Drawing.Printing; using System.Linq.Expressions; using System.Threading.Tasks; using WIDESEA_Cache; using WIDESEA_Common; using WIDESEA_Core; using WIDESEA_Core.Enums; namespace WIDESEA_StorageBasicService; public class StockInfoHtyService : ServiceBase, IStockInfoHtyService { private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository; public StockInfoHtyService(IStockInfoHtyRepository BaseDal, ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository) : base(BaseDal) { _locationStatusChangeRecordRepository = locationStatusChangeRecordRepository; } /// /// 分页 /// /// /// 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 { } } Expression> materielCode = null; foreach (var item in searchParametersList) { if (item.Name.Contains("materielCode")) { materielCode = x => x.StockInfoDetails.Any(d => d.MaterielCode == item.Value); } } var data = BaseDal.Db.Queryable() .Includes(x => x.StockInfoDetails) .Where(x=>x.CreateDate>DateTime.Now.AddMonths(-1)) .WhereIF(!wheres.IsNullOrEmpty(), wheres) .WhereIF(materielCode != null, materielCode) .OrderBy(orderByModels) .ToPageList(options.Page, options.Rows, ref totalCount); return new PageGridData(totalCount, data); } }