pan
8 天以前 cd7253920c5e597f6a8eefe813dd039bf1a5894b
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_AllocateService/AllocateDetailService.cs
@@ -15,37 +15,72 @@
{
    public class AllocateDetailService : ServiceBase<Dt_AllocateOrderDetail, IRepository<Dt_AllocateOrderDetail>>, IAllocateDetailService
    {
        public AllocateDetailService(IRepository<Dt_AllocateOrderDetail> BaseDal) : base(BaseDal)
        public readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository;
        public AllocateDetailService(IRepository<Dt_AllocateOrderDetail> BaseDal, IRepository<Dt_AllocateOrder> allocateOrderRepository) : base(BaseDal)
        {
            _allocateOrderRepository = allocateOrderRepository;
        }
        IRepository<Dt_AllocateOrderDetail> IAllocateDetailService.Repository => BaseDal;
        public override PageGridData<Dt_AllocateOrderDetail> GetPageData(PageDataOptions options)
        public override PageGridData<Dt_OutboundOrderDetail> GetDetailPage(PageDataOptions options)
        {
            string wheres = ValidatePageOptions(options);
            //鑾峰彇鎺掑簭瀛楁
            Dictionary<string, SqlSugar.OrderByType> orderbyDic = GetPageDataSort(options, TProperties);
            List<OrderByModel> orderByModels = new List<OrderByModel>();
            foreach (var item in orderbyDic)
            {
                OrderByModel orderByModel = new()
                {
                    FieldName = item.Key,
                    OrderByType = item.Value
                };
                orderByModels.Add(orderByModel);
            }
            ISugarQueryable<Dt_AllocateOrderDetail> sugarQueryable1 = BaseDal.Db.Queryable<Dt_AllocateOrderDetail>();
            int totalCount = 0;
            List<SearchParameters> searchParametersList = new List<SearchParameters>();
            if (!string.IsNullOrEmpty(options.Wheres))
            {
                try
                {
                    searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
                    options.Filter = searchParametersList;
                }
                catch { }
            }
            //var data = BaseDal.Db.Queryable<Dt_AllocateOrderDetail>()
            //    .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<Dt_InboundOrder>().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<Dt_AllocateOrderDetail>(totalCount, data);
                List<SearchParameters> searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
                int totalCount = 0;
                if (searchParametersList.Count > 0)
                {
                    {
                        SearchParameters? searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_AllocateOrderDetail.OrderId).FirstLetterToLower());
                        if (searchParameters != null)
                        {
                            sugarQueryable1 = sugarQueryable1.Where(x => x.OrderId == searchParameters.Value.ObjToInt());
                            var dataList = sugarQueryable1.ToPageList(options.Page, options.Rows, ref totalCount);
                            return new PageGridData<Dt_AllocateOrderDetail>(totalCount, dataList);
                        }
                    }
            Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.Id == options.Filter.FirstOrDefault().Value.ObjToInt());
            Dt_OutboundOrder _InboundOrder = SqlSugarHelper.DbWMS.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == allocateOrder.UpperOrderNo).First();
            var data = BaseDal.Db.Queryable<Dt_OutboundOrderDetail>()
                .WhereIF(!_InboundOrder.IsNullOrEmpty(), x => x.OrderId == _InboundOrder.Id)
                .OrderBy(orderByModels)
                .ToPageList(options.Page, options.Rows, ref totalCount);
                }
            }
            return new PageGridData<Dt_AllocateOrderDetail>();
            return new PageGridData<Dt_OutboundOrderDetail>(totalCount, data);
        }
    }
}