using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEA_Core; using WIDESEA_Core.BaseRepository; using WIDESEA_Core.BaseServices; using WIDESEA_Core.Helper; using WIDESEA_IAllocateService; using WIDESEA_Model.Models; namespace WIDESEA_AllocateService { public class AllocateDetailService : ServiceBase>, IAllocateDetailService { public readonly IRepository _allocateOrderRepository; public AllocateDetailService(IRepository BaseDal, IRepository allocateOrderRepository) : base(BaseDal) { _allocateOrderRepository = allocateOrderRepository; } IRepository IAllocateDetailService.Repository => BaseDal; public override PageGridData GetDetailPage(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); //Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.Id == (int)options.Value); //Dt_InboundOrder _InboundOrder = SqlSugarHelper.DbWMS.Queryable().Where(x => x.UpperOrderNo == allocateOrder.UpperOrderNo).First(); //var details = _inboundOrderDetailRepository.QueryData(x => x.OrderId == _InboundOrder.Id ); //foreach (var item in data) //{ // var detail = details.Where(x => x.MaterielCode == item.MaterielCode).FirstOrDefault(); // if (detail != null) // { // item.OrderQuantity = detail.OrderQuantity; // item.ReceiptQuantity = detail.ReceiptQuantity; // item.OverInQuantity = detail.OverInQuantity; // item.OrderDetailStatus = detail.OrderDetailStatus; // } //} //return new PageGridData(totalCount, data); Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.Id == options.Filter.FirstOrDefault().Value.ObjToInt()); Dt_OutboundOrder _InboundOrder = SqlSugarHelper.DbWMS.Queryable().Where(x => x.UpperOrderNo == allocateOrder.UpperOrderNo).First(); var data = BaseDal.Db.Queryable() .WhereIF(!_InboundOrder.IsNullOrEmpty(), x => x.OrderId == _InboundOrder.Id) .OrderBy(orderByModels) .ToPageList(options.Page, options.Rows, ref totalCount); return new PageGridData(totalCount, data); } } }