using SqlSugar; using System.Linq.Expressions; using WIDESEA_Core; using WIDESEA_Core.BaseRepository; using WIDESEA_Core.BaseServices; using WIDESEA_Core.Helper; using WIDESEA_IOrderRepository; using WIDESEA_IOrderServices; using WIDESEA_IStorageBasicRepository; using WIDESEA_IStorageTaskRepository; using WIDESEA_IStorageTaskServices; using WIDESEA_Model.Models; using WIDESEA_Model.Models.Order; using WIDESEA_StorageBasicRepository; namespace WIDESEA_OrderServices { public class Dt_AllocateOutboundOrderDetailService : ServiceBase, IDt_AllocateOutboundOrderDetailService { private readonly IUnitOfWorkManage _unitOfWorkManage; private readonly IStockInfoDetailRepository _stockInfoDetailRepository; public Dt_AllocateOutboundOrderDetailService(IDt_AllocateOutboundOrderDetailRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoDetailRepository stockInfoDetailRepository) : base(BaseDal) { _unitOfWorkManage = unitOfWorkManage; _stockInfoDetailRepository = stockInfoDetailRepository; } 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 data = BaseDal.Db.Queryable() .WhereIF(!wheres.IsNullOrEmpty(), wheres) .OrderBy(orderByModels) .ToPageList(options.Page, options.Rows, ref totalCount); foreach (var item in data) { var detail = _stockInfoDetailRepository.QueryFirst(x => x.MaterielCode == item.MaterielCode); if (detail != null) { item.Remark = "有库存"; } else { item.Remark = "无库存"; } } return new PageGridData(totalCount, data); } } }